Compare
88d06b1c911e8491029ef24e96e3f412ce24c2ae..a018953688f1b10bddf91bff8747068f5f4746a4
Git 2.56
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> ยท 2026-09-28 04:20 UTC
247 files changed,
+10989
โ4187
- .b4-config
- .b4-cover-template
- .gitattributes
- .github/workflows/main.yml
- .gitignore
- .gitlab-ci.yml
- .mailmap
- .tsan-suppressions
- Documentation/BreakingChanges.adoc
- Documentation/CodingGuidelines
- Documentation/Makefile
- Documentation/MyFirstContribution.adoc
- Documentation/RelNotes/2.55.0.adoc
- Documentation/RelNotes/2.56.0.adoc
- Documentation/SubmittingPatches
- Documentation/asciidoc.conf.in
- Documentation/config.adoc
- Documentation/config/advice.adoc
- Documentation/config/am.adoc
- Documentation/config/apply.adoc
- Documentation/config/bitmap-pseudo-merge.adoc
- Documentation/config/branch.adoc
- Documentation/config/core.adoc
- Documentation/config/difftool.adoc
- Documentation/config/fetch.adoc
- Documentation/config/format.adoc
- Documentation/config/fsmonitor--daemon.adoc
- Documentation/config/grep.adoc
- Documentation/config/hook.adoc
- Documentation/config/http.adoc
- Documentation/config/imap.adoc
- Documentation/config/log.adoc
- Documentation/config/maintenance.adoc
- Documentation/config/mergetool.adoc
- Documentation/config/promisor.adoc
- Documentation/config/push.adoc
- Documentation/config/remote.adoc
- Documentation/config/repack.adoc
- Documentation/config/replay.adoc
- Documentation/config/safe.adoc
- Documentation/config/sendemail.adoc
- Documentation/config/sideband.adoc
- Documentation/config/worktree.adoc
- Documentation/date-formats.adoc
- Documentation/diff-format.adoc
- Documentation/diff-options.adoc
- Documentation/fetch-options.adoc
- Documentation/format-patch-caveats.adoc
- Documentation/format-patch-end-of-commit-message.adoc
- Documentation/git-add.adoc
- Documentation/git-am.adoc
- Documentation/git-apply.adoc
- Documentation/git-backfill.adoc
- Documentation/git-bisect.adoc
- Documentation/git-blame.adoc
- Documentation/git-branch.adoc
- Documentation/git-cat-file.adoc
- Documentation/git-checkout.adoc
- Documentation/git-cherry-pick.adoc
- Documentation/git-commit-graph.adoc
- Documentation/git-config.adoc
- Documentation/git-describe.adoc
- Documentation/git-difftool.adoc
- Documentation/git-fast-export.adoc
- Documentation/git-fast-import.adoc
- Documentation/git-format-patch.adoc
- Documentation/git-format-rev.adoc
- Documentation/git-fsmonitor--daemon.adoc
- Documentation/git-grep.adoc
- Documentation/git-history.adoc
- Documentation/git-hook.adoc
- Documentation/git-http-fetch.adoc
- Documentation/git-imap-send.adoc
- Documentation/git-interpret-trailers.adoc
- Documentation/git-log.adoc
- Documentation/git-ls-files.adoc
- Documentation/git-multi-pack-index.adoc
- Documentation/git-pack-objects.adoc
- Documentation/git-pack-refs.adoc
- Documentation/git-push.adoc
- Documentation/git-range-diff.adoc
- Documentation/git-refs.adoc
- Documentation/git-repack.adoc
- Documentation/git-replace.adoc
- Documentation/git-replay.adoc
- Documentation/git-repo.adoc
- Documentation/git-request-pull.adoc
- Documentation/git-restore.adoc
- Documentation/git-send-email.adoc
- Documentation/git-shortlog.adoc
- Documentation/git-sparse-checkout.adoc
- Documentation/git-stash.adoc
- Documentation/git-svn.adoc
- Documentation/git-switch.adoc
- Documentation/git-url-parse.adoc
- Documentation/git-worktree.adoc
- Documentation/git.adoc
- Documentation/gitattributes.adoc
- Documentation/gitdatamodel.adoc
- Documentation/gitformat-index.adoc
- Documentation/gitglossary.adoc
- Documentation/gitignore.adoc
- Documentation/gitpacking.adoc
- Documentation/gitprotocol-v2.adoc
- Documentation/glossary-content.adoc
- Documentation/line-range-options.adoc
- Documentation/lint-gitlink.perl
- Documentation/meson.build
- Documentation/pack-refs-options.adoc
- Documentation/rev-list-options.adoc
- Documentation/revisions.adoc
- Documentation/technical/api-parse-options.adoc
- Documentation/technical/api-path-walk.adoc
- Documentation/technical/build-systems.adoc
- Documentation/technical/hash-function-transition.adoc
- Documentation/technical/meson.build
- Documentation/technical/paint-down-to-common.adoc
- Documentation/technical/partial-clone.adoc
- Documentation/technical/rerere.adoc
- GIT-VERSION-GEN
- Makefile
- README.md
- RelNotes
- advice.c
- advice.h
- apply.c
- archive-tar.c
- archive-zip.c
- archive.c
- attr.c
- bisect.c
- blame.c
- bloom.c
- branch.c
- branch.h
- builtin.h
- builtin/add.c
- builtin/am.c
- builtin/archive.c
- builtin/backfill.c
- builtin/bisect.c
- builtin/blame.c
- builtin/branch.c
- builtin/bundle.c
- builtin/cat-file.c
- builtin/check-attr.c
- builtin/check-ref-format.c
- builtin/checkout-index.c
- builtin/checkout.c
- builtin/clone.c
- builtin/commit.c
- builtin/config.c
- builtin/describe.c
- builtin/diff-index.c
- builtin/diff.c
- builtin/difftool.c
- builtin/fast-export.c
- builtin/fast-import.c
- builtin/fetch-pack.c
- builtin/fetch.c
- builtin/fsck.c
- builtin/fsmonitor--daemon.c
- builtin/gc.c
- builtin/grep.c
- builtin/hash-object.c
- builtin/help.c
- builtin/history.c
- builtin/hook.c
- builtin/index-pack.c
- builtin/init-db.c
- builtin/last-modified.c
- builtin/log.c
- builtin/ls-files.c
- builtin/ls-tree.c
- builtin/mailsplit.c
- builtin/merge-base.c
- builtin/merge-file.c
- builtin/merge-tree.c
- builtin/merge.c
- builtin/mktag.c
- builtin/mktree.c
- builtin/multi-pack-index.c
- builtin/mv.c
- builtin/name-rev.c
- builtin/notes.c
- builtin/pack-objects.c
- builtin/patch-id.c
- builtin/prune.c
- builtin/pull.c
- builtin/push.c
- builtin/read-tree.c
- builtin/rebase.c
- builtin/receive-pack.c
- builtin/reflog.c
- builtin/refs.c
- builtin/repack.c
- builtin/replace.c
- builtin/replay.c
- builtin/repo.c
- builtin/reset.c
- builtin/rev-list.c
- builtin/rev-parse.c
- builtin/rm.c
- builtin/send-pack.c
- builtin/shortlog.c
- builtin/show-branch.c
- builtin/sparse-checkout.c
- builtin/stash.c
- builtin/stripspace.c
- builtin/submodule--helper.c
- builtin/tag.c
- builtin/unpack-file.c
- builtin/unpack-objects.c
- builtin/update-index.c
- builtin/update-ref.c
- builtin/upload-archive.c
- builtin/upload-pack.c
- builtin/url-parse.c
- builtin/worktree.c
- bundle-uri.c
- bundle.c
- bundle.h
- cache-tree.c
- cache-tree.h
- cbtree.c
- cbtree.h
- chdir-notify.c
- chdir-notify.h
- checkout.c
- checkout.h
- ci/install-dependencies.ps1
- ci/install-dependencies.sh
- ci/lib.sh
- ci/run-build-and-minimal-fuzzers.sh
- ci/run-build-and-tests.sh
- combine-diff.c
- command-list.txt
- commit-graph.c
- commit-graph.h
- commit-reach.c
- commit-reach.h
- commit.c
- commit.h
- common-init.c
- compat/fsmonitor/fsm-health-linux.c
- compat/fsmonitor/fsm-ipc-darwin.c โ compat/fsmonitor/fsm-ipc-unix.c
- compat/fsmonitor/fsm-listen-linux.c
added .b4-config mode 100644
| @@ -0,0 +1,6 @@ | |||
| 1 | + | # Note that these are default values that you can tweak via the typical | |
| 2 | + | # git-config(1) machinery. You thus shouldn't ever have to change this file. | |
| 3 | + | # See also https://b4.docs.kernel.org/en/latest/config.html. | |
| 4 | + | [b4] | |
| 5 | + | send-same-thread = shallow | |
| 6 | + | prep-cover-template = ./.b4-cover-template | |
added .b4-cover-template mode 100644
| @@ -0,0 +1,12 @@ | |||
| 1 | + | ${cover} | |
| 2 | + | ||
| 3 | + | --- | |
| 4 | + | ${shortlog} | |
| 5 | + | ||
| 6 | + | ${diffstat} | |
| 7 | + | ||
| 8 | + | ${range_diff} | |
| 9 | + | --- | |
| 10 | + | base-commit: ${base_commit} | |
| 11 | + | change-id: ${change_id} | |
| 12 | + | ${prerequisites} | |
modified .gitattributes
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | *.[ch] whitespace=indent,trail,space,incomplete diff=cpp | |
| 3 | 3 | *.sh whitespace=indent,trail,space,incomplete text eol=lf | |
| 4 | 4 | *.perl text eol=lf diff=perl | |
| 5 | - | *.pl text eof=lf diff=perl | |
| 5 | + | *.pl text eol=lf diff=perl | |
| 6 | 6 | *.pm text eol=lf diff=perl | |
| 7 | 7 | *.py text eol=lf diff=python | |
| 8 | 8 | *.bat text eol=crlf | |
modified .github/workflows/main.yml
| @@ -5,18 +5,20 @@ on: [push, pull_request] | |||
| 5 | 5 | env: | |
| 6 | 6 | DEVELOPER: 1 | |
| 7 | 7 | ||
| 8 | - | # If more than one workflow run is triggered for the very same commit hash | |
| 9 | - | # (which happens when multiple branches pointing to the same commit), only | |
| 10 | - | # the first one is allowed to run, the second will be kept in the "queued" | |
| 11 | - | # state. This allows a successful completion of the first run to be reused | |
| 12 | - | # in the second run via the `skip-if-redundant` logic in the `config` job. | |
| 8 | + | # For pull requests, only the latest workflow run is allowed to proceed. | |
| 9 | + | # Older runs are canceled when a new revision is pushed. | |
| 13 | 10 | # | |
| 14 | - | # The only caveat is that if a workflow run is triggered for the same commit | |
| 15 | - | # hash that another run is already being held, that latter run will be | |
| 16 | - | # canceled. For more details about the `concurrency` attribute, see: | |
| 11 | + | # For pushes, if more than one workflow run is triggered for the very same | |
| 12 | + | # commit hash (which happens when multiple branches point to the same commit), | |
| 13 | + | # only the first one is allowed to run. This allows a successful completion of | |
| 14 | + | # the first run to be reused in the second run via the `skip-if-redundant` | |
| 15 | + | # logic in the `config` job. | |
| 16 | + | # | |
| 17 | + | # For more details about the `concurrency` attribute, see: | |
| 17 | 18 | # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency | |
| 18 | 19 | concurrency: | |
| 19 | - | group: ${{ github.sha }} | |
| 20 | + | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| 21 | + | cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| 20 | 22 | ||
| 21 | 23 | jobs: | |
| 22 | 24 | ci-config: | |
| @@ -114,6 +116,30 @@ jobs: | |||
| 114 | 116 | steps: | |
| 115 | 117 | - uses: actions/checkout@v6 | |
| 116 | 118 | - uses: git-for-windows/setup-git-for-windows-sdk@v2 | |
| 119 | + | - name: Install GCC-compatible Rust target | |
| 120 | + | shell: bash | |
| 121 | + | run: | | |
| 122 | + | # The hosted Windows runners ship a rustup-managed Rust whose | |
| 123 | + | # default toolchain targets the MSVC ABI. That produces a | |
| 124 | + | # `gitcore.lib` which the MinGW GCC used by the rest of the | |
| 125 | + | # build cannot link. Install the precompiled `std` for a | |
| 126 | + | # GCC-compatible target triple matching the MSYS2 subsystem; | |
| 127 | + | # the Makefile selects the same triple via $(MSYSTEM) and | |
| 128 | + | # passes it to `cargo build --target`. | |
| 129 | + | case "$MSYSTEM" in | |
| 130 | + | CLANGARM64) target=aarch64-pc-windows-gnullvm ;; | |
| 131 | + | CLANG64) target=x86_64-pc-windows-gnullvm ;; | |
| 132 | + | CLANG32) target=i686-pc-windows-gnullvm ;; | |
| 133 | + | UCRT64) target=x86_64-pc-windows-gnu ;; | |
| 134 | + | MINGW64) target=x86_64-pc-windows-gnu ;; | |
| 135 | + | MINGW32) target=i686-pc-windows-gnu ;; | |
| 136 | + | *) echo "::error::Unsupported MSYSTEM: $MSYSTEM"; exit 1 ;; | |
| 137 | + | esac && | |
| 138 | + | rustup target add "$target" && | |
| 139 | + | ||
| 140 | + | # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH | |
| 141 | + | CARGO="$(type -p cargo.exe)" && | |
| 142 | + | echo "export PATH=\$PATH:${CARGO%/cargo.exe}" >>/etc/profile | |
| 117 | 143 | - name: build | |
| 118 | 144 | shell: bash | |
| 119 | 145 | env: | |
| @@ -407,20 +433,22 @@ jobs: | |||
| 407 | 433 | image: alpine:latest | |
| 408 | 434 | # Supported until 2025-04-02. | |
| 409 | 435 | - jobname: linux32 | |
| 410 | - | image: i386/ubuntu:focal | |
| 436 | + | image: i386/ubuntu:20.04 | |
| 411 | 437 | # A RHEL 8 compatible distro. Supported until 2029-05-31. | |
| 412 | 438 | - jobname: almalinux-8 | |
| 413 | 439 | image: almalinux:8 | |
| 414 | - | # Supported until 2026-08-31. | |
| 415 | - | - jobname: debian-11 | |
| 416 | - | image: debian:11 | |
| 440 | + | # Supported until 2028-06-30. | |
| 441 | + | - jobname: debian-12 | |
| 442 | + | image: debian:12 | |
| 417 | 443 | env: | |
| 418 | 444 | jobname: ${{matrix.vector.jobname}} | |
| 419 | 445 | CC: ${{matrix.vector.cc}} | |
| 420 | 446 | CI_JOB_IMAGE: ${{matrix.vector.image}} | |
| 421 | 447 | CUSTOM_PATH: /custom | |
| 422 | 448 | runs-on: ubuntu-latest | |
| 423 | - | container: ${{matrix.vector.image}} | |
| 449 | + | container: | |
| 450 | + | image: ${{ matrix.vector.image }} | |
| 451 | + | options: ${{ github.repository_visibility == 'private' && '--pids-limit 16384 --ulimit nproc=16384:16384 --ulimit nofile=32768:32768' || '' }} | |
| 424 | 452 | steps: | |
| 425 | 453 | - name: prepare libc6 for actions | |
| 426 | 454 | if: matrix.vector.jobname == 'linux32' | |
| @@ -458,8 +486,8 @@ jobs: | |||
| 458 | 486 | if: needs.ci-config.outputs.enabled == 'yes' | |
| 459 | 487 | env: | |
| 460 | 488 | jobname: StaticAnalysis | |
| 461 | - | CI_JOB_IMAGE: ubuntu-22.04 | |
| 462 | - | runs-on: ubuntu-22.04 | |
| 489 | + | CI_JOB_IMAGE: ubuntu-latest | |
| 490 | + | runs-on: ubuntu-latest | |
| 463 | 491 | concurrency: | |
| 464 | 492 | group: static-analysis-${{ github.ref }} | |
| 465 | 493 | cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }} | |
modified .gitignore
| @@ -71,6 +71,7 @@ | |||
| 71 | 71 | /git-for-each-ref | |
| 72 | 72 | /git-for-each-repo | |
| 73 | 73 | /git-format-patch | |
| 74 | + | /git-format-rev | |
| 74 | 75 | /git-fsck | |
| 75 | 76 | /git-fsck-objects | |
| 76 | 77 | /git-fsmonitor--daemon | |
| @@ -182,6 +183,7 @@ | |||
| 182 | 183 | /git-update-server-info | |
| 183 | 184 | /git-upload-archive | |
| 184 | 185 | /git-upload-pack | |
| 186 | + | /git-url-parse | |
| 185 | 187 | /git-var | |
| 186 | 188 | /git-verify-commit | |
| 187 | 189 | /git-verify-pack | |
modified .gitlab-ci.yml
| @@ -42,15 +42,15 @@ test:linux: | |||
| 42 | 42 | - jobname: linux-reftable | |
| 43 | 43 | image: ubuntu:rolling | |
| 44 | 44 | CC: clang | |
| 45 | - | - jobname: linux-breaking-changes | |
| 46 | - | image: ubuntu:20.04 | |
| 47 | - | CC: gcc | |
| 48 | - | - jobname: fedora-breaking-changes-meson | |
| 49 | - | image: fedora:latest | |
| 50 | 45 | - jobname: linux-TEST-vars | |
| 51 | 46 | image: ubuntu:20.04 | |
| 52 | 47 | CC: gcc | |
| 53 | 48 | CC_PACKAGE: gcc-8 | |
| 49 | + | - jobname: linux-breaking-changes | |
| 50 | + | image: ubuntu:rolling | |
| 51 | + | CC: gcc | |
| 52 | + | - jobname: fedora-breaking-changes-meson | |
| 53 | + | image: fedora:latest | |
| 54 | 54 | - jobname: linux-leaks | |
| 55 | 55 | image: ubuntu:rolling | |
| 56 | 56 | CC: gcc | |
| @@ -60,13 +60,20 @@ test:linux: | |||
| 60 | 60 | - jobname: linux-asan-ubsan | |
| 61 | 61 | image: ubuntu:rolling | |
| 62 | 62 | CC: clang | |
| 63 | + | - jobname: linux-meson | |
| 64 | + | image: ubuntu:rolling | |
| 65 | + | CC: gcc | |
| 63 | 66 | - jobname: linux-musl-meson | |
| 64 | 67 | image: alpine:latest | |
| 68 | + | # Supported until 2025-04-02. | |
| 65 | 69 | - jobname: linux32 | |
| 66 | 70 | image: i386/ubuntu:20.04 | |
| 67 | - | - jobname: linux-meson | |
| 68 | - | image: ubuntu:rolling | |
| 69 | - | CC: gcc | |
| 71 | + | # A RHEL 8 compatible distro. Supported until 2029-05-31. | |
| 72 | + | - jobname: almalinux-8 | |
| 73 | + | image: almalinux:8 | |
| 74 | + | # Supported until 2028-06-30. | |
| 75 | + | - jobname: debian-12 | |
| 76 | + | image: debian:12 | |
| 70 | 77 | artifacts: | |
| 71 | 78 | paths: | |
| 72 | 79 | - t/failed-test-artifacts | |
| @@ -79,15 +86,10 @@ test:osx: | |||
| 79 | 86 | stage: test | |
| 80 | 87 | needs: [ ] | |
| 81 | 88 | tags: | |
| 82 | - | - saas-macos-medium-m1 | |
| 89 | + | - saas-macos-large-m2pro | |
| 83 | 90 | variables: | |
| 84 | - | TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk" | |
| 91 | + | TEST_OUTPUT_DIRECTORY: "/tmp/test-output" | |
| 85 | 92 | before_script: | |
| 86 | - | # Create a 4GB RAM disk that we use to store test output on. This small hack | |
| 87 | - | # significantly speeds up tests by more than a factor of 2 because the | |
| 88 | - | # macOS runners use network-attached storage as disks, which is _really_ | |
| 89 | - | # slow with the many small writes that our tests do. | |
| 90 | - | - sudo diskutil apfs create $(hdiutil attach -nomount ram://8192000) RAMDisk | |
| 91 | 93 | - ./ci/install-dependencies.sh | |
| 92 | 94 | script: | |
| 93 | 95 | - ./ci/run-build-and-tests.sh | |
| @@ -104,10 +106,10 @@ test:osx: | |||
| 104 | 106 | image: macos-15-xcode-16 | |
| 105 | 107 | CC: clang | |
| 106 | 108 | - jobname: osx-reftable | |
| 107 | - | image: macos-15-xcode-16 | |
| 109 | + | image: macos-26-xcode-26 | |
| 108 | 110 | CC: clang | |
| 109 | 111 | - jobname: osx-meson | |
| 110 | - | image: macos-15-xcode-16 | |
| 112 | + | image: macos-26-xcode-26 | |
| 111 | 113 | CC: clang | |
| 112 | 114 | artifacts: | |
| 113 | 115 | paths: | |
| @@ -145,6 +147,9 @@ test:mingw64: | |||
| 145 | 147 | needs: | |
| 146 | 148 | - job: "build:mingw64" | |
| 147 | 149 | artifacts: true | |
| 150 | + | variables: | |
| 151 | + | # Windows runners don't have enough RAM to run EXPENSIVE tests. | |
| 152 | + | GIT_TEST_LONG: false | |
| 148 | 153 | before_script: | |
| 149 | 154 | - *windows_before_script | |
| 150 | 155 | - git-sdk/usr/bin/bash.exe -l -c 'tar xf artifacts/artifacts.tar.gz' | |
| @@ -161,11 +166,16 @@ test:mingw64: | |||
| 161 | 166 | TEST_OUTPUT_DIRECTORY: "C:/Git-Test" | |
| 162 | 167 | tags: | |
| 163 | 168 | - saas-windows-medium-amd64 | |
| 169 | + | cache: | |
| 170 | + | key: | |
| 171 | + | files: | |
| 172 | + | - ci/install-dependencies.ps1 | |
| 173 | + | paths: | |
| 174 | + | - .dependencies | |
| 164 | 175 | before_script: | |
| 165 | 176 | - *windows_before_script | |
| 166 | - | - choco install -y git meson ninja rust-ms | |
| 167 | - | - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 | |
| 168 | - | - refreshenv | |
| 177 | + | - ./ci/install-dependencies.ps1 | |
| 178 | + | - $env:Path = "C:\Meson;C:\Rust\bin;$env:Path" | |
| 169 | 179 | - New-Item -Path $env:TEST_OUTPUT_DIRECTORY -ItemType Directory | |
| 170 | 180 | ||
| 171 | 181 | build:msvc-meson: | |
| @@ -188,6 +198,9 @@ test:msvc-meson: | |||
| 188 | 198 | script: | |
| 189 | 199 | - | | |
| 190 | 200 | & "C:/Program Files/Git/usr/bin/bash.exe" -l -c 'ci/run-test-slice-meson.sh build $CI_NODE_INDEX $CI_NODE_TOTAL' | |
| 201 | + | variables: | |
| 202 | + | # Windows runners don't have enough RAM to run EXPENSIVE tests. | |
| 203 | + | GIT_TEST_LONG: false | |
| 191 | 204 | after_script: | |
| 192 | 205 | - | | |
| 193 | 206 | if ($env:CI_JOB_STATUS -ne "success") { | |
| @@ -214,7 +227,7 @@ test:fuzz-smoke-tests: | |||
| 214 | 227 | - ./ci/run-build-and-minimal-fuzzers.sh | |
| 215 | 228 | ||
| 216 | 229 | static-analysis: | |
| 217 | - | image: ubuntu:22.04 | |
| 230 | + | image: ubuntu:latest | |
| 218 | 231 | stage: analyze | |
| 219 | 232 | needs: [ ] | |
| 220 | 233 | variables: | |
modified .mailmap
| @@ -39,12 +39,13 @@ Chris Shoemaker <c.shoemaker@cox.net> | |||
| 39 | 39 | Chris Wright <chrisw@sous-sol.org> <chrisw@osdl.org> | |
| 40 | 40 | Christian Ludwig <chrissicool@gmail.com> <chrissicool@googlemail.com> | |
| 41 | 41 | Cord Seele <cowose@gmail.com> <cowose@googlemail.com> | |
| 42 | - | Christian Couder <chriscool@tuxfamily.org> <christian.couder@gmail.com> | |
| 42 | + | Christian Couder <christian.couder@gmail.com> <chriscool@tuxfamily.org> | |
| 43 | 43 | Christian Stimming <stimming@tuhh.de> <chs@ckiste.goetheallee> | |
| 44 | 44 | Christopher Dรญaz Riveros <chrisadr@gentoo.org> Christopher Diaz Riveros | |
| 45 | 45 | Clemens Buchacher <drizzd@gmx.net> <drizzd@aon.at> | |
| 46 | 46 | Clemens Buchacher <drizzd@gmx.net> <clemens.buchacher@intel.com> | |
| 47 | 47 | Csaba Henk <csaba@gluster.com> <csaba@lowlife.hu> | |
| 48 | + | D. Ben Knoble <ben.knoble@gmail.com> <ben.knoble+github@gmail.com> | |
| 48 | 49 | Dan Johnson <computerdruid@gmail.com> | |
| 49 | 50 | Dana L. How <danahow@gmail.com> <how@deathvalley.cswitch.com> | |
| 50 | 51 | Dana L. How <danahow@gmail.com> Dana How | |
| @@ -65,6 +66,8 @@ Derrick Stolee <stolee@gmail.com> <dstolee@microsoft.com> | |||
| 65 | 66 | Deskin Miller <deskinm@umich.edu> | |
| 66 | 67 | ฤoร n Trแบงn Cรดng Danh <congdanhqx@gmail.com> Doan Tran Cong Danh | |
| 67 | 68 | Dirk Sรผsserott <newsletter@dirk.my1.cc> | |
| 69 | + | Elijah Newren <newren@gmail.com> <newren@palantir.com> | |
| 70 | + | Elijah Newren <newren@gmail.com> <newren@github.com> | |
| 68 | 71 | Emily Shaffer <nasamuffin@google.com> <emilyshaffer@google.com> | |
| 69 | 72 | Eric Blake <eblake@redhat.com> <ebb9@byu.net> | |
| 70 | 73 | Eric Hanchrow <eric.hanchrow@gmail.com> <offby1@blarg.net> | |
| @@ -277,6 +280,7 @@ Sven Verdoolaege <skimo@kotnet.org> <skimo@liacs.nl> | |||
| 277 | 280 | SZEDER Gรกbor <szeder.dev@gmail.com> <szeder@ira.uka.de> | |
| 278 | 281 | Tao Qingyun <taoqy@ls-a.me> <845767657@qq.com> | |
| 279 | 282 | Tay Ray Chuan <rctay89@gmail.com> | |
| 283 | + | Taylor Blau <me@ttaylorr.com> <ttaylorr@openai.com> | |
| 280 | 284 | Ted Percival <ted@midg3t.net> <ted.percival@quest.com> | |
| 281 | 285 | Theodore Ts'o <tytso@mit.edu> | |
| 282 | 286 | Thomas Ackermann <th.acker@arcor.de> <th.acker66@arcor.de> | |
| @@ -308,6 +312,7 @@ YONETANI Tomokazu <y0n3t4n1@gmail.com> <qhwt+git@les.ath.cx> | |||
| 308 | 312 | YONETANI Tomokazu <y0n3t4n1@gmail.com> <y0netan1@dragonflybsd.org> | |
| 309 | 313 | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | |
| 310 | 314 | Yi-Jyun Pan <pan93412@gmail.com> | |
| 315 | + | Yoichi NAKAYAMA <yoichi.nakayama@gmail.com> | |
| 311 | 316 | # the two anonymous contributors are different persons: | |
| 312 | 317 | anonymous <linux@horizon.com> | |
| 313 | 318 | anonymous <linux@horizon.net> | |
modified .tsan-suppressions
| @@ -7,7 +7,6 @@ | |||
| 7 | 7 | # A static variable is written to racily, but we always write the same value, so | |
| 8 | 8 | # in practice it (hopefully!) doesn't matter. | |
| 9 | 9 | race:^want_color$ | |
| 10 | - | race:^transfer_debug$ | |
| 11 | 10 | ||
| 12 | 11 | # A boolean value, which tells whether the replace_map has been initialized or | |
| 13 | 12 | # not, is read racily with an update. As this variable is written to only once, | |
modified Documentation/BreakingChanges.adoc
| @@ -216,6 +216,30 @@ would be significant, we may decide to defer this change to a subsequent minor | |||
| 216 | 216 | release. This evaluation will also take into account our own experience with | |
| 217 | 217 | how painful it is to keep Rust an optional component. | |
| 218 | 218 | ||
| 219 | + | * The default value of `safe.bareRepository` will change from `all` to | |
| 220 | + | `explicit`. It is all too easy for an attacker to trick a user into cloning a | |
| 221 | + | repository that contains an embedded bare repository with malicious hooks | |
| 222 | + | configured. If the user enters that subdirectory and runs any Git command, Git | |
| 223 | + | discovers the bare repository and the hooks fire. The user does not even need | |
| 224 | + | to run a Git command explicitly: many shell prompts run `git status` in the | |
| 225 | + | background to display branch and dirty state information, and `git status` in | |
| 226 | + | turn may invoke the fsmonitor hook if so configured, making the user | |
| 227 | + | vulnerable the moment they `cd` into the directory. The `safe.bareRepository` | |
| 228 | + | configuration variable was introduced in 8959555cee (setup_git_directory(): | |
| 229 | + | add an owner check for the top-level directory, 2022-03-02) with a default of | |
| 230 | + | `all` to preserve backwards compatibility. | |
| 231 | + | + | |
| 232 | + | Changing the default to `explicit` means that Git will refuse to work with bare | |
| 233 | + | repositories that are discovered implicitly by walking up the directory tree. | |
| 234 | + | Bare repositories specified explicitly via the `--git-dir` command-line option | |
| 235 | + | or the `GIT_DIR` environment variable continue to work regardless of this | |
| 236 | + | setting. Repositories that look like a `.git` directory, a worktree, or a | |
| 237 | + | submodule directory are also unaffected. | |
| 238 | + | + | |
| 239 | + | Users who rely on implicit discovery of bare repositories can restore the | |
| 240 | + | previous behavior by setting `safe.bareRepository=all` in their global or | |
| 241 | + | system configuration. | |
| 242 | + | ||
| 219 | 243 | === Removals | |
| 220 | 244 | ||
| 221 | 245 | * Support for grafting commits has long been superseded by git-replace(1). | |
modified Documentation/CodingGuidelines
| @@ -693,6 +693,12 @@ For C programs: | |||
| 693 | 693 | char *dogs[] = ...; | |
| 694 | 694 | walk_all_dogs(dogs); | |
| 695 | 695 | ||
| 696 | + | - For file timestamps, do not use "st_mtim" (and other timestamp | |
| 697 | + | members in "struct stat") unconditionally; not everybody is POSIX | |
| 698 | + | (grep for USE_ST_TIMESPEC). If you only need a timestamp in whole | |
| 699 | + | second resolution, "st_mtime" should work fine everywhere. | |
| 700 | + | ||
| 701 | + | ||
| 696 | 702 | For Perl programs: | |
| 697 | 703 | ||
| 698 | 704 | - Most of the C guidelines above apply. | |
modified Documentation/Makefile
| @@ -129,6 +129,7 @@ TECH_DOCS += technical/long-running-process-protocol | |||
| 129 | 129 | TECH_DOCS += technical/multi-pack-index | |
| 130 | 130 | TECH_DOCS += technical/packfile-uri | |
| 131 | 131 | TECH_DOCS += technical/pack-heuristics | |
| 132 | + | TECH_DOCS += technical/paint-down-to-common | |
| 132 | 133 | TECH_DOCS += technical/parallel-checkout | |
| 133 | 134 | TECH_DOCS += technical/partial-clone | |
| 134 | 135 | TECH_DOCS += technical/platform-support | |
modified Documentation/MyFirstContribution.adoc
| @@ -790,7 +790,7 @@ We can note a few things: | |||
| 790 | 790 | v3", etc. in place of "PATCH". For example, "[PATCH v2 1/3]" would be the first of | |
| 791 | 791 | three patches in the second iteration. Each iteration is sent with a new cover | |
| 792 | 792 | letter (like "[PATCH v2 0/3]" above), itself a reply to the cover letter of the | |
| 793 | - | previous iteration (more on that below). | |
| 793 | + | first iteration (more on that below). | |
| 794 | 794 | ||
| 795 | 795 | NOTE: A single-patch topic is sent with "[PATCH]", "[PATCH v2]", etc. without | |
| 796 | 796 | _i_/_n_ numbering (in the above thread overview, no single-patch topic appears, | |
| @@ -833,7 +833,7 @@ This patchset is part of the MyFirstContribution tutorial and should not | |||
| 833 | 833 | be merged. | |
| 834 | 834 | ---- | |
| 835 | 835 | ||
| 836 | - | At this point the tutorial diverges, in order to demonstrate two | |
| 836 | + | At this point the tutorial diverges, in order to demonstrate three | |
| 837 | 837 | different methods of formatting your patchset and getting it reviewed. | |
| 838 | 838 | ||
| 839 | 839 | The first method to be covered is GitGitGadget, which is useful for those | |
| @@ -845,9 +845,14 @@ more fine-grained control over the emails to be sent. This method requires some | |||
| 845 | 845 | setup which can change depending on your system and will not be covered in this | |
| 846 | 846 | tutorial. | |
| 847 | 847 | ||
| 848 | + | The third method to be covered is `b4`, which builds on top of `git | |
| 849 | + | format-patch` and `git send-email`. This method is the recommended way to | |
| 850 | + | submit patches via mail as it automates a lot of the bookkeeping required by | |
| 851 | + | `git send-email`. | |
| 852 | + | ||
| 848 | 853 | Regardless of which method you choose, your engagement with reviewers will be | |
| 849 | - | the same; the review process will be covered after the sections on GitGitGadget | |
| 850 | - | and `git send-email`. | |
| 854 | + | the same; the review process will be covered after the sections on GitGitGadget, | |
| 855 | + | `git send-email` and `b4`. | |
| 851 | 856 | ||
| 852 | 857 | [[howto-ggg]] | |
| 853 | 858 | == Sending Patches via GitGitGadget | |
| @@ -1214,7 +1219,7 @@ between your last version and now, if it's something significant. You do not | |||
| 1214 | 1219 | need the exact same body in your second cover letter; focus on explaining to | |
| 1215 | 1220 | reviewers the changes you've made that may not be as visible. | |
| 1216 | 1221 | ||
| 1217 | - | You will also need to go and find the Message-ID of your previous cover letter. | |
| 1222 | + | You will also need to go and find the Message-ID of your first cover letter. | |
| 1218 | 1223 | You can either note it when you send the first series, from the output of `git | |
| 1219 | 1224 | send-email`, or you can look it up on the | |
| 1220 | 1225 | https://lore.kernel.org/git[mailing list]. Find your cover letter in the | |
| @@ -1227,8 +1232,8 @@ Message-ID: <foo.12345.author@example.com> | |||
| 1227 | 1232 | ||
| 1228 | 1233 | Your Message-ID is `<foo.12345.author@example.com>`. This example will be used | |
| 1229 | 1234 | below as well; make sure to replace it with the correct Message-ID for your | |
| 1230 | - | **previous cover letter** - that is, if you're sending v2, use the Message-ID | |
| 1231 | - | from v1; if you're sending v3, use the Message-ID from v2. | |
| 1235 | + | **first cover letter** - that is, for any subsequent version that you send, | |
| 1236 | + | always use the Message-ID from v1. | |
| 1232 | 1237 | ||
| 1233 | 1238 | While you're looking at the email, you should also note who is CC'd, as it's | |
| 1234 | 1239 | common practice in the mailing list to keep all CCs on a thread. You can add | |
| @@ -1296,6 +1301,87 @@ index 88f126184c..38da593a60 100644 | |||
| 1296 | 1301 | 2.21.0.392.gf8f6787159e-goog | |
| 1297 | 1302 | ---- | |
| 1298 | 1303 | ||
| 1304 | + | [[howto-b4]] | |
| 1305 | + | == Sending Patches with `b4` | |
| 1306 | + | ||
| 1307 | + | `b4` is a tool that builds on top of `git format-patch` and `git send-email`. | |
| 1308 | + | It automates much of the bookkeeping involved in sending a patch series to a | |
| 1309 | + | mailing-list-based project. | |
| 1310 | + | ||
| 1311 | + | Refer to the https://b4.docs.kernel.org/[b4 documentation] for a full reference. | |
| 1312 | + | ||
| 1313 | + | [[prep-b4]] | |
| 1314 | + | === Preparing a Patch Series | |
| 1315 | + | ||
| 1316 | + | `b4` tracks your patch series as a branch. To start tracking the `psuh` branch | |
| 1317 | + | you have been working on, run: | |
| 1318 | + | ||
| 1319 | + | ---- | |
| 1320 | + | $ b4 prep --enroll master | |
| 1321 | + | ---- | |
| 1322 | + | ||
| 1323 | + | This enrolls the current branch, using `master` as the base of the topic. `b4` | |
| 1324 | + | manages the cover letter as part of the branch, so you can edit it at any time | |
| 1325 | + | with: | |
| 1326 | + | ||
| 1327 | + | ---- | |
| 1328 | + | $ b4 prep --edit-cover | |
| 1329 | + | ---- | |
| 1330 | + | ||
| 1331 | + | The cover letter not only tracks the content of the top-level mail, but also | |
| 1332 | + | the set of recipients. You can add recipients by adding `To:` and `Cc:` | |
| 1333 | + | trailer lines. | |
| 1334 | + | ||
| 1335 | + | [[send-b4]] | |
| 1336 | + | === Sending the Patches | |
| 1337 | + | ||
| 1338 | + | Before sending the series out for real, you can inspect what `b4` would send by | |
| 1339 | + | passing `--dry-run`: | |
| 1340 | + | ||
| 1341 | + | ---- | |
| 1342 | + | $ b4 send --dry-run | |
| 1343 | + | ---- | |
| 1344 | + | ||
| 1345 | + | Once you are happy with the result, send the series with: | |
| 1346 | + | ||
| 1347 | + | ---- | |
| 1348 | + | $ b4 send | |
| 1349 | + | ---- | |
| 1350 | + | ||
| 1351 | + | [[v2-b4]] | |
| 1352 | + | === Sending v2 | |
| 1353 | + | ||
| 1354 | + | When you are ready to send a new iteration of your series, refine your | |
| 1355 | + | patches as usual using linkgit:git-rebase[1]. Note that you typically want to | |
| 1356 | + | rebase on top of the cover letter. You can configure an alias to enable easy | |
| 1357 | + | rebases going forward: | |
| 1358 | + | ||
| 1359 | + | --- | |
| 1360 | + | $ git config set alias.b4-rebase 'rebase "HEAD^{/--- b4-submit-tracking ---}"' | |
| 1361 | + | $ git b4-rebase -i | |
| 1362 | + | --- | |
| 1363 | + | ||
| 1364 | + | Before sending out the new version you should also update the cover letter with | |
| 1365 | + | `b4 prep --edit-cover` to note the relevant changes compared to the previous | |
| 1366 | + | version. You can inspect the changes between the two versions with `b4 prep | |
| 1367 | + | --compare-to=v1`. | |
| 1368 | + | ||
| 1369 | + | Same as with the first version, you can use `b4 send` to send out the second | |
| 1370 | + | version. `b4` automatically bumps the version to `v2`, generates the range-diff | |
| 1371 | + | against the previous iteration, and threads the new series as a reply to the | |
| 1372 | + | cover letter of the first version. | |
| 1373 | + | ||
| 1374 | + | [[configure-b4]] | |
| 1375 | + | === Configure b4 | |
| 1376 | + | ||
| 1377 | + | `b4` can be configured via linkgit:git-config[1]. In addition to that, projects | |
| 1378 | + | can have their own set of defaults in `.b4-config` in the root tree, which also | |
| 1379 | + | uses Git's config format. The user's configuration always takes precedence over | |
| 1380 | + | the per-project defaults. | |
| 1381 | + | ||
| 1382 | + | Refer to the https://b4.docs.kernel.org/en/latest/config.html[b4 config documentation] | |
| 1383 | + | for more information on the available options. | |
| 1384 | + | ||
| 1299 | 1385 | [[now-what]] | |
| 1300 | 1386 | == My Patch Got Emailed - Now What? | |
| 1301 | 1387 | ||
| @@ -1330,6 +1416,28 @@ previous one" patches over 2 days), reviewers would strongly prefer if a | |||
| 1330 | 1416 | single polished version came 2 days later instead, and that version with | |
| 1331 | 1417 | fewer mistakes were the only one they would need to review. | |
| 1332 | 1418 | ||
| 1419 | + | This consideration applies not only when going from the initial patch to v2, | |
| 1420 | + | but also to later iterations of the same series. There is no fixed rule for how | |
| 1421 | + | long to wait before sending a new version. A useful default is to send at most | |
| 1422 | + | one new version of the same patch series per day. This gives multiple reviewers | |
| 1423 | + | time to comment, gives reviewers across time zones a fair chance to | |
| 1424 | + | participate, lets you batch feedback together, and gives you time to think | |
| 1425 | + | through the comments you received. Knowing that you should not immediately send | |
| 1426 | + | another version also encourages you to review the patches more carefully before | |
| 1427 | + | sending them, catch small mistakes such as typos and off-by-one errors | |
| 1428 | + | yourself, and let reviewers spend more of their attention on design, | |
| 1429 | + | algorithms, and other substantial issues. | |
| 1430 | + | ||
| 1431 | + | The right timing depends on the topic and the feedback. Larger series usually | |
| 1432 | + | need more review time. If the only comments so far are minor, such as typo | |
| 1433 | + | fixes, it often makes sense to wait a little longer in case deeper reviews are | |
| 1434 | + | still coming. If the comments call for substantial rework, do not rush out an | |
| 1435 | + | updated version before you have reviewed the larger changes carefully. Instead, | |
| 1436 | + | reply to the review that prompted the rewrite, say that you are preparing a | |
| 1437 | + | substantial rework, and mention which parts of the current series will become | |
| 1438 | + | obsolete so reviewers can avoid spending time on them until the updated series | |
| 1439 | + | is ready. | |
| 1440 | + | ||
| 1333 | 1441 | ||
| 1334 | 1442 | [[reviewing]] | |
| 1335 | 1443 | === Responding to Reviews | |
| @@ -1337,11 +1445,13 @@ fewer mistakes were the only one they would need to review. | |||
| 1337 | 1445 | After a few days, you will hopefully receive a reply to your patchset with some | |
| 1338 | 1446 | comments. Woohoo! Now you can get back to work. | |
| 1339 | 1447 | ||
| 1340 | - | It's good manners to reply to each comment, notifying the reviewer that you have | |
| 1341 | - | made the change suggested, feel the original is better, or that the comment | |
| 1342 | - | inspired you to do something a new way which is superior to both the original | |
| 1343 | - | and the suggested change. This way reviewers don't need to inspect your v2 to | |
| 1344 | - | figure out whether you implemented their comment or not. | |
| 1448 | + | It's good manners to reply to each comment in the mailing list discussion | |
| 1449 | + | instead of letting the next version of your patch be your only response. Tell | |
| 1450 | + | the reviewer whether you plan to make the suggested change, keep the original, | |
| 1451 | + | or pursue a different approach. This way reviewers can respond to your reasoning | |
| 1452 | + | before you spend time preparing a version they may not agree with, and later do | |
| 1453 | + | not need to inspect your v2 to figure out whether you implemented their comment | |
| 1454 | + | or not. | |
| 1345 | 1455 | ||
| 1346 | 1456 | Reviewers may ask you about what you wrote in the patchset, either in | |
| 1347 | 1457 | the proposed commit log message or in the changes themselves. You | |
| @@ -1367,6 +1477,11 @@ effect which had not occurred to you. It is always okay to ask for clarification | |||
| 1367 | 1477 | if you aren't sure why a change was suggested, or what the reviewer is asking | |
| 1368 | 1478 | you to do. | |
| 1369 | 1479 | ||
| 1480 | + | When replying to review comments, quote only the parts of the message that are | |
| 1481 | + | relevant to your response. It is usually helpful to trim away unrelated context, | |
| 1482 | + | such as large portions of the patch that are not being discussed, while keeping | |
| 1483 | + | enough quoted text for readers to understand what you are responding to. | |
| 1484 | + | ||
| 1370 | 1485 | Make sure your email client has a plaintext email mode and it is turned on; the | |
| 1371 | 1486 | Git list rejects HTML email. Please also follow the mailing list etiquette | |
| 1372 | 1487 | outlined in the | |
added Documentation/RelNotes/2.55.0.adoc mode 100644
| @@ -0,0 +1,460 @@ | |||
| 1 | + | Git v2.55 Release Notes | |
| 2 | + | ======================= | |
| 3 | + | ||
| 4 | + | UI, Workflows & Features | |
| 5 | + | ------------------------ | |
| 6 | + | ||
| 7 | + | * Hook scripts defined via the configuration system can now be | |
| 8 | + | configured to run in parallel. | |
| 9 | + | ||
| 10 | + | * The userdiff driver for the Scheme language has been extended to | |
| 11 | + | cover other Lisp dialects. | |
| 12 | + | ||
| 13 | + | * Terminal control sequences coming over the sideband while talking | |
| 14 | + | to a remote repository are mostly disabled by default, except for | |
| 15 | + | ANSI color escape sequences. | |
| 16 | + | ||
| 17 | + | * "ort" merge backend improvements. | |
| 18 | + | ||
| 19 | + | * "git checkout -m another-branch" was invented to deal with local | |
| 20 | + | changes to paths that are different between the current and the new | |
| 21 | + | branch, but it gave only one chance to resolve conflicts. The command | |
| 22 | + | was taught to create a stash to save the local changes. | |
| 23 | + | ||
| 24 | + | * A new builtin "git format-rev" is introduced for pretty formatting | |
| 25 | + | one revision expression per line or commit object names found in | |
| 26 | + | running text. | |
| 27 | + | ||
| 28 | + | * "git history" learned "fixup" command. | |
| 29 | + | ||
| 30 | + | * The internal URL parsing logic has been made accessible via a new | |
| 31 | + | subcommand "git url-parse". | |
| 32 | + | ||
| 33 | + | * Misspelt proxy URL (e.g., httt://...) did not trigger any warning | |
| 34 | + | or failure, which has been corrected. We had a regression in this | |
| 35 | + | update that broke https:// proxies, but that has been caught and | |
| 36 | + | corrected. | |
| 37 | + | ||
| 38 | + | * Document the fact that .git/info/exclude is shared across worktrees | |
| 39 | + | linked to the same repository. | |
| 40 | + | ||
| 41 | + | * The command line parser for "git diff" learned a few options take | |
| 42 | + | only non-negative integers. | |
| 43 | + | ||
| 44 | + | * The graph output from commands like "git log --graph" can now be | |
| 45 | + | limited to a specified number of lanes, preventing overly wide output | |
| 46 | + | in repositories with many branches. | |
| 47 | + | ||
| 48 | + | * The fsmonitor daemon has been implemented for Linux. | |
| 49 | + | ||
| 50 | + | * "git cat-file --batch" learns an in-line command "mailmap" | |
| 51 | + | that lets the user toggle use of mailmap. | |
| 52 | + | ||
| 53 | + | * The "git pack-objects --path-walk" traversal has been integrated | |
| 54 | + | with several object filters, including blobless and sparse filters. | |
| 55 | + | ||
| 56 | + | * "git push" learned to take a "remote group" name to push to, which | |
| 57 | + | causes pushes to multiple places, just like "git fetch" would do. | |
| 58 | + | ||
| 59 | + | * The 'git-jump' command (in contrib/) has been taught to automatically | |
| 60 | + | pick a mode (merge, diff, or ws) when invoked without arguments. | |
| 61 | + | ||
| 62 | + | * The documentation for `push.default = simple` has been clarified to | |
| 63 | + | better explain its behavior, making it clear that it pushes the | |
| 64 | + | current branch to a same-named branch on the remote, and detailing | |
| 65 | + | the upstream requirements for centralized workflows. | |
| 66 | + | ||
| 67 | + | * The documentation for "--word-diff" has been extended with a bit of | |
| 68 | + | implementation detail of where these different words come from. | |
| 69 | + | ||
| 70 | + | * "git config foo.bar=baz" is not likely to be a request to read the | |
| 71 | + | value of such a variable with '=' in its name; rather it is plausible | |
| 72 | + | that the user meant "git config set foo.bar baz". Give advice when | |
| 73 | + | giving an error message. | |
| 74 | + | ||
| 75 | + | * "git rev-list" (and "git log" family of commands) learned a new "--max-count-oldest" | |
| 76 | + | that picks oldest N commits in the range instead of the usual newest. | |
| 77 | + | ||
| 78 | + | * Various AsciiDoc markup fixes in 'git config' documentation and | |
| 79 | + | related files to ensure lists and formatting are rendered correctly. | |
| 80 | + | ||
| 81 | + | ||
| 82 | + | Performance, Internal Implementation, Development Support etc. | |
| 83 | + | -------------------------------------------------------------- | |
| 84 | + | ||
| 85 | + | * Promisor remote handling has been refactored and fixed in | |
| 86 | + | preparation for auto-configuration of advertised remotes. | |
| 87 | + | ||
| 88 | + | * Rust support is enabled by default (but still allows opting out); | |
| 89 | + | in Git version 3.0, Rust will become mandatory. | |
| 90 | + | ||
| 91 | + | * Preparation of the xdiff/ codebase to work with Rust. | |
| 92 | + | ||
| 93 | + | * Use a larger buffer size in the code paths to ingest pack stream. | |
| 94 | + | ||
| 95 | + | * Refactor service routines in the ref subsystem backends. | |
| 96 | + | ||
| 97 | + | * Shrink wasted memory in Myers diff that does not account for common | |
| 98 | + | prefix and suffix removal. | |
| 99 | + | ||
| 100 | + | * Enable expensive tests to catch topics that may cause breakages on | |
| 101 | + | integration branches closer to their origin in the contributor PR | |
| 102 | + | builds. | |
| 103 | + | ||
| 104 | + | * "git merge-base" optimization. | |
| 105 | + | ||
| 106 | + | * The limit_list() function that is one of the core part of the | |
| 107 | + | revision traversal infrastructure has been optimized by replacing | |
| 108 | + | its use of linear list with priority queue. | |
| 109 | + | ||
| 110 | + | * In a lazy clone, "git cherry" and "git grep" often fetch necessary | |
| 111 | + | blob objects one by one from promisor remotes. It has been corrected | |
| 112 | + | to collect necessary object names and fetch them in bulk to gain | |
| 113 | + | reasonable performance. | |
| 114 | + | ||
| 115 | + | * The logic to determine that branches in an octopus merge are | |
| 116 | + | independent has been optimized. | |
| 117 | + | ||
| 118 | + | * The consistency checks for the files reference backend have been updated | |
| 119 | + | to skip lock files earlier, avoiding unnecessary parsing of | |
| 120 | + | intermediate files. | |
| 121 | + | ||
| 122 | + | * The negotiation tip options in "git fetch" have been reworked to | |
| 123 | + | allow requiring certain refs to be sent as "have" lines, and to | |
| 124 | + | restrict negotiation to a specific set of refs. | |
| 125 | + | ||
| 126 | + | * The repacking code has been refactored and compaction of MIDX layers | |
| 127 | + | have been implemented, and incremental strategy that does not require | |
| 128 | + | all-into-one repacking has been introduced. | |
| 129 | + | ||
| 130 | + | * ODB transaction interface is being reworked to explicitly handle | |
| 131 | + | object writes. | |
| 132 | + | ||
| 133 | + | * Add a new odb "in-memory" source that is meant to only hold | |
| 134 | + | tentative objects (like the virtual blob object that represents the | |
| 135 | + | working tree file used by "git blame"). | |
| 136 | + | ||
| 137 | + | * Many uses of the_repository has been updated to use a more | |
| 138 | + | appropriate struct repository instance in setup.c codepath. | |
| 139 | + | ||
| 140 | + | * Revision traversal optimization. | |
| 141 | + | ||
| 142 | + | * Build update. | |
| 143 | + | ||
| 144 | + | * The logic to lazy-load trees from the commit-graph has been made | |
| 145 | + | more robust by falling back to reading the commit object when | |
| 146 | + | the commit-graph is no longer available. | |
| 147 | + | ||
| 148 | + | * The "name" argument in git_connect() and related functions has been | |
| 149 | + | converted to a "service" enum to improve type safety and clarify its | |
| 150 | + | purpose. | |
| 151 | + | ||
| 152 | + | * 'git restore --staged' has been optimized to avoid unnecessarily expanding | |
| 153 | + | the sparse index when operating on paths within the sparse checkout | |
| 154 | + | definition, by handling sparse directory entries at the tree level. | |
| 155 | + | ||
| 156 | + | * "git stash -p" has been optimized by reusing cached index | |
| 157 | + | entries in its temporary index, avoiding unnecessary lstat() | |
| 158 | + | calls on unchanged files. | |
| 159 | + | ||
| 160 | + | * The check for non-stale commits in the priority queue used by | |
| 161 | + | `paint_down_to_common` and `ahead_behind` has been optimized by | |
| 162 | + | replacing an O(N) scan with an O(1) counter, yielding performance | |
| 163 | + | improvements in repositories with wide histories. | |
| 164 | + | ||
| 165 | + | * Reachability bitmap generation has been significantly optimized. By | |
| 166 | + | reordering tree traversal, caching object positions, and refining how | |
| 167 | + | pseudo-merge bitmaps are constructed, the performance of "git repack | |
| 168 | + | --write-midx-bitmaps" is improved, especially for large repositories | |
| 169 | + | and when using pseudo-merges. | |
| 170 | + | ||
| 171 | + | * Adding a decimal integer with strbuf_addf("%u") appears commonly; | |
| 172 | + | they have been optimized by using a custom formatter. | |
| 173 | + | ||
| 174 | + | * Formatting object name in full hexadecimal form has been optimized | |
| 175 | + | by using a new strbuf_add_oid_hex() helper function. | |
| 176 | + | ||
| 177 | + | * Encourage original authors to monitor the CI status. | |
| 178 | + | ||
| 179 | + | * The `git log -L` implementation has been refactored to use the | |
| 180 | + | standard diff output pipeline, enabling pickaxe and diff-filter to | |
| 181 | + | work as expected. Additionally, metadata-only diff formats like | |
| 182 | + | --raw and --name-only are now supported with -L. | |
| 183 | + | ||
| 184 | + | * The loose object source has been refactored into a proper `struct | |
| 185 | + | odb_source`. | |
| 186 | + | ||
| 187 | + | * Guidelines on how to write a cover letter for a multi-patch series | |
| 188 | + | have been added to SubmittingPatches, which also got a new marker | |
| 189 | + | to separate the section for typofixes. | |
| 190 | + | ||
| 191 | + | * The setup logic to discover and configure repositories has been | |
| 192 | + | refactored, and the initialization of the object database has been | |
| 193 | + | centralized. | |
| 194 | + | ||
| 195 | + | * Many core configuration variables have been migrated from global | |
| 196 | + | variables into 'repo_config_values' to tie them to a specific | |
| 197 | + | repository instance, avoiding cross-repository state leakage. | |
| 198 | + | ||
| 199 | + | * Streaming revision walks have been optimized by using a priority queue | |
| 200 | + | for date-sorting commits, speeding up walks repositories with many | |
| 201 | + | merges. | |
| 202 | + | ||
| 203 | + | * A recent regression in t7527 that broke TAP output has been fixed, | |
| 204 | + | some other test noise that also broke TAP output has been silenced, | |
| 205 | + | and 'prove' is now configured to fail on invalid TAP output to | |
| 206 | + | prevent future regressions. | |
| 207 | + | ||
| 208 | + | * A handful of inappropriate uses of the_repository have been | |
| 209 | + | rewritten to use the right repository structure instance in the | |
| 210 | + | unpack-trees.c codepath. | |
| 211 | + | ||
| 212 | + | * "git index-pack" has been optimized by retaining child bases in the | |
| 213 | + | delta cache instead of immediately freeing them, letting the existing | |
| 214 | + | cache limit policy decide eviction. | |
| 215 | + | ||
| 216 | + | * `git ls-files --modified` and `git ls-files --deleted` have been | |
| 217 | + | optimized to filter with pathspec before calling lstat() when there is | |
| 218 | + | only a single pathspec item, avoiding unnecessary filesystem access | |
| 219 | + | for entries that will not be shown. | |
| 220 | + | ||
| 221 | + | * The UNUSED macro in 'compat/posix.h' has been updated to use a | |
| 222 | + | newly introduced GIT_CLANG_PREREQ macro for compiler version | |
| 223 | + | checks, and the existing GIT_GNUC_PREREQ macro has been modernized | |
| 224 | + | to use explicit major/minor comparisons rather than bit-shifting. | |
| 225 | + | ||
| 226 | + | * Wean the Windows builds in GitLab CI procedure away from | |
| 227 | + | (unfortunately unreliable) Chocolatey to install dependencies. | |
| 228 | + | (merge 0e7b51fed2 ps/gitlab-ci-windows later to maint). | |
| 229 | + | ||
| 230 | + | * Build-fix for 32-bit Windows. | |
| 231 | + | ||
| 232 | + | * Xcode 15 and later has a linker set to complain when the same library | |
| 233 | + | archive is listed twice on the command line. Squelch the annoyance. | |
| 234 | + | ||
| 235 | + | ||
| 236 | + | Fixes since v2.54 | |
| 237 | + | ----------------- | |
| 238 | + | ||
| 239 | + | * Code clean-up to use the right instance of a repository instance in | |
| 240 | + | calls inside refs subsystem. | |
| 241 | + | (merge 57c590feb9 sp/refs-reduce-the-repository later to maint). | |
| 242 | + | ||
| 243 | + | * The check that implements the logic to see if an in-core cache-tree | |
| 244 | + | is fully ready to write out a tree object was broken, which has | |
| 245 | + | been corrected. | |
| 246 | + | (merge 521731213c dl/cache-tree-fully-valid-fix later to maint). | |
| 247 | + | ||
| 248 | + | * The test suite harness and many individual test scripts have been | |
| 249 | + | updated to work correctly when 'set -e' is in effect, which helps | |
| 250 | + | detect misspelled test commands. | |
| 251 | + | (merge ffe8005b9d ps/test-set-e-clean later to maint). | |
| 252 | + | ||
| 253 | + | * Revert a recent change that introduced a regression to help mksh users. | |
| 254 | + | ||
| 255 | + | * Update various GitHub Actions versions. | |
| 256 | + | ||
| 257 | + | * Avoid hitting the pathname limit for socks proxy socket during the | |
| 258 | + | test.. | |
| 259 | + | ||
| 260 | + | * To help Windows 10 installations, avoid removing files whose | |
| 261 | + | contents are still mmap()'ed. | |
| 262 | + | ||
| 263 | + | * The 'git backfill' command now rejects revision-limiting options that | |
| 264 | + | are incompatible with its operation, uses standard documentation for | |
| 265 | + | revision ranges, and includes blobs from boundary commits by default | |
| 266 | + | to improve performance of subsequent operations. | |
| 267 | + | (merge a1ad4a0fca en/backfill-fixes-and-edges later to maint). | |
| 268 | + | ||
| 269 | + | * "git grep" update. | |
| 270 | + | (merge 9ff4b5ab1b rs/grep-column-only-match-fix later to maint). | |
| 271 | + | ||
| 272 | + | * Headers from glibc 2.43 when used with clang does not allow | |
| 273 | + | disabling C11 language features, causing build failures.. | |
| 274 | + | ||
| 275 | + | * The 'http.emptyAuth=auto' configuration now correctly attempts | |
| 276 | + | Negotiate authentication before falling back to manual credentials. | |
| 277 | + | This allows seamless Kerberos ticket-based authentication without | |
| 278 | + | requiring users to explicitly set 'http.emptyAuth=true'. | |
| 279 | + | (merge 4919938d28 mc/http-emptyauth-negotiate-fix later to maint). | |
| 280 | + | ||
| 281 | + | * Ramifications of turning off commit-graph has been documented a bit | |
| 282 | + | more clearly. | |
| 283 | + | (merge 48c855bb8f kh/doc-commit-graph later to maint). | |
| 284 | + | ||
| 285 | + | * "git rebase --update-refs", when used with an rebase.instructionFormat | |
| 286 | + | with "%d" (describe) in it, tried to update local branch HEAD by | |
| 287 | + | mistake, which has been corrected. | |
| 288 | + | (merge 106b6885c7 ag/rebase-update-refs-limit-to-branches later to maint). | |
| 289 | + | ||
| 290 | + | * Tweak the way how sideband messages from remote are printed while | |
| 291 | + | we talk with a remote repository to avoid tickling terminal | |
| 292 | + | emulator glitches. | |
| 293 | + | (merge 31e8fcabd8 rs/sideband-clear-line-before-print later to maint). | |
| 294 | + | ||
| 295 | + | * The configuration variable submodule.fetchJobs was not read correctly, | |
| 296 | + | which has been corrected. | |
| 297 | + | (merge aa45a5902f sj/submodule-update-clone-config-fix later to maint). | |
| 298 | + | ||
| 299 | + | * Update code paths that assumed "unsigned long" was long enough for | |
| 300 | + | "size_t". | |
| 301 | + | (merge 7a094d68a2 js/objects-larger-than-4gb-on-windows later to maint). | |
| 302 | + | ||
| 303 | + | * Stop using unmaintained custom allocator in Windows build which was | |
| 304 | + | the last user of the code. | |
| 305 | + | ||
| 306 | + | * The computation to shorten the filenames shown in diffstat measured | |
| 307 | + | width of individual UTF-8 characters to add up, but forgot to take | |
| 308 | + | into account error cases (e.g., an invalid UTF-8 sequence, or a | |
| 309 | + | control character). | |
| 310 | + | (merge 09d86a3b98 en/diffstat-utf8-truncation-fix later to maint). | |
| 311 | + | ||
| 312 | + | * Some tests assume that bare repository accesses are by default | |
| 313 | + | allowed; rewrite some of them to avoid the assumption, rewrite | |
| 314 | + | others to explicitly set safe.bareRepository to allow them. | |
| 315 | + | (merge 985b38ca6c js/adjust-tests-to-explicitly-access-bare-repo later to maint). | |
| 316 | + | ||
| 317 | + | * Signing commit with custom encoding was passing the data to be | |
| 318 | + | signed at a wrong stage in the pipeline, which has been corrected. | |
| 319 | + | (merge 7735d7eee3 bc/sign-commit-with-custom-encoding later to maint). | |
| 320 | + | ||
| 321 | + | * Further update to the i18n alias support to avoid regressions. | |
| 322 | + | ||
| 323 | + | * "git fetch --deepen=<n>" in a full clone truncated the history to <n> | |
| 324 | + | commits deep, which has been corrected to be a no-op instead. | |
| 325 | + | (merge 2431f5e0e5 sp/shallow-deepen-on-non-shallow-repo-fix later to maint). | |
| 326 | + | ||
| 327 | + | * "git maintenance" that goes background did not use the lockfile to | |
| 328 | + | prevent multiple maintenance processes from running at the same | |
| 329 | + | time, which has been corrected. | |
| 330 | + | (merge 29364f1624 ps/maintenance-daemonize-lockfix later to maint). | |
| 331 | + | ||
| 332 | + | * Remove ineffective strbuf presizing that would have computed an | |
| 333 | + | allocation that would not have fit in the available memory anyway, | |
| 334 | + | or too small due to integer wraparound to cause immediate automatic | |
| 335 | + | growing. | |
| 336 | + | (merge a9ce8526dc jk/pretty-no-strbuf-presizing later to maint). | |
| 337 | + | ||
| 338 | + | * The HTTP walker misinterpreted the alternates file that gives an | |
| 339 | + | absolute path when the server URL does not have the final slash | |
| 340 | + | (i.e., "https://example.com" not "https://example.com/"). | |
| 341 | + | (merge b92387cd55 jk/dumb-http-alternate-fix later to maint). | |
| 342 | + | ||
| 343 | + | * "git bisect" now uses the selected terms (e.g., old/new) more | |
| 344 | + | consistently in its output. | |
| 345 | + | (merge cb55991825 jr/bisect-custom-terms-in-output later to maint). | |
| 346 | + | ||
| 347 | + | * Update GitLab CI jobs that exercise macOS. | |
| 348 | + | (merge 62319b49bb ps/gitlab-ci-macOS-improvements later to maint). | |
| 349 | + | ||
| 350 | + | * "Friday noon" asked in the morning on Sunday was parsed to be one | |
| 351 | + | day before the specified time, which has been corrected. | |
| 352 | + | (merge b809304101 ta/approxidate-noon-fix later to maint). | |
| 353 | + | ||
| 354 | + | * The GIT_WORK_TREE variable prepared to invoke the push-to-checkout | |
| 355 | + | hook was leaking into the environment even when there was no hook | |
| 356 | + | used and broke the default push-to-deploy (i.e., let "git checkout" | |
| 357 | + | update the working tree only when the working tree is clean). | |
| 358 | + | (merge 44d04e4426 ar/receive-pack-worktree-env later to maint). | |
| 359 | + | ||
| 360 | + | * A batch of documentation pages has been updated to use the modern | |
| 361 | + | synopsis style. | |
| 362 | + | (merge 2ef248ae45 ja/doc-synopsis-style-again later to maint). | |
| 363 | + | ||
| 364 | + | * The "promisor.quiet" configuration variable was not used from | |
| 365 | + | relevant submodules when commands like "grep --recurse-submodules" | |
| 366 | + | triggered a lazy fetch, which has been corrected. | |
| 367 | + | (merge fa1468a1f7 th/promisor-quiet-per-repo later to maint). | |
| 368 | + | ||
| 369 | + | * Correct use of sockaddr API in "git daemon". | |
| 370 | + | (merge 422a5bf575 st/daemon-sockaddr-fixes later to maint). | |
| 371 | + | ||
| 372 | + | * A memory leak in `fetch_and_setup_pack_index()` when verification of | |
| 373 | + | the downloaded pack index fails has been plugged. Also an obsolete | |
| 374 | + | `unlink()` call on parse failure has been cleaned up. | |
| 375 | + | ||
| 376 | + | * In t3070-wildmatch, "via ls-files" test variants with patterns | |
| 377 | + | containing backslash escapes are now skipped on Windows, avoiding 36 | |
| 378 | + | test failures caused by pathspec separator conversion. | |
| 379 | + | (merge 8c84e6802c kk/wildmatch-windows-ls-files-prereq later to maint). | |
| 380 | + | ||
| 381 | + | * A linker warning on macOS when building with Xcode 16.3 or newer has | |
| 382 | + | been avoided by passing -fno-common to the compiler when a | |
| 383 | + | sufficiently new linker is detected. | |
| 384 | + | (merge 5cd4d0d850 hn/macos-linker-warning later to maint). | |
| 385 | + | ||
| 386 | + | * Documentation and tests have been added to clarify that Git's internal | |
| 387 | + | raw timestamp format requires a `@` prefix for values less than | |
| 388 | + | 100,000,000 to prevent ambiguity with other formats like YYYYMMDD. | |
| 389 | + | (merge 4018dc29ee ls/doc-raw-timestamp-prefix later to maint). | |
| 390 | + | ||
| 391 | + | * Wording used in "format-patch --subject-prefix" documentation | |
| 392 | + | has been improved. | |
| 393 | + | (merge 4a1eb9304a lo/doc-format-patch-subject-prefix later to maint). | |
| 394 | + | ||
| 395 | + | * Advanced emulation of kill() used on Windows in GfW has been | |
| 396 | + | upstreamed to improve the symptoms like left-behind .lock files and | |
| 397 | + | that fails to let the child clean-up itself when it gets killed. | |
| 398 | + | (merge 363f1d8b3a js/win-kill-child-more-gently later to maint). | |
| 399 | + | ||
| 400 | + | * The 'git describe --contains --all' command has been fixed to | |
| 401 | + | properly honor the '--match' and '--exclude' options by passing | |
| 402 | + | them down to 'git name-rev' with the appropriate reference | |
| 403 | + | prefixes. | |
| 404 | + | (merge 1891707d1b jk/describe-contains-all-match-fix later to maint). | |
| 405 | + | ||
| 406 | + | * Various typos, grammatical errors, and duplicated words in both | |
| 407 | + | documentation and code comments have been corrected. | |
| 408 | + | (merge dc6068df67 wy/docs-typofixes later to maint). | |
| 409 | + | ||
| 410 | + | * The subprocess handshake during startup has been made gentler by using | |
| 411 | + | packet_read_line_gently() instead of packet_read_line() to prevent the | |
| 412 | + | parent Git process from dying abruptly when a configured subprocess | |
| 413 | + | (e.g., a clean/smudge filter) fails to start. | |
| 414 | + | (merge 061a68e443 mm/subprocess-handshake-fix later to maint). | |
| 415 | + | ||
| 416 | + | * The TSAN race in transfer_debug() within transport-helper.c has been | |
| 417 | + | resolved by initializing the debug flag early in | |
| 418 | + | bidirectional_transfer_loop() before spawning worker threads, allowing | |
| 419 | + | the removal of a TSAN suppression. | |
| 420 | + | (merge 85704eda18 ps/transport-helper-tsan-fix later to maint). | |
| 421 | + | ||
| 422 | + | * 'git describe' has been taught to pass the 'refs/tags/' prefix down to | |
| 423 | + | the ref iterator when '--all' is not requested, avoiding unnecessary | |
| 424 | + | iteration over non-tag refs. | |
| 425 | + | (merge 55088ac8a4 td/describe-tag-iteration later to maint). | |
| 426 | + | ||
| 427 | + | * compute_reachable_generation_numbers() in commit-graph used a 32-bit | |
| 428 | + | integer to accumulate parent generations, which is OK for generation | |
| 429 | + | number v1 (topological levels), but with generation number v2 | |
| 430 | + | (adjusted committer timestamps), it truncated timestamps beyond | |
| 431 | + | 2106. Fixed by widening the accumulator to timestamp_t. | |
| 432 | + | (merge fbcc5408fc en/commit-graph-timestamp-fix later to maint). | |
| 433 | + | ||
| 434 | + | * Other code cleanup, docfix, build fix, etc. | |
| 435 | + | (merge 80f4b802e9 ja/doc-difftool-synopsis-style later to maint). | |
| 436 | + | (merge b96490241e jc/doc-timestamps-in-stat later to maint). | |
| 437 | + | (merge ef85286e51 ss/t7004-unhide-git-failures later to maint). | |
| 438 | + | (merge 7584d10bc2 mf/format-patch-cover-letter-format-docfix later to maint). | |
| 439 | + | (merge 8547908eb3 pw/rename-to-get-current-worktree later to maint). | |
| 440 | + | (merge 890229b3f3 sg/t6112-unwanted-tilde-expansion-fix later to maint). | |
| 441 | + | (merge ab9753e7bc kh/doc-restore-double-underscores-fix later to maint). | |
| 442 | + | (merge 4a9e097228 za/t2000-modernise-more later to maint). | |
| 443 | + | (merge b635fd0725 kh/doc-log-decorate-list later to maint). | |
| 444 | + | (merge 65ea197dca jk/commit-sign-overflow-fix later to maint). | |
| 445 | + | (merge 3ccb16052a jk/apply-leakfix later to maint). | |
| 446 | + | (merge 5e6e8dc786 tb/pseudo-merge-bugfixes later to maint). | |
| 447 | + | (merge 6d09e798bc pb/doc-diff-format-updates later to maint). | |
| 448 | + | (merge 34a891a2d3 rs/trailer-fold-optim later to maint). | |
| 449 | + | (merge 499f9048e0 ps/t3903-cover-stash-include-untracked later to maint). | |
| 450 | + | (merge b56ab270aa jk/sq-dequote-cleanup later to maint). | |
| 451 | + | (merge 29d9fdcf10 rs/use-builtin-add-overflow-explicitly-on-clang later to maint). | |
| 452 | + | (merge d9982e8290 ed/check-connected-close-err-fd-2.53 later to maint). | |
| 453 | + | (merge 1740cc35d0 ed/check-connected-close-err-fd later to maint). | |
| 454 | + | (merge f4d7eb3d1c sp/doc-range-diff-takes-notes later to maint). | |
| 455 | + | (merge 83e7f3bd2b kh/free-commit-list later to maint). | |
| 456 | + | (merge d1b72b29e9 am/doc-tech-hash-typofix later to maint). | |
| 457 | + | (merge 014c454799 ak/typofixes later to maint). | |
| 458 | + | (merge 522ea8ef7d js/osxkeychain-build-wo-rust later to maint). | |
| 459 | + | (merge e8f12e0e95 jc/t1400-fifo-cleanup later to maint). | |
| 460 | + | (merge 0bf506efd4 kw/gitattributes-typofix later to maint). | |
added Documentation/RelNotes/2.56.0.adoc mode 100644
| @@ -0,0 +1,911 @@ | |||
| 1 | + | Git v2.56 Release Notes | |
| 2 | + | ======================= | |
| 3 | + | ||
| 4 | + | UI, Workflows & Features | |
| 5 | + | ------------------------ | |
| 6 | + | ||
| 7 | + | * Advice shown by "git status" when the local branch is behind or has | |
| 8 | + | diverged from its push branch has been updated to suggest "git pull | |
| 9 | + | <remote> <branch>". | |
| 10 | + | ||
| 11 | + | * The handling of promisor-remote protocol capability has been updated | |
| 12 | + | to allow the other side to add to the list of promisor remotes via the | |
| 13 | + | 'promisor.acceptFromServerURL' configuration variable. | |
| 14 | + | ||
| 15 | + | * The 'ort' merge backend has been hardened against corrupt trees by | |
| 16 | + | ensuring it aborts under appropriate error conditions. | |
| 17 | + | ||
| 18 | + | * The `fetch.followRemoteHEAD` configuration variable has been added to | |
| 19 | + | provide a default for the per-remote `remote.<name>.followRemoteHEAD` | |
| 20 | + | setting. | |
| 21 | + | ||
| 22 | + | * "git log --follow" has been updated to better handle non-linear | |
| 23 | + | history, in which the path being tracked gets renamed differently in | |
| 24 | + | multiple history lines. | |
| 25 | + | ||
| 26 | + | * The "git repo info" command has been taught new keys to output both | |
| 27 | + | absolute and relative paths for "gitdir" and "commondir", supported by | |
| 28 | + | a new path-formatting helper extracted from "git rev-parse". | |
| 29 | + | ||
| 30 | + | * When 'git push origin/main' or 'git branch origin main' is run, the | |
| 31 | + | command is now recognized as a potential typo, and advice has been | |
| 32 | + | added to offer a typo fix. | |
| 33 | + | ||
| 34 | + | * The 'git refs' toolbox has been extended with new 'create', 'delete', | |
| 35 | + | 'update', and 'rename' subcommands to create, delete, update, and | |
| 36 | + | rename references, respectively. | |
| 37 | + | ||
| 38 | + | * The experimental 'git history' command has been taught a new 'drop' | |
| 39 | + | subcommand to remove a commit, with its descendants replayed onto its | |
| 40 | + | parent. | |
| 41 | + | ||
| 42 | + | * The alignment of commit object name abbreviations in 'git blame' | |
| 43 | + | output has been optimized to reserve a column for marks (caret, | |
| 44 | + | question mark, or asterisk) only when such marks are actually shown. | |
| 45 | + | ||
| 46 | + | * Option parsing with 'git rev-parse --parseopt' and in most 'git' | |
| 47 | + | subcommands has been updated to exit with 0 (instead of 129) when the | |
| 48 | + | help option ('-h' or '--help') is requested directly by the user, | |
| 49 | + | aligning with standard Unix convention. | |
| 50 | + | ||
| 51 | + | * The '[includeIf "condition"]' conditional inclusion facility for | |
| 52 | + | configuration files has been taught to use the location of the | |
| 53 | + | worktree in its condition. | |
| 54 | + | ||
| 55 | + | * The usage string and SYNOPSIS for 'git fast-export' have been | |
| 56 | + | standardized to make them consistent with each other and with other | |
| 57 | + | commands. | |
| 58 | + | ||
| 59 | + | * 'git log --graph' has been modified to visually distinguish parentless | |
| 60 | + | 'root' commits (and commits that become roots due to history | |
| 61 | + | simplification) by indenting them, preventing them from appearing | |
| 62 | + | falsely related to unrelated commits rendered immediately above them. | |
| 63 | + | ||
| 64 | + | * Userdiff patterns for Swift have been added, with support for | |
| 65 | + | Swift-specific constructs such as attributes, modifiers, failable | |
| 66 | + | initializers, and generics. | |
| 67 | + | ||
| 68 | + | * Configuration file locking has been updated to retry for a short | |
| 69 | + | period, avoiding failures when multiple processes attempt to update | |
| 70 | + | the configuration simultaneously. | |
| 71 | + | ||
| 72 | + | * The 'remote-object-info' command has been added to 'git cat-file | |
| 73 | + | --batch-command', allowing clients to request object metadata | |
| 74 | + | (currently size) from a remote server via protocol v2 without | |
| 75 | + | downloading the entire object. Format placeholders are dynamically | |
| 76 | + | filtered on the client based on server-advertised capabilities, | |
| 77 | + | returning empty strings for inapplicable or unsupported fields. | |
| 78 | + | ||
| 79 | + | * 'git branch -d' has been taught to report when a branch cannot be | |
| 80 | + | deleted because it is being used in an active bisect run. | |
| 81 | + | ||
| 82 | + | * 'git mv' has been updated to check for a missing destination | |
| 83 | + | leading directory during the checking phase, allowing 'git mv -n' | |
| 84 | + | to report the failure. The error message when the rename(2) | |
| 85 | + | syscall fails has also been improved to name both the source and | |
| 86 | + | the destination. | |
| 87 | + | ||
| 88 | + | * 'git add' has been taught a new '--resolved' option to stage | |
| 89 | + | conflict-resolved paths, while leaving unrelated local changes | |
| 90 | + | unstaged. It scans the unmerged paths for leftover conflict | |
| 91 | + | markers and aborts if any are found. | |
| 92 | + | ||
| 93 | + | * The known limitations of the ref format migration in 'git refs' have | |
| 94 | + | been moved to be displayed as a warning admonition directly under the | |
| 95 | + | description of the 'migrate' subcommand, improving visibility. A | |
| 96 | + | reference to 'git-maintenance' has also been corrected to use the | |
| 97 | + | 'linkgit' macro. | |
| 98 | + | ||
| 99 | + | * The 'git bisect' command has been taught a | |
| 100 | + | '--reset-when-found[=<where>]' option that tells the command to | |
| 101 | + | automatically run 'git bisect reset' to jump back to the original | |
| 102 | + | state or to the found culprit. | |
| 103 | + | ||
| 104 | + | * The 'git branch' command has been taught the '--delete-merged' option | |
| 105 | + | to remove local branches that are already merged into their tracked | |
| 106 | + | remote-tracking branches. | |
| 107 | + | ||
| 108 | + | * The 'remote-object-info' command for 'git cat-file --batch-command' | |
| 109 | + | has been extended to support the '%(objecttype)' placeholder. | |
| 110 | + | ||
| 111 | + | * The usage string of 'git fast-import' has been updated to use the | |
| 112 | + | parse_options() API for displaying help, and its SYNOPSIS in the | |
| 113 | + | documentation has been standardized to match. | |
| 114 | + | ||
| 115 | + | * The error message given by 'git send-email' when a message file is | |
| 116 | + | missing a 'Subject:' header has been clarified, and the error string | |
| 117 | + | is now terminated with a newline so that Perl avoids appending its | |
| 118 | + | internal source location data. | |
| 119 | + | ||
| 120 | + | * The '--shallow-file' option of 'git' command requires a value, but the | |
| 121 | + | code did not check the presence of a value and instead segfaulted | |
| 122 | + | without one, which has been corrected. | |
| 123 | + | ||
| 124 | + | * 'git repack' has been taught '--drop-filtered' to delete local | |
| 125 | + | promisor blobs exceeding a limit (currently 'blob:limit=') in partial | |
| 126 | + | clones, reclaiming space. Guards prevent running during other | |
| 127 | + | operations or if referenced by the index. | |
| 128 | + | ||
| 129 | + | * The documentation for 'git format-rev' has been updated to use the | |
| 130 | + | [synopsis] block definition on code blocks to properly highlight | |
| 131 | + | placeholders, and a quoting inconsistency in the running text has | |
| 132 | + | been fixed. | |
| 133 | + | ||
| 134 | + | * The DWIM logic in 'git worktree add' sometimes tried to infer a | |
| 135 | + | remote-tracking branch when an explicit '-b' or '-B' option was | |
| 136 | + | given to create a new branch, causing the explicit branch name to | |
| 137 | + | be ignored, which has been corrected. | |
| 138 | + | ||
| 139 | + | * The command line completion (in contrib/) has been taught to handle | |
| 140 | + | the experimental 'git history' command. | |
| 141 | + | ||
| 142 | + | * 'git checkout' and 'git worktree add' makes guesses based on a name | |
| 143 | + | of a remote-tracking branch, but does not give an error when such a | |
| 144 | + | remote-tracking branch cannot be uniquely identified, which has | |
| 145 | + | been corrected. | |
| 146 | + | ||
| 147 | + | * The 'git replay' command has been taught the '--linearize' option to | |
| 148 | + | drop merge commits and linearize the replayed history, mimicking 'git | |
| 149 | + | rebase --no-rebase-merges'. | |
| 150 | + | ||
| 151 | + | * The documentation for 'git cherry-pick' has been updated to clarify | |
| 152 | + | that the '--no-commit' option intentionally skips setting the | |
| 153 | + | 'CHERRY_PICK_HEAD' ref. A test has also been added to ensure this | |
| 154 | + | behavior holds even when the operation stops for conflicts. | |
| 155 | + | ||
| 156 | + | * The 'git imap-send' command has been taught to take the '--draft' | |
| 157 | + | option to mark uploaded messages as drafts, which helps some email | |
| 158 | + | clients render them properly for editing and sending. | |
| 159 | + | ||
| 160 | + | * The git rev-list command has been augmented with a '--missing-only' | |
| 161 | + | option that filters the output to only show missing objects, | |
| 162 | + | stripping the leading '?' character and suppressing present objects, | |
| 163 | + | which is useful when used in combination with '--missing=print' or | |
| 164 | + | '--missing=print-info'. | |
| 165 | + | ||
| 166 | + | ||
| 167 | + | Performance, Internal Implementation, Development Support etc. | |
| 168 | + | -------------------------------------------------------------- | |
| 169 | + | ||
| 170 | + | * The refactoring of 'setup.c' has been continued to drop remaining | |
| 171 | + | global state (`git_work_tree_cfg`, `is_bare_repository_cfg`), updating | |
| 172 | + | `is_bare_repository()` to no longer implicitly rely on | |
| 173 | + | `the_repository`. | |
| 174 | + | ||
| 175 | + | * Project-specific configuration for b4 has been introduced, and the | |
| 176 | + | documentation has been updated to recommend using it as a | |
| 177 | + | streamlined method for submitting patches. | |
| 178 | + | ||
| 179 | + | * The default format path of git cat-file --batch has been optimized | |
| 180 | + | to use strbuf_add_oid_hex() and strbuf_add_uint() instead of | |
| 181 | + | strbuf_addf(), yielding a noticeable speedup. | |
| 182 | + | ||
| 183 | + | * Commands that list branches and tags (like git branch and git tag) | |
| 184 | + | have been optimized to pass the namespace prefix when initializing | |
| 185 | + | their ref iterator, avoiding a loose-ref scaling regression in | |
| 186 | + | repositories with many unrelated loose references. | |
| 187 | + | ||
| 188 | + | * The packed object source has been refactored into a proper struct | |
| 189 | + | odb_source. | |
| 190 | + | ||
| 191 | + | * The global configuration variables protect_hfs and protect_ntfs have | |
| 192 | + | been migrated into struct repo_config_values to tie them to | |
| 193 | + | per-repository configuration state. | |
| 194 | + | ||
| 195 | + | * The trailer sections in SubmittingPatches have been updated to | |
| 196 | + | encourage use of standard trailers. | |
| 197 | + | ||
| 198 | + | * The documentation in SubmittingPatches has been updated to clarify how | |
| 199 | + | patch contributors should respond to design and viability critiques, | |
| 200 | + | and how the resolution of such critiques should be recorded in the | |
| 201 | + | final commit messages. | |
| 202 | + | ||
| 203 | + | * The pack-objects command has been updated to support reachability | |
| 204 | + | bitmaps and delta-islands concurrently with the `--path-walk` option, | |
| 205 | + | allowing faster packaging by falling back to path-walk when bitmaps | |
| 206 | + | cannot fully satisfy the request. | |
| 207 | + | ||
| 208 | + | * Documentation on community contribution guidelines has been updated to | |
| 209 | + | encourage replying to review comments before rerolling, and to advise | |
| 210 | + | a default limit of at most one reroll per day to give reviewers across | |
| 211 | + | different time zones enough time to participate. | |
| 212 | + | ||
| 213 | + | * The lazy priority queue optimization pattern (deferring actual removal | |
| 214 | + | in 'prio_queue_get()' to allow get+put fusion) has been folded | |
| 215 | + | directly into 'prio_queue' itself, speeding up commit traversal | |
| 216 | + | workflows and simplifying callers. | |
| 217 | + | ||
| 218 | + | * The 'reprepare()' callback for object database sources has been | |
| 219 | + | generalized into a 'prepare()' callback with an optional flush cache | |
| 220 | + | flag, and a new 'odb_prepare()' wrapper has been introduced to allow | |
| 221 | + | pre-opening object database sources. | |
| 222 | + | ||
| 223 | + | * The 'whence' field in 'struct object_info' has been removed. The | |
| 224 | + | backend-specific object information retrieval has been refactored into | |
| 225 | + | an opt-in 'struct object_info_source' structure. | |
| 226 | + | ||
| 227 | + | * A racy build failure under Meson has been corrected by ensuring that | |
| 228 | + | the generated header file 'hook-list.h' is built before compiling | |
| 229 | + | files in 'builtin_sources' that depend on it. | |
| 230 | + | ||
| 231 | + | * The repository discovery and repository configuration phases, which | |
| 232 | + | were previously intertwined in 'setup.c', have been split. Repository | |
| 233 | + | discovery has been updated to populate a 'struct repo_discovery' | |
| 234 | + | without modifying the repository state, which is then taken by | |
| 235 | + | repository configuration to initialize the repository, paving the way | |
| 236 | + | for clean unification of repository configuration. | |
| 237 | + | ||
| 238 | + | * The 'SubmittingPatches' document has been updated to explicitly | |
| 239 | + | describe the expectation for contributors to retract or abandon their | |
| 240 | + | patch series when they are no longer pursuing it. | |
| 241 | + | ||
| 242 | + | * The contributor guide has been updated to advise new contributors to | |
| 243 | + | trim irrelevant quoted text when replying to review comments, matching | |
| 244 | + | the existing advice given to reviewers. | |
| 245 | + | ||
| 246 | + | * The build system has been updated to support building universal macOS | |
| 247 | + | binaries when 'Rust' is enabled, by compiling separate static archives | |
| 248 | + | for each target triple listed in 'RUST_TARGETS' and combining them | |
| 249 | + | using the macOS 'lipo' tool. The 'git-credential-osxkeychain' helper | |
| 250 | + | has been updated to link against '$(RUST_LIB)' when 'Rust' is enabled. | |
| 251 | + | ||
| 252 | + | * The test suite has been updated to use the 'test_grep' helper instead | |
| 253 | + | of bare 'grep' for test assertions, allowing file contents to be | |
| 254 | + | printed on failure for easier debugging. A new 'greplint' linter has | |
| 255 | + | been introduced to detect and prevent new bare 'grep' assertions from | |
| 256 | + | being added to the test suite. | |
| 257 | + | ||
| 258 | + | * The pipelines in 't1410-reflog.sh' have been replaced with the | |
| 259 | + | 'test_stdout_line_count' helper to avoid suppressing the exit code of | |
| 260 | + | 'git' commands, ensuring failures are not hidden from the test suite. | |
| 261 | + | ||
| 262 | + | * The cache-scanning loop in 'next_cache_entry()' has been optimized | |
| 263 | + | to avoid rescanning already-unpacked index entries, preventing a | |
| 264 | + | quadratic performance slow-down when diffing the working tree | |
| 265 | + | against a commit with a pathspec matching early index entries. | |
| 266 | + | ||
| 267 | + | * The global configuration variable 'ignore_case' (representing the | |
| 268 | + | 'core.ignorecase' configuration) has been migrated into 'struct | |
| 269 | + | repo_config_values' to tie it to a specific repository instance. | |
| 270 | + | ||
| 271 | + | * The performance of ref updates and reads using the 'reftable' backend | |
| 272 | + | in the presence of many deletion tombstone records has been optimized | |
| 273 | + | by removing the tombstone suppression flag from the merged iterator | |
| 274 | + | and instead skipping tombstones at higher-level call sites where | |
| 275 | + | iteration bounds are known. | |
| 276 | + | ||
| 277 | + | * Various code paths have been hardened against potential NULL-pointer | |
| 278 | + | dereferences and invalid file descriptor accesses flagged by | |
| 279 | + | Coverity. | |
| 280 | + | ||
| 281 | + | * The in-tree 'b4' cover letter template has been updated to include the | |
| 282 | + | 'change-id' trailer, ensuring that sent tags generated by 'b4' contain | |
| 283 | + | the required tracking information for subsequent runs. | |
| 284 | + | ||
| 285 | + | * 'git receive-pack' has been refactored to use ODB transaction | |
| 286 | + | interfaces instead of directly managing 'tmp_objdir' for staging | |
| 287 | + | incoming objects, bringing it closer to being ODB backend agnostic. | |
| 288 | + | ||
| 289 | + | * The test script 't/t9811-git-p4-label-import.sh' has been | |
| 290 | + | modernized to use 'test_path_is_file' and 'test_path_is_missing' | |
| 291 | + | instead of raw 'test -f' and '! test -f' calls. | |
| 292 | + | ||
| 293 | + | * A redundant strbuf_reset() call in the 'HAVE_GETDELIM' path of | |
| 294 | + | strbuf_getwholeline() has been removed, as getdelim() overwrites the | |
| 295 | + | buffer and the length is updated afterward. | |
| 296 | + | ||
| 297 | + | * The object database enumeration interface odb_for_each_object() has | |
| 298 | + | been taught to accept object filters, allowing the underlying backends | |
| 299 | + | to optimize the traversal by using reachability bitmaps when | |
| 300 | + | available. 'git cat-file --batch-all-objects' has been updated to use | |
| 301 | + | this generic interface, simplifying its code and avoiding direct | |
| 302 | + | access to ODB backend internals. | |
| 303 | + | ||
| 304 | + | * The test script 't/t1100-commit-tree-options.sh' has been modernized | |
| 305 | + | by converting test cases to the modern style (using single quotes and | |
| 306 | + | tab indentation) and moving the creation of the expected file inside | |
| 307 | + | the setup test so it runs under the protection of the test harness. | |
| 308 | + | ||
| 309 | + | * The test script 't/t7614-merge-signoff.sh' has been updated to avoid | |
| 310 | + | suppressing the exit code of 'git' commands in a pipe. | |
| 311 | + | ||
| 312 | + | * The 'git rev-list --no-walk' command has been corrected to restore | |
| 313 | + | pathspec filtering, which was lost when the streaming walk was | |
| 314 | + | refactored. | |
| 315 | + | ||
| 316 | + | * The ref subsystem and the worktree API have been refactored to pass a | |
| 317 | + | repository pointer down the call chain, allowing them to drop | |
| 318 | + | references to the global 'the_repository' variable. As part of this, | |
| 319 | + | the handling of the 'core.packedRefsTimeout' configuration has been | |
| 320 | + | moved into the per-repository ref store structure. | |
| 321 | + | ||
| 322 | + | * 'git branch --contains' and 'git for-each-ref --contains' have been | |
| 323 | + | optimized to use the memoized commit traversal previously used only by | |
| 324 | + | 'git tag --contains', significantly speeding up connectivity checks | |
| 325 | + | across many candidate refs with shared history. | |
| 326 | + | ||
| 327 | + | * The passing of push destination specifications in the 'remote-curl' | |
| 328 | + | helper has been simplified by removing the explicit 'count' parameter | |
| 329 | + | and relying on the NULL-termination of the array. | |
| 330 | + | ||
| 331 | + | * The dependency on the global 'the_repository' variable in the | |
| 332 | + | 'refspec.c' API has been removed by passing the hash algorithm | |
| 333 | + | explicitly to refspec-parsing functions and storing it in 'struct | |
| 334 | + | refspec'. | |
| 335 | + | ||
| 336 | + | * The enumeration of untracked and ignored files in 'git status' has | |
| 337 | + | been optimized by avoiding quadratic complexity when inserting into | |
| 338 | + | string lists, reducing the construction cost from O(n^2) to O(n log | |
| 339 | + | n). | |
| 340 | + | ||
| 341 | + | * The copy_file() and copy_file_with_time() functions have been | |
| 342 | + | refactored to take a repository parameter, allowing the removal of the | |
| 343 | + | implicit dependency on the global 'the_repository' variable in | |
| 344 | + | 'copy.c'. | |
| 345 | + | ||
| 346 | + | * The tempfile and lockfile APIs have been refactored to stop depending | |
| 347 | + | on the 'the_repository' global variable, and their callers have been | |
| 348 | + | updated to use the repository-aware variants. | |
| 349 | + | ||
| 350 | + | * The 'trust_executable_bit' (coming from the 'core.filemode' | |
| 351 | + | configuration) has been migrated into 'struct repo_config_values' to | |
| 352 | + | tie it to a specific repository instance. | |
| 353 | + | ||
| 354 | + | * The 'excludes_file' and various other global configuration variables | |
| 355 | + | (including 'editor_program', 'pager_program', 'askpass_program', and | |
| 356 | + | 'push_default') have been migrated into the per-repository structure. | |
| 357 | + | ||
| 358 | + | * The 'git stash push' command has been optimized to avoid unnecessary | |
| 359 | + | sparse index expansion when pathspecs are wholly inside the | |
| 360 | + | sparse-checkout cone. Also, a potential out-of-bounds read in the | |
| 361 | + | sparse-index expansion check helper pathspec_needs_expanded_index() | |
| 362 | + | has been fixed by consistently using the parsed, prefixed path. | |
| 363 | + | ||
| 364 | + | * The logic to write loose objects has been refactored and moved from | |
| 365 | + | 'object-file.c' to the loose backend source file 'odb/source-loose.c', | |
| 366 | + | making the loose backend more self-contained. This is achieved by | |
| 367 | + | first refactoring force_object_loose() to use generic ODB write | |
| 368 | + | interfaces instead of loose-backend internals. | |
| 369 | + | ||
| 370 | + | * Object database housekeeping in 'git gc' and 'git maintenance' has | |
| 371 | + | been refactored to be pluggable. The files-backend-specific logic, | |
| 372 | + | including incremental and geometric repacking as well as object | |
| 373 | + | pruning, has been moved out of the command implementation and into the | |
| 374 | + | files object database source, enabling future alternative object | |
| 375 | + | database backends to implement their own housekeeping services. | |
| 376 | + | ||
| 377 | + | * The image version used by the static-analysis CI job has been bumped | |
| 378 | + | to ubuntu-latest (Ubuntu 24.04), which brings in a newer Coccinelle | |
| 379 | + | version that resolves a severe performance regression. A false | |
| 380 | + | positive warning from the 'CHECK_ASSERTION_SIDE_EFFECTS' build with | |
| 381 | + | GCC 15 in the Bloom filter code has also been silenced to facilitate | |
| 382 | + | the image upgrade. | |
| 383 | + | ||
| 384 | + | * The alias tests in 't/t0014-alias.sh' have been updated to dynamically | |
| 385 | + | query the list of deprecated commands using 'git | |
| 386 | + | --list-cmds=deprecated' to avoid test failures when running with | |
| 387 | + | 'WITH_BREAKING_CHANGES' in a build directory that contains stale | |
| 388 | + | executables of formerly deprecated commands. | |
| 389 | + | ||
| 390 | + | * The code path that deals with relative paths in the diff-lib has | |
| 391 | + | been cleaned up. | |
| 392 | + | ||
| 393 | + | * The get_commit_action() function has been refactored to be a pure | |
| 394 | + | predicate by moving the side-effecting line-level log range folding to | |
| 395 | + | simplify_commit(). This ensures that evaluating a commit's action | |
| 396 | + | before the walk reaches it does not prematurely mutate its tracked | |
| 397 | + | line ranges, making it safer for potential lookahead evaluations. | |
| 398 | + | ||
| 399 | + | * Synopsis and options in the documentation for 'git format-patch', | |
| 400 | + | 'git imap-send', 'git send-email', and 'git request-pull' have been | |
| 401 | + | updated to the modern style. | |
| 402 | + | ||
| 403 | + | * A new test helper commit_body() has been introduced to print the | |
| 404 | + | message body of a commit, and various tests have been updated to use | |
| 405 | + | it instead of spelling out the command pipeline manually and losing | |
| 406 | + | the exit status of the 'git cat-file' command on the upstream of the | |
| 407 | + | pipe. | |
| 408 | + | ||
| 409 | + | * Tests for 'git merge-base --is-ancestor' have been added to cover | |
| 410 | + | exit codes (0 for success, 1 for non-ancestor, 128 for errors) and | |
| 411 | + | to ensure it cannot be combined with '--all'. | |
| 412 | + | ||
| 413 | + | * The 'TRACE2_ANCESTRY' prerequisite in the 't0213' test script has been | |
| 414 | + | refined to avoid failures under user-mode emulation by verifying that | |
| 415 | + | the ancestry collector reports the expected process names rather than | |
| 416 | + | the emulator binary name. | |
| 417 | + | ||
| 418 | + | * Concurrent downloads of packfiles via packfile URIs and dumb HTTP are | |
| 419 | + | safer by avoiding concurrent appends to the staging file. Opening in | |
| 420 | + | read-write mode with separate file offsets prevents corruption and | |
| 421 | + | preserves resumability. 'fetch-pack' now tolerates pre-existing | |
| 422 | + | '.keep' files. | |
| 423 | + | ||
| 424 | + | * The 'ssh-agent' tests in 't7528' have been fixed to work when the | |
| 425 | + | user's login shell is csh-like, by explicitly passing '-s' to | |
| 426 | + | 'ssh-agent' to force Bourne shell syntax. | |
| 427 | + | ||
| 428 | + | * A compatibility wrapper for writev(3p) has been reintroduced, | |
| 429 | + | including fixes for CMake build and 'MAX_IO_SIZE' limits on NonStop. | |
| 430 | + | Calls to write(3p) in send_sideband() and cat_blob() have been | |
| 431 | + | refactored to use writev(3p) wrappers to reduce syscall overhead. | |
| 432 | + | ||
| 433 | + | * The creation of the on-disk data structures for the object database | |
| 434 | + | has been made pluggable, allowing future backends to customize their | |
| 435 | + | setup. As part of this, the initialization of the object database | |
| 436 | + | has been deferred, and the loading of the loose-object map has been | |
| 437 | + | detangled from repository initialization. | |
| 438 | + | ||
| 439 | + | * The 'struct odb_read_stream' and 'struct odb_write_stream' | |
| 440 | + | structures have been consolidated into a single unified 'struct | |
| 441 | + | odb_stream' structure, simplifying object database streaming APIs | |
| 442 | + | and enabling streaming of arbitrary object types. | |
| 443 | + | ||
| 444 | + | * The sequencer has been updated to release the object database before | |
| 445 | + | spawning 'git commit'. This prevents open file handles from | |
| 446 | + | blocking auto-maintenance tasks, such as repacking, on systems like | |
| 447 | + | Windows where open files cannot be easily unlinked. | |
| 448 | + | ||
| 449 | + | * The merge-base computation has been optimized by stopping the walk | |
| 450 | + | early when one side's exclusive commits in the queue are exhausted, | |
| 451 | + | yielding significant speedups for queries with one-sided histories. | |
| 452 | + | ||
| 453 | + | * A handful of code paths have been corrected to check return values | |
| 454 | + | from functions like curl_easy_duphandle(), deflateInit(), lseek(), | |
| 455 | + | dup(), and strbuf_getline_lf(), resolving several Coverity warnings | |
| 456 | + | about unchecked returns. | |
| 457 | + | ||
| 458 | + | * The setting of a now-unused member '.pretty_given' in the sequencer | |
| 459 | + | machinery has been removed. | |
| 460 | + | ||
| 461 | + | * The performance of adding numerous new packfiles has been improved | |
| 462 | + | by introducing a fast path for known-new packfiles to skip an | |
| 463 | + | unnecessary traversal in packfile_list_append(), avoiding a | |
| 464 | + | quadratic complexity regression on load. | |
| 465 | + | ||
| 466 | + | * The unused name parameter in 'struct chdir_notify_entry' has been | |
| 467 | + | removed from chdir_notify_register(), chdir_notify_unregister(), and | |
| 468 | + | related callback signatures across several subsystems, simplifying the | |
| 469 | + | API now that trace output no longer uses it. | |
| 470 | + | ||
| 471 | + | * A heap-use-after-free bug in the object name parsing code when | |
| 472 | + | reporting failures with a relative path to a sparse directory has | |
| 473 | + | been corrected. | |
| 474 | + | ||
| 475 | + | * The object database (odb) API has been refactored to distinguish | |
| 476 | + | between missing objects and corrupt ones by returning more | |
| 477 | + | descriptive error statuses. Both the packed and loose backends now | |
| 478 | + | faithfully propagate error details using a generic strbuf error | |
| 479 | + | mechanism, removing backend-specific leakage from central lookup | |
| 480 | + | paths. | |
| 481 | + | ||
| 482 | + | * The object database layer has been simplified by eagerly loading | |
| 483 | + | alternate object directories upon initialization, instead of | |
| 484 | + | deferring it to the first object lookup. This eliminates the need | |
| 485 | + | for scattered lazy-loading calls throughout the codebase and paves | |
| 486 | + | the way for integrating alternates with the pluggable backends. | |
| 487 | + | ||
| 488 | + | * The threshold for geometric repacking to trigger based on loose | |
| 489 | + | object count has been adjusted to match that of 'git gc --auto', | |
| 490 | + | preventing over-aggressive repacking during concurrent writes. | |
| 491 | + | ||
| 492 | + | * The 'git receive-pack' command has been updated to use a new ODB | |
| 493 | + | transaction interface for writing incoming packfiles, making it more | |
| 494 | + | backend-agnostic. | |
| 495 | + | ||
| 496 | + | * The mechanism to generate a packfile corresponding to the result of | |
| 497 | + | a fetch/push has been made pluggable through a set of object | |
| 498 | + | database callback functions, removing hardcoded references to | |
| 499 | + | 'pack-objects' and enabling alternative ODBs to serve packfiles | |
| 500 | + | themselves. | |
| 501 | + | ||
| 502 | + | * The pack-objects command has been updated to record the total bytes | |
| 503 | + | written to pack files in trace2 output, allowing performance | |
| 504 | + | analysis of different compression settings by comparing the | |
| 505 | + | resulting pack sizes. | |
| 506 | + | ||
| 507 | + | * The global variable 'fetch_if_missing' has been moved to a member in | |
| 508 | + | 'struct repository', continuing the libification process and | |
| 509 | + | allowing per-repository control (such as for submodules). | |
| 510 | + | ||
| 511 | + | * The reftable code has been optimized to avoid an unnecessary | |
| 512 | + | stat/reload of the stack when an addition already holds the | |
| 513 | + | list_file lock, reducing the number of newfstatat syscalls from | |
| 514 | + | linear to constant when writing refs. | |
| 515 | + | ||
| 516 | + | * The application of the edited patch in 'git add -e' has been | |
| 517 | + | refactored to use the internal apply API directly, avoiding the need | |
| 518 | + | to spawn a 'git apply' subprocess. | |
| 519 | + | ||
| 520 | + | * The memory ownership of argv elements passed to the revision | |
| 521 | + | machinery has been made more robust by keeping logically "freed" | |
| 522 | + | elements alive until the rev_info struct is released, preventing | |
| 523 | + | use-after-free bugs when options store references to them. | |
| 524 | + | ||
| 525 | + | * The object lookup machinery has been taught to gracefully recover | |
| 526 | + | when a multi-pack-index points to an owning pack that was removed | |
| 527 | + | during a concurrent geometric repack, and 'git replay' has been | |
| 528 | + | fixed to not segfault when reading such missing objects. | |
| 529 | + | ||
| 530 | + | * A collection of patches from Git for Windows has been upstreamed, | |
| 531 | + | mostly focusing on simplifying and robustifying build configurations | |
| 532 | + | for MinGW/MSYS2, dropping obsolete compatibility options, and allowing | |
| 533 | + | the main 'git.exe' to be used directly without the extra wrapper | |
| 534 | + | process on Windows. | |
| 535 | + | ||
| 536 | + | * The process of downloading packfile URIs in protocol v2 has been | |
| 537 | + | instrumented with a Trace2 region. This visibility allows tracking | |
| 538 | + | the cumulative time spent downloading external packs and the number | |
| 539 | + | of advertised URIs without emitting a separate event per pack. | |
| 540 | + | ||
| 541 | + | * CGI helper scripts used by HTTP-related test scripts have been updated | |
| 542 | + | to use atomic filesystem operations, preventing race conditions when | |
| 543 | + | Apache handles concurrent requests. | |
| 544 | + | ||
| 545 | + | * "git maintenance" triggered "rerere gc" in unappropriate times and | |
| 546 | + | interfered with "git rebase" etc. too much. The conditions "rerere | |
| 547 | + | gc" gets triggered have been tweaked. | |
| 548 | + | ||
| 549 | + | * Windows build switches from MINGW64 to URCR64 runtime starting Git | |
| 550 | + | 2.56.0; switch the cmake based build at the same time. | |
| 551 | + | ||
| 552 | + | * The mechanism to register in-memory alternate object sources has | |
| 553 | + | been removed, as submodule object databases are now accessed | |
| 554 | + | natively via their own repository structures. This simplifies | |
| 555 | + | object database management and prepares the codebase for migrating | |
| 556 | + | alternate tracking into the files backend. | |
| 557 | + | ||
| 558 | + | * The consistency checks for the object database (fsck) have been | |
| 559 | + | decoupled from the generic builtin implementation and moved into the | |
| 560 | + | backend-specific object source layers, making them pluggable for | |
| 561 | + | different object storage formats. | |
| 562 | + | ||
| 563 | + | * When cross-compiling with Cargo, the output artifact is placed in a | |
| 564 | + | target-specific subdirectory, which causes the build system to fail | |
| 565 | + | to locate it. The build system has been updated to respect the | |
| 566 | + | 'CARGO_BUILD_TARGET' environment variable. | |
| 567 | + | ||
| 568 | + | ||
| 569 | + | Fixes since v2.55 | |
| 570 | + | ----------------- | |
| 571 | + | ||
| 572 | + | * A regression in the error diagnosis code for invalid .git files has | |
| 573 | + | been fixed, avoiding a potential NULL-pointer crash when reporting | |
| 574 | + | that a .git file does not point to a valid repository. | |
| 575 | + | (merge 54a441bcea jk/setup-gitfile-diag-fix later to maint). | |
| 576 | + | ||
| 577 | + | * Support for hashing loose or packed objects larger than 4GB on Windows | |
| 578 | + | and other LLP64 platforms has been improved by converting object header | |
| 579 | + | buffers and data-handling functions from 'unsigned long' to 'size_t'. | |
| 580 | + | (merge d99e13d0be po/hash-object-size-t later to maint). | |
| 581 | + | ||
| 582 | + | * The display of the rebase todo list in "git status" has been | |
| 583 | + | improved to correctly abbreviate object IDs for more commands and | |
| 584 | + | avoid misinterpreting refs as object IDs. | |
| 585 | + | (merge 6f34e5f9e3 pw/status-rebase-todo later to maint). | |
| 586 | + | ||
| 587 | + | * Reference backend configuration has been updated to load lazily to | |
| 588 | + | avoid recursive calls during repository initialization when 'onbranch' | |
| 589 | + | configuration conditions are evaluated. This has also fixed a memory | |
| 590 | + | leak and allowed the unused `chdir_notify_reparent()` machinery to be | |
| 591 | + | dropped. | |
| 592 | + | (merge d6522d01df ps/refs-onbranch-fixes later to maint). | |
| 593 | + | ||
| 594 | + | * The connectivity check has been refactored to search for promisor | |
| 595 | + | objects in a generic way using the object database interface, | |
| 596 | + | rather than iterating packfiles directly. This allows connectivity | |
| 597 | + | checks to work properly in repositories that do not use packfiles. | |
| 598 | + | (merge 66ee9cb930 ps/connected-generic-promisor-checks later to maint). | |
| 599 | + | ||
| 600 | + | * A test checking interactions between git rebase --quit and | |
| 601 | + | autostash in t3420-rebase-autostash.sh has been corrected to use | |
| 602 | + | test_path_is_missing instead of ! grep on a file that shouldn't | |
| 603 | + | exist in the conflicted state. | |
| 604 | + | (merge eaad121fef sg/t3420-do-not-grep-in-missing-file later to maint). | |
| 605 | + | ||
| 606 | + | * The GPG and SSH signature parsing code has been corrected to strip | |
| 607 | + | carriage return characters only when they immediately precede line | |
| 608 | + | feeds, instead of unconditionally stripping all carriage returns. | |
| 609 | + | (merge 5dea8b690b ad/gpg-strip-cr-before-lf later to maint). | |
| 610 | + | ||
| 611 | + | * A memory leak in the 'reftable_writer_new()' initialization function | |
| 612 | + | has been fixed by delaying the allocation of 'struct reftable_writer' | |
| 613 | + | until after input options are validated. | |
| 614 | + | (merge c6fb3b9c3e jk/reftable-leakfix later to maint). | |
| 615 | + | ||
| 616 | + | * A memory leak in the '--base' handling of 'git format-patch' has been | |
| 617 | + | plugged, and the leak reporting of the test suite when running under a | |
| 618 | + | TAP harness has been improved. | |
| 619 | + | (merge 973a0373ff jk/format-patch-leakfix later to maint). | |
| 620 | + | ||
| 621 | + | * A write file stream resource leak has been fixed as part of a code | |
| 622 | + | cleanup. | |
| 623 | + | (merge ebb4d2ffa3 jc/history-message-prep-fix later to maint). | |
| 624 | + | ||
| 625 | + | * Various memory leaks in the Bloom-filter code paths that are exposed | |
| 626 | + | when running tests with the 'GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1' | |
| 627 | + | environment variable have been plugged. | |
| 628 | + | (merge 459088ec2e jk/bloom-leak-fixes later to maint). | |
| 629 | + | ||
| 630 | + | * The wincred credential helper has been updated to avoid memory | |
| 631 | + | corruption when erasing credentials and to prevent silent | |
| 632 | + | credential loss when storing OAuth tokens, by correcting buffer | |
| 633 | + | allocations and arguments passed to safe-CRT APIs. | |
| 634 | + | (merge f635ab9ab4 js/wincred-fixes later to maint). | |
| 635 | + | ||
| 636 | + | * Various code paths that initialize a cryptographic hash context but | |
| 637 | + | bail out or finish without calling 'git_hash_final()' have been taught | |
| 638 | + | to call 'git_hash_discard()' to release allocated resources, fixing | |
| 639 | + | memory leaks when Git is built with non-default backends like | |
| 640 | + | 'OpenSSL' or 'libgcrypt'. | |
| 641 | + | (merge 600588d2aa jk/hash-algo-leak-fixes later to maint). | |
| 642 | + | ||
| 643 | + | * Various resource leaks, invalid file descriptor closures, and process | |
| 644 | + | handle ownership issues flagged by Coverity have been fixed. | |
| 645 | + | (merge 9184231173 js/coverity-fixes later to maint). | |
| 646 | + | ||
| 647 | + | * Dockerized CI jobs running in private GitHub repositories have been | |
| 648 | + | adjusted to use explicit process and file limits, preventing resource | |
| 649 | + | exhaustion errors on private runners. | |
| 650 | + | (merge bad766fbac js/ci-dockerized-pid-limit later to maint). | |
| 651 | + | ||
| 652 | + | * Various test scripts have been updated to clean up large temporary | |
| 653 | + | files and repositories, reducing peak disk usage during testing. | |
| 654 | + | Also, expensive tests have been disabled on platforms that lack | |
| 655 | + | sufficient resources (like 32-bit platforms and Windows CI runners), | |
| 656 | + | and the long test suite has been enabled in GitLab CI. | |
| 657 | + | (merge 84248444ad ps/t-fixes-for-git-test-long later to maint). | |
| 658 | + | ||
| 659 | + | * The UTF-8 precomposition wrapper on macOS has been updated to use a | |
| 660 | + | flexible array member to represent the name of a directory entry, | |
| 661 | + | preventing fortified libc checks from failing when the name is | |
| 662 | + | reallocated to be larger than 'NAME_MAX' bytes. | |
| 663 | + | (merge 1eb281159f ih/precompose-flex-array later to maint). | |
| 664 | + | ||
| 665 | + | * The 'git_hash_*()' wrappers have been updated to be used consistently | |
| 666 | + | across the codebase instead of direct calls to members of 'struct | |
| 667 | + | git_hash_algo', and 'git_hash_discard()' has been made idempotent to | |
| 668 | + | simplify cleanups. | |
| 669 | + | (merge 9e396aa553 jk/git-hash-cleanups later to maint). | |
| 670 | + | ||
| 671 | + | * The sideband demultiplexer has been updated to recognize ANSI SGR | |
| 672 | + | escape sequences that use colon-separated subfields (e.g., for | |
| 673 | + | 256-color or true-color codes). | |
| 674 | + | (merge 3792b2aea4 mm/sideband-ansi-sgr-colon-fix later to maint). | |
| 675 | + | ||
| 676 | + | * The 'reftable' code has been hardened against corrupted tables by | |
| 677 | + | fixing out-of-bounds writes, out-of-bounds reads, and abort calls | |
| 678 | + | during parsing. | |
| 679 | + | (merge ca93c27328 ps/reftable-hardening later to maint). | |
| 680 | + | ||
| 681 | + | * A description in the release notes for Git 2.55.0 has been | |
| 682 | + | retroactively updated to clarify that Rust support is enabled by | |
| 683 | + | default, but still optional, and will become mandatory in Git 3.0. | |
| 684 | + | (merge 18b2009d14 jc/relnotes-2.55-rust-fix later to maint). | |
| 685 | + | ||
| 686 | + | * The early-exit optimization in 'paint_down_to_common()' has been | |
| 687 | + | gated on the queue being generation-ordered, fixing a bug where | |
| 688 | + | 'git merge-base' (without '--all') could return incorrect results | |
| 689 | + | on repositories with v1 commit graphs and clock skew. | |
| 690 | + | (merge ae68032a8d kk/commit-reach-find-all-fix later to maint). | |
| 691 | + | ||
| 692 | + | * The client-side parser of the server-advertised bundle-URI list has | |
| 693 | + | been updated to drain the remaining response in order to avoid | |
| 694 | + | protocol desynchronization when the server sends a misconfigured list. | |
| 695 | + | Also, the server-side has been taught to omit empty configuration | |
| 696 | + | values instead of sending invalid key-value lines. | |
| 697 | + | (merge 50de1169e4 tc/bundle-uri-empty-fix later to maint). | |
| 698 | + | ||
| 699 | + | * The 'topo_levels' slab was propagated only to the topmost layer of a | |
| 700 | + | split commit-graph chain, causing topological levels for commits in | |
| 701 | + | base layers to be recomputed during incremental writes. This has been | |
| 702 | + | corrected. | |
| 703 | + | ||
| 704 | + | * The stream-based object signature verification path has been | |
| 705 | + | corrected to avoid double-closing the stream on read errors. | |
| 706 | + | (merge cfd52a74a0 ps/odb-stream-double-close-fix later to maint). | |
| 707 | + | ||
| 708 | + | * The '-i' shorthand for the '--init' option, which was accepted by the | |
| 709 | + | 'git submodule update' command until it was broken in a modernization | |
| 710 | + | of the option-parsing code, has been restored. | |
| 711 | + | (merge ff1da37f58 dm/submodule-update-i-shorthand later to maint). | |
| 712 | + | ||
| 713 | + | * An accidental use of the '%zu' format specifier in 'git | |
| 714 | + | submodule--helper' has been corrected to use 'PRIuMAX' and cast the | |
| 715 | + | value to 'uintmax_t' to avoid portability issues. | |
| 716 | + | (merge 3279c13c00 jc/submodule-helper-avoid-zu later to maint). | |
| 717 | + | ||
| 718 | + | * The rebase post-rewrite notes-copying logic has been corrected. When | |
| 719 | + | a commit is dropped during rebase (e.g., because its changes are | |
| 720 | + | already upstream), it is no longer recorded as rewritten, preventing | |
| 721 | + | its notes from being copied to an unrelated commit. | |
| 722 | + | (merge 42554b78fd pw/rebase-drop-notes-with-commit later to maint). | |
| 723 | + | ||
| 724 | + | * A few memory problems in the Rust interface to C hash functions have | |
| 725 | + | been corrected. The 'Clone' implementation of 'CryptoHasher' now | |
| 726 | + | properly initializes the context before cloning, and its 'Drop' | |
| 727 | + | implementation now discards the context to prevent leaks. | |
| 728 | + | ||
| 729 | + | * The object ID shortening and linking in the 'commitdiff' view of | |
| 730 | + | 'gitweb' has been corrected to work even when the index line carries | |
| 731 | + | a trailing file mode. | |
| 732 | + | (merge fda513d6fe tl/gitweb-shorten-hashes-with-modes later to maint). | |
| 733 | + | ||
| 734 | + | * When the push remote is specified as a URL, the fetch refspec of a | |
| 735 | + | uniquely matching configured remote is now used to find and update | |
| 736 | + | the remote-tracking branch (e.g., '@{push}'). | |
| 737 | + | ||
| 738 | + | * Traversals with '--exclude-first-parent-only' have been corrected | |
| 739 | + | to properly stop after the first parent even when it has already | |
| 740 | + | been marked as 'SEEN'. | |
| 741 | + | (merge 47382f7398 jc/exclude-first-parent-seen later to maint). | |
| 742 | + | ||
| 743 | + | * A segfault when 'git clone --revision' talks to a server that does not | |
| 744 | + | support protocol v2 (falling back to protocol v0) has been corrected. | |
| 745 | + | (merge 1034ad383f af/clone-revision-v0-segfault-fix later to maint). | |
| 746 | + | ||
| 747 | + | * rewrites_release() in 'remote.c' has been updated to free 'struct | |
| 748 | + | rewrite' instances, their '.instead_of' arrays, and their contents. | |
| 749 | + | (merge dcef3bf041 jc/remote-insteadof-leakfix later to maint). | |
| 750 | + | ||
| 751 | + | * The remote-matching logic for submodules has been corrected to resolve | |
| 752 | + | 'url.*.insteadOf' aliases before comparing the inventoried URL from | |
| 753 | + | '.gitmodules' with the URLs of configured remotes. | |
| 754 | + | ||
| 755 | + | * 'git diff --relative' running with '--cached' has been corrected to | |
| 756 | + | avoid a segfault when encountering unmerged paths outside the | |
| 757 | + | prefix. | |
| 758 | + | (merge 447126ed7d jk/diff-relative-cached-unmerged later to maint). | |
| 759 | + | ||
| 760 | + | * Two bugs in how 'git rebase' handles skipped 'fixup' and 'squash' | |
| 761 | + | commands have been fixed. One bug caused an incorrect commit count to | |
| 762 | + | be shown in the template message when multiple commands were skipped, | |
| 763 | + | and another prevented the editor from opening when the final command | |
| 764 | + | in a chain containing 'fixup -c' was skipped. | |
| 765 | + | ||
| 766 | + | * Git for Windows has been updated to avoid auto-detecting the symlink | |
| 767 | + | type if the target path starts with a slash, preventing NTLM | |
| 768 | + | credential leaks when checking out repositories with crafted | |
| 769 | + | symbolic links pointing to network shares. | |
| 770 | + | ||
| 771 | + | * 'git cat-file --batch-command' that asked for 'contents' without | |
| 772 | + | 'type' segfaults, which has been corrected. | |
| 773 | + | (merge 2abc7f0304 jk/cat-file-batch-wo-type-fix later to maint). | |
| 774 | + | ||
| 775 | + | * A memory leak in 'git merge' when run without arguments (which | |
| 776 | + | triggers the default-to-upstream path) has been fixed. A test has | |
| 777 | + | been added to cover this case. | |
| 778 | + | (merge 68cce04a02 tc/merge-default-to-upstream-leakfix later to maint). | |
| 779 | + | ||
| 780 | + | * A boundary case check in reachability bitmap traversal has been | |
| 781 | + | corrected to properly handle the object at position zero, which was | |
| 782 | + | previously skipped, leading to redundant bitmap loading. | |
| 783 | + | (merge b56b48301e dl/pack-bitmap-position-zero later to maint). | |
| 784 | + | ||
| 785 | + | * A crash in the 'sparse-index' collapse code when encountering an | |
| 786 | + | invalidated cache-tree node (due to an intent-to-add path) has been | |
| 787 | + | fixed by avoiding collapsing such subtrees. | |
| 788 | + | (merge eede1e69fe ds/sparse-index-ita-crash later to maint). | |
| 789 | + | ||
| 790 | + | * Documentation for 'git replay' has been updated to refer to its | |
| 791 | + | configuration variables. | |
| 792 | + | (merge 48c0549f5c kh/doc-replay-config later to maint). | |
| 793 | + | ||
| 794 | + | * Documentation for 'git interpret-trailers' has been updated to explain | |
| 795 | + | the format of trailer keys (alphanumeric characters and hyphens), | |
| 796 | + | replace outdated terminology, define key terms upfront, and document | |
| 797 | + | how comment lines in the input are treated. | |
| 798 | + | (merge 4515c86fd9 kh/doc-trailers later to maint). | |
| 799 | + | ||
| 800 | + | * The 'pack-objects' and delta-encoding code paths have been updated to | |
| 801 | + | use 'size_t' instead of 'unsigned long' for object sizes and offset | |
| 802 | + | limits, avoiding potential truncation issues on 64-bit Windows. | |
| 803 | + | (merge d50ac11724 js/pack-objects-delta-size-t later to maint). | |
| 804 | + | ||
| 805 | + | * A client requesting the promisor-remote capability without a value | |
| 806 | + | caused a null pointer dereference, which has been corrected by | |
| 807 | + | rejecting a request without an argument. | |
| 808 | + | (merge dd6b35ff71 en/serve-promisor-remote-fix later to maint). | |
| 809 | + | ||
| 810 | + | * Various tests in 't7900-maintenance.sh' have been updated to use a | |
| 811 | + | throwaway repository, and auto-detaching of maintenance tasks is now | |
| 812 | + | disabled for these tests to fix flaky races with concurrent background | |
| 813 | + | maintenance jobs. | |
| 814 | + | (merge 2775d8bcd1 ps/t7900-deflake-maintenance later to maint). | |
| 815 | + | ||
| 816 | + | * The help text for the '-l' option of 'git diff' has been updated. | |
| 817 | + | (merge 764243bdf4 en/diff-l-opt-help later to maint). | |
| 818 | + | ||
| 819 | + | * 'git -C <dir> diff fi<TAB>' did not complete 'file', which has | |
| 820 | + | been corrected. | |
| 821 | + | (merge 354d1bf3a0 jc/complete-diff-tracked-paths later to maint). | |
| 822 | + | ||
| 823 | + | * 'git -C <dir> checkout fi<TAB>' did not complete 'file', which has | |
| 824 | + | been corrected. | |
| 825 | + | (merge 05e2ab1f31 jc/complete-checkout later to maint). | |
| 826 | + | ||
| 827 | + | * The trailer parsing machinery has been updated to avoid mistaking | |
| 828 | + | lines that begin with a URL (e.g., 'https://...') as trailer lines. | |
| 829 | + | This prevents intended textual URLs from being mangled or mistakenly | |
| 830 | + | treated as metadata keys. | |
| 831 | + | ||
| 832 | + | * The instructions for deprecated commands emitted by | |
| 833 | + | you_still_use_that() have been reworded to clarify that the removal | |
| 834 | + | decision is final and to provide more assertive guidance on finding | |
| 835 | + | a replacement. | |
| 836 | + | (merge 8ace32221c jc/you-still-use-that later to maint). | |
| 837 | + | ||
| 838 | + | * The zsh completion script (in 'contrib/') has been updated to | |
| 839 | + | correctly locate the Git command after global options like '-C' by | |
| 840 | + | properly skipping them, similar to how the bash completion does. | |
| 841 | + | ||
| 842 | + | * The git worktree repair command failed to rewrite the .git file of | |
| 843 | + | a working tree from a relative path to an absolute path when the | |
| 844 | + | command was run in the working tree itself. The | |
| 845 | + | read_gitfile_gently() function was modified to also return whether | |
| 846 | + | the path originally recorded in the file was absolute, and this new | |
| 847 | + | capability is used to correctly detect such mismatches. | |
| 848 | + | ||
| 849 | + | * GitHub Actions CI workflow runs triggered by pull requests have | |
| 850 | + | been configured to cancel older runs when a new push is made to the | |
| 851 | + | same pull request. | |
| 852 | + | (merge a251b1bd21 hn/ci-cancel-stale-pr-runs later to maint). | |
| 853 | + | ||
| 854 | + | * The string extraction logic for the branch name and worktree name | |
| 855 | + | from the given path in 'git worktree add' has been corrected and | |
| 856 | + | simplified to avoid out-of-bounds reads and improper handling of | |
| 857 | + | trailing slashes. | |
| 858 | + | (merge 2e8a9d94b0 rs/worktree-add-basename-fixes later to maint). | |
| 859 | + | ||
| 860 | + | * The CI job for Debian 11 has been updated to use Debian 12, as the | |
| 861 | + | former is now out of the LTS period. | |
| 862 | + | (merge 00fa850235 jk/ci-bump-debian-to-12 later to maint). | |
| 863 | + | ||
| 864 | + | * The CI script to install dependencies for the documentation build | |
| 865 | + | has been updated to install asciidoctor directly via the system | |
| 866 | + | package manager instead of pinning to an older version via gem. | |
| 867 | + | Additionally, an obsolete variable used for retired Azure Pipelines | |
| 868 | + | environments has been removed. | |
| 869 | + | ||
| 870 | + | * The error path in 'git submodule--helper' has been updated to plug a | |
| 871 | + | memory leak when a repository handle could not be obtained, | |
| 872 | + | leveraging an updated idempotent repo_clear(). | |
| 873 | + | (merge 2c03739705 jk/submodule-error-leak later to maint). | |
| 874 | + | ||
| 875 | + | * Two members in "struct pathspec_item" were of type "char *", but | |
| 876 | + | nobody updated the string through these pointers. They have been | |
| 877 | + | made "const char *" instead. | |
| 878 | + | (merge 88d06b1c91 jc/pathspec-match-const later to maint). | |
| 879 | + | ||
| 880 | + | * The gitdatamodel documentation page has been linked from a handful | |
| 881 | + | of key documentaiton pages. | |
| 882 | + | (merge ec602484bd kh/doc-datamodel later to maint). | |
| 883 | + | ||
| 884 | + | * Running "git history" in a corrupt repository can (unsurprisingly) | |
| 885 | + | segfault when a necessary tree object is not found, which has been | |
| 886 | + | made to die more gracefully. | |
| 887 | + | (merge 76621488e8 jc/history-missing-tree-errorfix later to maint). | |
| 888 | + | ||
| 889 | + | * The development helper script to lint gitlink references in the | |
| 890 | + | documentation has been updated to avoid a newer Perl regular | |
| 891 | + | expression syntax that breaks on older Perl versions. | |
| 892 | + | (merge 8a631963a9 ta/lint-gitlink-older-perl-fix later to maint). | |
| 893 | + | ||
| 894 | + | * The autostash fallback in 'git checkout -m' has been refined to only | |
| 895 | + | retry when there are local changes. Additionally, a blank line now | |
| 896 | + | visually separates autostash conflict advice from the subsequent | |
| 897 | + | branch-switch message. | |
| 898 | + | (merge 2ba77ea828 hn/checkout-m-autostash-refine later to maint). | |
| 899 | + | ||
| 900 | + | * The memory leak caused by not unusing the commit buffer returned by | |
| 901 | + | repo_logmsg_reencode() during the rewording operation in 'git | |
| 902 | + | history' has been plugged. | |
| 903 | + | ||
| 904 | + | * The pathspec matching logic has been updated to avoid out-of-bounds | |
| 905 | + | memory accesses when a negative pathspec is shorter than the common | |
| 906 | + | prefix of positive pathspecs. | |
| 907 | + | ||
| 908 | + | * Other code cleanup, docfix, build fix, etc. | |
| 909 | + | (merge 026636128f ss/submittingpatches-typofix later to maint). | |
| 910 | + | (merge d2af22cc21 jc/rerere-doc-typofix later to maint). | |
| 911 | + | (merge c486c1df72 hk/typofix later to maint). | |
modified Documentation/SubmittingPatches
| @@ -48,13 +48,41 @@ area. | |||
| 48 | 48 | ||
| 49 | 49 | . You get comments and suggestions for improvements. You may even get | |
| 50 | 50 | them in an "on top of your change" patch form. You are expected to | |
| 51 | - | respond to them with "Reply-All" on the mailing list, while taking | |
| 52 | - | them into account while preparing an updated set of patches. | |
| 51 | + | respond to them with "Reply-All" on the mailing list, instead of | |
| 52 | + | letting an updated patch series be your only response. Tell | |
| 53 | + | reviewers which suggestions you plan to use, which ones you disagree | |
| 54 | + | with, and when a comment leads you to consider a different approach. | |
| 55 | + | Use these replies and any follow-up discussion as input when | |
| 56 | + | preparing an updated set of patches. | |
| 57 | + | + | |
| 58 | + | Be particularly mindful of critiques regarding the high-level design | |
| 59 | + | or viability of your proposal (e.g., questioning if the feature is | |
| 60 | + | worth implementing, or if the chosen approach is appropriate). Defend | |
| 61 | + | your design decisions on the list first and work with reviewers and | |
| 62 | + | other members to improve the design before revising the implementation. | |
| 63 | + | This will avoid wasting effort on an implementation before its design is | |
| 64 | + | solid. | |
| 65 | + | + | |
| 66 | + | Make sure that any new version explains and justifies those design | |
| 67 | + | decisions more clearly, in the cover letter and in the revised commit | |
| 68 | + | messages. Aim to make the reviewers say "it is now clear why we may | |
| 69 | + | want to do this with the updated version". | |
| 70 | + | + | |
| 71 | + | Topics with unresolved fundamental design critiques will not be | |
| 72 | + | considered ready for merging. | |
| 53 | 73 | + | |
| 54 | 74 | It is often beneficial to allow some time for reviewers to provide | |
| 55 | 75 | feedback before sending a new version, rather than sending an updated | |
| 56 | 76 | series immediately after receiving a review. This helps collect broader | |
| 57 | - | input and avoids unnecessary churn from many rapid iterations. | |
| 77 | + | input, gives reviewers in different time zones a fair chance to comment, | |
| 78 | + | and avoids unnecessary churn from many rapid iterations. Waiting also | |
| 79 | + | encourages you to polish each version before sending it, so reviewers | |
| 80 | + | can focus on substantial issues rather than typos or other small | |
| 81 | + | mistakes. | |
| 82 | + | + | |
| 83 | + | As a rough default, avoid sending more than one new version of the same | |
| 84 | + | series per day, while considering the size of the series and the depth | |
| 85 | + | of review. | |
| 58 | 86 | ||
| 59 | 87 | . These early update iterations are expected to be full replacements, | |
| 60 | 88 | not incremental updates on top of what you posted already. If you | |
| @@ -89,12 +117,26 @@ input and avoids unnecessary churn from many rapid iterations. | |||
| 89 | 117 | can still continue to further improve them by adding more patches on | |
| 90 | 118 | top, but by the time a topic gets merged to 'next', it is expected | |
| 91 | 119 | that everybody agrees that the scope and the basic direction of the | |
| 92 | - | topic are appropriate, so such an incremental updates are limited to | |
| 120 | + | topic are appropriate, so such incremental updates are limited to | |
| 93 | 121 | small corrections and polishing. After a topic cooks for some time | |
| 94 | 122 | (like 7 calendar days) in 'next' without needing further tweaks on | |
| 95 | - | top, it gets merged to the 'master' branch and wait to become part | |
| 123 | + | top, it gets merged to the 'master' branch and waits to become part | |
| 96 | 124 | of the next major release. | |
| 97 | 125 | ||
| 126 | + | But sometimes things do not work as planned: | |
| 127 | + | ||
| 128 | + | . If a mailing list discussion convinces you that your changes aren't | |
| 129 | + | ideal, please explicitly retract the topic to save the maintainer | |
| 130 | + | time and effort. | |
| 131 | + | ||
| 132 | + | . If you must drop a topic due to shifting priorities, lack of time, | |
| 133 | + | or other commitments, notify the list as a courtesy so others can | |
| 134 | + | take over. Anyone can resurrect the topic later when they have the | |
| 135 | + | capacity to do so. | |
| 136 | + | ||
| 137 | + | . Topics with unaddressed review comments that remain inactive for | |
| 138 | + | four weeks may be discarded by the maintainer. | |
| 139 | + | ||
| 98 | 140 | In the following sections, many techniques and conventions are listed | |
| 99 | 141 | to help your patches get reviewed effectively in such a life cycle. | |
| 100 | 142 | ||
| @@ -237,6 +279,7 @@ Do not forget to update the documentation to describe the updated | |||
| 237 | 279 | behavior and make sure that the resulting documentation set formats | |
| 238 | 280 | well (try the Documentation/doc-diff script). | |
| 239 | 281 | ||
| 282 | + | [[typofixes]] | |
| 240 | 283 | We currently have a liberal mixture of US and UK English norms for | |
| 241 | 284 | spelling and grammar, which is somewhat unfortunate. A huge patch that | |
| 242 | 285 | touches the files all over the place only to correct the inconsistency | |
| @@ -322,6 +365,10 @@ The body should provide a meaningful commit message, which: | |||
| 322 | 365 | ||
| 323 | 366 | . alternate solutions considered but discarded, if any. | |
| 324 | 367 | ||
| 368 | + | . records the resolution of design or viability concerns raised by the | |
| 369 | + | community during the review, if any, ensuring the historical record | |
| 370 | + | explains why the chosen approach was accepted over alternatives. | |
| 371 | + | ||
| 325 | 372 | [[present-tense]] | |
| 326 | 373 | The problem statement that describes the status quo is written in the | |
| 327 | 374 | present tense. Write "The code does X when it is given input Y", | |
| @@ -374,7 +421,7 @@ or, on an older version of Git without support for --pretty=reference: | |||
| 374 | 421 | .... | |
| 375 | 422 | ||
| 376 | 423 | [[sign-off]] | |
| 377 | - | === Certify your work by adding your `Signed-off-by` trailer | |
| 424 | + | === Certify your work by adding your `Signed-off-by:` trailer | |
| 378 | 425 | ||
| 379 | 426 | To improve tracking of who did what, we ask you to certify that you | |
| 380 | 427 | wrote the patch or have the right to pass it on under the same license | |
| @@ -411,7 +458,7 @@ d. I understand and agree that this project and the contribution | |||
| 411 | 458 | this project or the open source license(s) involved. | |
| 412 | 459 | ____ | |
| 413 | 460 | ||
| 414 | - | you add a "Signed-off-by" trailer to your commit, that looks like | |
| 461 | + | you add a `Signed-off-by:` trailer to your commit, that looks like | |
| 415 | 462 | this: | |
| 416 | 463 | ||
| 417 | 464 | .... | |
| @@ -421,19 +468,23 @@ this: | |||
| 421 | 468 | This line can be added by Git if you run the git-commit command with | |
| 422 | 469 | the -s option. | |
| 423 | 470 | ||
| 424 | - | Notice that you can place your own `Signed-off-by` trailer when | |
| 471 | + | Notice that you can place your own `Signed-off-by:` trailer when | |
| 425 | 472 | forwarding somebody else's patch with the above rules for | |
| 426 | 473 | D-C-O. Indeed you are encouraged to do so. Do not forget to | |
| 427 | 474 | place an in-body "From: " line at the beginning to properly attribute | |
| 428 | 475 | the change to its true author (see (2) above). | |
| 429 | 476 | ||
| 477 | + | Place this `Signed-off-by:` trailer at the end, after trailers added by | |
| 478 | + | others and after other trailers added by you; see | |
| 479 | + | <<commit-trailers,Commit trailers>> below ("chronological order"). | |
| 480 | + | ||
| 430 | 481 | This procedure originally came from the Linux kernel project, so our | |
| 431 | 482 | rule is quite similar to theirs, but what exactly it means to sign-off | |
| 432 | 483 | your patch differs from project to project, so it may be different | |
| 433 | 484 | from that of the project you are accustomed to. | |
| 434 | 485 | ||
| 435 | 486 | [[real-name]] | |
| 436 | - | Please use a known identity in the `Signed-off-by` trailer, since we cannot | |
| 487 | + | Please use a known identity in the `Signed-off-by:` trailer, since we cannot | |
| 437 | 488 | accept anonymous contributions. It is common, but not required, to use some form | |
| 438 | 489 | of your real name. We realize that some contributors are not comfortable doing | |
| 439 | 490 | so or prefer to contribute under a pseudonym or preferred name and we can accept | |
| @@ -444,7 +495,15 @@ The goal of this policy is to allow us to have sufficient information to contact | |||
| 444 | 495 | you if questions arise about your contribution. | |
| 445 | 496 | ||
| 446 | 497 | [[commit-trailers]] | |
| 447 | - | If you like, you can put extra trailers at the end: | |
| 498 | + | === Commit trailers | |
| 499 | + | It is polite to credit people who have helped with your work to a | |
| 500 | + | substantial enough degree. This project uses commit trailers for that, | |
| 501 | + | where the credited person is written out like a Git author, i.e. with | |
| 502 | + | both their name and their email address. Note that the threshold to | |
| 503 | + | credit someone is a judgement call, and crediting someone for simple | |
| 504 | + | review work is certainly not necessary. | |
| 505 | + | ||
| 506 | + | These are the common trailers in use: | |
| 448 | 507 | ||
| 449 | 508 | . `Reported-by:` is used to credit someone who found the bug that | |
| 450 | 509 | the patch attempts to fix. | |
| @@ -457,6 +516,10 @@ If you like, you can put extra trailers at the end: | |||
| 457 | 516 | and found it to have the desired effect. | |
| 458 | 517 | . `Co-authored-by:` is used to indicate that people exchanged drafts | |
| 459 | 518 | of a patch before submitting it. | |
| 519 | + | . `Based-on-patch-by:` is used when someone else authored parts of the | |
| 520 | + | patch that you are submitting. This might be relevant if someone sent | |
| 521 | + | a patch to the mailing list with their sign-off. (Be mindful and ask | |
| 522 | + | them to sign off on it if they did not.) | |
| 460 | 523 | . `Helped-by:` is used to credit someone who suggested ideas for | |
| 461 | 524 | changes without providing the precise changes in patch form. | |
| 462 | 525 | . `Mentored-by:` is used to credit someone with helping develop a | |
| @@ -468,8 +531,42 @@ While you can also create your own trailer if the situation warrants it, we | |||
| 468 | 531 | encourage you to instead use one of the common trailers in this project | |
| 469 | 532 | highlighted above. | |
| 470 | 533 | ||
| 534 | + | Other projects might regularly refer to other kinds of data, like | |
| 535 | + | `Fixes:` and `Link:` in the Linux Kernel project, but these ones in | |
| 536 | + | particular are not used in this project. | |
| 537 | + | ||
| 471 | 538 | Only capitalize the very first letter of the trailer, i.e. favor | |
| 472 | - | "Signed-off-by" over "Signed-Off-By" and "Acked-by:" over "Acked-By". | |
| 539 | + | `Signed-off-by:` over `Signed-Off-By:` and `Acked-by:` over `Acked-By:`. | |
| 540 | + | ||
| 541 | + | As mentioned under <<dco,DCO>> above, trailers are added in | |
| 542 | + | chronological order; one person might sign-off on a patch and send it to | |
| 543 | + | someone else, who then in turn adds her own sign-off. Further, any | |
| 544 | + | trailers that you add beyond your sign-off should come before that | |
| 545 | + | sign-off. That makes it clear what trailers which person added. | |
| 546 | + | ||
| 547 | + | [[cover-letter]] | |
| 548 | + | === Cover Letter | |
| 549 | + | ||
| 550 | + | The purpose of your cover letter is to sell your changes, explain what | |
| 551 | + | they are about, and get your target audience interested enough to read | |
| 552 | + | the patches. | |
| 553 | + | ||
| 554 | + | . Every code change comes with risk of regression and maintenance cost. | |
| 555 | + | The cover letter should clearly communicate why the value of your | |
| 556 | + | proposed change is worth applying. You can also describe how the risk | |
| 557 | + | is reduced by the design choices you made while writing the patches. | |
| 558 | + | ||
| 559 | + | . Make sure your target audience can understand what the patches are | |
| 560 | + | about and why they are needed without prior context. | |
| 561 | + | ||
| 562 | + | . For a second or subsequent iteration of the same topic, make sure | |
| 563 | + | people who missed the earlier discussion can still understand what | |
| 564 | + | the patches are about, so they can judge if the topic is worth their | |
| 565 | + | time to read and comment on. | |
| 566 | + | ||
| 567 | + | . To help those who are familiar with earlier iterations, give a | |
| 568 | + | summary of changes since the previous rounds. | |
| 569 | + | ||
| 473 | 570 | ||
| 474 | 571 | [[ai]] | |
| 475 | 572 | === Use of Artificial Intelligence (AI) | |
| @@ -562,8 +659,8 @@ when the maintainer did not heavily participate in the discussion and | |||
| 562 | 659 | instead left the review to trusted others. | |
| 563 | 660 | ||
| 564 | 661 | Do not forget to add trailers such as `Acked-by:`, `Reviewed-by:` and | |
| 565 | - | `Tested-by:` lines as necessary to credit people who helped your | |
| 566 | - | patch, and "cc:" them when sending such a final version for inclusion. | |
| 662 | + | `Tested-by:` (see <<commit-trailers,Commit trailers>>), and "cc:" them | |
| 663 | + | when sending such a final version for inclusion. | |
| 567 | 664 | ||
| 568 | 665 | ==== `format-patch` and `send-email` | |
| 569 | 666 | ||
| @@ -573,8 +670,10 @@ your existing e-mail client (often optimized for "multipart/*" MIME | |||
| 573 | 670 | type e-mails) might render your patches unusable. | |
| 574 | 671 | ||
| 575 | 672 | NOTE: Here we outline the procedure using `format-patch` and | |
| 576 | - | `send-email`, but you can instead use GitGitGadget to send in your | |
| 577 | - | patches (see link:MyFirstContribution.html[MyFirstContribution]). | |
| 673 | + | `send-email`, but you can instead use GitGitGadget or `b4` to send in | |
| 674 | + | your patches (see link:MyFirstContribution.html[MyFirstContribution]). | |
| 675 | + | Contributors are encouraged to use `b4`, which automates much of the | |
| 676 | + | bookkeeping that is otherwise done by hand. | |
| 578 | 677 | ||
| 579 | 678 | People on the Git mailing list need to be able to read and | |
| 580 | 679 | comment on the changes you are submitting. It is important for | |
| @@ -588,10 +687,13 @@ grouped into their own e-mail thread to help readers find all parts of the | |||
| 588 | 687 | series. To that end, send them as replies to either an additional "cover | |
| 589 | 688 | letter" message (see below), the first patch, or the respective preceding patch. | |
| 590 | 689 | Here is a link:MyFirstContribution.html#v2-git-send-email[step-by-step guide] on | |
| 591 | - | how to submit updated versions of a patch series. | |
| 690 | + | how to submit updated versions of a patch series. Before sending another | |
| 691 | + | version, make sure you have answered meaningful review comments in the existing | |
| 692 | + | discussion. Also give reviewers enough time to comment before sending another | |
| 693 | + | version. | |
| 592 | 694 | ||
| 593 | 695 | If your log message (including your name on the | |
| 594 | - | `Signed-off-by` trailer) is not writable in ASCII, make sure that | |
| 696 | + | `Signed-off-by:` trailer) is not writable in ASCII, make sure that | |
| 595 | 697 | you send off a message in the correct encoding. | |
| 596 | 698 | ||
| 597 | 699 | WARNING: Be wary of your MUAs word-wrap | |
| @@ -611,7 +713,7 @@ previously sent. | |||
| 611 | 713 | The `git format-patch` command follows the best current practice to | |
| 612 | 714 | format the body of an e-mail message. At the beginning of the | |
| 613 | 715 | patch should come your commit message, ending with the | |
| 614 | - | `Signed-off-by` trailers, and a line that consists of three dashes, | |
| 716 | + | `Signed-off-by:` trailers, and a line that consists of three dashes, | |
| 615 | 717 | followed by the diffstat information and the patch itself. If | |
| 616 | 718 | you are forwarding a patch from somebody else, optionally, at | |
| 617 | 719 | the beginning of the e-mail message just before the commit | |
| @@ -817,6 +919,17 @@ relevant for debugging. | |||
| 817 | 919 | Then fix the problem and push your fix to your GitHub fork. This will | |
| 818 | 920 | trigger a new CI build to ensure all tests pass. | |
| 819 | 921 | ||
| 922 | + | Even if you do not use GitHub CI to test your changes, pay close | |
| 923 | + | attention to new failures on the branches when the maintainer pushes | |
| 924 | + | out after your topic gets merged to the 'seen' branch to make sure | |
| 925 | + | that your topic is not breaking the CI, and retract your breaking | |
| 926 | + | topic quickly while you fix the breakage you caused. | |
| 927 | + | ||
| 928 | + | To see maintainer's push, keep an eye on this page: | |
| 929 | + | ||
| 930 | + | `https://github.com/git/git/actions/workflows/main.yml?query=event%3Apush+actor%3Agitster` | |
| 931 | + | ||
| 932 | + | ||
| 820 | 933 | [[mua]] | |
| 821 | 934 | == MUA specific hints | |
| 822 | 935 | ||
modified Documentation/asciidoc.conf.in
| @@ -84,6 +84,9 @@ ifdef::doctype-manpage[] | |||
| 84 | 84 | [blockdef-open] | |
| 85 | 85 | synopsis-style=template="verseparagraph",filter="sed 's!…\\(\\]\\|$\\)!<phrase>\\0</phrase>!g;s!\\([\\[ |()]\\|^\\|\\]\\|>\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|…\\)!\\1<literal>\\2</literal>!g;s!<[-a-zA-Z0-9.]\\+>!<emphasis>\\0</emphasis>!g'" | |
| 86 | 86 | ||
| 87 | + | [blockdef-listing] | |
| 88 | + | synopsis-style=template="verseparagraph",filter="sed 's!…\\(\\]\\|$\\)!<phrase>\\0</phrase>!g;s!\\([\\[ |()]\\|^\\|\\]\\|>\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|…\\)!\\1<literal>\\2</literal>!g;s!<[-a-zA-Z0-9.]\\+>!<emphasis>\\0</emphasis>!g'" | |
| 89 | + | ||
| 87 | 90 | [paradef-default] | |
| 88 | 91 | synopsis-style=template="verseparagraph",filter="sed 's!…\\(\\]\\|$\\)!<phrase>\\0</phrase>!g;s!\\([\\[ |()]\\|^\\|\\]\\|>\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|…\\)!\\1<literal>\\2</literal>!g;s!<[-a-zA-Z0-9.]\\+>!<emphasis>\\0</emphasis>!g'" | |
| 89 | 92 | endif::doctype-manpage[] | |
| @@ -93,6 +96,9 @@ ifdef::backend-xhtml11[] | |||
| 93 | 96 | [blockdef-open] | |
| 94 | 97 | synopsis-style=template="verseparagraph",filter="sed 's!…\\(\\]\\|$\\)!<span>\\0</span>!g;s!\\([\\[ |()]\\|^\\|\\]\\|>\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|…\\)!\\1<code>\\2</code>!g;s!<[-a-zA-Z0-9.]\\+>!<em>\\0</em>!g'" | |
| 95 | 98 | ||
| 99 | + | [blockdef-listing] | |
| 100 | + | synopsis-style=template="verseparagraph",filter="sed 's!…\\(\\]\\|$\\)!<span>\\0</span>!g;s!\\([\\[ |()]\\|^\\|\\]\\|>\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|…\\)!\\1<code>\\2</code>!g;s!<[-a-zA-Z0-9.]\\+>!<em>\\0</em>!g'" | |
| 101 | + | ||
| 96 | 102 | [paradef-default] | |
| 97 | 103 | synopsis-style=template="verseparagraph",filter="sed 's!…\\(\\]\\|$\\)!<span>\\0</span>!g;s!\\([\\[ |()]\\|^\\|\\]\\|>\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|…\\)!\\1<code>\\2</code>!g;s!<[-a-zA-Z0-9.]\\+>!<em>\\0</em>!g'" | |
| 98 | 104 | endif::backend-xhtml11[] | |
modified Documentation/config.adoc
| @@ -146,6 +146,51 @@ refer to linkgit:gitignore[5] for details. For convenience: | |||
| 146 | 146 | This is the same as `gitdir` except that matching is done | |
| 147 | 147 | case-insensitively (e.g. on case-insensitive file systems) | |
| 148 | 148 | ||
| 149 | + | `worktree`:: | |
| 150 | + | The data that follows the keyword `worktree` and a colon is used as a | |
| 151 | + | glob pattern. If the working directory of the current worktree matches | |
| 152 | + | the pattern, the include condition is met. | |
| 153 | + | + | |
| 154 | + | The worktree location is the path where files are checked out (as returned | |
| 155 | + | by `git rev-parse --show-toplevel`). This is different from `gitdir`, which | |
| 156 | + | matches the `.git` directory path. In a linked worktree, the worktree path | |
| 157 | + | is the directory where that worktree's files are located, not the main | |
| 158 | + | repository's `.git` directory. | |
| 159 | + | + | |
| 160 | + | The pattern uses the same glob syntax as `gitdir` (including `~/`, `./`, | |
| 161 | + | `**/`, and trailing-`/` prefix matching). This condition will never match | |
| 162 | + | in a bare repository (which has no worktree). | |
| 163 | + | + | |
| 164 | + | Unlike `gitdir`, the `worktree` condition currently matches only the | |
| 165 | + | realpath-resolved worktree location. If the working tree was entered via a | |
| 166 | + | symbolic link, a pattern that uses the symbolic-link spelling may not match; | |
| 167 | + | use the real path instead. | |
| 168 | + | + | |
| 169 | + | This is useful when you want to apply configuration based on where the | |
| 170 | + | working tree is located on the filesystem. For example, a contributor who | |
| 171 | + | works on the same project both personally and as an employee can use | |
| 172 | + | different `user.name` and `user.email` values depending on which directory | |
| 173 | + | the worktree is checked out under: | |
| 174 | + | + | |
| 175 | + | ---- | |
| 176 | + | [includeIf "worktree:/home/user/work/"] | |
| 177 | + | path = ~/.config/git/work.inc | |
| 178 | + | [includeIf "worktree:/home/user/personal/"] | |
| 179 | + | path = ~/.config/git/personal.inc | |
| 180 | + | ---- | |
| 181 | + | + | |
| 182 | + | While `extensions.worktreeConfig` (see linkgit:git-worktree[1]) also supports | |
| 183 | + | per-worktree configuration, it stores the config inside each repository's | |
| 184 | + | `.git/config.worktree` file and requires running `git config --worktree` | |
| 185 | + | inside each worktree individually. In contrast, `includeIf "worktree:..."` | |
| 186 | + | can be set once in a global or system-level configuration file (e.g. | |
| 187 | + | `~/.config/git/config`) and applies to all repositories at once based on | |
| 188 | + | their worktree location. | |
| 189 | + | ||
| 190 | + | `worktree/i`:: | |
| 191 | + | This is the same as `worktree` except that matching is done | |
| 192 | + | case-insensitively (e.g. on case-insensitive file systems) | |
| 193 | + | ||
| 149 | 194 | `onbranch`:: | |
| 150 | 195 | The data that follows the keyword `onbranch` and a colon is taken to be a | |
| 151 | 196 | pattern with standard globbing wildcards and two additional | |
| @@ -244,6 +289,14 @@ Example | |||
| 244 | 289 | [includeIf "gitdir:~/to/group/"] | |
| 245 | 290 | path = /path/to/foo.inc | |
| 246 | 291 | ||
| 292 | + | ; include if the worktree is at /path/to/project-build | |
| 293 | + | [includeIf "worktree:/path/to/project-build"] | |
| 294 | + | path = build-config.inc | |
| 295 | + | ||
| 296 | + | ; include for all worktrees inside /path/to/group | |
| 297 | + | [includeIf "worktree:/path/to/group/"] | |
| 298 | + | path = group-config.inc | |
| 299 | + | ||
| 247 | 300 | ; relative paths are always relative to the including | |
| 248 | 301 | ; file (if the condition is true); their location is not | |
| 249 | 302 | ; affected by the condition | |
| @@ -276,13 +329,15 @@ boolean:: | |||
| 276 | 329 | When a variable is said to take a boolean value, many | |
| 277 | 330 | synonyms are accepted for 'true' and 'false'; these are all | |
| 278 | 331 | case-insensitive. | |
| 279 | - | ||
| 332 | + | + | |
| 333 | + | -- | |
| 280 | 334 | true;; Boolean true literals are `yes`, `on`, `true`, | |
| 281 | 335 | and `1`. Also, a variable defined without `= <value>` | |
| 282 | 336 | is taken as true. | |
| 283 | 337 | ||
| 284 | 338 | false;; Boolean false literals are `no`, `off`, `false`, | |
| 285 | 339 | `0` and the empty string. | |
| 340 | + | -- | |
| 286 | 341 | + | |
| 287 | 342 | When converting a value to its canonical form using the `--type=bool` type | |
| 288 | 343 | specifier, 'git config' will ensure that the output is "true" or | |
| @@ -451,6 +506,8 @@ include::config/guitool.adoc[] | |||
| 451 | 506 | ||
| 452 | 507 | include::config/help.adoc[] | |
| 453 | 508 | ||
| 509 | + | include::config/hook.adoc[] | |
| 510 | + | ||
| 454 | 511 | include::config/http.adoc[] | |
| 455 | 512 | ||
| 456 | 513 | include::config/i18n.adoc[] | |
| @@ -511,6 +568,8 @@ include::config/remotes.adoc[] | |||
| 511 | 568 | ||
| 512 | 569 | include::config/repack.adoc[] | |
| 513 | 570 | ||
| 571 | + | include::config/replay.adoc[] | |
| 572 | + | ||
| 514 | 573 | include::config/rerere.adoc[] | |
| 515 | 574 | ||
| 516 | 575 | include::config/revert.adoc[] | |
| @@ -523,6 +582,8 @@ include::config/sequencer.adoc[] | |||
| 523 | 582 | ||
| 524 | 583 | include::config/showbranch.adoc[] | |
| 525 | 584 | ||
| 585 | + | include::config/sideband.adoc[] | |
| 586 | + | ||
| 526 | 587 | include::config/sparse.adoc[] | |
| 527 | 588 | ||
| 528 | 589 | include::config/splitindex.adoc[] | |
modified Documentation/config/advice.adoc
| @@ -48,6 +48,10 @@ all advice messages. | |||
| 48 | 48 | to create a local branch after the fact. | |
| 49 | 49 | diverging:: | |
| 50 | 50 | Shown when a fast-forward is not possible. | |
| 51 | + | fetchRemoteHEADWarn:: | |
| 52 | + | Shown when linkgit:git-fetch[1] reveals that a remote `HEAD` | |
| 53 | + | differs from what is set locally and the user has opted into | |
| 54 | + | receiving a warning in this situation. | |
| 51 | 55 | fetchShowForcedUpdates:: | |
| 52 | 56 | Shown when linkgit:git-fetch[1] takes a long time | |
| 53 | 57 | to calculate forced updates after ref updates, or to warn | |
| @@ -90,6 +94,11 @@ all advice messages. | |||
| 90 | 94 | Shown when linkgit:git-push[1] rejects a forced update of | |
| 91 | 95 | a branch when its remote-tracking ref has updates that we | |
| 92 | 96 | do not have locally. | |
| 97 | + | pushRepoLooksLikeRef:: | |
| 98 | + | Shown when the repository given to linkgit:git-push[1] is not | |
| 99 | + | a configured remote but looks like a `<remote>/<branch>` ref, | |
| 100 | + | suggesting that the remote and branch be given as separate | |
| 101 | + | arguments. | |
| 93 | 102 | pushUnqualifiedRefname:: | |
| 94 | 103 | Shown when linkgit:git-push[1] gives up trying to | |
| 95 | 104 | guess based on the source and destination refs what | |
modified Documentation/config/am.adoc
| @@ -1,11 +1,11 @@ | |||
| 1 | - | am.keepcr:: | |
| 1 | + | `am.keepcr`:: | |
| 2 | 2 | If true, linkgit:git-am[1] will call linkgit:git-mailsplit[1] | |
| 3 | 3 | for patches in mbox format with parameter `--keep-cr`. In this | |
| 4 | 4 | case linkgit:git-mailsplit[1] will | |
| 5 | 5 | not remove `\r` from lines ending with `\r\n`. Can be overridden | |
| 6 | 6 | by giving `--no-keep-cr` from the command line. | |
| 7 | 7 | ||
| 8 | - | am.threeWay:: | |
| 8 | + | `am.threeWay`:: | |
| 9 | 9 | By default, linkgit:git-am[1] will fail if the patch does not | |
| 10 | 10 | apply cleanly. When set to true, this setting tells | |
| 11 | 11 | linkgit:git-am[1] to fall back on 3-way merge if the patch | |
| @@ -13,7 +13,7 @@ am.threeWay:: | |||
| 13 | 13 | have those blobs available locally (equivalent to giving the | |
| 14 | 14 | `--3way` option from the command line). Defaults to `false`. | |
| 15 | 15 | ||
| 16 | - | am.messageId:: | |
| 16 | + | `am.messageId`:: | |
| 17 | 17 | Add a `Message-ID` trailer based on the email header to the | |
| 18 | 18 | commit when using linkgit:git-am[1] (see | |
| 19 | 19 | linkgit:git-interpret-trailers[1]). See also the `--message-id` | |
modified Documentation/config/apply.adoc
| @@ -1,11 +1,16 @@ | |||
| 1 | - | apply.ignoreWhitespace:: | |
| 2 | - | When set to 'change', tells 'git apply' to ignore changes in | |
| 1 | + | `apply.ignoreWhitespace`:: | |
| 2 | + | When set to `change`, tells `git apply` to ignore changes in | |
| 3 | 3 | whitespace, in the same way as the `--ignore-space-change` | |
| 4 | 4 | option. | |
| 5 | - | When set to one of: no, none, never, false, it tells 'git apply' to | |
| 5 | + | When set to one of: `no`, `none`, `never`, `false`, it tells `git apply` to | |
| 6 | 6 | respect all whitespace differences. | |
| 7 | + | ifndef::git-apply[] | |
| 7 | 8 | See linkgit:git-apply[1]. | |
| 9 | + | endif::git-apply[] | |
| 8 | 10 | ||
| 9 | - | apply.whitespace:: | |
| 10 | - | Tells 'git apply' how to handle whitespace, in the same way | |
| 11 | - | as the `--whitespace` option. See linkgit:git-apply[1]. | |
| 11 | + | `apply.whitespace`:: | |
| 12 | + | Tells `git apply` how to handle whitespace, in the same way | |
| 13 | + | as the `--whitespace` option. | |
| 14 | + | ifndef::git-apply[] | |
| 15 | + | See linkgit:git-apply[1]. | |
| 16 | + | endif::git-apply[] | |
modified Documentation/config/bitmap-pseudo-merge.adoc
| @@ -47,8 +47,8 @@ will be updated more often than a reference pointing at an old commit. | |||
| 47 | 47 | bitmapPseudoMerge.<name>.sampleRate:: | |
| 48 | 48 | Determines the proportion of non-bitmapped commits (among | |
| 49 | 49 | reference tips) which are selected for inclusion in an | |
| 50 | - | unstable pseudo-merge bitmap. Must be between `0` and `1` | |
| 51 | - | (inclusive). The default is `1`. | |
| 50 | + | unstable pseudo-merge bitmap. Must be greater than `0` and | |
| 51 | + | less than or equal to `1`. The default is `1`. | |
| 52 | 52 | ||
| 53 | 53 | bitmapPseudoMerge.<name>.threshold:: | |
| 54 | 54 | Determines the minimum age of non-bitmapped commits (among | |
modified Documentation/config/branch.adoc
| @@ -55,6 +55,7 @@ This option defaults to `never`. | |||
| 55 | 55 | repository), you would want to set `remote.pushDefault` to | |
| 56 | 56 | specify the remote to push to for all branches, and use this | |
| 57 | 57 | option to override it for a specific branch. | |
| 58 | + | The value may be the name of a configured remote or a repository URL. | |
| 58 | 59 | ||
| 59 | 60 | `branch.<name>.merge`:: | |
| 60 | 61 | Defines, together with `branch.<name>.remote`, the upstream branch | |
| @@ -102,3 +103,10 @@ for details). | |||
| 102 | 103 | `git branch --edit-description`. Branch description is | |
| 103 | 104 | automatically added to the `format-patch` cover letter or | |
| 104 | 105 | `request-pull` summary. | |
| 106 | + | ||
| 107 | + | `branch.<name>.deleteMerged`:: | |
| 108 | + | If set to `false`, branch _<name>_ is exempt from | |
| 109 | + | `git branch --delete-merged`. Useful for a topic branch you | |
| 110 | + | intend to develop further after an initial round has been | |
| 111 | + | merged upstream. Defaults to true. Explicit deletion via | |
| 112 | + | `git branch -d` is unaffected. | |
modified Documentation/config/core.adoc
| @@ -589,6 +589,14 @@ core.packedRefsTimeout:: | |||
| 589 | 589 | all; -1 means to try indefinitely. Default is 1000 (i.e., | |
| 590 | 590 | retry for 1 second). | |
| 591 | 591 | ||
| 592 | + | core.configLockTimeout:: | |
| 593 | + | The length of time, in milliseconds, to retry when trying to | |
| 594 | + | lock a configuration file for writing. Value 0 means not to | |
| 595 | + | retry at all; -1 means to try indefinitely. Default is 1000 | |
| 596 | + | (i.e., retry for 1 second). This is read from the configuration | |
| 597 | + | that is already on disk before the lock is taken, so it can be | |
| 598 | + | set persistently like any other option. | |
| 599 | + | ||
| 592 | 600 | core.pager:: | |
| 593 | 601 | Text viewer for use by Git commands (e.g., 'less'). The value | |
| 594 | 602 | is meant to be interpreted by the shell. The order of preference | |
modified Documentation/config/difftool.adoc
| @@ -1,43 +1,43 @@ | |||
| 1 | - | diff.tool:: | |
| 1 | + | `diff.tool`:: | |
| 2 | 2 | Controls which diff tool is used by linkgit:git-difftool[1]. | |
| 3 | 3 | This variable overrides the value configured in `merge.tool`. | |
| 4 | 4 | The list below shows the valid built-in values. | |
| 5 | 5 | Any other value is treated as a custom diff tool and requires | |
| 6 | - | that a corresponding difftool.<tool>.cmd variable is defined. | |
| 6 | + | that a corresponding `difftool.<tool>.cmd` variable is defined. | |
| 7 | 7 | ||
| 8 | - | diff.guitool:: | |
| 8 | + | `diff.guitool`:: | |
| 9 | 9 | Controls which diff tool is used by linkgit:git-difftool[1] when | |
| 10 | - | the -g/--gui flag is specified. This variable overrides the value | |
| 10 | + | the `-g`/`--gui` flag is specified. This variable overrides the value | |
| 11 | 11 | configured in `merge.guitool`. The list below shows the valid | |
| 12 | 12 | built-in values. Any other value is treated as a custom diff tool | |
| 13 | - | and requires that a corresponding difftool.<guitool>.cmd variable | |
| 13 | + | and requires that a corresponding `difftool.<guitool>.cmd` variable | |
| 14 | 14 | is defined. | |
| 15 | 15 | ||
| 16 | 16 | include::{build_dir}/mergetools-diff.adoc[] | |
| 17 | 17 | ||
| 18 | - | difftool.<tool>.cmd:: | |
| 18 | + | `difftool.<tool>.cmd`:: | |
| 19 | 19 | Specify the command to invoke the specified diff tool. | |
| 20 | 20 | The specified command is evaluated in shell with the following | |
| 21 | - | variables available: 'LOCAL' is set to the name of the temporary | |
| 22 | - | file containing the contents of the diff pre-image and 'REMOTE' | |
| 21 | + | variables available: `LOCAL` is set to the name of the temporary | |
| 22 | + | file containing the contents of the diff pre-image and `REMOTE` | |
| 23 | 23 | is set to the name of the temporary file containing the contents | |
| 24 | 24 | of the diff post-image. | |
| 25 | 25 | + | |
| 26 | 26 | See the `--tool=<tool>` option in linkgit:git-difftool[1] for more details. | |
| 27 | 27 | ||
| 28 | - | difftool.<tool>.path:: | |
| 28 | + | `difftool.<tool>.path`:: | |
| 29 | 29 | Override the path for the given tool. This is useful in case | |
| 30 | 30 | your tool is not in the PATH. | |
| 31 | 31 | ||
| 32 | - | difftool.trustExitCode:: | |
| 32 | + | `difftool.trustExitCode`:: | |
| 33 | 33 | Exit difftool if the invoked diff tool returns a non-zero exit status. | |
| 34 | 34 | + | |
| 35 | 35 | See the `--trust-exit-code` option in linkgit:git-difftool[1] for more details. | |
| 36 | 36 | ||
| 37 | - | difftool.prompt:: | |
| 37 | + | `difftool.prompt`:: | |
| 38 | 38 | Prompt before each invocation of the diff tool. | |
| 39 | 39 | ||
| 40 | - | difftool.guiDefault:: | |
| 40 | + | `difftool.guiDefault`:: | |
| 41 | 41 | Set `true` to use the `diff.guitool` by default (equivalent to specifying | |
| 42 | 42 | the `--gui` argument), or `auto` to select `diff.guitool` or `diff.tool` | |
| 43 | 43 | depending on the presence of a `DISPLAY` environment variable value. The | |
modified Documentation/config/fetch.adoc
| @@ -76,7 +76,7 @@ | |||
| 76 | 76 | default is `skipping`. Unknown values will cause `git fetch` to | |
| 77 | 77 | error out. | |
| 78 | 78 | + | |
| 79 | - | See also the `--negotiate-only` and `--negotiation-tip` options to | |
| 79 | + | See also the `--negotiate-only` and `--negotiation-restrict` options to | |
| 80 | 80 | linkgit:git-fetch[1]. | |
| 81 | 81 | ||
| 82 | 82 | `fetch.showForcedUpdates`:: | |
| @@ -126,3 +126,22 @@ the new bundle URI. | |||
| 126 | 126 | The creation token values are chosen by the provider serving the specific | |
| 127 | 127 | bundle URI. If you modify the URI at `fetch.bundleURI`, then be sure to | |
| 128 | 128 | remove the value for the `fetch.bundleCreationToken` value before fetching. | |
| 129 | + | ||
| 130 | + | `fetch.followRemoteHEAD`:: | |
| 131 | + | When fetching using a default refspec, this setting determines how to handle | |
| 132 | + | differences between a fetched remote's `HEAD` and the local | |
| 133 | + | `remotes/<name>/HEAD` symbolic-ref. Its value is one of | |
| 134 | + | + | |
| 135 | + | -- | |
| 136 | + | `create`;; | |
| 137 | + | Create `remotes/<name>/HEAD` if a ref exists on the remote, but not locally. | |
| 138 | + | An existing symbolic-ref will not be touched. This is the default value. | |
| 139 | + | `warn`;; | |
| 140 | + | Display a warning if the remote advertises a different `HEAD` than what is | |
| 141 | + | set locally. Behaves like "create" if the local symbolic-ref doesn't exist. | |
| 142 | + | `always`;; | |
| 143 | + | Silently update `remotes/<name>/HEAD` whenever the remote advertises a new | |
| 144 | + | value. | |
| 145 | + | `never`;; | |
| 146 | + | Never create or modify the `remotes/<name>/HEAD` symbolic-ref. | |
| 147 | + | -- | |
modified Documentation/config/format.adoc
| @@ -102,7 +102,7 @@ format.coverLetter:: | |||
| 102 | 102 | Default is false. | |
| 103 | 103 | ||
| 104 | 104 | format.commitListFormat:: | |
| 105 | - | When the `--cover-letter-format` option is not given, `format-patch` | |
| 105 | + | When the `--commit-list-format` option is not given, `format-patch` | |
| 106 | 106 | uses the value of this variable to decide how to format the entry of | |
| 107 | 107 | each commit. Defaults to `shortlog`. | |
| 108 | 108 | ||
modified Documentation/config/fsmonitor--daemon.adoc
| @@ -4,8 +4,8 @@ fsmonitor.allowRemote:: | |||
| 4 | 4 | behavior. Only respected when `core.fsmonitor` is set to `true`. | |
| 5 | 5 | ||
| 6 | 6 | fsmonitor.socketDir:: | |
| 7 | - | This Mac OS-specific option, if set, specifies the directory in | |
| 7 | + | This Mac OS and Linux-specific option, if set, specifies the directory in | |
| 8 | 8 | which to create the Unix domain socket used for communication | |
| 9 | 9 | between the fsmonitor daemon and various Git commands. The directory must | |
| 10 | - | reside on a native Mac OS filesystem. Only respected when `core.fsmonitor` | |
| 10 | + | reside on a native filesystem. Only respected when `core.fsmonitor` | |
| 11 | 11 | is set to `true`. | |
modified Documentation/config/grep.adoc
| @@ -1,28 +1,28 @@ | |||
| 1 | - | grep.lineNumber:: | |
| 2 | - | If set to true, enable `-n` option by default. | |
| 1 | + | `grep.lineNumber`:: | |
| 2 | + | If set to `true`, enable `-n` option by default. | |
| 3 | 3 | ||
| 4 | - | grep.column:: | |
| 5 | - | If set to true, enable the `--column` option by default. | |
| 4 | + | `grep.column`:: | |
| 5 | + | If set to `true`, enable the `--column` option by default. | |
| 6 | 6 | ||
| 7 | - | grep.patternType:: | |
| 8 | - | Set the default matching behavior. Using a value of 'basic', 'extended', | |
| 9 | - | 'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`, | |
| 7 | + | `grep.patternType`:: | |
| 8 | + | Set the default matching behavior. Using a value of `basic`, `extended`, | |
| 9 | + | `fixed`, or `perl` will enable the `--basic-regexp`, `--extended-regexp`, | |
| 10 | 10 | `--fixed-strings`, or `--perl-regexp` option accordingly, while the | |
| 11 | - | value 'default' will use the `grep.extendedRegexp` option to choose | |
| 12 | - | between 'basic' and 'extended'. | |
| 11 | + | value `default` will use the `grep.extendedRegexp` option to choose | |
| 12 | + | between `basic` and `extended`. | |
| 13 | 13 | ||
| 14 | - | grep.extendedRegexp:: | |
| 15 | - | If set to true, enable `--extended-regexp` option by default. This | |
| 14 | + | `grep.extendedRegexp`:: | |
| 15 | + | If set to `true`, enable `--extended-regexp` option by default. This | |
| 16 | 16 | option is ignored when the `grep.patternType` option is set to a value | |
| 17 | - | other than 'default'. | |
| 17 | + | other than `default`. | |
| 18 | 18 | ||
| 19 | - | grep.threads:: | |
| 19 | + | `grep.threads`:: | |
| 20 | 20 | Number of grep worker threads to use. If unset (or set to 0), Git will | |
| 21 | 21 | use as many threads as the number of logical cores available. | |
| 22 | 22 | ||
| 23 | - | grep.fullName:: | |
| 24 | - | If set to true, enable `--full-name` option by default. | |
| 23 | + | `grep.fullName`:: | |
| 24 | + | If set to `true`, enable `--full-name` option by default. | |
| 25 | 25 | ||
| 26 | - | grep.fallbackToNoIndex:: | |
| 27 | - | If set to true, fall back to `git grep --no-index` if `git grep` | |
| 28 | - | is executed outside of a git repository. Defaults to false. | |
| 26 | + | `grep.fallbackToNoIndex`:: | |
| 27 | + | If set to `true`, fall back to `git grep --no-index` if `git grep` | |
| 28 | + | is executed outside of a git repository. Defaults to `false`. | |
modified Documentation/config/hook.adoc
| @@ -1,10 +1,17 @@ | |||
| 1 | + | ifdef::git-hook[] | |
| 2 | + | :see-git-hook: | |
| 3 | + | endif::git-hook[] | |
| 4 | + | ifndef::git-hook[] | |
| 5 | + | :see-git-hook: See linkgit:git-hook[1]. | |
| 6 | + | endif::git-hook[] | |
| 7 | + | ||
| 1 | 8 | hook.<friendly-name>.command:: | |
| 2 | 9 | The command to execute for `hook.<friendly-name>`. `<friendly-name>` | |
| 3 | 10 | is a unique name that identifies this hook. The hook events that | |
| 4 | 11 | trigger the command are configured with `hook.<friendly-name>.event`. | |
| 5 | 12 | The value can be an executable path or a shell oneliner. If more than | |
| 6 | 13 | one value is specified for the same `<friendly-name>`, only the last | |
| 7 | - | value parsed is used. See linkgit:git-hook[1]. | |
| 14 | + | value parsed is used. {see-git-hook} | |
| 8 | 15 | ||
| 9 | 16 | hook.<friendly-name>.event:: | |
| 10 | 17 | The hook events that trigger `hook.<friendly-name>`. The value is the | |
| @@ -14,11 +21,87 @@ hook.<friendly-name>.event:: | |||
| 14 | 21 | This is a multi-valued key. To run `hook.<friendly-name>` on multiple | |
| 15 | 22 | events, specify the key more than once. An empty value resets | |
| 16 | 23 | the list of events, clearing any previously defined events for | |
| 17 | - | `hook.<friendly-name>`. See linkgit:git-hook[1]. | |
| 24 | + | `hook.<friendly-name>`. {see-git-hook} | |
| 25 | + | + | |
| 26 | + | The `<friendly-name>` must not be the same as a known hook event name | |
| 27 | + | (e.g. do not use `hook.pre-commit.event`). Using a known event name as | |
| 28 | + | a friendly-name is a fatal error because it creates an ambiguity with | |
| 29 | + | `hook.<event>.enabled` and `hook.<event>.jobs`. For unknown event names, | |
| 30 | + | a warning is issued when `<friendly-name>` matches the event value. | |
| 18 | 31 | ||
| 19 | 32 | hook.<friendly-name>.enabled:: | |
| 20 | 33 | Whether the hook `hook.<friendly-name>` is enabled. Defaults to `true`. | |
| 21 | 34 | Set to `false` to disable the hook without removing its | |
| 22 | 35 | configuration. This is particularly useful when a hook is defined | |
| 23 | 36 | in a system or global config file and needs to be disabled for a | |
| 24 | - | specific repository. See linkgit:git-hook[1]. | |
| 37 | + | specific repository. {see-git-hook} | |
| 38 | + | ||
| 39 | + | hook.<friendly-name>.parallel:: | |
| 40 | + | Whether the hook `hook.<friendly-name>` may run in parallel with other hooks | |
| 41 | + | for the same event. Defaults to `false`. Set to `true` only when the | |
| 42 | + | hook script is safe to run concurrently with other hooks for the same | |
| 43 | + | event. If any hook for an event does not have this set to `true`, | |
| 44 | + | all hooks for that event run sequentially regardless of `hook.jobs`. | |
| 45 | + | Only configured (named) hooks need to declare this. Traditional hooks | |
| 46 | + | found in the hooks directory do not need to, and run in parallel when | |
| 47 | + | the effective job count is greater than 1. {see-git-hook} | |
| 48 | + | ||
| 49 | + | hook.<event>.enabled:: | |
| 50 | + | Switch to enable or disable all hooks for the `<event>` hook event. | |
| 51 | + | When set to `false`, no hooks fire for that event, regardless of any | |
| 52 | + | per-hook `hook.<friendly-name>.enabled` settings. Defaults to `true`. | |
| 53 | + | {see-git-hook} | |
| 54 | + | + | |
| 55 | + | Note on naming: `<event>` must be the event name (e.g. `pre-commit`), | |
| 56 | + | not a hook friendly-name. Since using a known event name as a | |
| 57 | + | friendly-name is disallowed (see `hook.<friendly-name>.event` above), | |
| 58 | + | there is no ambiguity between event-level and per-hook `.enabled` | |
| 59 | + | settings for known events. For unknown events, if a friendly-name | |
| 60 | + | matches the event name despite the warning, `.enabled` is treated | |
| 61 | + | as per-hook only. | |
| 62 | + | ||
| 63 | + | hook.<event>.jobs:: | |
| 64 | + | Specifies how many hooks can be run simultaneously for the `<event>` | |
| 65 | + | hook event (e.g. `hook.post-receive.jobs = 4`). Overrides `hook.jobs` | |
| 66 | + | for this specific event. The same parallelism restrictions apply: this | |
| 67 | + | setting has no effect unless all configured hooks for the event have | |
| 68 | + | `hook.<friendly-name>.parallel` set to `true`. Set to `-1` to use the | |
| 69 | + | number of available CPU cores. Must be a positive integer or `-1`; | |
| 70 | + | zero is rejected with a warning. {see-git-hook} | |
| 71 | + | + | |
| 72 | + | Note on naming: although this key resembles `hook.<friendly-name>.*` | |
| 73 | + | (a per-hook setting), `<event>` must be the event name, not a hook | |
| 74 | + | friendly name. The key component is stored literally and looked up by | |
| 75 | + | event name at runtime with no translation between the two namespaces. | |
| 76 | + | A key like `hook.my-hook.jobs` is stored under `"my-hook"` but the | |
| 77 | + | lookup at runtime uses the event name (e.g. `"post-receive"`), so | |
| 78 | + | `hook.my-hook.jobs` is silently ignored even when `my-hook` is | |
| 79 | + | registered for that event. Use `hook.post-receive.jobs` or any other | |
| 80 | + | valid event name when setting `hook.<event>.jobs`. | |
| 81 | + | ||
| 82 | + | hook.jobs:: | |
| 83 | + | Specifies how many hooks can be run simultaneously during parallelized | |
| 84 | + | hook execution. If unspecified, defaults to 1 (serial execution). | |
| 85 | + | Set to `-1` to use the number of available CPU cores. | |
| 86 | + | Can be overridden on a per-event basis with `hook.<event>.jobs`. | |
| 87 | + | Some hooks always run sequentially regardless of this setting because | |
| 88 | + | they operate on shared data and cannot safely be parallelized: | |
| 89 | + | + | |
| 90 | + | -- | |
| 91 | + | `applypatch-msg`;; | |
| 92 | + | `prepare-commit-msg`;; | |
| 93 | + | `commit-msg`;; | |
| 94 | + | Receive a commit message file and may rewrite it in place. | |
| 95 | + | `pre-commit`;; | |
| 96 | + | `post-checkout`;; | |
| 97 | + | `push-to-checkout`;; | |
| 98 | + | `post-commit`;; | |
| 99 | + | Access the working tree, index, or repository state. | |
| 100 | + | -- | |
| 101 | + | + | |
| 102 | + | This setting has no effect unless all configured hooks for the event have | |
| 103 | + | `hook.<friendly-name>.parallel` set to `true`. | |
| 104 | + | + | |
| 105 | + | For `pre-push` hooks, which normally keep stdout and stderr separate, | |
| 106 | + | setting this to a value greater than 1 (or passing `-j`) will merge stdout | |
| 107 | + | into stderr to allow correct de-interleaving of parallel output. | |
modified Documentation/config/http.adoc
| @@ -59,7 +59,18 @@ http.emptyAuth:: | |||
| 59 | 59 | Attempt authentication without seeking a username or password. This | |
| 60 | 60 | can be used to attempt GSS-Negotiate authentication without specifying | |
| 61 | 61 | a username in the URL, as libcurl normally requires a username for | |
| 62 | - | authentication. | |
| 62 | + | authentication. Possible values are: | |
| 63 | + | + | |
| 64 | + | -- | |
| 65 | + | * `auto` (default) - Send empty credentials only if the server's 401 response | |
| 66 | + | advertises an authentication mechanism that requires them (such as | |
| 67 | + | GSS-Negotiate); otherwise fall back to prompting via the credential helper. | |
| 68 | + | * `true` - Always send empty credentials on the very first request, before | |
| 69 | + | receiving any 401 response from the server. | |
| 70 | + | * `false` - Never send empty credentials. Mechanisms that require | |
| 71 | + | empty credentials or an explicit username, such as GSS-Negotiate, will not | |
| 72 | + | work. | |
| 73 | + | -- | |
| 63 | 74 | ||
| 64 | 75 | http.proactiveAuth:: | |
| 65 | 76 | Attempt authentication without first making an unauthenticated attempt and | |
modified Documentation/config/imap.adoc
| @@ -1,47 +1,47 @@ | |||
| 1 | - | imap.folder:: | |
| 1 | + | `imap.folder`:: | |
| 2 | 2 | The folder to drop the mails into, which is typically the Drafts | |
| 3 | 3 | folder. For example: `INBOX.Drafts`, `INBOX/Drafts` or | |
| 4 | 4 | `[Gmail]/Drafts`. The IMAP folder to interact with MUST be specified; | |
| 5 | 5 | the value of this configuration variable is used as the fallback | |
| 6 | 6 | default value when the `--folder` option is not given. | |
| 7 | 7 | ||
| 8 | - | imap.tunnel:: | |
| 8 | + | `imap.tunnel`:: | |
| 9 | 9 | Command used to set up a tunnel to the IMAP server through which | |
| 10 | 10 | commands will be piped instead of using a direct network connection | |
| 11 | - | to the server. Required when imap.host is not set. | |
| 11 | + | to the server. Required when `imap.host` is not set. | |
| 12 | 12 | ||
| 13 | - | imap.host:: | |
| 13 | + | `imap.host`:: | |
| 14 | 14 | A URL identifying the server. Use an `imap://` prefix for non-secure | |
| 15 | 15 | connections and an `imaps://` prefix for secure connections. | |
| 16 | - | Ignored when imap.tunnel is set, but required otherwise. | |
| 16 | + | Ignored when `imap.tunnel` is set, but required otherwise. | |
| 17 | 17 | ||
| 18 | - | imap.user:: | |
| 18 | + | `imap.user`:: | |
| 19 | 19 | The username to use when logging in to the server. | |
| 20 | 20 | ||
| 21 | - | imap.pass:: | |
| 21 | + | `imap.pass`:: | |
| 22 | 22 | The password to use when logging in to the server. | |
| 23 | 23 | ||
| 24 | - | imap.port:: | |
| 24 | + | `imap.port`:: | |
| 25 | 25 | An integer port number to connect to on the server. | |
| 26 | - | Defaults to 143 for imap:// hosts and 993 for imaps:// hosts. | |
| 27 | - | Ignored when imap.tunnel is set. | |
| 26 | + | Defaults to 143 for `imap://` hosts and 993 for `imaps://` hosts. | |
| 27 | + | Ignored when `imap.tunnel` is set. | |
| 28 | 28 | ||
| 29 | - | imap.sslverify:: | |
| 29 | + | `imap.sslverify`:: | |
| 30 | 30 | A boolean to enable/disable verification of the server certificate | |
| 31 | 31 | used by the SSL/TLS connection. Default is `true`. Ignored when | |
| 32 | - | imap.tunnel is set. | |
| 32 | + | `imap.tunnel` is set. | |
| 33 | 33 | ||
| 34 | - | imap.preformattedHTML:: | |
| 34 | + | `imap.preformattedHTML`:: | |
| 35 | 35 | A boolean to enable/disable the use of html encoding when sending | |
| 36 | - | a patch. An html encoded patch will be bracketed with <pre> | |
| 36 | + | a patch. An html encoded patch will be bracketed with `<pre>` | |
| 37 | 37 | and have a content type of text/html. Ironically, enabling this | |
| 38 | 38 | option causes Thunderbird to send the patch as a plain/text, | |
| 39 | 39 | format=fixed email. Default is `false`. | |
| 40 | 40 | ||
| 41 | - | imap.authMethod:: | |
| 41 | + | `imap.authMethod`:: | |
| 42 | 42 | Specify the authentication method for authenticating with the IMAP server. | |
| 43 | 43 | If Git was built with the NO_CURL option, or if your curl version is older | |
| 44 | - | than 7.34.0, or if you're running git-imap-send with the `--no-curl` | |
| 44 | + | than 7.34.0, or if you're running `git-imap-send` with the `--no-curl` | |
| 45 | 45 | option, the only supported methods are `PLAIN`, `CRAM-MD5`, `OAUTHBEARER` | |
| 46 | 46 | and `XOAUTH2`. If this is not set then `git imap-send` uses the basic IMAP | |
| 47 | 47 | plaintext `LOGIN` command. | |
modified Documentation/config/log.adoc
| @@ -53,13 +53,16 @@ This is the same as the `--decorate` option of the `git log`. | |||
| 53 | 53 | `log.follow`:: | |
| 54 | 54 | If `true`, `git log` will act as if the `--follow` option was used when | |
| 55 | 55 | a single <path> is given. This has the same limitations as `--follow`, | |
| 56 | - | i.e. it cannot be used to follow multiple files and does not work well | |
| 57 | - | on non-linear history. | |
| 56 | + | i.e. it cannot be used to follow multiple files. | |
| 58 | 57 | ||
| 59 | 58 | `log.graphColors`:: | |
| 60 | 59 | A list of colors, separated by commas, that can be used to draw | |
| 61 | 60 | history lines in `git log --graph`. | |
| 62 | 61 | ||
| 62 | + | `log.graphIndent`:: | |
| 63 | + | If `true`, indent visual roots when rendering the graphs with `--graph`. | |
| 64 | + | Set true by default. It can be overriden with `--[no-]graph-indent`. | |
| 65 | + | ||
| 63 | 66 | `log.showRoot`:: | |
| 64 | 67 | If true, the initial commit will be shown as a big creation event. | |
| 65 | 68 | This is equivalent to a diff against an empty tree. | |
modified Documentation/config/maintenance.adoc
| @@ -41,6 +41,7 @@ The possible strategies are: | |||
| 41 | 41 | This repacking strategy is a full replacement for the `gc` strategy and is | |
| 42 | 42 | recommended for large repositories. This is the default strategy for manual | |
| 43 | 43 | maintenance. | |
| 44 | + | + | |
| 44 | 45 | * `incremental`: This setting optimizes for performing small maintenance | |
| 45 | 46 | activities that do not delete any data. This does not schedule the `gc` | |
| 46 | 47 | task, but runs the `prefetch` and `commit-graph` tasks hourly, the | |
| @@ -101,7 +102,7 @@ maintenance.geometric-repack.auto:: | |||
| 101 | 102 | there are packfiles that need to be merged together to retain the | |
| 102 | 103 | geometric progression, or when there are at least this many loose | |
| 103 | 104 | objects that would be written into a new packfile. The default value is | |
| 104 | - | 100. | |
| 105 | + | 6700. | |
| 105 | 106 | ||
| 106 | 107 | maintenance.geometric-repack.splitFactor:: | |
| 107 | 108 | This integer config option controls the factor used for the geometric | |
| @@ -121,10 +122,10 @@ maintenance.rerere-gc.auto:: | |||
| 121 | 122 | This integer config option controls how often the `rerere-gc` task | |
| 122 | 123 | should be run as part of `git maintenance run --auto`. If zero, then | |
| 123 | 124 | the `rerere-gc` task will not run with the `--auto` option. A negative | |
| 124 | - | value will force the task to run every time. Otherwise, any positive | |
| 125 | - | value implies the command will run when the "rr-cache" directory exists | |
| 126 | - | and has at least one entry, regardless of whether it is stale or not. | |
| 127 | - | This heuristic may be refined in the future. The default value is 1. | |
| 125 | + | value will force the task to run every time. Otherwise, a positive | |
| 126 | + | value implies the command should run when the estimated number of stale | |
| 127 | + | entries that would be pruned is greater than or equal to the configured | |
| 128 | + | value. The default value is 512. | |
| 128 | 129 | ||
| 129 | 130 | maintenance.worktree-prune.auto:: | |
| 130 | 131 | This integer config option controls how often the `worktree-prune` task | |
modified Documentation/config/mergetool.adoc
| @@ -52,13 +52,13 @@ | |||
| 52 | 52 | if `merge.tool` is configured as _<variant>_), Git will consult | |
| 53 | 53 | `mergetool.<variant>.layout` to determine the tool's layout. If the | |
| 54 | 54 | variant-specific configuration is not available, `vimdiff` ' s is used as | |
| 55 | - | fallback. If that too is not available, a default layout with 4 windows | |
| 56 | - | will be used. To configure the layout, see the 'BACKEND SPECIFIC HINTS' | |
| 55 | + | fallback. If that too is not available, a default layout with 4 windows | |
| 56 | + | will be used. | |
| 57 | 57 | ifdef::git-mergetool[] | |
| 58 | - | section. | |
| 58 | + | To configure the layout, see the 'BACKEND SPECIFIC HINTS' section. | |
| 59 | 59 | endif::[] | |
| 60 | 60 | ifndef::git-mergetool[] | |
| 61 | - | section in linkgit:git-mergetool[1]. | |
| 61 | + | To configure the layout, see the 'BACKEND SPECIFIC HINTS' section in linkgit:git-mergetool[1]. | |
| 62 | 62 | endif::[] | |
| 63 | 63 | ||
| 64 | 64 | `mergetool.hideResolved`:: | |
modified Documentation/config/promisor.adoc
| @@ -32,24 +32,136 @@ variable is set to "true", and the "name" and "url" fields are always | |||
| 32 | 32 | advertised regardless of this setting. | |
| 33 | 33 | ||
| 34 | 34 | promisor.acceptFromServer:: | |
| 35 | - | If set to "all", a client will accept all the promisor remotes | |
| 36 | - | a server might advertise using the "promisor-remote" | |
| 37 | - | capability. If set to "knownName" the client will accept | |
| 38 | - | promisor remotes which are already configured on the client | |
| 39 | - | and have the same name as those advertised by the client. This | |
| 40 | - | is not very secure, but could be used in a corporate setup | |
| 41 | - | where servers and clients are trusted to not switch name and | |
| 42 | - | URLs. If set to "knownUrl", the client will accept promisor | |
| 43 | - | remotes which have both the same name and the same URL | |
| 44 | - | configured on the client as the name and URL advertised by the | |
| 45 | - | server. This is more secure than "all" or "knownName", so it | |
| 46 | - | should be used if possible instead of those options. Default | |
| 47 | - | is "none", which means no promisor remote advertised by a | |
| 48 | - | server will be accepted. By accepting a promisor remote, the | |
| 49 | - | client agrees that the server might omit objects that are | |
| 50 | - | lazily fetchable from this promisor remote from its responses | |
| 51 | - | to "fetch" and "clone" requests from the client. Name and URL | |
| 52 | - | comparisons are case sensitive. See linkgit:gitprotocol-v2[5]. | |
| 35 | + | Controls which promisor remotes advertised by a server (using the | |
| 36 | + | "promisor-remote" protocol capability) a client will accept. By | |
| 37 | + | accepting a promisor remote, the client agrees that the server | |
| 38 | + | might omit objects that are lazily fetchable from this promisor | |
| 39 | + | remote from its responses to "fetch" and "clone" requests. | |
| 40 | + | + | |
| 41 | + | Note that this option does not cause new remotes to be automatically | |
| 42 | + | created in the client's configuration. It only allows remotes which | |
| 43 | + | are somehow already configured to be trusted for the current | |
| 44 | + | operation, or their fields to be updated (if `promisor.storeFields` is | |
| 45 | + | set and the remote already exists locally). To allow Git to | |
| 46 | + | automatically create and persist new remotes from server | |
| 47 | + | advertisements, use `promisor.acceptFromServerUrl`. | |
| 48 | + | + | |
| 49 | + | The available options are: | |
| 50 | + | + | |
| 51 | + | * `none` (default): No promisor remote advertised by a server will be | |
| 52 | + | accepted. | |
| 53 | + | + | |
| 54 | + | * `knownUrl`: The client will accept promisor remotes that are already | |
| 55 | + | configured on the client and have both the same name and the same URL | |
| 56 | + | as advertised by the server. This is more secure than `all` or | |
| 57 | + | `knownName`, and should be used if possible instead of those options. | |
| 58 | + | + | |
| 59 | + | * `knownName`: The client will accept promisor remotes that are already | |
| 60 | + | configured on the client and have the same name as those advertised | |
| 61 | + | by the server. This is not very secure, but could be used in a corporate | |
| 62 | + | setup where servers and clients are trusted to not switch names and URLs. | |
| 63 | + | + | |
| 64 | + | * `all`: The client will accept all the promisor remotes a server might | |
| 65 | + | advertise. This is the least secure option and should only be used in | |
| 66 | + | fully trusted environments. | |
| 67 | + | + | |
| 68 | + | Name and URL comparisons are case-sensitive. See linkgit:gitprotocol-v2[5] | |
| 69 | + | for protocol details. | |
| 70 | + | ||
| 71 | + | promisor.acceptFromServerUrl:: | |
| 72 | + | A glob pattern to specify which server-advertised URLs a | |
| 73 | + | client is allowed to act on. When a URL matches, the client | |
| 74 | + | will accept the advertised remote as a promisor remote, may | |
| 75 | + | automatically create a new remote configuration for it and may | |
| 76 | + | automatically accept field updates (such as authentication | |
| 77 | + | tokens) from the server, even if `promisor.acceptFromServer` | |
| 78 | + | is set to `none` (the default). | |
| 79 | + | + | |
| 80 | + | This option can appear multiple times in config files. An advertised | |
| 81 | + | URL will be accepted if it matches _ANY_ glob pattern specified by | |
| 82 | + | this option in _ANY_ config file read by Git. | |
| 83 | + | + | |
| 84 | + | When both `promisor.acceptFromServer` and `promisor.acceptFromServerUrl` | |
| 85 | + | are set, `promisor.acceptFromServerUrl` is consulted first and takes | |
| 86 | + | precedence: if a matching pattern leads to acceptance (either by | |
| 87 | + | auto-configuring an unknown remote or by accepting field updates for | |
| 88 | + | a known remote whose URL matches both the local configuration and the | |
| 89 | + | allowlist), the advertised remote is accepted regardless of the | |
| 90 | + | `promisor.acceptFromServer` setting. If no pattern in | |
| 91 | + | `promisor.acceptFromServerUrl` triggers acceptance, the decision is | |
| 92 | + | left to `promisor.acceptFromServer`. | |
| 93 | + | + | |
| 94 | + | Note however that, even when an advertised URL matches a pattern in | |
| 95 | + | `promisor.acceptFromServerUrl`, an already-existing remote on the | |
| 96 | + | client whose name matches the advertised name but whose configured URL | |
| 97 | + | differs from the advertised one will _NOT_ be accepted through | |
| 98 | + | `promisor.acceptFromServerUrl`. This prevents a server from silently | |
| 99 | + | re-pointing an existing client-side remote at a different URL. (Such a | |
| 100 | + | remote may still be accepted through `promisor.acceptFromServer=all` | |
| 101 | + | or `=knownName`, which have their own, looser semantics; see the | |
| 102 | + | documentation of that option.) | |
| 103 | + | + | |
| 104 | + | Be _VERY_ careful with these patterns: `*` matches any sequence of | |
| 105 | + | characters within the 'host' and 'path' parts of a URL (but cannot | |
| 106 | + | cross part boundaries). An overly broad pattern is a major security | |
| 107 | + | risk, as a matching URL allows a server to auto-configure new remotes | |
| 108 | + | and to update fields (such as authentication tokens) on known remotes | |
| 109 | + | without further confirmation. To minimize security risks, follow these | |
| 110 | + | guidelines: | |
| 111 | + | + | |
| 112 | + | -- | |
| 113 | + | 1. Start with a secure protocol scheme, like `https://` or `ssh://`. | |
| 114 | + | + | |
| 115 | + | 2. Only allow domain names or paths where you control and trust _ALL_ | |
| 116 | + | the content. Be especially careful with shared hosting platforms | |
| 117 | + | like `github.com` or `gitlab.com`. A broad pattern like | |
| 118 | + | `https://gitlab.com/*` is dangerous because it trusts every | |
| 119 | + | repository on the entire platform. Always restrict such patterns to | |
| 120 | + | your specific organization or namespace (e.g., | |
| 121 | + | `https://gitlab.com/your-org/*`). | |
| 122 | + | + | |
| 123 | + | 3. Never use globs at the end of domain names. For example, | |
| 124 | + | `https://cdn.your-org.com/*` might be safe, but | |
| 125 | + | `https://cdn.your-org.com*/*` is a major security risk because | |
| 126 | + | the latter matches `https://cdn.your-org.com.hacker.net/repo`. | |
| 127 | + | + | |
| 128 | + | 4. Be careful using globs at the beginning of domain names. While the | |
| 129 | + | code ensures a `*` in the host cannot cross into the path, a | |
| 130 | + | pattern like `https://*.example.com/*` will still match any | |
| 131 | + | subdomain. This is extremely dangerous on shared hosting platforms | |
| 132 | + | (e.g., `https://*.github.io/*` trusts every user's site on the | |
| 133 | + | entire platform). | |
| 134 | + | -- | |
| 135 | + | + | |
| 136 | + | Before matching, both the advertised URL and the pattern are | |
| 137 | + | normalized: the scheme and host are lowercased, percent-encoded | |
| 138 | + | characters are decoded where possible, and path segments like `..` | |
| 139 | + | are resolved. The port must also match exactly (e.g., | |
| 140 | + | `https://example.com:8080/*` will not match a URL advertised on | |
| 141 | + | port 9999). The username and password components of the URL are | |
| 142 | + | ignored during matching. Note that embedding credentials in URLs is | |
| 143 | + | discouraged. Passing authentication tokens via the `token` field of | |
| 144 | + | the `promisor-remote` capability is strongly preferred. | |
| 145 | + | + | |
| 146 | + | The glob pattern can optionally be prefixed with a remote name and an | |
| 147 | + | equals sign (e.g., `cdn=https://cdn.example.com/*`). If such a prefix | |
| 148 | + | is provided, accepted remotes will be saved under that name. If no | |
| 149 | + | such prefix is provided, a safe remote name will be automatically | |
| 150 | + | generated by sanitizing the URL and prefixing it with | |
| 151 | + | `promisor-auto-`. | |
| 152 | + | + | |
| 153 | + | If a remote with the chosen name already exists but points to a | |
| 154 | + | different URL, Git will append a numeric suffix (e.g., `-1`, `-2`) to | |
| 155 | + | the name to prevent overwriting existing configurations. You should | |
| 156 | + | make sure that this doesn't happen often though, as remotes will be | |
| 157 | + | rejected if the numeric suffix increases too much. In all cases, the | |
| 158 | + | original name advertised by the server is recorded in the | |
| 159 | + | `remote.<name>.advertisedAs` configuration variable for tracing and | |
| 160 | + | debugging purposes. | |
| 161 | + | + | |
| 162 | + | For the security implications of accepting a promisor remote, see the | |
| 163 | + | documentation of `promisor.acceptFromServer`. For details on the | |
| 164 | + | protocol, see linkgit:gitprotocol-v2[5]. | |
| 53 | 165 | ||
| 54 | 166 | promisor.checkFields:: | |
| 55 | 167 | A comma or space separated list of additional remote related | |
| @@ -63,11 +175,13 @@ If one of these field names (e.g., "token") is being checked for an | |||
| 63 | 175 | advertised promisor remote (e.g., "foo"), three conditions must be met | |
| 64 | 176 | for the check of this specific field to pass: | |
| 65 | 177 | + | |
| 178 | + | -- | |
| 66 | 179 | 1. The corresponding local configuration (e.g., `remote.foo.token`) | |
| 67 | 180 | must be set. | |
| 68 | 181 | 2. The server must advertise the "token" field for remote "foo". | |
| 69 | 182 | 3. The value of the locally configured `remote.foo.token` must exactly | |
| 70 | 183 | match the value advertised by the server for the "token" field. | |
| 184 | + | -- | |
| 71 | 185 | + | |
| 72 | 186 | If any of these conditions is not met for any field name listed in | |
| 73 | 187 | `promisor.checkFields`, the advertised remote "foo" is rejected. | |
modified Documentation/config/push.adoc
| @@ -41,9 +41,10 @@ this is a deprecated synonym for `upstream`. | |||
| 41 | 41 | `simple`;; | |
| 42 | 42 | push the current branch with the same name on the remote. | |
| 43 | 43 | + | |
| 44 | - | If you are working on a centralized workflow (pushing to the same repository you | |
| 45 | - | pull from, which is typically `origin`), then you need to configure an upstream | |
| 46 | - | branch with the same name. | |
| 44 | + | This mode requires that the remote repository to be pushed to is | |
| 45 | + | known. When pushing back to the same remote you pull from, the | |
| 46 | + | current branch must also have an upstream tracking branch with the | |
| 47 | + | same name. | |
| 47 | 48 | + | |
| 48 | 49 | This mode is the default since Git 2.0, and is the safest option suited for | |
| 49 | 50 | beginners. | |
modified Documentation/config/remote.adoc
| @@ -91,6 +91,15 @@ remote.<name>.promisor:: | |||
| 91 | 91 | When set to true, this remote will be used to fetch promisor | |
| 92 | 92 | objects. | |
| 93 | 93 | ||
| 94 | + | remote.<name>.advertisedAs:: | |
| 95 | + | When a promisor remote is automatically configured using | |
| 96 | + | information advertised by a server through the | |
| 97 | + | `promisor-remote` protocol capability (see | |
| 98 | + | `promisor.acceptFromServerUrl`), the server's originally | |
| 99 | + | advertised name is saved in this variable. This is for | |
| 100 | + | information, tracing and debugging purposes. Users should not | |
| 101 | + | typically modify or create such configuration entries. | |
| 102 | + | ||
| 94 | 103 | remote.<name>.partialclonefilter:: | |
| 95 | 104 | The filter that will be applied when fetching from this promisor remote. | |
| 96 | 105 | Changing or clearing this value will only affect fetches for new commits. | |
| @@ -107,16 +116,62 @@ priority configuration file (e.g. `.git/config` in a repository) to clear | |||
| 107 | 116 | the values inherited from a lower priority configuration files (e.g. | |
| 108 | 117 | `$HOME/.gitconfig`). | |
| 109 | 118 | ||
| 119 | + | remote.<name>.negotiationRestrict:: | |
| 120 | + | When negotiating with this remote during `git fetch`, restrict the | |
| 121 | + | commits advertised as "have" lines to only those reachable from refs | |
| 122 | + | matching the given patterns. This multi-valued config option behaves | |
| 123 | + | like `--negotiation-restrict` on the command line. | |
| 124 | + | + | |
| 125 | + | Each value is either an exact ref name (e.g. `refs/heads/release`) or a | |
| 126 | + | glob pattern (e.g. `refs/heads/release/*`). The pattern syntax is the | |
| 127 | + | same as for `--negotiation-restrict`. | |
| 128 | + | + | |
| 129 | + | These config values are used as defaults for the `--negotiation-restrict` | |
| 130 | + | command-line option. If `--negotiation-restrict` (or its synonym | |
| 131 | + | `--negotiation-tip`) is specified on the command line, then the config | |
| 132 | + | values are not used. | |
| 133 | + | + | |
| 134 | + | These values also influence negotiation during `git push` if | |
| 135 | + | `push.negotiate` is enabled. | |
| 136 | + | + | |
| 137 | + | Blank values signal to ignore all previous values, allowing a reset of | |
| 138 | + | the list from broader config scenarios. | |
| 139 | + | ||
| 140 | + | remote.<name>.negotiationInclude:: | |
| 141 | + | When negotiating with this remote during `git fetch`, the client | |
| 142 | + | advertises a list of commits that exist locally. In repos with | |
| 143 | + | many references, this list of "haves" can be truncated. Depending | |
| 144 | + | on data shape, dropping certain references may be expensive. This | |
| 145 | + | multi-valued config option specifies references, commit hashes, | |
| 146 | + | or ref pattern globs whose tips should always be sent as "have" | |
| 147 | + | commits during fetch negotiation with this remote. | |
| 148 | + | + | |
| 149 | + | Each value is either an exact ref name (e.g. `refs/heads/release`), a | |
| 150 | + | commit hash, or a glob pattern (e.g. `refs/heads/release/*`). The | |
| 151 | + | pattern syntax is the same as for `--negotiation-include`. | |
| 152 | + | + | |
| 153 | + | These config values are used as defaults for the `--negotiation-include` | |
| 154 | + | command-line option. If `--negotiation-include` is specified on the | |
| 155 | + | command line, then the config values are not used. | |
| 156 | + | + | |
| 157 | + | This option is additive with the normal negotiation process: the | |
| 158 | + | negotiation algorithm still runs and advertises its own selected commits, | |
| 159 | + | but the refs matching `remote.<name>.negotiationInclude` are sent | |
| 160 | + | unconditionally on top of those heuristically selected commits. | |
| 161 | + | + | |
| 162 | + | These values also influence negotiation during `git push` if | |
| 163 | + | `push.negotiate` is enabled. | |
| 164 | + | + | |
| 165 | + | Blank values signal to ignore all previous values, allowing a reset of | |
| 166 | + | the list from broader config scenarios. | |
| 167 | + | ||
| 110 | 168 | remote.<name>.followRemoteHEAD:: | |
| 111 | - | How linkgit:git-fetch[1] should handle updates to `remotes/<name>/HEAD` | |
| 112 | - | when fetching using the configured refspecs of a remote. | |
| 113 | - | The default value is "create", which will create `remotes/<name>/HEAD` | |
| 114 | - | if it exists on the remote, but not locally; this will not touch an | |
| 115 | - | already existing local reference. Setting it to "warn" will print | |
| 116 | - | a message if the remote has a different value than the local one; | |
| 117 | - | in case there is no local reference, it behaves like "create". | |
| 118 | - | A variant on "warn" is "warn-if-not-$branch", which behaves like | |
| 119 | - | "warn", but if `HEAD` on the remote is `$branch` it will be silent. | |
| 120 | - | Setting it to "always" will silently update `remotes/<name>/HEAD` to | |
| 121 | - | the value on the remote. Finally, setting it to "never" will never | |
| 122 | - | change or create the local reference. | |
| 169 | + | When fetching this remote using its default refspec, this setting determines | |
| 170 | + | how to handle differences between the remote's `HEAD` and the local | |
| 171 | + | `remotes/<name>/HEAD` symbolic-ref. Overrides the value of | |
| 172 | + | `fetch.followRemoteHEAD`. See `fetch.followRemoteHEAD` for a description of | |
| 173 | + | accepted values. | |
| 174 | + | + | |
| 175 | + | In addition to the values supported by `fetch.followRemoteHEAD`, this setting | |
| 176 | + | may also take on the value "warn-if-not-`$branch`", which behaves like "warn", | |
| 177 | + | but ignores the warning if the remote's `HEAD` is `remotes/<name>/$branch`. | |
modified Documentation/config/repack.adoc
| @@ -46,3 +46,21 @@ repack.midxMustContainCruft:: | |||
| 46 | 46 | `--write-midx`. When false, cruft packs are only included in the MIDX | |
| 47 | 47 | when necessary (e.g., because they might be required to form a | |
| 48 | 48 | reachability closure with MIDX bitmaps). Defaults to true. | |
| 49 | + | ||
| 50 | + | repack.midxSplitFactor:: | |
| 51 | + | The factor used in the geometric merging condition when | |
| 52 | + | compacting incremental MIDX layers during `git repack` when | |
| 53 | + | invoked with the `--write-midx=incremental` option. | |
| 54 | + | + | |
| 55 | + | Adjacent layers are merged when the accumulated object count of the | |
| 56 | + | newer layer exceeds `1/<N>` of the object count of the next deeper | |
| 57 | + | layer. Must be at least 2. Defaults to 2. | |
| 58 | + | ||
| 59 | + | repack.midxNewLayerThreshold:: | |
| 60 | + | The minimum number of packs in the tip MIDX layer before those | |
| 61 | + | packs are considered as candidates for geometric repacking | |
| 62 | + | during `git repack --write-midx=incremental`. | |
| 63 | + | + | |
| 64 | + | When the tip layer has fewer packs than this threshold, those packs are | |
| 65 | + | excluded from the geometric repack entirely, and are thus left | |
| 66 | + | unmodified. Must be at least 1. Defaults to 8. | |
modified Documentation/config/replay.adoc
| @@ -1,11 +1,18 @@ | |||
| 1 | 1 | replay.refAction:: | |
| 2 | - | Specifies the default mode for handling reference updates in | |
| 3 | - | `git replay`. The value can be: | |
| 2 | + | Specifies the default mode for handling reference updates. | |
| 3 | + | The value can be: | |
| 4 | 4 | + | |
| 5 | 5 | -- | |
| 6 | - | * `update`: Update refs directly using an atomic transaction (default behavior). | |
| 7 | - | * `print`: Output update-ref commands for pipeline use. | |
| 6 | + | //// | |
| 7 | + | These use the first sentences from the description list in git-replay(1). | |
| 8 | + | //// | |
| 9 | + | `update`;; (default) Update refs directly using an atomic transaction. | |
| 10 | + | `print`;; Output update-ref commands for pipeline use. | |
| 8 | 11 | -- | |
| 9 | 12 | + | |
| 10 | - | This setting can be overridden with the `--ref-action` command-line option. | |
| 11 | - | When not configured, `git replay` defaults to `update` mode. | |
| 13 | + | ifdef::git-replay[] | |
| 14 | + | See `--ref-action`. | |
| 15 | + | endif::git-replay[] | |
| 16 | + | ifndef::git-replay[] | |
| 17 | + | See `--ref-action` in linkgit:git-replay[1] for details. | |
| 18 | + | endif::git-replay[] | |
modified Documentation/config/safe.adoc
| @@ -2,10 +2,14 @@ safe.bareRepository:: | |||
| 2 | 2 | Specifies which bare repositories Git will work with. The currently | |
| 3 | 3 | supported values are: | |
| 4 | 4 | + | |
| 5 | - | * `all`: Git works with all bare repositories. This is the default. | |
| 5 | + | -- | |
| 6 | + | * `all`: Git works with all bare repositories. This is the default in | |
| 7 | + | Git 2.x. | |
| 6 | 8 | * `explicit`: Git only works with bare repositories specified via | |
| 7 | 9 | the top-level `--git-dir` command-line option, or the `GIT_DIR` | |
| 8 | - | environment variable (see linkgit:git[1]). | |
| 10 | + | environment variable (see linkgit:git[1]). This will be the default | |
| 11 | + | in Git 3.0. | |
| 12 | + | -- | |
| 9 | 13 | + | |
| 10 | 14 | If you do not use bare repositories in your workflow, then it may be | |
| 11 | 15 | beneficial to set `safe.bareRepository` to `explicit` in your global | |
| @@ -13,6 +17,10 @@ config. This will protect you from attacks that involve cloning a | |||
| 13 | 17 | repository that contains a bare repository and running a Git command | |
| 14 | 18 | within that directory. | |
| 15 | 19 | + | |
| 20 | + | If you use bare repositories regularly and want to preserve the current | |
| 21 | + | behavior after upgrading to Git 3.0, set `safe.bareRepository` to `all` | |
| 22 | + | in your global or system config. | |
| 23 | + | + | |
| 16 | 24 | This config setting is only respected in protected configuration (see | |
| 17 | 25 | <<SCOPES>>). This prevents untrusted repositories from tampering with | |
| 18 | 26 | this value. | |
modified Documentation/config/sendemail.adoc
| @@ -1,25 +1,25 @@ | |||
| 1 | - | sendemail.identity:: | |
| 1 | + | `sendemail.identity`:: | |
| 2 | 2 | A configuration identity. When given, causes values in the | |
| 3 | 3 | `sendemail.<identity>` subsection to take precedence over | |
| 4 | 4 | values in the `sendemail` section. The default identity is | |
| 5 | 5 | the value of `sendemail.identity`. | |
| 6 | 6 | ||
| 7 | - | sendemail.smtpEncryption:: | |
| 7 | + | `sendemail.smtpEncryption`:: | |
| 8 | 8 | See linkgit:git-send-email[1] for description. Note that this | |
| 9 | 9 | setting is not subject to the `identity` mechanism. | |
| 10 | 10 | ||
| 11 | - | sendemail.smtpSSLCertPath:: | |
| 11 | + | `sendemail.smtpSSLCertPath`:: | |
| 12 | 12 | Path to ca-certificates (either a directory or a single file). | |
| 13 | 13 | Set it to an empty string to disable certificate verification. | |
| 14 | 14 | ||
| 15 | - | sendemail.smtpSSLClientCert:: | |
| 15 | + | `sendemail.smtpSSLClientCert`:: | |
| 16 | 16 | Path to the client certificate file to present if requested by the | |
| 17 | 17 | server. This is required when the server is set up to verify client | |
| 18 | 18 | certificates. If the corresponding private key is not included in the | |
| 19 | 19 | file, it must be supplied using `sendemail.smtpSSLClientKey` or the | |
| 20 | 20 | `--smtp-ssl-client-key` option. | |
| 21 | 21 | ||
| 22 | - | sendemail.smtpSSLClientKey:: | |
| 22 | + | `sendemail.smtpSSLClientKey`:: | |
| 23 | 23 | Path to the client private key file that corresponds to the client | |
| 24 | 24 | certificate. To avoid misconfiguration, this configuration must be used | |
| 25 | 25 | in conjunction with `sendemail.smtpSSLClientCert` or the | |
| @@ -28,45 +28,45 @@ sendemail.smtpSSLClientKey:: | |||
| 28 | 28 | the certificate. Visit https://metacpan.org/pod/IO::Socket::SSL for more | |
| 29 | 29 | details. | |
| 30 | 30 | ||
| 31 | - | sendemail.<identity>.*:: | |
| 32 | - | Identity-specific versions of the `sendemail.*` parameters | |
| 31 | + | `sendemail.<identity>.<config>`:: | |
| 32 | + | Identity-specific versions of the `sendemail.<config>` parameters | |
| 33 | 33 | found below, taking precedence over those when this | |
| 34 | 34 | identity is selected, through either the command-line or | |
| 35 | 35 | `sendemail.identity`. | |
| 36 | 36 | ||
| 37 | - | sendemail.multiEdit:: | |
| 37 | + | `sendemail.multiEdit`:: | |
| 38 | 38 | If `true` (default), a single editor instance will be spawned to edit | |
| 39 | 39 | files you have to edit (patches when `--annotate` is used, and the | |
| 40 | 40 | summary when `--compose` is used). If `false`, files will be edited one | |
| 41 | 41 | after the other, spawning a new editor each time. | |
| 42 | 42 | ||
| 43 | - | sendemail.confirm:: | |
| 43 | + | `sendemail.confirm`:: | |
| 44 | 44 | Sets the default for whether to confirm before sending. Must be | |
| 45 | 45 | one of `always`, `never`, `cc`, `compose`, or `auto`. See `--confirm` | |
| 46 | 46 | in the linkgit:git-send-email[1] documentation for the meaning of these | |
| 47 | 47 | values. | |
| 48 | 48 | ||
| 49 | - | sendemail.mailmap:: | |
| 49 | + | `sendemail.mailmap`:: | |
| 50 | 50 | If `true`, makes linkgit:git-send-email[1] assume `--mailmap`, | |
| 51 | 51 | otherwise assume `--no-mailmap`. `False` by default. | |
| 52 | 52 | ||
| 53 | - | sendemail.mailmap.file:: | |
| 53 | + | `sendemail.mailmap.file`:: | |
| 54 | 54 | The location of a linkgit:git-send-email[1] specific augmenting | |
| 55 | 55 | mailmap file. The default mailmap and `mailmap.file` are loaded | |
| 56 | 56 | first. Thus, entries in this file take precedence over entries in | |
| 57 | 57 | the default mailmap locations. See linkgit:gitmailmap[5]. | |
| 58 | 58 | ||
| 59 | - | sendemail.mailmap.blob:: | |
| 59 | + | `sendemail.mailmap.blob`:: | |
| 60 | 60 | Like `sendemail.mailmap.file`, but consider the value as a reference | |
| 61 | 61 | to a blob in the repository. Entries in `sendemail.mailmap.file` | |
| 62 | 62 | take precedence over entries here. See linkgit:gitmailmap[5]. | |
| 63 | 63 | ||
| 64 | - | sendemail.aliasesFile:: | |
| 64 | + | `sendemail.aliasesFile`:: | |
| 65 | 65 | To avoid typing long email addresses, point this to one or more | |
| 66 | 66 | email aliases files. You must also supply `sendemail.aliasFileType`. | |
| 67 | 67 | ||
| 68 | - | sendemail.aliasFileType:: | |
| 69 | - | Format of the file(s) specified in sendemail.aliasesFile. Must be | |
| 68 | + | `sendemail.aliasFileType`:: | |
| 69 | + | Format of the file(s) specified in `sendemail.aliasesFile`. Must be | |
| 70 | 70 | one of `mutt`, `mailrc`, `pine`, `elm`, `gnus`, or `sendmail`. | |
| 71 | 71 | + | |
| 72 | 72 | What an alias file in each format looks like can be found in | |
| @@ -75,7 +75,7 @@ differences and limitations from the standard formats are | |||
| 75 | 75 | described below: | |
| 76 | 76 | + | |
| 77 | 77 | -- | |
| 78 | - | sendmail;; | |
| 78 | + | `sendmail`;; | |
| 79 | 79 | * Quoted aliases and quoted addresses are not supported: lines that | |
| 80 | 80 | contain a `"` symbol are ignored. | |
| 81 | 81 | * Redirection to a file (`/path/name`) or pipe (`|command`) is not | |
| @@ -85,54 +85,54 @@ sendmail;; | |||
| 85 | 85 | explicitly unsupported constructs, and any other lines that are not | |
| 86 | 86 | recognized by the parser. | |
| 87 | 87 | -- | |
| 88 | - | sendemail.annotate:: | |
| 89 | - | sendemail.bcc:: | |
| 90 | - | sendemail.cc:: | |
| 91 | - | sendemail.ccCmd:: | |
| 92 | - | sendemail.chainReplyTo:: | |
| 93 | - | sendemail.envelopeSender:: | |
| 94 | - | sendemail.from:: | |
| 95 | - | sendemail.headerCmd:: | |
| 96 | - | sendemail.signedOffByCc:: | |
| 97 | - | sendemail.smtpPass:: | |
| 98 | - | sendemail.suppressCc:: | |
| 99 | - | sendemail.suppressFrom:: | |
| 100 | - | sendemail.to:: | |
| 101 | - | sendemail.toCmd:: | |
| 102 | - | sendemail.smtpDomain:: | |
| 103 | - | sendemail.smtpServer:: | |
| 104 | - | sendemail.smtpServerPort:: | |
| 105 | - | sendemail.smtpServerOption:: | |
| 106 | - | sendemail.smtpUser:: | |
| 107 | - | sendemail.imapSentFolder:: | |
| 108 | - | sendemail.useImapOnly:: | |
| 109 | - | sendemail.thread:: | |
| 110 | - | sendemail.transferEncoding:: | |
| 111 | - | sendemail.validate:: | |
| 112 | - | sendemail.xmailer:: | |
| 88 | + | `sendemail.annotate`:: | |
| 89 | + | `sendemail.bcc`:: | |
| 90 | + | `sendemail.cc`:: | |
| 91 | + | `sendemail.ccCmd`:: | |
| 92 | + | `sendemail.chainReplyTo`:: | |
| 93 | + | `sendemail.envelopeSender`:: | |
| 94 | + | `sendemail.from`:: | |
| 95 | + | `sendemail.headerCmd`:: | |
| 96 | + | `sendemail.signedOffByCc`:: | |
| 97 | + | `sendemail.smtpPass`:: | |
| 98 | + | `sendemail.suppressCc`:: | |
| 99 | + | `sendemail.suppressFrom`:: | |
| 100 | + | `sendemail.to`:: | |
| 101 | + | `sendemail.toCmd`:: | |
| 102 | + | `sendemail.smtpDomain`:: | |
| 103 | + | `sendemail.smtpServer`:: | |
| 104 | + | `sendemail.smtpServerPort`:: | |
| 105 | + | `sendemail.smtpServerOption`:: | |
| 106 | + | `sendemail.smtpUser`:: | |
| 107 | + | `sendemail.imapSentFolder`:: | |
| 108 | + | `sendemail.useImapOnly`:: | |
| 109 | + | `sendemail.thread`:: | |
| 110 | + | `sendemail.transferEncoding`:: | |
| 111 | + | `sendemail.validate`:: | |
| 112 | + | `sendemail.xmailer`:: | |
| 113 | 113 | These configuration variables all provide a default for | |
| 114 | 114 | linkgit:git-send-email[1] command-line options. See its | |
| 115 | 115 | documentation for details. | |
| 116 | 116 | ||
| 117 | - | sendemail.outlookidfix:: | |
| 117 | + | `sendemail.outlookidfix`:: | |
| 118 | 118 | If `true`, makes linkgit:git-send-email[1] assume `--outlook-id-fix`, | |
| 119 | 119 | and if `false` assume `--no-outlook-id-fix`. If not specified, it will | |
| 120 | 120 | behave the same way as if `--outlook-id-fix` is not specified. | |
| 121 | 121 | ||
| 122 | - | sendemail.signedOffCc (deprecated):: | |
| 122 | + | `sendemail.signedOffCc` (deprecated):: | |
| 123 | 123 | Deprecated alias for `sendemail.signedOffByCc`. | |
| 124 | 124 | ||
| 125 | - | sendemail.smtpBatchSize:: | |
| 125 | + | `sendemail.smtpBatchSize`:: | |
| 126 | 126 | Number of messages to be sent per connection, after that a relogin | |
| 127 | 127 | will happen. If the value is `0` or undefined, send all messages in | |
| 128 | 128 | one connection. | |
| 129 | 129 | See also the `--batch-size` option of linkgit:git-send-email[1]. | |
| 130 | 130 | ||
| 131 | - | sendemail.smtpReloginDelay:: | |
| 131 | + | `sendemail.smtpReloginDelay`:: | |
| 132 | 132 | Seconds to wait before reconnecting to the smtp server. | |
| 133 | 133 | See also the `--relogin-delay` option of linkgit:git-send-email[1]. | |
| 134 | 134 | ||
| 135 | - | sendemail.forbidSendmailVariables:: | |
| 135 | + | `sendemail.forbidSendmailVariables`:: | |
| 136 | 136 | To avoid common misconfiguration mistakes, linkgit:git-send-email[1] | |
| 137 | 137 | will abort with a warning if any configuration options for `sendmail` | |
| 138 | 138 | exist. Set this variable to bypass the check. | |
added Documentation/config/sideband.adoc mode 100644
| @@ -0,0 +1,27 @@ | |||
| 1 | + | sideband.allowControlCharacters:: | |
| 2 | + | By default, control characters that are delivered via the sideband | |
| 3 | + | are masked, except ANSI color sequences. This prevents potentially | |
| 4 | + | unwanted ANSI escape sequences from being sent to the terminal. Use | |
| 5 | + | this config setting to override this behavior (the value can be | |
| 6 | + | a comma-separated list of the following keywords): | |
| 7 | + | + | |
| 8 | + | -- | |
| 9 | + | `color`:: | |
| 10 | + | Allow ANSI color sequences, line feeds and horizontal tabs, | |
| 11 | + | but mask all other control characters. This is the default. | |
| 12 | + | `cursor`:: | |
| 13 | + | Allow control sequences that move the cursor. This is | |
| 14 | + | disabled by default. | |
| 15 | + | `erase`:: | |
| 16 | + | Allow control sequences that erase characters. This is | |
| 17 | + | disabled by default. | |
| 18 | + | `false`:: | |
| 19 | + | Mask all control characters other than line feeds and | |
| 20 | + | horizontal tabs. | |
| 21 | + | `true`:: | |
| 22 | + | Allow all control characters to be sent to the terminal. | |
| 23 | + | -- | |
| 24 | + | ||
| 25 | + | sideband.<url>.*:: | |
| 26 | + | Apply the `sideband.*` option selectively to specific URLs. The | |
| 27 | + | same URL matching logic applies as for `http.<url>.*` settings. | |
modified Documentation/config/worktree.adoc
| @@ -5,8 +5,9 @@ | |||
| 5 | 5 | set to true, `worktree add` tries to find a remote-tracking | |
| 6 | 6 | branch whose name uniquely matches the new branch name. If | |
| 7 | 7 | such a branch exists, it is checked out and set as "upstream" | |
| 8 | - | for the new branch. If no such match can be found, it falls | |
| 9 | - | back to creating a new branch from the current `HEAD`. | |
| 8 | + | for the new branch. If multiple matches are found, the command | |
| 9 | + | fails. If no such match can be found, it falls back to | |
| 10 | + | creating a new branch from the current `HEAD`. | |
| 10 | 11 | ||
| 11 | 12 | `worktree.useRelativePaths`:: | |
| 12 | 13 | Link worktrees using relative paths (when "`true`") or absolute | |
modified Documentation/date-formats.adoc
| @@ -9,6 +9,11 @@ Git internal format:: | |||
| 9 | 9 | `<unix-timestamp>` is the number of seconds since the UNIX epoch. | |
| 10 | 10 | `<time-zone-offset>` is a positive or negative offset from UTC. | |
| 11 | 11 | For example CET (which is 1 hour ahead of UTC) is `+0100`. | |
| 12 | + | + | |
| 13 | + | It is safer to prepend the `<unix-timestamp>` with `@` (e.g., | |
| 14 | + | `@0 +0000`), which forces Git to interpret it as a raw timestamp. This | |
| 15 | + | is required for values less than 100,000,000 (which have fewer than 9 | |
| 16 | + | digits) to avoid confusion with other date formats like `YYYYMMDD`. | |
| 12 | 17 | ||
| 13 | 18 | RFC 2822:: | |
| 14 | 19 | The standard date format as described by RFC 2822, for example | |
modified Documentation/diff-format.adoc
| @@ -19,9 +19,9 @@ compared differs: | |||
| 19 | 19 | `git-diff-files [<pattern>...]`:: | |
| 20 | 20 | compares the index and the files on the filesystem. | |
| 21 | 21 | ||
| 22 | - | The `git-diff-tree` command begins its output by printing the hash of | |
| 23 | - | what is being compared. After that, all the commands print one output | |
| 24 | - | line per changed file. | |
| 22 | + | All the commands print one output line per changed file, | |
| 23 | + | except `git diff-files` in the case of an unmerged file, which prints | |
| 24 | + | both an "unmerged" and an "in-place edit" line. | |
| 25 | 25 | ||
| 26 | 26 | An output line is formatted this way: | |
| 27 | 27 | ||
| @@ -37,13 +37,13 @@ unmerged :000000 000000 0000000 0000000 U file6 | |||
| 37 | 37 | That is, from the left to the right: | |
| 38 | 38 | ||
| 39 | 39 | . a colon. | |
| 40 | - | . mode for "src"; 000000 if creation or unmerged. | |
| 40 | + | . mode for "src"; 000000 if creation, or if "src" is from the index and is unmerged. | |
| 41 | 41 | . a space. | |
| 42 | - | . mode for "dst"; 000000 if deletion or unmerged. | |
| 42 | + | . mode for "dst"; 000000 if deletion, or if "dst" is from the index and is unmerged. | |
| 43 | 43 | . a space. | |
| 44 | - | . sha1 for "src"; 0\{40\} if creation or unmerged. | |
| 44 | + | . sha1 for "src"; 0\{40\} if creation, or if "src" is from the index and is unmerged. | |
| 45 | 45 | . a space. | |
| 46 | - | . sha1 for "dst"; 0\{40\} if deletion, unmerged or "work tree out of sync with the index". | |
| 46 | + | . sha1 for "dst"; 0\{40\} if deletion, if "dst" is from the index and is unmerged, or if "dst" is from the work tree and is out of sync with the index. | |
| 47 | 47 | . a space. | |
| 48 | 48 | . status, followed by optional "score" number. | |
| 49 | 49 | . a tab or a NUL when `-z` option is used. | |
modified Documentation/diff-options.adoc
| @@ -13,8 +13,8 @@ endif::git-diff[] | |||
| 13 | 13 | endif::git-format-patch[] | |
| 14 | 14 | ||
| 15 | 15 | ifdef::git-format-patch[] | |
| 16 | - | -p:: | |
| 17 | - | --no-stat:: | |
| 16 | + | `-p`:: | |
| 17 | + | `--no-stat`:: | |
| 18 | 18 | Generate plain patches without any diffstats. | |
| 19 | 19 | endif::git-format-patch[] | |
| 20 | 20 | ||
| @@ -457,6 +457,14 @@ endif::git-diff[] | |||
| 457 | 457 | + | |
| 458 | 458 | Note that despite the name of the first mode, color is used to | |
| 459 | 459 | highlight the changed parts in all modes if enabled. | |
| 460 | + | + | |
| 461 | + | The `--word-diff` option operates by taking the same line-by-line | |
| 462 | + | diff that is produced without the option and computing | |
| 463 | + | word-by-word changes within each hunk. This may produce a | |
| 464 | + | larger diff than a dedicated word-diff tool would. If Git | |
| 465 | + | acquires a different implementation in the future, the output | |
| 466 | + | may change. Note that this is similar to the `--diff-algorithm` | |
| 467 | + | option, which may also change the output. | |
| 460 | 468 | ||
| 461 | 469 | `--word-diff-regex=<regex>`:: | |
| 462 | 470 | Use _<regex>_ to decide what a word is, instead of considering | |
| @@ -885,8 +893,8 @@ endif::git-format-patch[] | |||
| 885 | 893 | reverted with `--ita-visible-in-index`. Both options are | |
| 886 | 894 | experimental and could be removed in future. | |
| 887 | 895 | ||
| 888 | - | --max-depth=<depth>:: | |
| 889 | - | For each pathspec given on command line, descend at most `<depth>` | |
| 896 | + | `--max-depth=<depth>`:: | |
| 897 | + | For each pathspec given on command line, descend at most _<depth>_ | |
| 890 | 898 | levels of directories. A value of `-1` means no limit. | |
| 891 | 899 | Cannot be combined with wildcards in the pathspec. | |
| 892 | 900 | Given a tree containing `foo/bar/baz`, the following list shows the | |
modified Documentation/fetch-options.adoc
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | `--all`:: | |
| 2 | 2 | `--no-all`:: | |
| 3 | - | Fetch all remotes, except for the ones that has the | |
| 3 | + | Fetch all remotes, except for the ones that have the | |
| 4 | 4 | `remote.<name>.skipFetchAll` configuration variable set. | |
| 5 | 5 | This overrides the configuration variable `fetch.all`. | |
| 6 | 6 | ||
| @@ -49,6 +49,7 @@ the current repository has the same history as the source repository. | |||
| 49 | 49 | `.git/shallow`. This option updates `.git/shallow` and accepts such | |
| 50 | 50 | refs. | |
| 51 | 51 | ||
| 52 | + | `--negotiation-restrict=(<commit>|<glob>)`:: | |
| 52 | 53 | `--negotiation-tip=(<commit>|<glob>)`:: | |
| 53 | 54 | By default, Git will report, to the server, commits reachable | |
| 54 | 55 | from all local refs to find common commits in an attempt to | |
| @@ -58,6 +59,9 @@ the current repository has the same history as the source repository. | |||
| 58 | 59 | local ref is likely to have commits in common with the | |
| 59 | 60 | upstream ref being fetched. | |
| 60 | 61 | + | |
| 62 | + | `--negotiation-restrict` is the preferred name for this option; | |
| 63 | + | `--negotiation-tip` is accepted as a synonym. | |
| 64 | + | + | |
| 61 | 65 | This option may be specified more than once; if so, Git will report | |
| 62 | 66 | commits reachable from any of the given commits. | |
| 63 | 67 | + | |
| @@ -69,9 +73,32 @@ See also the `fetch.negotiationAlgorithm` and `push.negotiate` | |||
| 69 | 73 | configuration variables documented in linkgit:git-config[1], and the | |
| 70 | 74 | `--negotiate-only` option below. | |
| 71 | 75 | ||
| 76 | + | `--negotiation-include=(<commit>|<glob>)`:: | |
| 77 | + | Ensure that the commits at the given tips are always sent as "have" | |
| 78 | + | lines during fetch negotiation, regardless of what the negotiation | |
| 79 | + | algorithm selects. This is useful to guarantee that common | |
| 80 | + | history reachable from specific refs is always considered, even | |
| 81 | + | when `--negotiation-restrict` restricts the set of tips or when | |
| 82 | + | the negotiation algorithm would otherwise skip them. | |
| 83 | + | + | |
| 84 | + | This option may be specified more than once; if so, each commit is sent | |
| 85 | + | unconditionally. | |
| 86 | + | + | |
| 87 | + | The argument may be an exact ref name (e.g. `refs/heads/release`), an | |
| 88 | + | object hash, or a glob pattern (e.g. `refs/heads/release/{asterisk}`). | |
| 89 | + | The pattern syntax is the same as for `--negotiation-restrict`. | |
| 90 | + | + | |
| 91 | + | If `--negotiation-restrict` is used, the have set is first restricted by | |
| 92 | + | that option and then increased to include the tips specified by | |
| 93 | + | `--negotiation-include`. | |
| 94 | + | + | |
| 95 | + | If this option is not specified on the command line, then any | |
| 96 | + | `remote.<name>.negotiationInclude` config values for the current remote | |
| 97 | + | are used instead. | |
| 98 | + | ||
| 72 | 99 | `--negotiate-only`:: | |
| 73 | 100 | Do not fetch anything from the server, and instead print the | |
| 74 | - | ancestors of the provided `--negotiation-tip=` arguments, | |
| 101 | + | ancestors of the provided `--negotiation-restrict=` arguments, | |
| 75 | 102 | which we have in common with the server. | |
| 76 | 103 | + | |
| 77 | 104 | This is incompatible with `--recurse-submodules=(yes|on-demand)`. | |
modified Documentation/format-patch-caveats.adoc
| @@ -28,6 +28,6 @@ repositories. This goes to show that this behavior does not only impact | |||
| 28 | 28 | email workflows. | |
| 29 | 29 | ||
| 30 | 30 | Given these limitations, one might be tempted to use a general-purpose | |
| 31 | - | utility like patch(1) instead. However, patch(1) will not only look for | |
| 31 | + | utility like `patch`(1) instead. However, `patch`(1) will not only look for | |
| 32 | 32 | unindented diffs (like linkgit:git-am[1]) but will try to apply indented | |
| 33 | 33 | diffs as well. | |
modified Documentation/format-patch-end-of-commit-message.adoc
| @@ -1,8 +1,8 @@ | |||
| 1 | 1 | Any line that is of the form: | |
| 2 | 2 | ||
| 3 | 3 | * three-dashes and end-of-line, or | |
| 4 | - | * a line that begins with "diff -", or | |
| 5 | - | * a line that begins with "Index: " | |
| 4 | + | * a line that begins with `diff -`, or | |
| 5 | + | * a line that begins with `Index: ` | |
| 6 | 6 | ||
| 7 | 7 | is taken as the beginning of a patch, and the commit log message | |
| 8 | 8 | is terminated before the first occurrence of such a line. | |
modified Documentation/git-add.adoc
| @@ -11,7 +11,7 @@ SYNOPSIS | |||
| 11 | 11 | git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] | |
| 12 | 12 | [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse] | |
| 13 | 13 | [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize] | |
| 14 | - | [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]] | |
| 14 | + | [--resolved] [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]] | |
| 15 | 15 | [--] [<pathspec>...] | |
| 16 | 16 | ||
| 17 | 17 | DESCRIPTION | |
| @@ -195,6 +195,14 @@ for `git add --no-all <pathspec>...`, i.e. ignored removed files. | |||
| 195 | 195 | while a _CRLF_ cleans to _LF_, a _CRCRLF_ sequence is only partially | |
| 196 | 196 | cleaned to _CRLF_. | |
| 197 | 197 | ||
| 198 | + | `--resolved`:: | |
| 199 | + | Update the index for unmerged paths matching _<pathspec>_ where | |
| 200 | + | no conflict markers remain in the working tree. Unmerged paths | |
| 201 | + | without conflict markers (including binary files and file | |
| 202 | + | deletions) are staged as resolved, while any path with leftover | |
| 203 | + | conflict markers causes the command to refuse to stage any files. | |
| 204 | + | Cannot be combined with `-u` or `-A`. | |
| 205 | + | ||
| 198 | 206 | `--chmod=(+|-)x`:: | |
| 199 | 207 | Override the executable bit of the added files. The executable | |
| 200 | 208 | bit is only changed in the index, the files on disk are left | |
modified Documentation/git-am.adoc
| @@ -8,17 +8,17 @@ git-am - Apply a series of patches from a mailbox | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--[no-]verify] | |
| 11 | + | [synopsis] | |
| 12 | + | git am [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--[no-]verify] | |
| 13 | 13 | [--[no-]3way] [--interactive] [--committer-date-is-author-date] | |
| 14 | 14 | [--ignore-date] [--ignore-space-change | --ignore-whitespace] | |
| 15 | 15 | [--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>] | |
| 16 | 16 | [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet] | |
| 17 | - | [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>] | |
| 17 | + | [--[no-]scissors] [-S[<key-id>]] [--patch-format=<format>] | |
| 18 | 18 | [--quoted-cr=<action>] | |
| 19 | 19 | [--empty=(stop|drop|keep)] | |
| 20 | 20 | [(<mbox> | <Maildir>)...] | |
| 21 | - | 'git am' (--continue | --skip | --abort | --quit | --retry | --show-current-patch[=(diff|raw)] | --allow-empty) | |
| 21 | + | git am (--continue | --skip | --abort | --quit | --retry | --show-current-patch[=(diff|raw)] | --allow-empty) | |
| 22 | 22 | ||
| 23 | 23 | DESCRIPTION | |
| 24 | 24 | ----------- | |
| @@ -30,45 +30,45 @@ history without merges. | |||
| 30 | 30 | ||
| 31 | 31 | OPTIONS | |
| 32 | 32 | ------- | |
| 33 | - | (<mbox>|<Maildir>)...:: | |
| 33 | + | `(<mbox>|<Maildir>)...`:: | |
| 34 | 34 | The list of mailbox files to read patches from. If you do not | |
| 35 | 35 | supply this argument, the command reads from the standard input. | |
| 36 | 36 | If you supply directories, they will be treated as Maildirs. | |
| 37 | 37 | ||
| 38 | - | -s:: | |
| 39 | - | --signoff:: | |
| 38 | + | `-s`:: | |
| 39 | + | `--signoff`:: | |
| 40 | 40 | Add a `Signed-off-by` trailer to the commit message (see | |
| 41 | 41 | linkgit:git-interpret-trailers[1]), using the committer identity | |
| 42 | 42 | of yourself. See the signoff option in linkgit:git-commit[1] | |
| 43 | 43 | for more information. | |
| 44 | 44 | ||
| 45 | - | -k:: | |
| 46 | - | --keep:: | |
| 45 | + | `-k`:: | |
| 46 | + | `--keep`:: | |
| 47 | 47 | Pass `-k` flag to linkgit:git-mailinfo[1]. | |
| 48 | 48 | ||
| 49 | - | --keep-non-patch:: | |
| 49 | + | `--keep-non-patch`:: | |
| 50 | 50 | Pass `-b` flag to linkgit:git-mailinfo[1]. | |
| 51 | 51 | ||
| 52 | - | --keep-cr:: | |
| 53 | - | --no-keep-cr:: | |
| 52 | + | `--keep-cr`:: | |
| 53 | + | `--no-keep-cr`:: | |
| 54 | 54 | With `--keep-cr`, call linkgit:git-mailsplit[1] | |
| 55 | 55 | with the same option, to prevent it from stripping CR at the end of | |
| 56 | 56 | lines. `am.keepcr` configuration variable can be used to specify the | |
| 57 | 57 | default behaviour. `--no-keep-cr` is useful to override `am.keepcr`. | |
| 58 | 58 | ||
| 59 | - | -c:: | |
| 60 | - | --scissors:: | |
| 59 | + | `-c`:: | |
| 60 | + | `--scissors`:: | |
| 61 | 61 | Remove everything in body before a scissors line (see | |
| 62 | 62 | linkgit:git-mailinfo[1]). Can be activated by default using | |
| 63 | 63 | the `mailinfo.scissors` configuration variable. | |
| 64 | 64 | ||
| 65 | - | --no-scissors:: | |
| 65 | + | `--no-scissors`:: | |
| 66 | 66 | Ignore scissors lines (see linkgit:git-mailinfo[1]). | |
| 67 | 67 | ||
| 68 | - | --quoted-cr=<action>:: | |
| 68 | + | `--quoted-cr=<action>`:: | |
| 69 | 69 | This flag will be passed down to linkgit:git-mailinfo[1]. | |
| 70 | 70 | ||
| 71 | - | --empty=(drop|keep|stop):: | |
| 71 | + | `--empty=(drop|keep|stop)`:: | |
| 72 | 72 | How to handle an e-mail message lacking a patch: | |
| 73 | 73 | + | |
| 74 | 74 | -- | |
| @@ -82,23 +82,23 @@ OPTIONS | |||
| 82 | 82 | session. This is the default behavior. | |
| 83 | 83 | -- | |
| 84 | 84 | ||
| 85 | - | -m:: | |
| 86 | - | --message-id:: | |
| 85 | + | `-m`:: | |
| 86 | + | `--message-id`:: | |
| 87 | 87 | Pass the `-m` flag to linkgit:git-mailinfo[1], | |
| 88 | 88 | so that the `Message-ID` header is added to the commit message. | |
| 89 | 89 | The `am.messageid` configuration variable can be used to specify | |
| 90 | 90 | the default behaviour. | |
| 91 | 91 | ||
| 92 | - | --no-message-id:: | |
| 92 | + | `--no-message-id`:: | |
| 93 | 93 | Do not add the Message-ID header to the commit message. | |
| 94 | 94 | `--no-message-id` is useful to override `am.messageid`. | |
| 95 | 95 | ||
| 96 | - | -q:: | |
| 97 | - | --quiet:: | |
| 96 | + | `-q`:: | |
| 97 | + | `--quiet`:: | |
| 98 | 98 | Be quiet. Only print error messages. | |
| 99 | 99 | ||
| 100 | - | -u:: | |
| 101 | - | --utf8:: | |
| 100 | + | `-u`:: | |
| 101 | + | `--utf8`:: | |
| 102 | 102 | Pass `-u` flag to linkgit:git-mailinfo[1]. | |
| 103 | 103 | The proposed commit log message taken from the e-mail | |
| 104 | 104 | is re-coded into UTF-8 encoding (configuration variable | |
| @@ -108,57 +108,57 @@ OPTIONS | |||
| 108 | 108 | This was optional in prior versions of git, but now it is the | |
| 109 | 109 | default. You can use `--no-utf8` to override this. | |
| 110 | 110 | ||
| 111 | - | --no-utf8:: | |
| 111 | + | `--no-utf8`:: | |
| 112 | 112 | Pass `-n` flag to linkgit:git-mailinfo[1]. | |
| 113 | 113 | ||
| 114 | - | -3:: | |
| 115 | - | --3way:: | |
| 116 | - | --no-3way:: | |
| 114 | + | `-3`:: | |
| 115 | + | `--3way`:: | |
| 116 | + | `--no-3way`:: | |
| 117 | 117 | When the patch does not apply cleanly, fall back on | |
| 118 | 118 | 3-way merge if the patch records the identity of blobs | |
| 119 | 119 | it is supposed to apply to and we have those blobs | |
| 120 | 120 | available locally. `--no-3way` can be used to override | |
| 121 | - | am.threeWay configuration variable. For more information, | |
| 122 | - | see am.threeWay in linkgit:git-config[1]. | |
| 121 | + | `am.threeWay` configuration variable. For more information, | |
| 122 | + | see `am.threeWay` in linkgit:git-config[1]. | |
| 123 | 123 | ||
| 124 | 124 | include::rerere-options.adoc[] | |
| 125 | 125 | ||
| 126 | - | --ignore-space-change:: | |
| 127 | - | --ignore-whitespace:: | |
| 128 | - | --whitespace=<action>:: | |
| 129 | - | -C<n>:: | |
| 130 | - | -p<n>:: | |
| 131 | - | --directory=<dir>:: | |
| 132 | - | --exclude=<path>:: | |
| 133 | - | --include=<path>:: | |
| 134 | - | --reject:: | |
| 126 | + | `--ignore-space-change`:: | |
| 127 | + | `--ignore-whitespace`:: | |
| 128 | + | `--whitespace=<action>`:: | |
| 129 | + | `-C<n>`:: | |
| 130 | + | `-p<n>`:: | |
| 131 | + | `--directory=<dir>`:: | |
| 132 | + | `--exclude=<path>`:: | |
| 133 | + | `--include=<path>`:: | |
| 134 | + | `--reject`:: | |
| 135 | 135 | These flags are passed to the linkgit:git-apply[1] program that | |
| 136 | 136 | applies the patch. | |
| 137 | 137 | + | |
| 138 | - | Valid <action> for the `--whitespace` option are: | |
| 138 | + | Valid _<action>_ for the `--whitespace` option are: | |
| 139 | 139 | `nowarn`, `warn`, `fix`, `error`, and `error-all`. | |
| 140 | 140 | ||
| 141 | - | --patch-format:: | |
| 141 | + | `--patch-format`:: | |
| 142 | 142 | By default the command will try to detect the patch format | |
| 143 | 143 | automatically. This option allows the user to bypass the automatic | |
| 144 | 144 | detection and specify the patch format that the patch(es) should be | |
| 145 | 145 | interpreted as. Valid formats are mbox, mboxrd, | |
| 146 | 146 | stgit, stgit-series, and hg. | |
| 147 | 147 | ||
| 148 | - | -i:: | |
| 149 | - | --interactive:: | |
| 148 | + | `-i`:: | |
| 149 | + | `--interactive`:: | |
| 150 | 150 | Run interactively. | |
| 151 | 151 | ||
| 152 | - | --verify:: | |
| 153 | - | -n:: | |
| 154 | - | --no-verify:: | |
| 152 | + | `--verify`:: | |
| 153 | + | `-n`:: | |
| 154 | + | `--no-verify`:: | |
| 155 | 155 | Run the `pre-applypatch` and `applypatch-msg` hooks. This is the | |
| 156 | 156 | default. Skip these hooks with `-n` or `--no-verify`. See also | |
| 157 | 157 | linkgit:githooks[5]. | |
| 158 | 158 | + | |
| 159 | 159 | Note that `post-applypatch` cannot be skipped. | |
| 160 | 160 | ||
| 161 | - | --committer-date-is-author-date:: | |
| 161 | + | `--committer-date-is-author-date`:: | |
| 162 | 162 | By default the command records the date from the e-mail | |
| 163 | 163 | message as the commit author date, and uses the time of | |
| 164 | 164 | commit creation as the committer date. This allows the | |
| @@ -172,29 +172,29 @@ committer date when applying commits on top of a base which commit is | |||
| 172 | 172 | older (in terms of the commit date) than the oldest patch you are | |
| 173 | 173 | applying. | |
| 174 | 174 | ||
| 175 | - | --ignore-date:: | |
| 175 | + | `--ignore-date`:: | |
| 176 | 176 | By default the command records the date from the e-mail | |
| 177 | 177 | message as the commit author date, and uses the time of | |
| 178 | 178 | commit creation as the committer date. This allows the | |
| 179 | 179 | user to lie about the author date by using the same | |
| 180 | 180 | value as the committer date. | |
| 181 | 181 | ||
| 182 | - | --skip:: | |
| 182 | + | `--skip`:: | |
| 183 | 183 | Skip the current patch. This is only meaningful when | |
| 184 | 184 | restarting an aborted patch. | |
| 185 | 185 | ||
| 186 | - | -S[<keyid>]:: | |
| 187 | - | --gpg-sign[=<keyid>]:: | |
| 188 | - | --no-gpg-sign:: | |
| 189 | - | GPG-sign commits. The `keyid` argument is optional and | |
| 186 | + | `-S[<key-id>]`:: | |
| 187 | + | `--gpg-sign[=<key-id>]`:: | |
| 188 | + | `--no-gpg-sign`:: | |
| 189 | + | GPG-sign commits. The _<key-id>_ is optional and | |
| 190 | 190 | defaults to the committer identity; if specified, it must be | |
| 191 | 191 | stuck to the option without a space. `--no-gpg-sign` is useful to | |
| 192 | 192 | countermand both `commit.gpgSign` configuration variable, and | |
| 193 | 193 | earlier `--gpg-sign`. | |
| 194 | 194 | ||
| 195 | - | --continue:: | |
| 196 | - | -r:: | |
| 197 | - | --resolved:: | |
| 195 | + | `--continue`:: | |
| 196 | + | `-r`:: | |
| 197 | + | `--resolved`:: | |
| 198 | 198 | After a patch failure (e.g. attempting to apply | |
| 199 | 199 | conflicting patch), the user has applied it by hand and | |
| 200 | 200 | the index file stores the result of the application. | |
| @@ -202,36 +202,36 @@ applying. | |||
| 202 | 202 | extracted from the e-mail message and the current index | |
| 203 | 203 | file, and continue. | |
| 204 | 204 | ||
| 205 | - | --resolvemsg=<msg>:: | |
| 206 | - | When a patch failure occurs, <msg> will be printed | |
| 205 | + | `--resolvemsg=<msg>`:: | |
| 206 | + | When a patch failure occurs, _<msg>_ will be printed | |
| 207 | 207 | to the screen before exiting. This overrides the | |
| 208 | 208 | standard message informing you to use `--continue` | |
| 209 | 209 | or `--skip` to handle the failure. This is solely | |
| 210 | 210 | for internal use between linkgit:git-rebase[1] and | |
| 211 | 211 | linkgit:git-am[1]. | |
| 212 | 212 | ||
| 213 | - | --abort:: | |
| 213 | + | `--abort`:: | |
| 214 | 214 | Restore the original branch and abort the patching operation. | |
| 215 | 215 | Revert the contents of files involved in the am operation to their | |
| 216 | 216 | pre-am state. | |
| 217 | 217 | ||
| 218 | - | --quit:: | |
| 219 | - | Abort the patching operation but keep HEAD and the index | |
| 218 | + | `--quit`:: | |
| 219 | + | Abort the patching operation but keep `HEAD` and the index | |
| 220 | 220 | untouched. | |
| 221 | 221 | ||
| 222 | - | --retry:: | |
| 222 | + | `--retry`:: | |
| 223 | 223 | Try to apply the last conflicting patch again. This is generally | |
| 224 | 224 | only useful for passing extra options to the retry attempt | |
| 225 | 225 | (e.g., `--3way`), since otherwise you'll just see the same | |
| 226 | 226 | failure again. | |
| 227 | 227 | ||
| 228 | - | --show-current-patch[=(diff|raw)]:: | |
| 228 | + | `--show-current-patch[=(diff|raw)]`:: | |
| 229 | 229 | Show the message at which linkgit:git-am[1] has stopped due to | |
| 230 | 230 | conflicts. If `raw` is specified, show the raw contents of | |
| 231 | 231 | the e-mail message; if `diff`, show the diff portion only. | |
| 232 | 232 | Defaults to `raw`. | |
| 233 | 233 | ||
| 234 | - | --allow-empty:: | |
| 234 | + | `--allow-empty`:: | |
| 235 | 235 | After a patch failure on an input e-mail message lacking a patch, | |
| 236 | 236 | create an empty commit with the contents of the e-mail message | |
| 237 | 237 | as its log message. | |
| @@ -278,11 +278,11 @@ operation is finished, so if you decide to start over from scratch, | |||
| 278 | 278 | run `git am --abort` before running the command with mailbox | |
| 279 | 279 | names. | |
| 280 | 280 | ||
| 281 | - | Before any patches are applied, ORIG_HEAD is set to the tip of the | |
| 281 | + | Before any patches are applied, `ORIG_HEAD` is set to the tip of the | |
| 282 | 282 | current branch. This is useful if you have problems with multiple | |
| 283 | 283 | commits, like running linkgit:git-am[1] on the wrong branch or an error | |
| 284 | 284 | in the commits that is more easily fixed by changing the mailbox (e.g. | |
| 285 | - | errors in the "From:" lines). | |
| 285 | + | errors in the `From:` lines). | |
| 286 | 286 | ||
| 287 | 287 | [[caveats]] | |
| 288 | 288 | CAVEATS | |
modified Documentation/git-apply.adoc
| @@ -8,8 +8,8 @@ git-apply - Apply a patch to files and/or to the index | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git apply' [--stat] [--numstat] [--summary] [--check] | |
| 11 | + | [synopsis] | |
| 12 | + | git apply [--stat] [--numstat] [--summary] [--check] | |
| 13 | 13 | [--index | --intent-to-add] [--3way] [--ours | --theirs | --union] | |
| 14 | 14 | [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse] | |
| 15 | 15 | [--allow-binary-replacement | --binary] [--reject] [-z] | |
| @@ -35,33 +35,33 @@ linkgit:git-format-patch[1] and/or received by email. | |||
| 35 | 35 | ||
| 36 | 36 | OPTIONS | |
| 37 | 37 | ------- | |
| 38 | - | <patch>...:: | |
| 39 | - | The files to read the patch from. '-' can be used to read | |
| 38 | + | `<patch>...`:: | |
| 39 | + | The files to read the patch from. `-` can be used to read | |
| 40 | 40 | from the standard input. | |
| 41 | 41 | ||
| 42 | - | --stat:: | |
| 42 | + | `--stat`:: | |
| 43 | 43 | Instead of applying the patch, output diffstat for the | |
| 44 | 44 | input. Turns off "apply". | |
| 45 | 45 | ||
| 46 | - | --numstat:: | |
| 46 | + | `--numstat`:: | |
| 47 | 47 | Similar to `--stat`, but shows the number of added and | |
| 48 | 48 | deleted lines in decimal notation and the pathname without | |
| 49 | 49 | abbreviation, to make it more machine friendly. For | |
| 50 | 50 | binary files, outputs two `-` instead of saying | |
| 51 | 51 | `0 0`. Turns off "apply". | |
| 52 | 52 | ||
| 53 | - | --summary:: | |
| 53 | + | `--summary`:: | |
| 54 | 54 | Instead of applying the patch, output a condensed | |
| 55 | 55 | summary of information obtained from git diff extended | |
| 56 | 56 | headers, such as creations, renames, and mode changes. | |
| 57 | 57 | Turns off "apply". | |
| 58 | 58 | ||
| 59 | - | --check:: | |
| 59 | + | `--check`:: | |
| 60 | 60 | Instead of applying the patch, see if the patch is | |
| 61 | 61 | applicable to the current working tree and/or the index | |
| 62 | 62 | file and detects errors. Turns off "apply". | |
| 63 | 63 | ||
| 64 | - | --index:: | |
| 64 | + | `--index`:: | |
| 65 | 65 | Apply the patch to both the index and the working tree (or | |
| 66 | 66 | merely check that it would apply cleanly to both if `--check` is | |
| 67 | 67 | in effect). Note that `--index` expects index entries and | |
| @@ -70,13 +70,13 @@ OPTIONS | |||
| 70 | 70 | raise an error if they are not, even if the patch would apply | |
| 71 | 71 | cleanly to both the index and the working tree in isolation. | |
| 72 | 72 | ||
| 73 | - | --cached:: | |
| 73 | + | `--cached`:: | |
| 74 | 74 | Apply the patch to just the index, without touching the working | |
| 75 | 75 | tree. If `--check` is in effect, merely check that it would | |
| 76 | 76 | apply cleanly to the index entry. | |
| 77 | 77 | ||
| 78 | - | -N:: | |
| 79 | - | --intent-to-add:: | |
| 78 | + | `-N`:: | |
| 79 | + | `--intent-to-add`:: | |
| 80 | 80 | When applying the patch only to the working tree, mark new | |
| 81 | 81 | files to be added to the index later (see `--intent-to-add` | |
| 82 | 82 | option in linkgit:git-add[1]). This option is ignored if | |
| @@ -84,8 +84,8 @@ OPTIONS | |||
| 84 | 84 | repository. Note that `--index` could be implied by other options | |
| 85 | 85 | such as `--3way`. | |
| 86 | 86 | ||
| 87 | - | -3:: | |
| 88 | - | --3way:: | |
| 87 | + | `-3`:: | |
| 88 | + | `--3way`:: | |
| 89 | 89 | Attempt 3-way merge if the patch records the identity of blobs it is supposed | |
| 90 | 90 | to apply to and we have those blobs available locally, possibly leaving the | |
| 91 | 91 | conflict markers in the files in the working tree for the user to | |
| @@ -94,14 +94,14 @@ OPTIONS | |||
| 94 | 94 | When used with the `--cached` option, any conflicts are left at higher stages | |
| 95 | 95 | in the cache. | |
| 96 | 96 | ||
| 97 | - | --ours:: | |
| 98 | - | --theirs:: | |
| 99 | - | --union:: | |
| 97 | + | `--ours`:: | |
| 98 | + | `--theirs`:: | |
| 99 | + | `--union`:: | |
| 100 | 100 | Instead of leaving conflicts in the file, resolve conflicts favouring | |
| 101 | - | our (or their or both) side of the lines. Requires --3way. | |
| 101 | + | our (or their or both) side of the lines. Requires `--3way`. | |
| 102 | 102 | ||
| 103 | - | --build-fake-ancestor=<file>:: | |
| 104 | - | Newer 'git diff' output has embedded 'index information' | |
| 103 | + | `--build-fake-ancestor=<file>`:: | |
| 104 | + | Newer `git diff` output has embedded 'index information' | |
| 105 | 105 | for each blob to help identify the original version that | |
| 106 | 106 | the patch applies to. When this flag is given, and if | |
| 107 | 107 | the original versions of the blobs are available locally, | |
| @@ -110,18 +110,18 @@ OPTIONS | |||
| 110 | 110 | When a pure mode change is encountered (which has no index information), | |
| 111 | 111 | the information is read from the current index instead. | |
| 112 | 112 | ||
| 113 | - | -R:: | |
| 114 | - | --reverse:: | |
| 113 | + | `-R`:: | |
| 114 | + | `--reverse`:: | |
| 115 | 115 | Apply the patch in reverse. | |
| 116 | 116 | ||
| 117 | - | --reject:: | |
| 118 | - | For atomicity, 'git apply' by default fails the whole patch and | |
| 117 | + | `--reject`:: | |
| 118 | + | For atomicity, `git apply` by default fails the whole patch and | |
| 119 | 119 | does not touch the working tree when some of the hunks | |
| 120 | 120 | do not apply. This option makes it apply | |
| 121 | 121 | the parts of the patch that are applicable, and leave the | |
| 122 | - | rejected hunks in corresponding *.rej files. | |
| 122 | + | rejected hunks in corresponding `*.rej` files. | |
| 123 | 123 | ||
| 124 | - | -z:: | |
| 124 | + | `-z`:: | |
| 125 | 125 | When `--numstat` has been given, do not munge pathnames, | |
| 126 | 126 | but use a NUL-terminated machine-readable format. | |
| 127 | 127 | + | |
| @@ -129,20 +129,20 @@ Without this option, pathnames with "unusual" characters are quoted as | |||
| 129 | 129 | explained for the configuration variable `core.quotePath` (see | |
| 130 | 130 | linkgit:git-config[1]). | |
| 131 | 131 | ||
| 132 | - | -p<n>:: | |
| 133 | - | Remove <n> leading path components (separated by slashes) from | |
| 132 | + | `-p<n>`:: | |
| 133 | + | Remove _<n>_ leading path components (separated by slashes) from | |
| 134 | 134 | traditional diff paths. E.g., with `-p2`, a patch against | |
| 135 | 135 | `a/dir/file` will be applied directly to `file`. The default is | |
| 136 | 136 | 1. | |
| 137 | 137 | ||
| 138 | - | -C<n>:: | |
| 139 | - | Ensure at least <n> lines of surrounding context match before | |
| 138 | + | `-C<n>`:: | |
| 139 | + | Ensure at least _<n>_ lines of surrounding context match before | |
| 140 | 140 | and after each change. When fewer lines of surrounding | |
| 141 | 141 | context exist they all must match. By default no context is | |
| 142 | 142 | ever ignored. | |
| 143 | 143 | ||
| 144 | - | --unidiff-zero:: | |
| 145 | - | By default, 'git apply' expects that the patch being | |
| 144 | + | `--unidiff-zero`:: | |
| 145 | + | By default, `git apply` expects that the patch being | |
| 146 | 146 | applied is a unified diff with at least one line of context. | |
| 147 | 147 | This provides good safety measures, but breaks down when | |
| 148 | 148 | applying a diff generated with `--unified=0`. To bypass these | |
| @@ -151,34 +151,34 @@ linkgit:git-config[1]). | |||
| 151 | 151 | Note, for the reasons stated above, the usage of context-free patches is | |
| 152 | 152 | discouraged. | |
| 153 | 153 | ||
| 154 | - | --apply:: | |
| 154 | + | `--apply`:: | |
| 155 | 155 | If you use any of the options marked "Turns off | |
| 156 | - | 'apply'" above, 'git apply' reads and outputs the | |
| 156 | + | 'apply'" above, `git apply` reads and outputs the | |
| 157 | 157 | requested information without actually applying the | |
| 158 | 158 | patch. Give this flag after those flags to also apply | |
| 159 | 159 | the patch. | |
| 160 | 160 | ||
| 161 | - | --no-add:: | |
| 161 | + | `--no-add`:: | |
| 162 | 162 | When applying a patch, ignore additions made by the | |
| 163 | 163 | patch. This can be used to extract the common part between | |
| 164 | - | two files by first running 'diff' on them and applying | |
| 164 | + | two files by first running `diff` on them and applying | |
| 165 | 165 | the result with this option, which would apply the | |
| 166 | 166 | deletion part but not the addition part. | |
| 167 | 167 | ||
| 168 | - | --allow-binary-replacement:: | |
| 169 | - | --binary:: | |
| 168 | + | `--allow-binary-replacement`:: | |
| 169 | + | `--binary`:: | |
| 170 | 170 | Historically we did not allow binary patch application | |
| 171 | 171 | without an explicit permission from the user, and this | |
| 172 | 172 | flag was the way to do so. Currently, we always allow binary | |
| 173 | 173 | patch application, so this is a no-op. | |
| 174 | 174 | ||
| 175 | - | --exclude=<path-pattern>:: | |
| 176 | - | Don't apply changes to files matching the given path pattern. This can | |
| 175 | + | `--exclude=<path-pattern>`:: | |
| 176 | + | Don't apply changes to files matching _<path-pattern>_. This can | |
| 177 | 177 | be useful when importing patchsets, where you want to exclude certain | |
| 178 | 178 | files or directories. | |
| 179 | 179 | ||
| 180 | - | --include=<path-pattern>:: | |
| 181 | - | Apply changes to files matching the given path pattern. This can | |
| 180 | + | `--include=<path-pattern>`:: | |
| 181 | + | Apply changes to files matching the _<path-pattern>_. This can | |
| 182 | 182 | be useful when importing patchsets, where you want to include certain | |
| 183 | 183 | files or directories. | |
| 184 | 184 | + | |
| @@ -188,15 +188,15 @@ patch to each path is used. A patch to a path that does not match any | |||
| 188 | 188 | include/exclude pattern is used by default if there is no include pattern | |
| 189 | 189 | on the command line, and ignored if there is any include pattern. | |
| 190 | 190 | ||
| 191 | - | --ignore-space-change:: | |
| 192 | - | --ignore-whitespace:: | |
| 191 | + | `--ignore-space-change`:: | |
| 192 | + | `--ignore-whitespace`:: | |
| 193 | 193 | When applying a patch, ignore changes in whitespace in context | |
| 194 | 194 | lines if necessary. | |
| 195 | 195 | Context lines will preserve their whitespace, and they will not | |
| 196 | 196 | undergo whitespace fixing regardless of the value of the | |
| 197 | 197 | `--whitespace` option. New lines will still be fixed, though. | |
| 198 | 198 | ||
| 199 | - | --whitespace=<action>:: | |
| 199 | + | `--whitespace=<action>`:: | |
| 200 | 200 | When applying a patch, detect a new or modified line that has | |
| 201 | 201 | whitespace errors. What are considered whitespace errors is | |
| 202 | 202 | controlled by `core.whitespace` configuration. By default, | |
| @@ -209,7 +209,7 @@ By default, the command outputs warning messages but applies the patch. | |||
| 209 | 209 | When `git-apply` is used for statistics and not applying a | |
| 210 | 210 | patch, it defaults to `nowarn`. | |
| 211 | 211 | + | |
| 212 | - | You can use different `<action>` values to control this | |
| 212 | + | You can use different _<action>_ values to control this | |
| 213 | 213 | behavior: | |
| 214 | 214 | + | |
| 215 | 215 | * `nowarn` turns off the trailing whitespace warning. | |
| @@ -223,48 +223,48 @@ behavior: | |||
| 223 | 223 | to apply the patch. | |
| 224 | 224 | * `error-all` is similar to `error` but shows all errors. | |
| 225 | 225 | ||
| 226 | - | --inaccurate-eof:: | |
| 227 | - | Under certain circumstances, some versions of 'diff' do not correctly | |
| 226 | + | `--inaccurate-eof`:: | |
| 227 | + | Under certain circumstances, some versions of `diff` do not correctly | |
| 228 | 228 | detect a missing new-line at the end of the file. As a result, patches | |
| 229 | - | created by such 'diff' programs do not record incomplete lines | |
| 229 | + | created by such `diff` programs do not record incomplete lines | |
| 230 | 230 | correctly. This option adds support for applying such patches by | |
| 231 | 231 | working around this bug. | |
| 232 | 232 | ||
| 233 | - | -v:: | |
| 234 | - | --verbose:: | |
| 233 | + | `-v`:: | |
| 234 | + | `--verbose`:: | |
| 235 | 235 | Report progress to stderr. By default, only a message about the | |
| 236 | 236 | current patch being applied will be printed. This option will cause | |
| 237 | 237 | additional information to be reported. | |
| 238 | 238 | ||
| 239 | - | -q:: | |
| 240 | - | --quiet:: | |
| 239 | + | `-q`:: | |
| 240 | + | `--quiet`:: | |
| 241 | 241 | Suppress stderr output. Messages about patch status and progress | |
| 242 | 242 | will not be printed. | |
| 243 | 243 | ||
| 244 | - | --recount:: | |
| 244 | + | `--recount`:: | |
| 245 | 245 | Do not trust the line counts in the hunk headers, but infer them | |
| 246 | 246 | by inspecting the patch (e.g. after editing the patch without | |
| 247 | 247 | adjusting the hunk headers appropriately). | |
| 248 | 248 | ||
| 249 | - | --directory=<root>:: | |
| 250 | - | Prepend <root> to all filenames. If a "-p" argument was also passed, | |
| 249 | + | `--directory=<root>`:: | |
| 250 | + | Prepend _<root>_ to all filenames. If a `-p` argument was also passed, | |
| 251 | 251 | it is applied before prepending the new root. | |
| 252 | 252 | + | |
| 253 | 253 | For example, a patch that talks about updating `a/git-gui.sh` to `b/git-gui.sh` | |
| 254 | 254 | can be applied to the file in the working tree `modules/git-gui/git-gui.sh` by | |
| 255 | 255 | running `git apply --directory=modules/git-gui`. | |
| 256 | 256 | ||
| 257 | - | --unsafe-paths:: | |
| 257 | + | `--unsafe-paths`:: | |
| 258 | 258 | By default, a patch that affects outside the working area | |
| 259 | 259 | (either a Git controlled working tree, or the current working | |
| 260 | - | directory when "git apply" is used as a replacement of GNU | |
| 261 | - | patch) is rejected as a mistake (or a mischief). | |
| 260 | + | directory when `git apply` is used as a replacement of GNU | |
| 261 | + | `patch`) is rejected as a mistake (or a mischief). | |
| 262 | 262 | + | |
| 263 | - | When `git apply` is used as a "better GNU patch", the user can pass | |
| 263 | + | When `git apply` is used as a "better GNU `patch`", the user can pass | |
| 264 | 264 | the `--unsafe-paths` option to override this safety check. This option | |
| 265 | 265 | has no effect when `--index` or `--cached` is in use. | |
| 266 | 266 | ||
| 267 | - | --allow-empty:: | |
| 267 | + | `--allow-empty`:: | |
| 268 | 268 | Don't return an error for patches containing no diff. This includes | |
| 269 | 269 | empty patches and patches with commit text only. | |
| 270 | 270 | ||
| @@ -273,11 +273,12 @@ CONFIGURATION | |||
| 273 | 273 | ||
| 274 | 274 | include::includes/cmd-config-section-all.adoc[] | |
| 275 | 275 | ||
| 276 | + | :git-apply: 1 | |
| 276 | 277 | include::config/apply.adoc[] | |
| 277 | 278 | ||
| 278 | 279 | SUBMODULES | |
| 279 | 280 | ---------- | |
| 280 | - | If the patch contains any changes to submodules then 'git apply' | |
| 281 | + | If the patch contains any changes to submodules then `git apply` | |
| 281 | 282 | treats these changes as follows. | |
| 282 | 283 | ||
| 283 | 284 | If `--index` is specified (explicitly or implicitly), then the submodule | |
modified Documentation/git-backfill.adoc
| @@ -9,7 +9,7 @@ git-backfill - Download missing objects in a partial clone | |||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | 11 | [synopsis] | |
| 12 | - | git backfill [--min-batch-size=<n>] [--[no-]sparse] | |
| 12 | + | git backfill [--min-batch-size=<n>] [--[no-]sparse] [--[no-]include-edges] [<revision-range>] | |
| 13 | 13 | ||
| 14 | 14 | DESCRIPTION | |
| 15 | 15 | ----------- | |
| @@ -43,7 +43,7 @@ smaller network calls than downloading the entire repository at clone | |||
| 43 | 43 | time. | |
| 44 | 44 | ||
| 45 | 45 | By default, `git backfill` downloads all blobs reachable from the `HEAD` | |
| 46 | - | commit. This set can be restricted or expanded using various options. | |
| 46 | + | commit. This set can be restricted or expanded using various options below. | |
| 47 | 47 | ||
| 48 | 48 | THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR MAY CHANGE IN THE FUTURE. | |
| 49 | 49 | ||
| @@ -63,7 +63,27 @@ OPTIONS | |||
| 63 | 63 | current sparse-checkout. If the sparse-checkout feature is enabled, | |
| 64 | 64 | then `--sparse` is assumed and can be disabled with `--no-sparse`. | |
| 65 | 65 | ||
| 66 | - | You may also specify the commit limiting options from linkgit:git-rev-list[1]. | |
| 66 | + | `--include-edges`:: | |
| 67 | + | `--no-include-edges`:: | |
| 68 | + | Include blobs from boundary commits in the backfill. Useful in | |
| 69 | + | preparation for commands like `git log -p A..B` or `git replay | |
| 70 | + | --onto TARGET A..B`, where A..B normally excludes A but you need | |
| 71 | + | the blobs from A as well. `--include-edges` is the default. | |
| 72 | + | ||
| 73 | + | `<revision-range>`:: | |
| 74 | + | Backfill only blobs reachable from commits in the specified | |
| 75 | + | revision range. When no _<revision-range>_ is specified, it | |
| 76 | + | defaults to `HEAD` (i.e. the whole history leading to the | |
| 77 | + | current commit). For a complete list of ways to spell | |
| 78 | + | _<revision-range>_, see the "Specifying Ranges" section of | |
| 79 | + | linkgit:gitrevisions[7]. | |
| 80 | + | + | |
| 81 | + | You may also use commit-limiting options understood by | |
| 82 | + | linkgit:git-rev-list[1] such as `--first-parent`, `--since`, or pathspecs. | |
| 83 | + | + | |
| 84 | + | Most `--filter=<spec>` options don't work with the purpose of | |
| 85 | + | `git backfill`, but the `sparse:<oid>` filter is integrated to provide a | |
| 86 | + | focused set of paths to download, distinct from the `--sparse` option. | |
| 67 | 87 | ||
| 68 | 88 | SEE ALSO | |
| 69 | 89 | -------- | |
modified Documentation/git-bisect.adoc
| @@ -8,20 +8,20 @@ git-bisect - Use binary search to find the commit that introduced a bug | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git bisect' start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>] | |
| 13 | - | [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...] | |
| 14 | - | 'git bisect' (bad|new|<term-new>) [<rev>] | |
| 15 | - | 'git bisect' (good|old|<term-old>) [<rev>...] | |
| 16 | - | 'git bisect' terms [--term-(good|old) | --term-(bad|new)] | |
| 17 | - | 'git bisect' skip [(<rev>|<range>)...] | |
| 18 | - | 'git bisect' next | |
| 19 | - | 'git bisect' reset [<commit>] | |
| 20 | - | 'git bisect' (visualize|view) | |
| 21 | - | 'git bisect' replay <logfile> | |
| 22 | - | 'git bisect' log | |
| 23 | - | 'git bisect' run <cmd> [<arg>...] | |
| 24 | - | 'git bisect' help | |
| 11 | + | [synopsis] | |
| 12 | + | git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>] | |
| 13 | + | [--no-checkout] [--first-parent] [--reset-when-found[=<where>]] [<bad> [<good>...]] [--] [<pathspec>...] | |
| 14 | + | git bisect (bad|new|<term-new>) [<rev>] | |
| 15 | + | git bisect (good|old|<term-old>) [<rev>...] | |
| 16 | + | git bisect terms [--term-(good|old) | --term-(bad|new)] | |
| 17 | + | git bisect skip [(<rev>|<range>)...] | |
| 18 | + | git bisect next | |
| 19 | + | git bisect reset [<commit>] | |
| 20 | + | git bisect (visualize|view) | |
| 21 | + | git bisect replay <logfile> | |
| 22 | + | git bisect log | |
| 23 | + | git bisect run [--reset-when-found[=<where>]] <cmd> [<arg>...] | |
| 24 | + | git bisect help | |
| 25 | 25 | ||
| 26 | 26 | DESCRIPTION | |
| 27 | 27 | ----------- | |
| @@ -94,11 +94,10 @@ Bisect reset | |||
| 94 | 94 | ~~~~~~~~~~~~ | |
| 95 | 95 | ||
| 96 | 96 | After a bisect session, to clean up the bisection state and return to | |
| 97 | - | the original HEAD, issue the following command: | |
| 97 | + | the original `HEAD`, issue the following command: | |
| 98 | 98 | ||
| 99 | - | ------------------------------------------------ | |
| 100 | - | $ git bisect reset | |
| 101 | - | ------------------------------------------------ | |
| 99 | + | [synopsis] | |
| 100 | + | git bisect reset | |
| 102 | 101 | ||
| 103 | 102 | By default, this will return your tree to the commit that was checked | |
| 104 | 103 | out before `git bisect start`. (A new `git bisect start` will also do | |
| @@ -107,9 +106,9 @@ that, as it cleans up the old bisection state.) | |||
| 107 | 106 | With an optional argument, you can return to a different commit | |
| 108 | 107 | instead: | |
| 109 | 108 | ||
| 110 | - | ------------------------------------------------ | |
| 111 | - | $ git bisect reset <commit> | |
| 112 | - | ------------------------------------------------ | |
| 109 | + | [synopsis] | |
| 110 | + | git bisect reset <commit> | |
| 111 | + | ||
| 113 | 112 | ||
| 114 | 113 | For example, `git bisect reset bisect/bad` will check out the first | |
| 115 | 114 | bad revision, while `git bisect reset HEAD` will leave you on the | |
| @@ -143,23 +142,20 @@ To use "old" and "new" instead of "good" and bad, you must run `git | |||
| 143 | 142 | bisect start` without commits as argument and then run the following | |
| 144 | 143 | commands to add the commits: | |
| 145 | 144 | ||
| 146 | - | ------------------------------------------------ | |
| 145 | + | [synopsis] | |
| 147 | 146 | git bisect old [<rev>] | |
| 148 | - | ------------------------------------------------ | |
| 149 | 147 | ||
| 150 | 148 | to indicate that a commit was before the sought change, or | |
| 151 | 149 | ||
| 152 | - | ------------------------------------------------ | |
| 150 | + | [synopsis] | |
| 153 | 151 | git bisect new [<rev>...] | |
| 154 | - | ------------------------------------------------ | |
| 155 | 152 | ||
| 156 | 153 | to indicate that it was after. | |
| 157 | 154 | ||
| 158 | 155 | To get a reminder of the currently used terms, use | |
| 159 | 156 | ||
| 160 | - | ------------------------------------------------ | |
| 157 | + | [synopsis] | |
| 161 | 158 | git bisect terms | |
| 162 | - | ------------------------------------------------ | |
| 163 | 159 | ||
| 164 | 160 | You can get just the old term with `git bisect terms --term-old` | |
| 165 | 161 | or `git bisect terms --term-good`; `git bisect terms --term-new` | |
| @@ -171,21 +167,20 @@ If you would like to use your own terms instead of "bad"/"good" or | |||
| 171 | 167 | subcommands like `reset`, `start`, ...) by starting the | |
| 172 | 168 | bisection using | |
| 173 | 169 | ||
| 174 | - | ------------------------------------------------ | |
| 170 | + | [synopsis] | |
| 175 | 171 | git bisect start --term-old <term-old> --term-new <term-new> | |
| 176 | - | ------------------------------------------------ | |
| 177 | 172 | ||
| 178 | 173 | For example, if you are looking for a commit that introduced a | |
| 179 | 174 | performance regression, you might use | |
| 180 | 175 | ||
| 181 | 176 | ------------------------------------------------ | |
| 182 | - | git bisect start --term-old fast --term-new slow | |
| 177 | + | $ git bisect start --term-old fast --term-new slow | |
| 183 | 178 | ------------------------------------------------ | |
| 184 | 179 | ||
| 185 | 180 | Or if you are looking for the commit that fixed a bug, you might use | |
| 186 | 181 | ||
| 187 | 182 | ------------------------------------------------ | |
| 188 | - | git bisect start --term-new fixed --term-old broken | |
| 183 | + | $ git bisect start --term-new fixed --term-old broken | |
| 189 | 184 | ------------------------------------------------ | |
| 190 | 185 | ||
| 191 | 186 | Then, use `git bisect <term-old>` and `git bisect <term-new>` instead | |
| @@ -194,7 +189,7 @@ of `git bisect good` and `git bisect bad` to mark commits. | |||
| 194 | 189 | Bisect visualize/view | |
| 195 | 190 | ~~~~~~~~~~~~~~~~~~~~~ | |
| 196 | 191 | ||
| 197 | - | To see the currently remaining suspects in 'gitk', issue the following | |
| 192 | + | To see the currently remaining suspects in `gitk`, issue the following | |
| 198 | 193 | command during the bisection process (the subcommand `view` can be used | |
| 199 | 194 | as an alternative to `visualize`): | |
| 200 | 195 | ||
| @@ -203,12 +198,13 @@ $ git bisect visualize | |||
| 203 | 198 | ------------ | |
| 204 | 199 | ||
| 205 | 200 | Git detects a graphical environment through various environment variables: | |
| 206 | - | `DISPLAY`, which is set in X Window System environments on Unix systems. | |
| 207 | - | `SESSIONNAME`, which is set under Cygwin in interactive desktop sessions. | |
| 208 | - | `MSYSTEM`, which is set under Msys2 and Git for Windows. | |
| 209 | - | `SECURITYSESSIONID`, which may be set on macOS in interactive desktop sessions. | |
| 210 | 201 | ||
| 211 | - | If none of these environment variables is set, 'git log' is used instead. | |
| 202 | + | `DISPLAY`:: which is set in X Window System environments on Unix systems. | |
| 203 | + | `SESSIONNAME`:: which is set under Cygwin in interactive desktop sessions. | |
| 204 | + | `MSYSTEM`:: which is set under Msys2 and Git for Windows. | |
| 205 | + | `SECURITYSESSIONID`:: which may be set on macOS in interactive desktop sessions. | |
| 206 | + | ||
| 207 | + | If none of these environment variables is set, `git log` is used instead. | |
| 212 | 208 | You can also give command-line options such as `-p` and `--stat`. | |
| 213 | 209 | ||
| 214 | 210 | ------------ | |
| @@ -332,18 +328,17 @@ Bisect run | |||
| 332 | 328 | If you have a script that can tell if the current source code is good | |
| 333 | 329 | or bad, you can bisect by issuing the command: | |
| 334 | 330 | ||
| 335 | - | ------------ | |
| 336 | - | $ git bisect run my_script arguments | |
| 337 | - | ------------ | |
| 331 | + | [synopsis] | |
| 332 | + | git bisect run <cmd> [<arg>...] | |
| 338 | 333 | ||
| 339 | - | Note that the script (`my_script` in the above example) should exit | |
| 334 | + | Note that _<cmd>_ run with _<arg>_ should exit | |
| 340 | 335 | with code 0 if the current source code is good/old, and exit with a | |
| 341 | 336 | code between 1 and 127 (inclusive), except 125, if the current source | |
| 342 | 337 | code is bad/new. | |
| 343 | 338 | ||
| 344 | 339 | Any other exit code will abort the bisect process. It should be noted | |
| 345 | - | that a program that terminates via `exit(-1)` leaves $? = 255, (see the | |
| 346 | - | exit(3) manual page), as the value is chopped with `& 0377`. | |
| 340 | + | that a program that terminates via `exit(-1)` leaves `$?` = 255, (see the | |
| 341 | + | `exit`(3) manual page), as the value is chopped with `& 0377`. | |
| 347 | 342 | ||
| 348 | 343 | The special exit code 125 should be used when the current source code | |
| 349 | 344 | cannot be tested. If the script exits with this code, the current | |
| @@ -355,12 +350,12 @@ details do not matter, as they are normal errors in the script, as far as | |||
| 355 | 350 | `bisect run` is concerned). | |
| 356 | 351 | ||
| 357 | 352 | You may often find that during a bisect session you want to have | |
| 358 | - | temporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a | |
| 353 | + | temporary modifications (e.g. `s/#define DEBUG 0/#define DEBUG 1/` in a | |
| 359 | 354 | header file, or "revision that does not have this commit needs this | |
| 360 | 355 | patch applied to work around another problem this bisection is not | |
| 361 | 356 | interested in") applied to the revision being tested. | |
| 362 | 357 | ||
| 363 | - | To cope with such a situation, after the inner 'git bisect' finds the | |
| 358 | + | To cope with such a situation, after the inner `git bisect` finds the | |
| 364 | 359 | next revision to test, the script can apply the patch | |
| 365 | 360 | before compiling, run the real test, and afterwards decide if the | |
| 366 | 361 | revision (possibly with the needed patch) passed the test and then | |
| @@ -370,20 +365,18 @@ determine the eventual outcome of the bisect session. | |||
| 370 | 365 | ||
| 371 | 366 | OPTIONS | |
| 372 | 367 | ------- | |
| 373 | - | --no-checkout:: | |
| 374 | - | + | |
| 375 | - | Do not checkout the new working tree at each iteration of the bisection | |
| 376 | - | process. Instead just update the reference named `BISECT_HEAD` to make | |
| 377 | - | it point to the commit that should be tested. | |
| 368 | + | `--no-checkout`:: | |
| 369 | + | Do not checkout the new working tree at each iteration of the bisection | |
| 370 | + | process. Instead just update the reference named `BISECT_HEAD` to make | |
| 371 | + | it point to the commit that should be tested. | |
| 378 | 372 | + | |
| 379 | 373 | This option may be useful when the test you would perform in each step | |
| 380 | 374 | does not require a checked out tree. | |
| 381 | 375 | + | |
| 382 | 376 | If the repository is bare, `--no-checkout` is assumed. | |
| 383 | 377 | ||
| 384 | - | --first-parent:: | |
| 385 | - | + | |
| 386 | - | Follow only the first parent commit upon seeing a merge commit. | |
| 378 | + | `--first-parent`:: | |
| 379 | + | Follow only the first parent commit upon seeing a merge commit. | |
| 387 | 380 | + | |
| 388 | 381 | In detecting regressions introduced through the merging of a branch, the merge | |
| 389 | 382 | commit will be identified as introduction of the bug and its ancestors will be | |
| @@ -392,10 +385,20 @@ ignored. | |||
| 392 | 385 | This option is particularly useful in avoiding false positives when a merged | |
| 393 | 386 | branch contained broken or non-buildable commits, but the merge itself was OK. | |
| 394 | 387 | ||
| 388 | + | `--reset-when-found[=<where>]`:: | |
| 389 | + | Once the first bad commit is found, report it and clean up the | |
| 390 | + | bisection state. `<where>` may be `original` to return to the commit | |
| 391 | + | checked out before `git bisect start`, or `found` to leave the first | |
| 392 | + | bad commit checked out. If `<where>` is omitted, it defaults to | |
| 393 | + | `original`. | |
| 394 | + | + | |
| 395 | + | This option may be given to `git bisect start` or to `git bisect run`. It | |
| 396 | + | cannot be used for a bisection started with `--no-checkout`. | |
| 397 | + | ||
| 395 | 398 | EXAMPLES | |
| 396 | 399 | -------- | |
| 397 | 400 | ||
| 398 | - | * Automatically bisect a broken build between v1.2 and HEAD: | |
| 401 | + | * Automatically bisect a broken build between v1.2 and `HEAD`: | |
| 399 | 402 | + | |
| 400 | 403 | ------------ | |
| 401 | 404 | $ git bisect start HEAD v1.2 -- # HEAD is bad, v1.2 is good | |
| @@ -403,7 +406,7 @@ $ git bisect run make # "make" builds the app | |||
| 403 | 406 | $ git bisect reset # quit the bisect session | |
| 404 | 407 | ------------ | |
| 405 | 408 | ||
| 406 | - | * Automatically bisect a test failure between origin and HEAD: | |
| 409 | + | * Automatically bisect a test failure between origin and `HEAD`: | |
| 407 | 410 | + | |
| 408 | 411 | ------------ | |
| 409 | 412 | $ git bisect start HEAD origin -- # HEAD is bad, origin is good | |
| @@ -430,7 +433,7 @@ and `exit 1` otherwise. | |||
| 430 | 433 | + | |
| 431 | 434 | It is safer if both `test.sh` and `check_test_case.sh` are | |
| 432 | 435 | outside the repository to prevent interactions between the bisect, | |
| 433 | - | make and test processes and the scripts. | |
| 436 | + | `make` and test processes and the scripts. | |
| 434 | 437 | ||
| 435 | 438 | * Automatically bisect with temporary modifications (hot-fix): | |
| 436 | 439 | + | |
| @@ -491,9 +494,9 @@ $ git bisect run sh -c ' | |||
| 491 | 494 | $ git bisect reset # quit the bisect session | |
| 492 | 495 | ------------ | |
| 493 | 496 | + | |
| 494 | - | In this case, when 'git bisect run' finishes, bisect/bad will refer to a commit that | |
| 497 | + | In this case, when `git bisect run` finishes, `bisect/bad` will refer to a commit that | |
| 495 | 498 | has at least one parent whose reachable graph is fully traversable in the sense | |
| 496 | - | required by 'git pack objects'. | |
| 499 | + | required by `git pack-objects`. | |
| 497 | 500 | ||
| 498 | 501 | * Look for a fix instead of a regression in the code | |
| 499 | 502 | + | |
modified Documentation/git-blame.adoc
| @@ -88,11 +88,12 @@ include::blame-options.adoc[] | |||
| 88 | 88 | include::diff-algorithm-option.adoc[] | |
| 89 | 89 | ||
| 90 | 90 | `--abbrev=<n>`:: | |
| 91 | - | Instead of using the default _7+1_ hexadecimal digits as the | |
| 92 | - | abbreviated object name, use _<m>+1_ digits, where _<m>_ is at | |
| 93 | - | least _<n>_ but ensures the commit object names are unique. | |
| 94 | - | Note that 1 column | |
| 95 | - | is used for a caret to mark the boundary commit. | |
| 91 | + | Instead of using the default _7_ hexadecimal digits as the | |
| 92 | + | abbreviated object name, use at least _<n>_ digits, but ensure | |
| 93 | + | the commit object names are unique. | |
| 94 | + | If commits marked with caret (boundary), question mark (ignored) | |
| 95 | + | or asterisk (unblamable) are shown, extend unmarked object names | |
| 96 | + | to align them. | |
| 96 | 97 | ||
| 97 | 98 | ||
| 98 | 99 | THE DEFAULT FORMAT | |
modified Documentation/git-branch.adoc
| @@ -13,6 +13,7 @@ git branch [--color[=<when>] | --no-color] [--show-current] | |||
| 13 | 13 | [--column[=<options>] | --no-column] [--sort=<key>] | |
| 14 | 14 | [--merged [<commit>]] [--no-merged [<commit>]] | |
| 15 | 15 | [--contains [<commit>]] [--no-contains [<commit>]] | |
| 16 | + | [(--forked <branch>)...] | |
| 16 | 17 | [--points-at <object>] [--format=<format>] | |
| 17 | 18 | [(-r|--remotes) | (-a|--all)] | |
| 18 | 19 | [--list] [<pattern>...] | |
| @@ -24,6 +25,7 @@ git branch (-m|-M) [<old-branch>] <new-branch> | |||
| 24 | 25 | git branch (-c|-C) [<old-branch>] <new-branch> | |
| 25 | 26 | git branch (-d|-D) [-r] <branch-name>... | |
| 26 | 27 | git branch --edit-description [<branch-name>] | |
| 28 | + | git branch [--dry-run] (--delete-merged <pattern>)... [<branch-pattern>...] | |
| 27 | 29 | ||
| 28 | 30 | DESCRIPTION | |
| 29 | 31 | ----------- | |
| @@ -51,7 +53,8 @@ merged into the named commit (i.e. the branches whose tip commits are | |||
| 51 | 53 | reachable from the named commit) will be listed. With `--no-merged` only | |
| 52 | 54 | branches not merged into the named commit will be listed. If the _<commit>_ | |
| 53 | 55 | argument is missing it defaults to `HEAD` (i.e. the tip of the current | |
| 54 | - | branch). | |
| 56 | + | branch). With `--forked`, only branches whose configured upstream matches | |
| 57 | + | the given branch or pattern will be listed. | |
| 55 | 58 | ||
| 56 | 59 | The command's second form creates a new branch head named _<branch-name>_ | |
| 57 | 60 | which points to the current `HEAD`, or _<start-point>_ if given. As a | |
| @@ -199,6 +202,45 @@ This option is only applicable in non-verbose mode. | |||
| 199 | 202 | Print the name of the current branch. In detached `HEAD` state, | |
| 200 | 203 | nothing is printed. | |
| 201 | 204 | ||
| 205 | + | `--delete-merged <pattern>`:: | |
| 206 | + | Delete local branches whose configured upstream matches | |
| 207 | + | _<pattern>_, but only when their tip is reachable from that | |
| 208 | + | upstream. In other words, the work on the branch has already | |
| 209 | + | landed on the upstream it tracks, so the local copy is no longer | |
| 210 | + | needed. _<pattern>_ may name a ref, a remote (using the branch its | |
| 211 | + | `HEAD` points at), or a shell-style glob. The option can be | |
| 212 | + | repeated to widen the upstream match. | |
| 213 | + | Optional _<branch-pattern>_ arguments limit which local branches | |
| 214 | + | are considered, e.g. `git branch --delete-merged 'origin/*' | |
| 215 | + | 'topic-*'`. | |
| 216 | + | + | |
| 217 | + | A branch is not deleted when: | |
| 218 | + | + | |
| 219 | + | -- | |
| 220 | + | * its configured upstream ref no longer exists, | |
| 221 | + | * it is checked out in any worktree, | |
| 222 | + | * pushing it to the remote configured by | |
| 223 | + | `branch.<name>.remote` would update its upstream, so it cannot be | |
| 224 | + | distinguished from a branch that just looks fully merged right | |
| 225 | + | after a pull; this is determined by the remote's configured push and | |
| 226 | + | fetch refspecs, | |
| 227 | + | * it is the local upstream of a branch that is not being deleted, or | |
| 228 | + | * `branch.<name>.deleteMerged` is set to `false`. | |
| 229 | + | -- | |
| 230 | + | + | |
| 231 | + | When such a local upstream branch has its own upstream deleted by the | |
| 232 | + | same operation, its upstream configuration is cleared. | |
| 233 | + | + | |
| 234 | + | A branch whose work has not yet been merged into its upstream is | |
| 235 | + | silently skipped. Delete it with `git branch -D` if you want to | |
| 236 | + | remove it anyway. | |
| 237 | + | ||
| 238 | + | `--dry-run`:: | |
| 239 | + | With `--delete-merged`, print which branches would be | |
| 240 | + | deleted and exit without touching any ref. Useful for | |
| 241 | + | sanity-checking a wide pattern like `'origin/*'` before | |
| 242 | + | committing to the deletion. | |
| 243 | + | ||
| 202 | 244 | `-v`:: | |
| 203 | 245 | `-vv`:: | |
| 204 | 246 | `--verbose`:: | |
| @@ -311,6 +353,14 @@ superproject's "origin/main", but tracks the submodule's "origin/main". | |||
| 311 | 353 | Only list branches whose tips are not reachable from | |
| 312 | 354 | _<commit>_ (`HEAD` if not specified). Implies `--list`. | |
| 313 | 355 | ||
| 356 | + | `--forked <branch>`:: | |
| 357 | + | Only list branches whose configured upstream matches | |
| 358 | + | _<branch>_. The argument can be a ref (e.g. `origin/main`, | |
| 359 | + | `master`), a remote name like `origin` for the branch its | |
| 360 | + | `origin/HEAD` points at, or a shell-style glob (e.g. | |
| 361 | + | `'origin/*'`). The option can be repeated to widen the | |
| 362 | + | filter. Implies `--list`. | |
| 363 | + | ||
| 314 | 364 | `--points-at <object>`:: | |
| 315 | 365 | Only list branches of _<object>_. | |
| 316 | 366 | ||
modified Documentation/git-cat-file.adoc
| @@ -169,11 +169,23 @@ info <object>:: | |||
| 169 | 169 | Print object info for object reference `<object>`. This corresponds to the | |
| 170 | 170 | output of `--batch-check`. | |
| 171 | 171 | ||
| 172 | + | remote-object-info <remote> <object>...:: | |
| 173 | + | Print object info for object references `<object>` at specified | |
| 174 | + | `<remote>` without downloading objects from the remote. | |
| 175 | + | Raise an error when the `object-info` capability is not supported by the remote. | |
| 176 | + | Raise an error when no object references are provided. | |
| 177 | + | This command may be combined with `--buffer`. | |
| 178 | + | ||
| 172 | 179 | flush:: | |
| 173 | 180 | Used with `--buffer` to execute all preceding commands that were issued | |
| 174 | 181 | since the beginning or since the last flush was issued. When `--buffer` | |
| 175 | 182 | is used, no output will come until a `flush` is issued. When `--buffer` | |
| 176 | 183 | is not used, commands are flushed each time without issuing `flush`. | |
| 184 | + | ||
| 185 | + | `mailmap (<bool>)`:: | |
| 186 | + | Enable or disable mailmap for subsequent commands. The `<bool>` | |
| 187 | + | argument accepts the same boolean values as linkgit:git-config[1]. | |
| 188 | + | The mailmap data is read upon the first use and only once. | |
| 177 | 189 | -- | |
| 178 | 190 | + | |
| 179 | 191 | ||
| @@ -296,7 +308,8 @@ one per line, and print information based on the command given. With | |||
| 296 | 308 | `--batch-command`, the `info` command followed by an object will print | |
| 297 | 309 | information about the object the same way `--batch-check` would, and the | |
| 298 | 310 | `contents` command followed by an object prints contents in the same way | |
| 299 | - | `--batch` would. | |
| 311 | + | `--batch` would. The `remote-object-info` command followed by a remote and | |
| 312 | + | object IDs prints object info from the remote without downloading the objects. | |
| 300 | 313 | ||
| 301 | 314 | You can specify the information shown for each object by using a custom | |
| 302 | 315 | `<format>`. The `<format>` is copied literally to stdout for each | |
| @@ -335,6 +348,10 @@ newline. The available atoms are: | |||
| 335 | 348 | after that first run of whitespace (i.e., the "rest" of the | |
| 336 | 349 | line) are output in place of the `%(rest)` atom. | |
| 337 | 350 | ||
| 351 | + | The command `remote-object-info` only supports the `%(objectname)`, | |
| 352 | + | `%(objectsize)` and `%(objecttype)` placeholders. See `CAVEATS` below for more | |
| 353 | + | information. | |
| 354 | + | ||
| 338 | 355 | If no format is specified, the default format is `%(objectname) | |
| 339 | 356 | %(objecttype) %(objectsize)`. | |
| 340 | 357 | ||
| @@ -433,6 +450,10 @@ scripting purposes. | |||
| 433 | 450 | CAVEATS | |
| 434 | 451 | ------- | |
| 435 | 452 | ||
| 453 | + | Note that only `%(objectname)`, `%(objectsize)` and `%(objecttype)` are | |
| 454 | + | currently supported by the `remote-object-info` command. Using any other | |
| 455 | + | placeholder in the format string will return an empty string in its position. | |
| 456 | + | ||
| 436 | 457 | Note that the sizes of objects on disk are reported accurately, but care | |
| 437 | 458 | should be taken in drawing conclusions about which refs or objects are | |
| 438 | 459 | responsible for disk usage. The size of a packed non-delta object may be | |
modified Documentation/git-checkout.adoc
| @@ -251,20 +251,19 @@ working tree, by copying them from elsewhere, extracting a tarball, etc. | |||
| 251 | 251 | are different between the current branch and the branch to | |
| 252 | 252 | which you are switching, the command refuses to switch | |
| 253 | 253 | branches in order to preserve your modifications in context. | |
| 254 | - | However, with this option, a three-way merge between the current | |
| 255 | - | branch, your working tree contents, and the new branch | |
| 256 | - | is done, and you will be on the new branch. | |
| 257 | - | + | |
| 258 | - | When a merge conflict happens, the index entries for conflicting | |
| 259 | - | paths are left unmerged, and you need to resolve the conflicts | |
| 260 | - | and mark the resolved paths with `git add` (or `git rm` if the merge | |
| 261 | - | should result in deletion of the path). | |
| 254 | + | With this option, the conflicting local changes are | |
| 255 | + | automatically stashed before the switch and reapplied | |
| 256 | + | afterwards. If the local changes do not overlap with the | |
| 257 | + | differences between branches, the switch proceeds without | |
| 258 | + | stashing. If reapplying the stash results in conflicts, the | |
| 259 | + | entry is saved to the stash list. Resolve the conflicts | |
| 260 | + | and run `git stash drop` when done, or clear the working | |
| 261 | + | tree (e.g. with `git reset --hard`) before running `git stash | |
| 262 | + | pop` later to re-apply your changes. | |
| 262 | 263 | + | |
| 263 | 264 | When checking out paths from the index, this option lets you recreate | |
| 264 | 265 | the conflicted merge in the specified paths. This option cannot be | |
| 265 | 266 | used when checking out paths from a tree-ish. | |
| 266 | - | + | |
| 267 | - | When switching branches with `--merge`, staged changes may be lost. | |
| 268 | 267 | ||
| 269 | 268 | `--conflict=<style>`:: | |
| 270 | 269 | The same as `--merge` option above, but changes the way the | |
| @@ -578,38 +577,36 @@ $ git checkout mytopic | |||
| 578 | 577 | error: You have local changes to 'frotz'; not switching branches. | |
| 579 | 578 | ------------ | |
| 580 | 579 | ||
| 581 | - | You can give the `-m` flag to the command, which would try a | |
| 582 | - | three-way merge: | |
| 580 | + | You can give the `-m` flag to the command, which will carry your local | |
| 581 | + | changes to the new branch: | |
| 583 | 582 | ||
| 584 | 583 | ------------ | |
| 585 | 584 | $ git checkout -m mytopic | |
| 586 | - | Auto-merging frotz | |
| 585 | + | Applied autostash. | |
| 586 | + | Switched to branch 'mytopic' | |
| 587 | + | The following paths have local changes: | |
| 588 | + | M frotz | |
| 587 | 589 | ------------ | |
| 588 | 590 | ||
| 589 | - | After this three-way merge, the local modifications are _not_ | |
| 591 | + | After the switch, the local modifications are reapplied and are _not_ | |
| 590 | 592 | registered in your index file, so `git diff` would show you what | |
| 591 | 593 | changes you made since the tip of the new branch. | |
| 592 | 594 | ||
| 593 | 595 | === 3. Merge conflict | |
| 594 | 596 | ||
| 595 | - | When a merge conflict happens during switching branches with | |
| 596 | - | the `-m` option, you would see something like this: | |
| 597 | + | When the `--merge` (`-m`) option is given and the local changes | |
| 598 | + | overlap with the changes in the branch we're switching to, the | |
| 599 | + | changes are stashed and reapplied after the switch. If this | |
| 600 | + | process results in conflicts, the stash entry is saved and a | |
| 601 | + | message is printed: | |
| 597 | 602 | ||
| 598 | 603 | ------------ | |
| 599 | 604 | $ git checkout -m mytopic | |
| 600 | - | Auto-merging frotz | |
| 601 | - | ERROR: Merge conflict in frotz | |
| 602 | - | fatal: merge program failed | |
| 603 | - | ------------ | |
| 604 | - | ||
| 605 | - | At this point, `git diff` shows the changes cleanly merged as in | |
| 606 | - | the previous example, as well as the changes in the conflicted | |
| 607 | - | files. Edit and resolve the conflict and mark it resolved with | |
| 608 | - | `git add` as usual: | |
| 609 | - | ||
| 610 | - | ------------ | |
| 611 | - | $ edit frotz | |
| 612 | - | $ git add frotz | |
| 605 | + | Your local changes are stashed, however applying them | |
| 606 | + | resulted in conflicts. You can either resolve the conflicts | |
| 607 | + | and then discard the stash with "git stash drop", or, if you | |
| 608 | + | do not want to resolve them now, run "git reset --hard" and | |
| 609 | + | apply the local changes later by running "git stash pop". | |
| 613 | 610 | ------------ | |
| 614 | 611 | ||
| 615 | 612 | CONFIGURATION | |
modified Documentation/git-cherry-pick.adoc
| @@ -25,7 +25,8 @@ happens: | |||
| 25 | 25 | 1. The current branch and `HEAD` pointer stay at the last commit | |
| 26 | 26 | successfully made. | |
| 27 | 27 | 2. The `CHERRY_PICK_HEAD` ref is set to point at the commit that | |
| 28 | - | introduced the change that is difficult to apply. | |
| 28 | + | introduced the change that is difficult to apply, unless the | |
| 29 | + | `--no-commit` option was given. | |
| 29 | 30 | 3. Paths in which the change applied cleanly are updated both | |
| 30 | 31 | in the index file and in your working tree. | |
| 31 | 32 | 4. For conflicting paths, the index file records up to three | |
| @@ -101,6 +102,11 @@ OPTIONS | |||
| 101 | 102 | + | |
| 102 | 103 | This is useful when cherry-picking more than one commits' | |
| 103 | 104 | effect to your index in a row. | |
| 105 | + | + | |
| 106 | + | This option does not record `CHERRY_PICK_HEAD`, so a plain `git commit` | |
| 107 | + | afterwards records you as the author. That is by design: what you are | |
| 108 | + | building is your own work, which you keep changing before committing, | |
| 109 | + | rather than a reproduction of the original commit. | |
| 104 | 110 | ||
| 105 | 111 | -s:: | |
| 106 | 112 | --signoff:: | |
modified Documentation/git-commit-graph.adoc
| @@ -146,6 +146,12 @@ $ git show-ref -s | git commit-graph write --stdin-commits | |||
| 146 | 146 | $ git rev-parse HEAD | git commit-graph write --stdin-commits --append | |
| 147 | 147 | ------------------------------------------------ | |
| 148 | 148 | ||
| 149 | + | CAVEATS | |
| 150 | + | ------- | |
| 151 | + | ||
| 152 | + | The existence of replace objects or commit grafts turns off reading or | |
| 153 | + | writing to the commit-graph. See linkgit:git-replace[1]. | |
| 154 | + | ||
| 149 | 155 | CONFIGURATION | |
| 150 | 156 | ------------- | |
| 151 | 157 | ||
modified Documentation/git-config.adoc
| @@ -119,10 +119,10 @@ OPTIONS | |||
| 119 | 119 | Append a comment at the end of new or modified lines. | |
| 120 | 120 | + | |
| 121 | 121 | If _<message>_ begins with one or more whitespaces followed | |
| 122 | - | by "#", it is used as-is. If it begins with "#", a space is | |
| 123 | - | prepended before it is used. Otherwise, a string " # " (a | |
| 122 | + | by `#`, it is used as-is. If it begins with `#`, a space is | |
| 123 | + | prepended before it is used. Otherwise, a string `" # "` (a | |
| 124 | 124 | space followed by a hash followed by a space) is prepended | |
| 125 | - | to it. And the resulting string is placed immediately after | |
| 125 | + | to it. The resulting string is placed immediately after | |
| 126 | 126 | the value defined for the variable. The _<message>_ must | |
| 127 | 127 | not contain linefeed characters (no multi-line comments are | |
| 128 | 128 | permitted). | |
| @@ -221,6 +221,7 @@ Use `--no-value` to unset _<pattern>_. | |||
| 221 | 221 | + | |
| 222 | 222 | Valid `<type>`'s include: | |
| 223 | 223 | + | |
| 224 | + | -- | |
| 224 | 225 | - 'bool': canonicalize values `true`, `yes`, `on`, and positive | |
| 225 | 226 | numbers as "true", and values `false`, `no`, `off` and `0` as | |
| 226 | 227 | "false". | |
| @@ -239,6 +240,7 @@ Valid `<type>`'s include: | |||
| 239 | 240 | escape sequence. When setting a value, a sanity-check is performed to ensure | |
| 240 | 241 | that the given value is canonicalize-able as an ANSI color, but it is written | |
| 241 | 242 | as-is. | |
| 243 | + | -- | |
| 242 | 244 | + | |
| 243 | 245 | If the command is in `list` mode, then the `--type <type>` argument will apply | |
| 244 | 246 | to each listed config value. If the value does not successfully parse in that | |
modified Documentation/git-describe.adoc
| @@ -7,10 +7,10 @@ git-describe - Give an object a human readable name based on an available ref | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...] | |
| 12 | - | 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>] | |
| 13 | - | 'git describe' <blob> | |
| 10 | + | [synopsis] | |
| 11 | + | git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...] | |
| 12 | + | git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>] | |
| 13 | + | git describe <blob> | |
| 14 | 14 | ||
| 15 | 15 | DESCRIPTION | |
| 16 | 16 | ----------- | |
| @@ -22,70 +22,70 @@ abbreviated object name of the most recent commit. The result | |||
| 22 | 22 | is a "human-readable" object name which can also be used to | |
| 23 | 23 | identify the commit to other git commands. | |
| 24 | 24 | ||
| 25 | - | By default (without --all or --tags) `git describe` only shows | |
| 25 | + | By default (without `--all` or `--tags`) `git describe` only shows | |
| 26 | 26 | annotated tags. For more information about creating annotated tags | |
| 27 | - | see the -a and -s options to linkgit:git-tag[1]. | |
| 27 | + | see the `-a` and `-s` options to linkgit:git-tag[1]. | |
| 28 | 28 | ||
| 29 | 29 | If the given object refers to a blob, it will be described | |
| 30 | 30 | as `<commit-ish>:<path>`, such that the blob can be found | |
| 31 | - | at `<path>` in the `<commit-ish>`, which itself describes the | |
| 31 | + | at _<path>_ in the _<commit-ish>_, which itself describes the | |
| 32 | 32 | first commit in which this blob occurs in a reverse revision walk | |
| 33 | - | from HEAD. | |
| 33 | + | from `HEAD`. | |
| 34 | 34 | ||
| 35 | 35 | OPTIONS | |
| 36 | 36 | ------- | |
| 37 | - | <commit-ish>...:: | |
| 38 | - | Commit-ish object names to describe. Defaults to HEAD if omitted. | |
| 37 | + | `<commit-ish>...`:: | |
| 38 | + | Commit-ish object names to describe. Defaults to `HEAD` if omitted. | |
| 39 | 39 | ||
| 40 | - | --dirty[=<mark>]:: | |
| 41 | - | --broken[=<mark>]:: | |
| 40 | + | `--dirty[=<mark>]`:: | |
| 41 | + | `--broken[=<mark>]`:: | |
| 42 | 42 | Describe the state of the working tree. When the working | |
| 43 | - | tree matches HEAD, the output is the same as "git describe | |
| 44 | - | HEAD". If the working tree has local modification "-dirty" | |
| 43 | + | tree matches `HEAD`, the output is the same as `git describe HEAD`. | |
| 44 | + | If the working tree has local modification, `-dirty` | |
| 45 | 45 | is appended to it. If a repository is corrupt and Git | |
| 46 | 46 | cannot determine if there is local modification, Git will | |
| 47 | - | error out, unless `--broken' is given, which appends | |
| 48 | - | the suffix "-broken" instead. | |
| 47 | + | error out, unless `--broken` is given, which appends | |
| 48 | + | the suffix `-broken` instead. | |
| 49 | 49 | ||
| 50 | - | --all:: | |
| 50 | + | `--all`:: | |
| 51 | 51 | Instead of using only the annotated tags, use any ref | |
| 52 | 52 | found in `refs/` namespace. This option enables matching | |
| 53 | 53 | any known branch, remote-tracking branch, or lightweight tag. | |
| 54 | 54 | ||
| 55 | - | --tags:: | |
| 55 | + | `--tags`:: | |
| 56 | 56 | Instead of using only the annotated tags, use any tag | |
| 57 | 57 | found in `refs/tags` namespace. This option enables matching | |
| 58 | 58 | a lightweight (non-annotated) tag. | |
| 59 | 59 | ||
| 60 | - | --contains:: | |
| 60 | + | `--contains`:: | |
| 61 | 61 | Instead of finding the tag that predates the commit, find | |
| 62 | 62 | the tag that comes after the commit, and thus contains it. | |
| 63 | - | Automatically implies --tags. | |
| 63 | + | Automatically implies `--tags`. | |
| 64 | 64 | ||
| 65 | - | --abbrev=<n>:: | |
| 65 | + | `--abbrev=<n>`:: | |
| 66 | 66 | Instead of using the default number of hexadecimal digits (which | |
| 67 | 67 | will vary according to the number of objects in the repository with | |
| 68 | - | a default of 7) of the abbreviated object name, use <n> digits, or | |
| 69 | - | as many digits as needed to form a unique object name. An <n> of 0 | |
| 68 | + | a default of 7) of the abbreviated object name, use _<n>_ digits, or | |
| 69 | + | as many digits as needed to form a unique object name. An _<n>_ of 0 | |
| 70 | 70 | will suppress long format, only showing the closest tag. | |
| 71 | 71 | ||
| 72 | - | --candidates=<n>:: | |
| 72 | + | `--candidates=<n>`:: | |
| 73 | 73 | Instead of considering only the 10 most recent tags as | |
| 74 | 74 | candidates to describe the input commit-ish consider | |
| 75 | - | up to <n> candidates. Increasing <n> above 10 will take | |
| 75 | + | up to _<n>_ candidates. Increasing _<n>_ above 10 will take | |
| 76 | 76 | slightly longer but may produce a more accurate result. | |
| 77 | - | An <n> of 0 will cause only exact matches to be output. | |
| 77 | + | An _<n>_ of 0 will cause only exact matches to be output. | |
| 78 | 78 | ||
| 79 | - | --exact-match:: | |
| 79 | + | `--exact-match`:: | |
| 80 | 80 | Only output exact matches (a tag directly references the | |
| 81 | - | supplied commit). This is a synonym for --candidates=0. | |
| 81 | + | supplied commit). This is a synonym for `--candidates=0`. | |
| 82 | 82 | ||
| 83 | - | --debug:: | |
| 83 | + | `--debug`:: | |
| 84 | 84 | Verbosely display information about the searching strategy | |
| 85 | 85 | being employed to standard error. The tag name will still | |
| 86 | 86 | be printed to standard out. | |
| 87 | 87 | ||
| 88 | - | --long:: | |
| 88 | + | `--long`:: | |
| 89 | 89 | Always output the long format (the tag, the number of commits | |
| 90 | 90 | and the abbreviated commit name) even when it matches a tag. | |
| 91 | 91 | This is useful when you want to see parts of the commit object name | |
| @@ -94,8 +94,8 @@ OPTIONS | |||
| 94 | 94 | describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2 | |
| 95 | 95 | that points at object deadbee....). | |
| 96 | 96 | ||
| 97 | - | --match <pattern>:: | |
| 98 | - | Only consider tags matching the given `glob(7)` pattern, | |
| 97 | + | `--match <pattern>`:: | |
| 98 | + | Only consider tags matching the given `glob`(7) pattern, | |
| 99 | 99 | excluding the "refs/tags/" prefix. If used with `--all`, it also | |
| 100 | 100 | considers local branches and remote-tracking references matching the | |
| 101 | 101 | pattern, excluding respectively "refs/heads/" and "refs/remotes/" | |
| @@ -104,22 +104,22 @@ OPTIONS | |||
| 104 | 104 | matching any of the patterns will be considered. Use `--no-match` to | |
| 105 | 105 | clear and reset the list of patterns. | |
| 106 | 106 | ||
| 107 | - | --exclude <pattern>:: | |
| 108 | - | Do not consider tags matching the given `glob(7)` pattern, excluding | |
| 107 | + | `--exclude <pattern>`:: | |
| 108 | + | Do not consider tags matching the given `glob`(7) pattern, excluding | |
| 109 | 109 | the "refs/tags/" prefix. If used with `--all`, it also does not consider | |
| 110 | 110 | local branches and remote-tracking references matching the pattern, | |
| 111 | - | excluding respectively "refs/heads/" and "refs/remotes/" prefix; | |
| 111 | + | excluding respectively "`refs/heads/`" and "`refs/remotes/`" prefix; | |
| 112 | 112 | references of other types are never considered. If given multiple times, | |
| 113 | 113 | a list of patterns will be accumulated and tags matching any of the | |
| 114 | - | patterns will be excluded. When combined with --match a tag will be | |
| 115 | - | considered when it matches at least one --match pattern and does not | |
| 116 | - | match any of the --exclude patterns. Use `--no-exclude` to clear and | |
| 114 | + | patterns will be excluded. When combined with `--match` a tag will be | |
| 115 | + | considered when it matches at least one `--match` pattern and does not | |
| 116 | + | match any of the `--exclude` patterns. Use `--no-exclude` to clear and | |
| 117 | 117 | reset the list of patterns. | |
| 118 | 118 | ||
| 119 | - | --always:: | |
| 119 | + | `--always`:: | |
| 120 | 120 | Show uniquely abbreviated commit object as fallback. | |
| 121 | 121 | ||
| 122 | - | --first-parent:: | |
| 122 | + | `--first-parent`:: | |
| 123 | 123 | Follow only the first parent commit upon seeing a merge commit. | |
| 124 | 124 | This is useful when you wish to not match tags on branches merged | |
| 125 | 125 | in the history of the target commit. | |
| @@ -139,8 +139,8 @@ an abbreviated object name for the commit itself ("2414721") | |||
| 139 | 139 | at the end. | |
| 140 | 140 | ||
| 141 | 141 | The number of additional commits is the number | |
| 142 | - | of commits which would be displayed by "git log v1.0.4..parent". | |
| 143 | - | The hash suffix is "-g" + an unambiguous abbreviation for the tip commit | |
| 142 | + | of commits which would be displayed by `git log v1.0.4..parent`. | |
| 143 | + | The hash suffix is "`-g`" + an unambiguous abbreviation for the tip commit | |
| 144 | 144 | of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). The | |
| 145 | 145 | length of the abbreviation scales as the repository grows, using the | |
| 146 | 146 | approximate number of objects in the repository and a bit of math | |
| @@ -149,12 +149,12 @@ The "g" prefix stands for "git" and is used to allow describing the version of | |||
| 149 | 149 | a software depending on the SCM the software is managed with. This is useful | |
| 150 | 150 | in an environment where people may use different SCMs. | |
| 151 | 151 | ||
| 152 | - | Doing a 'git describe' on a tag-name will just show the tag name: | |
| 152 | + | Doing a `git describe` on a tag-name will just show the tag name: | |
| 153 | 153 | ||
| 154 | 154 | [torvalds@g5 git]$ git describe v1.0.4 | |
| 155 | 155 | v1.0.4 | |
| 156 | 156 | ||
| 157 | - | With --all, the command can use branch heads as references, so | |
| 157 | + | With `--all`, the command can use branch heads as references, so | |
| 158 | 158 | the output shows the reference path as well: | |
| 159 | 159 | ||
| 160 | 160 | [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 | |
| @@ -163,7 +163,7 @@ the output shows the reference path as well: | |||
| 163 | 163 | [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^ | |
| 164 | 164 | heads/lt/describe-7-g975b | |
| 165 | 165 | ||
| 166 | - | With --abbrev set to 0, the command can be used to find the | |
| 166 | + | With `--abbrev` set to 0, the command can be used to find the | |
| 167 | 167 | closest tagname without any suffix: | |
| 168 | 168 | ||
| 169 | 169 | [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 | |
| @@ -179,13 +179,13 @@ be sufficient to disambiguate these commits. | |||
| 179 | 179 | SEARCH STRATEGY | |
| 180 | 180 | --------------- | |
| 181 | 181 | ||
| 182 | - | For each commit-ish supplied, 'git describe' will first look for | |
| 182 | + | For each commit-ish supplied, `git describe` will first look for | |
| 183 | 183 | a tag which tags exactly that commit. Annotated tags will always | |
| 184 | 184 | be preferred over lightweight tags, and tags with newer dates will | |
| 185 | 185 | always be preferred over tags with older dates. If an exact match | |
| 186 | 186 | is found, its name will be output and searching will stop. | |
| 187 | 187 | ||
| 188 | - | If an exact match was not found, 'git describe' will walk back | |
| 188 | + | If an exact match was not found, `git describe` will walk back | |
| 189 | 189 | through the commit history to locate an ancestor commit which | |
| 190 | 190 | has been tagged. The ancestor's tag will be output along with an | |
| 191 | 191 | abbreviation of the input commit-ish's SHA-1. If `--first-parent` was | |
| @@ -203,7 +203,7 @@ BUGS | |||
| 203 | 203 | ||
| 204 | 204 | Tree objects as well as tag objects not pointing at commits, cannot be described. | |
| 205 | 205 | When describing blobs, the lightweight tags pointing at blobs are ignored, | |
| 206 | - | but the blob is still described as <commit-ish>:<path> despite the lightweight | |
| 206 | + | but the blob is still described as `<commit-ish>:<path>` despite the lightweight | |
| 207 | 207 | tag being favorable. | |
| 208 | 208 | ||
| 209 | 209 | GIT | |
modified Documentation/git-difftool.adoc
| @@ -7,64 +7,64 @@ git-difftool - Show changes using common diff tools | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git difftool' [<options>] [<commit> [<commit>]] [--] [<path>...] | |
| 10 | + | [synopsis] | |
| 11 | + | git difftool [<options>] [<commit> [<commit>]] [--] [<path>...] | |
| 12 | 12 | ||
| 13 | 13 | DESCRIPTION | |
| 14 | 14 | ----------- | |
| 15 | - | 'git difftool' is a Git command that allows you to compare and edit files | |
| 16 | - | between revisions using common diff tools. 'git difftool' is a frontend | |
| 17 | - | to 'git diff' and accepts the same options and arguments. See | |
| 15 | + | `git difftool` is a Git command that allows you to compare and edit files | |
| 16 | + | between revisions using common diff tools. `git difftool` is a frontend | |
| 17 | + | to `git diff` and accepts the same options and arguments. See | |
| 18 | 18 | linkgit:git-diff[1]. | |
| 19 | 19 | ||
| 20 | 20 | OPTIONS | |
| 21 | 21 | ------- | |
| 22 | - | -d:: | |
| 23 | - | --dir-diff:: | |
| 22 | + | `-d`:: | |
| 23 | + | `--dir-diff`:: | |
| 24 | 24 | Copy the modified files to a temporary location and perform | |
| 25 | 25 | a directory diff on them. This mode never prompts before | |
| 26 | 26 | launching the diff tool. | |
| 27 | 27 | ||
| 28 | - | -y:: | |
| 29 | - | --no-prompt:: | |
| 28 | + | `-y`:: | |
| 29 | + | `--no-prompt`:: | |
| 30 | 30 | Do not prompt before launching a diff tool. | |
| 31 | 31 | ||
| 32 | - | --prompt:: | |
| 32 | + | `--prompt`:: | |
| 33 | 33 | Prompt before each invocation of the diff tool. | |
| 34 | 34 | This is the default behaviour; the option is provided to | |
| 35 | 35 | override any configuration settings. | |
| 36 | 36 | ||
| 37 | - | --rotate-to=<file>:: | |
| 38 | - | Start showing the diff for the given path, | |
| 37 | + | `--rotate-to=<file>`:: | |
| 38 | + | Start showing the diff for _<file>_, | |
| 39 | 39 | the paths before it will move to the end and output. | |
| 40 | 40 | ||
| 41 | - | --skip-to=<file>:: | |
| 42 | - | Start showing the diff for the given path, skipping all | |
| 41 | + | `--skip-to=<file>`:: | |
| 42 | + | Start showing the diff for _<file>_, skipping all | |
| 43 | 43 | the paths before it. | |
| 44 | 44 | ||
| 45 | - | -t <tool>:: | |
| 46 | - | --tool=<tool>:: | |
| 47 | - | Use the diff tool specified by <tool>. Valid values include | |
| 45 | + | `-t <tool>`:: | |
| 46 | + | `--tool=<tool>`:: | |
| 47 | + | Use the diff tool specified by _<tool>_. Valid values include | |
| 48 | 48 | emerge, kompare, meld, and vimdiff. Run `git difftool --tool-help` | |
| 49 | - | for the list of valid <tool> settings. | |
| 49 | + | for the list of valid _<tool>_ settings. | |
| 50 | 50 | + | |
| 51 | - | If a diff tool is not specified, 'git difftool' | |
| 51 | + | If a diff tool is not specified, `git difftool` | |
| 52 | 52 | will use the configuration variable `diff.tool`. If the | |
| 53 | - | configuration variable `diff.tool` is not set, 'git difftool' | |
| 53 | + | configuration variable `diff.tool` is not set, `git difftool` | |
| 54 | 54 | will pick a suitable default. | |
| 55 | 55 | + | |
| 56 | 56 | You can explicitly provide a full path to the tool by setting the | |
| 57 | 57 | configuration variable `difftool.<tool>.path`. For example, you | |
| 58 | 58 | can configure the absolute path to kdiff3 by setting | |
| 59 | - | `difftool.kdiff3.path`. Otherwise, 'git difftool' assumes the | |
| 59 | + | `difftool.kdiff3.path`. Otherwise, `git difftool` assumes the | |
| 60 | 60 | tool is available in PATH. | |
| 61 | 61 | + | |
| 62 | 62 | Instead of running one of the known diff tools, | |
| 63 | - | 'git difftool' can be customized to run an alternative program | |
| 63 | + | `git difftool` can be customized to run an alternative program | |
| 64 | 64 | by specifying the command line to invoke in a configuration | |
| 65 | 65 | variable `difftool.<tool>.cmd`. | |
| 66 | 66 | + | |
| 67 | - | When 'git difftool' is invoked with this tool (either through the | |
| 67 | + | When `git difftool` is invoked with this tool (either through the | |
| 68 | 68 | `-t` or `--tool` option or the `diff.tool` configuration variable) | |
| 69 | 69 | the configured command line will be invoked with the following | |
| 70 | 70 | variables available: `$LOCAL` is set to the name of the temporary | |
| @@ -74,30 +74,30 @@ of the diff post-image. `$MERGED` is the name of the file which is | |||
| 74 | 74 | being compared. `$BASE` is provided for compatibility | |
| 75 | 75 | with custom merge tool commands and has the same value as `$MERGED`. | |
| 76 | 76 | ||
| 77 | - | --tool-help:: | |
| 77 | + | `--tool-help`:: | |
| 78 | 78 | Print a list of diff tools that may be used with `--tool`. | |
| 79 | 79 | ||
| 80 | - | --symlinks:: | |
| 81 | - | --no-symlinks:: | |
| 82 | - | 'git difftool''s default behavior is to create symlinks to the | |
| 80 | + | `--symlinks`:: | |
| 81 | + | `--no-symlinks`:: | |
| 82 | + | `git difftool`'s default behavior is to create symlinks to the | |
| 83 | 83 | working tree when run in `--dir-diff` mode and the right-hand | |
| 84 | 84 | side of the comparison yields the same content as the file in | |
| 85 | 85 | the working tree. | |
| 86 | 86 | + | |
| 87 | - | Specifying `--no-symlinks` instructs 'git difftool' to create copies | |
| 87 | + | Specifying `--no-symlinks` instructs `git difftool` to create copies | |
| 88 | 88 | instead. `--no-symlinks` is the default on Windows. | |
| 89 | 89 | ||
| 90 | - | -x <command>:: | |
| 91 | - | --extcmd=<command>:: | |
| 90 | + | `-x <command>`:: | |
| 91 | + | `--extcmd=<command>`:: | |
| 92 | 92 | Specify a custom command for viewing diffs. | |
| 93 | - | 'git-difftool' ignores the configured defaults and runs | |
| 93 | + | `git-difftool` ignores the configured defaults and runs | |
| 94 | 94 | `<command> $LOCAL $REMOTE` when this option is specified. | |
| 95 | 95 | Additionally, `$BASE` is set in the environment. | |
| 96 | 96 | ||
| 97 | - | -g:: | |
| 98 | - | --gui:: | |
| 99 | - | --no-gui:: | |
| 100 | - | When 'git-difftool' is invoked with the `-g` or `--gui` option | |
| 97 | + | `-g`:: | |
| 98 | + | `--gui`:: | |
| 99 | + | `--no-gui`:: | |
| 100 | + | When `git-difftool` is invoked with the `-g` or `--gui` option | |
| 101 | 101 | the default diff tool will be read from the configured | |
| 102 | 102 | `diff.guitool` variable instead of `diff.tool`. This may be | |
| 103 | 103 | selected automatically using the configuration variable | |
| @@ -106,20 +106,20 @@ instead. `--no-symlinks` is the default on Windows. | |||
| 106 | 106 | fallback in the order of `merge.guitool`, `diff.tool`, | |
| 107 | 107 | `merge.tool` until a tool is found. | |
| 108 | 108 | ||
| 109 | - | --trust-exit-code:: | |
| 110 | - | --no-trust-exit-code:: | |
| 109 | + | `--trust-exit-code`:: | |
| 110 | + | `--no-trust-exit-code`:: | |
| 111 | 111 | Errors reported by the diff tool are ignored by default. | |
| 112 | - | Use `--trust-exit-code` to make 'git-difftool' exit when an | |
| 112 | + | Use `--trust-exit-code` to make `git-difftool` exit when an | |
| 113 | 113 | invoked diff tool returns a non-zero exit code. | |
| 114 | 114 | + | |
| 115 | - | 'git-difftool' will forward the exit code of the invoked tool when | |
| 115 | + | `git-difftool` will forward the exit code of the invoked tool when | |
| 116 | 116 | `--trust-exit-code` is used. | |
| 117 | 117 | ||
| 118 | 118 | See linkgit:git-diff[1] for the full list of supported options. | |
| 119 | 119 | ||
| 120 | 120 | CONFIGURATION | |
| 121 | 121 | ------------- | |
| 122 | - | 'git difftool' falls back to 'git mergetool' config variables when the | |
| 122 | + | `git difftool` falls back to `git mergetool` config variables when the | |
| 123 | 123 | difftool equivalents have not been defined. | |
| 124 | 124 | ||
| 125 | 125 | include::includes/cmd-config-section-rest.adoc[] | |
modified Documentation/git-fast-export.adoc
| @@ -9,7 +9,7 @@ git-fast-export - Git data exporter | |||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | 11 | [verse] | |
| 12 | - | 'git fast-export' [<options>] | 'git fast-import' | |
| 12 | + | 'git fast-export' [<options>] [<revision-range>] [[--] <path>...] | |
| 13 | 13 | ||
| 14 | 14 | DESCRIPTION | |
| 15 | 15 | ----------- | |
modified Documentation/git-fast-import.adoc
| @@ -9,7 +9,7 @@ git-fast-import - Backend for fast Git data importers | |||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | 11 | [verse] | |
| 12 | - | frontend | 'git fast-import' [<options>] | |
| 12 | + | 'git fast-import' [<options>] | |
| 13 | 13 | ||
| 14 | 14 | DESCRIPTION | |
| 15 | 15 | ----------- | |
| @@ -65,6 +65,13 @@ Only enable this option if you trust the program generating the | |||
| 65 | 65 | fast-import stream! This option is enabled automatically for | |
| 66 | 66 | remote-helpers that use the `import` capability, as they are | |
| 67 | 67 | already trusted to run their own code. | |
| 68 | + | + | |
| 69 | + | Note that this option has to be spelled in full, and has to appear | |
| 70 | + | before any option whose value is separated from it by a space, for | |
| 71 | + | the unsafe `feature` commands in the stream to be allowed. So | |
| 72 | + | `--allow-unsafe` or `--depth 5 --allow-unsafe-features` still refuse | |
| 73 | + | them, while `--allow-unsafe-features --depth 5` and | |
| 74 | + | `--depth=5 --allow-unsafe-features` allow them. | |
| 68 | 75 | ||
| 69 | 76 | `--signed-tags=<mode>`:: | |
| 70 | 77 | Specify how to handle signed tags. Behaves in the same way as | |
modified Documentation/git-format-patch.adoc
| @@ -8,8 +8,8 @@ git-format-patch - Prepare patches for e-mail submission | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git format-patch' [-k] [(-o|--output-directory) <dir> | --stdout] | |
| 11 | + | [synopsis] | |
| 12 | + | git format-patch [-k] [(-o|--output-directory) <dir> | --stdout] | |
| 13 | 13 | [--no-thread | --thread[=<style>]] | |
| 14 | 14 | [(--attach|--inline)[=<boundary>] | --no-attach] | |
| 15 | 15 | [-s | --signoff] | |
| @@ -40,20 +40,20 @@ DESCRIPTION | |||
| 40 | 40 | Prepare each non-merge commit with its "patch" in | |
| 41 | 41 | one "message" per commit, formatted to resemble a UNIX mailbox. | |
| 42 | 42 | The output of this command is convenient for e-mail submission or | |
| 43 | - | for use with 'git am'. | |
| 43 | + | for use with `git am`. | |
| 44 | 44 | ||
| 45 | 45 | A "message" generated by the command consists of three parts: | |
| 46 | 46 | ||
| 47 | 47 | * A brief metadata header that begins with `From <commit>` | |
| 48 | 48 | with a fixed `Mon Sep 17 00:00:00 2001` datestamp to help programs | |
| 49 | - | like "file(1)" to recognize that the file is an output from this | |
| 49 | + | like `file`(1) to recognize that the file is an output from this | |
| 50 | 50 | command, fields that record the author identity, the author date, | |
| 51 | 51 | and the title of the change (taken from the first paragraph of the | |
| 52 | 52 | commit log message). | |
| 53 | 53 | ||
| 54 | 54 | * The second and subsequent paragraphs of the commit log message. | |
| 55 | 55 | ||
| 56 | - | * The "patch", which is the "diff -p --stat" output (see | |
| 56 | + | * The "patch", which is the `diff -p --stat` output (see | |
| 57 | 57 | linkgit:git-diff[1]) between the commit and its parent. | |
| 58 | 58 | ||
| 59 | 59 | The log message and the patch are separated by a line with a | |
| @@ -61,18 +61,18 @@ three-dash line. | |||
| 61 | 61 | ||
| 62 | 62 | There are two ways to specify which commits to operate on. | |
| 63 | 63 | ||
| 64 | - | 1. A single commit, <since>, specifies that the commits leading | |
| 64 | + | 1. A single commit, _<since>_, specifies that the commits leading | |
| 65 | 65 | to the tip of the current branch that are not in the history | |
| 66 | - | that leads to the <since> to be output. | |
| 66 | + | that leads to the _<since>_ to be output. | |
| 67 | 67 | ||
| 68 | - | 2. Generic <revision-range> expression (see "SPECIFYING | |
| 69 | - | REVISIONS" section in linkgit:gitrevisions[7]) means the | |
| 68 | + | 2. Generic _<revision-range>_ expression (see 'SPECIFYING | |
| 69 | + | REVISIONS' section in linkgit:gitrevisions[7]) means the | |
| 70 | 70 | commits in the specified range. | |
| 71 | 71 | ||
| 72 | - | The first rule takes precedence in the case of a single <commit>. To | |
| 72 | + | The first rule takes precedence in the case of a single _<commit>_. To | |
| 73 | 73 | apply the second rule, i.e., format everything since the beginning of | |
| 74 | - | history up until <commit>, use the `--root` option: `git format-patch | |
| 75 | - | --root <commit>`. If you want to format only <commit> itself, you | |
| 74 | + | history up until _<commit>_, use the `--root` option: `git format-patch | |
| 75 | + | --root <commit>`. If you want to format only _<commit>_ itself, you | |
| 76 | 76 | can do this with `git format-patch -1 <commit>`. | |
| 77 | 77 | ||
| 78 | 78 | By default, each output file is numbered sequentially from 1, and uses the | |
| @@ -82,7 +82,7 @@ will only be numbers, without the first line of the commit appended. | |||
| 82 | 82 | The names of the output files are printed to standard | |
| 83 | 83 | output, unless the `--stdout` option is specified. | |
| 84 | 84 | ||
| 85 | - | If `-o` is specified, output files are created in <dir>. Otherwise | |
| 85 | + | If `-o` is specified, output files are created in _<dir>_. Otherwise | |
| 86 | 86 | they are created in the current working directory. The default path | |
| 87 | 87 | can be set with the `format.outputDirectory` configuration option. | |
| 88 | 88 | The `-o` option takes precedence over `format.outputDirectory`. | |
| @@ -108,123 +108,122 @@ OPTIONS | |||
| 108 | 108 | :git-format-patch: 1 | |
| 109 | 109 | include::diff-options.adoc[] | |
| 110 | 110 | ||
| 111 | - | -<n>:: | |
| 112 | - | Prepare patches from the topmost <n> commits. | |
| 111 | + | `-<n>`:: | |
| 112 | + | Prepare patches from the topmost _<n>_ commits. | |
| 113 | 113 | ||
| 114 | - | -o <dir>:: | |
| 115 | - | --output-directory <dir>:: | |
| 116 | - | Use <dir> to store the resulting files, instead of the | |
| 114 | + | `-o <dir>`:: | |
| 115 | + | `--output-directory=<dir>`:: | |
| 116 | + | Use _<dir>_ to store the resulting files, instead of the | |
| 117 | 117 | current working directory. | |
| 118 | 118 | ||
| 119 | - | -n:: | |
| 120 | - | --numbered:: | |
| 119 | + | `-n`:: | |
| 120 | + | `--numbered`:: | |
| 121 | 121 | Name output in '[PATCH n/m]' format, even with a single patch. | |
| 122 | 122 | ||
| 123 | - | -N:: | |
| 124 | - | --no-numbered:: | |
| 123 | + | `-N`:: | |
| 124 | + | `--no-numbered`:: | |
| 125 | 125 | Name output in '[PATCH]' format. | |
| 126 | 126 | ||
| 127 | - | --start-number <n>:: | |
| 128 | - | Start numbering the patches at <n> instead of 1. | |
| 127 | + | `--start-number <n>`:: | |
| 128 | + | Start numbering the patches at _<n>_ instead of 1. | |
| 129 | 129 | ||
| 130 | - | --numbered-files:: | |
| 130 | + | `--numbered-files`:: | |
| 131 | 131 | Output file names will be a simple number sequence | |
| 132 | 132 | without the default first line of the commit appended. | |
| 133 | 133 | ||
| 134 | - | -k:: | |
| 135 | - | --keep-subject:: | |
| 134 | + | `-k`:: | |
| 135 | + | `--keep-subject`:: | |
| 136 | 136 | Do not strip/add '[PATCH]' from the first line of the | |
| 137 | 137 | commit log message. | |
| 138 | 138 | ||
| 139 | - | -s:: | |
| 140 | - | --signoff:: | |
| 139 | + | `-s`:: | |
| 140 | + | `--signoff`:: | |
| 141 | 141 | Add a `Signed-off-by` trailer to the commit message, using | |
| 142 | 142 | the committer identity of yourself. | |
| 143 | 143 | See the signoff option in linkgit:git-commit[1] for more information. | |
| 144 | 144 | ||
| 145 | - | --stdout:: | |
| 145 | + | `--stdout`:: | |
| 146 | 146 | Print all commits to the standard output in mbox format, | |
| 147 | 147 | instead of creating a file for each one. | |
| 148 | 148 | ||
| 149 | - | --attach[=<boundary>]:: | |
| 149 | + | `--attach[=<boundary>]`:: | |
| 150 | 150 | Create multipart/mixed attachment, the first part of | |
| 151 | 151 | which is the commit message and the patch itself in the | |
| 152 | 152 | second part, with `Content-Disposition: attachment`. | |
| 153 | 153 | ||
| 154 | - | --no-attach:: | |
| 154 | + | `--no-attach`:: | |
| 155 | 155 | Disable the creation of an attachment, overriding the | |
| 156 | 156 | configuration setting. | |
| 157 | 157 | ||
| 158 | - | --inline[=<boundary>]:: | |
| 158 | + | `--inline[=<boundary>]`:: | |
| 159 | 159 | Create multipart/mixed attachment, the first part of | |
| 160 | 160 | which is the commit message and the patch itself in the | |
| 161 | 161 | second part, with `Content-Disposition: inline`. | |
| 162 | 162 | ||
| 163 | - | --thread[=<style>]:: | |
| 164 | - | --no-thread:: | |
| 165 | - | Controls addition of `In-Reply-To` and `References` headers to | |
| 163 | + | `--thread[=<style>]`:: | |
| 164 | + | `--no-thread`:: | |
| 165 | + | Control addition of `In-Reply-To` and `References` headers to | |
| 166 | 166 | make the second and subsequent mails appear as replies to the | |
| 167 | 167 | first. Also controls generation of the `Message-ID` header to | |
| 168 | 168 | reference. | |
| 169 | 169 | + | |
| 170 | - | The optional <style> argument can be either `shallow` or `deep`. | |
| 171 | - | 'shallow' threading makes every mail a reply to the head of the | |
| 170 | + | The optional _<style>_ argument can be either `shallow` or `deep`. | |
| 171 | + | `shallow` threading makes every mail a reply to the head of the | |
| 172 | 172 | series, where the head is chosen from the cover letter, the | |
| 173 | - | `--in-reply-to`, and the first patch mail, in this order. 'deep' | |
| 173 | + | `--in-reply-to`, and the first patch mail, in this order. `deep` | |
| 174 | 174 | threading makes every mail a reply to the previous one. | |
| 175 | 175 | + | |
| 176 | 176 | The default is `--no-thread`, unless the `format.thread` configuration | |
| 177 | 177 | is set. `--thread` without an argument is equivalent to `--thread=shallow`. | |
| 178 | 178 | + | |
| 179 | - | Beware that the default for 'git send-email' is to thread emails | |
| 179 | + | Beware that the default for `git send-email` is to thread emails | |
| 180 | 180 | itself. If you want `git format-patch` to take care of threading, you | |
| 181 | 181 | will want to ensure that threading is disabled for `git send-email`. | |
| 182 | 182 | ||
| 183 | - | --in-reply-to=<message-id>:: | |
| 183 | + | `--in-reply-to=<message-id>`:: | |
| 184 | 184 | Make the first mail (or all the mails with `--no-thread`) appear as a | |
| 185 | - | reply to the given <message-id>, which avoids breaking threads to | |
| 185 | + | reply to the given _<message-id>_, which avoids breaking threads to | |
| 186 | 186 | provide a new patch series. | |
| 187 | 187 | ||
| 188 | - | --ignore-if-in-upstream:: | |
| 188 | + | `--ignore-if-in-upstream`:: | |
| 189 | 189 | Do not include a patch that matches a commit in | |
| 190 | - | <until>..<since>. This will examine all patches reachable | |
| 191 | - | from <since> but not from <until> and compare them with the | |
| 190 | + | _<until>_.._<since>_. This will examine all patches reachable | |
| 191 | + | from _<since>_ but not from _<until>_ and compare them with the | |
| 192 | 192 | patches being generated, and any patch that matches is | |
| 193 | 193 | ignored. | |
| 194 | 194 | ||
| 195 | - | --always:: | |
| 195 | + | `--always`:: | |
| 196 | 196 | Include patches for commits that do not introduce any change, | |
| 197 | 197 | which are omitted by default. | |
| 198 | 198 | ||
| 199 | - | --cover-from-description=<mode>:: | |
| 200 | - | Controls which parts of the cover letter will be automatically | |
| 199 | + | `--cover-from-description=<mode>`:: | |
| 200 | + | Control which parts of the cover letter will be automatically | |
| 201 | 201 | populated using the branch's description. | |
| 202 | 202 | + | |
| 203 | - | If `<mode>` is `message` or `default`, the cover letter subject will be | |
| 203 | + | _<mode>_ can have the following values: | |
| 204 | + | ||
| 205 | + | `message`;; | |
| 206 | + | `default`;; the cover letter subject will be | |
| 204 | 207 | populated with placeholder text. The body of the cover letter will be | |
| 205 | 208 | populated with the branch's description. This is the default mode when | |
| 206 | 209 | no configuration nor command line option is specified. | |
| 207 | - | + | |
| 208 | - | If `<mode>` is `subject`, the first paragraph of the branch description will | |
| 210 | + | `subject`;; the first paragraph of the branch description will | |
| 209 | 211 | populate the cover letter subject. The remainder of the description will | |
| 210 | 212 | populate the body of the cover letter. | |
| 211 | - | + | |
| 212 | - | If `<mode>` is `auto`, if the first paragraph of the branch description | |
| 213 | + | `auto`;; if the first paragraph of the branch description | |
| 213 | 214 | is greater than 100 bytes, then the mode will be `message`, otherwise | |
| 214 | 215 | `subject` will be used. | |
| 215 | - | + | |
| 216 | - | If `<mode>` is `none`, both the cover letter subject and body will be | |
| 216 | + | `none`;; both the cover letter subject and body will be | |
| 217 | 217 | populated with placeholder text. | |
| 218 | 218 | ||
| 219 | - | --description-file=<file>:: | |
| 220 | - | Use the contents of <file> instead of the branch's description | |
| 219 | + | `--description-file=<file>`:: | |
| 220 | + | Use the contents of _<file>_ instead of the branch's description | |
| 221 | 221 | for generating the cover letter. | |
| 222 | 222 | ||
| 223 | - | --subject-prefix=<subject-prefix>:: | |
| 224 | - | Instead of the standard '[PATCH]' prefix in the subject | |
| 225 | - | line, instead use '[<subject-prefix>]'. This can be used | |
| 226 | - | to name a patch series, and can be combined with the | |
| 227 | - | `--numbered` option. | |
| 223 | + | `--subject-prefix=<subject-prefix>`:: | |
| 224 | + | Use '[<subject-prefix>]' instead of the standard '[PATCH]' | |
| 225 | + | prefix in the subject line. This can be used to name a patch | |
| 226 | + | series, and can be combined with the `--numbered` option. | |
| 228 | 227 | + | |
| 229 | 228 | The configuration variable `format.subjectPrefix` may also be used | |
| 230 | 229 | to configure a subject prefix to apply to a given repository for | |
| @@ -232,14 +231,14 @@ all patches. This is often useful on mailing lists which receive | |||
| 232 | 231 | patches for several repositories and can be used to disambiguate | |
| 233 | 232 | the patches (with a value of e.g. "PATCH my-project"). | |
| 234 | 233 | ||
| 235 | - | --filename-max-length=<n>:: | |
| 234 | + | `--filename-max-length=<n>`:: | |
| 236 | 235 | Instead of the standard 64 bytes, chomp the generated output | |
| 237 | - | filenames at around '<n>' bytes (too short a value will be | |
| 236 | + | filenames at around _<n>_ bytes (too short a value will be | |
| 238 | 237 | silently raised to a reasonable length). Defaults to the | |
| 239 | 238 | value of the `format.filenameMaxLength` configuration | |
| 240 | 239 | variable, or 64 if unconfigured. | |
| 241 | 240 | ||
| 242 | - | --rfc[=<rfc>]:: | |
| 241 | + | `--rfc[=<rfc>]`:: | |
| 243 | 242 | Prepends the string _<rfc>_ (defaults to "RFC") to | |
| 244 | 243 | the subject prefix. As the subject prefix defaults to | |
| 245 | 244 | "PATCH", you'll get "RFC PATCH" by default. | |
| @@ -255,38 +254,38 @@ can be prefixed with a dash ("`-`") to signal that the rest of | |||
| 255 | 254 | the _<rfc>_ string should be appended to the subject prefix instead, | |
| 256 | 255 | e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)". | |
| 257 | 256 | ||
| 258 | - | -v <n>:: | |
| 259 | - | --reroll-count=<n>:: | |
| 260 | - | Mark the series as the <n>-th iteration of the topic. The | |
| 257 | + | `-v <n>`:: | |
| 258 | + | `--reroll-count=<n>`:: | |
| 259 | + | Mark the series as the _<n>_-th iteration of the topic. The | |
| 261 | 260 | output filenames have `v<n>` prepended to them, and the | |
| 262 | 261 | subject prefix ("PATCH" by default, but configurable via the | |
| 263 | - | `--subject-prefix` option) has ` v<n>` appended to it. E.g. | |
| 262 | + | `--subject-prefix` option) has `v<n>` appended to it. E.g. | |
| 264 | 263 | `--reroll-count=4` may produce `v4-0001-add-makefile.patch` | |
| 265 | 264 | file that has "Subject: [PATCH v4 1/20] Add makefile" in it. | |
| 266 | - | `<n>` does not have to be an integer (e.g. "--reroll-count=4.4", | |
| 267 | - | or "--reroll-count=4rev2" are allowed), but the downside of | |
| 265 | + | _<n>_ does not have to be an integer (e.g. `--reroll-count=4.4`, | |
| 266 | + | or `--reroll-count=4rev2` are allowed), but the downside of | |
| 268 | 267 | using such a reroll-count is that the range-diff/interdiff | |
| 269 | 268 | with the previous version does not state exactly which | |
| 270 | 269 | version the new iteration is compared against. | |
| 271 | 270 | ||
| 272 | - | --to=<email>:: | |
| 271 | + | `--to=<email>`:: | |
| 273 | 272 | Add a `To:` header to the email headers. This is in addition | |
| 274 | 273 | to any configured headers, and may be used multiple times. | |
| 275 | 274 | The negated form `--no-to` discards all `To:` headers added so | |
| 276 | 275 | far (from config or command line). | |
| 277 | 276 | ||
| 278 | - | --cc=<email>:: | |
| 277 | + | `--cc=<email>`:: | |
| 279 | 278 | Add a `Cc:` header to the email headers. This is in addition | |
| 280 | 279 | to any configured headers, and may be used multiple times. | |
| 281 | 280 | The negated form `--no-cc` discards all `Cc:` headers added so | |
| 282 | 281 | far (from config or command line). | |
| 283 | 282 | ||
| 284 | - | --from:: | |
| 285 | - | --from=<ident>:: | |
| 286 | - | Use `ident` in the `From:` header of each email. In case of a | |
| 283 | + | `--from`:: | |
| 284 | + | `--from=<ident>`:: | |
| 285 | + | Use _<ident>_ in the `From:` header of each email. In case of a | |
| 287 | 286 | commit email, if the author ident of the commit is not textually | |
| 288 | - | identical to the provided `ident`, place a `From:` header in the | |
| 289 | - | body of the message with the original author. If no `ident` is | |
| 287 | + | identical to the provided _<ident>_, place a `From:` header in the | |
| 288 | + | body of the message with the original author. If no _<ident>_ is | |
| 290 | 289 | given, or if the option is not passed at all, use the ident of | |
| 291 | 290 | the current committer. | |
| 292 | 291 | + | |
| @@ -297,8 +296,8 @@ header). Note also that `git send-email` already handles this | |||
| 297 | 296 | transformation for you, and this option should not be used if you are | |
| 298 | 297 | feeding the result to `git send-email`. | |
| 299 | 298 | ||
| 300 | - | --force-in-body-from:: | |
| 301 | - | --no-force-in-body-from:: | |
| 299 | + | `--force-in-body-from`:: | |
| 300 | + | `--no-force-in-body-from`:: | |
| 302 | 301 | With the e-mail sender specified via the `--from` option, by | |
| 303 | 302 | default, an in-body "From:" to identify the real author of | |
| 304 | 303 | the commit is added at the top of the commit log message if | |
| @@ -309,7 +308,7 @@ feeding the result to `git send-email`. | |||
| 309 | 308 | Defaults to the value of the `format.forceInBodyFrom` | |
| 310 | 309 | configuration variable. | |
| 311 | 310 | ||
| 312 | - | --add-header=<header>:: | |
| 311 | + | `--add-header=<header>`:: | |
| 313 | 312 | Add an arbitrary header to the email headers. This is in addition | |
| 314 | 313 | to any configured headers, and may be used multiple times. | |
| 315 | 314 | For example, `--add-header="Organization: git-foo"`. | |
| @@ -317,13 +316,13 @@ feeding the result to `git send-email`. | |||
| 317 | 316 | `Cc:`, and custom) headers added so far from config or command | |
| 318 | 317 | line. | |
| 319 | 318 | ||
| 320 | - | --cover-letter:: | |
| 321 | - | --no-cover-letter:: | |
| 319 | + | `--cover-letter`:: | |
| 320 | + | `--no-cover-letter`:: | |
| 322 | 321 | In addition to the patches, generate a cover letter file containing the | |
| 323 | 322 | branch description, commit list and the overall diffstat. You can fill | |
| 324 | 323 | in a description in the file before sending it out. | |
| 325 | 324 | ||
| 326 | - | --commit-list-format=<format-spec>:: | |
| 325 | + | `--commit-list-format=<format-spec>`:: | |
| 327 | 326 | Specify the format in which to generate the commit list of the patch | |
| 328 | 327 | series. The accepted values for format-spec are `shortlog`, `modern` or | |
| 329 | 328 | a format-string prefixed with `log:`. E.g. `log: %s (%an)`. | |
| @@ -335,28 +334,28 @@ feeding the result to `git send-email`. | |||
| 335 | 334 | This option given from the command-line implies the use of | |
| 336 | 335 | `--cover-letter` unless `--no-cover-letter` is given. | |
| 337 | 336 | ||
| 338 | - | --encode-email-headers:: | |
| 339 | - | --no-encode-email-headers:: | |
| 337 | + | `--encode-email-headers`:: | |
| 338 | + | `--no-encode-email-headers`:: | |
| 340 | 339 | Encode email headers that have non-ASCII characters with | |
| 341 | 340 | "Q-encoding" (described in RFC 2047), instead of outputting the | |
| 342 | 341 | headers verbatim. Defaults to the value of the | |
| 343 | 342 | `format.encodeEmailHeaders` configuration variable. | |
| 344 | 343 | ||
| 345 | - | --interdiff=<previous>:: | |
| 344 | + | `--interdiff=<previous>`:: | |
| 346 | 345 | As a reviewer aid, insert an interdiff into the cover letter, | |
| 347 | 346 | or as commentary of the lone patch of a 1-patch series, showing | |
| 348 | 347 | the differences between the previous version of the patch series and | |
| 349 | - | the series currently being formatted. `previous` is a single revision | |
| 348 | + | the series currently being formatted. _<previous>_ is a single revision | |
| 350 | 349 | naming the tip of the previous series which shares a common base with | |
| 351 | 350 | the series being formatted (for example `git format-patch | |
| 352 | 351 | --cover-letter --interdiff=feature/v1 -3 feature/v2`). | |
| 353 | 352 | ||
| 354 | - | --range-diff=<previous>:: | |
| 353 | + | `--range-diff=<previous>`:: | |
| 355 | 354 | As a reviewer aid, insert a range-diff (see linkgit:git-range-diff[1]) | |
| 356 | 355 | into the cover letter, or as commentary of the lone patch of a | |
| 357 | 356 | 1-patch series, showing the differences between the previous | |
| 358 | 357 | version of the patch series and the series currently being formatted. | |
| 359 | - | `previous` can be a single revision naming the tip of the previous | |
| 358 | + | _<previous>_ can be a single revision naming the tip of the previous | |
| 360 | 359 | series if it shares a common base with the series being formatted (for | |
| 361 | 360 | example `git format-patch --cover-letter --range-diff=feature/v1 -3 | |
| 362 | 361 | feature/v2`), or a revision range if the two versions of the series are | |
| @@ -368,7 +367,7 @@ product of `format-patch` is generated, and they are not passed to | |||
| 368 | 367 | the underlying `range-diff` machinery used to generate the cover-letter | |
| 369 | 368 | material (this may change in the future). | |
| 370 | 369 | ||
| 371 | - | --creation-factor=<percent>:: | |
| 370 | + | `--creation-factor=<percent>`:: | |
| 372 | 371 | Used with `--range-diff`, tweak the heuristic which matches up commits | |
| 373 | 372 | between the previous and current series of patches by adjusting the | |
| 374 | 373 | creation/deletion cost fudge factor. See linkgit:git-range-diff[1]) | |
| @@ -379,8 +378,8 @@ case is to show comparison with an older iteration of the same | |||
| 379 | 378 | topic and the tool should find more correspondence between the two | |
| 380 | 379 | sets of patches. | |
| 381 | 380 | ||
| 382 | - | --notes[=<ref>]:: | |
| 383 | - | --no-notes:: | |
| 381 | + | `--notes[=<ref>]`:: | |
| 382 | + | `--no-notes`:: | |
| 384 | 383 | Append the notes (see linkgit:git-notes[1]) for the commit | |
| 385 | 384 | after the three-dash line. | |
| 386 | 385 | + | |
| @@ -395,17 +394,17 @@ configuration options in linkgit:git-notes[1] to use this workflow). | |||
| 395 | 394 | The default is `--no-notes`, unless the `format.notes` configuration is | |
| 396 | 395 | set. | |
| 397 | 396 | ||
| 398 | - | --signature=<signature>:: | |
| 399 | - | --no-signature:: | |
| 397 | + | `--signature=<signature>`:: | |
| 398 | + | `--no-signature`:: | |
| 400 | 399 | Add a signature to each message produced. Per RFC 3676 the signature | |
| 401 | - | is separated from the body by a line with '-- ' on it. If the | |
| 400 | + | is separated from the body by a line with "-- " on it. If the | |
| 402 | 401 | signature option is omitted the signature defaults to the Git version | |
| 403 | 402 | number. | |
| 404 | 403 | ||
| 405 | - | --signature-file=<file>:: | |
| 406 | - | Works just like --signature except the signature is read from a file. | |
| 404 | + | `--signature-file=<file>`:: | |
| 405 | + | Works just like `--signature` except the signature is read from a file. | |
| 407 | 406 | ||
| 408 | - | --suffix=.<sfx>:: | |
| 407 | + | `--suffix=.<sfx>`:: | |
| 409 | 408 | Instead of using `.patch` as the suffix for generated | |
| 410 | 409 | filenames, use specified suffix. A common alternative is | |
| 411 | 410 | `--suffix=.txt`. Leaving this empty will remove the `.patch` | |
| @@ -414,36 +413,36 @@ set. | |||
| 414 | 413 | Note that the leading character does not have to be a dot; for example, | |
| 415 | 414 | you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`. | |
| 416 | 415 | ||
| 417 | - | -q:: | |
| 418 | - | --quiet:: | |
| 416 | + | `-q`:: | |
| 417 | + | `--quiet`:: | |
| 419 | 418 | Do not print the names of the generated files to standard output. | |
| 420 | 419 | ||
| 421 | - | --no-binary:: | |
| 420 | + | `--no-binary`:: | |
| 422 | 421 | Do not output contents of changes in binary files, instead | |
| 423 | 422 | display a notice that those files changed. Patches generated | |
| 424 | 423 | using this option cannot be applied properly, but they are | |
| 425 | 424 | still useful for code review. | |
| 426 | 425 | ||
| 427 | - | --zero-commit:: | |
| 426 | + | `--zero-commit`:: | |
| 428 | 427 | Output an all-zero hash in each patch's From header instead | |
| 429 | 428 | of the hash of the commit. | |
| 430 | 429 | ||
| 431 | - | --no-base:: | |
| 432 | - | --base[=<commit>]:: | |
| 430 | + | `--no-base`:: | |
| 431 | + | `--base[=<commit>]`:: | |
| 433 | 432 | Record the base tree information to identify the state the | |
| 434 | 433 | patch series applies to. See the BASE TREE INFORMATION section | |
| 435 | - | below for details. If <commit> is "auto", a base commit is | |
| 434 | + | below for details. If _<commit>_ is `auto`, a base commit is | |
| 436 | 435 | automatically chosen. The `--no-base` option overrides a | |
| 437 | 436 | `format.useAutoBase` configuration. | |
| 438 | 437 | ||
| 439 | - | --root:: | |
| 440 | - | Treat the revision argument as a <revision-range>, even if it | |
| 438 | + | `--root`:: | |
| 439 | + | Treat the revision argument as a _<revision-range>_, even if it | |
| 441 | 440 | is just a single commit (that would normally be treated as a | |
| 442 | - | <since>). Note that root commits included in the specified | |
| 441 | + | _<since>_). Note that root commits included in the specified | |
| 443 | 442 | range are always formatted as creation patches, independently | |
| 444 | 443 | of this flag. | |
| 445 | 444 | ||
| 446 | - | --progress:: | |
| 445 | + | `--progress`:: | |
| 447 | 446 | Show progress reports on stderr as patches are generated. | |
| 448 | 447 | ||
| 449 | 448 | CONFIGURATION | |
| @@ -454,7 +453,7 @@ outputting more than one patch, add "To:" or "Cc:" headers, configure | |||
| 454 | 453 | attachments, change the patch output directory, and sign off patches | |
| 455 | 454 | with configuration variables. | |
| 456 | 455 | ||
| 457 | - | ------------ | |
| 456 | + | ---- | |
| 458 | 457 | [format] | |
| 459 | 458 | headers = "Organization: git-foo\n" | |
| 460 | 459 | subjectPrefix = CHANGE | |
| @@ -468,17 +467,16 @@ with configuration variables. | |||
| 468 | 467 | coverLetter = auto | |
| 469 | 468 | commitListFormat = shortlog | |
| 470 | 469 | coverFromDescription = auto | |
| 471 | - | ------------ | |
| 472 | - | ||
| 470 | + | ---- | |
| 473 | 471 | ||
| 474 | 472 | DISCUSSION | |
| 475 | 473 | ---------- | |
| 476 | 474 | ||
| 477 | - | The patch produced by 'git format-patch' is in UNIX mailbox format, | |
| 475 | + | The patch produced by `git format-patch` is in UNIX mailbox format, | |
| 478 | 476 | with a fixed "magic" time stamp to indicate that the file is output | |
| 479 | 477 | from format-patch rather than a real mailbox, like so: | |
| 480 | 478 | ||
| 481 | - | ------------ | |
| 479 | + | ---- | |
| 482 | 480 | From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 | |
| 483 | 481 | From: Tony Luck <tony.luck@intel.com> | |
| 484 | 482 | Date: Tue, 13 Jul 2010 11:42:54 -0700 | |
| @@ -493,7 +491,7 @@ arch/arm config files were slimmed down using a python script | |||
| 493 | 491 | ||
| 494 | 492 | Do the same for ia64 so we can have sleek & trim looking | |
| 495 | 493 | ... | |
| 496 | - | ------------ | |
| 494 | + | ---- | |
| 497 | 495 | ||
| 498 | 496 | Typically it will be placed in a MUA's drafts folder, edited to add | |
| 499 | 497 | timely commentary that should not go in the changelog after the three | |
| @@ -503,12 +501,12 @@ can save interesting patches in a UNIX mailbox and apply them with | |||
| 503 | 501 | linkgit:git-am[1]. | |
| 504 | 502 | ||
| 505 | 503 | When a patch is part of an ongoing discussion, the patch generated by | |
| 506 | - | 'git format-patch' can be tweaked to take advantage of the 'git am | |
| 507 | - | --scissors' feature. After your response to the discussion comes a | |
| 504 | + | `git format-patch` can be tweaked to take advantage of the `git am | |
| 505 | + | --scissors` feature. After your response to the discussion comes a | |
| 508 | 506 | line that consists solely of "`-- >8 --`" (scissors and perforation), | |
| 509 | 507 | followed by the patch with unnecessary header fields removed: | |
| 510 | 508 | ||
| 511 | - | ------------ | |
| 509 | + | ---- | |
| 512 | 510 | ... | |
| 513 | 511 | > So we should do such-and-such. | |
| 514 | 512 | ||
| @@ -519,7 +517,7 @@ Subject: [IA64] Put ia64 config files on the Uwe Kleine-Kรถnig diet | |||
| 519 | 517 | ||
| 520 | 518 | arch/arm config files were slimmed down using a python script | |
| 521 | 519 | ... | |
| 522 | - | ------------ | |
| 520 | + | ---- | |
| 523 | 521 | ||
| 524 | 522 | When sending a patch this way, most often you are sending your own | |
| 525 | 523 | patch, so in addition to the "`From $SHA1 $magic_timestamp`" marker you | |
| @@ -541,7 +539,7 @@ two common types of corruption: | |||
| 541 | 539 | One way to test if your MUA is set up correctly is: | |
| 542 | 540 | ||
| 543 | 541 | * Send the patch to yourself, exactly the way you would, except | |
| 544 | - | with To: and Cc: lines that do not contain the list and | |
| 542 | + | with `To:` and `Cc:` lines that do not contain the list and | |
| 545 | 543 | maintainer address. | |
| 546 | 544 | ||
| 547 | 545 | * Save that patch to a file in UNIX mailbox format. Call it a.patch, | |
| @@ -562,12 +560,12 @@ If it does not apply correctly, there can be various reasons. | |||
| 562 | 560 | this case. | |
| 563 | 561 | ||
| 564 | 562 | * The MUA corrupted your patch; "am" would complain that | |
| 565 | - | the patch does not apply. Look in the .git/rebase-apply/ subdirectory and | |
| 566 | - | see what 'patch' file contains and check for the common | |
| 567 | - | corruption patterns mentioned above. | |
| 563 | + | the patch does not apply. Look in the `.git/rebase-apply/` subdirectory and | |
| 564 | + | see what `patch` file contains and check for the common | |
| 565 | + | corruption patterns mentioned above. | |
| 568 | 566 | ||
| 569 | - | * While at it, check the 'info' and 'final-commit' files as well. | |
| 570 | - | If what is in 'final-commit' is not exactly what you would want to | |
| 567 | + | * While at it, check the `info` and `final-commit` files as well. | |
| 568 | + | If what is in `final-commit` is not exactly what you would want to | |
| 571 | 569 | see in the commit log message, it is very likely that the | |
| 572 | 570 | receiver would end up hand editing the log message when applying | |
| 573 | 571 | your patch. Things like "Hi, this is my first patch.\n" in the | |
| @@ -583,11 +581,11 @@ GMail | |||
| 583 | 581 | ~~~~~ | |
| 584 | 582 | GMail does not have any way to turn off line wrapping in the web | |
| 585 | 583 | interface, so it will mangle any emails that you send. You can however | |
| 586 | - | use "git send-email" and send your patches through the GMail SMTP server, or | |
| 584 | + | use `git send-email` and send your patches through the GMail SMTP server, or | |
| 587 | 585 | use any IMAP email client to connect to the google IMAP server and forward | |
| 588 | 586 | the emails through that. | |
| 589 | 587 | ||
| 590 | - | For hints on using 'git send-email' to send your patches through the | |
| 588 | + | For hints on using `git send-email` to send your patches through the | |
| 591 | 589 | GMail SMTP server, see the EXAMPLE section of linkgit:git-send-email[1]. | |
| 592 | 590 | ||
| 593 | 591 | For hints on submission using the IMAP interface, see the EXAMPLE | |
| @@ -596,7 +594,7 @@ section of linkgit:git-imap-send[1]. | |||
| 596 | 594 | Thunderbird | |
| 597 | 595 | ~~~~~~~~~~~ | |
| 598 | 596 | By default, Thunderbird will both wrap emails as well as flag | |
| 599 | - | them as being 'format=flowed', both of which will make the | |
| 597 | + | them as being `format=flowed`, both of which will make the | |
| 600 | 598 | resulting email unusable by Git. | |
| 601 | 599 | ||
| 602 | 600 | There are three different approaches: use an add-on to turn off line wraps, | |
| @@ -610,14 +608,14 @@ Install the Toggle Line Wrap add-on that is available from | |||
| 610 | 608 | https://addons.thunderbird.net/thunderbird/addon/toggle-line-wrap | |
| 611 | 609 | It adds a button "Line Wrap" to the composer's toolbar | |
| 612 | 610 | that you can tick off. Now you can compose the message as you otherwise do | |
| 613 | - | (cut + paste, 'git format-patch' | 'git imap-send', etc), but you have to | |
| 611 | + | (cut + paste, `git format-patch` | `git imap-send`, etc), but you have to | |
| 614 | 612 | insert line breaks manually in any text that you type. | |
| 615 | 613 | ||
| 616 | 614 | As a bonus feature, the add-on can detect patch text in the composer | |
| 617 | 615 | and warns when line wrapping has not yet been turned off. | |
| 618 | 616 | ||
| 619 | 617 | The add-on requires a few tweaks of the advanced configuration | |
| 620 | - | (about:config). These are listed on the download page. | |
| 618 | + | (`about:config`). These are listed on the download page. | |
| 621 | 619 | ||
| 622 | 620 | Approach #2 (configuration) | |
| 623 | 621 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| @@ -644,7 +642,7 @@ Toggle it to make sure it is set to `false`. Also, search for | |||
| 644 | 642 | Toggle it to make sure it is set to `false`. | |
| 645 | 643 | ||
| 646 | 644 | After that is done, you should be able to compose email as you | |
| 647 | - | otherwise would (cut + paste, 'git format-patch' | 'git imap-send', etc), | |
| 645 | + | otherwise would (cut + paste, `git format-patch` | `git imap-send`, etc), | |
| 648 | 646 | and the patches will not be mangled. | |
| 649 | 647 | ||
| 650 | 648 | Approach #3 (external editor) | |
| @@ -661,14 +659,14 @@ External Editor from https://globs.org/articles.php?lng=en&pg=8 | |||
| 661 | 659 | "Composition & Addressing" panel of the account to be used to | |
| 662 | 660 | send the patch. | |
| 663 | 661 | ||
| 664 | - | 3. In the main Thunderbird window, 'before' you open the compose | |
| 662 | + | 3. In the main Thunderbird window, _before_ you open the compose | |
| 665 | 663 | window for the patch, use Tools->about:config to set the | |
| 666 | 664 | following to the indicated values: | |
| 667 | 665 | + | |
| 668 | - | ---------- | |
| 666 | + | ---- | |
| 669 | 667 | mailnews.send_plaintext_flowed => false | |
| 670 | 668 | mailnews.wraplength => 0 | |
| 671 | - | ---------- | |
| 669 | + | ---- | |
| 672 | 670 | ||
| 673 | 671 | 4. Open a compose window and click the external editor icon. | |
| 674 | 672 | ||
| @@ -678,11 +676,11 @@ External Editor from https://globs.org/articles.php?lng=en&pg=8 | |||
| 678 | 676 | Side note: it may be possible to do step 2 with | |
| 679 | 677 | about:config and the following settings but no one's tried yet. | |
| 680 | 678 | ||
| 681 | - | ---------- | |
| 679 | + | ---- | |
| 682 | 680 | mail.html_compose => false | |
| 683 | 681 | mail.identity.default.compose_html => false | |
| 684 | 682 | mail.identity.id?.compose_html => false | |
| 685 | - | ---------- | |
| 683 | + | ---- | |
| 686 | 684 | ||
| 687 | 685 | There is a script in contrib/thunderbird-patch-inline which can help | |
| 688 | 686 | you include patches with Thunderbird in an easy way. To use it, do the | |
| @@ -709,15 +707,15 @@ BASE TREE INFORMATION | |||
| 709 | 707 | ||
| 710 | 708 | The base tree information block is used for maintainers or third party | |
| 711 | 709 | testers to know the exact state the patch series applies to. It consists | |
| 712 | - | of the 'base commit', which is a well-known commit that is part of the | |
| 710 | + | of the "base commit", which is a well-known commit that is part of the | |
| 713 | 711 | stable part of the project history everybody else works off of, and zero | |
| 714 | - | or more 'prerequisite patches', which are well-known patches in flight | |
| 715 | - | that is not yet part of the 'base commit' that need to be applied on top | |
| 716 | - | of 'base commit' in topological order before the patches can be applied. | |
| 712 | + | or more "prerequisite patches", which are well-known patches in flight | |
| 713 | + | that is not yet part of the "base commit" that need to be applied on top | |
| 714 | + | of "base commit" in topological order before the patches can be applied. | |
| 717 | 715 | ||
| 718 | - | The 'base commit' is shown as "base-commit: " followed by the 40-hex of | |
| 719 | - | the commit object name. A 'prerequisite patch' is shown as | |
| 720 | - | "prerequisite-patch-id: " followed by the 40-hex 'patch id', which can | |
| 716 | + | The "base commit" is shown as "`base-commit:` " followed by the 40-hex of | |
| 717 | + | the commit object name. A "prerequisite patch" is shown as | |
| 718 | + | "`prerequisite-patch-id:` " followed by the 40-hex "patch id", which can | |
| 721 | 719 | be obtained by passing the patch through the `git patch-id --stable` | |
| 722 | 720 | command. | |
| 723 | 721 | ||
| @@ -735,12 +733,12 @@ range), the base tree information block is shown at the end of the | |||
| 735 | 733 | first message the command outputs (either the first patch, or the | |
| 736 | 734 | cover letter), like this: | |
| 737 | 735 | ||
| 738 | - | ------------ | |
| 736 | + | ---- | |
| 739 | 737 | base-commit: P | |
| 740 | 738 | prerequisite-patch-id: X | |
| 741 | 739 | prerequisite-patch-id: Y | |
| 742 | 740 | prerequisite-patch-id: Z | |
| 743 | - | ------------ | |
| 741 | + | ---- | |
| 744 | 742 | ||
| 745 | 743 | For non-linear topology, such as | |
| 746 | 744 | ||
| @@ -764,7 +762,7 @@ EXAMPLES | |||
| 764 | 762 | -------- | |
| 765 | 763 | ||
| 766 | 764 | * Extract commits between revisions R1 and R2, and apply them on top of | |
| 767 | - | the current branch using 'git am' to cherry-pick them: | |
| 765 | + | the current branch using `git am` to cherry-pick them: | |
| 768 | 766 | + | |
| 769 | 767 | ------------ | |
| 770 | 768 | $ git format-patch -k --stdout R1..R2 | git am -3 -k | |
| @@ -779,7 +777,7 @@ $ git format-patch origin | |||
| 779 | 777 | + | |
| 780 | 778 | For each commit a separate file is created in the current directory. | |
| 781 | 779 | ||
| 782 | - | * Extract all commits that lead to 'origin' since the inception of the | |
| 780 | + | * Extract all commits that lead to `origin` since the inception of the | |
| 783 | 781 | project: | |
| 784 | 782 | + | |
| 785 | 783 | ------------ | |
| @@ -795,7 +793,7 @@ $ git format-patch -M -B origin | |||
| 795 | 793 | Additionally, it detects and handles renames and complete rewrites | |
| 796 | 794 | intelligently to produce a renaming patch. A renaming patch reduces | |
| 797 | 795 | the amount of text output, and generally makes it easier to review. | |
| 798 | - | Note that non-Git "patch" programs won't understand renaming patches, so | |
| 796 | + | Note that non-Git `patch` programs won't understand renaming patches, so | |
| 799 | 797 | use it only when you know the recipient uses Git to apply your patch. | |
| 800 | 798 | ||
| 801 | 799 | * Extract three topmost commits from the current branch and format them | |
added Documentation/git-format-rev.adoc mode 100644
| @@ -0,0 +1,216 @@ | |||
| 1 | + | git-format-rev(1) | |
| 2 | + | ================= | |
| 3 | + | ||
| 4 | + | NAME | |
| 5 | + | ---- | |
| 6 | + | git-format-rev - EXPERIMENTAL: Pretty format revisions on demand | |
| 7 | + | ||
| 8 | + | ||
| 9 | + | SYNOPSIS | |
| 10 | + | -------- | |
| 11 | + | [synopsis] | |
| 12 | + | (EXPERIMENTAL!) git format-rev --stdin-mode=<mode> --format=<pretty> [--[no-]notes=<ref>] [-z] [--[no-]null-output] [--[no-]null-input] | |
| 13 | + | ||
| 14 | + | DESCRIPTION | |
| 15 | + | ----------- | |
| 16 | + | ||
| 17 | + | Pretty format revisions from standard input. | |
| 18 | + | ||
| 19 | + | THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. | |
| 20 | + | ||
| 21 | + | OPTIONS | |
| 22 | + | ------- | |
| 23 | + | ||
| 24 | + | `--stdin-mode=<mode>`:: | |
| 25 | + | How to interpret standard input data: | |
| 26 | + | + | |
| 27 | + | -- | |
| 28 | + | `revs`;; Each line or record (see the <<io,INPUT AND OUTPUT FORMATS>> | |
| 29 | + | section) is interpreted as a commit. Any kind of revision | |
| 30 | + | expression can be used (see linkgit:gitrevisions[7]). Annotated | |
| 31 | + | tags are peeled (see linkgit:gitglossary[7]). | |
| 32 | + | + | |
| 33 | + | The argument `rev` is also accepted. | |
| 34 | + | ||
| 35 | + | `text`;; Formats all commit object names found in freeform text. These | |
| 36 | + | must be full object names, i.e. abbreviated hexadecimal object | |
| 37 | + | names will not be interpreted. | |
| 38 | + | + | |
| 39 | + | Anything that is parsed as an object name but that is not found to be a | |
| 40 | + | commit object name is left alone (echoed). | |
| 41 | + | -- | |
| 42 | + | ||
| 43 | + | `--format=<pretty>`:: | |
| 44 | + | Pretty format string. | |
| 45 | + | ||
| 46 | + | `--notes=<ref>`:: | |
| 47 | + | `--no-notes`:: | |
| 48 | + | Custom notes ref. Notes are displayed when using the `%N` | |
| 49 | + | atom. See linkgit:git-notes[1]. | |
| 50 | + | ||
| 51 | + | `-z`:: | |
| 52 | + | `--null`:: | |
| 53 | + | Use _NUL_ character to terminate both input and output instead | |
| 54 | + | of newline. This option cannot be negated. | |
| 55 | + | + | |
| 56 | + | This is useful if both the input and output could contain newlines or if | |
| 57 | + | the input to this command also uses _NUL_ character termination; see the | |
| 58 | + | <<io,INPUT AND OUTPUT FORMATS>> section below. | |
| 59 | + | + | |
| 60 | + | The mode `--stdin-mode=text` can have use for this option when it needs | |
| 61 | + | to process input like for example `git last-modified -z`; see the | |
| 62 | + | <<examples,EXAMPLES>> section below. | |
| 63 | + | ||
| 64 | + | `--null-output`:: | |
| 65 | + | `--no-null-output`:: | |
| 66 | + | Use _NUL_ character to terminate output instead of newline. The | |
| 67 | + | default is `--no-null-output`. | |
| 68 | + | + | |
| 69 | + | This is useful if the output could contain newlines, for example if the | |
| 70 | + | `%n` (newline) atom is used. | |
| 71 | + | ||
| 72 | + | `--null-input`:: | |
| 73 | + | `--no-null-input`:: | |
| 74 | + | Use _NUL_ character to terminate input instead of newline. The | |
| 75 | + | default is `--no-null-input`. | |
| 76 | + | + | |
| 77 | + | This is useful if the input revision expressions could contain newlines. | |
| 78 | + | ||
| 79 | + | [[io]] | |
| 80 | + | INPUT AND OUTPUT FORMAT | |
| 81 | + | ----------------------- | |
| 82 | + | ||
| 83 | + | The command uses newlines for both input and output termination by | |
| 84 | + | default. See the `-z`, `--null-output`, and `--null-input` options for | |
| 85 | + | using _NUL_ character as the terminator. | |
| 86 | + | ||
| 87 | + | The mode `--stdin-mode=revs` outputs one formatted commit followed by | |
| 88 | + | the terminator. This could either be called a _line_ or a _record_ in | |
| 89 | + | case "line" is too suggestive of newline termination. | |
| 90 | + | ||
| 91 | + | Note that this means that the terminator character (newline or _NUL_) | |
| 92 | + | acts as a _terminator_, not a _separator_. In other words, the final | |
| 93 | + | line or record is also terminated by the terminator character. | |
| 94 | + | ||
| 95 | + | The mode `--stdin-mode=text` replaces each object name with the | |
| 96 | + | formatted commit, i.e. the format `"%s"` would transform some commit | |
| 97 | + | object name to `"<subject>"` without any termination. Like this: | |
| 98 | + | ||
| 99 | + | [synopsis] | |
| 100 | + | -- | |
| 101 | + | Did we not fix this in "<subject>"? | |
| 102 | + | -- | |
| 103 | + | ||
| 104 | + | It is safe to interactively read and write from this command since each | |
| 105 | + | record is immediately flushed. | |
| 106 | + | ||
| 107 | + | [[examples]] | |
| 108 | + | EXAMPLES | |
| 109 | + | -------- | |
| 110 | + | ||
| 111 | + | The command linkgit:git-last-modified[1] shows the commit that each file | |
| 112 | + | was last modified in. | |
| 113 | + | ||
| 114 | + | ---- | |
| 115 | + | $ git last-modified -- README.md Makefile | |
| 116 | + | 7798034171030be0909c56377a4e0e10e6d2df93 Makefile | |
| 117 | + | c50fbb2dd225e7e82abba4380423ae105089f4d7 README.md | |
| 118 | + | ---- | |
| 119 | + | ||
| 120 | + | We can pipe the result to this command in order to replace the object | |
| 121 | + | name with the commit author. | |
| 122 | + | ||
| 123 | + | ---- | |
| 124 | + | $ git last-modified -- README.md Makefile | | |
| 125 | + | git format-rev --stdin-mode=text --format=%an | |
| 126 | + | Junio C Hamano Makefile | |
| 127 | + | Todd Zullinger README.md | |
| 128 | + | ---- | |
| 129 | + | ||
| 130 | + | Another example is _formatting commits in commit messages_. Given this commit message: | |
| 131 | + | ||
| 132 | + | ---- | |
| 133 | + | Fix off-by-one error | |
| 134 | + | ||
| 135 | + | Fix off-by-one error introduced in | |
| 136 | + | e83c5163316f89bfbde7d9ab23ca2e25604af290. | |
| 137 | + | ||
| 138 | + | We thought we fixed this in 5569bf9bbedd63a00780fc5c110e0cfab3aa97b9 but | |
| 139 | + | that only covered 1/3 of the faulty cases. | |
| 140 | + | ---- | |
| 141 | + | ||
| 142 | + | We can format the commits and use par(1) to reflow the text, say in a | |
| 143 | + | `commit-msg` hook: | |
| 144 | + | ||
| 145 | + | ---- | |
| 146 | + | $ git config set hook.reference-commits.event commit-msg | |
| 147 | + | $ git config set hook.reference-commits.command reference-commits | |
| 148 | + | $ cat $(which reference-commits) | |
| 149 | + | #/bin/sh | |
| 150 | + | ||
| 151 | + | msg="$1" | |
| 152 | + | rewritten=$(mktemp) | |
| 153 | + | git format-rev --stdin-mode=text --format=reference <"$msg" | | |
| 154 | + | par >"$rewritten" | |
| 155 | + | mv "$rewritten" "$msg" | |
| 156 | + | ---- | |
| 157 | + | ||
| 158 | + | Which will produce something like this: | |
| 159 | + | ||
| 160 | + | ---- | |
| 161 | + | Fix off-by-one error | |
| 162 | + | ||
| 163 | + | Fix off-by-one error introduced in e83c5163316 (Implement better memory | |
| 164 | + | allocator, 2005-04-07). | |
| 165 | + | ||
| 166 | + | We thought we fixed this in 5569bf9bbed (Fix memory allocator, | |
| 167 | + | 2005-06-22) but that only covered 1/3 of the faulty cases. | |
| 168 | + | ---- | |
| 169 | + | ||
| 170 | + | DISCUSSION | |
| 171 | + | ---------- | |
| 172 | + | ||
| 173 | + | This command lets you format any number of revisions in any order | |
| 174 | + | through one command invocation. Consider the | |
| 175 | + | linkgit:git-last-modified[1] case from the <<examples,EXAMPLES>> section | |
| 176 | + | above: | |
| 177 | + | ||
| 178 | + | 1. There might be hundreds of files | |
| 179 | + | 2. Commits can be repeated, i.e. two or more files were last modified in | |
| 180 | + | the same commit | |
| 181 | + | ||
| 182 | + | Two widely-used commands which pretty formats commits are | |
| 183 | + | linkgit:git-log[1] and linkgit:git-show[1]. It turns out that they are | |
| 184 | + | not a good fit for the above use case. | |
| 185 | + | ||
| 186 | + | - The output of linkgit:git-last-modified[1] would have to be processed | |
| 187 | + | in stages since you need to transform the first column separately and | |
| 188 | + | then link the author to the filename. But this is surmountable. | |
| 189 | + | - You can feed each commit to `git show` or `git log --no-walk -1`. But | |
| 190 | + | that means that you need to create a process for each line. | |
| 191 | + | - Letโs say that you want to use one process, not one per line. So you | |
| 192 | + | want to feed all the commits to the command. Now you face the problem | |
| 193 | + | that you have to feed all the commits to the commands before you get | |
| 194 | + | any output (this is also the case for the `--stdin` modes). In other | |
| 195 | + | words, you cannot loop through each line, get the author for the | |
| 196 | + | commit, and output the author and the filename. You need to feed all | |
| 197 | + | the commits, get back all the output, and match the output with the | |
| 198 | + | filename. | |
| 199 | + | - But the next problem is that commands will deduplicate the input and | |
| 200 | + | only output one commit one single time only. Thus you cannot make the | |
| 201 | + | output order match the input order, since a commit could have been | |
| 202 | + | repeated in the original input. | |
| 203 | + | ||
| 204 | + | In short, it is straightforward to use these two commands if you use one | |
| 205 | + | process per line. It is much more work if you just want to use one | |
| 206 | + | process, but still doable. In contrast, this problem is solved with just | |
| 207 | + | another shell pipeline with this command. | |
| 208 | + | ||
| 209 | + | SEE ALSO | |
| 210 | + | -------- | |
| 211 | + | linkgit:git-name-rev[1], | |
| 212 | + | linkgit:git-log[1]. | |
| 213 | + | ||
| 214 | + | GIT | |
| 215 | + | --- | |
| 216 | + | Part of the linkgit:git[1] suite | |
modified Documentation/git-fsmonitor--daemon.adoc
| @@ -76,9 +76,9 @@ repositories; this may be overridden by setting `fsmonitor.allowRemote` to | |||
| 76 | 76 | correctly with all network-mounted repositories, so such use is considered | |
| 77 | 77 | experimental. | |
| 78 | 78 | ||
| 79 | - | On Mac OS, the inter-process communication (IPC) between various Git | |
| 79 | + | On Mac OS and Linux, the inter-process communication (IPC) between various Git | |
| 80 | 80 | commands and the fsmonitor daemon is done via a Unix domain socket (UDS) -- a | |
| 81 | - | special type of file -- which is supported by native Mac OS filesystems, | |
| 81 | + | special type of file -- which is supported by native Mac OS and Linux filesystems, | |
| 82 | 82 | but not on network-mounted filesystems, NTFS, or FAT32. Other filesystems | |
| 83 | 83 | may or may not have the needed support; the fsmonitor daemon is not guaranteed | |
| 84 | 84 | to work with these filesystems and such use is considered experimental. | |
| @@ -87,13 +87,33 @@ By default, the socket is created in the `.git` directory. However, if the | |||
| 87 | 87 | `.git` directory is on a network-mounted filesystem, it will instead be | |
| 88 | 88 | created at `$HOME/.git-fsmonitor-*` unless `$HOME` itself is on a | |
| 89 | 89 | network-mounted filesystem, in which case you must set the configuration | |
| 90 | - | variable `fsmonitor.socketDir` to the path of a directory on a Mac OS native | |
| 90 | + | variable `fsmonitor.socketDir` to the path of a directory on a native | |
| 91 | 91 | filesystem in which to create the socket file. | |
| 92 | 92 | ||
| 93 | 93 | If none of the above directories (`.git`, `$HOME`, or `fsmonitor.socketDir`) | |
| 94 | - | is on a native Mac OS file filesystem the fsmonitor daemon will report an | |
| 94 | + | is on a native filesystem the fsmonitor daemon will report an | |
| 95 | 95 | error that will cause the daemon and the currently running command to exit. | |
| 96 | 96 | ||
| 97 | + | LINUX CAVEATS | |
| 98 | + | ~~~~~~~~~~~~~ | |
| 99 | + | ||
| 100 | + | On Linux, the fsmonitor daemon uses inotify to monitor filesystem events. | |
| 101 | + | The inotify system has per-user limits on the number of watches that can | |
| 102 | + | be created. The default limit is typically 8192 watches per user. | |
| 103 | + | ||
| 104 | + | For large repositories with many directories, you may need to increase | |
| 105 | + | this limit. Check the current limit with: | |
| 106 | + | ||
| 107 | + | cat /proc/sys/fs/inotify/max_user_watches | |
| 108 | + | ||
| 109 | + | To temporarily increase the limit: | |
| 110 | + | ||
| 111 | + | sudo sysctl fs.inotify.max_user_watches=65536 | |
| 112 | + | ||
| 113 | + | To make the change permanent, add to `/etc/sysctl.conf`: | |
| 114 | + | ||
| 115 | + | fs.inotify.max_user_watches=65536 | |
| 116 | + | ||
| 97 | 117 | CONFIGURATION | |
| 98 | 118 | ------------- | |
| 99 | 119 | ||
modified Documentation/git-grep.adoc
| @@ -8,8 +8,8 @@ git-grep - Print lines matching a pattern | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git grep' [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp] | |
| 11 | + | [synopsis] | |
| 12 | + | git grep [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp] | |
| 13 | 13 | [-v | --invert-match] [-h|-H] [--full-name] | |
| 14 | 14 | [-E | --extended-regexp] [-G | --basic-regexp] | |
| 15 | 15 | [-P | --perl-regexp] | |
| @@ -41,139 +41,139 @@ characters. An empty string as search expression matches all lines. | |||
| 41 | 41 | ||
| 42 | 42 | OPTIONS | |
| 43 | 43 | ------- | |
| 44 | - | --cached:: | |
| 44 | + | `--cached`:: | |
| 45 | 45 | Instead of searching tracked files in the working tree, search | |
| 46 | 46 | blobs registered in the index file. | |
| 47 | 47 | ||
| 48 | - | --untracked:: | |
| 48 | + | `--untracked`:: | |
| 49 | 49 | In addition to searching in the tracked files in the working | |
| 50 | 50 | tree, search also in untracked files. | |
| 51 | 51 | ||
| 52 | - | --no-index:: | |
| 52 | + | `--no-index`:: | |
| 53 | 53 | Search files in the current directory that is not managed by Git, | |
| 54 | 54 | or by ignoring that the current directory is managed by Git. This | |
| 55 | - | is rather similar to running the regular `grep(1)` utility with its | |
| 55 | + | is rather similar to running the regular `grep`(1) utility with its | |
| 56 | 56 | `-r` option specified, but with some additional benefits, such as | |
| 57 | - | using pathspec patterns to limit paths; see the 'pathspec' entry | |
| 57 | + | using pathspec patterns to limit paths; see the `pathspec` entry | |
| 58 | 58 | in linkgit:gitglossary[7] for more information. | |
| 59 | 59 | + | |
| 60 | 60 | This option cannot be used together with `--cached` or `--untracked`. | |
| 61 | 61 | See also `grep.fallbackToNoIndex` in 'CONFIGURATION' below. | |
| 62 | 62 | ||
| 63 | - | --no-exclude-standard:: | |
| 63 | + | `--no-exclude-standard`:: | |
| 64 | 64 | Also search in ignored files by not honoring the `.gitignore` | |
| 65 | 65 | mechanism. Only useful with `--untracked`. | |
| 66 | 66 | ||
| 67 | - | --exclude-standard:: | |
| 67 | + | `--exclude-standard`:: | |
| 68 | 68 | Do not pay attention to ignored files specified via the `.gitignore` | |
| 69 | 69 | mechanism. Only useful when searching files in the current directory | |
| 70 | 70 | with `--no-index`. | |
| 71 | 71 | ||
| 72 | - | --recurse-submodules:: | |
| 72 | + | `--recurse-submodules`:: | |
| 73 | 73 | Recursively search in each submodule that is active and | |
| 74 | 74 | checked out in the repository. When used in combination with the | |
| 75 | 75 | _<tree>_ option the prefix of all submodule output will be the name of | |
| 76 | 76 | the parent project's _<tree>_ object. This option cannot be used together | |
| 77 | 77 | with `--untracked`, and it has no effect if `--no-index` is specified. | |
| 78 | 78 | ||
| 79 | - | -a:: | |
| 80 | - | --text:: | |
| 79 | + | `-a`:: | |
| 80 | + | `--text`:: | |
| 81 | 81 | Process binary files as if they were text. | |
| 82 | 82 | ||
| 83 | - | --textconv:: | |
| 83 | + | `--textconv`:: | |
| 84 | 84 | Honor textconv filter settings. | |
| 85 | 85 | ||
| 86 | - | --no-textconv:: | |
| 86 | + | `--no-textconv`:: | |
| 87 | 87 | Do not honor textconv filter settings. | |
| 88 | 88 | This is the default. | |
| 89 | 89 | ||
| 90 | - | -i:: | |
| 91 | - | --ignore-case:: | |
| 90 | + | `-i`:: | |
| 91 | + | `--ignore-case`:: | |
| 92 | 92 | Ignore case differences between the patterns and the | |
| 93 | 93 | files. | |
| 94 | 94 | ||
| 95 | - | -I:: | |
| 95 | + | `-I`:: | |
| 96 | 96 | Don't match the pattern in binary files. | |
| 97 | 97 | ||
| 98 | - | --max-depth <depth>:: | |
| 99 | - | For each <pathspec> given on command line, descend at most <depth> | |
| 98 | + | `--max-depth <depth>`:: | |
| 99 | + | For each _<pathspec>_ given on command line, descend at most _<depth>_ | |
| 100 | 100 | levels of directories. A value of -1 means no limit. | |
| 101 | - | This option is ignored if <pathspec> contains active wildcards. | |
| 101 | + | This option is ignored if _<pathspec>_ contains active wildcards. | |
| 102 | 102 | In other words if "a*" matches a directory named "a*", | |
| 103 | - | "*" is matched literally so --max-depth is still effective. | |
| 103 | + | "*" is matched literally so `--max-depth` is still effective. | |
| 104 | 104 | ||
| 105 | - | -r:: | |
| 106 | - | --recursive:: | |
| 105 | + | `-r`:: | |
| 106 | + | `--recursive`:: | |
| 107 | 107 | Same as `--max-depth=-1`; this is the default. | |
| 108 | 108 | ||
| 109 | - | --no-recursive:: | |
| 109 | + | `--no-recursive`:: | |
| 110 | 110 | Same as `--max-depth=0`. | |
| 111 | 111 | ||
| 112 | - | -w:: | |
| 113 | - | --word-regexp:: | |
| 112 | + | `-w`:: | |
| 113 | + | `--word-regexp`:: | |
| 114 | 114 | Match the pattern only at word boundary (either begin at the | |
| 115 | 115 | beginning of a line, or preceded by a non-word character; end at | |
| 116 | 116 | the end of a line or followed by a non-word character). | |
| 117 | 117 | ||
| 118 | - | -v:: | |
| 119 | - | --invert-match:: | |
| 118 | + | `-v`:: | |
| 119 | + | `--invert-match`:: | |
| 120 | 120 | Select non-matching lines. | |
| 121 | 121 | ||
| 122 | - | -h:: | |
| 123 | - | -H:: | |
| 122 | + | `-h`:: | |
| 123 | + | `-H`:: | |
| 124 | 124 | By default, the command shows the filename for each | |
| 125 | 125 | match. `-h` option is used to suppress this output. | |
| 126 | 126 | `-H` is there for completeness and does not do anything | |
| 127 | 127 | except it overrides `-h` given earlier on the command | |
| 128 | 128 | line. | |
| 129 | 129 | ||
| 130 | - | --full-name:: | |
| 130 | + | `--full-name`:: | |
| 131 | 131 | When run from a subdirectory, the command usually | |
| 132 | 132 | outputs paths relative to the current directory. This | |
| 133 | 133 | option forces paths to be output relative to the project | |
| 134 | 134 | top directory. | |
| 135 | 135 | ||
| 136 | - | -E:: | |
| 137 | - | --extended-regexp:: | |
| 138 | - | -G:: | |
| 139 | - | --basic-regexp:: | |
| 136 | + | `-E`:: | |
| 137 | + | `--extended-regexp`:: | |
| 138 | + | `-G`:: | |
| 139 | + | `--basic-regexp`:: | |
| 140 | 140 | Use POSIX extended/basic regexp for patterns. Default | |
| 141 | 141 | is to use basic regexp. | |
| 142 | 142 | ||
| 143 | - | -P:: | |
| 144 | - | --perl-regexp:: | |
| 143 | + | `-P`:: | |
| 144 | + | `--perl-regexp`:: | |
| 145 | 145 | Use Perl-compatible regular expressions for patterns. | |
| 146 | 146 | + | |
| 147 | 147 | Support for these types of regular expressions is an optional | |
| 148 | 148 | compile-time dependency. If Git wasn't compiled with support for them | |
| 149 | 149 | providing this option will cause it to die. | |
| 150 | 150 | ||
| 151 | - | -F:: | |
| 152 | - | --fixed-strings:: | |
| 151 | + | `-F`:: | |
| 152 | + | `--fixed-strings`:: | |
| 153 | 153 | Use fixed strings for patterns (don't interpret pattern | |
| 154 | 154 | as a regex). | |
| 155 | 155 | ||
| 156 | - | -n:: | |
| 157 | - | --line-number:: | |
| 156 | + | `-n`:: | |
| 157 | + | `--line-number`:: | |
| 158 | 158 | Prefix the line number to matching lines. | |
| 159 | 159 | ||
| 160 | - | --column:: | |
| 160 | + | `--column`:: | |
| 161 | 161 | Prefix the 1-indexed byte-offset of the first match from the start of the | |
| 162 | 162 | matching line. | |
| 163 | 163 | ||
| 164 | - | -l:: | |
| 165 | - | --files-with-matches:: | |
| 166 | - | --name-only:: | |
| 167 | - | -L:: | |
| 168 | - | --files-without-match:: | |
| 164 | + | `-l`:: | |
| 165 | + | `--files-with-matches`:: | |
| 166 | + | `--name-only`:: | |
| 167 | + | `-L`:: | |
| 168 | + | `--files-without-match`:: | |
| 169 | 169 | Instead of showing every matched line, show only the | |
| 170 | 170 | names of files that contain (or do not contain) matches. | |
| 171 | - | For better compatibility with 'git diff', `--name-only` is a | |
| 171 | + | For better compatibility with `git diff`, `--name-only` is a | |
| 172 | 172 | synonym for `--files-with-matches`. | |
| 173 | 173 | ||
| 174 | - | -O[<pager>]:: | |
| 175 | - | --open-files-in-pager[=<pager>]:: | |
| 176 | - | Open the matching files in the pager (not the output of 'grep'). | |
| 174 | + | `-O[<pager>]`:: | |
| 175 | + | `--open-files-in-pager[=<pager>]`:: | |
| 176 | + | Open the matching files in the pager (not the output of `grep`). | |
| 177 | 177 | If the pager happens to be "less" or "vi", and the user | |
| 178 | 178 | specified only one pattern, the first file is positioned at | |
| 179 | 179 | the first match automatically. The `pager` argument is | |
| @@ -181,65 +181,65 @@ providing this option will cause it to die. | |||
| 181 | 181 | without a space. If `pager` is unspecified, the default pager | |
| 182 | 182 | will be used (see `core.pager` in linkgit:git-config[1]). | |
| 183 | 183 | ||
| 184 | - | -z:: | |
| 185 | - | --null:: | |
| 184 | + | `-z`:: | |
| 185 | + | `--null`:: | |
| 186 | 186 | Use \0 as the delimiter for pathnames in the output, and print | |
| 187 | 187 | them verbatim. Without this option, pathnames with "unusual" | |
| 188 | 188 | characters are quoted as explained for the configuration | |
| 189 | 189 | variable `core.quotePath` (see linkgit:git-config[1]). | |
| 190 | 190 | ||
| 191 | - | -o:: | |
| 192 | - | --only-matching:: | |
| 191 | + | `-o`:: | |
| 192 | + | `--only-matching`:: | |
| 193 | 193 | Print only the matched (non-empty) parts of a matching line, with each such | |
| 194 | 194 | part on a separate output line. | |
| 195 | 195 | ||
| 196 | - | -c:: | |
| 197 | - | --count:: | |
| 196 | + | `-c`:: | |
| 197 | + | `--count`:: | |
| 198 | 198 | Instead of showing every matched line, show the number of | |
| 199 | 199 | lines that match. | |
| 200 | 200 | ||
| 201 | - | --color[=<when>]:: | |
| 201 | + | `--color[=<when>]`:: | |
| 202 | 202 | Show colored matches. | |
| 203 | - | The value must be always (the default), never, or auto. | |
| 203 | + | The value must be `always` (the default), `never`, or `auto`. | |
| 204 | 204 | ||
| 205 | - | --no-color:: | |
| 205 | + | `--no-color`:: | |
| 206 | 206 | Turn off match highlighting, even when the configuration file | |
| 207 | 207 | gives the default to color output. | |
| 208 | 208 | Same as `--color=never`. | |
| 209 | 209 | ||
| 210 | - | --break:: | |
| 210 | + | `--break`:: | |
| 211 | 211 | Print an empty line between matches from different files. | |
| 212 | 212 | ||
| 213 | - | --heading:: | |
| 213 | + | `--heading`:: | |
| 214 | 214 | Show the filename above the matches in that file instead of | |
| 215 | 215 | at the start of each shown line. | |
| 216 | 216 | ||
| 217 | - | -p:: | |
| 218 | - | --show-function:: | |
| 217 | + | `-p`:: | |
| 218 | + | `--show-function`:: | |
| 219 | 219 | Show the preceding line that contains the function name of | |
| 220 | 220 | the match, unless the matching line is a function name itself. | |
| 221 | 221 | The name is determined in the same way as `git diff` works out | |
| 222 | 222 | patch hunk headers (see 'Defining a custom hunk-header' in | |
| 223 | 223 | linkgit:gitattributes[5]). | |
| 224 | 224 | ||
| 225 | - | -<num>:: | |
| 226 | - | -C <num>:: | |
| 227 | - | --context <num>:: | |
| 228 | - | Show <num> leading and trailing lines, and place a line | |
| 225 | + | `-<num>`:: | |
| 226 | + | `-C <num>`:: | |
| 227 | + | `--context <num>`:: | |
| 228 | + | Show _<num>_ leading and trailing lines, and place a line | |
| 229 | 229 | containing `--` between contiguous groups of matches. | |
| 230 | 230 | ||
| 231 | - | -A <num>:: | |
| 232 | - | --after-context <num>:: | |
| 233 | - | Show <num> trailing lines, and place a line containing | |
| 231 | + | `-A <num>`:: | |
| 232 | + | `--after-context <num>`:: | |
| 233 | + | Show _<num>_ trailing lines, and place a line containing | |
| 234 | 234 | `--` between contiguous groups of matches. | |
| 235 | 235 | ||
| 236 | - | -B <num>:: | |
| 237 | - | --before-context <num>:: | |
| 238 | - | Show <num> leading lines, and place a line containing | |
| 236 | + | `-B <num>`:: | |
| 237 | + | `--before-context <num>`:: | |
| 238 | + | Show _<num>_ leading lines, and place a line containing | |
| 239 | 239 | `--` between contiguous groups of matches. | |
| 240 | 240 | ||
| 241 | - | -W:: | |
| 242 | - | --function-context:: | |
| 241 | + | `-W`:: | |
| 242 | + | `--function-context`:: | |
| 243 | 243 | Show the surrounding text from the previous line containing a | |
| 244 | 244 | function name up to the one before the next function name, | |
| 245 | 245 | effectively showing the whole function in which the match was | |
| @@ -247,22 +247,22 @@ providing this option will cause it to die. | |||
| 247 | 247 | `git diff` works out patch hunk headers (see 'Defining a | |
| 248 | 248 | custom hunk-header' in linkgit:gitattributes[5]). | |
| 249 | 249 | ||
| 250 | - | -m <num>:: | |
| 251 | - | --max-count <num>:: | |
| 250 | + | `-m <num>`:: | |
| 251 | + | `--max-count <num>`:: | |
| 252 | 252 | Limit the amount of matches per file. When using the `-v` or | |
| 253 | 253 | `--invert-match` option, the search stops after the specified | |
| 254 | 254 | number of non-matches. A value of -1 will return unlimited | |
| 255 | 255 | results (the default). A value of 0 will exit immediately with | |
| 256 | 256 | a non-zero status. | |
| 257 | 257 | ||
| 258 | - | --threads <num>:: | |
| 259 | - | Number of `grep` worker threads to use. See 'NOTES ON THREADS' | |
| 258 | + | `--threads <num>`:: | |
| 259 | + | Number of `grep` worker threads to use. See `NOTES ON THREADS` | |
| 260 | 260 | and `grep.threads` in 'CONFIGURATION' for more information. | |
| 261 | 261 | ||
| 262 | - | -f <file>:: | |
| 263 | - | Read patterns from <file>, one per line. | |
| 262 | + | `-f <file>`:: | |
| 263 | + | Read patterns from _<file>_, one per line. | |
| 264 | 264 | + | |
| 265 | - | Passing the pattern via <file> allows for providing a search pattern | |
| 265 | + | Passing the pattern via _<file>_ allows for providing a search pattern | |
| 266 | 266 | containing a \0. | |
| 267 | 267 | + | |
| 268 | 268 | Not all pattern types support patterns containing \0. Git will error | |
| @@ -279,44 +279,44 @@ In future versions we may learn to support patterns containing \0 for | |||
| 279 | 279 | more search backends, until then we'll die when the pattern type in | |
| 280 | 280 | question doesn't support them. | |
| 281 | 281 | ||
| 282 | - | -e:: | |
| 282 | + | `-e`:: | |
| 283 | 283 | The next parameter is the pattern. This option has to be | |
| 284 | 284 | used for patterns starting with `-` and should be used in | |
| 285 | 285 | scripts passing user input to grep. Multiple patterns are | |
| 286 | - | combined by 'or'. | |
| 286 | + | combined by `or`. | |
| 287 | 287 | ||
| 288 | - | --and:: | |
| 289 | - | --or:: | |
| 290 | - | --not:: | |
| 291 | - | ( ... ):: | |
| 288 | + | `--and`:: | |
| 289 | + | `--or`:: | |
| 290 | + | `--not`:: | |
| 291 | + | `( ... )`:: | |
| 292 | 292 | Specify how multiple patterns are combined using Boolean | |
| 293 | 293 | expressions. `--or` is the default operator. `--and` has | |
| 294 | 294 | higher precedence than `--or`. `-e` has to be used for all | |
| 295 | 295 | patterns. | |
| 296 | 296 | ||
| 297 | - | --all-match:: | |
| 297 | + | `--all-match`:: | |
| 298 | 298 | When giving multiple pattern expressions combined with `--or`, | |
| 299 | 299 | this flag is specified to limit the match to files that | |
| 300 | 300 | have lines to match all of them. | |
| 301 | 301 | ||
| 302 | - | -q:: | |
| 303 | - | --quiet:: | |
| 302 | + | `-q`:: | |
| 303 | + | `--quiet`:: | |
| 304 | 304 | Do not output matched lines; instead, exit with status 0 when | |
| 305 | 305 | there is a match and with non-zero status when there isn't. | |
| 306 | 306 | ||
| 307 | - | <tree>...:: | |
| 307 | + | `<tree>...`:: | |
| 308 | 308 | Instead of searching tracked files in the working tree, search | |
| 309 | 309 | blobs in the given trees. | |
| 310 | 310 | ||
| 311 | - | \--:: | |
| 311 | + | `--`:: | |
| 312 | 312 | Signals the end of options; the rest of the parameters | |
| 313 | - | are <pathspec> limiters. | |
| 313 | + | are _<pathspec>_ limiters. | |
| 314 | 314 | ||
| 315 | - | <pathspec>...:: | |
| 315 | + | `<pathspec>...`:: | |
| 316 | 316 | If given, limit the search to paths matching at least one pattern. | |
| 317 | - | Both leading paths match and glob(7) patterns are supported. | |
| 317 | + | Both leading paths match and `glob`(7) patterns are supported. | |
| 318 | 318 | + | |
| 319 | - | For more details about the <pathspec> syntax, see the 'pathspec' entry | |
| 319 | + | For more details about the _<pathspec>_ syntax, see the `pathspec` entry | |
| 320 | 320 | in linkgit:gitglossary[7]. | |
| 321 | 321 | ||
| 322 | 322 | EXAMPLES | |
modified Documentation/git-history.adoc
| @@ -8,6 +8,8 @@ git-history - EXPERIMENTAL: Rewrite history | |||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | 10 | [synopsis] | |
| 11 | + | git history drop <commit> [--dry-run] [--update-refs=(branches|head)] [--empty=(drop|keep|abort)] | |
| 12 | + | git history fixup <commit> [--dry-run] [--update-refs=(branches|head)] [--reedit-message] [--empty=(drop|keep|abort)] | |
| 11 | 13 | git history reword <commit> [--dry-run] [--update-refs=(branches|head)] | |
| 12 | 14 | git history split <commit> [--dry-run] [--update-refs=(branches|head)] [--] [<pathspec>...] | |
| 13 | 15 | ||
| @@ -22,8 +24,9 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. | |||
| 22 | 24 | This command is related to linkgit:git-rebase[1] in that both commands can be | |
| 23 | 25 | used to rewrite history. There are a couple of major differences though: | |
| 24 | 26 | ||
| 25 | - | * linkgit:git-history[1] can work in a bare repository as it does not need to | |
| 26 | - | touch either the index or the worktree. | |
| 27 | + | * Most subcommands of linkgit:git-history[1] can work in a bare repository as | |
| 28 | + | they do not need to touch either the index or the worktree. The `fixup` | |
| 29 | + | subcommand is an exception to this, as it reads staged changes from the index. | |
| 27 | 30 | * linkgit:git-history[1] does not execute any linkgit:githooks[5] at the | |
| 28 | 31 | current point in time. This may change in the future. | |
| 29 | 32 | * linkgit:git-history[1] by default updates all branches that are descendants | |
| @@ -48,11 +51,43 @@ conflicts. This limitation is by design as history rewrites are not intended to | |||
| 48 | 51 | be stateful operations. The limitation can be lifted once (if) Git learns about | |
| 49 | 52 | first-class conflicts. | |
| 50 | 53 | ||
| 54 | + | When using `fixup` with `--empty=drop`, dropping the root commit is not yet | |
| 55 | + | supported. Likewise, `drop` cannot remove the root commit or a merge commit. | |
| 56 | + | ||
| 51 | 57 | COMMANDS | |
| 52 | 58 | -------- | |
| 53 | 59 | ||
| 54 | 60 | The following commands are available to rewrite history in different ways: | |
| 55 | 61 | ||
| 62 | + | `drop <commit>`:: | |
| 63 | + | Remove the specified commit from the history. All descendants of the | |
| 64 | + | commit are replayed directly onto its parent. | |
| 65 | + | + | |
| 66 | + | The root commit cannot be dropped as that may lead to edge cases where refs | |
| 67 | + | end up with no commits anymore. Merge commits cannot be dropped either; see | |
| 68 | + | LIMITATIONS. | |
| 69 | + | + | |
| 70 | + | If `HEAD` points at a commit that is to be rewritten, the index and working | |
| 71 | + | tree are updated to match the new `HEAD`. The command aborts before any | |
| 72 | + | references are updated in case local modifications would be overwritten. | |
| 73 | + | + | |
| 74 | + | If replaying any descendant would result in a conflict, the command aborts | |
| 75 | + | with an error. | |
| 76 | + | ||
| 77 | + | `fixup <commit>`:: | |
| 78 | + | Apply the currently staged changes to the specified commit. This is | |
| 79 | + | similar in nature to `git commit --fixup=<commit>` followed by `git | |
| 80 | + | rebase --autosquash <commit>~`. Changes are applied to the target | |
| 81 | + | commit by performing a three-way merge between the HEAD commit, the | |
| 82 | + | target commit and the tree generated from staged changes. | |
| 83 | + | + | |
| 84 | + | The commit message and authorship of the target commit are preserved by | |
| 85 | + | default, unless you specify `--reedit-message`. | |
| 86 | + | + | |
| 87 | + | If applying the staged changes would result in a conflict, the command | |
| 88 | + | aborts with an error. All branches that are descendants of the original | |
| 89 | + | commit are updated to point to the rewritten history. | |
| 90 | + | ||
| 56 | 91 | `reword <commit>`:: | |
| 57 | 92 | Rewrite the commit message of the specified commit. All the other | |
| 58 | 93 | details of this commit remain unchanged. This command will spawn an | |
| @@ -87,6 +122,31 @@ OPTIONS | |||
| 87 | 122 | objects will be written into the repository, so applying these printed | |
| 88 | 123 | ref updates is generally safe. | |
| 89 | 124 | ||
| 125 | + | `--reedit-message`:: | |
| 126 | + | Open an editor to modify the target commit's message. | |
| 127 | + | ||
| 128 | + | `--empty=(drop|keep|abort)`:: | |
| 129 | + | Control what happens when a commit becomes empty as a result of the | |
| 130 | + | fixup. This can happen in two situations: | |
| 131 | + | + | |
| 132 | + | -- | |
| 133 | + | * The fixup target itself becomes empty because the staged changes exactly | |
| 134 | + | cancel out all changes introduced by that commit. | |
| 135 | + | ||
| 136 | + | * A descendant commit becomes empty during replay because it introduced the | |
| 137 | + | same change that was just fixed up into an ancestor. | |
| 138 | + | -- | |
| 139 | + | + | |
| 140 | + | With `drop` (the default), empty commits are removed from the rewritten | |
| 141 | + | history. Descendants of a dropped target commit are replayed directly onto | |
| 142 | + | the target's parent. Note that dropping the root commit is not supported; | |
| 143 | + | see LIMITATIONS. | |
| 144 | + | + | |
| 145 | + | With `keep`, empty commits are retained in the rewritten history as-is. | |
| 146 | + | + | |
| 147 | + | With `abort`, the command stops with an error if any commit would become | |
| 148 | + | empty. | |
| 149 | + | ||
| 90 | 150 | `--update-refs=(branches|head)`:: | |
| 91 | 151 | Control which references will be updated by the command, if any. With | |
| 92 | 152 | `branches`, all local branches that point to commits which are | |
| @@ -96,6 +156,56 @@ OPTIONS | |||
| 96 | 156 | EXAMPLES | |
| 97 | 157 | -------- | |
| 98 | 158 | ||
| 159 | + | Fixup a commit | |
| 160 | + | ~~~~~~~~~~~~~~ | |
| 161 | + | ||
| 162 | + | ---------- | |
| 163 | + | $ git log --oneline --stat | |
| 164 | + | abc1234 (HEAD -> main) third | |
| 165 | + | third.txt | 1 + | |
| 166 | + | def5678 second | |
| 167 | + | second.txt | 1 + | |
| 168 | + | ghi9012 first | |
| 169 | + | first.txt | 1 + | |
| 170 | + | ||
| 171 | + | $ echo "change" >>unrelated.txt | |
| 172 | + | $ git add unrelated.txt | |
| 173 | + | $ git history fixup ghi9012 | |
| 174 | + | ||
| 175 | + | $ git log --oneline --stat | |
| 176 | + | jkl3456 (HEAD -> main) third | |
| 177 | + | third.txt | 1 + | |
| 178 | + | mno7890 second | |
| 179 | + | second.txt | 1 + | |
| 180 | + | pqr1234 first | |
| 181 | + | first.txt | 1 + | |
| 182 | + | unrelated.txt | 1 + | |
| 183 | + | ---------- | |
| 184 | + | ||
| 185 | + | The staged addition of `unrelated.txt` has been incorporated into the `first` | |
| 186 | + | commit. All descendant commits have been replayed on top of the rewritten | |
| 187 | + | history. | |
| 188 | + | ||
| 189 | + | Drop a commit | |
| 190 | + | ~~~~~~~~~~~~~ | |
| 191 | + | ||
| 192 | + | ---------- | |
| 193 | + | $ git log --oneline | |
| 194 | + | abc1234 (HEAD -> main) third | |
| 195 | + | def5678 second | |
| 196 | + | ghi9012 first | |
| 197 | + | ||
| 198 | + | $ git history drop 'main^{/second}' | |
| 199 | + | ||
| 200 | + | $ git log --oneline | |
| 201 | + | jkl3456 (HEAD -> main) third | |
| 202 | + | ghi9012 first | |
| 203 | + | ---------- | |
| 204 | + | ||
| 205 | + | The `second` commit has been removed from the history, and `third` has been | |
| 206 | + | replayed directly on top of `first`. All branches that pointed at the dropped | |
| 207 | + | commit have been moved to its parent. | |
| 208 | + | ||
| 99 | 209 | Split a commit | |
| 100 | 210 | ~~~~~~~~~~~~~~ | |
| 101 | 211 | ||
modified Documentation/git-hook.adoc
| @@ -3,19 +3,20 @@ git-hook(1) | |||
| 3 | 3 | ||
| 4 | 4 | NAME | |
| 5 | 5 | ---- | |
| 6 | - | git-hook - Run git hooks | |
| 6 | + | git-hook - Run Git hooks | |
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | 10 | [verse] | |
| 11 | - | 'git hook' run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>] | |
| 11 | + | 'git hook' run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] [(-j|--jobs) <n>] | |
| 12 | + | <hook-name> [-- <hook-args>] | |
| 12 | 13 | 'git hook' list [--allow-unknown-hook-name] [-z] [--show-scope] <hook-name> | |
| 13 | 14 | ||
| 14 | 15 | DESCRIPTION | |
| 15 | 16 | ----------- | |
| 16 | 17 | ||
| 17 | - | A command interface for running git hooks (see linkgit:githooks[5]), | |
| 18 | - | for use by other scripted git commands. | |
| 18 | + | A command interface for running Git hooks (see linkgit:githooks[5]), | |
| 19 | + | for use by other scripted Git commands. | |
| 19 | 20 | ||
| 20 | 21 | This command parses the default configuration files for sets of configs like | |
| 21 | 22 | so: | |
| @@ -40,7 +41,7 @@ spell-checker for your commit messages, you would write a configuration like so: | |||
| 40 | 41 | ||
| 41 | 42 | With this config, when you run 'git commit', first `~/bin/linter --cpp20` will | |
| 42 | 43 | have a chance to check your files to be committed (during the `pre-commit` hook | |
| 43 | - | event`), and then `~/bin/spellchecker` will have a chance to check your commit | |
| 44 | + | event), and then `~/bin/spellchecker` will have a chance to check your commit | |
| 44 | 45 | message (during the `commit-msg` hook event). | |
| 45 | 46 | ||
| 46 | 47 | Commands are run in the order Git encounters their associated | |
| @@ -147,6 +148,23 @@ OPTIONS | |||
| 147 | 148 | mirroring the output style of `git config --show-scope`. Traditional | |
| 148 | 149 | hooks from the hookdir are unaffected. | |
| 149 | 150 | ||
| 151 | + | -j:: | |
| 152 | + | --jobs:: | |
| 153 | + | Only valid for `run`. | |
| 154 | + | + | |
| 155 | + | Specify how many hooks to run simultaneously. If this flag is not specified, | |
| 156 | + | the value of the `hook.jobs` config is used, see linkgit:git-config[1]. If | |
| 157 | + | neither is specified, defaults to 1 (serial execution). | |
| 158 | + | + | |
| 159 | + | When greater than 1, it overrides the per-hook `hook.<friendly-name>.parallel` | |
| 160 | + | setting, allowing all hooks for the event to run concurrently, even if they | |
| 161 | + | are not individually marked as parallel. | |
| 162 | + | + | |
| 163 | + | Some hooks always run sequentially regardless of this flag or the | |
| 164 | + | `hook.jobs` config, because Git knows they cannot safely run in parallel: | |
| 165 | + | `applypatch-msg`, `pre-commit`, `prepare-commit-msg`, `commit-msg`, | |
| 166 | + | `post-commit`, `post-checkout`, and `push-to-checkout`. | |
| 167 | + | ||
| 150 | 168 | WRAPPERS | |
| 151 | 169 | -------- | |
| 152 | 170 | ||
| @@ -169,7 +187,8 @@ running: | |||
| 169 | 187 | git hook run --allow-unknown-hook-name mywrapper-start-tests \ | |
| 170 | 188 | # providing something to stdin | |
| 171 | 189 | --stdin some-tempfile-123 \ | |
| 172 | - | # execute hooks in serial | |
| 190 | + | # execute multiple hooks in parallel | |
| 191 | + | --jobs 3 \ | |
| 173 | 192 | # plus some arguments of your own... | |
| 174 | 193 | -- \ | |
| 175 | 194 | --testname bar \ | |
| @@ -185,6 +204,7 @@ unintended and unsupported ways. | |||
| 185 | 204 | ||
| 186 | 205 | CONFIGURATION | |
| 187 | 206 | ------------- | |
| 207 | + | :git-hook: 1 | |
| 188 | 208 | include::config/hook.adoc[] | |
| 189 | 209 | ||
| 190 | 210 | SEE ALSO | |
modified Documentation/git-http-fetch.adoc
| @@ -48,13 +48,15 @@ commit-id:: | |||
| 48 | 48 | line (which is not expected in | |
| 49 | 49 | this case), 'git http-fetch' fetches the packfile directly at the given | |
| 50 | 50 | URL and uses index-pack to generate corresponding .idx and .keep files. | |
| 51 | - | The hash is used to determine the name of the temporary file and is | |
| 52 | - | arbitrary. The output of index-pack is printed to stdout. Requires | |
| 53 | - | --index-pack-args. | |
| 51 | + | The hash is used to determine the name of the temporary file. It need | |
| 52 | + | not be the pack hash, but it must uniquely identify the pack contents | |
| 53 | + | for resumption. The output of index-pack is printed to stdout. Requires | |
| 54 | + | one or more --index-pack-arg options. | |
| 54 | 55 | ||
| 55 | - | --index-pack-args=<args>:: | |
| 56 | - | For internal use only. The command to run on the contents of the | |
| 57 | - | downloaded pack. Arguments are URL-encoded separated by spaces. | |
| 56 | + | --index-pack-arg=<arg>:: | |
| 57 | + | For internal use only. The first instance specifies the command run on | |
| 58 | + | the contents of the downloaded pack. Subsequent instances specify its | |
| 59 | + | arguments. | |
| 58 | 60 | ||
| 59 | 61 | --recover:: | |
| 60 | 62 | Verify that everything reachable from target is fetched. Used after | |
modified Documentation/git-imap-send.adoc
| @@ -8,9 +8,9 @@ git-imap-send - Send a collection of patches from stdin to an IMAP folder | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git imap-send' [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>] | |
| 13 | - | 'git imap-send' --list | |
| 11 | + | [synopsis] | |
| 12 | + | git imap-send [-v] [-q] [--[no-]curl] [--[no-]draft] [(--folder|-f) <folder>] | |
| 13 | + | git imap-send --list | |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | DESCRIPTION | |
| @@ -24,38 +24,45 @@ that order. | |||
| 24 | 24 | ||
| 25 | 25 | Typical usage is something like: | |
| 26 | 26 | ||
| 27 | - | ------ | |
| 27 | + | ---- | |
| 28 | 28 | $ git format-patch --signoff --stdout --attach origin | git imap-send | |
| 29 | - | ------ | |
| 29 | + | ---- | |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | OPTIONS | |
| 33 | 33 | ------- | |
| 34 | 34 | ||
| 35 | - | -v:: | |
| 36 | - | --verbose:: | |
| 35 | + | `-v`:: | |
| 36 | + | `--verbose`:: | |
| 37 | 37 | Be verbose. | |
| 38 | 38 | ||
| 39 | - | -q:: | |
| 40 | - | --quiet:: | |
| 39 | + | `-q`:: | |
| 40 | + | `--quiet`:: | |
| 41 | 41 | Be quiet. | |
| 42 | 42 | ||
| 43 | - | -f <folder>:: | |
| 44 | - | --folder=<folder>:: | |
| 43 | + | `-f <folder>`:: | |
| 44 | + | `--folder=<folder>`:: | |
| 45 | 45 | Specify the folder in which the emails have to saved. | |
| 46 | 46 | For example: `--folder=[Gmail]/Drafts` or `-f INBOX/Drafts`. | |
| 47 | 47 | ||
| 48 | - | --curl:: | |
| 48 | + | `--curl`:: | |
| 49 | 49 | Use libcurl to communicate with the IMAP server, unless tunneling | |
| 50 | 50 | into it. Ignored if Git was built without the USE_CURL_FOR_IMAP_SEND | |
| 51 | 51 | option set. | |
| 52 | 52 | ||
| 53 | - | --no-curl:: | |
| 53 | + | `--no-curl`:: | |
| 54 | 54 | Talk to the IMAP server using git's own IMAP routines instead of | |
| 55 | 55 | using libcurl. Ignored if Git was built with the NO_OPENSSL option | |
| 56 | 56 | set. | |
| 57 | 57 | ||
| 58 | - | --list:: | |
| 58 | + | `--draft`:: | |
| 59 | + | `--no-draft`:: | |
| 60 | + | Mark uploaded messages with the IMAP `\Draft` flag. The default is `--no-draft`. | |
| 61 | + | + | |
| 62 | + | With libcurl, `--draft` requires version 8.13.0 or later. | |
| 63 | + | Older libcurl still uploads the message but cannot set the flag. | |
| 64 | + | ||
| 65 | + | `--list`:: | |
| 59 | 66 | Run the IMAP LIST command to output a list of all the folders present. | |
| 60 | 67 | ||
| 61 | 68 | CONFIGURATION | |
| @@ -138,13 +145,13 @@ have set up) may not be verified correctly. | |||
| 138 | 145 | ||
| 139 | 146 | Using Gmail's IMAP interface: | |
| 140 | 147 | ||
| 141 | - | --------- | |
| 148 | + | ---- | |
| 142 | 149 | [imap] | |
| 143 | 150 | folder = "[Gmail]/Drafts" | |
| 144 | 151 | host = imaps://imap.gmail.com | |
| 145 | 152 | user = user@gmail.com | |
| 146 | 153 | port = 993 | |
| 147 | - | --------- | |
| 154 | + | ---- | |
| 148 | 155 | ||
| 149 | 156 | Gmail does not allow using your regular password for `git imap-send`. | |
| 150 | 157 | If you have multi-factor authentication set up on your Gmail account, you | |
| @@ -167,32 +174,34 @@ than using app-specific passwords, and also does not enforce the need of | |||
| 167 | 174 | having multi-factor authentication. You will have to use an OAuth2.0 | |
| 168 | 175 | access token in place of your password when using this authentication. | |
| 169 | 176 | ||
| 170 | - | --------- | |
| 177 | + | ---- | |
| 171 | 178 | [imap] | |
| 172 | 179 | folder = "[Gmail]/Drafts" | |
| 173 | 180 | host = imaps://imap.gmail.com | |
| 174 | 181 | user = user@gmail.com | |
| 175 | 182 | port = 993 | |
| 176 | 183 | authmethod = OAUTHBEARER | |
| 177 | - | --------- | |
| 184 | + | ---- | |
| 178 | 185 | ||
| 179 | 186 | Using Outlook's IMAP interface: | |
| 180 | 187 | ||
| 181 | 188 | Unlike Gmail, Outlook only supports OAuth2.0 based authentication. Also, it | |
| 182 | 189 | supports only `XOAUTH2` as the mechanism. | |
| 183 | 190 | ||
| 184 | - | --------- | |
| 191 | + | ---- | |
| 185 | 192 | [imap] | |
| 186 | 193 | folder = "Drafts" | |
| 187 | 194 | host = imaps://outlook.office365.com | |
| 188 | 195 | user = user@outlook.com | |
| 189 | 196 | port = 993 | |
| 190 | 197 | authmethod = XOAUTH2 | |
| 191 | - | --------- | |
| 198 | + | ---- | |
| 192 | 199 | ||
| 193 | 200 | Once the commits are ready to be sent, run the following command: | |
| 194 | 201 | ||
| 195 | - | $ git format-patch --cover-letter -M --stdout origin/master | git imap-send | |
| 202 | + | ---- | |
| 203 | + | $ git format-patch --cover-letter -M --stdout origin/master | git imap-send | |
| 204 | + | ---- | |
| 196 | 205 | ||
| 197 | 206 | Just make sure to disable line wrapping in the email client (Gmail's web | |
| 198 | 207 | interface will wrap lines no matter what, so you need to use a real | |
| @@ -217,7 +226,7 @@ users may wish to visit this web page for more information: | |||
| 217 | 226 | ||
| 218 | 227 | SEE ALSO | |
| 219 | 228 | -------- | |
| 220 | - | linkgit:git-format-patch[1], linkgit:git-send-email[1], mbox(5) | |
| 229 | + | linkgit:git-format-patch[1], linkgit:git-send-email[1], `mbox`(5) | |
| 221 | 230 | ||
| 222 | 231 | GIT | |
| 223 | 232 | --- | |
modified Documentation/git-interpret-trailers.adoc
| @@ -3,7 +3,7 @@ git-interpret-trailers(1) | |||
| 3 | 3 | ||
| 4 | 4 | NAME | |
| 5 | 5 | ---- | |
| 6 | - | git-interpret-trailers - Add or parse structured information in commit messages | |
| 6 | + | git-interpret-trailers - Add or parse metadata in commit messages | |
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| @@ -14,9 +14,15 @@ git interpret-trailers [--in-place] [--trim-empty] | |||
| 14 | 14 | ||
| 15 | 15 | DESCRIPTION | |
| 16 | 16 | ----------- | |
| 17 | - | Add or parse _trailer_ lines that look similar to RFC 822 e-mail | |
| 18 | - | headers, at the end of the otherwise free-form part of a commit | |
| 19 | - | message. For example, in the following commit message | |
| 17 | + | Add or parse trailer metadata at the end of the otherwise | |
| 18 | + | free-form part of a commit message, or any other kind of text. | |
| 19 | + | ||
| 20 | + | A _trailer_ in its simplest form is a key-value pair with a colon as a | |
| 21 | + | separator. The _key_ consists of ASCII alphanumeric characters and | |
| 22 | + | hyphens (`-`). A _trailer block_ consists of one or more trailers. The | |
| 23 | + | trailer block needs to be preceded by a blank line, where a _blank line_ | |
| 24 | + | is either an empty or a whitespace-only line. For example, in the | |
| 25 | + | following commit message | |
| 20 | 26 | ||
| 21 | 27 | ------------------------------------------------ | |
| 22 | 28 | subject | |
| @@ -54,10 +60,18 @@ are applied to each input and the way any existing trailer in | |||
| 54 | 60 | the input is changed. They also make it possible to | |
| 55 | 61 | automatically add some trailers. | |
| 56 | 62 | ||
| 57 | - | By default, a `<key>=<value>` or `<key>:<value>` argument given | |
| 58 | - | using `--trailer` will be appended after the existing trailers only if | |
| 59 | - | the last trailer has a different (_<key>_, _<value>_) pair (or if there | |
| 60 | - | is no existing trailer). The _<key>_ and _<value>_ parts will be trimmed | |
| 63 | + | Let's consider new trailers added with `--trailer`. | |
| 64 | + | By default, the new trailer will appear at the end of the trailer block. | |
| 65 | + | Also by default, this new trailer will only be added | |
| 66 | + | if the last trailer is different to it. | |
| 67 | + | A trailer block will be created with only that trailer if a trailer | |
| 68 | + | block does not already exist. Recall that a trailer block needs to be | |
| 69 | + | preceded by a blank line, so a blank line will be inserted before the | |
| 70 | + | new trailer block in that case. | |
| 71 | + | ||
| 72 | + | This is how the new trailer is added: a `<key>=<value>` or | |
| 73 | + | `<key>:<value>` argument given using `--trailer` will be appended after | |
| 74 | + | the existing trailers. The _<key>_ and _<value>_ parts will be trimmed | |
| 61 | 75 | to remove starting and trailing whitespace, and the resulting trimmed | |
| 62 | 76 | _<key>_ and _<value>_ will appear in the output like this: | |
| 63 | 77 | ||
| @@ -68,6 +82,16 @@ key: value | |||
| 68 | 82 | This means that the trimmed _<key>_ and _<value>_ will be separated by | |
| 69 | 83 | "`:`{nbsp}" (one colon followed by one space). | |
| 70 | 84 | ||
| 85 | + | Existing trailers are extracted from the input by looking for the | |
| 86 | + | trailer block. A trailer block is a group of one or more lines that (i) | |
| 87 | + | is all trailers, or (ii) contains at least one Git-generated or | |
| 88 | + | user-configured trailer and consists of at | |
| 89 | + | least 25% trailers. | |
| 90 | + | The trailer block is by definition at the end of the commit message. | |
| 91 | + | The message in turn is either (i) at the end of the input, or (ii) the | |
| 92 | + | last non-whitespace lines before a line that starts with `---` (followed | |
| 93 | + | by a space or the end of the line). | |
| 94 | + | ||
| 71 | 95 | For convenience, a _<key-alias>_ can be configured to make using `--trailer` | |
| 72 | 96 | shorter to type on the command line. This can be configured using the | |
| 73 | 97 | `trailer.<key-alias>.key` configuration variable. The _<key-alias>_ must be a prefix | |
| @@ -81,20 +105,6 @@ trailer.sign.key "Signed-off-by: " | |||
| 81 | 105 | in your configuration, you only need to specify `--trailer="sign: foo"` | |
| 82 | 106 | on the command line instead of `--trailer="Signed-off-by: foo"`. | |
| 83 | 107 | ||
| 84 | - | By default the new trailer will appear at the end of all the existing | |
| 85 | - | trailers. If there is no existing trailer, the new trailer will appear | |
| 86 | - | at the end of the input. A blank line will be added before the new | |
| 87 | - | trailer if there isn't one already. | |
| 88 | - | ||
| 89 | - | Existing trailers are extracted from the input by looking for | |
| 90 | - | a group of one or more lines that (i) is all trailers, or (ii) contains at | |
| 91 | - | least one Git-generated or user-configured trailer and consists of at | |
| 92 | - | least 25% trailers. | |
| 93 | - | The group must be preceded by one or more empty (or whitespace-only) lines. | |
| 94 | - | The group must either be at the end of the input or be the last | |
| 95 | - | non-whitespace lines before a line that starts with `---` (followed by a | |
| 96 | - | space or the end of the line). | |
| 97 | - | ||
| 98 | 108 | When reading trailers, there can be no whitespace before or inside the | |
| 99 | 109 | _<key>_, but any number of regular space and tab characters are allowed | |
| 100 | 110 | between the _<key>_ and the separator. There can be whitespaces before, | |
| @@ -107,8 +117,22 @@ key: This is a very long value, with spaces and | |||
| 107 | 117 | newlines in it. | |
| 108 | 118 | ------------------------------------------------ | |
| 109 | 119 | ||
| 110 | - | Note that trailers do not follow (nor are they intended to follow) many of the | |
| 111 | - | rules for RFC 822 headers. For example they do not follow the encoding rule. | |
| 120 | + | OTHER RULES | |
| 121 | + | ----------- | |
| 122 | + | ||
| 123 | + | What was covered in the previous section are the rules that are relevant | |
| 124 | + | for regular use. The following points are included for completeness. | |
| 125 | + | ||
| 126 | + | -- | |
| 127 | + | * This command ignores comment lines (see `core.commentString` in | |
| 128 | + | linkgit:git-config[1]). This is for use with the `prepare-commit-msg` | |
| 129 | + | and `commit-msg` hooks. | |
| 130 | + | ||
| 131 | + | * Candidate trailer lines that have `:` as the separator, that have no | |
| 132 | + | whitespace before the value part, and that start with `//` are not | |
| 133 | + | recognized as trailers. This is to avoid accidentally interpreting | |
| 134 | + | URLs as trailers (e.g. lines that start with `https://`). | |
| 135 | + | -- | |
| 112 | 136 | ||
| 113 | 137 | OPTIONS | |
| 114 | 138 | ------- | |
| @@ -402,6 +426,29 @@ mv "\$1.new" "\$1" | |||
| 402 | 426 | $ chmod +x .git/hooks/commit-msg | |
| 403 | 427 | ------------ | |
| 404 | 428 | ||
| 429 | + | * Here we try to use three different trailer keys. But it fails because | |
| 430 | + | two of them are not recognized as trailer keys. | |
| 431 | + | + | |
| 432 | + | ---- | |
| 433 | + | $ cat msg.txt | |
| 434 | + | subject | |
| 435 | + | ||
| 436 | + | Skapad-pรฅ: some-branch | |
| 437 | + | Hash-in-v6.11: 45c12d3269fe48f22834320c782ffe86c3560f2c | |
| 438 | + | Reviewed-by: Alice <alice@example.com> | |
| 439 | + | $ git interpret-trailers --only-trailers <msg.txt | |
| 440 | + | $ | |
| 441 | + | ---- | |
| 442 | + | + | |
| 443 | + | Recall that a trailer key has to consist of only ASCII alphanumeric | |
| 444 | + | characters and hyphens, and this does not hold for the two first | |
| 445 | + | supposed trailer keys. And now none are recognized as trailers because | |
| 446 | + | the candidate trailer block has at least one non-trailer line, even | |
| 447 | + | though `Reviewed-by` is a valid trailer key. Recall that a trailer block | |
| 448 | + | has to either (i) be all trailers, or (ii) consist of at least one | |
| 449 | + | Git-generated or user-configured trailer (and some other conditions). | |
| 450 | + | And (ii) is not satisfied since we have not configured any trailer keys. | |
| 451 | + | ||
| 405 | 452 | SEE ALSO | |
| 406 | 453 | -------- | |
| 407 | 454 | linkgit:git-commit[1], linkgit:git-format-patch[1], linkgit:git-config[1] | |
modified Documentation/git-log.adoc
| @@ -36,14 +36,14 @@ OPTIONS | |||
| 36 | 36 | Print out the ref names of any commits that are shown. Possible values | |
| 37 | 37 | are: | |
| 38 | 38 | + | |
| 39 | - | ---- | |
| 39 | + | -- | |
| 40 | 40 | `short`;; the ref name prefixes `refs/heads/`, `refs/tags/` and | |
| 41 | 41 | `refs/remotes/` are not printed. | |
| 42 | 42 | `full`;; the full ref name (including prefix) is printed. | |
| 43 | - | `auto`:: if the output is going to a terminal, the ref names | |
| 43 | + | `auto`;; if the output is going to a terminal, the ref names | |
| 44 | 44 | are shown as if `short` were given, otherwise no ref names are | |
| 45 | 45 | shown. | |
| 46 | - | ---- | |
| 46 | + | -- | |
| 47 | 47 | + | |
| 48 | 48 | The option `--decorate` is short-hand for `--decorate=short`. Default to | |
| 49 | 49 | configuration value of `log.decorate` if configured, otherwise, `auto`. | |
modified Documentation/git-ls-files.adoc
| @@ -331,7 +331,7 @@ can give `--exclude-per-directory=.gitignore`, and then specify: | |||
| 331 | 331 | 1. The file specified by the `core.excludesfile` configuration | |
| 332 | 332 | variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file. | |
| 333 | 333 | ||
| 334 | - | 2. The `$GIT_DIR/info/exclude` file. | |
| 334 | + | 2. The `$GIT_COMMON_DIR/info/exclude` file. | |
| 335 | 335 | ||
| 336 | 336 | via the `--exclude-from=` option. | |
| 337 | 337 | ||
modified Documentation/git-multi-pack-index.adoc
| @@ -11,9 +11,11 @@ SYNOPSIS | |||
| 11 | 11 | [verse] | |
| 12 | 12 | 'git multi-pack-index' [<options>] write [--preferred-pack=<pack>] | |
| 13 | 13 | [--[no-]bitmap] [--[no-]incremental] [--[no-]stdin-packs] | |
| 14 | - | [--refs-snapshot=<path>] | |
| 14 | + | [--refs-snapshot=<path>] [--[no-]write-chain-file] | |
| 15 | + | [--base=<checksum>] | |
| 15 | 16 | 'git multi-pack-index' [<options>] compact [--[no-]incremental] | |
| 16 | - | [--[no-]bitmap] <from> <to> | |
| 17 | + | [--[no-]bitmap] [--base=<checksum>] [--[no-]write-chain-file] | |
| 18 | + | <from> <to> | |
| 17 | 19 | 'git multi-pack-index' [<options>] verify | |
| 18 | 20 | 'git multi-pack-index' [<options>] expire | |
| 19 | 21 | 'git multi-pack-index' [<options>] repack [--batch-size=<size>] | |
| @@ -83,6 +85,20 @@ marker). | |||
| 83 | 85 | and packs not present in an existing MIDX layer. | |
| 84 | 86 | Migrates non-incremental MIDXs to incremental ones when | |
| 85 | 87 | necessary. | |
| 88 | + | ||
| 89 | + | --[no-]write-chain-file:: | |
| 90 | + | When used with `--incremental`, write a new MIDX layer | |
| 91 | + | but do not update the multi-pack-index-chain file. | |
| 92 | + | The checksum of the new layer is printed to standard | |
| 93 | + | output, allowing the caller to assemble and write the | |
| 94 | + | chain itself. Requires `--incremental`. | |
| 95 | + | ||
| 96 | + | --base=<checksum>:: | |
| 97 | + | Specify the checksum of an existing MIDX layer to use | |
| 98 | + | as the base when writing a new incremental layer. | |
| 99 | + | The special value `none` indicates that the new layer | |
| 100 | + | should have no base (i.e., it becomes a root layer). | |
| 101 | + | Requires `--no-write-chain-file`. | |
| 86 | 102 | -- | |
| 87 | 103 | ||
| 88 | 104 | compact:: | |
| @@ -97,6 +113,18 @@ compact:: | |||
| 97 | 113 | ||
| 98 | 114 | --[no-]bitmap:: | |
| 99 | 115 | Control whether or not a multi-pack bitmap is written. | |
| 116 | + | ||
| 117 | + | --[no-]write-chain-file:: | |
| 118 | + | When used with `--incremental`, write a new compacted | |
| 119 | + | MIDX layer but do not update the multi-pack-index-chain | |
| 120 | + | file. The checksum of the new layer is printed to | |
| 121 | + | standard output. Requires `--incremental`. | |
| 122 | + | ||
| 123 | + | --base=<checksum>:: | |
| 124 | + | Specify the checksum of an existing MIDX layer to use | |
| 125 | + | as the base for the compacted result, instead of using | |
| 126 | + | the immediate parent of `<from>`. The special value | |
| 127 | + | `none` indicates that the result should have no base. | |
| 100 | 128 | -- | |
| 101 | 129 | + | |
| 102 | 130 | Note that the compact command requires writing a version-2 midx that | |
modified Documentation/git-pack-objects.adoc
| @@ -402,9 +402,13 @@ will be automatically changed to version `1`. | |||
| 402 | 402 | of filenames that cause collisions in Git's default name-hash | |
| 403 | 403 | algorithm. | |
| 404 | 404 | + | |
| 405 | - | Incompatible with `--delta-islands`, `--shallow`, or `--filter`. The | |
| 406 | - | `--use-bitmap-index` option will be ignored in the presence of | |
| 407 | - | `--path-walk.` | |
| 405 | + | When `--use-bitmap-index` is specified with `--path-walk`, a successful | |
| 406 | + | bitmap traversal is used for object enumeration, with path-walk | |
| 407 | + | remaining as the fallback traversal when the bitmap cannot satisfy the | |
| 408 | + | request. The `--path-walk` option supports the `--filter=<spec>` forms | |
| 409 | + | `blob:none`, `blob:limit=<n>`, `tree:0`, `object:type=<type>`, and | |
| 410 | + | `sparse:<oid>`. These supported filter types can be combined with the | |
| 411 | + | `combine:<spec>+<spec>` form. | |
| 408 | 412 | ||
| 409 | 413 | ||
| 410 | 414 | DELTA ISLANDS | |
modified Documentation/git-pack-refs.adoc
| @@ -7,8 +7,8 @@ git-pack-refs - Pack heads and tags for efficient repository access | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git pack-refs' [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 10 | + | [synopsis] | |
| 11 | + | git pack-refs [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 12 | 12 | ||
| 13 | 13 | DESCRIPTION | |
| 14 | 14 | ----------- | |
| @@ -52,8 +52,8 @@ BUGS | |||
| 52 | 52 | ---- | |
| 53 | 53 | ||
| 54 | 54 | Older documentation written before the packed-refs mechanism was | |
| 55 | - | introduced may still say things like ".git/refs/heads/<branch> file | |
| 56 | - | exists" when it means "branch <branch> exists". | |
| 55 | + | introduced may still say things like ".git/refs/heads/_<branch>_ file | |
| 56 | + | exists" when it means "branch _<branch>_ exists". | |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | 59 | GIT | |
modified Documentation/git-push.adoc
| @@ -18,17 +18,28 @@ git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | |||
| 18 | 18 | ||
| 19 | 19 | DESCRIPTION | |
| 20 | 20 | ----------- | |
| 21 | - | ||
| 22 | - | Updates one or more branches, tags, or other references in a remote | |
| 23 | - | repository from your local repository, and sends all necessary data | |
| 24 | - | that isn't already on the remote. | |
| 21 | + | Updates one or more branches, tags, or other references in one or more | |
| 22 | + | remote repositories from your local repository, and sends all necessary | |
| 23 | + | data that isn't already on the remote. | |
| 25 | 24 | ||
| 26 | 25 | The simplest way to push is `git push <remote> <branch>`. | |
| 27 | 26 | `git push origin main` will push the local `main` branch to the `main` | |
| 28 | 27 | branch on the remote named `origin`. | |
| 29 | 28 | ||
| 30 | - | The `<repository>` argument defaults to the upstream for the current branch, | |
| 31 | - | or `origin` if there's no configured upstream. | |
| 29 | + | You can also push to multiple remotes at once by using a remote group. | |
| 30 | + | A remote group is a named list of remotes configured via `remotes.<name>` | |
| 31 | + | in your git config: | |
| 32 | + | ||
| 33 | + | $ git config remotes.all-remotes "origin gitlab backup" | |
| 34 | + | ||
| 35 | + | Then `git push all-remotes` will push to `origin`, `gitlab`, and | |
| 36 | + | `backup` in turn, as if you had run `git push` against each one | |
| 37 | + | individually. Each remote is pushed independently using its own | |
| 38 | + | push mapping configuration. There is a `remotes.<group>` entry in | |
| 39 | + | the configuration file. (See linkgit:git-config[1]). | |
| 40 | + | ||
| 41 | + | The `<repository>` argument defaults to the upstream for the current | |
| 42 | + | branch, or `origin` if there's no configured upstream. | |
| 32 | 43 | ||
| 33 | 44 | To decide which branches, tags, or other refs to push, Git uses | |
| 34 | 45 | (in order of precedence): | |
| @@ -55,8 +66,10 @@ OPTIONS | |||
| 55 | 66 | _<repository>_:: | |
| 56 | 67 | The "remote" repository that is the destination of a push | |
| 57 | 68 | operation. This parameter can be either a URL | |
| 58 | - | (see the section <<URLS,GIT URLS>> below) or the name | |
| 59 | - | of a remote (see the section <<REMOTES,REMOTES>> below). | |
| 69 | + | (see the section <<URLS,GIT URLS>> below), the name | |
| 70 | + | of a remote (see the section <<REMOTES,REMOTES>> below), | |
| 71 | + | or the name of a remote group | |
| 72 | + | (see the section <<REMOTE-GROUPS,REMOTE GROUPS>> below). | |
| 60 | 73 | ||
| 61 | 74 | `<refspec>...`:: | |
| 62 | 75 | Specify what destination ref to update with what source object. | |
| @@ -430,6 +443,57 @@ further recursion will occur. In this case, `only` is treated as `on-demand`. | |||
| 430 | 443 | ||
| 431 | 444 | include::urls-remotes.adoc[] | |
| 432 | 445 | ||
| 446 | + | [[REMOTE-GROUPS]] | |
| 447 | + | REMOTE GROUPS | |
| 448 | + | ------------- | |
| 449 | + | ||
| 450 | + | A remote group is a named list of remotes configured via `remotes.<name>` | |
| 451 | + | in your git config: | |
| 452 | + | ||
| 453 | + | $ git config remotes.all-remotes "r1 r2 r3" | |
| 454 | + | ||
| 455 | + | When a group name is given as the `<repository>` argument, the push is | |
| 456 | + | performed to each member remote in turn. The defining principle is: | |
| 457 | + | ||
| 458 | + | git push <options> all-remotes <args> | |
| 459 | + | ||
| 460 | + | is exactly equivalent to: | |
| 461 | + | ||
| 462 | + | git push <options> r1 <args> | |
| 463 | + | git push <options> r2 <args> | |
| 464 | + | ... | |
| 465 | + | git push <options> rN <args> | |
| 466 | + | ||
| 467 | + | where r1, r2, ..., rN are the members of `all-remotes`. No special | |
| 468 | + | behaviour is added or removed โ the group is purely a shorthand for | |
| 469 | + | running the same push command against each member remote individually. | |
| 470 | + | ||
| 471 | + | When pushing to a group of more than one remote, Git spawns a separate | |
| 472 | + | `git push` subprocess for each member remote in sequence. Each subprocess | |
| 473 | + | receives the same flags and refspecs as the original invocation. This | |
| 474 | + | means that per-remote push mappings configured via `remote.<name>.push` | |
| 475 | + | and mirror mode (`remote.<name>.mirror`) are evaluated independently for | |
| 476 | + | each remote, and a mirror remote in the group cannot affect the push | |
| 477 | + | behaviour of other non-mirror remotes in the same group. | |
| 478 | + | ||
| 479 | + | The `--atomic` option is not supported for group pushes, because atomicity | |
| 480 | + | can only be guaranteed within a single transport connection to a single | |
| 481 | + | remote. Git will refuse the invocation with an error if `--atomic` is | |
| 482 | + | combined with a group name. | |
| 483 | + | ||
| 484 | + | If any member remote fails whether due to a push rejection (e.g. a | |
| 485 | + | non-fast-forward update, a server-side hook refusing a ref) or a connection | |
| 486 | + | error (e.g. the repository does not exist, authentication fails, or the | |
| 487 | + | network is unreachable), Git reports the error and continues pushing to | |
| 488 | + | the remaining remotes in the group. The overall exit code is non-zero if | |
| 489 | + | any member push fails. | |
| 490 | + | ||
| 491 | + | This means the user is responsible for ensuring that the sequence of | |
| 492 | + | individual pushes makes sense. If `git push r1`` would fail for a given | |
| 493 | + | set of options and arguments, then `git push all-remotes` will fail in | |
| 494 | + | the same way when it reaches r1. The group push does not do anything | |
| 495 | + | special to make a failing individual push succeed. | |
| 496 | + | ||
| 433 | 497 | OUTPUT | |
| 434 | 498 | ------ | |
| 435 | 499 | ||
modified Documentation/git-range-diff.adoc
| @@ -7,11 +7,11 @@ git-range-diff - Compare two commit ranges (e.g. two versions of a branch) | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git range-diff' [--color=[<when>]] [--no-color] [<diff-options>] | |
| 10 | + | [synopsis] | |
| 11 | + | git range-diff [--color=[<when>]] [--no-color] [<diff-options>] | |
| 12 | 12 | [--no-dual-color] [--creation-factor=<factor>] | |
| 13 | 13 | [--left-only | --right-only] [--diff-merges=<format>] | |
| 14 | - | [--remerge-diff] | |
| 14 | + | [--remerge-diff] [--no-notes | --notes[=<ref>]] | |
| 15 | 15 | ( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> ) | |
| 16 | 16 | [[--] <path>...] | |
| 17 | 17 | ||
| @@ -21,14 +21,14 @@ DESCRIPTION | |||
| 21 | 21 | This command shows the differences between two versions of a patch | |
| 22 | 22 | series, or more generally, two commit ranges (ignoring merge commits). | |
| 23 | 23 | ||
| 24 | - | In the presence of `<path>` arguments, these commit ranges are limited | |
| 24 | + | In the presence of _<path>_ arguments, these commit ranges are limited | |
| 25 | 25 | accordingly. | |
| 26 | 26 | ||
| 27 | 27 | To that end, it first finds pairs of commits from both commit ranges | |
| 28 | 28 | that correspond with each other. Two commits are said to correspond when | |
| 29 | 29 | the diff between their patches (i.e. the author information, the commit | |
| 30 | 30 | message and the commit diff) is reasonably small compared to the | |
| 31 | - | patches' size. See ``Algorithm`` below for details. | |
| 31 | + | patches' size. See 'Algorithm' below for details. | |
| 32 | 32 | ||
| 33 | 33 | Finally, the list of matching commits is shown in the order of the | |
| 34 | 34 | second commit range, with unmatched commits being inserted just after | |
| @@ -37,7 +37,7 @@ all of their ancestors have been shown. | |||
| 37 | 37 | There are three ways to specify the commit ranges: | |
| 38 | 38 | ||
| 39 | 39 | - `<range1> <range2>`: Either commit range can be of the form | |
| 40 | - | `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES` | |
| 40 | + | `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See 'SPECIFYING RANGES' | |
| 41 | 41 | in linkgit:gitrevisions[7] for more details. | |
| 42 | 42 | ||
| 43 | 43 | - `<rev1>...<rev2>`. This is equivalent to | |
| @@ -48,7 +48,7 @@ There are three ways to specify the commit ranges: | |||
| 48 | 48 | ||
| 49 | 49 | OPTIONS | |
| 50 | 50 | ------- | |
| 51 | - | --no-dual-color:: | |
| 51 | + | `--no-dual-color`:: | |
| 52 | 52 | When the commit diffs differ, `git range-diff` recreates the | |
| 53 | 53 | original diffs' coloring, and adds outer -/+ diff markers with | |
| 54 | 54 | the *background* being red/green to make it easier to see e.g. | |
| @@ -56,33 +56,33 @@ OPTIONS | |||
| 56 | 56 | + | |
| 57 | 57 | Additionally, the commit diff lines that are only present in the first commit | |
| 58 | 58 | range are shown "dimmed" (this can be overridden using the `color.diff.<slot>` | |
| 59 | - | config setting where `<slot>` is one of `contextDimmed`, `oldDimmed` and | |
| 59 | + | config setting where _<slot>_ is one of `contextDimmed`, `oldDimmed` and | |
| 60 | 60 | `newDimmed`), and the commit diff lines that are only present in the second | |
| 61 | 61 | commit range are shown in bold (which can be overridden using the config | |
| 62 | - | settings `color.diff.<slot>` with `<slot>` being one of `contextBold`, | |
| 62 | + | settings `color.diff.<slot>` with _<slot>_ being one of `contextBold`, | |
| 63 | 63 | `oldBold` or `newBold`). | |
| 64 | 64 | + | |
| 65 | 65 | This is known to `range-diff` as "dual coloring". Use `--no-dual-color` | |
| 66 | 66 | to revert to color all lines according to the outer diff markers | |
| 67 | 67 | (and completely ignore the inner diff when it comes to color). | |
| 68 | 68 | ||
| 69 | - | --creation-factor=<percent>:: | |
| 70 | - | Set the creation/deletion cost fudge factor to `<percent>`. | |
| 69 | + | `--creation-factor=<percent>`:: | |
| 70 | + | Set the creation/deletion cost fudge factor to _<percent>_. | |
| 71 | 71 | Defaults to 60. Try a larger value if `git range-diff` erroneously | |
| 72 | 72 | considers a large change a total rewrite (deletion of one commit | |
| 73 | 73 | and addition of another), and a smaller one in the reverse case. | |
| 74 | - | See the ``Algorithm`` section below for an explanation of why this is | |
| 74 | + | See the 'Algorithm' section below for an explanation of why this is | |
| 75 | 75 | needed. | |
| 76 | 76 | ||
| 77 | - | --left-only:: | |
| 77 | + | `--left-only`:: | |
| 78 | 78 | Suppress commits that are missing from the first specified range | |
| 79 | - | (or the "left range" when using the `<rev1>...<rev2>` format). | |
| 79 | + | (or the "left range" when using the `<rev1>...<rev2>` form). | |
| 80 | 80 | ||
| 81 | - | --right-only:: | |
| 81 | + | `--right-only`:: | |
| 82 | 82 | Suppress commits that are missing from the second specified range | |
| 83 | - | (or the "right range" when using the `<rev1>...<rev2>` format). | |
| 83 | + | (or the "right range" when using the `<rev1>...<rev2>` form). | |
| 84 | 84 | ||
| 85 | - | --diff-merges=<format>:: | |
| 85 | + | `--diff-merges=<format>`:: | |
| 86 | 86 | Instead of ignoring merge commits, generate diffs for them using the | |
| 87 | 87 | corresponding `--diff-merges=<format>` option of linkgit:git-log[1], | |
| 88 | 88 | and include them in the comparison. | |
| @@ -93,30 +93,30 @@ have produced. In other words, if a merge commit is the result of a | |||
| 93 | 93 | non-conflicting `git merge`, the `remerge` mode will represent it with an empty | |
| 94 | 94 | diff. | |
| 95 | 95 | ||
| 96 | - | --remerge-diff:: | |
| 96 | + | `--remerge-diff`:: | |
| 97 | 97 | Convenience option, equivalent to `--diff-merges=remerge`. | |
| 98 | 98 | ||
| 99 | - | --notes[=<ref>]:: | |
| 100 | - | --no-notes:: | |
| 99 | + | `--notes[=<ref>]`:: | |
| 100 | + | `--no-notes`:: | |
| 101 | 101 | This flag is passed to the `git log` program | |
| 102 | 102 | (see linkgit:git-log[1]) that generates the patches. | |
| 103 | 103 | ||
| 104 | - | <range1> <range2>:: | |
| 104 | + | `<range1> <range2>`:: | |
| 105 | 105 | Compare the commits specified by the two ranges, where | |
| 106 | - | `<range1>` is considered an older version of `<range2>`. | |
| 106 | + | _<range1>_ is considered an older version of _<range2>_. | |
| 107 | 107 | ||
| 108 | - | <rev1>...<rev2>:: | |
| 108 | + | `<rev1>...<rev2>`:: | |
| 109 | 109 | Equivalent to passing `<rev2>..<rev1>` and `<rev1>..<rev2>`. | |
| 110 | 110 | ||
| 111 | - | <base> <rev1> <rev2>:: | |
| 111 | + | `<base> <rev1> <rev2>`:: | |
| 112 | 112 | Equivalent to passing `<base>..<rev1>` and `<base>..<rev2>`. | |
| 113 | - | Note that `<base>` does not need to be the exact branch point | |
| 113 | + | Note that _<base>_ does not need to be the exact branch point | |
| 114 | 114 | of the branches. Example: after rebasing a branch `my-topic`, | |
| 115 | 115 | `git range-diff my-topic@{u} my-topic@{1} my-topic` would | |
| 116 | 116 | show the differences introduced by the rebase. | |
| 117 | 117 | ||
| 118 | 118 | `git range-diff` also accepts the regular diff options (see | |
| 119 | - | linkgit:git-diff[1]), most notably the `--color=[<when>]` and | |
| 119 | + | linkgit:git-diff[1]), most notably the `--color[=<when>]` and | |
| 120 | 120 | `--no-color` options. These options are used when generating the "diff | |
| 121 | 121 | between patches", i.e. to compare the author, commit message and diff of | |
| 122 | 122 | corresponding old/new commits. There is currently no means to tweak most of the | |
modified Documentation/git-refs.adoc
| @@ -20,6 +20,10 @@ git refs list [--count=<count>] [--shell|--perl|--python|--tcl] | |||
| 20 | 20 | [ --stdin | (<pattern>...)] | |
| 21 | 21 | git refs exists <ref> | |
| 22 | 22 | git refs optimize [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>] | |
| 23 | + | git refs create [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value> | |
| 24 | + | git refs delete [--message=<reason>] [--no-deref] <ref> [<old-value>] | |
| 25 | + | git refs update [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value> [<old-value>] | |
| 26 | + | git refs rename [--message=<reason>] <old-ref> <new-ref> | |
| 23 | 27 | ||
| 24 | 28 | DESCRIPTION | |
| 25 | 29 | ----------- | |
| @@ -31,26 +35,63 @@ COMMANDS | |||
| 31 | 35 | ||
| 32 | 36 | `migrate`:: | |
| 33 | 37 | Migrate ref store between different formats. | |
| 38 | + | + | |
| 39 | + | [WARNING] | |
| 40 | + | -- | |
| 41 | + | The ref format migration has several known limitations in its current form: | |
| 42 | + | ||
| 43 | + | * It is not possible to migrate repositories that have worktrees. | |
| 44 | + | ||
| 45 | + | * There is no way to block concurrent writes to the repository during an | |
| 46 | + | ongoing migration. Concurrent writes can lead to an inconsistent migrated | |
| 47 | + | state. Users are expected to block writes on a higher level. If your | |
| 48 | + | repository is registered for scheduled maintenance, it is recommended to | |
| 49 | + | unregister it first with linkgit:git-maintenance[1]. | |
| 50 | + | ||
| 51 | + | These limitations may eventually be lifted. | |
| 52 | + | -- | |
| 34 | 53 | ||
| 35 | 54 | `verify`:: | |
| 36 | 55 | Verify reference database consistency. | |
| 37 | 56 | ||
| 38 | - | list:: | |
| 57 | + | `list`:: | |
| 39 | 58 | List references in the repository with support for filtering, | |
| 40 | 59 | formatting, and sorting. This subcommand is an alias for | |
| 41 | 60 | linkgit:git-for-each-ref[1] and offers identical functionality. | |
| 42 | 61 | ||
| 43 | - | exists:: | |
| 62 | + | `exists`:: | |
| 44 | 63 | Check whether the given reference exists. Returns an exit code of 0 if | |
| 45 | 64 | it does, 2 if it is missing, and 1 in case looking up the reference | |
| 46 | 65 | failed with an error other than the reference being missing. This does | |
| 47 | 66 | not verify whether the reference resolves to an actual object. | |
| 48 | 67 | ||
| 49 | - | optimize:: | |
| 68 | + | `optimize`:: | |
| 50 | 69 | Optimizes references to improve repository performance and reduce disk | |
| 51 | 70 | usage. This subcommand is an alias for linkgit:git-pack-refs[1] and | |
| 52 | 71 | offers identical functionality. | |
| 53 | 72 | ||
| 73 | + | `create`:: | |
| 74 | + | Create the given reference, which must not already exist, pointing at | |
| 75 | + | `<new-value>`. | |
| 76 | + | ||
| 77 | + | `delete`:: | |
| 78 | + | Delete the given reference. This subcommand mirrors `git update-ref -d` | |
| 79 | + | (see linkgit:git-update-ref[1]). When `<old-value>` is given, the | |
| 80 | + | reference is only deleted after verifying that it currently contains | |
| 81 | + | `<old-value>`. | |
| 82 | + | ||
| 83 | + | `update`:: | |
| 84 | + | Update the given reference to point at `<new-value>`. If `<old-value>` | |
| 85 | + | is given, the reference is only updated after verifying that it | |
| 86 | + | currently contains `<old-value>`. As a special case, an all-zeroes | |
| 87 | + | `<new-value>` deletes the branch, whereas an all-zeroes `<old-value>` | |
| 88 | + | ensures that the branch does not yet exist. | |
| 89 | + | ||
| 90 | + | `rename`:: | |
| 91 | + | Rename the reference `<oldref>` to `<newref>`. The old reference must | |
| 92 | + | exist and the new reference must not yet exist, and both must have a | |
| 93 | + | well-formed name (see linkgit:git-check-ref-format[1]). | |
| 94 | + | ||
| 54 | 95 | OPTIONS | |
| 55 | 96 | ------- | |
| 56 | 97 | ||
| @@ -90,20 +131,19 @@ The following options are specific to 'git refs optimize': | |||
| 90 | 131 | ||
| 91 | 132 | include::pack-refs-options.adoc[] | |
| 92 | 133 | ||
| 93 | - | KNOWN LIMITATIONS | |
| 94 | - | ----------------- | |
| 134 | + | The following options are specific to commands which write references: | |
| 95 | 135 | ||
| 96 | - | The ref format migration has several known limitations in its current form: | |
| 136 | + | `--create-reflog`:: | |
| 137 | + | Create a reflog for the reference even if one would not ordinarily be | |
| 138 | + | created. | |
| 97 | 139 | ||
| 98 | - | * It is not possible to migrate repositories that have worktrees. | |
| 140 | + | `--message=<reason>`:: | |
| 141 | + | Use the given <reason> string for the reflog entry associated with the | |
| 142 | + | update. An empty message is rejected. | |
| 99 | 143 | ||
| 100 | - | * There is no way to block concurrent writes to the repository during an | |
| 101 | - | ongoing migration. Concurrent writes can lead to an inconsistent migrated | |
| 102 | - | state. Users are expected to block writes on a higher level. If your | |
| 103 | - | repository is registered for scheduled maintenance, it is recommended to | |
| 104 | - | unregister it first with git-maintenance(1). | |
| 105 | - | ||
| 106 | - | These limitations may eventually be lifted. | |
| 144 | + | `--no-deref`:: | |
| 145 | + | Operate on <ref> itself rather than the reference it points to via a | |
| 146 | + | symbolic ref. | |
| 107 | 147 | ||
| 108 | 148 | GIT | |
| 109 | 149 | --- | |
modified Documentation/git-repack.adoc
| @@ -11,7 +11,8 @@ SYNOPSIS | |||
| 11 | 11 | [verse] | |
| 12 | 12 | 'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m] | |
| 13 | 13 | [--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>] | |
| 14 | - | [--write-midx] [--name-hash-version=<n>] [--path-walk] | |
| 14 | + | [--write-midx[=<mode>]] [--name-hash-version=<n>] [--path-walk] | |
| 15 | + | [--filter=<filter-spec>] [--drop-filtered [--dry-run]] | |
| 15 | 16 | ||
| 16 | 17 | DESCRIPTION | |
| 17 | 18 | ----------- | |
| @@ -182,6 +183,42 @@ depth is 4095. | |||
| 182 | 183 | `objects` and `objects/info/alternates` sections of | |
| 183 | 184 | linkgit:gitrepository-layout[5]. | |
| 184 | 185 | ||
| 186 | + | --drop-filtered:: | |
| 187 | + | Delete the local objects that match the `--filter` specification | |
| 188 | + | instead of keeping them in a separate packfile, reclaiming the | |
| 189 | + | disk space they occupy. This is intended for partial clones, | |
| 190 | + | where the filtered objects are promisor objects that remain | |
| 191 | + | recoverable from the promisor remote and are lazily re-fetched | |
| 192 | + | on demand when they are next needed. | |
| 193 | + | + | |
| 194 | + | Only large blobs are supported for now, so `--filter=blob:limit=<n>` | |
| 195 | + | is currently the only accepted filter. Because dropped objects must be | |
| 196 | + | recoverable, this option requires a promisor remote to be configured | |
| 197 | + | and refuses to run otherwise. | |
| 198 | + | + | |
| 199 | + | This option requires `-a`, and implies `-d`: the objects are dropped by | |
| 200 | + | rebuilding the promisor pack without them and then removing the now | |
| 201 | + | redundant old packs, so the redundant packs must be deleted for the | |
| 202 | + | space to actually be reclaimed. It is incompatible with `--filter-to` | |
| 203 | + | and with bitmap writing (`-b`/`--write-bitmap-index`), since filtering | |
| 204 | + | breaks the single-pack closure that bitmaps require. A bitmap setting | |
| 205 | + | coming from configuration is silently disabled for the duration of the | |
| 206 | + | command. | |
| 207 | + | + | |
| 208 | + | As a convenience, since dropped objects remain recoverable by lazy fetch, | |
| 209 | + | `--drop-filtered` refuses to run while another operation | |
| 210 | + | (merge, rebase, am, cherry-pick, revert, or bisect) is in progress, to | |
| 211 | + | avoid a surprising network fetch mid-operation, and refuses to drop any | |
| 212 | + | blob that the current index references, since such a blob would only be | |
| 213 | + | lazily re-fetched by the next command that inspects the working tree. | |
| 214 | + | These checks are skipped in bare repositories, which have neither a | |
| 215 | + | working tree nor an index. | |
| 216 | + | ||
| 217 | + | --dry-run:: | |
| 218 | + | Only meaningful with `--drop-filtered`. List the objects that | |
| 219 | + | would be dropped, one object ID per line, without rebuilding any | |
| 220 | + | pack or deleting anything. | |
| 221 | + | ||
| 185 | 222 | -b:: | |
| 186 | 223 | --write-bitmap-index:: | |
| 187 | 224 | Write a reachability bitmap index as part of the repack. This | |
| @@ -250,9 +287,47 @@ pack as the preferred pack for object selection by the MIDX (see | |||
| 250 | 287 | linkgit:git-multi-pack-index[1]). | |
| 251 | 288 | ||
| 252 | 289 | -m:: | |
| 253 | - | --write-midx:: | |
| 290 | + | --write-midx[=<mode>]:: | |
| 254 | 291 | Write a multi-pack index (see linkgit:git-multi-pack-index[1]) | |
| 255 | - | containing the non-redundant packs. | |
| 292 | + | containing the non-redundant packs. The following modes are | |
| 293 | + | available: | |
| 294 | + | + | |
| 295 | + | -- | |
| 296 | + | `default`;; | |
| 297 | + | Write a single MIDX covering all packs. This is the | |
| 298 | + | default when `--write-midx` is given without an | |
| 299 | + | explicit mode. | |
| 300 | + | ||
| 301 | + | `incremental`;; | |
| 302 | + | Write an incremental MIDX chain instead of a single | |
| 303 | + | flat MIDX. | |
| 304 | + | + | |
| 305 | + | Without `--geometric`, a new MIDX layer is appended to the existing | |
| 306 | + | chain (or a new chain is started) containing whatever packs were written | |
| 307 | + | by the repack. Existing layers are preserved as-is. | |
| 308 | + | + | |
| 309 | + | When combined with `--geometric`, the incremental mode maintains a chain | |
| 310 | + | of MIDX layers that is compacted over time using a geometric merging | |
| 311 | + | strategy. Each repack creates a new tip layer containing the newly | |
| 312 | + | written pack(s). Adjacent layers are then merged whenever the newer | |
| 313 | + | layer's object count exceeds `1/repack.midxSplitFactor` of the next | |
| 314 | + | deeper layer's count. Layers that do not meet this condition are | |
| 315 | + | retained as-is. | |
| 316 | + | + | |
| 317 | + | The result is that newer (tip) layers tend to contain many small packs | |
| 318 | + | with relatively few objects, while older (deeper) layers contain fewer, | |
| 319 | + | larger packs covering more objects. Because compaction is driven by the | |
| 320 | + | tip of the chain, newer layers are also rewritten more frequently than | |
| 321 | + | older ones, which are only touched when enough objects have accumulated | |
| 322 | + | to justify merging into them. This keeps the total number of layers | |
| 323 | + | logarithmic relative to the total number of objects. | |
| 324 | + | + | |
| 325 | + | Only packs in the tip MIDX layer are considered as candidates for the | |
| 326 | + | geometric repack; packs in deeper layers are left untouched. If the tip | |
| 327 | + | layer contains fewer packs than `repack.midxNewLayerThreshold`, those | |
| 328 | + | packs are excluded from the geometry entirely, and a new layer is | |
| 329 | + | created for any new pack(s) without disturbing the existing chain. | |
| 330 | + | -- | |
| 256 | 331 | ||
| 257 | 332 | --name-hash-version=<n>:: | |
| 258 | 333 | Provide this argument to the underlying `git pack-objects` process. | |
modified Documentation/git-replace.adoc
| @@ -145,6 +145,13 @@ commit instead of the replaced commit. | |||
| 145 | 145 | There may be other problems when using 'git rev-list' related to | |
| 146 | 146 | pending objects. | |
| 147 | 147 | ||
| 148 | + | CAVEATS | |
| 149 | + | ------- | |
| 150 | + | ||
| 151 | + | The existence of replace objects or commit grafts turns off reading or | |
| 152 | + | writing to the commit-graph, which can cause performance issues. See | |
| 153 | + | linkgit:git-commit-graph[1]. | |
| 154 | + | ||
| 148 | 155 | SEE ALSO | |
| 149 | 156 | -------- | |
| 150 | 157 | linkgit:git-hash-object[1] | |
modified Documentation/git-replay.adoc
| @@ -10,7 +10,7 @@ SYNOPSIS | |||
| 10 | 10 | -------- | |
| 11 | 11 | [verse] | |
| 12 | 12 | (EXPERIMENTAL!) 'git replay' ([--contained] --onto=<newbase> | --advance=<branch> | --revert=<branch>) | |
| 13 | - | [--ref=<ref>] [--ref-action=<mode>] <revision-range> | |
| 13 | + | [--ref=<ref>] [--ref-action=<mode>] [--linearize] <revision-range> | |
| 14 | 14 | ||
| 15 | 15 | DESCRIPTION | |
| 16 | 16 | ----------- | |
| @@ -80,14 +80,32 @@ incompatible with `--contained` (which is a modifier for `--onto` only). | |||
| 80 | 80 | Control how references are updated. The mode can be: | |
| 81 | 81 | + | |
| 82 | 82 | -- | |
| 83 | - | * `update` (default): Update refs directly using an atomic transaction. | |
| 84 | - | All refs are updated or none are (all-or-nothing behavior). | |
| 85 | - | * `print`: Output update-ref commands for pipeline use. This is the | |
| 86 | - | traditional behavior where output can be piped to `git update-ref --stdin`. | |
| 83 | + | //// | |
| 84 | + | Expanded description list compared to 'replay.refAction'. | |
| 85 | + | //// | |
| 86 | + | `update`;; (default) Update refs directly using an atomic transaction. | |
| 87 | + | All refs are updated or none are (all-or-nothing behavior). | |
| 88 | + | `print`;; Output update-ref commands for pipeline use. This is the | |
| 89 | + | traditional behavior where output can be piped to `git update-ref --stdin`. | |
| 87 | 90 | -- | |
| 88 | 91 | + | |
| 89 | 92 | The default mode can be configured via the `replay.refAction` configuration variable. | |
| 90 | 93 | ||
| 94 | + | --linearize:: | |
| 95 | + | In this mode, each replayed commit is stacked on top of the | |
| 96 | + | previously replayed one, so all replayed commits are flattened into | |
| 97 | + | a single linear history. | |
| 98 | + | + | |
| 99 | + | When a merge commit is encountered, all commits in the range reachable | |
| 100 | + | from the merge commit are replayed into the linear history, and the | |
| 101 | + | merge commit itself is dropped. A ref that pointed to a merge commit is | |
| 102 | + | updated to the merge's last replayed ancestor. (This matches the | |
| 103 | + | behavior of git-rebase(1)'s `--no-rebase-merges` option.) | |
| 104 | + | + | |
| 105 | + | `--linearize` cannot be combined with multiple branches or with | |
| 106 | + | `--contained`. To linearize several branches, replay them in separate | |
| 107 | + | `git replay` invocations. | |
| 108 | + | ||
| 91 | 109 | <revision-range>:: | |
| 92 | 110 | Range of commits to replay; see "Specifying Ranges" in | |
| 93 | 111 | linkgit:git-rev-parse[1]. In `--advance=<branch>` or | |
| @@ -209,6 +227,11 @@ This replays the range `aabbcc..ddeeff` onto commit `112233` and updates | |||
| 209 | 227 | `refs/heads/mybranch` to point at the result. This can be useful when you want | |
| 210 | 228 | to use bare commit IDs instead of branch names. | |
| 211 | 229 | ||
| 230 | + | CONFIGURATION | |
| 231 | + | ------------- | |
| 232 | + | :git-replay: 1 | |
| 233 | + | include::config/replay.adoc[] | |
| 234 | + | ||
| 212 | 235 | GIT | |
| 213 | 236 | --- | |
| 214 | 237 | Part of the linkgit:git[1] suite | |
modified Documentation/git-repo.adoc
| @@ -104,6 +104,21 @@ values that they return: | |||
| 104 | 104 | `object.format`:: | |
| 105 | 105 | The object format (hash algorithm) used in the repository. | |
| 106 | 106 | ||
| 107 | + | `path.commondir.absolute`:: | |
| 108 | + | The canonical absolute path to the Git repository's common | |
| 109 | + | directory (the shared `.git` directory containing objects, | |
| 110 | + | refs, and global configuration). | |
| 111 | + | ||
| 112 | + | `path.commondir.relative`:: | |
| 113 | + | The path to the Git repository's common directory relative to | |
| 114 | + | the current working directory. | |
| 115 | + | ||
| 116 | + | `path.gitdir.absolute`:: | |
| 117 | + | The canonical absolute path to the Git repository directory (the `.git` directory). | |
| 118 | + | ||
| 119 | + | `path.gitdir.relative`:: | |
| 120 | + | The path to the Git repository directory relative to the current working directory. | |
| 121 | + | ||
| 107 | 122 | `references.format`:: | |
| 108 | 123 | The reference storage format. The valid values are: | |
| 109 | 124 | + | |
modified Documentation/git-request-pull.adoc
| @@ -7,8 +7,8 @@ git-request-pull - Generates a summary of pending changes | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git request-pull' [-p] <start> <URL> [<end>] | |
| 10 | + | [synopsis] | |
| 11 | + | git request-pull [-p] <start> <URL> [<end>] | |
| 12 | 12 | ||
| 13 | 13 | DESCRIPTION | |
| 14 | 14 | ----------- | |
| @@ -19,28 +19,28 @@ begins with the branch description, summarizes | |||
| 19 | 19 | the changes, and indicates from where they can be pulled. | |
| 20 | 20 | ||
| 21 | 21 | The upstream project is expected to have the commit named by | |
| 22 | - | `<start>` and the output asks it to integrate the changes you made | |
| 23 | - | since that commit, up to the commit named by `<end>`, by visiting | |
| 24 | - | the repository named by `<URL>`. | |
| 22 | + | _<start>_ and the output asks it to integrate the changes you made | |
| 23 | + | since that commit, up to the commit named by _<end>_, by visiting | |
| 24 | + | the repository named by _<URL>_. | |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | OPTIONS | |
| 28 | 28 | ------- | |
| 29 | - | -p:: | |
| 29 | + | `-p`:: | |
| 30 | 30 | Include patch text in the output. | |
| 31 | 31 | ||
| 32 | - | <start>:: | |
| 32 | + | _<start>_:: | |
| 33 | 33 | Commit to start at. This names a commit that is already in | |
| 34 | 34 | the upstream history. | |
| 35 | 35 | ||
| 36 | - | <URL>:: | |
| 36 | + | _<URL>_:: | |
| 37 | 37 | The repository URL to be pulled from. | |
| 38 | 38 | ||
| 39 | - | <end>:: | |
| 40 | - | Commit to end at (defaults to HEAD). This names the commit | |
| 39 | + | _<end>_:: | |
| 40 | + | Commit to end at (defaults to `HEAD`). This names the commit | |
| 41 | 41 | at the tip of the history you are asking to be pulled. | |
| 42 | 42 | + | |
| 43 | - | When the repository named by `<URL>` has the commit at a tip of a | |
| 43 | + | When the repository named by _<URL>_ has the commit at a tip of a | |
| 44 | 44 | ref that is different from the ref you have locally, you can use the | |
| 45 | 45 | `<local>:<remote>` syntax, to have its local name, a colon `:`, and | |
| 46 | 46 | its remote name. | |
| @@ -54,11 +54,15 @@ the `v1.0` release, and want it to be integrated into the project. | |||
| 54 | 54 | First you push that change to your public repository for others to | |
| 55 | 55 | see: | |
| 56 | 56 | ||
| 57 | - | git push https://git.ko.xz/project master | |
| 57 | + | ---- | |
| 58 | + | git push https://git.ko.xz/project master | |
| 59 | + | ---- | |
| 58 | 60 | ||
| 59 | 61 | Then, you run this command: | |
| 60 | 62 | ||
| 61 | - | git request-pull v1.0 https://git.ko.xz/project master | |
| 63 | + | ---- | |
| 64 | + | git request-pull v1.0 https://git.ko.xz/project master | |
| 65 | + | ---- | |
| 62 | 66 | ||
| 63 | 67 | which will produce a request to the upstream, summarizing the | |
| 64 | 68 | changes between the `v1.0` release and your `master`, to pull it | |
| @@ -67,11 +71,15 @@ from your public repository. | |||
| 67 | 71 | If you pushed your change to a branch whose name is different from | |
| 68 | 72 | the one you have locally, e.g. | |
| 69 | 73 | ||
| 70 | - | git push https://git.ko.xz/project master:for-linus | |
| 74 | + | ---- | |
| 75 | + | git push https://git.ko.xz/project master:for-linus | |
| 76 | + | ---- | |
| 71 | 77 | ||
| 72 | 78 | then you can ask that to be pulled with | |
| 73 | 79 | ||
| 74 | - | git request-pull v1.0 https://git.ko.xz/project master:for-linus | |
| 80 | + | ---- | |
| 81 | + | git request-pull v1.0 https://git.ko.xz/project master:for-linus | |
| 82 | + | ---- | |
| 75 | 83 | ||
| 76 | 84 | ||
| 77 | 85 | GIT | |
modified Documentation/git-restore.adoc
| @@ -41,7 +41,7 @@ given, otherwise from the index. | |||
| 41 | 41 | + | |
| 42 | 42 | As a special case, you may use `"<rev-A>...<rev-B>"` as a shortcut for the | |
| 43 | 43 | merge base of _<rev-A>_ and _<rev-B>_ if there is exactly one merge base. You can | |
| 44 | - | leave out at most one of _<rev-A>__ and _<rev-B>_, in which case it defaults to `HEAD`. | |
| 44 | + | leave out at most one of _<rev-A>_ and _<rev-B>_, in which case it defaults to `HEAD`. | |
| 45 | 45 | ||
| 46 | 46 | `-p`:: | |
| 47 | 47 | `--patch`:: | |
modified Documentation/git-send-email.adoc
| @@ -8,11 +8,11 @@ git-send-email - Send a collection of patches as emails | |||
| 8 | 8 | ||
| 9 | 9 | SYNOPSIS | |
| 10 | 10 | -------- | |
| 11 | - | [verse] | |
| 12 | - | 'git send-email' [<options>] (<file>|<directory>)... | |
| 13 | - | 'git send-email' [<options>] <format-patch-options> | |
| 14 | - | 'git send-email' --dump-aliases | |
| 15 | - | 'git send-email' --translate-aliases | |
| 11 | + | [synopsis] | |
| 12 | + | git send-email [<options>] (<file>|<directory>)... | |
| 13 | + | git send-email [<options>] <format-patch-options> | |
| 14 | + | git send-email --dump-aliases | |
| 15 | + | git send-email --translate-aliases | |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | DESCRIPTION | |
| @@ -48,24 +48,24 @@ OPTIONS | |||
| 48 | 48 | Composing | |
| 49 | 49 | ~~~~~~~~~ | |
| 50 | 50 | ||
| 51 | - | --annotate:: | |
| 51 | + | `--annotate`:: | |
| 52 | 52 | Review and edit each patch you're about to send. Default is the value | |
| 53 | 53 | of `sendemail.annotate`. See the CONFIGURATION section for | |
| 54 | 54 | `sendemail.multiEdit`. | |
| 55 | 55 | ||
| 56 | - | --bcc=<address>,...:: | |
| 56 | + | `--bcc=<address>,...`:: | |
| 57 | 57 | Specify a `Bcc:` value for each email. Default is the value of | |
| 58 | 58 | `sendemail.bcc`. | |
| 59 | 59 | + | |
| 60 | 60 | This option may be specified multiple times. | |
| 61 | 61 | ||
| 62 | - | --cc=<address>,...:: | |
| 62 | + | `--cc=<address>,...`:: | |
| 63 | 63 | Specify a starting `Cc:` value for each email. | |
| 64 | 64 | Default is the value of `sendemail.cc`. | |
| 65 | 65 | + | |
| 66 | 66 | This option may be specified multiple times. | |
| 67 | 67 | ||
| 68 | - | --compose:: | |
| 68 | + | `--compose`:: | |
| 69 | 69 | Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1]) | |
| 70 | 70 | to edit an introductory message for the patch series. | |
| 71 | 71 | + | |
| @@ -80,7 +80,7 @@ Missing `From` or `In-Reply-To` headers will be prompted for. | |||
| 80 | 80 | + | |
| 81 | 81 | See the CONFIGURATION section for `sendemail.multiEdit`. | |
| 82 | 82 | ||
| 83 | - | --from=<address>:: | |
| 83 | + | `--from=<address>`:: | |
| 84 | 84 | Specify the sender of the emails. If not specified on the command line, | |
| 85 | 85 | the value of the `sendemail.from` configuration option is used. If | |
| 86 | 86 | neither the command-line option nor `sendemail.from` are set, then the | |
| @@ -88,12 +88,12 @@ See the CONFIGURATION section for `sendemail.multiEdit`. | |||
| 88 | 88 | the value of `GIT_AUTHOR_IDENT`, or `GIT_COMMITTER_IDENT` if that is not | |
| 89 | 89 | set, as returned by `git var -l`. | |
| 90 | 90 | ||
| 91 | - | --reply-to=<address>:: | |
| 91 | + | `--reply-to=<address>`:: | |
| 92 | 92 | Specify the address where replies from recipients should go to. | |
| 93 | 93 | Use this if replies to messages should go to another address than what | |
| 94 | 94 | is specified with the `--from` parameter. | |
| 95 | 95 | ||
| 96 | - | --in-reply-to=<identifier>:: | |
| 96 | + | `--in-reply-to=<identifier>`:: | |
| 97 | 97 | Make the first mail (or all the mails with `--no-thread`) appear as a | |
| 98 | 98 | reply to the given Message-ID, which avoids breaking threads to | |
| 99 | 99 | provide a new patch series. | |
| @@ -115,8 +115,8 @@ illustration below where `[PATCH v2 0/3]` is in reply to `[PATCH 0/2]`: | |||
| 115 | 115 | Only necessary if `--compose` is also set. If `--compose` | |
| 116 | 116 | is not set, this will be prompted for. | |
| 117 | 117 | ||
| 118 | - | --outlook-id-fix:: | |
| 119 | - | --no-outlook-id-fix:: | |
| 118 | + | `--outlook-id-fix`:: | |
| 119 | + | `--no-outlook-id-fix`:: | |
| 120 | 120 | Microsoft Outlook SMTP servers discard the Message-ID sent via email and | |
| 121 | 121 | assign a new random Message-ID, thus breaking threads. | |
| 122 | 122 | + | |
| @@ -126,15 +126,15 @@ threading. Use it only when you know that the server reports the | |||
| 126 | 126 | rewritten Message-ID the same way as Outlook servers do. | |
| 127 | 127 | + | |
| 128 | 128 | Without this option specified, the fix is done by default when talking | |
| 129 | - | to 'smtp.office365.com' or 'smtp-mail.outlook.com'. Use | |
| 129 | + | to `smtp.office365.com` or `smtp-mail.outlook.com`. Use | |
| 130 | 130 | `--no-outlook-id-fix` to disable even when talking to these two servers. | |
| 131 | 131 | ||
| 132 | - | --subject=<string>:: | |
| 132 | + | `--subject=<string>`:: | |
| 133 | 133 | Specify the initial subject of the email thread. | |
| 134 | 134 | Only necessary if `--compose` is also set. If `--compose` | |
| 135 | 135 | is not set, this will be prompted for. | |
| 136 | 136 | ||
| 137 | - | --to=<address>,...:: | |
| 137 | + | `--to=<address>,...`:: | |
| 138 | 138 | Specify the primary recipient of the emails generated. Generally, this | |
| 139 | 139 | will be the upstream maintainer of the project involved. Default is the | |
| 140 | 140 | value of the `sendemail.to` configuration value; if that is unspecified, | |
| @@ -142,20 +142,20 @@ to 'smtp.office365.com' or 'smtp-mail.outlook.com'. Use | |||
| 142 | 142 | + | |
| 143 | 143 | This option may be specified multiple times. | |
| 144 | 144 | ||
| 145 | - | --8bit-encoding=<encoding>:: | |
| 145 | + | `--8bit-encoding=<encoding>`:: | |
| 146 | 146 | When encountering a non-ASCII message or subject that does not | |
| 147 | 147 | declare its encoding, add headers/quoting to indicate it is | |
| 148 | - | encoded in <encoding>. Default is the value of the | |
| 148 | + | encoded in _<encoding>_. Default is the value of the | |
| 149 | 149 | `sendemail.assume8bitEncoding`; if that is unspecified, this | |
| 150 | 150 | will be prompted for if any non-ASCII files are encountered. | |
| 151 | 151 | + | |
| 152 | 152 | Note that no attempts whatsoever are made to validate the encoding. | |
| 153 | 153 | ||
| 154 | - | --compose-encoding=<encoding>:: | |
| 154 | + | `--compose-encoding=<encoding>`:: | |
| 155 | 155 | Specify encoding of compose message. Default is the value of the | |
| 156 | 156 | `sendemail.composeEncoding`; if that is unspecified, UTF-8 is assumed. | |
| 157 | 157 | ||
| 158 | - | --transfer-encoding=(7bit|8bit|quoted-printable|base64|auto):: | |
| 158 | + | `--transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)`:: | |
| 159 | 159 | Specify the transfer encoding to be used to send the message over SMTP. | |
| 160 | 160 | `7bit` will fail upon encountering a non-ASCII message. `quoted-printable` | |
| 161 | 161 | can be useful when the repository contains files that contain carriage | |
| @@ -167,8 +167,8 @@ Note that no attempts whatsoever are made to validate the encoding. | |||
| 167 | 167 | Default is the value of the `sendemail.transferEncoding` configuration | |
| 168 | 168 | value; if that is unspecified, default to `auto`. | |
| 169 | 169 | ||
| 170 | - | --xmailer:: | |
| 171 | - | --no-xmailer:: | |
| 170 | + | `--xmailer`:: | |
| 171 | + | `--no-xmailer`:: | |
| 172 | 172 | Add (or prevent adding) the `X-Mailer:` header. By default, | |
| 173 | 173 | the header is added, but it can be turned off by setting the | |
| 174 | 174 | `sendemail.xmailer` configuration variable to `false`. | |
| @@ -176,7 +176,7 @@ value; if that is unspecified, default to `auto`. | |||
| 176 | 176 | Sending | |
| 177 | 177 | ~~~~~~~ | |
| 178 | 178 | ||
| 179 | - | --envelope-sender=<address>:: | |
| 179 | + | `--envelope-sender=<address>`:: | |
| 180 | 180 | Specify the envelope sender used to send the emails. | |
| 181 | 181 | This is useful if your default address is not the address that is | |
| 182 | 182 | subscribed to a list. In order to use the `From` address, set the | |
| @@ -185,7 +185,7 @@ Sending | |||
| 185 | 185 | `sendemail.envelopeSender` configuration variable; if that is | |
| 186 | 186 | unspecified, choosing the envelope sender is left to your MTA. | |
| 187 | 187 | ||
| 188 | - | --sendmail-cmd=<command>:: | |
| 188 | + | `--sendmail-cmd=<command>`:: | |
| 189 | 189 | Specify a command to run to send the email. The command should | |
| 190 | 190 | be sendmail-like; specifically, it must support the `-i` option. | |
| 191 | 191 | The command will be executed in the shell if necessary. Default | |
| @@ -193,7 +193,7 @@ Sending | |||
| 193 | 193 | `--smtp-server` is also unspecified, `git send-email` will search | |
| 194 | 194 | for `sendmail` in `/usr/sbin`, `/usr/lib` and `$PATH`. | |
| 195 | 195 | ||
| 196 | - | --smtp-encryption=<encryption>:: | |
| 196 | + | `--smtp-encryption=<encryption>`:: | |
| 197 | 197 | Specify in what way encrypting begins for the SMTP connection. | |
| 198 | 198 | Valid values are `ssl` and `tls`. Any other value reverts to plain | |
| 199 | 199 | (unencrypted) SMTP, which defaults to port 25. | |
| @@ -207,14 +207,14 @@ Sending | |||
| 207 | 207 | documentation or your server configuration to make sure | |
| 208 | 208 | for your own case. Default is the value of `sendemail.smtpEncryption`. | |
| 209 | 209 | ||
| 210 | - | --smtp-domain=<FQDN>:: | |
| 210 | + | `--smtp-domain=<FQDN>`:: | |
| 211 | 211 | Specify the Fully Qualified Domain Name (FQDN) used in the | |
| 212 | 212 | HELO/EHLO command to the SMTP server. Some servers require the | |
| 213 | 213 | FQDN to match your IP address. If not set, `git send-email` attempts | |
| 214 | 214 | to determine your FQDN automatically. Default is the value of | |
| 215 | 215 | `sendemail.smtpDomain`. | |
| 216 | 216 | ||
| 217 | - | --smtp-auth=<mechanisms>:: | |
| 217 | + | `--smtp-auth=<mechanisms>`:: | |
| 218 | 218 | Whitespace-separated list of allowed SMTP-AUTH mechanisms. This setting | |
| 219 | 219 | forces using only the listed mechanisms. Example: | |
| 220 | 220 | + | |
| @@ -229,7 +229,7 @@ is specified, all mechanisms supported by the SASL library can be used. The | |||
| 229 | 229 | special value `none` maybe specified to completely disable authentication | |
| 230 | 230 | independently of `--smtp-user`. | |
| 231 | 231 | ||
| 232 | - | --smtp-pass[=<password>]:: | |
| 232 | + | `--smtp-pass[=<password>]`:: | |
| 233 | 233 | Password for SMTP-AUTH. The argument is optional: If no | |
| 234 | 234 | argument is specified, then the empty string is used as | |
| 235 | 235 | the password. Default is the value of `sendemail.smtpPass`, | |
| @@ -241,10 +241,10 @@ or on the command line. If a username has been specified (with | |||
| 241 | 241 | specified (with `--smtp-pass` or `sendemail.smtpPass`), then | |
| 242 | 242 | a password is obtained using linkgit:git-credential[1]. | |
| 243 | 243 | ||
| 244 | - | --no-smtp-auth:: | |
| 244 | + | `--no-smtp-auth`:: | |
| 245 | 245 | Disable SMTP authentication. Short hand for `--smtp-auth=none`. | |
| 246 | 246 | ||
| 247 | - | --smtp-server=<host>:: | |
| 247 | + | `--smtp-server=<host>`:: | |
| 248 | 248 | Specify the outgoing SMTP server to use (e.g. | |
| 249 | 249 | `smtp.example.com` or a raw IP address). If unspecified, and if | |
| 250 | 250 | `--sendmail-cmd` is also unspecified, the default is to search | |
| @@ -257,7 +257,7 @@ option. This method does not support passing arguments or using plain | |||
| 257 | 257 | command names. For those use cases, consider using `--sendmail-cmd` | |
| 258 | 258 | instead. | |
| 259 | 259 | ||
| 260 | - | --smtp-server-port=<port>:: | |
| 260 | + | `--smtp-server-port=<port>`:: | |
| 261 | 261 | Specify a port different from the default port (SMTP | |
| 262 | 262 | servers typically listen to smtp port 25, but may also listen to | |
| 263 | 263 | submission port 587, or the common SSL smtp port 465); | |
| @@ -265,7 +265,7 @@ instead. | |||
| 265 | 265 | are also accepted. The port can also be set with the | |
| 266 | 266 | `sendemail.smtpServerPort` configuration variable. | |
| 267 | 267 | ||
| 268 | - | --smtp-server-option=<option>:: | |
| 268 | + | `--smtp-server-option=<option>`:: | |
| 269 | 269 | Specify the outgoing SMTP server option to use. | |
| 270 | 270 | Default value can be specified by the `sendemail.smtpServerOption` | |
| 271 | 271 | configuration option. | |
| @@ -274,15 +274,15 @@ The `--smtp-server-option` option must be repeated for each option you want | |||
| 274 | 274 | to pass to the server. Likewise, different lines in the configuration files | |
| 275 | 275 | must be used for each option. | |
| 276 | 276 | ||
| 277 | - | --smtp-ssl:: | |
| 277 | + | `--smtp-ssl`:: | |
| 278 | 278 | Legacy alias for `--smtp-encryption ssl`. | |
| 279 | 279 | ||
| 280 | - | --smtp-ssl-cert-path <path>:: | |
| 280 | + | `--smtp-ssl-cert-path <path>`:: | |
| 281 | 281 | Path to a store of trusted CA certificates for SMTP SSL/TLS | |
| 282 | 282 | certificate validation (either a directory that has been processed | |
| 283 | 283 | by `c_rehash`, or a single file containing one or more PEM format | |
| 284 | 284 | certificates concatenated together: see the description of the | |
| 285 | - | `-CAfile` _<file>_ and the `-CApath` _<dir>_ options of | |
| 285 | + | `-CAfile <file>` and the `-CApath <dir>` options of | |
| 286 | 286 | https://docs.openssl.org/master/man1/openssl-verify/ | |
| 287 | 287 | [OpenSSL's verify(1) manual page] for more information on these). | |
| 288 | 288 | Set it to an empty string to disable certificate verification. | |
| @@ -290,7 +290,7 @@ must be used for each option. | |||
| 290 | 290 | variable, if set, or the backing SSL library's compiled-in default | |
| 291 | 291 | otherwise (which should be the best choice on most platforms). | |
| 292 | 292 | ||
| 293 | - | --smtp-ssl-client-cert <path>:: | |
| 293 | + | `--smtp-ssl-client-cert <path>`:: | |
| 294 | 294 | Path to the client certificate file to present if requested by the | |
| 295 | 295 | server. This option is required when the server is set up to verify | |
| 296 | 296 | client certificates. If the corresponding private key is not included in | |
| @@ -299,7 +299,7 @@ must be used for each option. | |||
| 299 | 299 | to the value of the `sendemail.smtpSSLClientCert` configuration | |
| 300 | 300 | variable, if set. | |
| 301 | 301 | ||
| 302 | - | --smtp-ssl-client-key <path>:: | |
| 302 | + | `--smtp-ssl-client-key <path>`:: | |
| 303 | 303 | Path to the client private key file that corresponds to the client | |
| 304 | 304 | certificate. To avoid misconfiguration, this option must be used in | |
| 305 | 305 | conjunction with the `sendemail.smtpSSLClientKey` configuration variable | |
| @@ -309,17 +309,17 @@ must be used for each option. | |||
| 309 | 309 | more details. Defaults to the value of the `sendemail.smtpSSLClientKey` | |
| 310 | 310 | configuration variable, if set. | |
| 311 | 311 | ||
| 312 | - | --smtp-user=<user>:: | |
| 312 | + | `--smtp-user=<user>`:: | |
| 313 | 313 | Username for SMTP-AUTH. Default is the value of `sendemail.smtpUser`; | |
| 314 | 314 | if a username is not specified (with `--smtp-user` or `sendemail.smtpUser`), | |
| 315 | 315 | then authentication is not attempted. | |
| 316 | 316 | ||
| 317 | - | --smtp-debug=(0|1):: | |
| 317 | + | `--smtp-debug=(0|1)`:: | |
| 318 | 318 | Enable (1) or disable (0) debug output. If enabled, SMTP | |
| 319 | 319 | commands and replies will be printed. Useful to debug TLS | |
| 320 | 320 | connection and authentication problems. | |
| 321 | 321 | ||
| 322 | - | --imap-sent-folder=<folder>:: | |
| 322 | + | `--imap-sent-folder=<folder>`:: | |
| 323 | 323 | Some email providers (e.g. iCloud) do not send a copy of the emails sent | |
| 324 | 324 | using SMTP to the `Sent` folder or similar in your mailbox. Use this option | |
| 325 | 325 | to use `git imap-send` to send a copy of the emails to the folder specified | |
| @@ -331,8 +331,8 @@ must be used for each option. | |||
| 331 | 331 | This feature requires setting up `git imap-send`. See linkgit:git-imap-send[1] | |
| 332 | 332 | for instructions. | |
| 333 | 333 | ||
| 334 | - | --use-imap-only:: | |
| 335 | - | --no-use-imap-only:: | |
| 334 | + | `--use-imap-only`:: | |
| 335 | + | `--no-use-imap-only`:: | |
| 336 | 336 | If this is set, all emails will only be copied to the IMAP folder specified | |
| 337 | 337 | with `--imap-sent-folder` or `sendemail.imapSentFolder` and will not be sent | |
| 338 | 338 | to the recipients. Useful if you just want to create a draft of the emails | |
| @@ -344,8 +344,8 @@ for instructions. | |||
| 344 | 344 | This feature requires setting up `git imap-send`. See linkgit:git-imap-send[1] | |
| 345 | 345 | for instructions. | |
| 346 | 346 | ||
| 347 | - | --batch-size=<num>:: | |
| 348 | - | Some email servers (e.g. 'smtp.163.com') limit the number of emails to be | |
| 347 | + | `--batch-size=<num>`:: | |
| 348 | + | Some email servers (e.g. `smtp.163.com`) limit the number of emails to be | |
| 349 | 349 | sent per session (connection) and this will lead to a failure when | |
| 350 | 350 | sending many messages. With this option, send-email will disconnect after | |
| 351 | 351 | sending _<num>_ messages and wait for a few seconds | |
| @@ -354,7 +354,7 @@ for instructions. | |||
| 354 | 354 | retype your password every time this happens. Defaults to the | |
| 355 | 355 | `sendemail.smtpBatchSize` configuration variable. | |
| 356 | 356 | ||
| 357 | - | --relogin-delay=<int>:: | |
| 357 | + | `--relogin-delay=<int>`:: | |
| 358 | 358 | Waiting _<int>_ seconds before reconnecting to SMTP server. Used together | |
| 359 | 359 | with `--batch-size` option. Defaults to the `sendemail.smtpReloginDelay` | |
| 360 | 360 | configuration variable. | |
| @@ -362,29 +362,29 @@ for instructions. | |||
| 362 | 362 | Automating | |
| 363 | 363 | ~~~~~~~~~~ | |
| 364 | 364 | ||
| 365 | - | --no-to:: | |
| 366 | - | --no-cc:: | |
| 367 | - | --no-bcc:: | |
| 365 | + | `--no-to`:: | |
| 366 | + | `--no-cc`:: | |
| 367 | + | `--no-bcc`:: | |
| 368 | 368 | Clear any list of `To:`, `Cc:`, `Bcc:` addresses previously | |
| 369 | 369 | set via config. | |
| 370 | 370 | ||
| 371 | - | --no-identity:: | |
| 371 | + | `--no-identity`:: | |
| 372 | 372 | Clear the previously read value of `sendemail.identity` set | |
| 373 | 373 | via config, if any. | |
| 374 | 374 | ||
| 375 | - | --to-cmd=<command>:: | |
| 375 | + | `--to-cmd=<command>`:: | |
| 376 | 376 | Specify a command to execute once per patch file which | |
| 377 | 377 | should generate patch file specific `To:` entries. | |
| 378 | 378 | Output of this command must be single email address per line. | |
| 379 | 379 | Default is the value of `sendemail.toCmd` configuration value. | |
| 380 | 380 | ||
| 381 | - | --cc-cmd=<command>:: | |
| 381 | + | `--cc-cmd=<command>`:: | |
| 382 | 382 | Specify a command to execute once per patch file which | |
| 383 | 383 | should generate patch file specific `Cc:` entries. | |
| 384 | 384 | Output of this command must be single email address per line. | |
| 385 | 385 | Default is the value of `sendemail.ccCmd` configuration value. | |
| 386 | 386 | ||
| 387 | - | --header-cmd=<command>:: | |
| 387 | + | `--header-cmd=<command>`:: | |
| 388 | 388 | Specify a command that is executed once per outgoing message | |
| 389 | 389 | and output RFC 2822 style header lines to be inserted into | |
| 390 | 390 | them. When the `sendemail.headerCmd` configuration variable is | |
| @@ -392,11 +392,11 @@ Automating | |||
| 392 | 392 | at the command line, its value takes precedence over the | |
| 393 | 393 | `sendemail.headerCmd` configuration variable. | |
| 394 | 394 | ||
| 395 | - | --no-header-cmd:: | |
| 395 | + | `--no-header-cmd`:: | |
| 396 | 396 | Disable any header command in use. | |
| 397 | 397 | ||
| 398 | - | --chain-reply-to:: | |
| 399 | - | --no-chain-reply-to:: | |
| 398 | + | `--chain-reply-to`:: | |
| 399 | + | `--no-chain-reply-to`:: | |
| 400 | 400 | If this is set, each email will be sent as a reply to the previous | |
| 401 | 401 | email sent. If disabled with `--no-chain-reply-to`, all emails after | |
| 402 | 402 | the first will be sent as replies to the first email sent. When using | |
| @@ -404,34 +404,34 @@ Automating | |||
| 404 | 404 | entire patch series. Disabled by default, but the `sendemail.chainReplyTo` | |
| 405 | 405 | configuration variable can be used to enable it. | |
| 406 | 406 | ||
| 407 | - | --identity=<identity>:: | |
| 407 | + | `--identity=<identity>`:: | |
| 408 | 408 | A configuration identity. When given, causes values in the | |
| 409 | 409 | `sendemail.<identity>` subsection to take precedence over | |
| 410 | 410 | values in the `sendemail` section. The default identity is | |
| 411 | 411 | the value of `sendemail.identity`. | |
| 412 | 412 | ||
| 413 | - | --signed-off-by-cc:: | |
| 414 | - | --no-signed-off-by-cc:: | |
| 413 | + | `--signed-off-by-cc`:: | |
| 414 | + | `--no-signed-off-by-cc`:: | |
| 415 | 415 | If this is set, add emails found in the `Signed-off-by` trailer or `Cc:` | |
| 416 | 416 | lines to the cc list. Default is the value of `sendemail.signedOffByCc` | |
| 417 | 417 | configuration value; if that is unspecified, default to | |
| 418 | 418 | `--signed-off-by-cc`. | |
| 419 | 419 | ||
| 420 | - | --cc-cover:: | |
| 421 | - | --no-cc-cover:: | |
| 420 | + | `--cc-cover`:: | |
| 421 | + | `--no-cc-cover`:: | |
| 422 | 422 | If this is set, emails found in `Cc:` headers in the first patch of | |
| 423 | 423 | the series (typically the cover letter) are added to the cc list | |
| 424 | 424 | for each email set. Default is the value of `sendemail.ccCover` | |
| 425 | 425 | configuration value; if that is unspecified, default to `--no-cc-cover`. | |
| 426 | 426 | ||
| 427 | - | --to-cover:: | |
| 428 | - | --no-to-cover:: | |
| 427 | + | `--to-cover`:: | |
| 428 | + | `--no-to-cover`:: | |
| 429 | 429 | If this is set, emails found in `To:` headers in the first patch of | |
| 430 | 430 | the series (typically the cover letter) are added to the to list | |
| 431 | 431 | for each email set. Default is the value of `sendemail.toCover` | |
| 432 | 432 | configuration value; if that is unspecified, default to `--no-to-cover`. | |
| 433 | 433 | ||
| 434 | - | --suppress-cc=<category>:: | |
| 434 | + | `--suppress-cc=<category>`:: | |
| 435 | 435 | Specify an additional category of recipients to suppress the | |
| 436 | 436 | auto-cc of: | |
| 437 | 437 | + | |
| @@ -456,14 +456,14 @@ Default is the value of `sendemail.suppressCc` configuration value; if | |||
| 456 | 456 | that is unspecified, default to `self` if `--suppress-from` is | |
| 457 | 457 | specified, as well as `body` if `--no-signed-off-by-cc` is specified. | |
| 458 | 458 | ||
| 459 | - | --suppress-from:: | |
| 460 | - | --no-suppress-from:: | |
| 459 | + | `--suppress-from`:: | |
| 460 | + | `--no-suppress-from`:: | |
| 461 | 461 | If this is set, do not add the `From:` address to the `Cc:` list. | |
| 462 | 462 | Default is the value of `sendemail.suppressFrom` configuration | |
| 463 | 463 | value; if that is unspecified, default to `--no-suppress-from`. | |
| 464 | 464 | ||
| 465 | - | --thread:: | |
| 466 | - | --no-thread:: | |
| 465 | + | `--thread`:: | |
| 466 | + | `--no-thread`:: | |
| 467 | 467 | If this is set, the `In-Reply-To` and `References` headers will be | |
| 468 | 468 | added to each email sent. Whether each mail refers to the | |
| 469 | 469 | previous email (`deep` threading per `git format-patch` | |
| @@ -481,8 +481,8 @@ exists when `git send-email` is asked to add it (especially note that | |||
| 481 | 481 | Failure to do so may not produce the expected result in the | |
| 482 | 482 | recipient's MUA. | |
| 483 | 483 | ||
| 484 | - | --mailmap:: | |
| 485 | - | --no-mailmap:: | |
| 484 | + | `--mailmap`:: | |
| 485 | + | `--no-mailmap`:: | |
| 486 | 486 | Use the mailmap file (see linkgit:gitmailmap[5]) to map all | |
| 487 | 487 | addresses to their canonical real name and email address. Additional | |
| 488 | 488 | mailmap data specific to `git send-email` may be provided using the | |
| @@ -492,7 +492,7 @@ recipient's MUA. | |||
| 492 | 492 | Administering | |
| 493 | 493 | ~~~~~~~~~~~~~ | |
| 494 | 494 | ||
| 495 | - | --confirm=<mode>:: | |
| 495 | + | `--confirm=<mode>`:: | |
| 496 | 496 | Confirm just before sending: | |
| 497 | 497 | + | |
| 498 | 498 | -- | |
| @@ -508,22 +508,22 @@ Default is the value of `sendemail.confirm` configuration value; if that | |||
| 508 | 508 | is unspecified, default to `auto` unless any of the suppress options | |
| 509 | 509 | have been specified, in which case default to `compose`. | |
| 510 | 510 | ||
| 511 | - | --dry-run:: | |
| 511 | + | `--dry-run`:: | |
| 512 | 512 | Do everything except actually send the emails. | |
| 513 | 513 | ||
| 514 | - | --format-patch:: | |
| 515 | - | --no-format-patch:: | |
| 514 | + | `--format-patch`:: | |
| 515 | + | `--no-format-patch`:: | |
| 516 | 516 | When an argument may be understood either as a reference or as a file name, | |
| 517 | 517 | choose to understand it as a format-patch argument (`--format-patch`) | |
| 518 | 518 | or as a file name (`--no-format-patch`). By default, when such a conflict | |
| 519 | 519 | occurs, `git send-email` will fail. | |
| 520 | 520 | ||
| 521 | - | --quiet:: | |
| 521 | + | `--quiet`:: | |
| 522 | 522 | Make `git send-email` less verbose. One line per email should be | |
| 523 | 523 | all that is output. | |
| 524 | 524 | ||
| 525 | - | --validate:: | |
| 526 | - | --no-validate:: | |
| 525 | + | `--validate`:: | |
| 526 | + | `--no-validate`:: | |
| 527 | 527 | Perform sanity checks on patches. | |
| 528 | 528 | Currently, validation means the following: | |
| 529 | 529 | + | |
| @@ -539,20 +539,20 @@ have been specified, in which case default to `compose`. | |||
| 539 | 539 | Default is the value of `sendemail.validate`; if this is not set, | |
| 540 | 540 | default to `--validate`. | |
| 541 | 541 | ||
| 542 | - | --force:: | |
| 542 | + | `--force`:: | |
| 543 | 543 | Send emails even if safety checks would prevent it. | |
| 544 | 544 | ||
| 545 | 545 | ||
| 546 | 546 | Information | |
| 547 | 547 | ~~~~~~~~~~~ | |
| 548 | 548 | ||
| 549 | - | --dump-aliases:: | |
| 549 | + | `--dump-aliases`:: | |
| 550 | 550 | Instead of the normal operation, dump the shorthand alias names from | |
| 551 | 551 | the configured alias file(s), one per line in alphabetical order. Note | |
| 552 | 552 | that this only includes the alias name and not its expanded email addresses. | |
| 553 | 553 | See `sendemail.aliasesFile` for more information about aliases. | |
| 554 | 554 | ||
| 555 | - | --translate-aliases:: | |
| 555 | + | `--translate-aliases`:: | |
| 556 | 556 | Instead of the normal operation, read from standard input and | |
| 557 | 557 | interpret each line as an email alias. Translate it according to the | |
| 558 | 558 | configured alias file(s). Output each translated name and email | |
| @@ -718,7 +718,7 @@ include::format-patch-caveats.adoc[] | |||
| 718 | 718 | ||
| 719 | 719 | SEE ALSO | |
| 720 | 720 | -------- | |
| 721 | - | linkgit:git-format-patch[1], linkgit:git-imap-send[1], mbox(5) | |
| 721 | + | linkgit:git-format-patch[1], linkgit:git-imap-send[1], `mbox`(5) | |
| 722 | 722 | ||
| 723 | 723 | GIT | |
| 724 | 724 | --- | |
modified Documentation/git-shortlog.adoc
| @@ -3,63 +3,63 @@ git-shortlog(1) | |||
| 3 | 3 | ||
| 4 | 4 | NAME | |
| 5 | 5 | ---- | |
| 6 | - | git-shortlog - Summarize 'git log' output | |
| 6 | + | git-shortlog - Summarize `git log` output | |
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | [verse] | |
| 11 | - | 'git shortlog' [<options>] [<revision-range>] [[--] <path>...] | |
| 12 | - | git log --pretty=short | 'git shortlog' [<options>] | |
| 10 | + | [synopsis] | |
| 11 | + | git shortlog [<options>] [<revision-range>] [[--] <path>...] | |
| 12 | + | git log --pretty=short | git shortlog [<options>] | |
| 13 | 13 | ||
| 14 | 14 | DESCRIPTION | |
| 15 | 15 | ----------- | |
| 16 | - | Summarizes 'git log' output in a format suitable for inclusion | |
| 16 | + | Summarizes `git log` output in a format suitable for inclusion | |
| 17 | 17 | in release announcements. Each commit will be grouped by author and title. | |
| 18 | 18 | ||
| 19 | 19 | Additionally, "[PATCH]" will be stripped from the commit description. | |
| 20 | 20 | ||
| 21 | 21 | If no revisions are passed on the command line and either standard input | |
| 22 | - | is not a terminal or there is no current branch, 'git shortlog' will | |
| 22 | + | is not a terminal or there is no current branch, `git shortlog` will | |
| 23 | 23 | output a summary of the log read from standard input, without | |
| 24 | 24 | reference to the current repository. | |
| 25 | 25 | ||
| 26 | 26 | OPTIONS | |
| 27 | 27 | ------- | |
| 28 | 28 | ||
| 29 | - | -n:: | |
| 30 | - | --numbered:: | |
| 29 | + | `-n`:: | |
| 30 | + | `--numbered`:: | |
| 31 | 31 | Sort output according to the number of commits per author instead | |
| 32 | 32 | of author alphabetic order. | |
| 33 | 33 | ||
| 34 | - | -s:: | |
| 35 | - | --summary:: | |
| 34 | + | `-s`:: | |
| 35 | + | `--summary`:: | |
| 36 | 36 | Suppress commit description and provide a commit count summary only. | |
| 37 | 37 | ||
| 38 | - | -e:: | |
| 39 | - | --email:: | |
| 38 | + | `-e`:: | |
| 39 | + | `--email`:: | |
| 40 | 40 | Show the email address of each author. | |
| 41 | 41 | ||
| 42 | - | --format[=<format>]:: | |
| 42 | + | `--format[=<format>]`:: | |
| 43 | 43 | Instead of the commit subject, use some other information to | |
| 44 | - | describe each commit. '<format>' can be any string accepted | |
| 45 | - | by the `--format` option of 'git log', such as '* [%h] %s'. | |
| 46 | - | (See the "PRETTY FORMATS" section of linkgit:git-log[1].) | |
| 44 | + | describe each commit. _<format>_ can be any string accepted | |
| 45 | + | by the `--format` option of `git log`, such as '* [%h] %s'. | |
| 46 | + | (See the 'PRETTY FORMATS' section of linkgit:git-log[1].) | |
| 47 | 47 | + | |
| 48 | 48 | Each pretty-printed commit will be rewrapped before it is shown. | |
| 49 | 49 | ||
| 50 | - | --date=<format>:: | |
| 50 | + | `--date=<format>`:: | |
| 51 | 51 | Show dates formatted according to the given date string. (See | |
| 52 | - | the `--date` option in the "Commit Formatting" section of | |
| 52 | + | the `--date` option in the 'Commit Formatting' section of | |
| 53 | 53 | linkgit:git-log[1]). Useful with `--group=format:<format>`. | |
| 54 | 54 | ||
| 55 | - | --group=<type>:: | |
| 56 | - | Group commits based on `<type>`. If no `--group` option is | |
| 57 | - | specified, the default is `author`. `<type>` is one of: | |
| 55 | + | `--group=<type>`:: | |
| 56 | + | Group commits based on _<type>_. If no `--group` option is | |
| 57 | + | specified, the default is `author`. _<type>_ is one of: | |
| 58 | 58 | + | |
| 59 | 59 | -- | |
| 60 | 60 | - `author`, commits are grouped by author | |
| 61 | 61 | - `committer`, commits are grouped by committer (the same as `-c`) | |
| 62 | - | - `trailer:<field>`, the `<field>` is interpreted as a case-insensitive | |
| 62 | + | - `trailer:<field>`, the _<field>_ is interpreted as a case-insensitive | |
| 63 | 63 | commit message trailer (see linkgit:git-interpret-trailers[1]). For | |
| 64 | 64 | example, if your project uses `Reviewed-by` trailers, you might want | |
| 65 | 65 | to see who has been reviewing with | |
| @@ -76,7 +76,7 @@ unless the `--email` option is specified. If the value cannot be parsed | |||
| 76 | 76 | as an identity, it will be taken literally and completely. | |
| 77 | 77 | ||
| 78 | 78 | - `format:<format>`, any string accepted by the `--format` option of | |
| 79 | - | 'git log'. (See the "PRETTY FORMATS" section of | |
| 79 | + | `git log`. (See the 'PRETTY FORMATS' section of | |
| 80 | 80 | linkgit:git-log[1].) | |
| 81 | 81 | -- | |
| 82 | 82 | + | |
| @@ -85,11 +85,11 @@ value (but again, only once per unique value in that commit). For | |||
| 85 | 85 | example, `git shortlog --group=author --group=trailer:co-authored-by` | |
| 86 | 86 | counts both authors and co-authors. | |
| 87 | 87 | ||
| 88 | - | -c:: | |
| 89 | - | --committer:: | |
| 88 | + | `-c`:: | |
| 89 | + | `--committer`:: | |
| 90 | 90 | This is an alias for `--group=committer`. | |
| 91 | 91 | ||
| 92 | - | -w[<width>[,<indent1>[,<indent2>]]]:: | |
| 92 | + | `-w[<width>[,<indent1>[,<indent2>]]]`:: | |
| 93 | 93 | Linewrap the output by wrapping each line at `width`. The first | |
| 94 | 94 | line of each entry is indented by `indent1` spaces, and the second | |
| 95 | 95 | and subsequent lines are indented by `indent2` spaces. `width`, | |
| @@ -98,16 +98,16 @@ counts both authors and co-authors. | |||
| 98 | 98 | If width is `0` (zero) then indent the lines of the output without wrapping | |
| 99 | 99 | them. | |
| 100 | 100 | ||
| 101 | - | <revision-range>:: | |
| 101 | + | `<revision-range>`:: | |
| 102 | 102 | Show only commits in the specified revision range. When no | |
| 103 | - | <revision-range> is specified, it defaults to `HEAD` (i.e. the | |
| 103 | + | _<revision-range>_ is specified, it defaults to `HEAD` (i.e. the | |
| 104 | 104 | whole history leading to the current commit). `origin..HEAD` | |
| 105 | 105 | specifies all the commits reachable from the current commit | |
| 106 | 106 | (i.e. `HEAD`), but not from `origin`. For a complete list of | |
| 107 | - | ways to spell <revision-range>, see the "Specifying Ranges" | |
| 107 | + | ways to spell _<revision-range>_, see the 'Specifying Ranges' | |
| 108 | 108 | section of linkgit:gitrevisions[7]. | |
| 109 | 109 | ||
| 110 | - | [--] <path>...:: | |
| 110 | + | `[--] <path>...`:: | |
| 111 | 111 | Consider only commits that are enough to explain how the files | |
| 112 | 112 | that match the specified paths came to be. | |
| 113 | 113 | + | |
modified Documentation/git-sparse-checkout.adoc
| @@ -134,7 +134,7 @@ the `clean.requireForce` config option is set to `false`. | |||
| 134 | 134 | + | |
| 135 | 135 | The `--dry-run` option will list the directories that would be removed | |
| 136 | 136 | without deleting them. Running in this mode can be helpful to predict the | |
| 137 | - | behavior of the clean comand or to determine which kinds of files are left | |
| 137 | + | behavior of the clean command or to determine which kinds of files are left | |
| 138 | 138 | in the sparse directories. | |
| 139 | 139 | + | |
| 140 | 140 | The `--verbose` option will list every file within the directories that | |
modified Documentation/git-stash.adoc
| @@ -12,7 +12,7 @@ git stash list [<log-options>] | |||
| 12 | 12 | git stash show [-u | --include-untracked | --only-untracked] [<diff-options>] [<stash>] | |
| 13 | 13 | git stash drop [-q | --quiet] [<stash>] | |
| 14 | 14 | git stash pop [--index] [-q | --quiet] [<stash>] | |
| 15 | - | git stash apply [--index] [-q | --quiet] [<stash>] | |
| 15 | + | git stash apply [--index] [-q | --quiet] [--label-ours=<label>] [--label-theirs=<label>] [--label-base=<label>] [<stash>] | |
| 16 | 16 | git stash branch <branchname> [<stash>] | |
| 17 | 17 | git stash [push] [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet] | |
| 18 | 18 | [-u | --include-untracked] [-a | --all] [(-m | --message) <message>] | |
| @@ -195,6 +195,15 @@ the index's ones. However, this can fail, when you have conflicts | |||
| 195 | 195 | (which are stored in the index, where you therefore can no longer | |
| 196 | 196 | apply the changes as they were originally). | |
| 197 | 197 | ||
| 198 | + | `--label-ours=<label>`:: | |
| 199 | + | `--label-theirs=<label>`:: | |
| 200 | + | `--label-base=<label>`:: | |
| 201 | + | These options are only valid for the `apply` command. | |
| 202 | + | + | |
| 203 | + | Use the given labels in conflict markers instead of the default | |
| 204 | + | "Updated upstream", "Stashed changes", and "Stash base". | |
| 205 | + | `--label-base` only has an effect with merge.conflictStyle=diff3. | |
| 206 | + | ||
| 198 | 207 | `-k`:: | |
| 199 | 208 | `--keep-index`:: | |
| 200 | 209 | `--no-keep-index`:: | |
| @@ -417,6 +426,15 @@ include::includes/cmd-config-section-all.adoc[] | |||
| 417 | 426 | :git-stash: 1 | |
| 418 | 427 | include::config/stash.adoc[] | |
| 419 | 428 | ||
| 429 | + | EXIT STATUS | |
| 430 | + | ----------- | |
| 431 | + | ||
| 432 | + | The `git stash` subcommands exit with status 0 on success. The | |
| 433 | + | subcommands that apply a stash entry, i.e. `apply`, `pop` and `branch`, | |
| 434 | + | exit with status 1 when applying the stash entry resulted in conflicts, | |
| 435 | + | in which case the stash entry is left in place, and with a non-zero | |
| 436 | + | status other than 1 when they fail for other reasons. | |
| 437 | + | ||
| 420 | 438 | ||
| 421 | 439 | SEE ALSO | |
| 422 | 440 | -------- | |
modified Documentation/git-svn.adoc
| @@ -439,7 +439,7 @@ Any other arguments are passed directly to 'git log' | |||
| 439 | 439 | 'show-ignore':: | |
| 440 | 440 | Recursively finds and lists the svn:ignore and svn:global-ignores | |
| 441 | 441 | properties on directories. The output is suitable for appending to | |
| 442 | - | the $GIT_DIR/info/exclude file. | |
| 442 | + | the $GIT_COMMON_DIR/info/exclude file. | |
| 443 | 443 | ||
| 444 | 444 | 'mkdirs':: | |
| 445 | 445 | Attempts to recreate empty directories that core Git cannot track | |
modified Documentation/git-switch.adoc
| @@ -123,18 +123,19 @@ variable. | |||
| 123 | 123 | ||
| 124 | 124 | `-m`:: | |
| 125 | 125 | `--merge`:: | |
| 126 | - | If you have local modifications to one or more files that are | |
| 127 | - | different between the current branch and the branch to which | |
| 128 | - | you are switching, the command refuses to switch branches in | |
| 129 | - | order to preserve your modifications in context. However, | |
| 130 | - | with this option, a three-way merge between the current | |
| 131 | - | branch, your working tree contents, and the new branch is | |
| 132 | - | done, and you will be on the new branch. | |
| 133 | - | + | |
| 134 | - | When a merge conflict happens, the index entries for conflicting | |
| 135 | - | paths are left unmerged, and you need to resolve the conflicts | |
| 136 | - | and mark the resolved paths with `git add` (or `git rm` if the merge | |
| 137 | - | should result in deletion of the path). | |
| 126 | + | If you have local modifications to one or more files that | |
| 127 | + | are different between the current branch and the branch to | |
| 128 | + | which you are switching, the command normally refuses to | |
| 129 | + | switch branches in order to preserve your modifications in | |
| 130 | + | context. However, with this option, the conflicting local | |
| 131 | + | changes are automatically stashed before the switch and | |
| 132 | + | reapplied afterwards. If the local changes do not overlap | |
| 133 | + | with the differences between branches, the switch proceeds | |
| 134 | + | without stashing. If reapplying the stash results in | |
| 135 | + | conflicts, the entry is saved to the stash list. Resolve | |
| 136 | + | the conflicts and run `git stash drop` when done, or clear | |
| 137 | + | the working tree (e.g. with `git reset --hard`) before | |
| 138 | + | running `git stash pop` later to re-apply your changes. | |
| 138 | 139 | ||
| 139 | 140 | `--conflict=<style>`:: | |
| 140 | 141 | The same as `--merge` option above, but changes the way the | |
| @@ -217,15 +218,18 @@ $ git switch mytopic | |||
| 217 | 218 | error: You have local changes to 'frotz'; not switching branches. | |
| 218 | 219 | ------------ | |
| 219 | 220 | ||
| 220 | - | You can give the `-m` flag to the command, which would try a three-way | |
| 221 | - | merge: | |
| 221 | + | You can give the `-m` flag to the command, which will carry your local | |
| 222 | + | changes to the new branch: | |
| 222 | 223 | ||
| 223 | 224 | ------------ | |
| 224 | 225 | $ git switch -m mytopic | |
| 225 | - | Auto-merging frotz | |
| 226 | + | Applied autostash. | |
| 227 | + | Switched to branch 'mytopic' | |
| 228 | + | The following paths have local changes: | |
| 229 | + | M frotz | |
| 226 | 230 | ------------ | |
| 227 | 231 | ||
| 228 | - | After this three-way merge, the local modifications are _not_ | |
| 232 | + | After the switch, the local modifications are reapplied and are _not_ | |
| 229 | 233 | registered in your index file, so `git diff` would show you what | |
| 230 | 234 | changes you made since the tip of the new branch. | |
| 231 | 235 | ||
added Documentation/git-url-parse.adoc mode 100644
| @@ -0,0 +1,80 @@ | |||
| 1 | + | git-url-parse(1) | |
| 2 | + | ================ | |
| 3 | + | ||
| 4 | + | NAME | |
| 5 | + | ---- | |
| 6 | + | git-url-parse - Parse and extract git URL components | |
| 7 | + | ||
| 8 | + | SYNOPSIS | |
| 9 | + | -------- | |
| 10 | + | [synopsis] | |
| 11 | + | git url-parse [-c <component>] [--] <url>... | |
| 12 | + | ||
| 13 | + | DESCRIPTION | |
| 14 | + | ----------- | |
| 15 | + | ||
| 16 | + | Git supports many ways to specify URLs, some of them non-standard. | |
| 17 | + | For example, git supports the scp style [user@]host:[path] format. | |
| 18 | + | This command eases interoperability with git URLs by enabling the | |
| 19 | + | parsing and extraction of the components of all git URLs. | |
| 20 | + | ||
| 21 | + | Any syntactically valid URL is parsed, even if the scheme is not one | |
| 22 | + | git supports for fetching or pushing. | |
| 23 | + | ||
| 24 | + | OPTIONS | |
| 25 | + | ------- | |
| 26 | + | ||
| 27 | + | `-c <component>`:: | |
| 28 | + | `--component <component>`:: | |
| 29 | + | Extract the _<component>_ component from the given Git URLs. | |
| 30 | + | _<component>_ can be one of: | |
| 31 | + | `scheme`, `user`, `password`, `host`, `port`, `path`. | |
| 32 | + | ||
| 33 | + | OUTPUT | |
| 34 | + | ------ | |
| 35 | + | ||
| 36 | + | When `--component` is given, the requested component of each URL | |
| 37 | + | is printed on its own line, in the order the URLs were given. If | |
| 38 | + | the URL has no such component (for example, a port in a URL that | |
| 39 | + | does not specify one), an empty line is printed in its place. | |
| 40 | + | ||
| 41 | + | When `--component` is not given, no output is produced. The exit | |
| 42 | + | status is zero if every URL parses successfully and non-zero | |
| 43 | + | otherwise, allowing the command to be used purely as a validator. | |
| 44 | + | ||
| 45 | + | EXAMPLES | |
| 46 | + | -------- | |
| 47 | + | ||
| 48 | + | * Print the host name: | |
| 49 | + | + | |
| 50 | + | ------------ | |
| 51 | + | $ git url-parse --component host https://example.com/user/repo | |
| 52 | + | example.com | |
| 53 | + | ------------ | |
| 54 | + | ||
| 55 | + | * Print the path: | |
| 56 | + | + | |
| 57 | + | ------------ | |
| 58 | + | $ git url-parse --component path https://example.com/user/repo | |
| 59 | + | /user/repo | |
| 60 | + | $ git url-parse --component path example.com:~user/repo | |
| 61 | + | ~user/repo | |
| 62 | + | $ git url-parse --component path example.com:user/repo | |
| 63 | + | /user/repo | |
| 64 | + | ------------ | |
| 65 | + | ||
| 66 | + | * Validate URLs without outputting anything: | |
| 67 | + | + | |
| 68 | + | ------------ | |
| 69 | + | $ git url-parse https://example.com/user/repo example.com:~user/repo | |
| 70 | + | ------------ | |
| 71 | + | ||
| 72 | + | SEE ALSO | |
| 73 | + | -------- | |
| 74 | + | linkgit:git-clone[1], | |
| 75 | + | linkgit:git-fetch[1], | |
| 76 | + | linkgit:git-config[1] | |
| 77 | + | ||
| 78 | + | GIT | |
| 79 | + | --- | |
| 80 | + | Part of the linkgit:git[1] suite | |
modified Documentation/git-worktree.adoc
| @@ -219,7 +219,9 @@ To remove a locked worktree, specify `--force` twice. | |||
| 219 | 219 | of creating a new branch from `HEAD`, if there exists a tracking | |
| 220 | 220 | branch in exactly one remote matching the basename of _<path>_, | |
| 221 | 221 | base the new branch on the remote-tracking branch, and mark | |
| 222 | - | the remote-tracking branch as "upstream" from the new branch. | |
| 222 | + | the remote-tracking branch as "upstream" from the new branch. If | |
| 223 | + | there are multiple matches, the command fails. If there is no | |
| 224 | + | match, the command falls back to creating a new branch from `HEAD`. | |
| 223 | 225 | + | |
| 224 | 226 | This can also be set up as the default behaviour by using the | |
| 225 | 227 | `worktree.guessRemote` config option. | |
modified Documentation/git.adoc
| @@ -25,7 +25,8 @@ and full access to internals. | |||
| 25 | 25 | See linkgit:gittutorial[7] to get started, then see | |
| 26 | 26 | linkgit:giteveryday[7] for a useful minimum set of | |
| 27 | 27 | commands. The link:user-manual.html[Git User's Manual] has a more | |
| 28 | - | in-depth introduction. | |
| 28 | + | in-depth introduction. See linkgit:gitdatamodel[7] if you want to | |
| 29 | + | learn about the data model and important terminology. | |
| 29 | 30 | ||
| 30 | 31 | After you mastered the basic concepts, you can come back to this | |
| 31 | 32 | page to learn what commands Git offers. You can learn more about | |
| @@ -469,7 +470,9 @@ Higher level SCMs may provide and manage additional information in the | |||
| 469 | 470 | ||
| 470 | 471 | Terminology | |
| 471 | 472 | ----------- | |
| 472 | - | Please see linkgit:gitglossary[7]. | |
| 473 | + | Please see linkgit:gitglossary[7]. See linkgit:gitdatamodel[7] for a | |
| 474 | + | discussion of the core data model, which includes important terminology | |
| 475 | + | used throughout the documentation. | |
| 473 | 476 | ||
| 474 | 477 | ||
| 475 | 478 | Environment Variables | |
| @@ -1199,8 +1202,9 @@ SEE ALSO | |||
| 1199 | 1202 | -------- | |
| 1200 | 1203 | linkgit:gittutorial[7], linkgit:gittutorial-2[7], | |
| 1201 | 1204 | linkgit:giteveryday[7], linkgit:gitcvs-migration[7], | |
| 1202 | - | linkgit:gitglossary[7], linkgit:gitcore-tutorial[7], | |
| 1203 | - | linkgit:gitcli[7], link:user-manual.html[The Git User's Manual], | |
| 1205 | + | linkgit:gitglossary[7], linkgit:gitdatamodel[7], | |
| 1206 | + | linkgit:gitcore-tutorial[7], linkgit:gitcli[7], | |
| 1207 | + | link:user-manual.html[The Git User's Manual], | |
| 1204 | 1208 | linkgit:gitworkflows[7] | |
| 1205 | 1209 | ||
| 1206 | 1210 | GIT | |
modified Documentation/gitattributes.adoc
| @@ -911,7 +911,10 @@ patterns are available: | |||
| 911 | 911 | ||
| 912 | 912 | - `rust` suitable for source code in the Rust language. | |
| 913 | 913 | ||
| 914 | - | - `scheme` suitable for source code in the Scheme language. | |
| 914 | + | - `scheme` suitable for source code in most Lisp dialects, | |
| 915 | + | including Scheme, Emacs Lisp, Common Lisp, and Clojure. | |
| 916 | + | ||
| 917 | + | - `swift` suitable for source code in the Swift language. | |
| 915 | 918 | ||
| 916 | 919 | - `tex` suitable for source code for LaTeX documents. | |
| 917 | 920 | ||
modified Documentation/gitdatamodel.adoc
| @@ -300,6 +300,10 @@ $ git reflog main --date=iso --no-decorate | |||
| 300 | 300 | 4ccb6d7 main@{2025-09-29 15:16:48 -0400}: commit (initial): Initial commit | |
| 301 | 301 | ---- | |
| 302 | 302 | ||
| 303 | + | SEE ALSO | |
| 304 | + | -------- | |
| 305 | + | linkgit:gitglossary[7] | |
| 306 | + | ||
| 303 | 307 | GIT | |
| 304 | 308 | --- | |
| 305 | 309 | Part of the linkgit:git[1] suite | |
modified Documentation/gitformat-index.adoc
| @@ -291,14 +291,14 @@ Git index format | |||
| 291 | 291 | sequence in variable width encoding. Each string describes the | |
| 292 | 292 | environment where the cache can be used. | |
| 293 | 293 | ||
| 294 | - | - Stat data of $GIT_DIR/info/exclude. See "Index entry" section from | |
| 294 | + | - Stat data of $GIT_COMMON_DIR/info/exclude. See "Index entry" section from | |
| 295 | 295 | ctime field until "file size". | |
| 296 | 296 | ||
| 297 | 297 | - Stat data of core.excludesFile | |
| 298 | 298 | ||
| 299 | 299 | - 32-bit dir_flags (see struct dir_struct) | |
| 300 | 300 | ||
| 301 | - | - Hash of $GIT_DIR/info/exclude. A null hash means the file | |
| 301 | + | - Hash of $GIT_COMMON_DIR/info/exclude. A null hash means the file | |
| 302 | 302 | does not exist. | |
| 303 | 303 | ||
| 304 | 304 | - Hash of core.excludesFile. A null hash means the file does | |
modified Documentation/gitglossary.adoc
| @@ -16,6 +16,7 @@ include::glossary-content.adoc[] | |||
| 16 | 16 | ||
| 17 | 17 | SEE ALSO | |
| 18 | 18 | -------- | |
| 19 | + | linkgit:gitdatamodel[7], | |
| 19 | 20 | linkgit:gittutorial[7], | |
| 20 | 21 | linkgit:gittutorial-2[7], | |
| 21 | 22 | linkgit:gitcvs-migration[7], | |
modified Documentation/gitignore.adoc
| @@ -7,7 +7,7 @@ gitignore - Specifies intentionally untracked files to ignore | |||
| 7 | 7 | ||
| 8 | 8 | SYNOPSIS | |
| 9 | 9 | -------- | |
| 10 | - | $XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore | |
| 10 | + | $XDG_CONFIG_HOME/git/ignore, $GIT_COMMON_DIR/info/exclude, .gitignore | |
| 11 | 11 | ||
| 12 | 12 | DESCRIPTION | |
| 13 | 13 | ----------- | |
| @@ -34,7 +34,7 @@ precedence, the last matching pattern decides the outcome): | |||
| 34 | 34 | includes such `.gitignore` files in its repository, containing patterns for | |
| 35 | 35 | files generated as part of the project build. | |
| 36 | 36 | ||
| 37 | - | * Patterns read from `$GIT_DIR/info/exclude`. | |
| 37 | + | * Patterns read from `$GIT_COMMON_DIR/info/exclude`. | |
| 38 | 38 | ||
| 39 | 39 | * Patterns read from the file specified by the configuration | |
| 40 | 40 | variable `core.excludesFile`. | |
| @@ -50,7 +50,7 @@ be used. | |||
| 50 | 50 | specific to a particular repository but which do not need to be shared | |
| 51 | 51 | with other related repositories (e.g., auxiliary files that live inside | |
| 52 | 52 | the repository but are specific to one user's workflow) should go into | |
| 53 | - | the `$GIT_DIR/info/exclude` file. | |
| 53 | + | the `$GIT_COMMON_DIR/info/exclude` file. | |
| 54 | 54 | ||
| 55 | 55 | * Patterns which a user wants Git to | |
| 56 | 56 | ignore in all situations (e.g., backup or temporary files generated by | |
| @@ -97,7 +97,7 @@ PATTERN FORMAT | |||
| 97 | 97 | match at any level below the `.gitignore` level. | |
| 98 | 98 | ||
| 99 | 99 | - Patterns read from exclude sources that are outside the working tree, | |
| 100 | - | such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if | |
| 100 | + | such as $GIT_COMMON_DIR/info/exclude and core.excludesFile, are treated as if | |
| 101 | 101 | they are specified at the root of the working tree, i.e. a leading "/" | |
| 102 | 102 | in such patterns anchors the match at the root of the repository. | |
| 103 | 103 | ||
| @@ -146,8 +146,8 @@ CONFIGURATION | |||
| 146 | 146 | ||
| 147 | 147 | The optional configuration variable `core.excludesFile` indicates a path to a | |
| 148 | 148 | file containing patterns of file names to exclude, similar to | |
| 149 | - | `$GIT_DIR/info/exclude`. Patterns in the exclude file are used in addition to | |
| 150 | - | those in `$GIT_DIR/info/exclude`. | |
| 149 | + | `$GIT_COMMON_DIR/info/exclude`. Patterns in the exclude file are used in | |
| 150 | + | addition to those in `$GIT_COMMON_DIR/info/exclude`. | |
| 151 | 151 | ||
| 152 | 152 | NOTES | |
| 153 | 153 | ----- | |
modified Documentation/gitpacking.adoc
| @@ -150,7 +150,7 @@ with a configuration like so: | |||
| 150 | 150 | pattern = "refs/" | |
| 151 | 151 | threshold = now | |
| 152 | 152 | stableThreshold = never | |
| 153 | - | sampleRate = 100 | |
| 153 | + | sampleRate = 1 | |
| 154 | 154 | maxMerges = 64 | |
| 155 | 155 | ---- | |
| 156 | 156 | ||
| @@ -177,7 +177,7 @@ like: | |||
| 177 | 177 | pattern = "refs/virtual/([0-9]+)/(heads|tags)/" | |
| 178 | 178 | threshold = now | |
| 179 | 179 | stableThreshold = never | |
| 180 | - | sampleRate = 100 | |
| 180 | + | sampleRate = 1 | |
| 181 | 181 | maxMerges = 64 | |
| 182 | 182 | ---- | |
| 183 | 183 | ||
modified Documentation/gitprotocol-v2.adoc
| @@ -558,31 +558,46 @@ object-info | |||
| 558 | 558 | ||
| 559 | 559 | `object-info` is the command to retrieve information about one or more objects. | |
| 560 | 560 | Its main purpose is to allow a client to make decisions based on this | |
| 561 | - | information without having to fully fetch objects. Object size is the only | |
| 562 | - | information that is currently supported. | |
| 561 | + | information without having to fully fetch objects. Currently only object size | |
| 562 | + | and type are supported. | |
| 563 | 563 | ||
| 564 | 564 | An `object-info` request takes the following arguments: | |
| 565 | 565 | ||
| 566 | 566 | size | |
| 567 | 567 | Requests size information to be returned for each listed object id. | |
| 568 | 568 | ||
| 569 | + | type | |
| 570 | + | Requests type information to be returned for each listed object id. | |
| 571 | + | ||
| 569 | 572 | oid <oid> | |
| 570 | 573 | Indicates to the server an object which the client wants to obtain | |
| 571 | - | information for. | |
| 574 | + | information for. They must be full OIDs. | |
| 572 | 575 | ||
| 573 | - | The response of `object-info` is a list of the requested object ids | |
| 574 | - | and associated requested information, each separated by a single space. | |
| 576 | + | The response of `object-info` consists of one pkt-line per requested attribute, | |
| 577 | + | echoing the attributes the server will report, followed by one pkt-line per | |
| 578 | + | requested object id with its information, each field separated by a single | |
| 579 | + | space. | |
| 575 | 580 | ||
| 576 | 581 | output = info flush-pkt | |
| 577 | 582 | ||
| 578 | - | info = PKT-LINE(attrs) LF) | |
| 579 | - | *PKT-LINE(obj-info LF) | |
| 583 | + | info = *PKT-LINE(attr LF) | |
| 584 | + | *PKT-LINE(obj-info LF) | |
| 585 | + | ||
| 586 | + | attr = "size" | "type" | |
| 587 | + | ||
| 588 | + | obj-size = 1*DIGIT | |
| 580 | 589 | ||
| 581 | - | attrs = attr | attrs SP attrs | |
| 590 | + | obj-type = "blob" | "tree" | "commit" | "tag" | |
| 582 | 591 | ||
| 583 | - | attr = "size" | |
| 592 | + | obj-val = obj-size | obj-type | |
| 584 | 593 | ||
| 585 | - | obj-info = obj-id SP obj-size | |
| 594 | + | obj-info = obj-id [SP [obj-val *(SP obj-val)]] | |
| 595 | + | ||
| 596 | + | The values in `obj-info` appear in the same order as the corresponding `attr` | |
| 597 | + | lines, with exactly one value per requested attribute. | |
| 598 | + | ||
| 599 | + | If the server does not recognize the OID, the response will be `<oid> SP` | |
| 600 | + | regardless of the number of attributes requested. | |
| 586 | 601 | ||
| 587 | 602 | bundle-uri | |
| 588 | 603 | ~~~~~~~~~~ | |
| @@ -848,6 +863,10 @@ advertised, it can reply with "promisor-remote=<pr-names>" where | |||
| 848 | 863 | where `pr-name` is the urlencoded name of a promisor remote the server | |
| 849 | 864 | advertised and the client accepts. | |
| 850 | 865 | ||
| 866 | + | The promisor remotes that the client accepted will be tried before the | |
| 867 | + | other configured promisor remotes when the client attempts to fetch | |
| 868 | + | missing objects. | |
| 869 | + | ||
| 851 | 870 | Note that, everywhere in this document, the ';' and ',' characters | |
| 852 | 871 | MUST be encoded if they appear in `pr-name` or `field-value`. | |
| 853 | 872 | ||
| @@ -862,10 +881,11 @@ the server advertised, the client shouldn't advertise the | |||
| 862 | 881 | ||
| 863 | 882 | On the server side, the "promisor.advertise" and "promisor.sendFields" | |
| 864 | 883 | configuration options can be used to control what it advertises. On | |
| 865 | - | the client side, the "promisor.acceptFromServer" configuration option | |
| 866 | - | can be used to control what it accepts, and the "promisor.storeFields" | |
| 867 | - | option, to control what it stores. See the documentation of these | |
| 868 | - | configuration options in linkgit:git-config[1] for more information. | |
| 884 | + | the client side, the "promisor.acceptFromServer" and | |
| 885 | + | "promisor.acceptFromServerUrl" configuration options can be used to | |
| 886 | + | control what it accepts, and the "promisor.storeFields" option, to | |
| 887 | + | control what it stores. See the documentation of these configuration | |
| 888 | + | options in linkgit:git-config[1] for more information. | |
| 869 | 889 | ||
| 870 | 890 | Note that in the future it would be nice if the "promisor-remote" | |
| 871 | 891 | protocol capability could be used by the server, when responding to | |
modified Documentation/glossary-content.adoc
| @@ -251,7 +251,8 @@ for a more flexible and robust system to do the same thing. | |||
| 251 | 251 | as objects. The index is a stored version of your | |
| 252 | 252 | <<def_working_tree,working tree>>. Truth be told, it can also contain a second, and even | |
| 253 | 253 | a third version of a working tree, which are used | |
| 254 | - | when <<def_merge,merging>>. | |
| 254 | + | when <<def_merge,merging>>. See "THE INDEX" in | |
| 255 | + | linkgit:gitdatamodel[7] for details. | |
| 255 | 256 | ||
| 256 | 257 | [[def_index_entry]]index entry:: | |
| 257 | 258 | The information regarding a particular file, stored in the | |
| @@ -290,7 +291,8 @@ This commit is referred to as a "merge commit", or sometimes just a | |||
| 290 | 291 | [[def_object]]object:: | |
| 291 | 292 | The unit of storage in Git. It is uniquely identified by the | |
| 292 | 293 | <<def_SHA1,SHA-1>> of its contents. Consequently, an | |
| 293 | - | object cannot be changed. | |
| 294 | + | object cannot be changed. See "OBJECTS" in | |
| 295 | + | linkgit:gitdatamodel[7] for details. | |
| 294 | 296 | ||
| 295 | 297 | [[def_object_database]]object database:: | |
| 296 | 298 | Stores a set of "objects", and an individual <<def_object,object>> is | |
| @@ -587,12 +589,17 @@ extended in the future: | |||
| 587 | 589 | Different subhierarchies are used for different purposes. For example, | |
| 588 | 590 | the `refs/heads/` hierarchy is used to represent local branches whereas | |
| 589 | 591 | the `refs/tags/` hierarchy is used to represent local tags.. | |
| 592 | + | + | |
| 593 | + | See also "REFERENCES" in linkgit:gitdatamodel[7]. | |
| 590 | 594 | ||
| 591 | 595 | [[def_reflog]]reflog:: | |
| 592 | 596 | A reflog shows the local "history" of a ref. In other words, | |
| 593 | 597 | it can tell you what the 3rd last revision in _this_ repository | |
| 594 | 598 | was, and what was the current state in _this_ repository, | |
| 595 | - | yesterday 9:14pm. See linkgit:git-reflog[1] for details. | |
| 599 | + | yesterday 9:14pm. | |
| 600 | + | + | |
| 601 | + | See "REFLOGS" in linkgit:gitdatamodel[7] for a short explanation of the | |
| 602 | + | format. See linkgit:git-reflog[1] for details. | |
| 596 | 603 | ||
| 597 | 604 | [[def_refspec]]refspec:: | |
| 598 | 605 | A "refspec" is used by <<def_fetch,fetch>> and | |
modified Documentation/line-range-options.adoc
| @@ -8,12 +8,14 @@ | |||
| 8 | 8 | give zero or one positive revision arguments, and | |
| 9 | 9 | _<start>_ and _<end>_ (or _<funcname>_) must exist in the starting revision. | |
| 10 | 10 | You can specify this option more than once. Implies `--patch`. | |
| 11 | - | Patch output can be suppressed using `--no-patch`, but other diff formats | |
| 12 | - | (namely `--raw`, `--numstat`, `--shortstat`, `--dirstat`, `--summary`, | |
| 13 | - | `--name-only`, `--name-status`, `--check`) are not currently implemented. | |
| 11 | + | Patch output can be suppressed using `--no-patch`. | |
| 12 | + | Non-patch diff formats `--raw`, `--name-only`, `--name-status`, | |
| 13 | + | and `--summary` are supported. Diff stat formats | |
| 14 | + | (`--stat`, `--numstat`, `--shortstat`, `--dirstat`) are not | |
| 15 | + | currently implemented. | |
| 14 | 16 | + | |
| 15 | 17 | Patch formatting options such as `--word-diff`, `--color-moved`, | |
| 16 | 18 | `--no-prefix`, and whitespace options (`-w`, `-b`) are supported, | |
| 17 | - | as are pickaxe options (`-S`, `-G`). | |
| 19 | + | as are pickaxe options (`-S`, `-G`) and `--diff-filter`. | |
| 18 | 20 | + | |
| 19 | 21 | include::line-range-format.adoc[] | |
modified Documentation/lint-gitlink.perl
| @@ -42,7 +42,7 @@ die "BUG: No list of valid linkgit:* files given" unless @ARGV; | |||
| 42 | 42 | while (<>) { | |
| 43 | 43 | my $line = $_; | |
| 44 | 44 | next if $line =~ /^\s*(ifn?def|endif)::/; | |
| 45 | - | while ($line =~ m/(.{,8})((git[-a-z]+|scalar)\[(\d)*\])/g) { | |
| 45 | + | while ($line =~ m/(.{0,8})((git[-a-z]+|scalar)\[(\d)*\])/g) { | |
| 46 | 46 | my $pos = pos $line; | |
| 47 | 47 | my ($macro, $target, $page, $section) = ($1, $2, $3, $4); | |
| 48 | 48 | if ( $macro ne "linkgit:" ) { | |
modified Documentation/meson.build
| @@ -55,6 +55,7 @@ manpages = { | |||
| 55 | 55 | 'git-for-each-ref.adoc' : 1, | |
| 56 | 56 | 'git-for-each-repo.adoc' : 1, | |
| 57 | 57 | 'git-format-patch.adoc' : 1, | |
| 58 | + | 'git-format-rev.adoc' : 1, | |
| 58 | 59 | 'git-fsck-objects.adoc' : 1, | |
| 59 | 60 | 'git-fsck.adoc' : 1, | |
| 60 | 61 | 'git-fsmonitor--daemon.adoc' : 1, | |
| @@ -155,6 +156,7 @@ manpages = { | |||
| 155 | 156 | 'git-update-server-info.adoc' : 1, | |
| 156 | 157 | 'git-upload-archive.adoc' : 1, | |
| 157 | 158 | 'git-upload-pack.adoc' : 1, | |
| 159 | + | 'git-url-parse.adoc' : 1, | |
| 158 | 160 | 'git-var.adoc' : 1, | |
| 159 | 161 | 'git-verify-commit.adoc' : 1, | |
| 160 | 162 | 'git-verify-pack.adoc' : 1, | |
modified Documentation/pack-refs-options.adoc
| @@ -1,4 +1,4 @@ | |||
| 1 | - | --all:: | |
| 1 | + | `--all`:: | |
| 2 | 2 | ||
| 3 | 3 | The command by default packs all tags and refs that are already | |
| 4 | 4 | packed, and leaves other refs | |
| @@ -8,12 +8,12 @@ This option causes all refs to be packed as well, with the exception | |||
| 8 | 8 | of hidden refs, broken refs, and symbolic refs. Useful for a repository | |
| 9 | 9 | with many branches of historical interests. | |
| 10 | 10 | ||
| 11 | - | --no-prune:: | |
| 11 | + | `--no-prune`:: | |
| 12 | 12 | ||
| 13 | 13 | The command usually removes loose refs under `$GIT_DIR/refs` | |
| 14 | 14 | hierarchy after packing them. This option tells it not to. | |
| 15 | 15 | ||
| 16 | - | --auto:: | |
| 16 | + | `--auto`:: | |
| 17 | 17 | ||
| 18 | 18 | Pack refs as needed depending on the current state of the ref database. The | |
| 19 | 19 | behavior depends on the ref format used by the repository and may change in the | |
| @@ -29,7 +29,7 @@ future. | |||
| 29 | 29 | maintains the property that N is at least twice as big as N+1. Only | |
| 30 | 30 | tables that violate this property are compacted. | |
| 31 | 31 | ||
| 32 | - | --include <pattern>:: | |
| 32 | + | `--include <pattern>`:: | |
| 33 | 33 | ||
| 34 | 34 | Pack refs based on a `glob(7)` pattern. Repetitions of this option | |
| 35 | 35 | accumulate inclusion patterns. If a ref is both included in `--include` and | |
| @@ -38,7 +38,7 @@ tags from being included by default. Symbolic refs and broken refs will never | |||
| 38 | 38 | be packed. When used with `--all`, it will be a noop. Use `--no-include` to clear | |
| 39 | 39 | and reset the list of patterns. | |
| 40 | 40 | ||
| 41 | - | --exclude <pattern>:: | |
| 41 | + | `--exclude <pattern>`:: | |
| 42 | 42 | ||
| 43 | 43 | Do not pack refs matching the given `glob(7)` pattern. Repetitions of this option | |
| 44 | 44 | accumulate exclusion patterns. Use `--no-exclude` to clear and reset the list of | |
modified Documentation/rev-list-options.adoc
| @@ -16,14 +16,18 @@ ordering and formatting options, such as `--reverse`. | |||
| 16 | 16 | `-<number>`:: | |
| 17 | 17 | `-n <number>`:: | |
| 18 | 18 | `--max-count=<number>`:: | |
| 19 | - | Limit the output to _<number>_ commits. | |
| 19 | + | Limit the output to the first _<number>_ commits that would be shown. | |
| 20 | + | ||
| 21 | + | `--max-count-oldest=<number>`:: | |
| 22 | + | Limit the output to the last _<number>_ commits that would be shown. | |
| 20 | 23 | ||
| 21 | 24 | `--skip=<number>`:: | |
| 22 | 25 | Skip _<number>_ commits before starting to show the commit output. | |
| 23 | 26 | ||
| 24 | 27 | `--since=<date>`:: | |
| 25 | 28 | `--after=<date>`:: | |
| 26 | - | Show commits more recent than _<date>_. | |
| 29 | + | Show commits more recent than _<date>_. As a special case, | |
| 30 | + | 'today' means the last midnight. | |
| 27 | 31 | ||
| 28 | 32 | `--since-as-filter=<date>`:: | |
| 29 | 33 | Show all commits more recent than _<date>_. This visits | |
| @@ -1079,6 +1083,19 @@ If some tips passed to the traversal are missing, they will be | |||
| 1079 | 1083 | considered as missing too, and the traversal will ignore them. In case | |
| 1080 | 1084 | we cannot get their Object ID though, an error will be raised. | |
| 1081 | 1085 | ||
| 1086 | + | `--missing-only`:: | |
| 1087 | + | When used together with `--missing=print` or `--missing=print-info`, | |
| 1088 | + | suppress all output for present objects and print only the missing | |
| 1089 | + | ones. The selected `--missing=` format is preserved (so | |
| 1090 | + | `--missing=print-info` still emits `path=` / `type=` fields), but the | |
| 1091 | + | leading ``?'' prefix used by the non-`-z` forms is omitted. This is | |
| 1092 | + | useful for scripting, as a simpler and faster alternative to | |
| 1093 | + | post-processing the output of `--missing=print`. | |
| 1094 | + | + | |
| 1095 | + | This option is incompatible with `--count` and `--disk-usage`. | |
| 1096 | + | It is an error to use `--missing-only` without `--missing=print` or | |
| 1097 | + | `--missing=print-info`. | |
| 1098 | + | ||
| 1082 | 1099 | `--exclude-promisor-objects`:: | |
| 1083 | 1100 | (For internal use only.) Prefilter object traversal at | |
| 1084 | 1101 | promisor boundary. This is used with partial clone. This is | |
| @@ -1259,6 +1276,20 @@ This implies the `--topo-order` option by default, but the | |||
| 1259 | 1276 | in between them in that case. If _<barrier>_ is specified, it | |
| 1260 | 1277 | is the string that will be shown instead of the default one. | |
| 1261 | 1278 | ||
| 1279 | + | `--graph-lane-limit=<n>`:: | |
| 1280 | + | When `--graph` is used, limit the number of graph lanes to be shown. | |
| 1281 | + | Lanes over the limit are replaced with a truncation mark '~'. | |
| 1282 | + | By default it is set to 0 (no limit), zero and negative values | |
| 1283 | + | are ignored and treated as no limit. | |
| 1284 | + | ||
| 1285 | + | `--no-graph-indent`:: | |
| 1286 | + | `--graph-indent`:: | |
| 1287 | + | When used with `--graph`, indent visual roots (commits with no parents | |
| 1288 | + | or whose parents are not shown) to differentiate them from commits that | |
| 1289 | + | are vertically adjacent but unrelated. Enabled by default. Use | |
| 1290 | + | `--no-graph-indent` to disable or set `log.graphIndent` to set a | |
| 1291 | + | default preference. | |
| 1292 | + | ||
| 1262 | 1293 | ifdef::git-rev-list[] | |
| 1263 | 1294 | `--count`:: | |
| 1264 | 1295 | Print a number stating how many commits would have been | |
modified Documentation/revisions.adoc
| @@ -127,6 +127,9 @@ some output processing may assume ref names in UTF-8. | |||
| 127 | 127 | `git push` were run while `branchname` was checked out (or the current | |
| 128 | 128 | `HEAD` if no branchname is specified). Like for '@\{upstream\}', we report | |
| 129 | 129 | the remote-tracking branch that corresponds to that branch at the remote. | |
| 130 | + | If the push destination is a URL and exactly one configured remote uses | |
| 131 | + | that URL for pushing, '@\{push}' reports that remote's remote-tracking | |
| 132 | + | branch. | |
| 130 | 133 | + | |
| 131 | 134 | Here's an example to make it more clear: | |
| 132 | 135 | + | |
modified Documentation/technical/api-parse-options.adoc
| @@ -150,8 +150,77 @@ Data Structure | |||
| 150 | 150 | ||
| 151 | 151 | The main data structure is an array of the `option` struct, | |
| 152 | 152 | say `static struct option builtin_add_options[]`. | |
| 153 | + | ||
| 154 | + | Option flags | |
| 155 | + | ~~~~~~~~~~~~ | |
| 156 | + | ||
| 157 | + | Each option can carry flags in the `flags` field of its `option` | |
| 158 | + | struct. These are per-option flags and are distinct from the | |
| 159 | + | `parse_options()` flags described above; they are usually set through | |
| 160 | + | the `OPT_*_F()` macro variants (see below) rather than by hand. They | |
| 161 | + | are the bitwise-or of: | |
| 162 | + | ||
| 163 | + | `PARSE_OPT_OPTARG`:: | |
| 164 | + | The option's argument is optional, i.e. both `--option` and | |
| 165 | + | `--option=<value>` are accepted. | |
| 166 | + | ||
| 167 | + | `PARSE_OPT_NOARG`:: | |
| 168 | + | The option takes no argument at all. Using `--option=<value>` | |
| 169 | + | is rejected. | |
| 170 | + | ||
| 171 | + | `PARSE_OPT_NONEG`:: | |
| 172 | + | Disable the automatically generated negated `--no-option` | |
| 173 | + | form. | |
| 174 | + | ||
| 175 | + | `PARSE_OPT_HIDDEN`:: | |
| 176 | + | Hide the option: it is omitted from the usage shown by | |
| 177 | + | `git <cmd> -h`, but is still shown by `git <cmd> --help-all`. | |
| 178 | + | The option is parsed as usual either way. This is meant for | |
| 179 | + | deprecated, advanced or otherwise uncommon options. | |
| 180 | + | ||
| 181 | + | `PARSE_OPT_LASTARG_DEFAULT`:: | |
| 182 | + | The no-argument form is only accepted when the option is the | |
| 183 | + | last token on the command line; used earlier, it still | |
| 184 | + | requires an argument. Should not be combined with | |
| 185 | + | `PARSE_OPT_OPTARG`. | |
| 186 | + | ||
| 187 | + | `PARSE_OPT_NODASH`:: | |
| 188 | + | The option is a single character without a leading dash, such | |
| 189 | + | as the `+` used by some commands. | |
| 190 | + | ||
| 191 | + | `PARSE_OPT_LITERAL_ARGHELP`:: | |
| 192 | + | Use the argument help string (`argh`) verbatim in the usage | |
| 193 | + | output instead of surrounding it with `<>` or `[]`. Useful when | |
| 194 | + | `argh` already contains a hand-formatted description. | |
| 195 | + | ||
| 196 | + | `PARSE_OPT_FROM_ALIAS`:: | |
| 197 | + | Internal flag, set on options that were expanded from a | |
| 198 | + | configured alias. It should not be set by callers. | |
| 199 | + | ||
| 200 | + | `PARSE_OPT_NOCOMPLETE`:: | |
| 201 | + | Do not offer this option for completion. | |
| 202 | + | ||
| 203 | + | `PARSE_OPT_COMP_ARG`:: | |
| 204 | + | The option's argument, rather than the option itself, is what | |
| 205 | + | should be completed. | |
| 206 | + | ||
| 207 | + | `PARSE_OPT_CMDMODE`:: | |
| 208 | + | The option is one of several mutually exclusive "command mode" | |
| 209 | + | options that share the same variable. Using more than one of | |
| 210 | + | them at once is rejected. | |
| 211 | + | ||
| 212 | + | Macros | |
| 213 | + | ~~~~~~ | |
| 214 | + | ||
| 153 | 215 | There are some macros to easily define options: | |
| 154 | 216 | ||
| 217 | + | Many of the macros below have an `_F` variant (for example `OPT_BOOL_F`, | |
| 218 | + | `OPT_STRING_F`, `OPT_INTEGER_F`, `OPT_SET_INT_F`, `OPT_BIT_F` and | |
| 219 | + | `OPT_CALLBACK_F`) that takes an additional trailing `flags` argument. | |
| 220 | + | That argument is the bitwise-or of the per-option flags described in the | |
| 221 | + | "Option flags" section above; the non-`_F` macros are simply defined | |
| 222 | + | with `flags` set to `0`. | |
| 223 | + | ||
| 155 | 224 | `OPT__ABBREV(&int_var)`:: | |
| 156 | 225 | Add `--abbrev[=<n>]`. | |
| 157 | 226 | ||
| @@ -175,10 +244,21 @@ There are some macros to easily define options: | |||
| 175 | 244 | describes the group or an empty string. | |
| 176 | 245 | Start the description with an upper-case letter. | |
| 177 | 246 | ||
| 247 | + | `OPT_HIDDEN_GROUP(description)`:: | |
| 248 | + | Like `OPT_GROUP()`, but the group header carries | |
| 249 | + | `PARSE_OPT_HIDDEN`, so it is only shown by `--help-all` and not | |
| 250 | + | by `-h`. Use it to label a group that contains only hidden | |
| 251 | + | options, which would otherwise show an empty header under `-h`. | |
| 252 | + | ||
| 178 | 253 | `OPT_BOOL(short, long, &int_var, description)`:: | |
| 179 | 254 | Introduce a boolean option. `int_var` is set to one with | |
| 180 | 255 | `--option` and set to zero with `--no-option`. | |
| 181 | 256 | ||
| 257 | + | `OPT_HIDDEN_BOOL(short, long, &int_var, description)`:: | |
| 258 | + | Like `OPT_BOOL()`, but the option carries `PARSE_OPT_HIDDEN`, | |
| 259 | + | so it is hidden from `-h` while still being shown by | |
| 260 | + | `--help-all`. | |
| 261 | + | ||
| 182 | 262 | `OPT_COUNTUP(short, long, &int_var, description)`:: | |
| 183 | 263 | Introduce a count-up option. | |
| 184 | 264 | Each use of `--option` increments `int_var`, starting from zero | |
modified Documentation/technical/api-path-walk.adoc
| @@ -48,6 +48,13 @@ commits. | |||
| 48 | 48 | applications could disable some options to make it simpler to walk | |
| 49 | 49 | the objects or to have fewer calls to `path_fn`. | |
| 50 | 50 | + | |
| 51 | + | Note that objects directly requested as pending objects (such as targets | |
| 52 | + | of lightweight tags or other ref tips) are always emitted to `path_fn`, | |
| 53 | + | even when the corresponding type flag is disabled. Only objects | |
| 54 | + | discovered during the tree walk are subject to these type filters. This | |
| 55 | + | ensures that objects specifically requested through the revision input | |
| 56 | + | are never silently dropped. | |
| 57 | + | + | |
| 51 | 58 | While it is possible to walk only commits in this way, consumers would be | |
| 52 | 59 | better off using the revision walk API instead. | |
| 53 | 60 | ||
modified Documentation/technical/build-systems.adoc
| @@ -47,7 +47,7 @@ Auto-detection of the following items is considered to be important: | |||
| 47 | 47 | ||
| 48 | 48 | - Check for the existence of headers. | |
| 49 | 49 | - Check for the existence of libraries. | |
| 50 | - | - Check for the existence of exectuables. | |
| 50 | + | - Check for the existence of executables. | |
| 51 | 51 | - Check for the runtime behavior of specific functions. | |
| 52 | 52 | - Check for specific link order requirements when multiple libraries are | |
| 53 | 53 | involved. | |
| @@ -106,7 +106,7 @@ by the build system: | |||
| 106 | 106 | ||
| 107 | 107 | - C: the primary compiled language used by Git, must be supported. Relevant | |
| 108 | 108 | toolchains are GCC, Clang and MSVC. | |
| 109 | - | - Rust: candidate as a second compiled lanugage, should be supported. Relevant | |
| 109 | + | - Rust: candidate as a second compiled language, should be supported. Relevant | |
| 110 | 110 | toolchains is the LLVM-based rustc. | |
| 111 | 111 | ||
| 112 | 112 | Built-in support for the respective languages is preferred over support that | |
| @@ -142,7 +142,7 @@ The following list of build systems are considered: | |||
| 142 | 142 | ||
| 143 | 143 | === GNU Make | |
| 144 | 144 | ||
| 145 | - | - Platform support: ubitquitous on all platforms, but not well-integrated into Windows. | |
| 145 | + | - Platform support: ubiquitous on all platforms, but not well-integrated into Windows. | |
| 146 | 146 | - Auto-detection: no built-in support for auto-detection of features. | |
| 147 | 147 | - Ease of use: easy to use, but discovering available options is hard. Makefile | |
| 148 | 148 | rules can quickly get out of hand once reaching a certain scope. | |
modified Documentation/technical/hash-function-transition.adoc
| @@ -545,7 +545,7 @@ Alternates | |||
| 545 | 545 | ~~~~~~~~~~ | |
| 546 | 546 | For the same reason, a SHA-256 repository cannot borrow objects from a | |
| 547 | 547 | SHA-1 repository using objects/info/alternates or | |
| 548 | - | $GIT_ALTERNATE_OBJECT_REPOSITORIES. | |
| 548 | + | $GIT_ALTERNATE_OBJECT_DIRECTORIES. | |
| 549 | 549 | ||
| 550 | 550 | git notes | |
| 551 | 551 | ~~~~~~~~~ | |
modified Documentation/technical/meson.build
| @@ -18,6 +18,7 @@ articles = [ | |||
| 18 | 18 | 'multi-pack-index.adoc', | |
| 19 | 19 | 'packfile-uri.adoc', | |
| 20 | 20 | 'pack-heuristics.adoc', | |
| 21 | + | 'paint-down-to-common.adoc', | |
| 21 | 22 | 'parallel-checkout.adoc', | |
| 22 | 23 | 'partial-clone.adoc', | |
| 23 | 24 | 'platform-support.adoc', | |
added Documentation/technical/paint-down-to-common.adoc mode 100644
| @@ -0,0 +1,155 @@ | |||
| 1 | + | Merge-Base Computation and paint_down_to_common() | |
| 2 | + | ================================================== | |
| 3 | + | ||
| 4 | + | The function `paint_down_to_common()` in `commit-reach.c` computes merge | |
| 5 | + | bases by walking the commit graph backwards from two sets of tips and | |
| 6 | + | finding where their ancestry meets. | |
| 7 | + | ||
| 8 | + | Use cases | |
| 9 | + | --------- | |
| 10 | + | ||
| 11 | + | Computing merge bases is used in two different ways: | |
| 12 | + | ||
| 13 | + | 1. *Finding all merge bases* (`merge-base --all`, `merge-tree`, | |
| 14 | + | `merge`, `rebase`). A merge base is a common ancestor that is | |
| 15 | + | not itself an ancestor of another common ancestor. | |
| 16 | + | ||
| 17 | + | 2. *Ancestry checks* (`in_merge_bases`, used by `merge-base | |
| 18 | + | --is-ancestor`, `branch -d`, `fetch`). These ask: "is commit A | |
| 19 | + | an ancestor of commit B?" If a common ancestor equals one of the | |
| 20 | + | inputs, that input is necessarily the only merge base -- no other | |
| 21 | + | common ancestor can be both as recent and not an ancestor of it. | |
| 22 | + | ||
| 23 | + | Both use cases share the same algorithm and implementation. | |
| 24 | + | ||
| 25 | + | Algorithm | |
| 26 | + | --------- | |
| 27 | + | ||
| 28 | + | Given a commit `one` and a set of commits `twos[]`, the walk paints | |
| 29 | + | commits with two colors: | |
| 30 | + | ||
| 31 | + | - PARENT1: reachable from `one` | |
| 32 | + | - PARENT2: reachable from any commit in `twos[]` | |
| 33 | + | ||
| 34 | + | The walk uses a priority queue ordered by generation number | |
| 35 | + | (highest first), breaking ties by commit date. Each step dequeues | |
| 36 | + | the highest-priority commit and propagates its paint flags to its | |
| 37 | + | parents, enqueuing any parent that gained new flags. When a | |
| 38 | + | commit receives both PARENT1 and PARENT2, it is a merge-base | |
| 39 | + | candidate. A candidate gains the STALE flag so its ancestors | |
| 40 | + | propagate staleness -- any deeper common ancestor is necessarily | |
| 41 | + | redundant. | |
| 42 | + | ||
| 43 | + | [[generation-regions]] | |
| 44 | + | Topologically ordered and unordered generation regions | |
| 45 | + | ------------------------------------------------------ | |
| 46 | + | ||
| 47 | + | Commits fall into two regions based on whether their generation | |
| 48 | + | numbers provide a topological ordering guarantee: | |
| 49 | + | ||
| 50 | + | .... | |
| 51 | + | +------------------------------------------+ | |
| 52 | + | | Unordered region | | |
| 53 | + | | generation = INFINITY or V1_MAX | | |
| 54 | + | | queue order: heuristic (commit date) | | |
| 55 | + | +------------------------------------------+ | |
| 56 | + | | | |
| 57 | + | v | |
| 58 | + | +------------------------------------------+ | |
| 59 | + | | Ordered region | | |
| 60 | + | | generation = finite, unsaturated | | |
| 61 | + | | queue order: topological | | |
| 62 | + | +------------------------------------------+ | |
| 63 | + | .... | |
| 64 | + | ||
| 65 | + | In the ordered region, a child's generation is strictly greater | |
| 66 | + | than its parent's. Same-generation commits are necessarily | |
| 67 | + | independent, so the queue always processes children before | |
| 68 | + | their parents. | |
| 69 | + | ||
| 70 | + | In the unordered region, parent-child pairs can share the same | |
| 71 | + | generation number, so topological order is not guaranteed. The | |
| 72 | + | queue uses commit-date as a heuristic, which typically produces | |
| 73 | + | a reasonable traversal order but may process a parent before | |
| 74 | + | its child. | |
| 75 | + | ||
| 76 | + | Commits not in the commit-graph have generation INFINITY; v1 | |
| 77 | + | commit-graphs saturate at V1_MAX. Both place commits in the | |
| 78 | + | unordered region. Any optimization that depends on generation | |
| 79 | + | ordering must account for this saturation boundary. The early | |
| 80 | + | exit gates compare against a topological ceiling -- | |
| 81 | + | `GENERATION_NUMBER_V1_MAX` for v1 graphs and | |
| 82 | + | `GENERATION_NUMBER_INFINITY` for v2 graphs -- so that saturated | |
| 83 | + | commits are treated as unordered. | |
| 84 | + | ||
| 85 | + | With generation ordering, values in the unordered region exceed | |
| 86 | + | those in the ordered region. The walk may therefore transition | |
| 87 | + | from the unordered region into the ordered region, but never in | |
| 88 | + | the reverse direction. Without a commit-graph, every commit has INFINITY | |
| 89 | + | and the walk operates entirely in the unordered region. | |
| 90 | + | ||
| 91 | + | In the ordered region, paint on a dequeued commit is final -- | |
| 92 | + | no future step can add flags to it. In the unordered region, | |
| 93 | + | a dequeued commit may later gain additional paint. Paint flags | |
| 94 | + | are only added, never removed, bounding the number of | |
| 95 | + | re-enqueues per commit. | |
| 96 | + | ||
| 97 | + | Termination | |
| 98 | + | ----------- | |
| 99 | + | ||
| 100 | + | The walk tracks the number of commits of each type in the queue | |
| 101 | + | (PARENT1-only, PARENT2-only, pending merge-base). The main loop | |
| 102 | + | ends when one of the following conditions holds: | |
| 103 | + | ||
| 104 | + | 1. The queue is empty. | |
| 105 | + | 2. The queue contains only stale entries. | |
| 106 | + | 3. Generation cutoff: the dequeued commit's generation is below | |
| 107 | + | a caller-supplied `min_generation` threshold. | |
| 108 | + | 4. Single result: the caller only needs one merge base, one has | |
| 109 | + | been found, and the walk has entered the ordered region. | |
| 110 | + | 5. Side exhaustion: no pure PARENT1 or pure PARENT2 commits | |
| 111 | + | remain in the queue, no pending merge-base candidates exist, | |
| 112 | + | and the walk has entered the ordered region. | |
| 113 | + | ||
| 114 | + | Stale entry condition | |
| 115 | + | ~~~~~~~~~~~~~~~~~~~~~ | |
| 116 | + | Once all queued entries are stale, no new merge-base candidates can | |
| 117 | + | be discovered -- that requires at least one non-stale commit from | |
| 118 | + | each side meeting. Continuing the walk could still invalidate | |
| 119 | + | existing candidates by proving one is an ancestor of another, but | |
| 120 | + | `remove_redundant()` handles that as a post-processing step, so it | |
| 121 | + | is safe to exit early. | |
| 122 | + | ||
| 123 | + | Side-exhaustion condition | |
| 124 | + | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 125 | + | A new merge-base requires commits from both sides to meet. When one | |
| 126 | + | side's exclusive counter reaches zero and there are no pending | |
| 127 | + | merge-base candidates, no future traversal step can produce a new | |
| 128 | + | candidate. This optimization only activates in the ordered region, | |
| 129 | + | where paint flags are final at visit time; in the unordered region, | |
| 130 | + | a side that appears exhausted could reappear through late paint | |
| 131 | + | propagation. | |
| 132 | + | ||
| 133 | + | Generation cutoff | |
| 134 | + | ~~~~~~~~~~~~~~~~~ | |
| 135 | + | Some callers (notably `remove_redundant()`) supply a `min_generation` | |
| 136 | + | threshold equal to the minimum generation of the input commits. | |
| 137 | + | These callers only need to determine reachability among the inputs, | |
| 138 | + | not find deep merge bases, so the walk can safely terminate when it | |
| 139 | + | dequeues a commit below this threshold. | |
| 140 | + | ||
| 141 | + | Single result | |
| 142 | + | ~~~~~~~~~~~~~ | |
| 143 | + | When only one merge base is needed and the walk is in the | |
| 144 | + | ordered region with generation ordering, the first candidate | |
| 145 | + | found is necessarily the highest-generation common ancestor. | |
| 146 | + | No remaining commit in the queue can be a descendant of this | |
| 147 | + | candidate (generation ordering guarantees children are visited | |
| 148 | + | first), so it cannot be redundant and the walk can stop | |
| 149 | + | immediately. | |
| 150 | + | ||
| 151 | + | Related documentation | |
| 152 | + | --------------------- | |
| 153 | + | ||
| 154 | + | - `Documentation/technical/commit-graph.adoc` -- generation numbers | |
| 155 | + | and the reachability closure property. | |
modified Documentation/technical/partial-clone.adoc
| @@ -159,7 +159,7 @@ and prefetch those objects in bulk. | |||
| 159 | 159 | - `repack` in GC has been updated to not touch promisor packfiles at all, | |
| 160 | 160 | and to only repack other objects. | |
| 161 | 161 | ||
| 162 | - | - The global variable "fetch_if_missing" is used to control whether an | |
| 162 | + | - The per-repository flag "fetch_if_missing" is used to control whether an | |
| 163 | 163 | object lookup will attempt to dynamically fetch a missing object or | |
| 164 | 164 | report an error. | |
| 165 | 165 | + | |
modified Documentation/technical/rerere.adoc
| @@ -77,7 +77,7 @@ Sorting hunks | |||
| 77 | 77 | ~~~~~~~~~~~~~ | |
| 78 | 78 | ||
| 79 | 79 | As before, let's imagine that a common ancestor had a file with line A | |
| 80 | - | its early part, and line X in its late part. And then four branches | |
| 80 | + | in its early part, and line X in its late part. And then four branches | |
| 81 | 81 | are forked that do these things: | |
| 82 | 82 | ||
| 83 | 83 | - AB: changes A to B | |
modified GIT-VERSION-GEN
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | - | DEF_VER=v2.54.0 | |
| 3 | + | DEF_VER=v2.56.0 | |
| 4 | 4 | ||
| 5 | 5 | LF=' | |
| 6 | 6 | ' | |
modified Makefile
| @@ -416,7 +416,7 @@ include shared.mak | |||
| 416 | 416 | # If your platform has OS-specific ways to tell if a repo is incompatible with | |
| 417 | 417 | # fsmonitor (whether the hook or IPC daemon version), set FSMONITOR_OS_SETTINGS | |
| 418 | 418 | # to the "<name>" of the corresponding `compat/fsmonitor/fsm-settings-<name>.c` | |
| 419 | - | # that implements the `fsm_os_settings__*()` routines. | |
| 419 | + | # and `compat/fsmonitor/fsm-ipc-<name>.c` files. | |
| 420 | 420 | # | |
| 421 | 421 | # Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test | |
| 422 | 422 | # programs in oss-fuzz/. | |
| @@ -494,12 +494,20 @@ include shared.mak | |||
| 494 | 494 | # | |
| 495 | 495 | # == Optional Rust support == | |
| 496 | 496 | # | |
| 497 | - | # Define WITH_RUST if you want to include features and subsystems written in | |
| 498 | - | # Rust into Git. For now, Rust is still an optional feature of the build | |
| 499 | - | # process. With Git 3.0 though, Rust will always be enabled. | |
| 497 | + | # Define NO_RUST if you want to disable features and subsystems written in Rust | |
| 498 | + | # from being compiled into Git. For now, Rust is still an optional feature of | |
| 499 | + | # the build process. With Git 3.0 though, Rust will always be enabled. | |
| 500 | 500 | # | |
| 501 | 501 | # Building Rust code requires Cargo. | |
| 502 | 502 | # | |
| 503 | + | # Define RUST_TARGETS if you want to cross-compile. If left unspecified, it uses | |
| 504 | + | # the default Rust target on the system. | |
| 505 | + | # | |
| 506 | + | # On macOS, this supports specifying multiple targets, separated by a space. | |
| 507 | + | # This will produce a Universal static library using `lipo`. | |
| 508 | + | # | |
| 509 | + | # Example: RUST_TARGETS="aarch64-apple-darwin x86_64-apple-darwin" | |
| 510 | + | # | |
| 503 | 511 | # == SHA-1 and SHA-256 defines == | |
| 504 | 512 | # | |
| 505 | 513 | # === SHA-1 backend === | |
| @@ -868,6 +876,7 @@ TEST_BUILTINS_OBJS += test-submodule-config.o | |||
| 868 | 876 | TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o | |
| 869 | 877 | TEST_BUILTINS_OBJS += test-submodule.o | |
| 870 | 878 | TEST_BUILTINS_OBJS += test-subprocess.o | |
| 879 | + | TEST_BUILTINS_OBJS += test-synthesize.o | |
| 871 | 880 | TEST_BUILTINS_OBJS += test-trace2.o | |
| 872 | 881 | TEST_BUILTINS_OBJS += test-truncate.o | |
| 873 | 882 | TEST_BUILTINS_OBJS += test-userdiff.o | |
| @@ -891,6 +900,7 @@ BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS)) | |||
| 891 | 900 | BUILT_INS += git-cherry$X | |
| 892 | 901 | BUILT_INS += git-cherry-pick$X | |
| 893 | 902 | BUILT_INS += git-format-patch$X | |
| 903 | + | BUILT_INS += git-format-rev$X | |
| 894 | 904 | BUILT_INS += git-fsck-objects$X | |
| 895 | 905 | BUILT_INS += git-init$X | |
| 896 | 906 | BUILT_INS += git-maintenance$X | |
| @@ -937,16 +947,19 @@ TEST_SHELL_PATH = $(SHELL_PATH) | |||
| 937 | 947 | ||
| 938 | 948 | LIB_FILE = libgit.a | |
| 939 | 949 | ||
| 950 | + | ifndef NO_RUST | |
| 940 | 951 | ifdef DEBUG | |
| 941 | - | RUST_TARGET_DIR = target/debug | |
| 952 | + | RUST_BUILD_CONFIG = debug | |
| 942 | 953 | else | |
| 943 | - | RUST_TARGET_DIR = target/release | |
| 954 | + | RUST_BUILD_CONFIG = release | |
| 944 | 955 | endif | |
| 945 | 956 | ||
| 946 | 957 | ifeq ($(uname_S),Windows) | |
| 947 | - | RUST_LIB = $(RUST_TARGET_DIR)/gitcore.lib | |
| 958 | + | RUST_LIB_NAME = gitcore.lib | |
| 948 | 959 | else | |
| 949 | - | RUST_LIB = $(RUST_TARGET_DIR)/libgitcore.a | |
| 960 | + | RUST_LIB_NAME = libgitcore.a | |
| 961 | + | endif | |
| 962 | + | RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME) | |
| 950 | 963 | endif | |
| 951 | 964 | ||
| 952 | 965 | GITLIBS = common-main.o $(LIB_FILE) | |
| @@ -1156,6 +1169,7 @@ LIB_OBJS += ewah/ewah_io.o | |||
| 1156 | 1169 | LIB_OBJS += ewah/ewah_rlw.o | |
| 1157 | 1170 | LIB_OBJS += exec-cmd.o | |
| 1158 | 1171 | LIB_OBJS += fetch-negotiator.o | |
| 1172 | + | LIB_OBJS += fetch-object-info.o | |
| 1159 | 1173 | LIB_OBJS += fetch-pack.o | |
| 1160 | 1174 | LIB_OBJS += fmt-merge-msg.o | |
| 1161 | 1175 | LIB_OBJS += fsck.o | |
| @@ -1214,7 +1228,11 @@ LIB_OBJS += object.o | |||
| 1214 | 1228 | LIB_OBJS += odb.o | |
| 1215 | 1229 | LIB_OBJS += odb/source.o | |
| 1216 | 1230 | LIB_OBJS += odb/source-files.o | |
| 1231 | + | LIB_OBJS += odb/source-inmemory.o | |
| 1232 | + | LIB_OBJS += odb/source-loose.o | |
| 1233 | + | LIB_OBJS += odb/source-packed.o | |
| 1217 | 1234 | LIB_OBJS += odb/streaming.o | |
| 1235 | + | LIB_OBJS += odb/transaction.o | |
| 1218 | 1236 | LIB_OBJS += oid-array.o | |
| 1219 | 1237 | LIB_OBJS += oidmap.o | |
| 1220 | 1238 | LIB_OBJS += oidset.o | |
| @@ -1228,6 +1246,7 @@ LIB_OBJS += pack-refs.o | |||
| 1228 | 1246 | LIB_OBJS += pack-revindex.o | |
| 1229 | 1247 | LIB_OBJS += pack-write.o | |
| 1230 | 1248 | LIB_OBJS += packfile.o | |
| 1249 | + | LIB_OBJS += packfile-list.o | |
| 1231 | 1250 | LIB_OBJS += pager.o | |
| 1232 | 1251 | LIB_OBJS += parallel-checkout.o | |
| 1233 | 1252 | LIB_OBJS += parse.o | |
| @@ -1347,7 +1366,7 @@ LIB_OBJS += urlmatch.o | |||
| 1347 | 1366 | LIB_OBJS += usage.o | |
| 1348 | 1367 | LIB_OBJS += userdiff.o | |
| 1349 | 1368 | LIB_OBJS += utf8.o | |
| 1350 | - | ifndef WITH_RUST | |
| 1369 | + | ifdef NO_RUST | |
| 1351 | 1370 | LIB_OBJS += varint.o | |
| 1352 | 1371 | endif | |
| 1353 | 1372 | LIB_OBJS += version.o | |
| @@ -1493,6 +1512,7 @@ BUILTIN_OBJS += builtin/update-ref.o | |||
| 1493 | 1512 | BUILTIN_OBJS += builtin/update-server-info.o | |
| 1494 | 1513 | BUILTIN_OBJS += builtin/upload-archive.o | |
| 1495 | 1514 | BUILTIN_OBJS += builtin/upload-pack.o | |
| 1515 | + | BUILTIN_OBJS += builtin/url-parse.o | |
| 1496 | 1516 | BUILTIN_OBJS += builtin/var.o | |
| 1497 | 1517 | BUILTIN_OBJS += builtin/verify-commit.o | |
| 1498 | 1518 | BUILTIN_OBJS += builtin/verify-pack.o | |
| @@ -1522,6 +1542,7 @@ CLAR_TEST_SUITES += u-hash | |||
| 1522 | 1542 | CLAR_TEST_SUITES += u-hashmap | |
| 1523 | 1543 | CLAR_TEST_SUITES += u-list-objects-filter-options | |
| 1524 | 1544 | CLAR_TEST_SUITES += u-mem-pool | |
| 1545 | + | CLAR_TEST_SUITES += u-odb-inmemory | |
| 1525 | 1546 | CLAR_TEST_SUITES += u-oid-array | |
| 1526 | 1547 | CLAR_TEST_SUITES += u-oidmap | |
| 1527 | 1548 | CLAR_TEST_SUITES += u-oidtree | |
| @@ -1585,7 +1606,7 @@ endif | |||
| 1585 | 1606 | ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND) | |
| 1586 | 1607 | ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND) | |
| 1587 | 1608 | ||
| 1588 | - | ifdef WITH_RUST | |
| 1609 | + | ifndef NO_RUST | |
| 1589 | 1610 | BASIC_CFLAGS += -DWITH_RUST | |
| 1590 | 1611 | GITLIBS += $(RUST_LIB) | |
| 1591 | 1612 | ifeq ($(uname_S),Windows) | |
| @@ -2024,6 +2045,10 @@ ifdef NO_PREAD | |||
| 2024 | 2045 | COMPAT_CFLAGS += -DNO_PREAD | |
| 2025 | 2046 | COMPAT_OBJS += compat/pread.o | |
| 2026 | 2047 | endif | |
| 2048 | + | ifdef NO_WRITEV | |
| 2049 | + | COMPAT_CFLAGS += -DNO_WRITEV | |
| 2050 | + | COMPAT_OBJS += compat/writev.o | |
| 2051 | + | endif | |
| 2027 | 2052 | ifdef NO_FAST_WORKING_DIRECTORY | |
| 2028 | 2053 | BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY | |
| 2029 | 2054 | endif | |
| @@ -2368,13 +2393,13 @@ ifdef FSMONITOR_DAEMON_BACKEND | |||
| 2368 | 2393 | COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND | |
| 2369 | 2394 | COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o | |
| 2370 | 2395 | COMPAT_OBJS += compat/fsmonitor/fsm-health-$(FSMONITOR_DAEMON_BACKEND).o | |
| 2371 | - | COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_BACKEND).o | |
| 2372 | 2396 | endif | |
| 2373 | 2397 | ||
| 2374 | 2398 | ifdef FSMONITOR_OS_SETTINGS | |
| 2375 | 2399 | COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS | |
| 2400 | + | COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_OS_SETTINGS).o | |
| 2376 | 2401 | COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o | |
| 2377 | - | COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o | |
| 2402 | + | COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_DAEMON_BACKEND).o | |
| 2378 | 2403 | endif | |
| 2379 | 2404 | ||
| 2380 | 2405 | ifdef WITH_BREAKING_CHANGES | |
| @@ -2592,6 +2617,7 @@ FUZZ_OBJS += oss-fuzz/fuzz-date.o | |||
| 2592 | 2617 | FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o | |
| 2593 | 2618 | FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o | |
| 2594 | 2619 | FUZZ_OBJS += oss-fuzz/fuzz-parse-attr-line.o | |
| 2620 | + | FUZZ_OBJS += oss-fuzz/fuzz-reftable.o | |
| 2595 | 2621 | FUZZ_OBJS += oss-fuzz/fuzz-url-decode-mem.o | |
| 2596 | 2622 | .PHONY: fuzz-objs | |
| 2597 | 2623 | fuzz-objs: $(FUZZ_OBJS) | |
| @@ -2660,7 +2686,7 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) | |||
| 2660 | 2686 | ||
| 2661 | 2687 | help.sp help.s help.o: command-list.h | |
| 2662 | 2688 | builtin/bugreport.sp builtin/bugreport.s builtin/bugreport.o: hook-list.h | |
| 2663 | - | builtin/hook.sp builtin/hook.s builtin/hook.o: hook-list.h | |
| 2689 | + | hook.sp hook.s hook.o: hook-list.h | |
| 2664 | 2690 | ||
| 2665 | 2691 | builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX | |
| 2666 | 2692 | builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ | |
| @@ -3010,11 +3036,35 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS) | |||
| 3010 | 3036 | $(LIB_FILE): $(LIB_OBJS) | |
| 3011 | 3037 | $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^ | |
| 3012 | 3038 | ||
| 3039 | + | ifndef NO_RUST | |
| 3040 | + | ifeq ($(RUST_TARGETS),) | |
| 3013 | 3041 | $(RUST_LIB): Cargo.toml $(RUST_SOURCES) $(LIB_FILE) | |
| 3014 | 3042 | $(QUIET_CARGO)cargo build $(CARGO_ARGS) | |
| 3043 | + | else | |
| 3044 | + | ifneq ($(words $(RUST_TARGETS)),1) | |
| 3045 | + | ifneq ($(uname_S),Darwin) | |
| 3046 | + | $(error Building universal Rust libraries requires macOS (lipo is not available on $(uname_S))) | |
| 3047 | + | endif | |
| 3048 | + | endif | |
| 3049 | + | ||
| 3050 | + | RUST_MEMBER_LIBS = $(foreach target,$(RUST_TARGETS),target/$(target)/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)) | |
| 3051 | + | $(RUST_MEMBER_LIBS): target/%/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME): Cargo.toml $(RUST_SOURCES) $(LIB_FILE) | |
| 3052 | + | $(QUIET_CARGO)cargo build $(CARGO_ARGS) --target $* | |
| 3053 | + | ||
| 3054 | + | $(RUST_LIB): $(RUST_MEMBER_LIBS) | |
| 3055 | + | $(call mkdir_p_parent_template) | |
| 3056 | + | $(QUIET_GEN)\ | |
| 3057 | + | if test $(words $(RUST_TARGETS)) -gt 1; \ | |
| 3058 | + | then \ | |
| 3059 | + | lipo -create $^ -output $@; \ | |
| 3060 | + | else \ | |
| 3061 | + | cp $< $@; \ | |
| 3062 | + | fi | |
| 3063 | + | endif | |
| 3015 | 3064 | ||
| 3016 | 3065 | .PHONY: rust | |
| 3017 | 3066 | rust: $(RUST_LIB) | |
| 3067 | + | endif | |
| 3018 | 3068 | ||
| 3019 | 3069 | export DEFAULT_EDITOR DEFAULT_PAGER | |
| 3020 | 3070 | ||
| @@ -4065,9 +4115,10 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT) | |||
| 4065 | 4115 | contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT) | |
| 4066 | 4116 | $(AR) $(ARFLAGS) $@ $^ | |
| 4067 | 4117 | ||
| 4068 | - | contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) GIT-LDFLAGS | |
| 4118 | + | # When Rust is enabled, git-credential-osxkeychain depends on Rust symbols in $(RUST_LIB) | |
| 4119 | + | contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) $(RUST_LIB) GIT-LDFLAGS | |
| 4069 | 4120 | $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \ | |
| 4070 | - | $(filter %.o,$^) $(LIB_FILE) $(EXTLIBS) -framework Security -framework CoreFoundation | |
| 4121 | + | $(filter %.o,$^) $(LIBS) -framework Security -framework CoreFoundation | |
| 4071 | 4122 | ||
| 4072 | 4123 | contrib/credential/osxkeychain/git-credential-osxkeychain.o: contrib/credential/osxkeychain/git-credential-osxkeychain.c GIT-CFLAGS | |
| 4073 | 4124 | $(QUIET_LINK)$(CC) -o $@ -c $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $< | |
modified README.md
| @@ -1,4 +1,5 @@ | |||
| 1 | - | [](https://github.com/git/git/actions?query=branch%3Amaster+event%3Apush) | |
| 1 | + | [](https://github.com/git/git/actions?query=branch%3Amaster+event%3Apush) | |
| 2 | + | [](https://gitlab.com/git-scm/git/-/pipelines?ref=master) | |
| 2 | 3 | ||
| 3 | 4 | Git - fast, scalable, distributed revision control system | |
| 4 | 5 | ========================================================= | |
modified RelNotes
| @@ -1 +1 @@ | |||
| 1 | - | Documentation/RelNotes/2.54.1.adocโ | |
| 1 | + | Documentation/RelNotes/2.56.0.adocโ | |
modified advice.c
| @@ -69,6 +69,7 @@ static struct { | |||
| 69 | 69 | [ADVICE_PUSH_NON_FF_CURRENT] = { "pushNonFFCurrent" }, | |
| 70 | 70 | [ADVICE_PUSH_NON_FF_MATCHING] = { "pushNonFFMatching" }, | |
| 71 | 71 | [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "pushRefNeedsUpdate" }, | |
| 72 | + | [ADVICE_PUSH_REPO_LOOKS_LIKE_REF] = { "pushRepoLooksLikeRef" }, | |
| 72 | 73 | [ADVICE_PUSH_UNQUALIFIED_REF_NAME] = { "pushUnqualifiedRefName" }, | |
| 73 | 74 | [ADVICE_PUSH_UPDATE_REJECTED] = { "pushUpdateRejected" }, | |
| 74 | 75 | [ADVICE_PUSH_UPDATE_REJECTED_ALIAS] = { "pushNonFastForward" }, /* backwards compatibility */ | |
modified advice.h
| @@ -36,6 +36,7 @@ enum advice_type { | |||
| 36 | 36 | ADVICE_PUSH_NON_FF_CURRENT, | |
| 37 | 37 | ADVICE_PUSH_NON_FF_MATCHING, | |
| 38 | 38 | ADVICE_PUSH_REF_NEEDS_UPDATE, | |
| 39 | + | ADVICE_PUSH_REPO_LOOKS_LIKE_REF, | |
| 39 | 40 | ADVICE_PUSH_UNQUALIFIED_REF_NAME, | |
| 40 | 41 | ADVICE_PUSH_UPDATE_REJECTED, | |
| 41 | 42 | ADVICE_PUSH_UPDATE_REJECTED_ALIAS, | |
modified apply.c
| @@ -47,11 +47,17 @@ struct gitdiff_data { | |||
| 47 | 47 | int p_value; | |
| 48 | 48 | }; | |
| 49 | 49 | ||
| 50 | - | static void git_apply_config(void) | |
| 50 | + | static void git_apply_config(struct repository *repo) | |
| 51 | 51 | { | |
| 52 | - | repo_config_get_string(the_repository, "apply.whitespace", &apply_default_whitespace); | |
| 53 | - | repo_config_get_string(the_repository, "apply.ignorewhitespace", &apply_default_ignorewhitespace); | |
| 54 | - | repo_config(the_repository, git_xmerge_config, NULL); | |
| 52 | + | struct repo_config_values *cfg = repo_config_values(repo); | |
| 53 | + | ||
| 54 | + | FREE_AND_NULL(cfg->apply_default_whitespace); | |
| 55 | + | repo_config_get_string(repo, "apply.whitespace", | |
| 56 | + | &cfg->apply_default_whitespace); | |
| 57 | + | FREE_AND_NULL(cfg->apply_default_ignorewhitespace); | |
| 58 | + | repo_config_get_string(repo, "apply.ignorewhitespace", | |
| 59 | + | &cfg->apply_default_ignorewhitespace); | |
| 60 | + | repo_config(repo, git_xmerge_config, NULL); | |
| 55 | 61 | } | |
| 56 | 62 | ||
| 57 | 63 | static int parse_whitespace_option(struct apply_state *state, const char *option) | |
| @@ -109,6 +115,8 @@ int init_apply_state(struct apply_state *state, | |||
| 109 | 115 | struct repository *repo, | |
| 110 | 116 | const char *prefix) | |
| 111 | 117 | { | |
| 118 | + | struct repo_config_values *cfg = repo_config_values(repo); | |
| 119 | + | ||
| 112 | 120 | memset(state, 0, sizeof(*state)); | |
| 113 | 121 | state->prefix = prefix; | |
| 114 | 122 | state->repo = repo; | |
| @@ -126,10 +134,13 @@ int init_apply_state(struct apply_state *state, | |||
| 126 | 134 | strset_init(&state->kept_symlinks); | |
| 127 | 135 | strbuf_init(&state->root, 0); | |
| 128 | 136 | ||
| 129 | - | git_apply_config(); | |
| 130 | - | if (apply_default_whitespace && parse_whitespace_option(state, apply_default_whitespace)) | |
| 137 | + | git_apply_config(repo); | |
| 138 | + | ||
| 139 | + | if (cfg->apply_default_whitespace && | |
| 140 | + | parse_whitespace_option(state, cfg->apply_default_whitespace)) | |
| 131 | 141 | return -1; | |
| 132 | - | if (apply_default_ignorewhitespace && parse_ignorewhitespace_option(state, apply_default_ignorewhitespace)) | |
| 142 | + | if (cfg->apply_default_ignorewhitespace && | |
| 143 | + | parse_ignorewhitespace_option(state, cfg->apply_default_ignorewhitespace)) | |
| 133 | 144 | return -1; | |
| 134 | 145 | return 0; | |
| 135 | 146 | } | |
| @@ -192,7 +203,8 @@ int check_apply_state(struct apply_state *state, int force_apply) | |||
| 192 | 203 | ||
| 193 | 204 | static void set_default_whitespace_mode(struct apply_state *state) | |
| 194 | 205 | { | |
| 195 | - | if (!state->whitespace_option && !apply_default_whitespace) | |
| 206 | + | if (!state->whitespace_option && | |
| 207 | + | !repo_config_values(state->repo)->apply_default_whitespace) | |
| 196 | 208 | state->ws_error_action = (state->apply ? warn_on_ws_error : nowarn_ws_error); | |
| 197 | 209 | } | |
| 198 | 210 | ||
| @@ -3232,7 +3244,7 @@ static int apply_binary_fragment(struct apply_state *state, | |||
| 3232 | 3244 | struct patch *patch) | |
| 3233 | 3245 | { | |
| 3234 | 3246 | struct fragment *fragment = patch->fragments; | |
| 3235 | - | unsigned long len; | |
| 3247 | + | size_t len; | |
| 3236 | 3248 | void *dst; | |
| 3237 | 3249 | ||
| 3238 | 3250 | if (!fragment) | |
| @@ -3321,7 +3333,7 @@ static int apply_binary(struct apply_state *state, | |||
| 3321 | 3333 | if (odb_has_object(the_repository->objects, &oid, 0)) { | |
| 3322 | 3334 | /* We already have the postimage */ | |
| 3323 | 3335 | enum object_type type; | |
| 3324 | - | unsigned long size; | |
| 3336 | + | size_t size; | |
| 3325 | 3337 | char *result; | |
| 3326 | 3338 | ||
| 3327 | 3339 | result = odb_read_object(the_repository->objects, &oid, | |
| @@ -3384,7 +3396,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns | |||
| 3384 | 3396 | strbuf_addf(buf, "Subproject commit %s\n", oid_to_hex(oid)); | |
| 3385 | 3397 | } else { | |
| 3386 | 3398 | enum object_type type; | |
| 3387 | - | unsigned long sz; | |
| 3399 | + | size_t sz; | |
| 3388 | 3400 | char *result; | |
| 3389 | 3401 | ||
| 3390 | 3402 | result = odb_read_object(the_repository->objects, oid, | |
| @@ -3611,7 +3623,7 @@ static int load_preimage(struct apply_state *state, | |||
| 3611 | 3623 | ||
| 3612 | 3624 | static int resolve_to(struct image *image, const struct object_id *result_id) | |
| 3613 | 3625 | { | |
| 3614 | - | unsigned long size; | |
| 3626 | + | size_t size; | |
| 3615 | 3627 | enum object_type type; | |
| 3616 | 3628 | char *data; | |
| 3617 | 3629 | ||
| @@ -3893,8 +3905,8 @@ static int check_preimage(struct apply_state *state, | |||
| 3893 | 3905 | if (*ce && !(*ce)->ce_mode) | |
| 3894 | 3906 | BUG("ce_mode == 0 for path '%s'", old_name); | |
| 3895 | 3907 | ||
| 3896 | - | if (trust_executable_bit || !S_ISREG(st->st_mode)) | |
| 3897 | - | st_mode = ce_mode_from_stat(*ce, st->st_mode); | |
| 3908 | + | if (repo_trust_executable_bit(state->repo) || !S_ISREG(st->st_mode)) | |
| 3909 | + | st_mode = ce_mode_from_stat(state->repo, *ce, st->st_mode); | |
| 3898 | 3910 | else if (*ce) | |
| 3899 | 3911 | st_mode = (*ce)->ce_mode; | |
| 3900 | 3912 | else | |
| @@ -4008,7 +4020,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *na | |||
| 4008 | 4020 | struct cache_entry *ce; | |
| 4009 | 4021 | ||
| 4010 | 4022 | ce = index_file_exists(state->repo->index, name->buf, | |
| 4011 | - | name->len, ignore_case); | |
| 4023 | + | name->len, repo_ignore_case(the_repository)); | |
| 4012 | 4024 | if (ce && S_ISLNK(ce->ce_mode)) | |
| 4013 | 4025 | return 1; | |
| 4014 | 4026 | } else { | |
| @@ -4287,7 +4299,8 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list) | |||
| 4287 | 4299 | } | |
| 4288 | 4300 | } | |
| 4289 | 4301 | ||
| 4290 | - | hold_lock_file_for_update(&lock, state->fake_ancestor, LOCK_DIE_ON_ERROR); | |
| 4302 | + | repo_hold_lock_file_for_update(state->repo, &lock, state->fake_ancestor, | |
| 4303 | + | LOCK_DIE_ON_ERROR); | |
| 4291 | 4304 | res = write_locked_index(&result, &lock, COMMIT_LOCK); | |
| 4292 | 4305 | discard_index(&result); | |
| 4293 | 4306 | ||
| @@ -4511,7 +4524,7 @@ static int try_create_file(struct apply_state *state, const char *path, | |||
| 4511 | 4524 | return !!mkdir(path, 0777); | |
| 4512 | 4525 | } | |
| 4513 | 4526 | ||
| 4514 | - | if (has_symlinks && S_ISLNK(mode)) | |
| 4527 | + | if (repo_has_symlinks(state->repo) && S_ISLNK(mode)) | |
| 4515 | 4528 | /* Although buf:size is counted string, it also is NUL | |
| 4516 | 4529 | * terminated. | |
| 4517 | 4530 | */ | |
| @@ -4881,8 +4894,10 @@ static int apply_patch(struct apply_state *state, | |||
| 4881 | 4894 | ||
| 4882 | 4895 | state->patch_input_file = filename; | |
| 4883 | 4896 | state->linenr = 1; | |
| 4884 | - | if (read_patch_file(&buf, fd) < 0) | |
| 4885 | - | return -128; | |
| 4897 | + | if (read_patch_file(&buf, fd) < 0) { | |
| 4898 | + | res = -128; | |
| 4899 | + | goto end; | |
| 4900 | + | } | |
| 4886 | 4901 | offset = 0; | |
| 4887 | 4902 | while (offset < buf.len) { | |
| 4888 | 4903 | struct patch *patch; | |
| @@ -4943,9 +4958,10 @@ static int apply_patch(struct apply_state *state, | |||
| 4943 | 4958 | state->update_index = (state->check_index || state->ita_only) && state->apply; | |
| 4944 | 4959 | if (state->update_index && !is_lock_file_locked(&state->lock_file)) { | |
| 4945 | 4960 | if (state->index_file) | |
| 4946 | - | hold_lock_file_for_update(&state->lock_file, | |
| 4947 | - | state->index_file, | |
| 4948 | - | LOCK_DIE_ON_ERROR); | |
| 4961 | + | repo_hold_lock_file_for_update(state->repo, | |
| 4962 | + | &state->lock_file, | |
| 4963 | + | state->index_file, | |
| 4964 | + | LOCK_DIE_ON_ERROR); | |
| 4949 | 4965 | else | |
| 4950 | 4966 | repo_hold_locked_index(state->repo, &state->lock_file, | |
| 4951 | 4967 | LOCK_DIE_ON_ERROR); | |
modified archive-tar.c
| @@ -129,20 +129,20 @@ static void write_trailer(void) | |||
| 129 | 129 | */ | |
| 130 | 130 | static int stream_blocked(struct repository *r, const struct object_id *oid) | |
| 131 | 131 | { | |
| 132 | - | struct odb_read_stream *st; | |
| 132 | + | struct odb_stream *st; | |
| 133 | 133 | char buf[BLOCKSIZE]; | |
| 134 | 134 | ssize_t readlen; | |
| 135 | 135 | ||
| 136 | - | st = odb_read_stream_open(r->objects, oid, NULL); | |
| 136 | + | st = odb_stream_from_object(r->objects, oid, NULL); | |
| 137 | 137 | if (!st) | |
| 138 | 138 | return error(_("cannot stream blob %s"), oid_to_hex(oid)); | |
| 139 | 139 | for (;;) { | |
| 140 | - | readlen = odb_read_stream_read(st, buf, sizeof(buf)); | |
| 140 | + | readlen = odb_stream_read(st, buf, sizeof(buf)); | |
| 141 | 141 | if (readlen <= 0) | |
| 142 | 142 | break; | |
| 143 | 143 | do_write_blocked(buf, readlen); | |
| 144 | 144 | } | |
| 145 | - | odb_read_stream_close(st); | |
| 145 | + | odb_stream_close(st); | |
| 146 | 146 | if (!readlen) | |
| 147 | 147 | finish_record(); | |
| 148 | 148 | return readlen; | |
modified archive-zip.c
| @@ -206,7 +206,7 @@ static void *zlib_deflate_raw(void *data, unsigned long size, | |||
| 206 | 206 | unsigned long *compressed_size) | |
| 207 | 207 | { | |
| 208 | 208 | git_zstream stream; | |
| 209 | - | unsigned long maxsize; | |
| 209 | + | size_t maxsize; | |
| 210 | 210 | void *buffer; | |
| 211 | 211 | int result; | |
| 212 | 212 | ||
| @@ -309,7 +309,7 @@ static int write_zip_entry(struct archiver_args *args, | |||
| 309 | 309 | enum zip_method method; | |
| 310 | 310 | unsigned char *out; | |
| 311 | 311 | void *deflated = NULL; | |
| 312 | - | struct odb_read_stream *stream = NULL; | |
| 312 | + | struct odb_stream *stream = NULL; | |
| 313 | 313 | unsigned long flags = 0; | |
| 314 | 314 | int is_binary = -1; | |
| 315 | 315 | const char *path_without_prefix = path + args->baselen; | |
| @@ -347,7 +347,7 @@ static int write_zip_entry(struct archiver_args *args, | |||
| 347 | 347 | method = ZIP_METHOD_DEFLATE; | |
| 348 | 348 | ||
| 349 | 349 | if (!buffer) { | |
| 350 | - | stream = odb_read_stream_open(args->repo->objects, oid, NULL); | |
| 350 | + | stream = odb_stream_from_object(args->repo->objects, oid, NULL); | |
| 351 | 351 | if (!stream) | |
| 352 | 352 | return error(_("cannot stream blob %s"), | |
| 353 | 353 | oid_to_hex(oid)); | |
| @@ -428,7 +428,7 @@ static int write_zip_entry(struct archiver_args *args, | |||
| 428 | 428 | ssize_t readlen; | |
| 429 | 429 | ||
| 430 | 430 | for (;;) { | |
| 431 | - | readlen = odb_read_stream_read(stream, buf, sizeof(buf)); | |
| 431 | + | readlen = odb_stream_read(stream, buf, sizeof(buf)); | |
| 432 | 432 | if (readlen <= 0) | |
| 433 | 433 | break; | |
| 434 | 434 | crc = crc32(crc, buf, readlen); | |
| @@ -438,7 +438,7 @@ static int write_zip_entry(struct archiver_args *args, | |||
| 438 | 438 | buf, readlen); | |
| 439 | 439 | write_or_die(1, buf, readlen); | |
| 440 | 440 | } | |
| 441 | - | odb_read_stream_close(stream); | |
| 441 | + | odb_stream_close(stream); | |
| 442 | 442 | if (readlen) | |
| 443 | 443 | return readlen; | |
| 444 | 444 | ||
| @@ -461,7 +461,7 @@ static int write_zip_entry(struct archiver_args *args, | |||
| 461 | 461 | zstream.avail_out = sizeof(compressed); | |
| 462 | 462 | ||
| 463 | 463 | for (;;) { | |
| 464 | - | readlen = odb_read_stream_read(stream, buf, sizeof(buf)); | |
| 464 | + | readlen = odb_stream_read(stream, buf, sizeof(buf)); | |
| 465 | 465 | if (readlen <= 0) | |
| 466 | 466 | break; | |
| 467 | 467 | crc = crc32(crc, buf, readlen); | |
| @@ -485,7 +485,7 @@ static int write_zip_entry(struct archiver_args *args, | |||
| 485 | 485 | } | |
| 486 | 486 | ||
| 487 | 487 | } | |
| 488 | - | odb_read_stream_close(stream); | |
| 488 | + | odb_stream_close(stream); | |
| 489 | 489 | if (readlen) | |
| 490 | 490 | return readlen; | |
| 491 | 491 | ||
modified archive.c
| @@ -87,7 +87,7 @@ static void *object_file_to_archive(const struct archiver_args *args, | |||
| 87 | 87 | const struct object_id *oid, | |
| 88 | 88 | unsigned int mode, | |
| 89 | 89 | enum object_type *type, | |
| 90 | - | unsigned long *sizep) | |
| 90 | + | size_t *sizep) | |
| 91 | 91 | { | |
| 92 | 92 | void *buffer; | |
| 93 | 93 | const struct commit *commit = args->convert ? args->commit : NULL; | |
| @@ -158,7 +158,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base, | |||
| 158 | 158 | write_archive_entry_fn_t write_entry = c->write_entry; | |
| 159 | 159 | int err; | |
| 160 | 160 | const char *path_without_prefix; | |
| 161 | - | unsigned long size; | |
| 161 | + | size_t size; | |
| 162 | 162 | void *buffer; | |
| 163 | 163 | enum object_type type; | |
| 164 | 164 | ||
| @@ -786,7 +786,7 @@ int write_archive(int argc, const char **argv, const char *prefix, | |||
| 786 | 786 | * die ourselves; but its error message will be more specific | |
| 787 | 787 | * than what we could write here. | |
| 788 | 788 | */ | |
| 789 | - | setup_git_directory(); | |
| 789 | + | setup_git_directory(the_repository); | |
| 790 | 790 | } | |
| 791 | 791 | ||
| 792 | 792 | parse_treeish_arg(argv, &args, remote); | |
modified attr.c
| @@ -681,7 +681,7 @@ static enum git_attr_direction direction; | |||
| 681 | 681 | ||
| 682 | 682 | void git_attr_set_direction(enum git_attr_direction new_direction) | |
| 683 | 683 | { | |
| 684 | - | if (is_bare_repository() && new_direction != GIT_ATTR_INDEX) | |
| 684 | + | if (is_bare_repository(the_repository) && new_direction != GIT_ATTR_INDEX) | |
| 685 | 685 | BUG("non-INDEX attr direction in a bare repo"); | |
| 686 | 686 | ||
| 687 | 687 | if (new_direction != direction) | |
| @@ -768,7 +768,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate, | |||
| 768 | 768 | const char *path, unsigned flags) | |
| 769 | 769 | { | |
| 770 | 770 | struct object_id oid; | |
| 771 | - | unsigned long sz; | |
| 771 | + | size_t sz; | |
| 772 | 772 | enum object_type type; | |
| 773 | 773 | void *buf; | |
| 774 | 774 | unsigned short mode; | |
| @@ -848,7 +848,7 @@ static struct attr_stack *read_attr(struct index_state *istate, | |||
| 848 | 848 | res = read_attr_from_index(istate, path, flags); | |
| 849 | 849 | } else if (tree_oid) { | |
| 850 | 850 | res = read_attr_from_blob(istate, tree_oid, path, flags); | |
| 851 | - | } else if (!is_bare_repository()) { | |
| 851 | + | } else if (!is_bare_repository(the_repository)) { | |
| 852 | 852 | if (direction == GIT_ATTR_CHECKOUT) { | |
| 853 | 853 | res = read_attr_from_index(istate, path, flags); | |
| 854 | 854 | if (!res) | |
modified bisect.c
| @@ -154,7 +154,7 @@ static void show_list(const char *debug, int counted, int nr, | |||
| 154 | 154 | struct commit *commit = p->item; | |
| 155 | 155 | unsigned commit_flags = commit->object.flags; | |
| 156 | 156 | enum object_type type; | |
| 157 | - | unsigned long size; | |
| 157 | + | size_t size; | |
| 158 | 158 | char *buf = odb_read_object(the_repository->objects, | |
| 159 | 159 | &commit->object.oid, &type, | |
| 160 | 160 | &size); | |
| @@ -488,6 +488,7 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") | |||
| 488 | 488 | static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") | |
| 489 | 489 | static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") | |
| 490 | 490 | static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") | |
| 491 | + | static GIT_PATH_FUNC(git_path_bisect_reset_when_found, "BISECT_RESET_WHEN_FOUND") | |
| 491 | 492 | ||
| 492 | 493 | static void read_bisect_paths(struct strvec *array) | |
| 493 | 494 | { | |
| @@ -512,7 +513,7 @@ static char *join_oid_array_hex(struct oid_array *array, char delim) | |||
| 512 | 513 | int i; | |
| 513 | 514 | ||
| 514 | 515 | for (i = 0; i < array->nr; i++) { | |
| 515 | - | strbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i)); | |
| 516 | + | strbuf_add_oid_hex(&joined_hexs, array->oid + i); | |
| 516 | 517 | if (i + 1 < array->nr) | |
| 517 | 518 | strbuf_addch(&joined_hexs, delim); | |
| 518 | 519 | } | |
| @@ -711,7 +712,7 @@ static enum bisect_error error_if_skipped_commits(struct commit_list *tried, | |||
| 711 | 712 | return BISECT_OK; | |
| 712 | 713 | ||
| 713 | 714 | printf("There are only 'skip'ped commits left to test.\n" | |
| 714 | - | "The first %s commit could be any of:\n", term_bad); | |
| 715 | + | "The first '%s' commit could be any of:\n", term_bad); | |
| 715 | 716 | ||
| 716 | 717 | for ( ; tried; tried = tried->next) | |
| 717 | 718 | printf("%s\n", oid_to_hex(&tried->item->object.oid)); | |
| @@ -810,7 +811,7 @@ static enum bisect_error handle_bad_merge_base(void) | |||
| 810 | 811 | "between %s and [%s].\n"), | |
| 811 | 812 | bad_hex, bad_hex, good_hex); | |
| 812 | 813 | } else { | |
| 813 | - | fprintf(stderr, _("The merge base %s is %s.\n" | |
| 814 | + | fprintf(stderr, _("The merge base %s is '%s'.\n" | |
| 814 | 815 | "This means the first '%s' commit is " | |
| 815 | 816 | "between %s and [%s].\n"), | |
| 816 | 817 | bad_hex, term_bad, term_good, bad_hex, good_hex); | |
| @@ -820,9 +821,9 @@ static enum bisect_error handle_bad_merge_base(void) | |||
| 820 | 821 | return BISECT_MERGE_BASE_CHECK; | |
| 821 | 822 | } | |
| 822 | 823 | ||
| 823 | - | fprintf(stderr, _("Some %s revs are not ancestors of the %s rev.\n" | |
| 824 | + | fprintf(stderr, _("Some '%s' revs are not ancestors of the '%s' rev.\n" | |
| 824 | 825 | "git bisect cannot work properly in this case.\n" | |
| 825 | - | "Maybe you mistook %s and %s revs?\n"), | |
| 826 | + | "Maybe you mistook '%s' and '%s' revs?\n"), | |
| 826 | 827 | term_good, term_bad, term_good, term_bad); | |
| 827 | 828 | return BISECT_FAILED; | |
| 828 | 829 | } | |
| @@ -835,7 +836,7 @@ static void handle_skipped_merge_base(const struct object_id *mb) | |||
| 835 | 836 | ||
| 836 | 837 | warning(_("the merge base between %s and [%s] " | |
| 837 | 838 | "must be skipped.\n" | |
| 838 | - | "So we cannot be sure the first %s commit is " | |
| 839 | + | "So we cannot be sure the first '%s' commit is " | |
| 839 | 840 | "between %s and %s.\n" | |
| 840 | 841 | "We continue anyway."), | |
| 841 | 842 | bad_hex, good_hex, term_bad, mb_hex, bad_hex); | |
| @@ -928,7 +929,7 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r, | |||
| 928 | 929 | struct commit **rev; | |
| 929 | 930 | ||
| 930 | 931 | if (!current_bad_oid) | |
| 931 | - | return error(_("a %s revision is needed"), term_bad); | |
| 932 | + | return error(_("a '%s' revision is needed"), term_bad); | |
| 932 | 933 | ||
| 933 | 934 | filename = repo_git_path(the_repository, "BISECT_ANCESTORS_OK"); | |
| 934 | 935 | ||
| @@ -1019,10 +1020,12 @@ void read_bisect_terms(char **read_bad, char **read_good) | |||
| 1019 | 1020 | die_errno(_("could not read file '%s'"), filename); | |
| 1020 | 1021 | } | |
| 1021 | 1022 | } else { | |
| 1022 | - | strbuf_getline_lf(&str, fp); | |
| 1023 | + | if (strbuf_getline_lf(&str, fp) == EOF) | |
| 1024 | + | die(_("could not read bad term from file '%s'"), filename); | |
| 1023 | 1025 | free(*read_bad); | |
| 1024 | 1026 | *read_bad = strbuf_detach(&str, NULL); | |
| 1025 | - | strbuf_getline_lf(&str, fp); | |
| 1027 | + | if (strbuf_getline_lf(&str, fp) == EOF) | |
| 1028 | + | die(_("could not read good term from file '%s'"), filename); | |
| 1026 | 1029 | free(*read_good); | |
| 1027 | 1030 | *read_good = strbuf_detach(&str, NULL); | |
| 1028 | 1031 | } | |
| @@ -1090,7 +1093,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) | |||
| 1090 | 1093 | res = error_if_skipped_commits(tried, NULL); | |
| 1091 | 1094 | if (res < 0) | |
| 1092 | 1095 | goto cleanup; | |
| 1093 | - | printf(_("%s was both %s and %s\n"), | |
| 1096 | + | printf(_("%s was both '%s' and '%s'\n"), | |
| 1094 | 1097 | oid_to_hex(current_bad_oid), | |
| 1095 | 1098 | term_good, | |
| 1096 | 1099 | term_bad); | |
| @@ -1113,7 +1116,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix) | |||
| 1113 | 1116 | res = error_if_skipped_commits(tried, current_bad_oid); | |
| 1114 | 1117 | if (res) | |
| 1115 | 1118 | goto cleanup; | |
| 1116 | - | printf("%s is the first %s commit\n", oid_to_hex(bisect_rev), | |
| 1119 | + | printf("%s is the first '%s' commit\n", oid_to_hex(bisect_rev), | |
| 1117 | 1120 | term_bad); | |
| 1118 | 1121 | ||
| 1119 | 1122 | show_commit(revs.commits->item); | |
| @@ -1211,6 +1214,7 @@ int bisect_clean_state(void) | |||
| 1211 | 1214 | unlink_or_warn(git_path_bisect_run()); | |
| 1212 | 1215 | unlink_or_warn(git_path_bisect_terms()); | |
| 1213 | 1216 | unlink_or_warn(git_path_bisect_first_parent()); | |
| 1217 | + | unlink_or_warn(git_path_bisect_reset_when_found()); | |
| 1214 | 1218 | /* | |
| 1215 | 1219 | * Cleanup BISECT_START last to support the --no-checkout option | |
| 1216 | 1220 | * introduced in the commit 4796e823a. | |
modified blame.c
| @@ -1041,10 +1041,13 @@ static void fill_origin_blob(struct diff_options *opt, | |||
| 1041 | 1041 | textconv_object(opt->repo, o->path, o->mode, | |
| 1042 | 1042 | &o->blob_oid, 1, &file->ptr, &file_size)) | |
| 1043 | 1043 | ; | |
| 1044 | - | else | |
| 1044 | + | else { | |
| 1045 | + | size_t file_size_st = 0; | |
| 1045 | 1046 | file->ptr = odb_read_object(the_repository->objects, | |
| 1046 | 1047 | &o->blob_oid, &type, | |
| 1047 | - | &file_size); | |
| 1048 | + | &file_size_st); | |
| 1049 | + | file_size = cast_size_t_to_ulong(file_size_st); | |
| 1050 | + | } | |
| 1048 | 1051 | file->size = file_size; | |
| 1049 | 1052 | ||
| 1050 | 1053 | if (!file->ptr) | |
| @@ -2813,7 +2816,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, | |||
| 2813 | 2816 | } | |
| 2814 | 2817 | ||
| 2815 | 2818 | if (!sb->contents_from) | |
| 2816 | - | setup_work_tree(); | |
| 2819 | + | setup_work_tree(the_repository); | |
| 2817 | 2820 | ||
| 2818 | 2821 | sb->final = fake_working_tree_commit(sb->repo, | |
| 2819 | 2822 | &sb->revs->diffopt, | |
| @@ -2869,10 +2872,14 @@ void setup_scoreboard(struct blame_scoreboard *sb, | |||
| 2869 | 2872 | textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf, | |
| 2870 | 2873 | &sb->final_buf_size)) | |
| 2871 | 2874 | ; | |
| 2872 | - | else | |
| 2875 | + | else { | |
| 2876 | + | size_t final_buf_size_st = 0; | |
| 2873 | 2877 | sb->final_buf = odb_read_object(the_repository->objects, | |
| 2874 | 2878 | &o->blob_oid, &type, | |
| 2875 | - | &sb->final_buf_size); | |
| 2879 | + | &final_buf_size_st); | |
| 2880 | + | sb->final_buf_size = | |
| 2881 | + | cast_size_t_to_ulong(final_buf_size_st); | |
| 2882 | + | } | |
| 2876 | 2883 | ||
| 2877 | 2884 | if (!sb->final_buf) | |
| 2878 | 2885 | die(_("cannot read blob %s for path %s"), | |
modified bloom.c
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | define_commit_slab(bloom_filter_slab, struct bloom_filter); | |
| 17 | 17 | ||
| 18 | 18 | static struct bloom_filter_slab bloom_filters; | |
| 19 | + | static int bloom_filter_slab_initialized; | |
| 19 | 20 | ||
| 20 | 21 | struct pathmap_hash_entry { | |
| 21 | 22 | struct hashmap_entry entry; | |
| @@ -263,7 +264,10 @@ void add_key_to_filter(const struct bloom_key *key, | |||
| 263 | 264 | ||
| 264 | 265 | void init_bloom_filters(void) | |
| 265 | 266 | { | |
| 267 | + | if (bloom_filter_slab_initialized) | |
| 268 | + | return; | |
| 266 | 269 | init_bloom_filter_slab(&bloom_filters); | |
| 270 | + | bloom_filter_slab_initialized = 1; | |
| 267 | 271 | } | |
| 268 | 272 | ||
| 269 | 273 | static void free_one_bloom_filter(struct bloom_filter *filter) | |
| @@ -276,6 +280,7 @@ static void free_one_bloom_filter(struct bloom_filter *filter) | |||
| 276 | 280 | void deinit_bloom_filters(void) | |
| 277 | 281 | { | |
| 278 | 282 | deep_clear_bloom_filter_slab(&bloom_filters, free_one_bloom_filter); | |
| 283 | + | bloom_filter_slab_initialized = 0; | |
| 279 | 284 | } | |
| 280 | 285 | ||
| 281 | 286 | struct bloom_keyvec *bloom_keyvec_new(const char *path, size_t len, | |
| @@ -605,10 +610,10 @@ int bloom_filter_contains_vec(const struct bloom_filter *filter, | |||
| 605 | 610 | uint32_t test_bloom_murmur3_seeded(uint32_t seed, const char *data, size_t len, | |
| 606 | 611 | int version) | |
| 607 | 612 | { | |
| 608 | - | assert(version == 1 || version == 2); | |
| 609 | - | ||
| 610 | 613 | if (version == 2) | |
| 611 | 614 | return murmur3_seeded_v2(seed, data, len); | |
| 612 | - | else | |
| 615 | + | else if (version == 1) | |
| 613 | 616 | return murmur3_seeded_v1(seed, data, len); | |
| 617 | + | else | |
| 618 | + | BUG("unexpected bloom version: %d", version); | |
| 614 | 619 | } | |
modified branch.c
| @@ -61,7 +61,7 @@ static int find_tracked_branch(struct remote *remote, void *priv) | |||
| 61 | 61 | ||
| 62 | 62 | static int should_setup_rebase(const char *origin) | |
| 63 | 63 | { | |
| 64 | - | switch (autorebase) { | |
| 64 | + | switch (repo_config_values(the_repository)->autorebase) { | |
| 65 | 65 | case AUTOREBASE_NEVER: | |
| 66 | 66 | return 0; | |
| 67 | 67 | case AUTOREBASE_LOCAL: | |
| @@ -372,7 +372,7 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name) | |||
| 372 | 372 | */ | |
| 373 | 373 | int validate_branchname(const char *name, struct strbuf *ref) | |
| 374 | 374 | { | |
| 375 | - | if (check_branch_ref(ref, name)) { | |
| 375 | + | if (check_branch_ref(the_repository, ref, name)) { | |
| 376 | 376 | int code = die_message(_("'%s' is not a valid branch name"), name); | |
| 377 | 377 | advise_if_enabled(ADVICE_REF_SYNTAX, | |
| 378 | 378 | _("See 'git help check-ref-format'")); | |
| @@ -385,6 +385,39 @@ int validate_branchname(const char *name, struct strbuf *ref) | |||
| 385 | 385 | static int initialized_checked_out_branches; | |
| 386 | 386 | static struct strmap current_checked_out_branches = STRMAP_INIT; | |
| 387 | 387 | ||
| 388 | + | enum branch_checkout_kind { | |
| 389 | + | BRANCH_CHECKOUT_KIND_CHECKOUT, | |
| 390 | + | BRANCH_CHECKOUT_KIND_REBASE, | |
| 391 | + | BRANCH_CHECKOUT_KIND_BISECT, | |
| 392 | + | BRANCH_CHECKOUT_KIND_UPDATE_REF, | |
| 393 | + | }; | |
| 394 | + | ||
| 395 | + | struct checked_out_branch { | |
| 396 | + | char *refname; | |
| 397 | + | char *path; | |
| 398 | + | enum branch_checkout_kind kind; | |
| 399 | + | }; | |
| 400 | + | ||
| 401 | + | static struct checked_out_branch *checked_out_branches; | |
| 402 | + | static size_t checked_out_branches_alloc, checked_out_branches_nr; | |
| 403 | + | ||
| 404 | + | static void register_checked_out_branch(const char *prefix, const char *name, | |
| 405 | + | const char *path, | |
| 406 | + | enum branch_checkout_kind kind) | |
| 407 | + | { | |
| 408 | + | char *refname = xstrfmt("%s%s", prefix, name); | |
| 409 | + | char *path_copy = xstrdup(path); | |
| 410 | + | ||
| 411 | + | ALLOC_GROW(checked_out_branches, checked_out_branches_nr + 1, | |
| 412 | + | checked_out_branches_alloc); | |
| 413 | + | checked_out_branches[checked_out_branches_nr].refname = refname; | |
| 414 | + | checked_out_branches[checked_out_branches_nr].path = path_copy; | |
| 415 | + | checked_out_branches[checked_out_branches_nr].kind = kind; | |
| 416 | + | checked_out_branches_nr++; | |
| 417 | + | ||
| 418 | + | strmap_put(¤t_checked_out_branches, refname, path_copy); | |
| 419 | + | } | |
| 420 | + | ||
| 388 | 421 | static void prepare_checked_out_branches(void) | |
| 389 | 422 | { | |
| 390 | 423 | int i = 0; | |
| @@ -394,10 +427,10 @@ static void prepare_checked_out_branches(void) | |||
| 394 | 427 | return; | |
| 395 | 428 | initialized_checked_out_branches = 1; | |
| 396 | 429 | ||
| 397 | - | worktrees = get_worktrees(); | |
| 430 | + | worktrees = get_worktrees(the_repository); | |
| 398 | 431 | ||
| 399 | 432 | while (worktrees[i]) { | |
| 400 | - | char *old, *wt_gitdir; | |
| 433 | + | char *wt_gitdir; | |
| 401 | 434 | struct wt_status_state state = { 0 }; | |
| 402 | 435 | struct worktree *wt = worktrees[i++]; | |
| 403 | 436 | struct string_list update_refs = STRING_LIST_INIT_DUP; | |
| @@ -406,34 +439,25 @@ static void prepare_checked_out_branches(void) | |||
| 406 | 439 | continue; | |
| 407 | 440 | ||
| 408 | 441 | if (wt->head_ref) { | |
| 409 | - | old = strmap_put(¤t_checked_out_branches, | |
| 410 | - | wt->head_ref, | |
| 411 | - | xstrdup(wt->path)); | |
| 412 | - | free(old); | |
| 442 | + | register_checked_out_branch("", wt->head_ref, wt->path, | |
| 443 | + | BRANCH_CHECKOUT_KIND_CHECKOUT); | |
| 413 | 444 | } | |
| 414 | 445 | ||
| 415 | 446 | if (wt_status_check_rebase(wt, &state) && | |
| 416 | 447 | (state.rebase_in_progress || state.rebase_interactive_in_progress) && | |
| 417 | 448 | state.branch) { | |
| 418 | - | struct strbuf ref = STRBUF_INIT; | |
| 419 | - | strbuf_addf(&ref, "refs/heads/%s", state.branch); | |
| 420 | - | old = strmap_put(¤t_checked_out_branches, | |
| 421 | - | ref.buf, | |
| 422 | - | xstrdup(wt->path)); | |
| 423 | - | free(old); | |
| 424 | - | strbuf_release(&ref); | |
| 449 | + | register_checked_out_branch("refs/heads/", state.branch, | |
| 450 | + | wt->path, | |
| 451 | + | BRANCH_CHECKOUT_KIND_REBASE); | |
| 425 | 452 | } | |
| 426 | 453 | wt_status_state_free_buffers(&state); | |
| 427 | 454 | ||
| 428 | 455 | if (wt_status_check_bisect(wt, &state) && | |
| 429 | 456 | state.bisecting_from) { | |
| 430 | - | struct strbuf ref = STRBUF_INIT; | |
| 431 | - | strbuf_addf(&ref, "refs/heads/%s", state.bisecting_from); | |
| 432 | - | old = strmap_put(¤t_checked_out_branches, | |
| 433 | - | ref.buf, | |
| 434 | - | xstrdup(wt->path)); | |
| 435 | - | free(old); | |
| 436 | - | strbuf_release(&ref); | |
| 457 | + | register_checked_out_branch("refs/heads/", | |
| 458 | + | state.bisecting_from, | |
| 459 | + | wt->path, | |
| 460 | + | BRANCH_CHECKOUT_KIND_BISECT); | |
| 437 | 461 | } | |
| 438 | 462 | wt_status_state_free_buffers(&state); | |
| 439 | 463 | ||
| @@ -442,10 +466,9 @@ static void prepare_checked_out_branches(void) | |||
| 442 | 466 | &update_refs)) { | |
| 443 | 467 | struct string_list_item *item; | |
| 444 | 468 | for_each_string_list_item(item, &update_refs) { | |
| 445 | - | old = strmap_put(¤t_checked_out_branches, | |
| 446 | - | item->string, | |
| 447 | - | xstrdup(wt->path)); | |
| 448 | - | free(old); | |
| 469 | + | register_checked_out_branch("", item->string, | |
| 470 | + | wt->path, | |
| 471 | + | BRANCH_CHECKOUT_KIND_UPDATE_REF); | |
| 449 | 472 | } | |
| 450 | 473 | string_list_clear(&update_refs, 1); | |
| 451 | 474 | } | |
| @@ -462,6 +485,17 @@ const char *branch_checked_out(const char *refname) | |||
| 462 | 485 | return strmap_get(¤t_checked_out_branches, refname); | |
| 463 | 486 | } | |
| 464 | 487 | ||
| 488 | + | const char *branch_bisecting(const char *refname) | |
| 489 | + | { | |
| 490 | + | prepare_checked_out_branches(); | |
| 491 | + | for (size_t i = 0; i < checked_out_branches_nr; i++) { | |
| 492 | + | if (!strcmp(refname, checked_out_branches[i].refname) && | |
| 493 | + | checked_out_branches[i].kind == BRANCH_CHECKOUT_KIND_BISECT) | |
| 494 | + | return checked_out_branches[i].path; | |
| 495 | + | } | |
| 496 | + | return NULL; | |
| 497 | + | } | |
| 498 | + | ||
| 465 | 499 | /* | |
| 466 | 500 | * Check if a branch 'name' can be created as a new branch; die otherwise. | |
| 467 | 501 | * 'force' can be used when it is OK for the named branch already exists. | |
| @@ -846,7 +880,7 @@ void remove_branch_state(struct repository *r, int verbose) | |||
| 846 | 880 | ||
| 847 | 881 | void die_if_checked_out(const char *branch, int ignore_current_worktree) | |
| 848 | 882 | { | |
| 849 | - | struct worktree **worktrees = get_worktrees(); | |
| 883 | + | struct worktree **worktrees = get_worktrees(the_repository); | |
| 850 | 884 | ||
| 851 | 885 | for (int i = 0; worktrees[i]; i++) { | |
| 852 | 886 | if (worktrees[i]->is_current && ignore_current_worktree) | |
modified branch.h
| @@ -106,6 +106,12 @@ void create_branches_recursively(struct repository *r, const char *name, | |||
| 106 | 106 | */ | |
| 107 | 107 | const char *branch_checked_out(const char *refname); | |
| 108 | 108 | ||
| 109 | + | /* | |
| 110 | + | * If the branch at 'refname' is currently used for bisecting in a | |
| 111 | + | * worktree, then return the path to that worktree. | |
| 112 | + | */ | |
| 113 | + | const char *branch_bisecting(const char *refname); | |
| 114 | + | ||
| 109 | 115 | /* | |
| 110 | 116 | * Check if 'name' can be a valid name for a branch; die otherwise. | |
| 111 | 117 | * Return 1 if the named branch already exists; return 0 otherwise. | |
modified builtin.h
| @@ -189,6 +189,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix, struct re | |||
| 189 | 189 | int cmd_for_each_ref(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 190 | 190 | int cmd_for_each_repo(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 191 | 191 | int cmd_format_patch(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 192 | + | int cmd_format_rev(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 192 | 193 | int cmd_fsck(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 193 | 194 | int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 194 | 195 | int cmd_gc(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| @@ -271,6 +272,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix, stru | |||
| 271 | 272 | int cmd_upload_archive(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 272 | 273 | int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 273 | 274 | int cmd_upload_pack(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 275 | + | int cmd_url_parse(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 274 | 276 | int cmd_var(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 275 | 277 | int cmd_verify_commit(int argc, const char **argv, const char *prefix, struct repository *repo); | |
| 276 | 278 | int cmd_verify_tag(int argc, const char **argv, const char *prefix, struct repository *repo); | |
modified builtin/add.c
| @@ -13,18 +13,19 @@ | |||
| 13 | 13 | #include "dir.h" | |
| 14 | 14 | #include "gettext.h" | |
| 15 | 15 | #include "pathspec.h" | |
| 16 | - | #include "run-command.h" | |
| 17 | 16 | #include "object-file.h" | |
| 18 | 17 | #include "odb.h" | |
| 18 | + | #include "odb/transaction.h" | |
| 19 | 19 | #include "parse-options.h" | |
| 20 | 20 | #include "path.h" | |
| 21 | 21 | #include "preload-index.h" | |
| 22 | 22 | #include "diff.h" | |
| 23 | 23 | #include "read-cache.h" | |
| 24 | 24 | #include "revision.h" | |
| 25 | - | #include "strvec.h" | |
| 26 | 25 | #include "submodule.h" | |
| 27 | 26 | #include "add-interactive.h" | |
| 27 | + | #include "merge-ll.h" | |
| 28 | + | #include "apply.h" | |
| 28 | 29 | ||
| 29 | 30 | static const char * const builtin_add_usage[] = { | |
| 30 | 31 | N_("git add [<options>] [--] <pathspec>..."), | |
| @@ -34,6 +35,7 @@ static int patch_interactive, add_interactive, edit_interactive; | |||
| 34 | 35 | static struct interactive_options interactive_opts = INTERACTIVE_OPTIONS_INIT; | |
| 35 | 36 | static int take_worktree_changes; | |
| 36 | 37 | static int add_renormalize; | |
| 38 | + | static int add_resolved; | |
| 37 | 39 | static int pathspec_file_nul; | |
| 38 | 40 | static int include_sparse; | |
| 39 | 41 | static const char *pathspec_from_file; | |
| @@ -186,7 +188,8 @@ static int edit_patch(struct repository *repo, | |||
| 186 | 188 | const char *prefix) | |
| 187 | 189 | { | |
| 188 | 190 | char *file = repo_git_path(repo, "ADD_EDIT.patch"); | |
| 189 | - | struct child_process child = CHILD_PROCESS_INIT; | |
| 191 | + | struct apply_state state; | |
| 192 | + | const char *apply_argv[2]; | |
| 190 | 193 | struct rev_info rev; | |
| 191 | 194 | int out; | |
| 192 | 195 | struct stat st; | |
| @@ -216,11 +219,16 @@ static int edit_patch(struct repository *repo, | |||
| 216 | 219 | if (!st.st_size) | |
| 217 | 220 | die(_("empty patch. aborted")); | |
| 218 | 221 | ||
| 219 | - | child.git_cmd = 1; | |
| 220 | - | strvec_pushl(&child.args, "apply", "--recount", "--cached", file, | |
| 221 | - | NULL); | |
| 222 | - | if (run_command(&child)) | |
| 222 | + | apply_argv[0] = file; | |
| 223 | + | apply_argv[1] = NULL; | |
| 224 | + | if (init_apply_state(&state, repo, NULL)) | |
| 225 | + | die(_("could not initialize apply state")); | |
| 226 | + | state.cached = 1; | |
| 227 | + | if (check_apply_state(&state, 0)) | |
| 228 | + | die(_("could not check apply state")); | |
| 229 | + | if (apply_all_patches(&state, 1, apply_argv, APPLY_OPT_RECOUNT)) | |
| 223 | 230 | die(_("could not apply '%s'"), file); | |
| 231 | + | clear_apply_state(&state); | |
| 224 | 232 | ||
| 225 | 233 | unlink(file); | |
| 226 | 234 | free(file); | |
| @@ -264,6 +272,7 @@ static struct option builtin_add_options[] = { | |||
| 264 | 272 | OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files"), 0), | |
| 265 | 273 | OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")), | |
| 266 | 274 | OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")), | |
| 275 | + | OPT_BOOL(0, "resolved", &add_resolved, N_("add conflict-resolved tracked files")), | |
| 267 | 276 | OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")), | |
| 268 | 277 | OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")), | |
| 269 | 278 | OPT_CALLBACK_F(0, "ignore-removal", &addremove_explicit, | |
| @@ -378,6 +387,76 @@ static int add_files(struct repository *repo, struct dir_struct *dir, int flags) | |||
| 378 | 387 | return exit_status; | |
| 379 | 388 | } | |
| 380 | 389 | ||
| 390 | + | static int failed_to_add(int flags, const char *path) | |
| 391 | + | { | |
| 392 | + | if (!(flags & ADD_CACHE_IGNORE_ERRORS)) | |
| 393 | + | die(_("updating file '%s' failed"), path); | |
| 394 | + | return 1; | |
| 395 | + | } | |
| 396 | + | ||
| 397 | + | static int add_resolved_files(struct repository *repo, | |
| 398 | + | const struct pathspec *pathspec, | |
| 399 | + | int flags) | |
| 400 | + | { | |
| 401 | + | struct index_state *istate = repo->index; | |
| 402 | + | struct string_list unmerged_paths = STRING_LIST_INIT_DUP; | |
| 403 | + | struct string_list unresolved_paths = STRING_LIST_INIT_DUP; | |
| 404 | + | int exit_status = 0; | |
| 405 | + | size_t i; | |
| 406 | + | ||
| 407 | + | for (i = 0; i < istate->cache_nr; i++) { | |
| 408 | + | struct cache_entry *ce = istate->cache[i]; | |
| 409 | + | if (!ce_stage(ce)) | |
| 410 | + | continue; | |
| 411 | + | if (pathspec->nr && !ce_path_match(istate, ce, pathspec, NULL)) | |
| 412 | + | continue; | |
| 413 | + | if (!unmerged_paths.nr || | |
| 414 | + | strcmp(unmerged_paths.items[unmerged_paths.nr - 1].string, ce->name)) | |
| 415 | + | string_list_append(&unmerged_paths, ce->name); | |
| 416 | + | } | |
| 417 | + | ||
| 418 | + | if (!unmerged_paths.nr) { | |
| 419 | + | string_list_clear(&unmerged_paths, 0); | |
| 420 | + | return 0; | |
| 421 | + | } | |
| 422 | + | ||
| 423 | + | for (i = 0; i < unmerged_paths.nr; i++) { | |
| 424 | + | const char *path = unmerged_paths.items[i].string; | |
| 425 | + | struct stat st; | |
| 426 | + | ||
| 427 | + | if (!lstat(path, &st) && S_ISREG(st.st_mode)) { | |
| 428 | + | if (has_conflict_markers(istate, path)) | |
| 429 | + | string_list_append(&unresolved_paths, path); | |
| 430 | + | } | |
| 431 | + | } | |
| 432 | + | ||
| 433 | + | if (unresolved_paths.nr) { | |
| 434 | + | struct strbuf sb = STRBUF_INIT; | |
| 435 | + | for (i = 0; i < unresolved_paths.nr; i++) | |
| 436 | + | strbuf_addf(&sb, "\t%s\n", unresolved_paths.items[i].string); | |
| 437 | + | die(_("the following paths still have conflict markers:\n%s"), sb.buf); | |
| 438 | + | } | |
| 439 | + | ||
| 440 | + | for (i = 0; i < unmerged_paths.nr; i++) { | |
| 441 | + | const char *path = unmerged_paths.items[i].string; | |
| 442 | + | struct stat st; | |
| 443 | + | ||
| 444 | + | if (lstat(path, &st)) { | |
| 445 | + | if (errno != ENOENT) | |
| 446 | + | die_errno(_("cannot lstat: '%s'"), path); | |
| 447 | + | if (remove_file_from_index_with_flags(istate, path, flags)) | |
| 448 | + | exit_status = failed_to_add(flags, path); | |
| 449 | + | } else { | |
| 450 | + | if (add_file_to_index(istate, path, flags)) | |
| 451 | + | exit_status = failed_to_add(flags, path); | |
| 452 | + | } | |
| 453 | + | } | |
| 454 | + | ||
| 455 | + | string_list_clear(&unmerged_paths, 0); | |
| 456 | + | string_list_clear(&unresolved_paths, 0); | |
| 457 | + | return exit_status; | |
| 458 | + | } | |
| 459 | + | ||
| 381 | 460 | int cmd_add(int argc, | |
| 382 | 461 | const char **argv, | |
| 383 | 462 | const char *prefix, | |
| @@ -392,7 +471,7 @@ int cmd_add(int argc, | |||
| 392 | 471 | char *seen = NULL; | |
| 393 | 472 | char *ps_matched = NULL; | |
| 394 | 473 | struct lock_file lock_file = LOCK_INIT; | |
| 395 | - | struct odb_transaction *transaction; | |
| 474 | + | struct odb_transaction *transaction = NULL; | |
| 396 | 475 | ||
| 397 | 476 | repo_config(repo, add_config, NULL); | |
| 398 | 477 | ||
| @@ -437,8 +516,9 @@ int cmd_add(int argc, | |||
| 437 | 516 | else if (take_worktree_changes && ADDREMOVE_DEFAULT) | |
| 438 | 517 | addremove = 0; /* "-u" was given but not "-A" */ | |
| 439 | 518 | ||
| 440 | - | if (addremove && take_worktree_changes) | |
| 441 | - | die(_("options '%s' and '%s' cannot be used together"), "-A", "-u"); | |
| 519 | + | die_for_incompatible_opt3(take_worktree_changes, "-u/--update", | |
| 520 | + | 0 < addremove_explicit, "-A/--all", | |
| 521 | + | add_resolved, "--resolved"); | |
| 442 | 522 | ||
| 443 | 523 | if (!show_only && ignore_missing) | |
| 444 | 524 | die(_("the option '%s' requires '%s'"), "--ignore-missing", "--dry-run"); | |
| @@ -447,8 +527,11 @@ int cmd_add(int argc, | |||
| 447 | 527 | chmod_arg[1] != 'x' || chmod_arg[2])) | |
| 448 | 528 | die(_("--chmod param '%s' must be either -x or +x"), chmod_arg); | |
| 449 | 529 | ||
| 450 | - | add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize; | |
| 451 | - | require_pathspec = !(take_worktree_changes || (0 < addremove_explicit)); | |
| 530 | + | add_new_files = !take_worktree_changes && !refresh_only && | |
| 531 | + | !add_renormalize && !add_resolved; | |
| 532 | + | require_pathspec = !(take_worktree_changes || | |
| 533 | + | (0 < addremove_explicit) || | |
| 534 | + | add_resolved); | |
| 452 | 535 | ||
| 453 | 536 | repo_hold_locked_index(repo, &lock_file, LOCK_DIE_ON_ERROR); | |
| 454 | 537 | ||
| @@ -480,7 +563,8 @@ int cmd_add(int argc, | |||
| 480 | 563 | return 0; | |
| 481 | 564 | } | |
| 482 | 565 | ||
| 483 | - | if (!take_worktree_changes && addremove_explicit < 0 && pathspec.nr) | |
| 566 | + | if (!take_worktree_changes && !add_resolved && | |
| 567 | + | addremove_explicit < 0 && pathspec.nr) | |
| 484 | 568 | /* Turn "git add pathspec..." to "git add -A pathspec..." */ | |
| 485 | 569 | addremove = 1; | |
| 486 | 570 | ||
| @@ -580,10 +664,12 @@ int cmd_add(int argc, | |||
| 580 | 664 | string_list_clear(&only_match_skip_worktree, 0); | |
| 581 | 665 | } | |
| 582 | 666 | ||
| 583 | - | transaction = odb_transaction_begin(repo->objects); | |
| 667 | + | odb_transaction_begin_or_die(repo->objects, &transaction, 0); | |
| 584 | 668 | ||
| 585 | 669 | ps_matched = xcalloc(pathspec.nr, 1); | |
| 586 | - | if (add_renormalize) | |
| 670 | + | if (add_resolved) | |
| 671 | + | exit_status |= add_resolved_files(repo, &pathspec, flags); | |
| 672 | + | else if (add_renormalize) | |
| 587 | 673 | exit_status |= renormalize_tracked_files(repo, &pathspec, flags); | |
| 588 | 674 | else | |
| 589 | 675 | exit_status |= add_files_to_cache(repo, prefix, | |
| @@ -599,7 +685,7 @@ int cmd_add(int argc, | |||
| 599 | 685 | ||
| 600 | 686 | if (chmod_arg && pathspec.nr) | |
| 601 | 687 | exit_status |= chmod_pathspec(repo, &pathspec, chmod_arg[0], show_only); | |
| 602 | - | odb_transaction_commit(transaction); | |
| 688 | + | odb_transaction_commit_and_finalize_or_die(transaction); | |
| 603 | 689 | ||
| 604 | 690 | finish: | |
| 605 | 691 | if (write_locked_index(repo->index, &lock_file, | |
modified builtin/am.c
| @@ -490,9 +490,11 @@ static int run_applypatch_msg_hook(struct am_state *state) | |||
| 490 | 490 | ||
| 491 | 491 | assert(state->msg); | |
| 492 | 492 | ||
| 493 | - | if (!state->no_verify) | |
| 494 | - | ret = run_hooks_l(the_repository, "applypatch-msg", | |
| 495 | - | am_path(state, "final-commit"), NULL); | |
| 493 | + | if (!state->no_verify) { | |
| 494 | + | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; | |
| 495 | + | strvec_push(&opt.args, am_path(state, "final-commit")); | |
| 496 | + | ret = run_hooks_opt(the_repository, "applypatch-msg", &opt); | |
| 497 | + | } | |
| 496 | 498 | ||
| 497 | 499 | if (!ret) { | |
| 498 | 500 | FREE_AND_NULL(state->msg); | |
modified builtin/archive.c
| @@ -31,7 +31,7 @@ static int run_remote_archiver(int argc, const char **argv, | |||
| 31 | 31 | ||
| 32 | 32 | _remote = remote_get(remote); | |
| 33 | 33 | transport = transport_get(_remote, _remote->url.v[0]); | |
| 34 | - | transport_connect(transport, "git-upload-archive", exec, fd); | |
| 34 | + | transport_connect(transport, GIT_CONNECT_UPLOAD_ARCHIVE, exec, fd); | |
| 35 | 35 | ||
| 36 | 36 | /* | |
| 37 | 37 | * Inject a fake --format field at the beginning of the | |
modified builtin/backfill.c
| @@ -26,7 +26,7 @@ | |||
| 26 | 26 | #include "path-walk.h" | |
| 27 | 27 | ||
| 28 | 28 | static const char * const builtin_backfill_usage[] = { | |
| 29 | - | N_("git backfill [--min-batch-size=<n>] [--[no-]sparse]"), | |
| 29 | + | N_("git backfill [--min-batch-size=<n>] [--[no-]sparse] [--[no-]include-edges] [<revision-range>]"), | |
| 30 | 30 | NULL | |
| 31 | 31 | }; | |
| 32 | 32 | ||
| @@ -35,6 +35,7 @@ struct backfill_context { | |||
| 35 | 35 | struct oid_array current_batch; | |
| 36 | 36 | size_t min_batch_size; | |
| 37 | 37 | int sparse; | |
| 38 | + | int include_edges; | |
| 38 | 39 | struct rev_info revs; | |
| 39 | 40 | }; | |
| 40 | 41 | ||
| @@ -78,6 +79,29 @@ static int fill_missing_blobs(const char *path UNUSED, | |||
| 78 | 79 | return 0; | |
| 79 | 80 | } | |
| 80 | 81 | ||
| 82 | + | static void reject_unsupported_rev_list_options(struct rev_info *revs) | |
| 83 | + | { | |
| 84 | + | if (revs->diffopt.pickaxe) | |
| 85 | + | die(_("'%s' cannot be used with 'git backfill'"), | |
| 86 | + | (revs->diffopt.pickaxe_opts & DIFF_PICKAXE_REGEX) ? "-G" : "-S"); | |
| 87 | + | if (revs->diffopt.filter || revs->diffopt.filter_not) | |
| 88 | + | die(_("'%s' cannot be used with 'git backfill'"), | |
| 89 | + | "--diff-filter"); | |
| 90 | + | if (revs->diffopt.flags.follow_renames) | |
| 91 | + | die(_("'%s' cannot be used with 'git backfill'"), | |
| 92 | + | "--follow"); | |
| 93 | + | if (revs->line_level_traverse) | |
| 94 | + | die(_("'%s' cannot be used with 'git backfill'"), | |
| 95 | + | "-L"); | |
| 96 | + | if (revs->explicit_diff_merges) | |
| 97 | + | die(_("'%s' cannot be used with 'git backfill'"), | |
| 98 | + | "--diff-merges"); | |
| 99 | + | if (!path_walk_filter_compatible(&revs->filter)) | |
| 100 | + | die(_("cannot backfill with these filter options")); | |
| 101 | + | if (revs->filter.blob_limit_value) | |
| 102 | + | die(_("cannot backfill with blob size limits")); | |
| 103 | + | } | |
| 104 | + | ||
| 81 | 105 | static int do_backfill(struct backfill_context *ctx) | |
| 82 | 106 | { | |
| 83 | 107 | struct path_walk_info info = PATH_WALK_INFO_INIT; | |
| @@ -85,6 +109,7 @@ static int do_backfill(struct backfill_context *ctx) | |||
| 85 | 109 | ||
| 86 | 110 | if (ctx->sparse) { | |
| 87 | 111 | CALLOC_ARRAY(info.pl, 1); | |
| 112 | + | info.pl_sparse_trees = 1; | |
| 88 | 113 | if (get_sparse_checkout_patterns(info.pl)) { | |
| 89 | 114 | path_walk_info_clear(&info); | |
| 90 | 115 | return error(_("problem loading sparse-checkout")); | |
| @@ -94,6 +119,8 @@ static int do_backfill(struct backfill_context *ctx) | |||
| 94 | 119 | /* Walk from HEAD if otherwise unspecified. */ | |
| 95 | 120 | if (!ctx->revs.pending.nr) | |
| 96 | 121 | add_head_to_pending(&ctx->revs); | |
| 122 | + | if (ctx->include_edges) | |
| 123 | + | ctx->revs.edge_hint = 1; | |
| 97 | 124 | ||
| 98 | 125 | info.blobs = 1; | |
| 99 | 126 | info.tags = info.commits = info.trees = 0; | |
| @@ -121,12 +148,15 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit | |||
| 121 | 148 | .min_batch_size = 50000, | |
| 122 | 149 | .sparse = -1, | |
| 123 | 150 | .revs = REV_INFO_INIT, | |
| 151 | + | .include_edges = 1, | |
| 124 | 152 | }; | |
| 125 | 153 | struct option options[] = { | |
| 126 | 154 | OPT_UNSIGNED(0, "min-batch-size", &ctx.min_batch_size, | |
| 127 | 155 | N_("Minimum number of objects to request at a time")), | |
| 128 | 156 | OPT_BOOL(0, "sparse", &ctx.sparse, | |
| 129 | 157 | N_("Restrict the missing objects to the current sparse-checkout")), | |
| 158 | + | OPT_BOOL(0, "include-edges", &ctx.include_edges, | |
| 159 | + | N_("Include blobs from boundary commits in the backfill")), | |
| 130 | 160 | OPT_END(), | |
| 131 | 161 | }; | |
| 132 | 162 | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| @@ -144,6 +174,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit | |||
| 144 | 174 | ||
| 145 | 175 | if (argc > 1) | |
| 146 | 176 | die(_("unrecognized argument: %s"), argv[1]); | |
| 177 | + | reject_unsupported_rev_list_options(&ctx.revs); | |
| 147 | 178 | ||
| 148 | 179 | repo_config(repo, git_default_config, NULL); | |
| 149 | 180 | ||
modified builtin/bisect.c
| @@ -24,11 +24,12 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START") | |||
| 24 | 24 | static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG") | |
| 25 | 25 | static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") | |
| 26 | 26 | static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") | |
| 27 | + | static GIT_PATH_FUNC(git_path_bisect_reset_when_found, "BISECT_RESET_WHEN_FOUND") | |
| 27 | 28 | static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN") | |
| 28 | 29 | ||
| 29 | 30 | #define BUILTIN_GIT_BISECT_START_USAGE \ | |
| 30 | 31 | N_("git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]\n" \ | |
| 31 | - | " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]") | |
| 32 | + | " [--no-checkout] [--first-parent] [--reset-when-found[=<where>]] [<bad> [<good>...]] [--] [<pathspec>...]") | |
| 32 | 33 | #define BUILTIN_GIT_BISECT_BAD_USAGE \ | |
| 33 | 34 | N_("git bisect (bad|new|<term-new>) [<rev>]") | |
| 34 | 35 | #define BUILTIN_GIT_BISECT_GOOD_USAGE \ | |
| @@ -48,7 +49,7 @@ static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN") | |||
| 48 | 49 | #define BUILTIN_GIT_BISECT_LOG_USAGE \ | |
| 49 | 50 | "git bisect log" | |
| 50 | 51 | #define BUILTIN_GIT_BISECT_RUN_USAGE \ | |
| 51 | - | N_("git bisect run <cmd> [<arg>...]") | |
| 52 | + | N_("git bisect run [--reset-when-found[=<where>]] <cmd> [<arg>...]") | |
| 52 | 53 | #define BUILTIN_GIT_BISECT_HELP_USAGE \ | |
| 53 | 54 | "git bisect help" | |
| 54 | 55 | ||
| @@ -68,6 +69,12 @@ static const char * const git_bisect_usage[] = { | |||
| 68 | 69 | NULL | |
| 69 | 70 | }; | |
| 70 | 71 | ||
| 72 | + | enum reset_when_found_mode { | |
| 73 | + | RESET_WHEN_FOUND_NONE, | |
| 74 | + | RESET_WHEN_FOUND_TO_ORIGINAL, | |
| 75 | + | RESET_WHEN_FOUND_TO_FOUND, | |
| 76 | + | }; | |
| 77 | + | ||
| 71 | 78 | struct add_bisect_ref_data { | |
| 72 | 79 | struct rev_info *revs; | |
| 73 | 80 | unsigned int object_flags; | |
| @@ -234,7 +241,7 @@ static int write_terms(const char *bad, const char *good) | |||
| 234 | 241 | return res; | |
| 235 | 242 | } | |
| 236 | 243 | ||
| 237 | - | static int bisect_reset(const char *commit) | |
| 244 | + | static int bisect_reset(const char *commit, bool quiet) | |
| 238 | 245 | { | |
| 239 | 246 | struct strbuf branch = STRBUF_INIT; | |
| 240 | 247 | ||
| @@ -255,8 +262,10 @@ static int bisect_reset(const char *commit) | |||
| 255 | 262 | struct child_process cmd = CHILD_PROCESS_INIT; | |
| 256 | 263 | ||
| 257 | 264 | cmd.git_cmd = 1; | |
| 258 | - | strvec_pushl(&cmd.args, "checkout", "--ignore-other-worktrees", | |
| 259 | - | branch.buf, "--", NULL); | |
| 265 | + | strvec_pushl(&cmd.args, "checkout", "--ignore-other-worktrees", NULL); | |
| 266 | + | if (quiet) | |
| 267 | + | strvec_push(&cmd.args, "--quiet"); | |
| 268 | + | strvec_pushl(&cmd.args, branch.buf, "--", NULL); | |
| 260 | 269 | if (run_command(&cmd)) { | |
| 261 | 270 | error(_("could not check out original" | |
| 262 | 271 | " HEAD '%s'. Try 'git bisect" | |
| @@ -267,7 +276,79 @@ static int bisect_reset(const char *commit) | |||
| 267 | 276 | } | |
| 268 | 277 | ||
| 269 | 278 | strbuf_release(&branch); | |
| 270 | - | return bisect_clean_state(); | |
| 279 | + | return 0; | |
| 280 | + | } | |
| 281 | + | ||
| 282 | + | static int parse_reset_when_found(const char *value, | |
| 283 | + | enum reset_when_found_mode *mode) | |
| 284 | + | { | |
| 285 | + | if (!strcmp(value, "original")) | |
| 286 | + | *mode = RESET_WHEN_FOUND_TO_ORIGINAL; | |
| 287 | + | else if (!strcmp(value, "found")) | |
| 288 | + | *mode = RESET_WHEN_FOUND_TO_FOUND; | |
| 289 | + | else | |
| 290 | + | return error(_("invalid value for '--reset-when-found': '%s'"), | |
| 291 | + | value); | |
| 292 | + | ||
| 293 | + | return 0; | |
| 294 | + | } | |
| 295 | + | ||
| 296 | + | static const char *reset_when_found_mode_name(enum reset_when_found_mode mode) | |
| 297 | + | { | |
| 298 | + | switch (mode) { | |
| 299 | + | case RESET_WHEN_FOUND_TO_ORIGINAL: | |
| 300 | + | return "original"; | |
| 301 | + | case RESET_WHEN_FOUND_TO_FOUND: | |
| 302 | + | return "found"; | |
| 303 | + | case RESET_WHEN_FOUND_NONE: | |
| 304 | + | BUG("no name for unset reset-when-found mode"); | |
| 305 | + | } | |
| 306 | + | BUG("unknown reset-when-found mode %d", mode); | |
| 307 | + | } | |
| 308 | + | ||
| 309 | + | static int read_reset_when_found(enum reset_when_found_mode *mode) | |
| 310 | + | { | |
| 311 | + | struct strbuf value = STRBUF_INIT; | |
| 312 | + | int res = 0; | |
| 313 | + | ||
| 314 | + | *mode = RESET_WHEN_FOUND_NONE; | |
| 315 | + | if (is_empty_or_missing_file(git_path_bisect_reset_when_found())) | |
| 316 | + | return 0; | |
| 317 | + | ||
| 318 | + | if (strbuf_read_file(&value, git_path_bisect_reset_when_found(), 0) < 0) { | |
| 319 | + | res = error_errno(_("could not read '%s'"), | |
| 320 | + | git_path_bisect_reset_when_found()); | |
| 321 | + | goto out; | |
| 322 | + | } | |
| 323 | + | strbuf_trim(&value); | |
| 324 | + | if (parse_reset_when_found(value.buf, mode)) | |
| 325 | + | res = -1; | |
| 326 | + | ||
| 327 | + | out: | |
| 328 | + | strbuf_release(&value); | |
| 329 | + | return res; | |
| 330 | + | } | |
| 331 | + | ||
| 332 | + | static int bisect_reset_when_found(enum reset_when_found_mode mode) | |
| 333 | + | { | |
| 334 | + | struct bisect_terms terms = { 0 }; | |
| 335 | + | char *commit = NULL; | |
| 336 | + | int res; | |
| 337 | + | ||
| 338 | + | if (mode == RESET_WHEN_FOUND_TO_FOUND) { | |
| 339 | + | read_bisect_terms(&terms.term_bad, &terms.term_good); | |
| 340 | + | commit = xstrfmt("refs/bisect/%s", terms.term_bad); | |
| 341 | + | } else if (mode == RESET_WHEN_FOUND_NONE) { | |
| 342 | + | BUG("automatic reset requested without a reset mode"); | |
| 343 | + | } | |
| 344 | + | ||
| 345 | + | res = bisect_reset(commit, true); | |
| 346 | + | if (!res) | |
| 347 | + | res = bisect_clean_state(); | |
| 348 | + | ||
| 349 | + | free(commit); | |
| 350 | + | free_terms(&terms); | |
| 351 | + | return res; | |
| 271 | 352 | } | |
| 272 | 353 | ||
| 273 | 354 | static void log_commit(FILE *fp, | |
| @@ -465,13 +546,16 @@ static void bisect_print_status(const struct bisect_terms *terms) | |||
| 465 | 546 | return; | |
| 466 | 547 | ||
| 467 | 548 | if (!state.nr_good && !state.nr_bad) | |
| 468 | - | bisect_log_printf(_("status: waiting for both good and bad commits\n")); | |
| 549 | + | bisect_log_printf(_("status: waiting for both '%s' and '%s' commits\n"), | |
| 550 | + | terms->term_good, terms->term_bad); | |
| 469 | 551 | else if (state.nr_good) | |
| 470 | - | bisect_log_printf(Q_("status: waiting for bad commit, %d good commit known\n", | |
| 471 | - | "status: waiting for bad commit, %d good commits known\n", | |
| 472 | - | state.nr_good), state.nr_good); | |
| 552 | + | bisect_log_printf(Q_("status: waiting for '%s' commit, %d '%s' commit known\n", | |
| 553 | + | "status: waiting for '%s' commit, %d '%s' commits known\n", | |
| 554 | + | state.nr_good), | |
| 555 | + | terms->term_bad, state.nr_good, terms->term_good); | |
| 473 | 556 | else | |
| 474 | - | bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n")); | |
| 557 | + | bisect_log_printf(_("status: waiting for '%s' commit(s), '%s' commit known\n"), | |
| 558 | + | terms->term_good, terms->term_bad); | |
| 475 | 559 | } | |
| 476 | 560 | ||
| 477 | 561 | static int bisect_next_check(const struct bisect_terms *terms, | |
| @@ -482,7 +566,7 @@ static int bisect_next_check(const struct bisect_terms *terms, | |||
| 482 | 566 | return decide_next(terms, current_term, !state.nr_good, !state.nr_bad); | |
| 483 | 567 | } | |
| 484 | 568 | ||
| 485 | - | static int get_terms(struct bisect_terms *terms) | |
| 569 | + | static int get_terms(struct bisect_terms *terms, int file_missing_is_ok) | |
| 486 | 570 | { | |
| 487 | 571 | struct strbuf str = STRBUF_INIT; | |
| 488 | 572 | FILE *fp = NULL; | |
| @@ -490,14 +574,21 @@ static int get_terms(struct bisect_terms *terms) | |||
| 490 | 574 | ||
| 491 | 575 | fp = fopen(git_path_bisect_terms(), "r"); | |
| 492 | 576 | if (!fp) { | |
| 493 | - | res = -1; | |
| 577 | + | res = file_missing_is_ok ? 0 : -1; | |
| 494 | 578 | goto finish; | |
| 495 | 579 | } | |
| 496 | 580 | ||
| 497 | 581 | free_terms(terms); | |
| 498 | - | strbuf_getline_lf(&str, fp); | |
| 582 | + | if (strbuf_getline_lf(&str, fp) == EOF) { | |
| 583 | + | res = -1; | |
| 584 | + | goto finish; | |
| 585 | + | } | |
| 499 | 586 | terms->term_bad = strbuf_detach(&str, NULL); | |
| 500 | - | strbuf_getline_lf(&str, fp); | |
| 587 | + | if (strbuf_getline_lf(&str, fp) == EOF) { | |
| 588 | + | res = -1; | |
| 589 | + | FREE_AND_NULL(terms->term_bad); | |
| 590 | + | goto finish; | |
| 591 | + | } | |
| 501 | 592 | terms->term_good = strbuf_detach(&str, NULL); | |
| 502 | 593 | ||
| 503 | 594 | finish: | |
| @@ -509,12 +600,12 @@ finish: | |||
| 509 | 600 | ||
| 510 | 601 | static int bisect_terms(struct bisect_terms *terms, const char *option) | |
| 511 | 602 | { | |
| 512 | - | if (get_terms(terms)) | |
| 603 | + | if (get_terms(terms, 0)) | |
| 513 | 604 | return error(_("no terms defined")); | |
| 514 | 605 | ||
| 515 | 606 | if (!option) { | |
| 516 | - | printf(_("Your current terms are %s for the old state\n" | |
| 517 | - | "and %s for the new state.\n"), | |
| 607 | + | printf(_("Your current terms are '%s' for the old state\n" | |
| 608 | + | "and '%s' for the new state.\n"), | |
| 518 | 609 | terms->term_good, terms->term_bad); | |
| 519 | 610 | return 0; | |
| 520 | 611 | } | |
| @@ -632,7 +723,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms) | |||
| 632 | 723 | strbuf_reset(&commit_name); | |
| 633 | 724 | repo_format_commit_message(the_repository, commit, "%s", | |
| 634 | 725 | &commit_name, &pp); | |
| 635 | - | fprintf(fp, "# possible first %s commit: [%s] %s\n", | |
| 726 | + | fprintf(fp, "# possible first '%s' commit: [%s] %s\n", | |
| 636 | 727 | terms->term_bad, oid_to_hex(&commit->object.oid), | |
| 637 | 728 | commit_name.buf); | |
| 638 | 729 | } | |
| @@ -660,10 +751,15 @@ static int bisect_successful(struct bisect_terms *terms) | |||
| 660 | 751 | ||
| 661 | 752 | refs_read_ref(get_main_ref_store(the_repository), bad_ref, &oid); | |
| 662 | 753 | commit = lookup_commit_reference_by_name(bad_ref); | |
| 754 | + | if (!commit) { | |
| 755 | + | error(_("could not find commit for '%s'"), bad_ref); | |
| 756 | + | free(bad_ref); | |
| 757 | + | return BISECT_FAILED; | |
| 758 | + | } | |
| 663 | 759 | repo_format_commit_message(the_repository, commit, "%s", &commit_name, | |
| 664 | 760 | &pp); | |
| 665 | 761 | ||
| 666 | - | res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n", | |
| 762 | + | res = append_to_file(git_path_bisect_log(), "# first '%s' commit: [%s] %s\n", | |
| 667 | 763 | terms->term_bad, oid_to_hex(&commit->object.oid), | |
| 668 | 764 | commit_name.buf); | |
| 669 | 765 | ||
| @@ -672,7 +768,8 @@ static int bisect_successful(struct bisect_terms *terms) | |||
| 672 | 768 | return res; | |
| 673 | 769 | } | |
| 674 | 770 | ||
| 675 | - | static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix) | |
| 771 | + | static enum bisect_error bisect_next(struct bisect_terms *terms, | |
| 772 | + | const char *prefix) | |
| 676 | 773 | { | |
| 677 | 774 | enum bisect_error res; | |
| 678 | 775 | ||
| @@ -695,7 +792,8 @@ static enum bisect_error bisect_next(struct bisect_terms *terms, const char *pre | |||
| 695 | 792 | return res; | |
| 696 | 793 | } | |
| 697 | 794 | ||
| 698 | - | static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char *prefix) | |
| 795 | + | static enum bisect_error bisect_auto_next(struct bisect_terms *terms, | |
| 796 | + | const char *prefix) | |
| 699 | 797 | { | |
| 700 | 798 | if (bisect_next_check(terms, NULL)) { | |
| 701 | 799 | bisect_print_status(terms); | |
| @@ -719,9 +817,10 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 719 | 817 | struct strbuf bisect_names = STRBUF_INIT; | |
| 720 | 818 | struct object_id head_oid; | |
| 721 | 819 | struct object_id oid; | |
| 820 | + | enum reset_when_found_mode reset_when_found = RESET_WHEN_FOUND_NONE; | |
| 722 | 821 | const char *head; | |
| 723 | 822 | ||
| 724 | - | if (is_bare_repository()) | |
| 823 | + | if (is_bare_repository(the_repository)) | |
| 725 | 824 | no_checkout = 1; | |
| 726 | 825 | ||
| 727 | 826 | /* | |
| @@ -742,6 +841,13 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 742 | 841 | no_checkout = 1; | |
| 743 | 842 | } else if (!strcmp(arg, "--first-parent")) { | |
| 744 | 843 | first_parent_only = 1; | |
| 844 | + | } else if (!strcmp(arg, "--reset-when-found")) { | |
| 845 | + | reset_when_found = RESET_WHEN_FOUND_TO_ORIGINAL; | |
| 846 | + | } else if (skip_prefix(arg, "--reset-when-found=", &arg)) { | |
| 847 | + | if (parse_reset_when_found(arg, &reset_when_found)) { | |
| 848 | + | res = BISECT_FAILED; | |
| 849 | + | goto finish; | |
| 850 | + | } | |
| 745 | 851 | } else if (!strcmp(arg, "--term-good") || | |
| 746 | 852 | !strcmp(arg, "--term-old")) { | |
| 747 | 853 | i++; | |
| @@ -779,6 +885,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 779 | 885 | break; | |
| 780 | 886 | } | |
| 781 | 887 | } | |
| 888 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE && no_checkout) { | |
| 889 | + | res = error(_("options '%s' and '%s' cannot be used together"), | |
| 890 | + | "--reset-when-found", "--no-checkout"); | |
| 891 | + | goto finish; | |
| 892 | + | } | |
| 782 | 893 | pathspec_pos = i; | |
| 783 | 894 | ||
| 784 | 895 | /* | |
| @@ -803,9 +914,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 803 | 914 | */ | |
| 804 | 915 | head = refs_resolve_ref_unsafe(get_main_ref_store(the_repository), | |
| 805 | 916 | "HEAD", 0, &head_oid, &flags); | |
| 806 | - | if (!head) | |
| 917 | + | if (!head) { | |
| 807 | 918 | if (repo_get_oid(the_repository, "HEAD", &head_oid)) | |
| 808 | 919 | return error(_("bad HEAD - I need a HEAD")); | |
| 920 | + | head = "HEAD"; | |
| 921 | + | } | |
| 809 | 922 | ||
| 810 | 923 | /* | |
| 811 | 924 | * Check if we are bisecting | |
| @@ -833,7 +946,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 833 | 946 | if (!repo_get_oid(the_repository, head, &head_oid) && | |
| 834 | 947 | !starts_with(head, "refs/heads/")) { | |
| 835 | 948 | strbuf_reset(&start_head); | |
| 836 | - | strbuf_addstr(&start_head, oid_to_hex(&head_oid)); | |
| 949 | + | strbuf_add_oid_hex(&start_head, &head_oid); | |
| 837 | 950 | } else if (!repo_get_oid(the_repository, head, &head_oid) && | |
| 838 | 951 | skip_prefix(head, "refs/heads/", &head)) { | |
| 839 | 952 | strbuf_addstr(&start_head, head); | |
| @@ -856,6 +969,10 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc, | |||
| 856 | 969 | if (first_parent_only) | |
| 857 | 970 | write_file(git_path_bisect_first_parent(), "\n"); | |
| 858 | 971 | ||
| 972 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE) | |
| 973 | + | write_file(git_path_bisect_reset_when_found(), "%s\n", | |
| 974 | + | reset_when_found_mode_name(reset_when_found)); | |
| 975 | + | ||
| 859 | 976 | if (no_checkout) { | |
| 860 | 977 | if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) { | |
| 861 | 978 | res = error(_("invalid ref: '%s'"), start_head.buf); | |
| @@ -1047,7 +1164,8 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line) | |||
| 1047 | 1164 | rev = word_end + strspn(word_end, " \t"); | |
| 1048 | 1165 | *word_end = '\0'; /* NUL-terminate the word */ | |
| 1049 | 1166 | ||
| 1050 | - | get_terms(terms); | |
| 1167 | + | if (get_terms(terms, 1)) | |
| 1168 | + | return error(_("no terms defined")); | |
| 1051 | 1169 | if (check_and_set_terms(terms, p)) | |
| 1052 | 1170 | return -1; | |
| 1053 | 1171 | ||
| @@ -1086,7 +1204,7 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f | |||
| 1086 | 1204 | if (is_empty_or_missing_file(filename)) | |
| 1087 | 1205 | return error(_("cannot read file '%s' for replaying"), filename); | |
| 1088 | 1206 | ||
| 1089 | - | if (bisect_reset(NULL)) | |
| 1207 | + | if (bisect_clean_state()) | |
| 1090 | 1208 | return BISECT_FAILED; | |
| 1091 | 1209 | ||
| 1092 | 1210 | fp = fopen(filename, "r"); | |
| @@ -1234,13 +1352,36 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1234 | 1352 | { | |
| 1235 | 1353 | int res = BISECT_OK; | |
| 1236 | 1354 | struct strbuf command = STRBUF_INIT; | |
| 1355 | + | const char *reset_when_found_arg; | |
| 1237 | 1356 | const char *new_state; | |
| 1238 | 1357 | int temporary_stdout_fd, saved_stdout; | |
| 1239 | 1358 | int is_first_run = 1; | |
| 1359 | + | enum reset_when_found_mode reset_when_found = RESET_WHEN_FOUND_NONE; | |
| 1240 | 1360 | ||
| 1241 | 1361 | if (bisect_next_check(terms, NULL)) | |
| 1242 | 1362 | return BISECT_FAILED; | |
| 1243 | 1363 | ||
| 1364 | + | if (argc && !strcmp(argv[0], "--reset-when-found")) { | |
| 1365 | + | reset_when_found = RESET_WHEN_FOUND_TO_ORIGINAL; | |
| 1366 | + | } else if (argc && skip_prefix(argv[0], "--reset-when-found=", | |
| 1367 | + | &reset_when_found_arg)) { | |
| 1368 | + | if (parse_reset_when_found(reset_when_found_arg, | |
| 1369 | + | &reset_when_found)) | |
| 1370 | + | return BISECT_FAILED; | |
| 1371 | + | } | |
| 1372 | + | ||
| 1373 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE && | |
| 1374 | + | refs_ref_exists(get_main_ref_store(the_repository), "BISECT_HEAD")) | |
| 1375 | + | return error(_("options '%s' and '%s' cannot be used together"), | |
| 1376 | + | "--reset-when-found", "--no-checkout"); | |
| 1377 | + | ||
| 1378 | + | if (reset_when_found != RESET_WHEN_FOUND_NONE) { | |
| 1379 | + | write_file(git_path_bisect_reset_when_found(), "%s\n", | |
| 1380 | + | reset_when_found_mode_name(reset_when_found)); | |
| 1381 | + | argc--; | |
| 1382 | + | argv++; | |
| 1383 | + | } | |
| 1384 | + | ||
| 1244 | 1385 | if (!argc) { | |
| 1245 | 1386 | error(_("bisect run failed: no command provided.")); | |
| 1246 | 1387 | return BISECT_FAILED; | |
| @@ -1262,14 +1403,14 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1262 | 1403 | int rc = verify_good(terms, command.buf); | |
| 1263 | 1404 | is_first_run = 0; | |
| 1264 | 1405 | if (rc < 0 || 128 <= rc) { | |
| 1265 | - | error(_("unable to verify %s on good" | |
| 1266 | - | " revision"), command.buf); | |
| 1406 | + | error(_("unable to verify %s on '%s' revision"), | |
| 1407 | + | command.buf, terms->term_good); | |
| 1267 | 1408 | res = BISECT_FAILED; | |
| 1268 | 1409 | break; | |
| 1269 | 1410 | } | |
| 1270 | 1411 | if (rc == res) { | |
| 1271 | - | error(_("bogus exit code %d for good revision"), | |
| 1272 | - | rc); | |
| 1412 | + | error(_("bogus exit code %d for '%s' revision"), | |
| 1413 | + | rc, terms->term_good); | |
| 1273 | 1414 | res = BISECT_FAILED; | |
| 1274 | 1415 | break; | |
| 1275 | 1416 | } | |
| @@ -1297,7 +1438,14 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1297 | 1438 | ||
| 1298 | 1439 | fflush(stdout); | |
| 1299 | 1440 | saved_stdout = dup(1); | |
| 1300 | - | dup2(temporary_stdout_fd, 1); | |
| 1441 | + | if (saved_stdout < 0 || | |
| 1442 | + | dup2(temporary_stdout_fd, 1) < 0) { | |
| 1443 | + | res = error_errno(_("could not duplicate stdout")); | |
| 1444 | + | if (saved_stdout >= 0) | |
| 1445 | + | close(saved_stdout); | |
| 1446 | + | close(temporary_stdout_fd); | |
| 1447 | + | break; | |
| 1448 | + | } | |
| 1301 | 1449 | ||
| 1302 | 1450 | res = bisect_state(terms, 1, &new_state); | |
| 1303 | 1451 | ||
| @@ -1314,8 +1462,7 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1314 | 1462 | puts(_("bisect run success")); | |
| 1315 | 1463 | res = BISECT_OK; | |
| 1316 | 1464 | } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { | |
| 1317 | - | puts(_("bisect found first bad commit")); | |
| 1318 | - | res = BISECT_OK; | |
| 1465 | + | printf(_("bisect found first '%s' commit\n"), terms->term_bad); | |
| 1319 | 1466 | } else if (res) { | |
| 1320 | 1467 | error(_("bisect run failed: 'git bisect %s'" | |
| 1321 | 1468 | " exited with error code %d"), new_state, res); | |
| @@ -1332,10 +1479,15 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) | |||
| 1332 | 1479 | static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED, | |
| 1333 | 1480 | struct repository *repo UNUSED) | |
| 1334 | 1481 | { | |
| 1482 | + | int res; | |
| 1483 | + | ||
| 1335 | 1484 | if (argc > 1) | |
| 1336 | 1485 | return error(_("'%s' requires either no argument or a commit"), | |
| 1337 | 1486 | "git bisect reset"); | |
| 1338 | - | return bisect_reset(argc ? argv[0] : NULL); | |
| 1487 | + | res = bisect_reset(argc ? argv[0] : NULL, false); | |
| 1488 | + | if (res) | |
| 1489 | + | return res; | |
| 1490 | + | return bisect_clean_state(); | |
| 1339 | 1491 | } | |
| 1340 | 1492 | ||
| 1341 | 1493 | static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED, | |
| @@ -1373,7 +1525,8 @@ static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref | |||
| 1373 | 1525 | if (argc) | |
| 1374 | 1526 | return error(_("'%s' requires 0 arguments"), | |
| 1375 | 1527 | "git bisect next"); | |
| 1376 | - | get_terms(&terms); | |
| 1528 | + | if (get_terms(&terms, 1)) | |
| 1529 | + | return error(_("no terms defined")); | |
| 1377 | 1530 | res = bisect_next(&terms, prefix); | |
| 1378 | 1531 | free_terms(&terms); | |
| 1379 | 1532 | return res; | |
| @@ -1407,7 +1560,8 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS | |||
| 1407 | 1560 | struct bisect_terms terms = { 0 }; | |
| 1408 | 1561 | ||
| 1409 | 1562 | set_terms(&terms, "bad", "good"); | |
| 1410 | - | get_terms(&terms); | |
| 1563 | + | if (get_terms(&terms, 1)) | |
| 1564 | + | return error(_("no terms defined")); | |
| 1411 | 1565 | res = bisect_skip(&terms, argc, argv); | |
| 1412 | 1566 | free_terms(&terms); | |
| 1413 | 1567 | return res; | |
| @@ -1419,7 +1573,8 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix | |||
| 1419 | 1573 | int res; | |
| 1420 | 1574 | struct bisect_terms terms = { 0 }; | |
| 1421 | 1575 | ||
| 1422 | - | get_terms(&terms); | |
| 1576 | + | if (get_terms(&terms, 1)) | |
| 1577 | + | return error(_("no terms defined")); | |
| 1423 | 1578 | res = bisect_visualize(&terms, argc, argv); | |
| 1424 | 1579 | free_terms(&terms); | |
| 1425 | 1580 | return res; | |
| @@ -1433,7 +1588,8 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE | |||
| 1433 | 1588 | ||
| 1434 | 1589 | if (!argc) | |
| 1435 | 1590 | return error(_("'%s' failed: no command provided."), "git bisect run"); | |
| 1436 | - | get_terms(&terms); | |
| 1591 | + | if (get_terms(&terms, 1)) | |
| 1592 | + | return error(_("no terms defined")); | |
| 1437 | 1593 | res = bisect_run(&terms, argc, argv); | |
| 1438 | 1594 | free_terms(&terms); | |
| 1439 | 1595 | return res; | |
| @@ -1472,12 +1628,14 @@ int cmd_bisect(int argc, | |||
| 1472 | 1628 | usage_with_options(git_bisect_usage, options); | |
| 1473 | 1629 | ||
| 1474 | 1630 | set_terms(&terms, "bad", "good"); | |
| 1475 | - | get_terms(&terms); | |
| 1631 | + | if (get_terms(&terms, 1)) | |
| 1632 | + | return error(_("no terms defined")); | |
| 1476 | 1633 | if (check_and_set_terms(&terms, argv[0]) || | |
| 1477 | 1634 | !one_of(argv[0], terms.term_good, terms.term_bad, NULL)) | |
| 1478 | 1635 | usage_msg_optf(_("unknown command: '%s'"), git_bisect_usage, | |
| 1479 | 1636 | options, argv[0]); | |
| 1480 | - | res = bisect_state(&terms, argc, argv); | |
| 1637 | + | else | |
| 1638 | + | res = bisect_state(&terms, argc, argv); | |
| 1481 | 1639 | free_terms(&terms); | |
| 1482 | 1640 | } else { | |
| 1483 | 1641 | argc--; | |
| @@ -1485,5 +1643,15 @@ int cmd_bisect(int argc, | |||
| 1485 | 1643 | res = fn(argc, argv, prefix, repo); | |
| 1486 | 1644 | } | |
| 1487 | 1645 | ||
| 1646 | + | if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) { | |
| 1647 | + | enum reset_when_found_mode mode; | |
| 1648 | + | ||
| 1649 | + | if (read_reset_when_found(&mode)) | |
| 1650 | + | res = BISECT_FAILED; | |
| 1651 | + | else if (mode != RESET_WHEN_FOUND_NONE && | |
| 1652 | + | bisect_reset_when_found(mode)) | |
| 1653 | + | res = BISECT_FAILED; | |
| 1654 | + | } | |
| 1655 | + | ||
| 1488 | 1656 | return is_bisect_success(res) ? 0 : -res; | |
| 1489 | 1657 | } | |
modified builtin/blame.c
| @@ -453,6 +453,36 @@ static void determine_line_heat(struct commit_info *ci, const char **dest_color) | |||
| 453 | 453 | *dest_color = colorfield[i].col; | |
| 454 | 454 | } | |
| 455 | 455 | ||
| 456 | + | static inline int maybe_putc(int c, FILE *out) | |
| 457 | + | { | |
| 458 | + | return out ? putc(c, out) : 0; | |
| 459 | + | } | |
| 460 | + | ||
| 461 | + | static size_t print_marks(FILE *out, const struct blame_entry *ent, int opt) | |
| 462 | + | { | |
| 463 | + | size_t len = 0; | |
| 464 | + | ||
| 465 | + | if ((ent->suspect->commit->object.flags & UNINTERESTING) && | |
| 466 | + | !blank_boundary && !(opt & OUTPUT_ANNOTATE_COMPAT)) { | |
| 467 | + | maybe_putc('^', out); | |
| 468 | + | len++; | |
| 469 | + | } | |
| 470 | + | if (mark_unblamable_lines && ent->unblamable) { | |
| 471 | + | maybe_putc('*', out); | |
| 472 | + | len++; | |
| 473 | + | } | |
| 474 | + | if (mark_ignored_lines && ent->ignored) { | |
| 475 | + | maybe_putc('?', out); | |
| 476 | + | len++; | |
| 477 | + | } | |
| 478 | + | return len; | |
| 479 | + | } | |
| 480 | + | ||
| 481 | + | static size_t count_marks(const struct blame_entry *ent, int opt) | |
| 482 | + | { | |
| 483 | + | return print_marks(NULL, ent, opt); | |
| 484 | + | } | |
| 485 | + | ||
| 456 | 486 | static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, | |
| 457 | 487 | int opt, struct blame_entry *prev_ent) | |
| 458 | 488 | { | |
| @@ -499,23 +529,10 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, | |||
| 499 | 529 | if (color) | |
| 500 | 530 | fputs(color, stdout); | |
| 501 | 531 | ||
| 502 | - | if (suspect->commit->object.flags & UNINTERESTING) { | |
| 503 | - | if (blank_boundary) { | |
| 504 | - | memset(hex, ' ', strlen(hex)); | |
| 505 | - | } else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) { | |
| 506 | - | length--; | |
| 507 | - | putchar('^'); | |
| 508 | - | } | |
| 509 | - | } | |
| 510 | - | ||
| 511 | - | if (mark_unblamable_lines && ent->unblamable) { | |
| 512 | - | length--; | |
| 513 | - | putchar('*'); | |
| 514 | - | } | |
| 515 | - | if (mark_ignored_lines && ent->ignored) { | |
| 516 | - | length--; | |
| 517 | - | putchar('?'); | |
| 518 | - | } | |
| 532 | + | if ((suspect->commit->object.flags & UNINTERESTING) && | |
| 533 | + | blank_boundary) | |
| 534 | + | memset(hex, ' ', strlen(hex)); | |
| 535 | + | length -= print_marks(stdout, ent, opt); | |
| 519 | 536 | ||
| 520 | 537 | printf("%.*s", (int)(length < GIT_MAX_HEXSZ ? length : GIT_MAX_HEXSZ), hex); | |
| 521 | 538 | if (opt & OUTPUT_ANNOTATE_COMPAT) { | |
| @@ -647,11 +664,15 @@ static void find_alignment(struct blame_scoreboard *sb, int *option) | |||
| 647 | 664 | struct blame_entry *e; | |
| 648 | 665 | int compute_auto_abbrev = (abbrev < 0); | |
| 649 | 666 | int auto_abbrev = DEFAULT_ABBREV; | |
| 667 | + | size_t max_marks_count = 0; | |
| 650 | 668 | ||
| 651 | 669 | for (e = sb->ent; e; e = e->next) { | |
| 652 | 670 | struct blame_origin *suspect = e->suspect; | |
| 653 | 671 | int num; | |
| 672 | + | size_t marks_count = count_marks(e, *option); | |
| 654 | 673 | ||
| 674 | + | if (max_marks_count < marks_count) | |
| 675 | + | max_marks_count = marks_count; | |
| 655 | 676 | if (compute_auto_abbrev) | |
| 656 | 677 | auto_abbrev = update_auto_abbrev(auto_abbrev, suspect); | |
| 657 | 678 | if (strcmp(suspect->path, sb->path)) | |
| @@ -685,8 +706,12 @@ static void find_alignment(struct blame_scoreboard *sb, int *option) | |||
| 685 | 706 | max_score_digits = decimal_width(largest_score); | |
| 686 | 707 | ||
| 687 | 708 | if (compute_auto_abbrev) | |
| 688 | - | /* one more abbrev length is needed for the boundary commit */ | |
| 689 | - | abbrev = auto_abbrev + 1; | |
| 709 | + | abbrev = auto_abbrev; | |
| 710 | + | if (abbrev < (int)the_hash_algo->hexsz) { | |
| 711 | + | abbrev += max_marks_count; | |
| 712 | + | if (abbrev > (int)the_hash_algo->hexsz) | |
| 713 | + | abbrev = the_hash_algo->hexsz; | |
| 714 | + | } | |
| 690 | 715 | } | |
| 691 | 716 | ||
| 692 | 717 | static void sanity_check_on_fail(struct blame_scoreboard *sb, int baa) | |
| @@ -708,7 +733,7 @@ static unsigned parse_score(const char *arg) | |||
| 708 | 733 | ||
| 709 | 734 | static char *add_prefix(const char *prefix, const char *path) | |
| 710 | 735 | { | |
| 711 | - | return prefix_path(prefix, prefix ? strlen(prefix) : 0, path); | |
| 736 | + | return prefix_path(the_repository, prefix, prefix ? strlen(prefix) : 0, path); | |
| 712 | 737 | } | |
| 713 | 738 | ||
| 714 | 739 | static int git_blame_config(const char *var, const char *value, | |
| @@ -1013,6 +1038,8 @@ int cmd_blame(int argc, | |||
| 1013 | 1038 | case PARSE_OPT_UNKNOWN: | |
| 1014 | 1039 | break; | |
| 1015 | 1040 | case PARSE_OPT_HELP: | |
| 1041 | + | exit(0); | |
| 1042 | + | case PARSE_OPT_HELP_ERROR: | |
| 1016 | 1043 | case PARSE_OPT_ERROR: | |
| 1017 | 1044 | case PARSE_OPT_SUBCOMMAND: | |
| 1018 | 1045 | exit(129); | |
| @@ -1047,10 +1074,7 @@ parse_done: | |||
| 1047 | 1074 | } else if (show_progress < 0) | |
| 1048 | 1075 | show_progress = isatty(2); | |
| 1049 | 1076 | ||
| 1050 | - | if (0 < abbrev && abbrev < (int)the_hash_algo->hexsz) | |
| 1051 | - | /* one more abbrev length is needed for the boundary commit */ | |
| 1052 | - | abbrev++; | |
| 1053 | - | else if (!abbrev) | |
| 1077 | + | if (!abbrev) | |
| 1054 | 1078 | abbrev = the_hash_algo->hexsz; | |
| 1055 | 1079 | ||
| 1056 | 1080 | if (revs_file && read_ancestry(revs_file)) | |
| @@ -1163,7 +1187,7 @@ parse_done: | |||
| 1163 | 1187 | ||
| 1164 | 1188 | revs.disable_stdin = 1; | |
| 1165 | 1189 | setup_revisions(argc, argv, &revs, NULL); | |
| 1166 | - | if (!revs.pending.nr && is_bare_repository()) { | |
| 1190 | + | if (!revs.pending.nr && is_bare_repository(the_repository)) { | |
| 1167 | 1191 | struct commit *head_commit; | |
| 1168 | 1192 | struct object_id head_oid; | |
| 1169 | 1193 | ||
modified builtin/branch.c
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | #include "branch.h" | |
| 22 | 22 | #include "path.h" | |
| 23 | 23 | #include "string-list.h" | |
| 24 | + | #include "strmap.h" | |
| 24 | 25 | #include "column.h" | |
| 25 | 26 | #include "utf8.h" | |
| 26 | 27 | #include "ref-filter.h" | |
| @@ -30,7 +31,7 @@ | |||
| 30 | 31 | #include "commit-reach.h" | |
| 31 | 32 | ||
| 32 | 33 | static const char * const builtin_branch_usage[] = { | |
| 33 | - | N_("git branch [<options>] [-r | -a] [--merged] [--no-merged]"), | |
| 34 | + | N_("git branch [<options>] [-r | -a] [--merged] [--no-merged] [(--forked <branch>)...]"), | |
| 34 | 35 | N_("git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]"), | |
| 35 | 36 | N_("git branch [<options>] [-l] [<pattern>...]"), | |
| 36 | 37 | N_("git branch [<options>] [-r] (-d | -D) <branch-name>..."), | |
| @@ -38,6 +39,8 @@ static const char * const builtin_branch_usage[] = { | |||
| 38 | 39 | N_("git branch [<options>] (-c | -C) [<old-branch>] <new-branch>"), | |
| 39 | 40 | N_("git branch [<options>] [-r | -a] [--points-at]"), | |
| 40 | 41 | N_("git branch [<options>] [-r | -a] [--format]"), | |
| 42 | + | N_("git branch [<options>] (--delete-merged <pattern>)... " | |
| 43 | + | "[<branch-pattern>...]"), | |
| 41 | 44 | NULL | |
| 42 | 45 | }; | |
| 43 | 46 | ||
| @@ -168,10 +171,13 @@ static int branch_merged(int kind, const char *name, | |||
| 168 | 171 | * upstream, if any, otherwise with HEAD", we should just | |
| 169 | 172 | * return the result of the repo_in_merge_bases() above without | |
| 170 | 173 | * any of the following code, but during the transition period, | |
| 171 | - | * a gentle reminder is in order. | |
| 174 | + | * a gentle reminder is in order. Callers that opt out of the | |
| 175 | + | * HEAD fallback by passing head_rev=NULL are not interested in | |
| 176 | + | * the reminder either: they have already established that the | |
| 177 | + | * branch has an upstream, so HEAD is irrelevant to the decision. | |
| 172 | 178 | */ | |
| 173 | - | if (head_rev != reference_rev) { | |
| 174 | - | int expect = head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0; | |
| 179 | + | if (head_rev && head_rev != reference_rev) { | |
| 180 | + | int expect = repo_in_merge_bases(the_repository, rev, head_rev); | |
| 175 | 181 | if (expect < 0) | |
| 176 | 182 | exit(128); | |
| 177 | 183 | if (expect == merged) | |
| @@ -189,20 +195,32 @@ static int branch_merged(int kind, const char *name, | |||
| 189 | 195 | return merged; | |
| 190 | 196 | } | |
| 191 | 197 | ||
| 198 | + | enum delete_branch_flags { | |
| 199 | + | DELETE_BRANCH_FORCE = (1 << 0), | |
| 200 | + | DELETE_BRANCH_QUIET = (1 << 1), | |
| 201 | + | DELETE_BRANCH_SKIP_UNMERGED = (1 << 2), | |
| 202 | + | DELETE_BRANCH_NO_HEAD_FALLBACK = (1 << 3), | |
| 203 | + | DELETE_BRANCH_DRY_RUN = (1 << 4), | |
| 204 | + | }; | |
| 205 | + | ||
| 192 | 206 | static int check_branch_commit(const char *branchname, const char *refname, | |
| 193 | 207 | const struct object_id *oid, struct commit *head_rev, | |
| 194 | - | int kinds, int force) | |
| 208 | + | int kinds, unsigned int flags) | |
| 195 | 209 | { | |
| 196 | 210 | struct commit *rev = lookup_commit_reference(the_repository, oid); | |
| 197 | - | if (!force && !rev) { | |
| 211 | + | if (!(flags & DELETE_BRANCH_FORCE) && !rev) { | |
| 198 | 212 | error(_("couldn't look up commit object for '%s'"), refname); | |
| 199 | 213 | return -1; | |
| 200 | 214 | } | |
| 201 | - | if (!force && !branch_merged(kinds, branchname, rev, head_rev)) { | |
| 202 | - | error(_("the branch '%s' is not fully merged"), branchname); | |
| 203 | - | advise_if_enabled(ADVICE_FORCE_DELETE_BRANCH, | |
| 204 | - | _("If you are sure you want to delete it, " | |
| 205 | - | "run 'git branch -D %s'"), branchname); | |
| 215 | + | if (!(flags & DELETE_BRANCH_FORCE) && | |
| 216 | + | !branch_merged(kinds, branchname, rev, head_rev)) { | |
| 217 | + | if (!(flags & DELETE_BRANCH_SKIP_UNMERGED)) { | |
| 218 | + | error(_("the branch '%s' is not fully merged"), | |
| 219 | + | branchname); | |
| 220 | + | advise_if_enabled(ADVICE_FORCE_DELETE_BRANCH, | |
| 221 | + | _("If you are sure you want to delete it, " | |
| 222 | + | "run 'git branch -D %s'"), branchname); | |
| 223 | + | } | |
| 206 | 224 | return -1; | |
| 207 | 225 | } | |
| 208 | 226 | return 0; | |
| @@ -217,8 +235,8 @@ static void delete_branch_config(const char *branchname) | |||
| 217 | 235 | strbuf_release(&buf); | |
| 218 | 236 | } | |
| 219 | 237 | ||
| 220 | - | static int delete_branches(int argc, const char **argv, int force, int kinds, | |
| 221 | - | int quiet) | |
| 238 | + | static int delete_branches(int argc, const char **argv, int kinds, | |
| 239 | + | unsigned int flags) | |
| 222 | 240 | { | |
| 223 | 241 | struct commit *head_rev = NULL; | |
| 224 | 242 | struct object_id oid; | |
| @@ -241,7 +259,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, | |||
| 241 | 259 | remote_branch = 1; | |
| 242 | 260 | allowed_interpret = INTERPRET_BRANCH_REMOTE; | |
| 243 | 261 | ||
| 244 | - | force = 1; | |
| 262 | + | flags |= DELETE_BRANCH_FORCE; | |
| 245 | 263 | break; | |
| 246 | 264 | case FILTER_REFS_BRANCHES: | |
| 247 | 265 | fmt = "refs/heads/%s"; | |
| @@ -252,19 +270,28 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, | |||
| 252 | 270 | } | |
| 253 | 271 | branch_name_pos = strcspn(fmt, "%"); | |
| 254 | 272 | ||
| 255 | - | if (!force) | |
| 273 | + | if (!(flags & DELETE_BRANCH_FORCE) && | |
| 274 | + | !(flags & DELETE_BRANCH_NO_HEAD_FALLBACK)) | |
| 256 | 275 | head_rev = lookup_commit_reference(the_repository, &head_oid); | |
| 257 | 276 | ||
| 258 | 277 | for (i = 0; i < argc; i++, strbuf_reset(&bname)) { | |
| 259 | 278 | char *target = NULL; | |
| 260 | - | int flags = 0; | |
| 279 | + | int ref_flags = 0; | |
| 261 | 280 | ||
| 262 | - | copy_branchname(&bname, argv[i], allowed_interpret); | |
| 281 | + | copy_branchname(the_repository, &bname, | |
| 282 | + | argv[i], allowed_interpret); | |
| 263 | 283 | free(name); | |
| 264 | 284 | name = mkpathdup(fmt, bname.buf); | |
| 265 | 285 | ||
| 266 | 286 | if (kinds == FILTER_REFS_BRANCHES) { | |
| 267 | 287 | const char *path; | |
| 288 | + | if ((path = branch_bisecting(name))) { | |
| 289 | + | error(_("cannot delete branch '%s' " | |
| 290 | + | "used by worktree at '%s' for bisect"), | |
| 291 | + | bname.buf, path); | |
| 292 | + | ret = 1; | |
| 293 | + | continue; | |
| 294 | + | } | |
| 268 | 295 | if ((path = branch_checked_out(name))) { | |
| 269 | 296 | error(_("cannot delete branch '%s' " | |
| 270 | 297 | "used by worktree at '%s'"), | |
| @@ -279,7 +306,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, | |||
| 279 | 306 | RESOLVE_REF_READING | |
| 280 | 307 | | RESOLVE_REF_NO_RECURSE | |
| 281 | 308 | | RESOLVE_REF_ALLOW_BAD_NAME, | |
| 282 | - | &oid, &flags); | |
| 309 | + | &oid, &ref_flags); | |
| 283 | 310 | if (!target) { | |
| 284 | 311 | if (remote_branch) { | |
| 285 | 312 | error(_("remote-tracking branch '%s' not found"), bname.buf); | |
| @@ -291,7 +318,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, | |||
| 291 | 318 | | RESOLVE_REF_NO_RECURSE | |
| 292 | 319 | | RESOLVE_REF_ALLOW_BAD_NAME, | |
| 293 | 320 | &oid, | |
| 294 | - | &flags); | |
| 321 | + | &ref_flags); | |
| 295 | 322 | FREE_AND_NULL(virtual_name); | |
| 296 | 323 | ||
| 297 | 324 | if (virtual_target) | |
| @@ -306,31 +333,39 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, | |||
| 306 | 333 | continue; | |
| 307 | 334 | } | |
| 308 | 335 | ||
| 309 | - | if (!(flags & (REF_ISSYMREF|REF_ISBROKEN)) && | |
| 336 | + | if (!(ref_flags & (REF_ISSYMREF|REF_ISBROKEN)) && | |
| 310 | 337 | check_branch_commit(bname.buf, name, &oid, head_rev, kinds, | |
| 311 | - | force)) { | |
| 312 | - | ret = 1; | |
| 338 | + | flags)) { | |
| 339 | + | if (!(flags & DELETE_BRANCH_SKIP_UNMERGED)) | |
| 340 | + | ret = 1; | |
| 313 | 341 | goto next; | |
| 314 | 342 | } | |
| 315 | 343 | ||
| 316 | 344 | item = string_list_append(&refs_to_delete, name); | |
| 317 | - | item->util = xstrdup((flags & REF_ISBROKEN) ? "broken" | |
| 318 | - | : (flags & REF_ISSYMREF) ? target | |
| 345 | + | item->util = xstrdup((ref_flags & REF_ISBROKEN) ? "broken" | |
| 346 | + | : (ref_flags & REF_ISSYMREF) ? target | |
| 319 | 347 | : repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV)); | |
| 320 | 348 | ||
| 321 | 349 | next: | |
| 322 | 350 | free(target); | |
| 323 | 351 | } | |
| 324 | 352 | ||
| 325 | - | if (refs_delete_refs(get_main_ref_store(the_repository), NULL, &refs_to_delete, REF_NO_DEREF)) | |
| 353 | + | if (!(flags & DELETE_BRANCH_DRY_RUN) && | |
| 354 | + | refs_delete_refs(get_main_ref_store(the_repository), NULL, &refs_to_delete, REF_NO_DEREF)) | |
| 326 | 355 | ret = 1; | |
| 327 | 356 | ||
| 328 | 357 | for_each_string_list_item(item, &refs_to_delete) { | |
| 329 | 358 | char *describe_ref = item->util; | |
| 330 | 359 | char *name = item->string; | |
| 331 | - | if (!refs_ref_exists(get_main_ref_store(the_repository), name)) { | |
| 360 | + | if (flags & DELETE_BRANCH_DRY_RUN) { | |
| 361 | + | if (!(flags & DELETE_BRANCH_QUIET)) | |
| 362 | + | printf(remote_branch | |
| 363 | + | ? _("Would delete remote-tracking branch %s (was %s).\n") | |
| 364 | + | : _("Would delete branch %s (was %s).\n"), | |
| 365 | + | name + branch_name_pos, describe_ref); | |
| 366 | + | } else if (!refs_ref_exists(get_main_ref_store(the_repository), name)) { | |
| 332 | 367 | char *refname = name + branch_name_pos; | |
| 333 | - | if (!quiet) | |
| 368 | + | if (!(flags & DELETE_BRANCH_QUIET)) | |
| 334 | 369 | printf(remote_branch | |
| 335 | 370 | ? _("Deleted remote-tracking branch %s (was %s).\n") | |
| 336 | 371 | : _("Deleted branch %s (was %s).\n"), | |
| @@ -579,9 +614,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int | |||
| 579 | 614 | const char *interpreted_oldname = NULL; | |
| 580 | 615 | const char *interpreted_newname = NULL; | |
| 581 | 616 | int recovery = 0, oldref_usage = 0; | |
| 582 | - | struct worktree **worktrees = get_worktrees(); | |
| 617 | + | struct worktree **worktrees = get_worktrees(the_repository); | |
| 583 | 618 | ||
| 584 | - | if (check_branch_ref(&oldref, oldname)) { | |
| 619 | + | if (check_branch_ref(the_repository, &oldref, oldname)) { | |
| 585 | 620 | /* | |
| 586 | 621 | * Bad name --- this could be an attempt to rename a | |
| 587 | 622 | * ref that we used to allow to be created by accident. | |
| @@ -673,6 +708,208 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int | |||
| 673 | 708 | free_worktrees(worktrees); | |
| 674 | 709 | } | |
| 675 | 710 | ||
| 711 | + | static int parse_opt_forked(const struct option *opt, const char *arg, int unset) | |
| 712 | + | { | |
| 713 | + | struct ref_filter *filter = opt->value; | |
| 714 | + | ||
| 715 | + | BUG_ON_OPT_NEG(unset); | |
| 716 | + | if (ref_filter_forked_add(filter, arg) < 0) | |
| 717 | + | die(_("'%s' is not a valid branch or pattern"), arg); | |
| 718 | + | return 0; | |
| 719 | + | } | |
| 720 | + | ||
| 721 | + | struct stacked_branch_data { | |
| 722 | + | struct strset *deletable_branch_names; | |
| 723 | + | struct strset *protected_branch_names; | |
| 724 | + | }; | |
| 725 | + | ||
| 726 | + | static int collect_stacked_branch_base(const struct reference *ref, | |
| 727 | + | void *cb_data) | |
| 728 | + | { | |
| 729 | + | struct stacked_branch_data *data = cb_data; | |
| 730 | + | const char *branch_name; | |
| 731 | + | struct branch *branch; | |
| 732 | + | const char *upstream_refname; | |
| 733 | + | const char *upstream_branch_name; | |
| 734 | + | ||
| 735 | + | if (!skip_prefix(ref->name, "refs/heads/", &branch_name)) | |
| 736 | + | BUG("expected local branch ref, got '%s'", ref->name); | |
| 737 | + | if (strset_contains(data->deletable_branch_names, branch_name)) | |
| 738 | + | return 0; | |
| 739 | + | ||
| 740 | + | branch = branch_get(branch_name); | |
| 741 | + | upstream_refname = branch_get_upstream(branch, NULL); | |
| 742 | + | if (!upstream_refname || | |
| 743 | + | !skip_prefix(upstream_refname, "refs/heads/", | |
| 744 | + | &upstream_branch_name) || | |
| 745 | + | !strset_contains(data->deletable_branch_names, | |
| 746 | + | upstream_branch_name)) | |
| 747 | + | return 0; | |
| 748 | + | ||
| 749 | + | strset_add(data->protected_branch_names, upstream_branch_name); | |
| 750 | + | return 0; | |
| 751 | + | } | |
| 752 | + | ||
| 753 | + | static void protect_stacked_branch_bases(struct ref_store *refs, | |
| 754 | + | struct strset *deletable_branch_names, | |
| 755 | + | struct strset *protected_branch_names) | |
| 756 | + | { | |
| 757 | + | struct stacked_branch_data data = { | |
| 758 | + | .deletable_branch_names = deletable_branch_names, | |
| 759 | + | .protected_branch_names = protected_branch_names, | |
| 760 | + | }; | |
| 761 | + | struct refs_for_each_ref_options opts = { | |
| 762 | + | .prefix = "refs/heads/", | |
| 763 | + | }; | |
| 764 | + | struct hashmap_iter iter; | |
| 765 | + | struct strmap_entry *entry; | |
| 766 | + | ||
| 767 | + | refs_for_each_ref_ext(refs, collect_stacked_branch_base, &data, &opts); | |
| 768 | + | ||
| 769 | + | strset_for_each_entry(protected_branch_names, &iter, entry) | |
| 770 | + | strset_remove(deletable_branch_names, entry->key); | |
| 771 | + | } | |
| 772 | + | ||
| 773 | + | static void clear_deleted_upstreams(struct strset *protected_branch_names, | |
| 774 | + | struct strset *deletable_branch_names) | |
| 775 | + | { | |
| 776 | + | struct strbuf key = STRBUF_INIT; | |
| 777 | + | struct hashmap_iter iter; | |
| 778 | + | struct strmap_entry *entry; | |
| 779 | + | ||
| 780 | + | strset_for_each_entry(protected_branch_names, &iter, entry) { | |
| 781 | + | struct branch *branch = branch_get(entry->key); | |
| 782 | + | const char *upstream_refname = branch_get_upstream(branch, NULL); | |
| 783 | + | const char *upstream_branch_name; | |
| 784 | + | ||
| 785 | + | if (!upstream_refname || | |
| 786 | + | !skip_prefix(upstream_refname, "refs/heads/", | |
| 787 | + | &upstream_branch_name) || | |
| 788 | + | !strset_contains(deletable_branch_names, | |
| 789 | + | upstream_branch_name)) | |
| 790 | + | continue; | |
| 791 | + | ||
| 792 | + | strbuf_addf(&key, "branch.%s.merge", branch->name); | |
| 793 | + | repo_config_set_gently(the_repository, key.buf, NULL); | |
| 794 | + | strbuf_reset(&key); | |
| 795 | + | strbuf_addf(&key, "branch.%s.remote", branch->name); | |
| 796 | + | repo_config_set_gently(the_repository, key.buf, NULL); | |
| 797 | + | strbuf_reset(&key); | |
| 798 | + | } | |
| 799 | + | ||
| 800 | + | strbuf_release(&key); | |
| 801 | + | } | |
| 802 | + | ||
| 803 | + | static int branch_pushes_to_upstream(struct branch *branch, | |
| 804 | + | const char *upstream) | |
| 805 | + | { | |
| 806 | + | struct remote *remote = remote_get(remote_for_branch(branch, NULL)); | |
| 807 | + | char *push_refname = NULL; | |
| 808 | + | char *tracking = NULL; | |
| 809 | + | int ret = 0; | |
| 810 | + | ||
| 811 | + | if (!remote) | |
| 812 | + | return 0; | |
| 813 | + | if (remote->push.nr) | |
| 814 | + | push_refname = apply_refspecs(&remote->push, branch->refname); | |
| 815 | + | else | |
| 816 | + | push_refname = xstrdup(branch->refname); | |
| 817 | + | if (push_refname) | |
| 818 | + | tracking = apply_refspecs(&remote->fetch, push_refname); | |
| 819 | + | if (tracking && !strcmp(tracking, upstream)) | |
| 820 | + | ret = 1; | |
| 821 | + | ||
| 822 | + | free(push_refname); | |
| 823 | + | free(tracking); | |
| 824 | + | return ret; | |
| 825 | + | } | |
| 826 | + | ||
| 827 | + | static int delete_merged_branches(const struct strvec *upstreams, | |
| 828 | + | const char **argv, unsigned int flags) | |
| 829 | + | { | |
| 830 | + | struct ref_store *refs = get_main_ref_store(the_repository); | |
| 831 | + | struct ref_filter filter = REF_FILTER_INIT; | |
| 832 | + | struct ref_array candidates = { 0 }; | |
| 833 | + | struct strset deletable_branch_names = STRSET_INIT; | |
| 834 | + | struct strset protected_branch_names = STRSET_INIT; | |
| 835 | + | struct strvec branches_to_delete = STRVEC_INIT; | |
| 836 | + | struct strbuf key = STRBUF_INIT; | |
| 837 | + | struct hashmap_iter iter; | |
| 838 | + | struct strmap_entry *entry; | |
| 839 | + | int ret = 0; | |
| 840 | + | ||
| 841 | + | for (size_t i = 0; i < upstreams->nr; i++) | |
| 842 | + | if (ref_filter_forked_add(&filter, upstreams->v[i]) < 0) | |
| 843 | + | die(_("'%s' is not a valid branch or pattern"), | |
| 844 | + | upstreams->v[i]); | |
| 845 | + | ||
| 846 | + | filter.kind = FILTER_REFS_BRANCHES; | |
| 847 | + | filter.name_patterns = argv; | |
| 848 | + | filter_refs(&candidates, &filter, filter.kind); | |
| 849 | + | ||
| 850 | + | for (int i = 0; i < candidates.nr; i++) { | |
| 851 | + | const char *branch_refname = candidates.items[i]->refname; | |
| 852 | + | const char *branch_name; | |
| 853 | + | struct branch *branch; | |
| 854 | + | const char *upstream_refname; | |
| 855 | + | int opt_out; | |
| 856 | + | ||
| 857 | + | if (!skip_prefix(branch_refname, "refs/heads/", &branch_name)) | |
| 858 | + | BUG("filter returned non-branch ref '%s'", branch_refname); | |
| 859 | + | if (branch_checked_out(branch_refname)) | |
| 860 | + | continue; | |
| 861 | + | ||
| 862 | + | branch = branch_get(branch_name); | |
| 863 | + | upstream_refname = branch_get_upstream(branch, NULL); | |
| 864 | + | if (!upstream_refname || !refs_ref_exists(refs, upstream_refname)) | |
| 865 | + | continue; | |
| 866 | + | if (branch_pushes_to_upstream(branch, upstream_refname)) | |
| 867 | + | continue; | |
| 868 | + | if (check_branch_commit(branch_name, branch_name, | |
| 869 | + | &candidates.items[i]->objectname, NULL, | |
| 870 | + | FILTER_REFS_BRANCHES, DELETE_BRANCH_SKIP_UNMERGED)) | |
| 871 | + | continue; | |
| 872 | + | ||
| 873 | + | strbuf_reset(&key); | |
| 874 | + | strbuf_addf(&key, "branch.%s.deletemerged", branch_name); | |
| 875 | + | if (!repo_config_get_bool(the_repository, key.buf, &opt_out) && | |
| 876 | + | !opt_out) { | |
| 877 | + | if (!(flags & DELETE_BRANCH_QUIET)) | |
| 878 | + | fprintf(stderr, | |
| 879 | + | _("Skipping '%s' (branch.%s.deleteMerged is false)\n"), | |
| 880 | + | branch_name, branch_name); | |
| 881 | + | continue; | |
| 882 | + | } | |
| 883 | + | ||
| 884 | + | strset_add(&deletable_branch_names, branch_name); | |
| 885 | + | } | |
| 886 | + | ||
| 887 | + | protect_stacked_branch_bases(refs, &deletable_branch_names, | |
| 888 | + | &protected_branch_names); | |
| 889 | + | ||
| 890 | + | strset_for_each_entry(&deletable_branch_names, &iter, entry) | |
| 891 | + | strvec_push(&branches_to_delete, entry->key); | |
| 892 | + | ||
| 893 | + | if (branches_to_delete.nr) | |
| 894 | + | ret = delete_branches(branches_to_delete.nr, branches_to_delete.v, | |
| 895 | + | FILTER_REFS_BRANCHES, | |
| 896 | + | DELETE_BRANCH_SKIP_UNMERGED | | |
| 897 | + | DELETE_BRANCH_NO_HEAD_FALLBACK | | |
| 898 | + | flags); | |
| 899 | + | ||
| 900 | + | if (!ret && !(flags & DELETE_BRANCH_DRY_RUN)) | |
| 901 | + | clear_deleted_upstreams(&protected_branch_names, | |
| 902 | + | &deletable_branch_names); | |
| 903 | + | ||
| 904 | + | strbuf_release(&key); | |
| 905 | + | strvec_clear(&branches_to_delete); | |
| 906 | + | strset_clear(&protected_branch_names); | |
| 907 | + | strset_clear(&deletable_branch_names); | |
| 908 | + | ref_array_clear(&candidates); | |
| 909 | + | ref_filter_clear(&filter); | |
| 910 | + | return ret; | |
| 911 | + | } | |
| 912 | + | ||
| 676 | 913 | static GIT_PATH_FUNC(edit_description, "EDIT_DESCRIPTION") | |
| 677 | 914 | ||
| 678 | 915 | static int edit_branch_description(const char *branch_name) | |
| @@ -706,6 +943,29 @@ static int edit_branch_description(const char *branch_name) | |||
| 706 | 943 | return 0; | |
| 707 | 944 | } | |
| 708 | 945 | ||
| 946 | + | static void die_if_upstream_looks_like_remote(const char *new_upstream, const char *branch_name) | |
| 947 | + | { | |
| 948 | + | struct strbuf remote_ref = STRBUF_INIT; | |
| 949 | + | int code; | |
| 950 | + | ||
| 951 | + | if (strchr(new_upstream, '/') || | |
| 952 | + | !remote_is_configured(remote_get(new_upstream), 0)) | |
| 953 | + | return; | |
| 954 | + | ||
| 955 | + | strbuf_addf(&remote_ref, "refs/remotes/%s/%s", new_upstream, branch_name); | |
| 956 | + | if (!refs_ref_exists(get_main_ref_store(the_repository), remote_ref.buf)) { | |
| 957 | + | strbuf_release(&remote_ref); | |
| 958 | + | return; | |
| 959 | + | } | |
| 960 | + | ||
| 961 | + | code = die_message(_("--set-upstream-to takes a single <remote>/<branch> argument")); | |
| 962 | + | advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE, | |
| 963 | + | _("Did you mean to use: git branch --set-upstream-to=%s/%s?"), | |
| 964 | + | new_upstream, branch_name); | |
| 965 | + | strbuf_release(&remote_ref); | |
| 966 | + | exit(code); | |
| 967 | + | } | |
| 968 | + | ||
| 709 | 969 | int cmd_branch(int argc, | |
| 710 | 970 | const char **argv, | |
| 711 | 971 | const char *prefix, | |
| @@ -714,6 +974,8 @@ int cmd_branch(int argc, | |||
| 714 | 974 | /* possible actions */ | |
| 715 | 975 | int delete = 0, rename = 0, copy = 0, list = 0, | |
| 716 | 976 | unset_upstream = 0, show_current = 0, edit_description = 0; | |
| 977 | + | struct strvec delete_merged = STRVEC_INIT; | |
| 978 | + | int dry_run = 0; | |
| 717 | 979 | const char *new_upstream = NULL; | |
| 718 | 980 | int noncreate_actions = 0; | |
| 719 | 981 | /* possible options */ | |
| @@ -767,9 +1029,17 @@ int cmd_branch(int argc, | |||
| 767 | 1029 | OPT_BOOL(0, "create-reflog", &reflog, N_("create the branch's reflog")), | |
| 768 | 1030 | OPT_BOOL(0, "edit-description", &edit_description, | |
| 769 | 1031 | N_("edit the description for the branch")), | |
| 1032 | + | OPT_CALLBACK_F(0, "delete-merged", &delete_merged, N_("pattern"), | |
| 1033 | + | N_("delete merged branches whose upstream matches <pattern> (repeatable)"), | |
| 1034 | + | PARSE_OPT_NONEG, parse_opt_strvec), | |
| 1035 | + | OPT_BOOL(0, "dry-run", &dry_run, | |
| 1036 | + | N_("with --delete-merged, only print which branches would be deleted")), | |
| 770 | 1037 | OPT__FORCE(&force, N_("force creation, move/rename, deletion"), PARSE_OPT_NOCOMPLETE), | |
| 771 | 1038 | OPT_MERGED(&filter, N_("print only branches that are merged")), | |
| 772 | 1039 | OPT_NO_MERGED(&filter, N_("print only branches that are not merged")), | |
| 1040 | + | OPT_CALLBACK_F(0, "forked", &filter, N_("branch"), | |
| 1041 | + | N_("print only branches whose upstream matches <branch> (repeatable)"), | |
| 1042 | + | PARSE_OPT_NONEG, parse_opt_forked), | |
| 773 | 1043 | OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")), | |
| 774 | 1044 | OPT_REF_SORT(&sorting_options), | |
| 775 | 1045 | OPT_CALLBACK(0, "points-at", &filter.points_at, N_("object"), | |
| @@ -811,19 +1081,24 @@ int cmd_branch(int argc, | |||
| 811 | 1081 | 0); | |
| 812 | 1082 | ||
| 813 | 1083 | if (!delete && !rename && !copy && !edit_description && !new_upstream && | |
| 814 | - | !show_current && !unset_upstream && argc == 0) | |
| 1084 | + | !show_current && !unset_upstream && !delete_merged.nr && | |
| 1085 | + | argc == 0) | |
| 815 | 1086 | list = 1; | |
| 816 | 1087 | ||
| 817 | 1088 | if (filter.with_commit || filter.no_commit || | |
| 818 | - | filter.reachable_from || filter.unreachable_from || filter.points_at.nr) | |
| 1089 | + | filter.reachable_from || filter.unreachable_from || | |
| 1090 | + | filter.points_at.nr || filter.forked.nr) | |
| 819 | 1091 | list = 1; | |
| 820 | 1092 | ||
| 821 | 1093 | noncreate_actions = !!delete + !!rename + !!copy + !!new_upstream + | |
| 822 | 1094 | !!show_current + !!list + !!edit_description + | |
| 823 | - | !!unset_upstream; | |
| 1095 | + | !!unset_upstream + !!delete_merged.nr; | |
| 824 | 1096 | if (noncreate_actions > 1) | |
| 825 | 1097 | usage_with_options(builtin_branch_usage, options); | |
| 826 | 1098 | ||
| 1099 | + | if (dry_run && !delete_merged.nr) | |
| 1100 | + | die(_("--dry-run requires --delete-merged")); | |
| 1101 | + | ||
| 827 | 1102 | if (recurse_submodules_explicit) { | |
| 828 | 1103 | if (!submodule_propagate_branches) | |
| 829 | 1104 | die(_("branch with --recurse-submodules can only be used if submodule.propagateBranches is enabled")); | |
| @@ -858,7 +1133,14 @@ int cmd_branch(int argc, | |||
| 858 | 1133 | if (delete) { | |
| 859 | 1134 | if (!argc) | |
| 860 | 1135 | die(_("branch name required")); | |
| 861 | - | ret = delete_branches(argc, argv, delete > 1, filter.kind, quiet); | |
| 1136 | + | ret = delete_branches(argc, argv, filter.kind, | |
| 1137 | + | (delete > 1 ? DELETE_BRANCH_FORCE : 0) | | |
| 1138 | + | (quiet ? DELETE_BRANCH_QUIET : 0)); | |
| 1139 | + | goto out; | |
| 1140 | + | } else if (delete_merged.nr) { | |
| 1141 | + | ret = delete_merged_branches(&delete_merged, argv, | |
| 1142 | + | (quiet ? DELETE_BRANCH_QUIET : 0) | | |
| 1143 | + | (dry_run ? DELETE_BRANCH_DRY_RUN : 0)); | |
| 862 | 1144 | goto out; | |
| 863 | 1145 | } else if (show_current) { | |
| 864 | 1146 | print_current_branch_name(); | |
| @@ -898,7 +1180,8 @@ int cmd_branch(int argc, | |||
| 898 | 1180 | die(_("cannot give description to detached HEAD")); | |
| 899 | 1181 | branch_name = head; | |
| 900 | 1182 | } else if (argc == 1) { | |
| 901 | - | copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); | |
| 1183 | + | copy_branchname(the_repository, &buf, argv[0], | |
| 1184 | + | INTERPRET_BRANCH_LOCAL); | |
| 902 | 1185 | branch_name = buf.buf; | |
| 903 | 1186 | } else { | |
| 904 | 1187 | die(_("cannot edit description of more than one branch")); | |
| @@ -941,7 +1224,8 @@ int cmd_branch(int argc, | |||
| 941 | 1224 | if (!argc) | |
| 942 | 1225 | branch = branch_get(NULL); | |
| 943 | 1226 | else if (argc == 1) { | |
| 944 | - | copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); | |
| 1227 | + | copy_branchname(the_repository, &buf, argv[0], | |
| 1228 | + | INTERPRET_BRANCH_LOCAL); | |
| 945 | 1229 | branch = branch_get(buf.buf); | |
| 946 | 1230 | } else | |
| 947 | 1231 | die(_("too many arguments to set new upstream")); | |
| @@ -957,6 +1241,15 @@ int cmd_branch(int argc, | |||
| 957 | 1241 | if (!refs_ref_exists(get_main_ref_store(the_repository), branch->refname)) { | |
| 958 | 1242 | if (!argc || branch_checked_out(branch->refname)) | |
| 959 | 1243 | die(_("no commit on branch '%s' yet"), branch->name); | |
| 1244 | + | /* | |
| 1245 | + | * Check the advice up front to avoid the ref | |
| 1246 | + | * lookups when the hint is off. The helper still | |
| 1247 | + | * calls advise_if_enabled() so the hint carries the | |
| 1248 | + | * standard "disable this message" instructions. | |
| 1249 | + | */ | |
| 1250 | + | if (argc == 1 && | |
| 1251 | + | advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) | |
| 1252 | + | die_if_upstream_looks_like_remote(new_upstream, argv[0]); | |
| 960 | 1253 | die(_("branch '%s' does not exist"), branch->name); | |
| 961 | 1254 | } | |
| 962 | 1255 | ||
| @@ -971,7 +1264,8 @@ int cmd_branch(int argc, | |||
| 971 | 1264 | if (!argc) | |
| 972 | 1265 | branch = branch_get(NULL); | |
| 973 | 1266 | else if (argc == 1) { | |
| 974 | - | copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL); | |
| 1267 | + | copy_branchname(the_repository, &buf, argv[0], | |
| 1268 | + | INTERPRET_BRANCH_LOCAL); | |
| 975 | 1269 | branch = branch_get(buf.buf); | |
| 976 | 1270 | } else | |
| 977 | 1271 | die(_("too many arguments to unset upstream")); | |
| @@ -1019,6 +1313,7 @@ int cmd_branch(int argc, | |||
| 1019 | 1313 | ret = 0; | |
| 1020 | 1314 | ||
| 1021 | 1315 | out: | |
| 1316 | + | strvec_clear(&delete_merged); | |
| 1022 | 1317 | string_list_clear(&sorting_options, 0); | |
| 1023 | 1318 | return ret; | |
| 1024 | 1319 | } | |
modified builtin/bundle.c
| @@ -68,32 +68,25 @@ static int parse_options_cmd_bundle(int argc, | |||
| 68 | 68 | } | |
| 69 | 69 | ||
| 70 | 70 | static int cmd_bundle_create(int argc, const char **argv, const char *prefix, | |
| 71 | - | struct repository *repo UNUSED) { | |
| 72 | - | struct strvec pack_opts = STRVEC_INIT; | |
| 71 | + | struct repository *repo UNUSED) | |
| 72 | + | { | |
| 73 | + | int progress = isatty(STDERR_FILENO); | |
| 73 | 74 | int version = -1; | |
| 74 | - | int ret; | |
| 75 | 75 | struct option options[] = { | |
| 76 | - | OPT_PASSTHRU_ARGV('q', "quiet", &pack_opts, NULL, | |
| 77 | - | N_("do not show progress meter"), | |
| 78 | - | PARSE_OPT_NOARG), | |
| 79 | - | OPT_PASSTHRU_ARGV(0, "progress", &pack_opts, NULL, | |
| 80 | - | N_("show progress meter"), | |
| 81 | - | PARSE_OPT_NOARG), | |
| 82 | - | OPT_PASSTHRU_ARGV(0, "all-progress", &pack_opts, NULL, | |
| 83 | - | N_("historical; same as --progress"), | |
| 84 | - | PARSE_OPT_NOARG | PARSE_OPT_HIDDEN), | |
| 85 | - | OPT_PASSTHRU_ARGV(0, "all-progress-implied", &pack_opts, NULL, | |
| 86 | - | N_("historical; does nothing"), | |
| 87 | - | PARSE_OPT_NOARG | PARSE_OPT_HIDDEN), | |
| 76 | + | OPT_NEGBIT('q', "quiet", &progress, | |
| 77 | + | N_("do not show progress meter"), 1), | |
| 78 | + | OPT_BIT(0, "progress", &progress, | |
| 79 | + | N_("show progress meter"), 1), | |
| 80 | + | OPT_BIT_F(0, "all-progress", &progress, | |
| 81 | + | N_("historical; same as --progress"), 1, | |
| 82 | + | PARSE_OPT_HIDDEN), | |
| 83 | + | OPT_NOOP_NOARG(0, "all-progress-implied"), | |
| 88 | 84 | OPT_INTEGER(0, "version", &version, | |
| 89 | 85 | N_("specify bundle format version")), | |
| 90 | 86 | OPT_END() | |
| 91 | 87 | }; | |
| 92 | 88 | char *bundle_file; | |
| 93 | - | ||
| 94 | - | if (isatty(STDERR_FILENO)) | |
| 95 | - | strvec_push(&pack_opts, "--progress"); | |
| 96 | - | strvec_push(&pack_opts, "--all-progress-implied"); | |
| 89 | + | int ret; | |
| 97 | 90 | ||
| 98 | 91 | argc = parse_options_cmd_bundle(argc, argv, prefix, | |
| 99 | 92 | builtin_bundle_create_usage, options, &bundle_file); | |
| @@ -101,8 +94,7 @@ static int cmd_bundle_create(int argc, const char **argv, const char *prefix, | |||
| 101 | 94 | ||
| 102 | 95 | if (!startup_info->have_repository) | |
| 103 | 96 | die(_("Need a repository to create a bundle.")); | |
| 104 | - | ret = !!create_bundle(the_repository, bundle_file, argc, argv, &pack_opts, version); | |
| 105 | - | strvec_clear(&pack_opts); | |
| 97 | + | ret = !!create_bundle(the_repository, bundle_file, argc, argv, version, progress); | |
| 106 | 98 | free(bundle_file); | |
| 107 | 99 | return ret; | |
| 108 | 100 | } | |
modified builtin/cat-file.c
| @@ -20,7 +20,6 @@ | |||
| 20 | 20 | #include "userdiff.h" | |
| 21 | 21 | #include "oid-array.h" | |
| 22 | 22 | #include "packfile.h" | |
| 23 | - | #include "pack-bitmap.h" | |
| 24 | 23 | #include "object-file.h" | |
| 25 | 24 | #include "object-name.h" | |
| 26 | 25 | #include "odb.h" | |
| @@ -29,6 +28,23 @@ | |||
| 29 | 28 | #include "promisor-remote.h" | |
| 30 | 29 | #include "mailmap.h" | |
| 31 | 30 | #include "write-or-die.h" | |
| 31 | + | #include "alias.h" | |
| 32 | + | #include "remote.h" | |
| 33 | + | #include "transport.h" | |
| 34 | + | #include "fetch-object-info.h" | |
| 35 | + | ||
| 36 | + | /* | |
| 37 | + | * Maximum length for a remote URL. While no universal standard exists, | |
| 38 | + | * 8K is assumed to be a reasonable limit. | |
| 39 | + | */ | |
| 40 | + | #define MAX_REMOTE_URL_LEN (8 * 1024) | |
| 41 | + | ||
| 42 | + | /* Maximum number of objects allowed in a single remote-object-info request. */ | |
| 43 | + | #define MAX_ALLOWED_OBJ_LIMIT 10000 | |
| 44 | + | ||
| 45 | + | /* Maximum input size permitted for the remote-object-info command. */ | |
| 46 | + | #define MAX_REMOTE_OBJ_INFO_LINE \ | |
| 47 | + | (MAX_REMOTE_URL_LEN + MAX_ALLOWED_OBJ_LIMIT * (GIT_MAX_HEXSZ + 1)) | |
| 32 | 48 | ||
| 33 | 49 | enum batch_mode { | |
| 34 | 50 | BATCH_MODE_CONTENTS, | |
| @@ -57,6 +73,20 @@ static int use_mailmap; | |||
| 57 | 73 | ||
| 58 | 74 | static char *replace_idents_using_mailmap(char *, size_t *); | |
| 59 | 75 | ||
| 76 | + | /* | |
| 77 | + | * The mailmap is initialized with .strdup_strings set to 0, | |
| 78 | + | * but read_mailmap() sets the bit to 1 (this is true even when | |
| 79 | + | * not a single mailmap entry is read), so it can be used for | |
| 80 | + | * lazy loading. | |
| 81 | + | */ | |
| 82 | + | static void load_mailmap(void) | |
| 83 | + | { | |
| 84 | + | if (mailmap.strdup_strings) | |
| 85 | + | return; | |
| 86 | + | ||
| 87 | + | read_mailmap(the_repository, &mailmap); | |
| 88 | + | } | |
| 89 | + | ||
| 60 | 90 | static char *replace_idents_using_mailmap(char *object_buf, size_t *size) | |
| 61 | 91 | { | |
| 62 | 92 | struct strbuf sb = STRBUF_INIT; | |
| @@ -70,7 +100,7 @@ static char *replace_idents_using_mailmap(char *object_buf, size_t *size) | |||
| 70 | 100 | ||
| 71 | 101 | static int filter_object(const char *path, unsigned mode, | |
| 72 | 102 | const struct object_id *oid, | |
| 73 | - | char **buf, unsigned long *size) | |
| 103 | + | char **buf, size_t *size) | |
| 74 | 104 | { | |
| 75 | 105 | enum object_type type; | |
| 76 | 106 | ||
| @@ -106,7 +136,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) | |||
| 106 | 136 | struct object_id oid; | |
| 107 | 137 | enum object_type type; | |
| 108 | 138 | char *buf; | |
| 109 | - | unsigned long size; | |
| 139 | + | size_t size; | |
| 110 | 140 | struct object_context obj_context = {0}; | |
| 111 | 141 | struct object_info oi = OBJECT_INFO_INIT; | |
| 112 | 142 | unsigned flags = OBJECT_INFO_LOOKUP_REPLACE; | |
| @@ -149,11 +179,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) | |||
| 149 | 179 | if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0) | |
| 150 | 180 | die("git cat-file: could not get object info"); | |
| 151 | 181 | ||
| 152 | - | if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) { | |
| 153 | - | size_t s = size; | |
| 154 | - | buf = replace_idents_using_mailmap(buf, &s); | |
| 155 | - | size = cast_size_t_to_ulong(s); | |
| 156 | - | } | |
| 182 | + | if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) | |
| 183 | + | buf = replace_idents_using_mailmap(buf, &size); | |
| 157 | 184 | ||
| 158 | 185 | printf("%"PRIuMAX"\n", (uintmax_t)size); | |
| 159 | 186 | ret = 0; | |
| @@ -174,9 +201,15 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) | |||
| 174 | 201 | break; | |
| 175 | 202 | ||
| 176 | 203 | case 'c': | |
| 177 | - | if (textconv_object(the_repository, path, obj_context.mode, | |
| 178 | - | &oid, 1, &buf, &size)) | |
| 204 | + | { | |
| 205 | + | unsigned long size_ul = 0; | |
| 206 | + | int textconv_ret = textconv_object(the_repository, path, | |
| 207 | + | obj_context.mode, &oid, 1, | |
| 208 | + | &buf, &size_ul); | |
| 209 | + | size = size_ul; | |
| 210 | + | if (textconv_ret) | |
| 179 | 211 | break; | |
| 212 | + | } | |
| 180 | 213 | /* else fallthrough */ | |
| 181 | 214 | ||
| 182 | 215 | case 'p': | |
| @@ -202,11 +235,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) | |||
| 202 | 235 | if (!buf) | |
| 203 | 236 | die("Cannot read object %s", obj_name); | |
| 204 | 237 | ||
| 205 | - | if (use_mailmap) { | |
| 206 | - | size_t s = size; | |
| 207 | - | buf = replace_idents_using_mailmap(buf, &s); | |
| 208 | - | size = cast_size_t_to_ulong(s); | |
| 209 | - | } | |
| 238 | + | if (use_mailmap) | |
| 239 | + | buf = replace_idents_using_mailmap(buf, &size); | |
| 210 | 240 | ||
| 211 | 241 | /* otherwise just spit out the data */ | |
| 212 | 242 | break; | |
| @@ -249,11 +279,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) | |||
| 249 | 279 | buf = odb_read_object_peeled(the_repository->objects, &oid, | |
| 250 | 280 | exp_type_id, &size, NULL); | |
| 251 | 281 | ||
| 252 | - | if (use_mailmap) { | |
| 253 | - | size_t s = size; | |
| 254 | - | buf = replace_idents_using_mailmap(buf, &s); | |
| 255 | - | size = cast_size_t_to_ulong(s); | |
| 256 | - | } | |
| 282 | + | if (use_mailmap) | |
| 283 | + | buf = replace_idents_using_mailmap(buf, &size); | |
| 257 | 284 | break; | |
| 258 | 285 | } | |
| 259 | 286 | default: | |
| @@ -274,7 +301,7 @@ cleanup: | |||
| 274 | 301 | struct expand_data { | |
| 275 | 302 | struct object_id oid; | |
| 276 | 303 | enum object_type type; | |
| 277 | - | unsigned long size; | |
| 304 | + | size_t size; | |
| 278 | 305 | unsigned short mode; | |
| 279 | 306 | off_t disk_size; | |
| 280 | 307 | const char *rest; | |
| @@ -306,8 +333,24 @@ struct expand_data { | |||
| 306 | 333 | * optimized out. | |
| 307 | 334 | */ | |
| 308 | 335 | unsigned skip_object_info : 1; | |
| 336 | + | ||
| 337 | + | /* | |
| 338 | + | * Flags about when an object info is being fetched from remote. | |
| 339 | + | */ | |
| 340 | + | unsigned is_remote:1; | |
| 341 | + | ||
| 342 | + | /* | |
| 343 | + | * List of atoms (i.e. "objectsize") that the server supports. Built | |
| 344 | + | * from the server's object-info advertised capabilities. | |
| 345 | + | */ | |
| 346 | + | struct string_list remote_allowed_atoms; | |
| 309 | 347 | }; | |
| 310 | - | #define EXPAND_DATA_INIT { .mode = S_IFINVALID } | |
| 348 | + | ||
| 349 | + | #define EXPAND_DATA_INIT { \ | |
| 350 | + | .mode = S_IFINVALID, \ | |
| 351 | + | .type = OBJ_BAD, \ | |
| 352 | + | .remote_allowed_atoms = STRING_LIST_INIT_NODUP, \ | |
| 353 | + | } | |
| 311 | 354 | ||
| 312 | 355 | static int is_atom(const char *atom, const char *s, int slen) | |
| 313 | 356 | { | |
| @@ -318,24 +361,36 @@ static int is_atom(const char *atom, const char *s, int slen) | |||
| 318 | 361 | static int expand_atom(struct strbuf *sb, const char *atom, int len, | |
| 319 | 362 | struct expand_data *data) | |
| 320 | 363 | { | |
| 364 | + | if (data->is_remote) { | |
| 365 | + | size_t i; | |
| 366 | + | for (i = 0; i < data->remote_allowed_atoms.nr; i++) | |
| 367 | + | if (is_atom(data->remote_allowed_atoms.items[i].string, | |
| 368 | + | atom, len)) | |
| 369 | + | break; | |
| 370 | + | if (i == data->remote_allowed_atoms.nr) | |
| 371 | + | return 1; | |
| 372 | + | } | |
| 373 | + | ||
| 321 | 374 | if (is_atom("objectname", atom, len)) { | |
| 322 | 375 | if (!data->mark_query) | |
| 323 | - | strbuf_addstr(sb, oid_to_hex(&data->oid)); | |
| 376 | + | strbuf_add_oid_hex(sb, &data->oid); | |
| 324 | 377 | } else if (is_atom("objecttype", atom, len)) { | |
| 325 | - | if (data->mark_query) | |
| 378 | + | if (data->mark_query) { | |
| 326 | 379 | data->info.typep = &data->type; | |
| 327 | - | else | |
| 328 | - | strbuf_addstr(sb, type_name(data->type)); | |
| 380 | + | } else { | |
| 381 | + | const char *t = type_name(data->type); | |
| 382 | + | strbuf_addstr(sb, t ? t : ""); | |
| 383 | + | } | |
| 329 | 384 | } else if (is_atom("objectsize", atom, len)) { | |
| 330 | 385 | if (data->mark_query) | |
| 331 | 386 | data->info.sizep = &data->size; | |
| 332 | 387 | else | |
| 333 | - | strbuf_addf(sb, "%"PRIuMAX , (uintmax_t)data->size); | |
| 388 | + | strbuf_add_uint(sb, data->size); | |
| 334 | 389 | } else if (is_atom("objectsize:disk", atom, len)) { | |
| 335 | 390 | if (data->mark_query) | |
| 336 | 391 | data->info.disk_sizep = &data->disk_size; | |
| 337 | 392 | else | |
| 338 | - | strbuf_addf(sb, "%"PRIuMAX, (uintmax_t)data->disk_size); | |
| 393 | + | strbuf_add_uint(sb, data->disk_size); | |
| 339 | 394 | } else if (is_atom("rest", atom, len)) { | |
| 340 | 395 | if (data->mark_query) | |
| 341 | 396 | data->split_on_whitespace = 1; | |
| @@ -345,8 +400,7 @@ static int expand_atom(struct strbuf *sb, const char *atom, int len, | |||
| 345 | 400 | if (data->mark_query) | |
| 346 | 401 | data->info.delta_base_oid = &data->delta_base_oid; | |
| 347 | 402 | else | |
| 348 | - | strbuf_addstr(sb, | |
| 349 | - | oid_to_hex(&data->delta_base_oid)); | |
| 403 | + | strbuf_add_oid_hex(sb, &data->delta_base_oid); | |
| 350 | 404 | } else if (is_atom("objectmode", atom, len)) { | |
| 351 | 405 | if (!data->mark_query && !(S_IFINVALID == data->mode)) | |
| 352 | 406 | strbuf_addf(sb, "%06o", data->mode); | |
| @@ -391,7 +445,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d | |||
| 391 | 445 | fflush(stdout); | |
| 392 | 446 | if (opt->transform_mode) { | |
| 393 | 447 | char *contents; | |
| 394 | - | unsigned long size; | |
| 448 | + | size_t size; | |
| 395 | 449 | ||
| 396 | 450 | if (!data->rest) | |
| 397 | 451 | die("missing path for '%s'", oid_to_hex(oid)); | |
| @@ -403,9 +457,12 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d | |||
| 403 | 457 | oid_to_hex(oid), data->rest); | |
| 404 | 458 | } else if (opt->transform_mode == 'c') { | |
| 405 | 459 | enum object_type type; | |
| 406 | - | if (!textconv_object(the_repository, | |
| 407 | - | data->rest, 0100644, oid, | |
| 408 | - | 1, &contents, &size)) | |
| 460 | + | unsigned long size_ul = 0; | |
| 461 | + | if (textconv_object(the_repository, | |
| 462 | + | data->rest, 0100644, oid, | |
| 463 | + | 1, &contents, &size_ul)) | |
| 464 | + | size = size_ul; | |
| 465 | + | else | |
| 409 | 466 | contents = odb_read_object(the_repository->objects, | |
| 410 | 467 | oid, &type, &size); | |
| 411 | 468 | if (!contents) | |
| @@ -421,7 +478,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d | |||
| 421 | 478 | } | |
| 422 | 479 | else { | |
| 423 | 480 | enum object_type type; | |
| 424 | - | unsigned long size; | |
| 481 | + | size_t size; | |
| 425 | 482 | void *contents; | |
| 426 | 483 | ||
| 427 | 484 | contents = odb_read_object(the_repository->objects, oid, | |
| @@ -429,11 +486,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d | |||
| 429 | 486 | if (!contents) | |
| 430 | 487 | die("object %s disappeared", oid_to_hex(oid)); | |
| 431 | 488 | ||
| 432 | - | if (use_mailmap) { | |
| 433 | - | size_t s = size; | |
| 434 | - | contents = replace_idents_using_mailmap(contents, &s); | |
| 435 | - | size = cast_size_t_to_ulong(s); | |
| 436 | - | } | |
| 489 | + | if (use_mailmap) | |
| 490 | + | contents = replace_idents_using_mailmap(contents, &size); | |
| 437 | 491 | ||
| 438 | 492 | if (type != data->type) | |
| 439 | 493 | die("object %s changed type!?", oid_to_hex(oid)); | |
| @@ -448,9 +502,12 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d | |||
| 448 | 502 | static void print_default_format(struct strbuf *scratch, struct expand_data *data, | |
| 449 | 503 | struct batch_options *opt) | |
| 450 | 504 | { | |
| 451 | - | strbuf_addf(scratch, "%s %s %"PRIuMAX"%c", oid_to_hex(&data->oid), | |
| 452 | - | type_name(data->type), | |
| 453 | - | (uintmax_t)data->size, opt->output_delim); | |
| 505 | + | strbuf_add_oid_hex(scratch, &data->oid); | |
| 506 | + | strbuf_addch(scratch, ' '); | |
| 507 | + | strbuf_addstr(scratch, type_name(data->type)); | |
| 508 | + | strbuf_addch(scratch, ' '); | |
| 509 | + | strbuf_add_uint(scratch, data->size); | |
| 510 | + | strbuf_addch(scratch, opt->output_delim); | |
| 454 | 511 | } | |
| 455 | 512 | ||
| 456 | 513 | static void report_object_status(struct batch_options *opt, | |
| @@ -487,7 +544,7 @@ static void batch_object_write(const char *obj_name, | |||
| 487 | 544 | data->info.sizep = &data->size; | |
| 488 | 545 | ||
| 489 | 546 | if (pack) | |
| 490 | - | ret = packed_object_info(pack, offset, &data->info); | |
| 547 | + | ret = packed_object_info(NULL, pack, offset, &data->info); | |
| 491 | 548 | else | |
| 492 | 549 | ret = odb_read_object_info_extended(the_repository->objects, | |
| 493 | 550 | &data->oid, &data->info, | |
| @@ -533,15 +590,13 @@ static void batch_object_write(const char *obj_name, | |||
| 533 | 590 | } | |
| 534 | 591 | ||
| 535 | 592 | if (use_mailmap && (data->type == OBJ_COMMIT || data->type == OBJ_TAG)) { | |
| 536 | - | size_t s = data->size; | |
| 537 | 593 | char *buf = NULL; | |
| 538 | 594 | ||
| 539 | 595 | buf = odb_read_object(the_repository->objects, &data->oid, | |
| 540 | 596 | &data->type, &data->size); | |
| 541 | 597 | if (!buf) | |
| 542 | 598 | die(_("unable to read %s"), oid_to_hex(&data->oid)); | |
| 543 | - | buf = replace_idents_using_mailmap(buf, &s); | |
| 544 | - | data->size = cast_size_t_to_ulong(s); | |
| 599 | + | buf = replace_idents_using_mailmap(buf, &data->size); | |
| 545 | 600 | ||
| 546 | 601 | free(buf); | |
| 547 | 602 | } | |
| @@ -625,6 +680,57 @@ out: | |||
| 625 | 680 | object_context_release(&ctx); | |
| 626 | 681 | } | |
| 627 | 682 | ||
| 683 | + | static int get_remote_info(int argc, | |
| 684 | + | const char **argv, | |
| 685 | + | struct fetch_object_info_results *results, | |
| 686 | + | struct oid_array *object_info_oids) | |
| 687 | + | { | |
| 688 | + | int retval = 0; | |
| 689 | + | struct remote *remote = NULL; | |
| 690 | + | struct object_id oid; | |
| 691 | + | struct transport *gtransport; | |
| 692 | + | ||
| 693 | + | remote = remote_get(argv[0]); | |
| 694 | + | if (!remote) | |
| 695 | + | die(_("must supply valid remote when using remote-object-info")); | |
| 696 | + | ||
| 697 | + | oid_array_clear(object_info_oids); | |
| 698 | + | for (size_t i = 1; i < argc; i++) { | |
| 699 | + | if (get_oid_hex(argv[i], &oid)) { | |
| 700 | + | size_t len = strlen(argv[i]); | |
| 701 | + | ||
| 702 | + | if (len < the_hash_algo->hexsz && len >= 4) { | |
| 703 | + | size_t j; | |
| 704 | + | for (j = 0; j < len; j++) | |
| 705 | + | if (!isxdigit(argv[i][j])) | |
| 706 | + | break; | |
| 707 | + | if (j == len) | |
| 708 | + | die(_("remote-object-info does not support " | |
| 709 | + | "short oids, %d characters required"), | |
| 710 | + | (int)the_hash_algo->hexsz); | |
| 711 | + | } | |
| 712 | + | die(_("not a valid object name '%s'"), argv[i]); | |
| 713 | + | } | |
| 714 | + | oid_array_append(object_info_oids, &oid); | |
| 715 | + | } | |
| 716 | + | ||
| 717 | + | if (!object_info_oids->nr) | |
| 718 | + | die(_("remote-object-info requires objects")); | |
| 719 | + | ||
| 720 | + | gtransport = transport_get(remote, NULL); | |
| 721 | + | ||
| 722 | + | if (!gtransport->smart_options) { | |
| 723 | + | retval = -1; | |
| 724 | + | goto cleanup; | |
| 725 | + | } | |
| 726 | + | ||
| 727 | + | retval = transport_fetch_object_info(gtransport, object_info_oids, | |
| 728 | + | results); | |
| 729 | + | cleanup: | |
| 730 | + | transport_disconnect(gtransport); | |
| 731 | + | return retval; | |
| 732 | + | } | |
| 733 | + | ||
| 628 | 734 | struct object_cb_data { | |
| 629 | 735 | struct batch_options *opt; | |
| 630 | 736 | struct expand_data *expand; | |
| @@ -679,8 +785,11 @@ static void parse_cmd_contents(struct batch_options *opt, | |||
| 679 | 785 | struct strbuf *output, | |
| 680 | 786 | struct expand_data *data) | |
| 681 | 787 | { | |
| 788 | + | enum object_type *saved_typep = data->info.typep; | |
| 789 | + | data->info.typep = &data->type; | |
| 682 | 790 | opt->batch_mode = BATCH_MODE_CONTENTS; | |
| 683 | 791 | batch_one_object(line, output, opt, data); | |
| 792 | + | data->info.typep = saved_typep; | |
| 684 | 793 | } | |
| 685 | 794 | ||
| 686 | 795 | static void parse_cmd_info(struct batch_options *opt, | |
| @@ -692,18 +801,100 @@ static void parse_cmd_info(struct batch_options *opt, | |||
| 692 | 801 | batch_one_object(line, output, opt, data); | |
| 693 | 802 | } | |
| 694 | 803 | ||
| 804 | + | static void parse_cmd_mailmap(struct batch_options *opt UNUSED, | |
| 805 | + | const char *line, | |
| 806 | + | struct strbuf *output UNUSED, | |
| 807 | + | struct expand_data *data UNUSED) | |
| 808 | + | { | |
| 809 | + | use_mailmap = git_parse_maybe_bool(line); | |
| 810 | + | ||
| 811 | + | if (use_mailmap < 0) | |
| 812 | + | die(_("mailmap: invalid boolean '%s'"), line); | |
| 813 | + | ||
| 814 | + | if (use_mailmap) | |
| 815 | + | load_mailmap(); | |
| 816 | + | } | |
| 817 | + | ||
| 818 | + | static void parse_cmd_remote_object_info(struct batch_options *opt, | |
| 819 | + | const char *line, struct strbuf *output, | |
| 820 | + | struct expand_data *data) | |
| 821 | + | { | |
| 822 | + | int count; | |
| 823 | + | const char **argv; | |
| 824 | + | char *line_to_split; | |
| 825 | + | struct fetch_object_info_results results = FETCH_OBJECT_INFO_RESULTS_INIT; | |
| 826 | + | struct oid_array object_info_oids = OID_ARRAY_INIT; | |
| 827 | + | ||
| 828 | + | if (strlen(line) >= MAX_REMOTE_OBJ_INFO_LINE) | |
| 829 | + | die(_("remote-object-info command too long")); | |
| 830 | + | ||
| 831 | + | line_to_split = xstrdup(line); | |
| 832 | + | count = split_cmdline(line_to_split, &argv); | |
| 833 | + | if (count < 0) | |
| 834 | + | die(_("remote-object-info: failed to parse command line: %s"), | |
| 835 | + | split_cmdline_strerror(count)); | |
| 836 | + | if (count - 1 > MAX_ALLOWED_OBJ_LIMIT) | |
| 837 | + | die(_("remote-object-info supports at most %d objects"), | |
| 838 | + | MAX_ALLOWED_OBJ_LIMIT); | |
| 839 | + | ||
| 840 | + | if (data->info.sizep) | |
| 841 | + | results.wants_size = 1; | |
| 842 | + | if (data->info.typep) | |
| 843 | + | results.wants_type = 1; | |
| 844 | + | ||
| 845 | + | if (get_remote_info(count, argv, &results, &object_info_oids)) | |
| 846 | + | die(_("failed to get object info from the remote: %s"), argv[0]); | |
| 847 | + | ||
| 848 | + | string_list_clear(&data->remote_allowed_atoms, 0); | |
| 849 | + | string_list_append(&data->remote_allowed_atoms, "objectname"); | |
| 850 | + | if (results.sizes) | |
| 851 | + | string_list_append(&data->remote_allowed_atoms, "objectsize"); | |
| 852 | + | if (results.types) | |
| 853 | + | string_list_append(&data->remote_allowed_atoms, "objecttype"); | |
| 854 | + | ||
| 855 | + | data->skip_object_info = 1; | |
| 856 | + | for (size_t i = 0; i < results.nr; i++) { | |
| 857 | + | data->oid = object_info_oids.oid[i]; | |
| 858 | + | ||
| 859 | + | if (results.unrecognized[i]) { | |
| 860 | + | report_object_status(opt, oid_to_hex(&data->oid), | |
| 861 | + | &data->oid, "missing"); | |
| 862 | + | continue; | |
| 863 | + | } | |
| 864 | + | ||
| 865 | + | /* | |
| 866 | + | * When reaching here, it means remote-object-info can retrieve | |
| 867 | + | * information from server without downloading them. | |
| 868 | + | */ | |
| 869 | + | if (results.sizes) | |
| 870 | + | data->size = results.sizes[i]; | |
| 871 | + | ||
| 872 | + | if (results.types) | |
| 873 | + | data->type = results.types[i]; | |
| 874 | + | ||
| 875 | + | opt->batch_mode = BATCH_MODE_INFO; | |
| 876 | + | data->is_remote = 1; | |
| 877 | + | batch_object_write(argv[i + 1], output, opt, data, NULL, 0); | |
| 878 | + | data->is_remote = 0; | |
| 879 | + | } | |
| 880 | + | data->skip_object_info = 0; | |
| 881 | + | ||
| 882 | + | free_fetch_object_info_results(&results); | |
| 883 | + | free(line_to_split); | |
| 884 | + | free(argv); | |
| 885 | + | oid_array_clear(&object_info_oids); | |
| 886 | + | } | |
| 887 | + | ||
| 695 | 888 | static void dispatch_calls(struct batch_options *opt, | |
| 696 | 889 | struct strbuf *output, | |
| 697 | 890 | struct expand_data *data, | |
| 698 | 891 | struct queued_cmd *cmd, | |
| 699 | - | int nr) | |
| 892 | + | size_t nr) | |
| 700 | 893 | { | |
| 701 | - | int i; | |
| 702 | - | ||
| 703 | 894 | if (!opt->buffer_output) | |
| 704 | 895 | die(_("flush is only for --buffer mode")); | |
| 705 | 896 | ||
| 706 | - | for (i = 0; i < nr; i++) | |
| 897 | + | for (size_t i = 0; i < nr; i++) | |
| 707 | 898 | cmd[i].fn(opt, cmd[i].line, output, data); | |
| 708 | 899 | ||
| 709 | 900 | fflush(stdout); | |
| @@ -711,9 +902,7 @@ static void dispatch_calls(struct batch_options *opt, | |||
| 711 | 902 | ||
| 712 | 903 | static void free_cmds(struct queued_cmd *cmd, size_t *nr) | |
| 713 | 904 | { | |
| 714 | - | size_t i; | |
| 715 | - | ||
| 716 | - | for (i = 0; i < *nr; i++) | |
| 905 | + | for (size_t i = 0; i < *nr; i++) | |
| 717 | 906 | FREE_AND_NULL(cmd[i].line); | |
| 718 | 907 | ||
| 719 | 908 | *nr = 0; | |
| @@ -725,9 +914,11 @@ static const struct parse_cmd { | |||
| 725 | 914 | parse_cmd_fn_t fn; | |
| 726 | 915 | unsigned takes_args; | |
| 727 | 916 | } commands[] = { | |
| 728 | - | { "contents", parse_cmd_contents, 1}, | |
| 729 | - | { "info", parse_cmd_info, 1}, | |
| 730 | - | { "flush", NULL, 0}, | |
| 917 | + | { "contents", parse_cmd_contents, 1 }, | |
| 918 | + | { "flush", NULL, 0 }, | |
| 919 | + | { "info", parse_cmd_info, 1 }, | |
| 920 | + | { "mailmap", parse_cmd_mailmap, 1 }, | |
| 921 | + | { "remote-object-info", parse_cmd_remote_object_info, 1 }, | |
| 731 | 922 | }; | |
| 732 | 923 | ||
| 733 | 924 | static void batch_objects_command(struct batch_options *opt, | |
| @@ -739,7 +930,6 @@ static void batch_objects_command(struct batch_options *opt, | |||
| 739 | 930 | size_t alloc = 0, nr = 0; | |
| 740 | 931 | ||
| 741 | 932 | while (strbuf_getdelim_strip_crlf(&input, stdin, opt->input_delim) != EOF) { | |
| 742 | - | int i; | |
| 743 | 933 | const struct parse_cmd *cmd = NULL; | |
| 744 | 934 | const char *p = NULL, *cmd_end; | |
| 745 | 935 | struct queued_cmd call = {0}; | |
| @@ -749,7 +939,7 @@ static void batch_objects_command(struct batch_options *opt, | |||
| 749 | 939 | if (isspace(*input.buf)) | |
| 750 | 940 | die(_("whitespace before command: '%s'"), input.buf); | |
| 751 | 941 | ||
| 752 | - | for (i = 0; i < ARRAY_SIZE(commands); i++) { | |
| 942 | + | for (size_t i = 0; i < ARRAY_SIZE(commands); i++) { | |
| 753 | 943 | if (!skip_prefix(input.buf, commands[i].name, &cmd_end)) | |
| 754 | 944 | continue; | |
| 755 | 945 | ||
| @@ -811,34 +1001,13 @@ static int batch_one_object_oi(const struct object_id *oid, | |||
| 811 | 1001 | void *_payload) | |
| 812 | 1002 | { | |
| 813 | 1003 | struct for_each_object_payload *payload = _payload; | |
| 814 | - | if (oi && oi->whence == OI_PACKED) | |
| 815 | - | return payload->callback(oid, oi->u.packed.pack, oi->u.packed.offset, | |
| 1004 | + | if (oi && oi->source_infop->source->type == ODB_SOURCE_PACKED) | |
| 1005 | + | return payload->callback(oid, oi->source_infop->u.packed.pack, | |
| 1006 | + | oi->source_infop->u.packed.offset, | |
| 816 | 1007 | payload->payload); | |
| 817 | 1008 | return payload->callback(oid, NULL, 0, payload->payload); | |
| 818 | 1009 | } | |
| 819 | 1010 | ||
| 820 | - | static int batch_one_object_packed(const struct object_id *oid, | |
| 821 | - | struct packed_git *pack, | |
| 822 | - | uint32_t pos, | |
| 823 | - | void *_payload) | |
| 824 | - | { | |
| 825 | - | struct for_each_object_payload *payload = _payload; | |
| 826 | - | return payload->callback(oid, pack, nth_packed_object_offset(pack, pos), | |
| 827 | - | payload->payload); | |
| 828 | - | } | |
| 829 | - | ||
| 830 | - | static int batch_one_object_bitmapped(const struct object_id *oid, | |
| 831 | - | enum object_type type UNUSED, | |
| 832 | - | int flags UNUSED, | |
| 833 | - | uint32_t hash UNUSED, | |
| 834 | - | struct packed_git *pack, | |
| 835 | - | off_t offset, | |
| 836 | - | void *_payload) | |
| 837 | - | { | |
| 838 | - | struct for_each_object_payload *payload = _payload; | |
| 839 | - | return payload->callback(oid, pack, offset, payload->payload); | |
| 840 | - | } | |
| 841 | - | ||
| 842 | 1011 | static void batch_each_object(struct batch_options *opt, | |
| 843 | 1012 | for_each_object_fn callback, | |
| 844 | 1013 | unsigned flags, | |
| @@ -848,52 +1017,17 @@ static void batch_each_object(struct batch_options *opt, | |||
| 848 | 1017 | .callback = callback, | |
| 849 | 1018 | .payload = _payload, | |
| 850 | 1019 | }; | |
| 1020 | + | struct odb_source_info source_info; | |
| 1021 | + | struct object_info oi = { | |
| 1022 | + | .source_infop = &source_info, | |
| 1023 | + | }; | |
| 851 | 1024 | struct odb_for_each_object_options opts = { | |
| 852 | 1025 | .flags = flags, | |
| 1026 | + | .filter = &opt->objects_filter, | |
| 853 | 1027 | }; | |
| 854 | - | struct bitmap_index *bitmap = NULL; | |
| 855 | - | struct odb_source *source; | |
| 856 | - | ||
| 857 | - | /* | |
| 858 | - | * TODO: we still need to tap into implementation details of the object | |
| 859 | - | * database sources. Ideally, we should extend `odb_for_each_object()` | |
| 860 | - | * to handle object filters itself so that we can move the filtering | |
| 861 | - | * logic into the individual sources. | |
| 862 | - | */ | |
| 863 | - | odb_prepare_alternates(the_repository->objects); | |
| 864 | - | for (source = the_repository->objects->sources; source; source = source->next) { | |
| 865 | - | int ret = odb_source_loose_for_each_object(source, NULL, batch_one_object_oi, | |
| 866 | - | &payload, &opts); | |
| 867 | - | if (ret) | |
| 868 | - | break; | |
| 869 | - | } | |
| 870 | - | ||
| 871 | - | if (opt->objects_filter.choice != LOFC_DISABLED && | |
| 872 | - | (bitmap = prepare_bitmap_git(the_repository)) && | |
| 873 | - | !for_each_bitmapped_object(bitmap, &opt->objects_filter, | |
| 874 | - | batch_one_object_bitmapped, &payload)) { | |
| 875 | - | struct packed_git *pack; | |
| 876 | - | ||
| 877 | - | repo_for_each_pack(the_repository, pack) { | |
| 878 | - | if (bitmap_index_contains_pack(bitmap, pack) || | |
| 879 | - | open_pack_index(pack)) | |
| 880 | - | continue; | |
| 881 | - | for_each_object_in_pack(pack, batch_one_object_packed, | |
| 882 | - | &payload, flags); | |
| 883 | - | } | |
| 884 | - | } else { | |
| 885 | - | struct object_info oi = { 0 }; | |
| 886 | - | ||
| 887 | - | for (source = the_repository->objects->sources; source; source = source->next) { | |
| 888 | - | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 889 | - | int ret = packfile_store_for_each_object(files->packed, &oi, | |
| 890 | - | batch_one_object_oi, &payload, &opts); | |
| 891 | - | if (ret) | |
| 892 | - | break; | |
| 893 | - | } | |
| 894 | - | } | |
| 895 | 1028 | ||
| 896 | - | free_bitmap_index(bitmap); | |
| 1029 | + | odb_for_each_object_ext(the_repository->objects, &oi, | |
| 1030 | + | batch_one_object_oi, &payload, &opts); | |
| 897 | 1031 | } | |
| 898 | 1032 | ||
| 899 | 1033 | static int batch_objects(struct batch_options *opt) | |
| @@ -901,6 +1035,7 @@ static int batch_objects(struct batch_options *opt) | |||
| 901 | 1035 | struct strbuf input = STRBUF_INIT; | |
| 902 | 1036 | struct strbuf output = STRBUF_INIT; | |
| 903 | 1037 | struct expand_data data = EXPAND_DATA_INIT; | |
| 1038 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 904 | 1039 | int save_warning; | |
| 905 | 1040 | int retval = 0; | |
| 906 | 1041 | ||
| @@ -973,8 +1108,8 @@ static int batch_objects(struct batch_options *opt) | |||
| 973 | 1108 | * warn) ends up dwarfing the actual cost of the object lookups | |
| 974 | 1109 | * themselves. We can work around it by just turning off the warning. | |
| 975 | 1110 | */ | |
| 976 | - | save_warning = warn_on_object_refname_ambiguity; | |
| 977 | - | warn_on_object_refname_ambiguity = 0; | |
| 1111 | + | save_warning = cfg->warn_on_object_refname_ambiguity; | |
| 1112 | + | cfg->warn_on_object_refname_ambiguity = 0; | |
| 978 | 1113 | ||
| 979 | 1114 | if (opt->batch_mode == BATCH_MODE_QUEUE_AND_DISPATCH) { | |
| 980 | 1115 | batch_objects_command(opt, &output, &data); | |
| @@ -1002,7 +1137,8 @@ static int batch_objects(struct batch_options *opt) | |||
| 1002 | 1137 | cleanup: | |
| 1003 | 1138 | strbuf_release(&input); | |
| 1004 | 1139 | strbuf_release(&output); | |
| 1005 | - | warn_on_object_refname_ambiguity = save_warning; | |
| 1140 | + | string_list_clear(&data.remote_allowed_atoms, 0); | |
| 1141 | + | cfg->warn_on_object_refname_ambiguity = save_warning; | |
| 1006 | 1142 | return retval; | |
| 1007 | 1143 | } | |
| 1008 | 1144 | ||
| @@ -1131,7 +1267,7 @@ int cmd_cat_file(int argc, | |||
| 1131 | 1267 | opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's'); | |
| 1132 | 1268 | ||
| 1133 | 1269 | if (use_mailmap) | |
| 1134 | - | read_mailmap(the_repository, &mailmap); | |
| 1270 | + | load_mailmap(); | |
| 1135 | 1271 | ||
| 1136 | 1272 | switch (batch.objects_filter.choice) { | |
| 1137 | 1273 | case LOFC_DISABLED: | |
modified builtin/check-attr.c
| @@ -67,7 +67,7 @@ static void check_attr(const char *prefix, struct attr_check *check, | |||
| 67 | 67 | ||
| 68 | 68 | { | |
| 69 | 69 | char *full_path = | |
| 70 | - | prefix_path(prefix, prefix ? strlen(prefix) : 0, file); | |
| 70 | + | prefix_path(the_repository, prefix, prefix ? strlen(prefix) : 0, file); | |
| 71 | 71 | ||
| 72 | 72 | if (collect_all) { | |
| 73 | 73 | git_all_attrs(the_repository->index, full_path, check); | |
| @@ -116,8 +116,8 @@ int cmd_check_attr(int argc, | |||
| 116 | 116 | struct object_id initialized_oid; | |
| 117 | 117 | int cnt, i, doubledash, filei; | |
| 118 | 118 | ||
| 119 | - | if (!is_bare_repository()) | |
| 120 | - | setup_work_tree(); | |
| 119 | + | if (!is_bare_repository(the_repository)) | |
| 120 | + | setup_work_tree(the_repository); | |
| 121 | 121 | ||
| 122 | 122 | repo_config(the_repository, git_default_config, NULL); | |
| 123 | 123 | ||
modified builtin/check-ref-format.c
| @@ -1,6 +1,9 @@ | |||
| 1 | 1 | /* | |
| 2 | 2 | * GIT - The information manager from hell | |
| 3 | 3 | */ | |
| 4 | + | ||
| 5 | + | #define USE_THE_REPOSITORY_VARIABLE | |
| 6 | + | ||
| 4 | 7 | #include "builtin.h" | |
| 5 | 8 | #include "refs.h" | |
| 6 | 9 | #include "setup.h" | |
| @@ -41,8 +44,8 @@ static int check_ref_format_branch(const char *arg) | |||
| 41 | 44 | const char *name; | |
| 42 | 45 | int nongit; | |
| 43 | 46 | ||
| 44 | - | setup_git_directory_gently(&nongit); | |
| 45 | - | if (check_branch_ref(&sb, arg) || | |
| 47 | + | setup_git_directory_gently(the_repository, &nongit); | |
| 48 | + | if (check_branch_ref(the_repository, &sb, arg) || | |
| 46 | 49 | !skip_prefix(sb.buf, "refs/heads/", &name)) | |
| 47 | 50 | die("'%s' is not a valid branch name", arg); | |
| 48 | 51 | printf("%s\n", name); | |
modified builtin/checkout-index.c
| @@ -303,7 +303,7 @@ int cmd_checkout_index(int argc, | |||
| 303 | 303 | die("git checkout-index: don't mix '--all' and explicit filenames"); | |
| 304 | 304 | if (read_from_stdin) | |
| 305 | 305 | die("git checkout-index: don't mix '--stdin' and explicit filenames"); | |
| 306 | - | p = prefix_path(prefix, prefix_length, arg); | |
| 306 | + | p = prefix_path(repo, prefix, prefix_length, arg); | |
| 307 | 307 | err |= checkout_file(repo->index, p, prefix); | |
| 308 | 308 | free(p); | |
| 309 | 309 | } | |
| @@ -325,7 +325,7 @@ int cmd_checkout_index(int argc, | |||
| 325 | 325 | die("line is badly quoted"); | |
| 326 | 326 | strbuf_swap(&buf, &unquoted); | |
| 327 | 327 | } | |
| 328 | - | p = prefix_path(prefix, prefix_length, buf.buf); | |
| 328 | + | p = prefix_path(repo, prefix, prefix_length, buf.buf); | |
| 329 | 329 | err |= checkout_file(repo->index, p, prefix); | |
| 330 | 330 | free(p); | |
| 331 | 331 | } | |
modified builtin/checkout.c
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | #include "merge-ll.h" | |
| 18 | 18 | #include "lockfile.h" | |
| 19 | 19 | #include "mem-pool.h" | |
| 20 | - | #include "merge-ort-wrappers.h" | |
| 21 | 20 | #include "object-file.h" | |
| 22 | 21 | #include "object-name.h" | |
| 23 | 22 | #include "odb.h" | |
| @@ -30,7 +29,10 @@ | |||
| 30 | 29 | #include "repo-settings.h" | |
| 31 | 30 | #include "resolve-undo.h" | |
| 32 | 31 | #include "revision.h" | |
| 32 | + | #include "sequencer.h" | |
| 33 | 33 | #include "setup.h" | |
| 34 | + | #include "sparse-index.h" | |
| 35 | + | #include "strvec.h" | |
| 34 | 36 | #include "submodule.h" | |
| 35 | 37 | #include "symlinks.h" | |
| 36 | 38 | #include "trace2.h" | |
| @@ -99,6 +101,8 @@ struct checkout_opts { | |||
| 99 | 101 | .auto_advance = 1, \ | |
| 100 | 102 | } | |
| 101 | 103 | ||
| 104 | + | #define MERGE_WORKING_TREE_UNPACK_FAILED (-2) | |
| 105 | + | ||
| 102 | 106 | struct branch_info { | |
| 103 | 107 | char *name; /* The short name used */ | |
| 104 | 108 | char *path; /* The full name of a real branch */ | |
| @@ -123,24 +127,80 @@ static void branch_info_release(struct branch_info *info) | |||
| 123 | 127 | static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit, | |
| 124 | 128 | int changed) | |
| 125 | 129 | { | |
| 126 | - | return run_hooks_l(the_repository, "post-checkout", | |
| 127 | - | oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)), | |
| 128 | - | oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)), | |
| 129 | - | changed ? "1" : "0", NULL); | |
| 130 | - | /* "new_commit" can be NULL when checking out from the index before | |
| 131 | - | a commit exists. */ | |
| 130 | + | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; | |
| 131 | + | ||
| 132 | + | /* | |
| 133 | + | * "new_commit" can be NULL when checking out from the index before | |
| 134 | + | * a commit exists. | |
| 135 | + | */ | |
| 136 | + | strvec_pushl(&opt.args, | |
| 137 | + | oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)), | |
| 138 | + | oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)), | |
| 139 | + | changed ? "1" : "0", | |
| 140 | + | NULL); | |
| 141 | + | ||
| 142 | + | return run_hooks_opt(the_repository, "post-checkout", &opt); | |
| 143 | + | } | |
| 144 | + | ||
| 145 | + | /* | |
| 146 | + | * Handle a tree object and determine if we need to recurse into the | |
| 147 | + | * tree (READ_TREE_RECURSIVE) or skip it (0). | |
| 148 | + | */ | |
| 149 | + | static int try_update_sparse_directory(const struct object_id *oid, | |
| 150 | + | struct strbuf *base, | |
| 151 | + | const char *pathname, | |
| 152 | + | int overlay_mode) | |
| 153 | + | { | |
| 154 | + | struct strbuf dirpath = STRBUF_INIT; | |
| 155 | + | struct cache_entry *old; | |
| 156 | + | int pos, result = READ_TREE_RECURSIVE; | |
| 157 | + | ||
| 158 | + | if (!the_repository->index->sparse_index) | |
| 159 | + | return result; | |
| 160 | + | ||
| 161 | + | strbuf_addbuf(&dirpath, base); | |
| 162 | + | strbuf_addstr(&dirpath, pathname); | |
| 163 | + | strbuf_addch(&dirpath, '/'); | |
| 164 | + | ||
| 165 | + | pos = index_name_pos_sparse(the_repository->index, | |
| 166 | + | dirpath.buf, dirpath.len); | |
| 167 | + | if (pos < 0) | |
| 168 | + | goto cleanup; | |
| 169 | + | ||
| 170 | + | old = the_repository->index->cache[pos]; | |
| 171 | + | if (!S_ISSPARSEDIR(old->ce_mode)) | |
| 172 | + | goto cleanup; | |
| 173 | + | ||
| 174 | + | if (oideq(oid, &old->oid)) { | |
| 175 | + | /* Tree content already matches; no need to descend. */ | |
| 176 | + | result = 0; | |
| 177 | + | } else if (!overlay_mode) { | |
| 178 | + | /* | |
| 179 | + | * In non-overlay mode (e.g., restore --staged), replace the | |
| 180 | + | * sparse directory OID directly since files not present in | |
| 181 | + | * the source tree should be removed anyway. | |
| 182 | + | */ | |
| 183 | + | oidcpy(&old->oid, oid); | |
| 184 | + | old->ce_flags |= CE_UPDATE; | |
| 185 | + | result = 0; | |
| 186 | + | } | |
| 132 | 187 | ||
| 188 | + | cleanup: | |
| 189 | + | strbuf_release(&dirpath); | |
| 190 | + | return result; | |
| 133 | 191 | } | |
| 134 | 192 | ||
| 135 | 193 | static int update_some(const struct object_id *oid, struct strbuf *base, | |
| 136 | - | const char *pathname, unsigned mode, void *context UNUSED) | |
| 194 | + | const char *pathname, unsigned mode, void *context) | |
| 137 | 195 | { | |
| 138 | 196 | int len; | |
| 139 | 197 | struct cache_entry *ce; | |
| 140 | 198 | int pos; | |
| 199 | + | int overlay_mode = context ? *((int *)context) : 1; | |
| 141 | 200 | ||
| 142 | 201 | if (S_ISDIR(mode)) | |
| 143 | - | return READ_TREE_RECURSIVE; | |
| 202 | + | return try_update_sparse_directory(oid, base, pathname, | |
| 203 | + | overlay_mode); | |
| 144 | 204 | ||
| 145 | 205 | len = base->len + strlen(pathname); | |
| 146 | 206 | ce = make_empty_cache_entry(the_repository->index, len); | |
| @@ -156,7 +216,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base, | |||
| 156 | 216 | * entry in place. Whether it is UPTODATE or not, checkout_entry will | |
| 157 | 217 | * do the right thing. | |
| 158 | 218 | */ | |
| 159 | - | pos = index_name_pos(the_repository->index, ce->name, ce->ce_namelen); | |
| 219 | + | pos = index_name_pos_sparse(the_repository->index, ce->name, ce->ce_namelen); | |
| 160 | 220 | if (pos >= 0) { | |
| 161 | 221 | struct cache_entry *old = the_repository->index->cache[pos]; | |
| 162 | 222 | if (ce->ce_mode == old->ce_mode && | |
| @@ -173,10 +233,11 @@ static int update_some(const struct object_id *oid, struct strbuf *base, | |||
| 173 | 233 | return 0; | |
| 174 | 234 | } | |
| 175 | 235 | ||
| 176 | - | static int read_tree_some(struct tree *tree, const struct pathspec *pathspec) | |
| 236 | + | static int read_tree_some(struct tree *tree, const struct pathspec *pathspec, | |
| 237 | + | int overlay_mode) | |
| 177 | 238 | { | |
| 178 | 239 | read_tree(the_repository, tree, | |
| 179 | - | pathspec, update_some, NULL); | |
| 240 | + | pathspec, update_some, &overlay_mode); | |
| 180 | 241 | ||
| 181 | 242 | /* update the index with the given tree's info | |
| 182 | 243 | * for all args, expanding wildcards, and exit | |
| @@ -571,7 +632,8 @@ static int checkout_paths(const struct checkout_opts *opts, | |||
| 571 | 632 | return error(_("index file corrupt")); | |
| 572 | 633 | ||
| 573 | 634 | if (opts->source_tree) | |
| 574 | - | read_tree_some(opts->source_tree, &opts->pathspec); | |
| 635 | + | read_tree_some(opts->source_tree, &opts->pathspec, | |
| 636 | + | opts->overlay_mode); | |
| 575 | 637 | if (opts->merge) | |
| 576 | 638 | unmerge_index(the_repository->index, &opts->pathspec, CE_MATCHED); | |
| 577 | 639 | ||
| @@ -743,7 +805,7 @@ static void setup_branch_path(struct branch_info *branch) | |||
| 743 | 805 | &branch->oid, &branch->refname, 0)) | |
| 744 | 806 | repo_get_oid_committish(the_repository, branch->name, &branch->oid); | |
| 745 | 807 | ||
| 746 | - | copy_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL); | |
| 808 | + | copy_branchname(the_repository, &buf, branch->name, INTERPRET_BRANCH_LOCAL); | |
| 747 | 809 | if (strcmp(buf.buf, branch->name)) { | |
| 748 | 810 | free(branch->name); | |
| 749 | 811 | branch->name = xstrdup(buf.buf); | |
| @@ -753,9 +815,9 @@ static void setup_branch_path(struct branch_info *branch) | |||
| 753 | 815 | branch->path = strbuf_detach(&buf, NULL); | |
| 754 | 816 | } | |
| 755 | 817 | ||
| 756 | - | static void init_topts(struct unpack_trees_options *topts, int merge, | |
| 818 | + | static void init_topts(struct unpack_trees_options *topts, | |
| 757 | 819 | int show_progress, int overwrite_ignore, | |
| 758 | - | struct commit *old_commit) | |
| 820 | + | bool quiet) | |
| 759 | 821 | { | |
| 760 | 822 | memset(topts, 0, sizeof(*topts)); | |
| 761 | 823 | topts->head_idx = -1; | |
| @@ -767,7 +829,7 @@ static void init_topts(struct unpack_trees_options *topts, int merge, | |||
| 767 | 829 | topts->initial_checkout = is_index_unborn(the_repository->index); | |
| 768 | 830 | topts->update = 1; | |
| 769 | 831 | topts->merge = 1; | |
| 770 | - | topts->quiet = merge && old_commit; | |
| 832 | + | topts->quiet = quiet; | |
| 771 | 833 | topts->verbose_update = show_progress; | |
| 772 | 834 | topts->fn = twoway_merge; | |
| 773 | 835 | topts->preserve_ignored = !overwrite_ignore; | |
| @@ -776,6 +838,7 @@ static void init_topts(struct unpack_trees_options *topts, int merge, | |||
| 776 | 838 | static int merge_working_tree(const struct checkout_opts *opts, | |
| 777 | 839 | struct branch_info *old_branch_info, | |
| 778 | 840 | struct branch_info *new_branch_info, | |
| 841 | + | bool quiet, | |
| 779 | 842 | int *writeout_error) | |
| 780 | 843 | { | |
| 781 | 844 | int ret; | |
| @@ -783,8 +846,10 @@ static int merge_working_tree(const struct checkout_opts *opts, | |||
| 783 | 846 | struct tree *new_tree; | |
| 784 | 847 | ||
| 785 | 848 | repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR); | |
| 786 | - | if (repo_read_index_preload(the_repository, NULL, 0) < 0) | |
| 849 | + | if (repo_read_index_preload(the_repository, NULL, 0) < 0) { | |
| 850 | + | rollback_lock_file(&lock_file); | |
| 787 | 851 | return error(_("index file corrupt")); | |
| 852 | + | } | |
| 788 | 853 | ||
| 789 | 854 | resolve_undo_clear_index(the_repository->index); | |
| 790 | 855 | if (opts->new_orphan_branch && opts->orphan_from_empty_tree) { | |
| @@ -797,14 +862,18 @@ static int merge_working_tree(const struct checkout_opts *opts, | |||
| 797 | 862 | } else { | |
| 798 | 863 | new_tree = repo_get_commit_tree(the_repository, | |
| 799 | 864 | new_branch_info->commit); | |
| 800 | - | if (!new_tree) | |
| 865 | + | if (!new_tree) { | |
| 866 | + | rollback_lock_file(&lock_file); | |
| 801 | 867 | return error(_("unable to read tree (%s)"), | |
| 802 | 868 | oid_to_hex(&new_branch_info->commit->object.oid)); | |
| 869 | + | } | |
| 803 | 870 | } | |
| 804 | 871 | if (opts->discard_changes) { | |
| 805 | 872 | ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info); | |
| 806 | - | if (ret) | |
| 873 | + | if (ret) { | |
| 874 | + | rollback_lock_file(&lock_file); | |
| 807 | 875 | return ret; | |
| 876 | + | } | |
| 808 | 877 | } else { | |
| 809 | 878 | struct tree_desc trees[2]; | |
| 810 | 879 | struct tree *tree; | |
| @@ -814,13 +883,14 @@ static int merge_working_tree(const struct checkout_opts *opts, | |||
| 814 | 883 | refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL); | |
| 815 | 884 | ||
| 816 | 885 | if (unmerged_index(the_repository->index)) { | |
| 886 | + | rollback_lock_file(&lock_file); | |
| 817 | 887 | error(_("you need to resolve your current index first")); | |
| 818 | 888 | return 1; | |
| 819 | 889 | } | |
| 820 | 890 | ||
| 821 | 891 | /* 2-way merge to the new branch */ | |
| 822 | - | init_topts(&topts, opts->merge, opts->show_progress, | |
| 823 | - | opts->overwrite_ignore, old_branch_info->commit); | |
| 892 | + | init_topts(&topts, opts->show_progress, | |
| 893 | + | opts->overwrite_ignore, quiet); | |
| 824 | 894 | init_checkout_metadata(&topts.meta, new_branch_info->refname, | |
| 825 | 895 | new_branch_info->commit ? | |
| 826 | 896 | &new_branch_info->commit->object.oid : | |
| @@ -846,86 +916,12 @@ static int merge_working_tree(const struct checkout_opts *opts, | |||
| 846 | 916 | ret = unpack_trees(2, trees, &topts); | |
| 847 | 917 | clear_unpack_trees_porcelain(&topts); | |
| 848 | 918 | if (ret == -1) { | |
| 849 | - | /* | |
| 850 | - | * Unpack couldn't do a trivial merge; either | |
| 851 | - | * give up or do a real merge, depending on | |
| 852 | - | * whether the merge flag was used. | |
| 853 | - | */ | |
| 854 | - | struct tree *work; | |
| 855 | - | struct tree *old_tree; | |
| 856 | - | struct merge_options o; | |
| 857 | - | struct strbuf sb = STRBUF_INIT; | |
| 858 | - | struct strbuf old_commit_shortname = STRBUF_INIT; | |
| 859 | - | ||
| 860 | - | if (!opts->merge) | |
| 861 | - | return 1; | |
| 862 | - | ||
| 863 | - | /* | |
| 864 | - | * Without old_branch_info->commit, the below is the same as | |
| 865 | - | * the two-tree unpack we already tried and failed. | |
| 866 | - | */ | |
| 867 | - | if (!old_branch_info->commit) | |
| 868 | - | return 1; | |
| 869 | - | old_tree = repo_get_commit_tree(the_repository, | |
| 870 | - | old_branch_info->commit); | |
| 871 | - | ||
| 872 | - | if (repo_index_has_changes(the_repository, old_tree, &sb)) | |
| 873 | - | die(_("cannot continue with staged changes in " | |
| 874 | - | "the following files:\n%s"), sb.buf); | |
| 875 | - | strbuf_release(&sb); | |
| 876 | - | ||
| 877 | - | /* Do more real merge */ | |
| 878 | - | ||
| 879 | - | /* | |
| 880 | - | * We update the index fully, then write the | |
| 881 | - | * tree from the index, then merge the new | |
| 882 | - | * branch with the current tree, with the old | |
| 883 | - | * branch as the base. Then we reset the index | |
| 884 | - | * (but not the working tree) to the new | |
| 885 | - | * branch, leaving the working tree as the | |
| 886 | - | * merged version, but skipping unmerged | |
| 887 | - | * entries in the index. | |
| 888 | - | */ | |
| 889 | - | ||
| 890 | - | add_files_to_cache(the_repository, NULL, NULL, NULL, 0, | |
| 891 | - | 0, 0); | |
| 892 | - | init_ui_merge_options(&o, the_repository); | |
| 893 | - | o.verbosity = 0; | |
| 894 | - | work = write_in_core_index_as_tree(the_repository, | |
| 895 | - | the_repository->index); | |
| 896 | - | ||
| 897 | - | ret = reset_tree(new_tree, | |
| 898 | - | opts, 1, | |
| 899 | - | writeout_error, new_branch_info); | |
| 900 | - | if (ret) | |
| 901 | - | return ret; | |
| 902 | - | o.ancestor = old_branch_info->name; | |
| 903 | - | if (!old_branch_info->name) { | |
| 904 | - | strbuf_add_unique_abbrev(&old_commit_shortname, | |
| 905 | - | &old_branch_info->commit->object.oid, | |
| 906 | - | DEFAULT_ABBREV); | |
| 907 | - | o.ancestor = old_commit_shortname.buf; | |
| 908 | - | } | |
| 909 | - | o.branch1 = new_branch_info->name; | |
| 910 | - | o.branch2 = "local"; | |
| 911 | - | o.conflict_style = opts->conflict_style; | |
| 912 | - | ret = merge_ort_nonrecursive(&o, | |
| 913 | - | new_tree, | |
| 914 | - | work, | |
| 915 | - | old_tree); | |
| 916 | - | if (ret < 0) | |
| 917 | - | die(NULL); | |
| 918 | - | ret = reset_tree(new_tree, | |
| 919 | - | opts, 0, | |
| 920 | - | writeout_error, new_branch_info); | |
| 921 | - | strbuf_release(&o.obuf); | |
| 922 | - | strbuf_release(&old_commit_shortname); | |
| 923 | - | if (ret) | |
| 924 | - | return ret; | |
| 919 | + | rollback_lock_file(&lock_file); | |
| 920 | + | return MERGE_WORKING_TREE_UNPACK_FAILED; | |
| 925 | 921 | } | |
| 926 | 922 | } | |
| 927 | 923 | ||
| 928 | - | if (!cache_tree_fully_valid(the_repository->index->cache_tree)) | |
| 924 | + | if (!cache_tree_fully_valid(the_repository->index)) | |
| 929 | 925 | cache_tree_update(the_repository->index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR); | |
| 930 | 926 | ||
| 931 | 927 | if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK)) | |
| @@ -956,10 +952,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts, | |||
| 956 | 952 | const char *old_desc, *reflog_msg; | |
| 957 | 953 | if (opts->new_branch) { | |
| 958 | 954 | if (opts->new_orphan_branch) { | |
| 959 | - | enum log_refs_config log_all_ref_updates = | |
| 960 | - | repo_settings_get_log_all_ref_updates(the_repository); | |
| 955 | + | enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET; | |
| 956 | + | const char *value; | |
| 961 | 957 | char *refname; | |
| 962 | 958 | ||
| 959 | + | if (!repo_config_get_string_tmp(the_repository, "core.logallrefupdates", &value)) | |
| 960 | + | log_all_ref_updates = refs_parse_log_all_ref_updates_config(value); | |
| 961 | + | ||
| 963 | 962 | refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch); | |
| 964 | 963 | if (opts->new_branch_log && | |
| 965 | 964 | !should_autocreate_reflog(log_all_ref_updates, refname)) { | |
| @@ -1166,6 +1165,11 @@ static int switch_branches(const struct checkout_opts *opts, | |||
| 1166 | 1165 | struct object_id rev; | |
| 1167 | 1166 | int flag, writeout_error = 0; | |
| 1168 | 1167 | int do_merge = 1; | |
| 1168 | + | int created_autostash = 0; | |
| 1169 | + | enum stash_apply_result autostash_res = STASH_APPLY_CLEAN; | |
| 1170 | + | struct strbuf old_commit_shortname = STRBUF_INIT; | |
| 1171 | + | struct strbuf autostash_msg = STRBUF_INIT; | |
| 1172 | + | const char *stash_label_base = NULL; | |
| 1169 | 1173 | ||
| 1170 | 1174 | trace2_cmd_mode("branch"); | |
| 1171 | 1175 | ||
| @@ -1203,21 +1207,75 @@ static int switch_branches(const struct checkout_opts *opts, | |||
| 1203 | 1207 | do_merge = 0; | |
| 1204 | 1208 | } | |
| 1205 | 1209 | ||
| 1210 | + | if (old_branch_info.name) { | |
| 1211 | + | stash_label_base = old_branch_info.name; | |
| 1212 | + | } else if (old_branch_info.commit) { | |
| 1213 | + | strbuf_add_unique_abbrev(&old_commit_shortname, | |
| 1214 | + | &old_branch_info.commit->object.oid, | |
| 1215 | + | DEFAULT_ABBREV); | |
| 1216 | + | stash_label_base = old_commit_shortname.buf; | |
| 1217 | + | } | |
| 1218 | + | ||
| 1206 | 1219 | if (do_merge) { | |
| 1207 | - | ret = merge_working_tree(opts, &old_branch_info, new_branch_info, &writeout_error); | |
| 1220 | + | ret = merge_working_tree(opts, &old_branch_info, new_branch_info, | |
| 1221 | + | opts->merge, &writeout_error); | |
| 1222 | + | if (ret == MERGE_WORKING_TREE_UNPACK_FAILED && opts->merge) { | |
| 1223 | + | strbuf_addf(&autostash_msg, | |
| 1224 | + | "autostash while switching to '%s'", | |
| 1225 | + | new_branch_info->name); | |
| 1226 | + | create_autostash_ref(the_repository, | |
| 1227 | + | "CHECKOUT_AUTOSTASH_HEAD", | |
| 1228 | + | autostash_msg.buf, true); | |
| 1229 | + | created_autostash = 1; | |
| 1230 | + | ret = merge_working_tree(opts, &old_branch_info, new_branch_info, | |
| 1231 | + | false, &writeout_error); | |
| 1232 | + | } | |
| 1233 | + | if (created_autostash) { | |
| 1234 | + | if (opts->conflict_style >= 0) { | |
| 1235 | + | struct strbuf cfg = STRBUF_INIT; | |
| 1236 | + | strbuf_addf(&cfg, "merge.conflictStyle=%s", | |
| 1237 | + | conflict_style_name(opts->conflict_style)); | |
| 1238 | + | git_config_push_parameter(cfg.buf); | |
| 1239 | + | strbuf_release(&cfg); | |
| 1240 | + | } | |
| 1241 | + | autostash_res = apply_autostash_ref(the_repository, | |
| 1242 | + | "CHECKOUT_AUTOSTASH_HEAD", | |
| 1243 | + | new_branch_info->name, | |
| 1244 | + | "local", | |
| 1245 | + | stash_label_base, | |
| 1246 | + | autostash_msg.buf); | |
| 1247 | + | } | |
| 1208 | 1248 | if (ret) { | |
| 1209 | 1249 | branch_info_release(&old_branch_info); | |
| 1210 | - | return ret; | |
| 1250 | + | strbuf_release(&old_commit_shortname); | |
| 1251 | + | strbuf_release(&autostash_msg); | |
| 1252 | + | return ret < 0 ? 1 : ret; | |
| 1211 | 1253 | } | |
| 1212 | 1254 | } | |
| 1213 | 1255 | ||
| 1214 | 1256 | if (!opts->quiet && !old_branch_info.path && old_branch_info.commit && new_branch_info->commit != old_branch_info.commit) | |
| 1215 | 1257 | orphaned_commit_warning(old_branch_info.commit, new_branch_info->commit); | |
| 1216 | 1258 | ||
| 1259 | + | if (autostash_res == STASH_APPLY_CONFLICT && !opts->quiet) | |
| 1260 | + | fputc('\n', stderr); | |
| 1217 | 1261 | update_refs_for_switch(opts, &old_branch_info, new_branch_info); | |
| 1218 | 1262 | ||
| 1263 | + | if (created_autostash) { | |
| 1264 | + | discard_index(the_repository->index); | |
| 1265 | + | if (repo_read_index(the_repository) < 0) | |
| 1266 | + | die(_("index file corrupt")); | |
| 1267 | + | ||
| 1268 | + | if (!opts->quiet && new_branch_info->commit) { | |
| 1269 | + | printf(_("The following paths have local changes:\n")); | |
| 1270 | + | show_local_changes(&new_branch_info->commit->object, | |
| 1271 | + | &opts->diff_options); | |
| 1272 | + | } | |
| 1273 | + | } | |
| 1274 | + | ||
| 1219 | 1275 | ret = post_checkout_hook(old_branch_info.commit, new_branch_info->commit, 1); | |
| 1220 | 1276 | branch_info_release(&old_branch_info); | |
| 1277 | + | strbuf_release(&old_commit_shortname); | |
| 1278 | + | strbuf_release(&autostash_msg); | |
| 1221 | 1279 | ||
| 1222 | 1280 | return ret || writeout_error; | |
| 1223 | 1281 | } | |
| @@ -1288,13 +1346,51 @@ enum checkout_command { | |||
| 1288 | 1346 | CHECKOUT_RESTORE = 3, | |
| 1289 | 1347 | }; | |
| 1290 | 1348 | ||
| 1349 | + | static void advise_disambiguating_remotes(enum checkout_command which_command, | |
| 1350 | + | const char *branch, | |
| 1351 | + | const struct string_list *matched_remote_names) | |
| 1352 | + | { | |
| 1353 | + | const char *cmdname; | |
| 1354 | + | struct string_list_item *item; | |
| 1355 | + | ||
| 1356 | + | switch (which_command) { | |
| 1357 | + | case CHECKOUT_CHECKOUT: | |
| 1358 | + | cmdname = "checkout"; | |
| 1359 | + | break; | |
| 1360 | + | case CHECKOUT_SWITCH: | |
| 1361 | + | cmdname = "switch"; | |
| 1362 | + | break; | |
| 1363 | + | default: | |
| 1364 | + | BUG("command <%d> should not reach advise_disambiguating_remotes", | |
| 1365 | + | which_command); | |
| 1366 | + | break; | |
| 1367 | + | } | |
| 1368 | + | ||
| 1369 | + | advise(_("Branch name '%s' appears in multiple remotes:"), branch); | |
| 1370 | + | for_each_string_list_item(item, matched_remote_names) { | |
| 1371 | + | advise(_(" %s"), item->string); | |
| 1372 | + | } | |
| 1373 | + | advise(_("If you meant to check out a remote tracking branch on <remote>,\n" | |
| 1374 | + | "you can do so by fully qualifying the name with the --track option:\n" | |
| 1375 | + | "\n" | |
| 1376 | + | " git %s --track <remote>/%s\n" | |
| 1377 | + | "\n" | |
| 1378 | + | "If you'd like to always have checkouts of an ambiguous name prefer\n" | |
| 1379 | + | "one remote, e.g. the 'origin' remote, consider setting\n" | |
| 1380 | + | "checkout.defaultRemote=origin in your config."), | |
| 1381 | + | cmdname, branch); | |
| 1382 | + | } | |
| 1383 | + | ||
| 1291 | 1384 | static char *parse_remote_branch(const char *arg, | |
| 1292 | 1385 | struct object_id *rev, | |
| 1293 | 1386 | int could_be_checkout_paths, | |
| 1294 | 1387 | enum checkout_command which_command) | |
| 1295 | 1388 | { | |
| 1296 | 1389 | int num_matches = 0; | |
| 1297 | - | char *remote = unique_tracking_name(arg, rev, &num_matches); | |
| 1390 | + | struct string_list matched_remote_names = STRING_LIST_INIT_DUP; | |
| 1391 | + | ||
| 1392 | + | char *remote = unique_tracking_name(arg, rev, &num_matches, | |
| 1393 | + | &matched_remote_names); | |
| 1298 | 1394 | ||
| 1299 | 1395 | if (remote && could_be_checkout_paths) { | |
| 1300 | 1396 | die(_("'%s' could be both a local file and a tracking branch.\n" | |
| @@ -1303,37 +1399,15 @@ static char *parse_remote_branch(const char *arg, | |||
| 1303 | 1399 | } | |
| 1304 | 1400 | ||
| 1305 | 1401 | if (!remote && num_matches > 1) { | |
| 1306 | - | if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) { | |
| 1307 | - | const char *cmdname; | |
| 1308 | - | ||
| 1309 | - | switch (which_command) { | |
| 1310 | - | case CHECKOUT_CHECKOUT: | |
| 1311 | - | cmdname = "checkout"; | |
| 1312 | - | break; | |
| 1313 | - | case CHECKOUT_SWITCH: | |
| 1314 | - | cmdname = "switch"; | |
| 1315 | - | break; | |
| 1316 | - | default: | |
| 1317 | - | BUG("command <%d> should not reach parse_remote_branch", | |
| 1318 | - | which_command); | |
| 1319 | - | break; | |
| 1320 | - | } | |
| 1321 | - | ||
| 1322 | - | advise(_("If you meant to check out a remote tracking branch on, e.g. 'origin',\n" | |
| 1323 | - | "you can do so by fully qualifying the name with the --track option:\n" | |
| 1324 | - | "\n" | |
| 1325 | - | " git %s --track origin/<name>\n" | |
| 1326 | - | "\n" | |
| 1327 | - | "If you'd like to always have checkouts of an ambiguous <name> prefer\n" | |
| 1328 | - | "one remote, e.g. the 'origin' remote, consider setting\n" | |
| 1329 | - | "checkout.defaultRemote=origin in your config."), | |
| 1330 | - | cmdname); | |
| 1331 | - | } | |
| 1332 | - | ||
| 1333 | - | die(_("'%s' matched multiple (%d) remote tracking branches"), | |
| 1334 | - | arg, num_matches); | |
| 1402 | + | if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) | |
| 1403 | + | advise_disambiguating_remotes(which_command, arg, | |
| 1404 | + | &matched_remote_names); | |
| 1405 | + | die(_("'%s' matched multiple (%d) remote tracking branches"), | |
| 1406 | + | arg, num_matches); | |
| 1335 | 1407 | } | |
| 1336 | 1408 | ||
| 1409 | + | string_list_clear(&matched_remote_names, 0); | |
| 1410 | + | ||
| 1337 | 1411 | return remote; | |
| 1338 | 1412 | } | |
| 1339 | 1413 | ||
| @@ -1485,7 +1559,7 @@ static int parse_branchname_arg(int argc, const char **argv, | |||
| 1485 | 1559 | * it would be extremely annoying. | |
| 1486 | 1560 | */ | |
| 1487 | 1561 | if (argc) | |
| 1488 | - | verify_non_filename(opts->prefix, arg); | |
| 1562 | + | verify_non_filename(the_repository, opts->prefix, arg); | |
| 1489 | 1563 | } else if (opts->accept_pathspec) { | |
| 1490 | 1564 | argcount++; | |
| 1491 | 1565 | argv++; | |
modified builtin/clone.c
| @@ -335,7 +335,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest, | |||
| 335 | 335 | die_errno(_("failed to create link '%s'"), dest->buf); | |
| 336 | 336 | option_no_hardlinks = 1; | |
| 337 | 337 | } | |
| 338 | - | if (copy_file_with_time(dest->buf, src->buf, 0666)) | |
| 338 | + | if (copy_file_with_time(the_repository, dest->buf, src->buf, 0666)) | |
| 339 | 339 | die_errno(_("failed to copy file to '%s'"), dest->buf); | |
| 340 | 340 | } | |
| 341 | 341 | ||
| @@ -557,7 +557,7 @@ static void update_remote_refs(const struct ref *refs, | |||
| 557 | 557 | write_followtags(refs, msg); | |
| 558 | 558 | } | |
| 559 | 559 | ||
| 560 | - | if (remote_head_points_at && !option_bare) { | |
| 560 | + | if (remote_head_points_at && remote_head_points_at->peer_ref && !option_bare) { | |
| 561 | 561 | struct strbuf head_ref = STRBUF_INIT; | |
| 562 | 562 | strbuf_addstr(&head_ref, branch_top); | |
| 563 | 563 | strbuf_addstr(&head_ref, "HEAD"); | |
| @@ -647,6 +647,7 @@ static int checkout(int submodule_progress, | |||
| 647 | 647 | struct tree *tree; | |
| 648 | 648 | struct tree_desc t; | |
| 649 | 649 | int err = 0; | |
| 650 | + | struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; | |
| 650 | 651 | ||
| 651 | 652 | if (option_no_checkout) | |
| 652 | 653 | return 0; | |
| @@ -668,7 +669,7 @@ static int checkout(int submodule_progress, | |||
| 668 | 669 | } | |
| 669 | 670 | ||
| 670 | 671 | /* We need to be in the new work tree for the checkout */ | |
| 671 | - | setup_work_tree(); | |
| 672 | + | setup_work_tree(the_repository); | |
| 672 | 673 | ||
| 673 | 674 | repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR); | |
| 674 | 675 | ||
| @@ -697,8 +698,9 @@ static int checkout(int submodule_progress, | |||
| 697 | 698 | if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK)) | |
| 698 | 699 | die(_("unable to write new index file")); | |
| 699 | 700 | ||
| 700 | - | err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid(the_hash_algo)), | |
| 701 | - | oid_to_hex(&oid), "1", NULL); | |
| 701 | + | strvec_pushl(&hook_opt.args, oid_to_hex(null_oid(the_hash_algo)), | |
| 702 | + | oid_to_hex(&oid), "1", NULL); | |
| 703 | + | err |= run_hooks_opt(the_repository, "post-checkout", &hook_opt); | |
| 702 | 704 | ||
| 703 | 705 | if (!err && (option_recurse_submodules.nr > 0)) { | |
| 704 | 706 | struct child_process cmd = CHILD_PROCESS_INIT; | |
| @@ -1114,7 +1116,6 @@ int cmd_clone(int argc, | |||
| 1114 | 1116 | die_errno(_("could not create work tree dir '%s'"), | |
| 1115 | 1117 | work_tree); | |
| 1116 | 1118 | junk_work_tree = work_tree; | |
| 1117 | - | set_git_work_tree(work_tree); | |
| 1118 | 1119 | } | |
| 1119 | 1120 | ||
| 1120 | 1121 | if (real_git_dir) { | |
| @@ -1184,9 +1185,10 @@ int cmd_clone(int argc, | |||
| 1184 | 1185 | * repository, and reference backends may persist that information into | |
| 1185 | 1186 | * their on-disk data structures. | |
| 1186 | 1187 | */ | |
| 1187 | - | init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, | |
| 1188 | - | ref_storage_format, NULL, | |
| 1189 | - | do_not_override_repo_unix_permissions, INIT_DB_QUIET | INIT_DB_SKIP_REFDB); | |
| 1188 | + | init_db(the_repository, git_dir, real_git_dir, work_tree, option_template, | |
| 1189 | + | GIT_HASH_UNKNOWN, ref_storage_format, NULL, | |
| 1190 | + | do_not_override_repo_unix_permissions, | |
| 1191 | + | INIT_DB_QUIET | INIT_DB_SKIP_REFDB); | |
| 1190 | 1192 | ||
| 1191 | 1193 | if (real_git_dir) { | |
| 1192 | 1194 | free((char *)git_dir); | |
| @@ -1227,7 +1229,7 @@ int cmd_clone(int argc, | |||
| 1227 | 1229 | * | |
| 1228 | 1230 | * This is sufficient for Git commands to discover the Git directory. | |
| 1229 | 1231 | */ | |
| 1230 | - | initialize_repository_version(GIT_HASH_UNKNOWN, | |
| 1232 | + | initialize_repository_version(the_repository, GIT_HASH_UNKNOWN, | |
| 1231 | 1233 | the_repository->ref_storage_format, 1); | |
| 1232 | 1234 | ||
| 1233 | 1235 | refs_create_refdir_stubs(the_repository, git_dir, NULL); | |
| @@ -1440,9 +1442,9 @@ int cmd_clone(int argc, | |||
| 1440 | 1442 | * ours to the same thing. | |
| 1441 | 1443 | */ | |
| 1442 | 1444 | hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport)); | |
| 1443 | - | initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1); | |
| 1445 | + | initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1); | |
| 1444 | 1446 | repo_set_hash_algo(the_repository, hash_algo); | |
| 1445 | - | create_reference_database(NULL, 1); | |
| 1447 | + | create_reference_database(the_repository, NULL, 1); | |
| 1446 | 1448 | ||
| 1447 | 1449 | /* | |
| 1448 | 1450 | * Before fetching from the remote, download and install bundle | |
modified builtin/commit.c
| @@ -484,7 +484,7 @@ static const char *prepare_index(const char **argv, const char *prefix, | |||
| 484 | 484 | LOCK_DIE_ON_ERROR); | |
| 485 | 485 | refresh_cache_or_die(refresh_flags); | |
| 486 | 486 | if (the_repository->index->cache_changed | |
| 487 | - | || !cache_tree_fully_valid(the_repository->index->cache_tree)) | |
| 487 | + | || !cache_tree_fully_valid(the_repository->index)) | |
| 488 | 488 | cache_tree_update(the_repository->index, WRITE_TREE_SILENT); | |
| 489 | 489 | if (write_locked_index(the_repository->index, &index_lock, | |
| 490 | 490 | COMMIT_LOCK | SKIP_IF_UNCHANGED)) | |
| @@ -1979,7 +1979,8 @@ int cmd_commit(int argc, | |||
| 1979 | 1979 | &oid, flags); | |
| 1980 | 1980 | } | |
| 1981 | 1981 | ||
| 1982 | - | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH"); | |
| 1982 | + | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH", | |
| 1983 | + | NULL, NULL, NULL, NULL); | |
| 1983 | 1984 | ||
| 1984 | 1985 | cleanup: | |
| 1985 | 1986 | free_commit_extra_headers(extra); | |
modified builtin/config.c
| @@ -1,6 +1,7 @@ | |||
| 1 | 1 | #define USE_THE_REPOSITORY_VARIABLE | |
| 2 | 2 | #include "builtin.h" | |
| 3 | 3 | #include "abspath.h" | |
| 4 | + | #include "advice.h" | |
| 4 | 5 | #include "config.h" | |
| 5 | 6 | #include "color.h" | |
| 6 | 7 | #include "date.h" | |
| @@ -210,6 +211,26 @@ static void check_argc(int argc, int min, int max) | |||
| 210 | 211 | exit(129); | |
| 211 | 212 | } | |
| 212 | 213 | ||
| 214 | + | static NORETURN void die_missing_set_value(const char *arg) | |
| 215 | + | { | |
| 216 | + | const char *last_dot = strrchr(arg, '.'); | |
| 217 | + | const char *eq = last_dot ? strchr(last_dot + 1, '=') : NULL; | |
| 218 | + | char *prefix = eq ? xstrndup(arg, eq - arg) : NULL; | |
| 219 | + | ||
| 220 | + | if (prefix && git_config_key_is_valid(prefix)) { | |
| 221 | + | error(_("missing value to set to the variable '%s'"), arg); | |
| 222 | + | advise(_("did you mean \"git config set %s %s\"?"), | |
| 223 | + | prefix, eq + 1); | |
| 224 | + | } else if (git_config_key_is_valid(arg)) { | |
| 225 | + | error(_("missing value to set to the variable '%s'"), arg); | |
| 226 | + | } else { | |
| 227 | + | error(_("missing value to set to a variable with an invalid name '%s'"), | |
| 228 | + | arg); | |
| 229 | + | } | |
| 230 | + | free(prefix); | |
| 231 | + | exit(129); | |
| 232 | + | } | |
| 233 | + | ||
| 213 | 234 | static void show_config_origin(const struct config_display_options *opts, | |
| 214 | 235 | const struct key_value_info *kvi, | |
| 215 | 236 | struct strbuf *buf) | |
| @@ -953,7 +974,7 @@ static void location_options_init(struct config_location_options *opts, | |||
| 953 | 974 | opts->source.file = opts->file_to_free = repo_git_path(the_repository, "config"); | |
| 954 | 975 | opts->source.scope = CONFIG_SCOPE_LOCAL; | |
| 955 | 976 | } else if (opts->use_worktree_config) { | |
| 956 | - | struct worktree **worktrees = get_worktrees(); | |
| 977 | + | struct worktree **worktrees = get_worktrees(the_repository); | |
| 957 | 978 | if (the_repository->repository_format_worktree_config) | |
| 958 | 979 | opts->source.file = opts->file_to_free = | |
| 959 | 980 | repo_git_path(the_repository, "config.worktree"); | |
| @@ -1133,6 +1154,8 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix, | |||
| 1133 | 1154 | ||
| 1134 | 1155 | argc = parse_options(argc, argv, prefix, opts, builtin_config_set_usage, | |
| 1135 | 1156 | PARSE_OPT_STOP_AT_NON_OPTION); | |
| 1157 | + | if (argc == 1) | |
| 1158 | + | die_missing_set_value(argv[0]); | |
| 1136 | 1159 | check_argc(argc, 2, 2); | |
| 1137 | 1160 | ||
| 1138 | 1161 | if ((flags & CONFIG_FLAGS_FIXED_VALUE) && !value_pattern) | |
| @@ -1290,7 +1313,10 @@ static int show_editor(struct config_location_options *opts) | |||
| 1290 | 1313 | else if (errno != EEXIST) | |
| 1291 | 1314 | die_errno(_("cannot create configuration file %s"), config_file); | |
| 1292 | 1315 | } | |
| 1293 | - | launch_editor(config_file, NULL, NULL); | |
| 1316 | + | if (launch_editor(config_file, NULL, NULL)) { | |
| 1317 | + | free(config_file); | |
| 1318 | + | return -1; | |
| 1319 | + | } | |
| 1294 | 1320 | free(config_file); | |
| 1295 | 1321 | ||
| 1296 | 1322 | return 0; | |
| @@ -1371,6 +1397,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix) | |||
| 1371 | 1397 | }; | |
| 1372 | 1398 | char *value = NULL, *comment = NULL; | |
| 1373 | 1399 | int ret = 0; | |
| 1400 | + | int actions_implicit; | |
| 1374 | 1401 | struct key_value_info default_kvi = KVI_INIT; | |
| 1375 | 1402 | ||
| 1376 | 1403 | argc = parse_options(argc, argv, prefix, opts, | |
| @@ -1385,7 +1412,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix) | |||
| 1385 | 1412 | exit(129); | |
| 1386 | 1413 | } | |
| 1387 | 1414 | ||
| 1388 | - | if (actions == 0) | |
| 1415 | + | actions_implicit = (actions == 0); | |
| 1416 | + | if (actions_implicit) | |
| 1389 | 1417 | switch (argc) { | |
| 1390 | 1418 | case 1: actions = ACTION_GET; break; | |
| 1391 | 1419 | case 2: actions = ACTION_SET; break; | |
| @@ -1394,6 +1422,11 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix) | |||
| 1394 | 1422 | error(_("no action specified")); | |
| 1395 | 1423 | exit(129); | |
| 1396 | 1424 | } | |
| 1425 | + | if (actions_implicit && argc == 1) { | |
| 1426 | + | const char *last_dot = strrchr(argv[0], '.'); | |
| 1427 | + | if (last_dot && strchr(last_dot + 1, '=')) | |
| 1428 | + | die_missing_set_value(argv[0]); | |
| 1429 | + | } | |
| 1397 | 1430 | if (display_opts.omit_values && | |
| 1398 | 1431 | !(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) { | |
| 1399 | 1432 | error(_("--name-only is only applicable to --list or --get-regexp")); | |
modified builtin/describe.c
| @@ -251,56 +251,19 @@ static int compare_pt(const void *a_, const void *b_) | |||
| 251 | 251 | return 0; | |
| 252 | 252 | } | |
| 253 | 253 | ||
| 254 | - | struct lazy_queue { | |
| 255 | - | struct prio_queue queue; | |
| 256 | - | bool get_pending; | |
| 257 | - | }; | |
| 258 | - | ||
| 259 | - | #define LAZY_QUEUE_INIT { { compare_commits_by_commit_date }, false } | |
| 260 | - | ||
| 261 | - | static void *lazy_queue_get(struct lazy_queue *queue) | |
| 262 | - | { | |
| 263 | - | if (queue->get_pending) | |
| 264 | - | prio_queue_get(&queue->queue); | |
| 265 | - | else | |
| 266 | - | queue->get_pending = true; | |
| 267 | - | return prio_queue_peek(&queue->queue); | |
| 268 | - | } | |
| 269 | - | ||
| 270 | - | static void lazy_queue_put(struct lazy_queue *queue, void *thing) | |
| 271 | - | { | |
| 272 | - | if (queue->get_pending) | |
| 273 | - | prio_queue_replace(&queue->queue, thing); | |
| 274 | - | else | |
| 275 | - | prio_queue_put(&queue->queue, thing); | |
| 276 | - | queue->get_pending = false; | |
| 277 | - | } | |
| 278 | - | ||
| 279 | - | static bool lazy_queue_empty(const struct lazy_queue *queue) | |
| 280 | - | { | |
| 281 | - | return queue->queue.nr == (queue->get_pending ? 1 : 0); | |
| 282 | - | } | |
| 283 | - | ||
| 284 | - | static void lazy_queue_clear(struct lazy_queue *queue) | |
| 285 | - | { | |
| 286 | - | clear_prio_queue(&queue->queue); | |
| 287 | - | queue->get_pending = false; | |
| 288 | - | } | |
| 289 | - | ||
| 290 | - | static unsigned long finish_depth_computation(struct lazy_queue *queue, | |
| 254 | + | static unsigned long finish_depth_computation(struct prio_queue *queue, | |
| 291 | 255 | struct possible_tag *best) | |
| 292 | 256 | { | |
| 293 | 257 | unsigned long seen_commits = 0; | |
| 294 | 258 | struct oidset unflagged = OIDSET_INIT; | |
| 259 | + | struct commit *c; | |
| 295 | 260 | ||
| 296 | - | for (size_t i = queue->get_pending ? 1 : 0; i < queue->queue.nr; i++) { | |
| 297 | - | struct commit *commit = queue->queue.array[i].data; | |
| 298 | - | if (!(commit->object.flags & best->flag_within)) | |
| 299 | - | oidset_insert(&unflagged, &commit->object.oid); | |
| 261 | + | prio_queue_for_each(queue, c) { | |
| 262 | + | if (!(c->object.flags & best->flag_within)) | |
| 263 | + | oidset_insert(&unflagged, &c->object.oid); | |
| 300 | 264 | } | |
| 301 | 265 | ||
| 302 | - | while (!lazy_queue_empty(queue)) { | |
| 303 | - | struct commit *c = lazy_queue_get(queue); | |
| 266 | + | while ((c = prio_queue_get(queue))) { | |
| 304 | 267 | struct commit_list *parents = c->parents; | |
| 305 | 268 | seen_commits++; | |
| 306 | 269 | if (c->object.flags & best->flag_within) { | |
| @@ -316,7 +279,7 @@ static unsigned long finish_depth_computation(struct lazy_queue *queue, | |||
| 316 | 279 | repo_parse_commit(the_repository, p); | |
| 317 | 280 | seen = p->object.flags & SEEN; | |
| 318 | 281 | if (!seen) | |
| 319 | - | lazy_queue_put(queue, p); | |
| 282 | + | prio_queue_put(queue, p); | |
| 320 | 283 | flag_before = p->object.flags & best->flag_within; | |
| 321 | 284 | p->object.flags |= c->object.flags; | |
| 322 | 285 | flag_after = p->object.flags & best->flag_within; | |
| @@ -364,8 +327,8 @@ static void append_suffix(int depth, const struct object_id *oid, struct strbuf | |||
| 364 | 327 | ||
| 365 | 328 | static void describe_commit(struct commit *cmit, struct strbuf *dst) | |
| 366 | 329 | { | |
| 367 | - | struct commit *gave_up_on = NULL; | |
| 368 | - | struct lazy_queue queue = LAZY_QUEUE_INIT; | |
| 330 | + | struct commit *c, *gave_up_on = NULL; | |
| 331 | + | struct prio_queue queue = { compare_commits_by_commit_date }; | |
| 369 | 332 | struct commit_name *n; | |
| 370 | 333 | struct possible_tag all_matches[MAX_TAGS]; | |
| 371 | 334 | unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; | |
| @@ -407,9 +370,8 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst) | |||
| 407 | 370 | } | |
| 408 | 371 | ||
| 409 | 372 | cmit->object.flags = SEEN; | |
| 410 | - | lazy_queue_put(&queue, cmit); | |
| 411 | - | while (!lazy_queue_empty(&queue)) { | |
| 412 | - | struct commit *c = lazy_queue_get(&queue); | |
| 373 | + | prio_queue_put(&queue, cmit); | |
| 374 | + | while ((c = prio_queue_get(&queue))) { | |
| 413 | 375 | struct commit_list *parents = c->parents; | |
| 414 | 376 | struct commit_name **slot; | |
| 415 | 377 | ||
| @@ -443,7 +405,7 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst) | |||
| 443 | 405 | t->depth++; | |
| 444 | 406 | } | |
| 445 | 407 | /* Stop if last remaining path already covered by best candidate(s) */ | |
| 446 | - | if (annotated_cnt && lazy_queue_empty(&queue)) { | |
| 408 | + | if (annotated_cnt && !prio_queue_size(&queue)) { | |
| 447 | 409 | int best_depth = INT_MAX; | |
| 448 | 410 | unsigned best_within = 0; | |
| 449 | 411 | for (cur_match = 0; cur_match < match_cnt; cur_match++) { | |
| @@ -466,7 +428,7 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst) | |||
| 466 | 428 | struct commit *p = parents->item; | |
| 467 | 429 | repo_parse_commit(the_repository, p); | |
| 468 | 430 | if (!(p->object.flags & SEEN)) | |
| 469 | - | lazy_queue_put(&queue, p); | |
| 431 | + | prio_queue_put(&queue, p); | |
| 470 | 432 | p->object.flags |= c->object.flags; | |
| 471 | 433 | parents = parents->next; | |
| 472 | 434 | ||
| @@ -481,7 +443,7 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst) | |||
| 481 | 443 | strbuf_add_unique_abbrev(dst, cmit_oid, abbrev); | |
| 482 | 444 | if (suffix) | |
| 483 | 445 | strbuf_addstr(dst, suffix); | |
| 484 | - | lazy_queue_clear(&queue); | |
| 446 | + | clear_prio_queue(&queue); | |
| 485 | 447 | return; | |
| 486 | 448 | } | |
| 487 | 449 | if (unannotated_cnt) | |
| @@ -497,11 +459,11 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst) | |||
| 497 | 459 | QSORT(all_matches, match_cnt, compare_pt); | |
| 498 | 460 | ||
| 499 | 461 | if (gave_up_on) { | |
| 500 | - | lazy_queue_put(&queue, gave_up_on); | |
| 462 | + | prio_queue_put(&queue, gave_up_on); | |
| 501 | 463 | seen_commits--; | |
| 502 | 464 | } | |
| 503 | 465 | seen_commits += finish_depth_computation(&queue, &all_matches[0]); | |
| 504 | - | lazy_queue_clear(&queue); | |
| 466 | + | clear_prio_queue(&queue); | |
| 505 | 467 | ||
| 506 | 468 | if (debug) { | |
| 507 | 469 | static int label_width = -1; | |
| @@ -712,13 +674,25 @@ int cmd_describe(int argc, | |||
| 712 | 674 | NULL); | |
| 713 | 675 | if (always) | |
| 714 | 676 | strvec_push(&args, "--always"); | |
| 715 | - | if (!all) { | |
| 677 | + | if (!all) | |
| 716 | 678 | strvec_push(&args, "--tags"); | |
| 679 | + | ||
| 680 | + | for_each_string_list_item(item, &patterns) | |
| 681 | + | strvec_pushf(&args, "--refs=refs/tags/%s", item->string); | |
| 682 | + | for_each_string_list_item(item, &exclude_patterns) | |
| 683 | + | strvec_pushf(&args, "--exclude=refs/tags/%s", item->string); | |
| 684 | + | ||
| 685 | + | if (all) { | |
| 686 | + | for_each_string_list_item(item, &patterns) | |
| 687 | + | strvec_pushf(&args, "--refs=refs/heads/%s", item->string); | |
| 688 | + | for_each_string_list_item(item, &exclude_patterns) | |
| 689 | + | strvec_pushf(&args, "--exclude=refs/heads/%s", item->string); | |
| 717 | 690 | for_each_string_list_item(item, &patterns) | |
| 718 | - | strvec_pushf(&args, "--refs=refs/tags/%s", item->string); | |
| 691 | + | strvec_pushf(&args, "--refs=refs/remotes/%s", item->string); | |
| 719 | 692 | for_each_string_list_item(item, &exclude_patterns) | |
| 720 | - | strvec_pushf(&args, "--exclude=refs/tags/%s", item->string); | |
| 693 | + | strvec_pushf(&args, "--exclude=refs/remotes/%s", item->string); | |
| 721 | 694 | } | |
| 695 | + | ||
| 722 | 696 | if (argc) | |
| 723 | 697 | strvec_pushv(&args, argv); | |
| 724 | 698 | else | |
| @@ -740,6 +714,9 @@ int cmd_describe(int argc, | |||
| 740 | 714 | return ret; | |
| 741 | 715 | } | |
| 742 | 716 | ||
| 717 | + | if (!all) | |
| 718 | + | for_each_ref_opts.prefix = "refs/tags/"; | |
| 719 | + | ||
| 743 | 720 | hashmap_init(&names, commit_name_neq, NULL, 0); | |
| 744 | 721 | refs_for_each_ref_ext(get_main_ref_store(the_repository), | |
| 745 | 722 | get_name, NULL, &for_each_ref_opts); | |
| @@ -781,7 +758,7 @@ int cmd_describe(int argc, | |||
| 781 | 758 | struct rev_info revs; | |
| 782 | 759 | int fd; | |
| 783 | 760 | ||
| 784 | - | setup_work_tree(); | |
| 761 | + | setup_work_tree(the_repository); | |
| 785 | 762 | prepare_repo_settings(the_repository); | |
| 786 | 763 | the_repository->settings.command_requires_full_index = 0; | |
| 787 | 764 | repo_read_index(the_repository); | |
modified builtin/diff-index.c
| @@ -69,7 +69,7 @@ int cmd_diff_index(int argc, | |||
| 69 | 69 | rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1) | |
| 70 | 70 | usage(diff_cache_usage); | |
| 71 | 71 | if (!(option & DIFF_INDEX_CACHED)) { | |
| 72 | - | setup_work_tree(); | |
| 72 | + | setup_work_tree(the_repository); | |
| 73 | 73 | if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) { | |
| 74 | 74 | perror("repo_read_index_preload"); | |
| 75 | 75 | return -1; | |
modified builtin/diff.c
| @@ -159,7 +159,7 @@ static void builtin_diff_index(struct rev_info *revs, | |||
| 159 | 159 | revs->max_age != -1) | |
| 160 | 160 | usage(builtin_diff_usage); | |
| 161 | 161 | if (!(option & DIFF_INDEX_CACHED)) { | |
| 162 | - | setup_work_tree(); | |
| 162 | + | setup_work_tree(the_repository); | |
| 163 | 163 | if (repo_read_index_preload(the_repository, | |
| 164 | 164 | &revs->diffopt.pathspec, 0) < 0) { | |
| 165 | 165 | die_errno("repo_read_index_preload"); | |
| @@ -281,7 +281,7 @@ static void builtin_diff_files(struct rev_info *revs, int argc, const char **arg | |||
| 281 | 281 | (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) | |
| 282 | 282 | diff_merges_set_dense_combined_if_unset(revs); | |
| 283 | 283 | ||
| 284 | - | setup_work_tree(); | |
| 284 | + | setup_work_tree(the_repository); | |
| 285 | 285 | if (repo_read_index_preload(the_repository, &revs->diffopt.pathspec, | |
| 286 | 286 | 0) < 0) { | |
| 287 | 287 | die_errno("repo_read_index_preload"); | |
| @@ -455,7 +455,7 @@ int cmd_diff(int argc, | |||
| 455 | 455 | break; | |
| 456 | 456 | } | |
| 457 | 457 | ||
| 458 | - | prefix = setup_git_directory_gently(&nongit); | |
| 458 | + | prefix = setup_git_directory_gently(the_repository, &nongit); | |
| 459 | 459 | ||
| 460 | 460 | if (!nongit) { | |
| 461 | 461 | prepare_repo_settings(the_repository); | |
| @@ -471,8 +471,8 @@ int cmd_diff(int argc, | |||
| 471 | 471 | * as a colourful "diff" replacement. | |
| 472 | 472 | */ | |
| 473 | 473 | if (nongit || ((argc == i + 2) && | |
| 474 | - | (!path_inside_repo(prefix, argv[i]) || | |
| 475 | - | !path_inside_repo(prefix, argv[i + 1])))) | |
| 474 | + | (!path_inside_repo(the_repository, prefix, argv[i]) || | |
| 475 | + | !path_inside_repo(the_repository, prefix, argv[i + 1])))) | |
| 476 | 476 | no_index = DIFF_NO_INDEX_IMPLICIT; | |
| 477 | 477 | } | |
| 478 | 478 | ||
| @@ -579,9 +579,13 @@ int cmd_diff(int argc, | |||
| 579 | 579 | obj = deref_tag(the_repository, obj, NULL, 0); | |
| 580 | 580 | if (!obj) | |
| 581 | 581 | die(_("invalid object '%s' given."), name); | |
| 582 | - | if (obj->type == OBJ_COMMIT) | |
| 583 | - | obj = &repo_get_commit_tree(the_repository, | |
| 584 | - | ((struct commit *)obj))->object; | |
| 582 | + | if (obj->type == OBJ_COMMIT) { | |
| 583 | + | struct tree *tree = repo_get_commit_tree( | |
| 584 | + | the_repository, (struct commit *)obj); | |
| 585 | + | if (!tree) | |
| 586 | + | die(_("unable to read tree object for commit '%s'"), name); | |
| 587 | + | obj = &tree->object; | |
| 588 | + | } | |
| 585 | 589 | ||
| 586 | 590 | if (obj->type == OBJ_TREE) { | |
| 587 | 591 | if (sdiff.skip && bitmap_get(sdiff.skip, i)) | |
modified builtin/difftool.c
| @@ -319,7 +319,7 @@ static char *get_symlink(struct repository *repo, | |||
| 319 | 319 | data = strbuf_detach(&link, NULL); | |
| 320 | 320 | } else { | |
| 321 | 321 | enum object_type type; | |
| 322 | - | unsigned long size; | |
| 322 | + | size_t size; | |
| 323 | 323 | data = odb_read_object(repo->objects, oid, &type, &size); | |
| 324 | 324 | if (!data) | |
| 325 | 325 | die(_("could not read object %s for symlink %s"), | |
| @@ -552,7 +552,7 @@ static int run_dir_diff(struct repository *repo, | |||
| 552 | 552 | struct stat st; | |
| 553 | 553 | if (stat(wtdir.buf, &st)) | |
| 554 | 554 | st.st_mode = 0644; | |
| 555 | - | if (copy_file(rdir.buf, wtdir.buf, | |
| 555 | + | if (copy_file(repo, rdir.buf, wtdir.buf, | |
| 556 | 556 | st.st_mode)) { | |
| 557 | 557 | ret = error("could not copy '%s' to '%s'", wtdir.buf, rdir.buf); | |
| 558 | 558 | goto finish; | |
| @@ -636,7 +636,7 @@ static int run_dir_diff(struct repository *repo, | |||
| 636 | 636 | struct lock_file lock = LOCK_INIT; | |
| 637 | 637 | strbuf_reset(&buf); | |
| 638 | 638 | strbuf_addf(&buf, "%s/wtindex", tmpdir.buf); | |
| 639 | - | if (hold_lock_file_for_update(&lock, buf.buf, 0) < 0 || | |
| 639 | + | if (repo_hold_lock_file_for_update(repo, &lock, buf.buf, 0) < 0 || | |
| 640 | 640 | write_locked_index(&wtindex, &lock, COMMIT_LOCK)) { | |
| 641 | 641 | ret = error("could not write %s", buf.buf); | |
| 642 | 642 | goto finish; | |
| @@ -658,7 +658,7 @@ static int run_dir_diff(struct repository *repo, | |||
| 658 | 658 | warning("%s", ""); | |
| 659 | 659 | err = 1; | |
| 660 | 660 | } else if (unlink(wtdir.buf) || | |
| 661 | - | copy_file(wtdir.buf, rdir.buf, st.st_mode)) | |
| 661 | + | copy_file(repo, wtdir.buf, rdir.buf, st.st_mode)) | |
| 662 | 662 | warning_errno(_("could not copy '%s' to '%s'"), | |
| 663 | 663 | rdir.buf, wtdir.buf); | |
| 664 | 664 | } | |
| @@ -767,7 +767,7 @@ int cmd_difftool(int argc, | |||
| 767 | 767 | die(_("difftool requires worktree or --no-index")); | |
| 768 | 768 | ||
| 769 | 769 | if (!no_index){ | |
| 770 | - | setup_work_tree(); | |
| 770 | + | setup_work_tree(repo); | |
| 771 | 771 | setenv(GIT_DIR_ENVIRONMENT, absolute_path(repo_get_git_dir(repo)), 1); | |
| 772 | 772 | setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(repo_get_work_tree(repo)), 1); | |
| 773 | 773 | } else if (dir_diff) | |
modified builtin/fast-export.c
| @@ -33,7 +33,7 @@ | |||
| 33 | 33 | #include "gpg-interface.h" | |
| 34 | 34 | ||
| 35 | 35 | static const char *const fast_export_usage[] = { | |
| 36 | - | N_("git fast-export [<rev-list-opts>]"), | |
| 36 | + | N_("git fast-export [<options>] [<revision-range>] [[--] <path>...]"), | |
| 37 | 37 | NULL | |
| 38 | 38 | }; | |
| 39 | 39 | ||
| @@ -51,7 +51,7 @@ static int show_original_ids; | |||
| 51 | 51 | static int mark_tags; | |
| 52 | 52 | static struct string_list extra_refs = STRING_LIST_INIT_DUP; | |
| 53 | 53 | static struct string_list tag_refs = STRING_LIST_INIT_DUP; | |
| 54 | - | static struct refspec refspecs = REFSPEC_INIT_FETCH; | |
| 54 | + | static struct refspec refspecs; | |
| 55 | 55 | static int anonymize; | |
| 56 | 56 | static struct hashmap anonymized_seeds; | |
| 57 | 57 | static struct revision_sources revision_sources; | |
| @@ -317,7 +317,10 @@ static void export_blob(const struct object_id *oid) | |||
| 317 | 317 | object = (struct object *)lookup_blob(the_repository, oid); | |
| 318 | 318 | eaten = 0; | |
| 319 | 319 | } else { | |
| 320 | - | buf = odb_read_object(the_repository->objects, oid, &type, &size); | |
| 320 | + | size_t size_st = 0; | |
| 321 | + | buf = odb_read_object(the_repository->objects, oid, &type, | |
| 322 | + | &size_st); | |
| 323 | + | size = cast_size_t_to_ulong(size_st); | |
| 321 | 324 | if (!buf) | |
| 322 | 325 | die(_("could not read blob %s"), oid_to_hex(oid)); | |
| 323 | 326 | if (check_object_signature(the_repository, oid, buf, size, | |
| @@ -880,7 +883,7 @@ static char *anonymize_tag(void) | |||
| 880 | 883 | ||
| 881 | 884 | static void handle_tag(const char *name, struct tag *tag) | |
| 882 | 885 | { | |
| 883 | - | unsigned long size; | |
| 886 | + | size_t size; | |
| 884 | 887 | enum object_type type; | |
| 885 | 888 | char *buf; | |
| 886 | 889 | const char *tagger, *tagger_end, *message; | |
| @@ -1369,6 +1372,8 @@ int cmd_fast_export(int argc, | |||
| 1369 | 1372 | /* we handle encodings */ | |
| 1370 | 1373 | repo_config(the_repository, git_default_config, NULL); | |
| 1371 | 1374 | ||
| 1375 | + | refspec_init_fetch(&refspecs, the_hash_algo); | |
| 1376 | + | ||
| 1372 | 1377 | repo_init_revisions(the_repository, &revs, prefix); | |
| 1373 | 1378 | init_revision_sources(&revision_sources); | |
| 1374 | 1379 | revs.topo_order = 1; | |
modified builtin/fast-import.c
| @@ -30,6 +30,7 @@ | |||
| 30 | 30 | #include "khash.h" | |
| 31 | 31 | #include "date.h" | |
| 32 | 32 | #include "gpg-interface.h" | |
| 33 | + | #include "parse-options.h" | |
| 33 | 34 | ||
| 34 | 35 | #define PACK_ID_BITS 16 | |
| 35 | 36 | #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1) | |
| @@ -182,12 +183,8 @@ static unsigned long branch_count; | |||
| 182 | 183 | static unsigned long branch_load_count; | |
| 183 | 184 | static int failure; | |
| 184 | 185 | static FILE *pack_edges; | |
| 185 | - | static unsigned int show_stats = 1; | |
| 186 | - | static unsigned int quiet; | |
| 187 | - | static int global_argc; | |
| 188 | - | static const char **global_argv; | |
| 189 | - | static const char *global_prefix; | |
| 190 | - | ||
| 186 | + | static int show_stats = 1; | |
| 187 | + | static int quiet; | |
| 191 | 188 | static enum sign_mode signed_tag_mode = SIGN_VERBATIM; | |
| 192 | 189 | static enum sign_mode signed_commit_mode = SIGN_VERBATIM; | |
| 193 | 190 | static const char *signed_commit_keyid; | |
| @@ -261,9 +258,7 @@ static struct recent_command *rc_free; | |||
| 261 | 258 | static unsigned int cmd_save = 100; | |
| 262 | 259 | static uintmax_t next_mark; | |
| 263 | 260 | static struct strbuf new_data = STRBUF_INIT; | |
| 264 | - | static int seen_data_command; | |
| 265 | 261 | static int require_explicit_termination; | |
| 266 | - | static int allow_unsafe_features; | |
| 267 | 262 | ||
| 268 | 263 | /* Signal handling */ | |
| 269 | 264 | static volatile sig_atomic_t checkpoint_requested; | |
| @@ -276,10 +271,33 @@ static kh_oid_map_t *sub_oid_map; | |||
| 276 | 271 | /* Where to write output of cat-blob commands */ | |
| 277 | 272 | static int cat_blob_fd = STDOUT_FILENO; | |
| 278 | 273 | ||
| 279 | - | static void parse_argv(void); | |
| 280 | - | static void parse_get_mark(const char *p); | |
| 281 | - | static void parse_cat_blob(const char *p); | |
| 282 | - | static void parse_ls(const char *p, struct branch *b); | |
| 274 | + | /* Command state */ | |
| 275 | + | struct fast_import_state { | |
| 276 | + | int argc; | |
| 277 | + | const char **argv; | |
| 278 | + | const char *prefix; | |
| 279 | + | int seen_data_command; | |
| 280 | + | int allow_unsafe_features; | |
| 281 | + | struct option *option; | |
| 282 | + | }; | |
| 283 | + | ||
| 284 | + | static void fast_import_state_init(struct fast_import_state *state, | |
| 285 | + | int argc, const char **argv, | |
| 286 | + | const char *prefix, struct option *option) | |
| 287 | + | { | |
| 288 | + | memset(state, 0, sizeof(*state)); | |
| 289 | + | state->argc = argc; | |
| 290 | + | state->argv = argv; | |
| 291 | + | state->prefix = prefix; | |
| 292 | + | state->option = option; | |
| 293 | + | } | |
| 294 | + | ||
| 295 | + | static void parse_argv(struct fast_import_state *state); | |
| 296 | + | static void parse_get_mark(struct fast_import_state *state, const char *p); | |
| 297 | + | static void parse_cat_blob(struct fast_import_state *state, const char *p); | |
| 298 | + | static void parse_ls(struct fast_import_state *state, | |
| 299 | + | const char *p, | |
| 300 | + | struct branch *b); | |
| 283 | 301 | ||
| 284 | 302 | static void for_each_mark(struct mark_set *m, uintmax_t base, each_mark_fn_t callback, void *p) | |
| 285 | 303 | { | |
| @@ -962,13 +980,14 @@ static int store_object( | |||
| 962 | 980 | struct object_entry *e; | |
| 963 | 981 | unsigned char hdr[96]; | |
| 964 | 982 | struct object_id oid; | |
| 965 | - | unsigned long hdrlen, deltalen; | |
| 983 | + | unsigned long hdrlen, deltalen = 0; | |
| 966 | 984 | struct git_hash_ctx c; | |
| 967 | 985 | git_zstream s; | |
| 986 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 968 | 987 | ||
| 969 | 988 | hdrlen = format_object_header((char *)hdr, sizeof(hdr), type, | |
| 970 | 989 | dat->len); | |
| 971 | - | the_hash_algo->init_fn(&c); | |
| 990 | + | git_hash_init(&c, the_hash_algo); | |
| 972 | 991 | git_hash_update(&c, hdr, hdrlen); | |
| 973 | 992 | git_hash_update(&c, dat->buf, dat->len); | |
| 974 | 993 | git_hash_final_oid(&oid, &c); | |
| @@ -997,15 +1016,17 @@ static int store_object( | |||
| 997 | 1016 | ||
| 998 | 1017 | if (last && last->data.len && last->data.buf && last->depth < max_depth | |
| 999 | 1018 | && dat->len > the_hash_algo->rawsz) { | |
| 1019 | + | size_t deltalen_st; | |
| 1000 | 1020 | ||
| 1001 | 1021 | delta_count_attempts_by_type[type]++; | |
| 1002 | 1022 | delta = diff_delta(last->data.buf, last->data.len, | |
| 1003 | 1023 | dat->buf, dat->len, | |
| 1004 | - | &deltalen, dat->len - the_hash_algo->rawsz); | |
| 1024 | + | &deltalen_st, dat->len - the_hash_algo->rawsz); | |
| 1025 | + | deltalen = cast_size_t_to_ulong(deltalen_st); | |
| 1005 | 1026 | } else | |
| 1006 | 1027 | delta = NULL; | |
| 1007 | 1028 | ||
| 1008 | - | git_deflate_init(&s, pack_compression_level); | |
| 1029 | + | git_deflate_init(&s, cfg->pack_compression_level); | |
| 1009 | 1030 | if (delta) { | |
| 1010 | 1031 | s.next_in = delta; | |
| 1011 | 1032 | s.avail_in = deltalen; | |
| @@ -1032,7 +1053,7 @@ static int store_object( | |||
| 1032 | 1053 | if (delta) { | |
| 1033 | 1054 | FREE_AND_NULL(delta); | |
| 1034 | 1055 | ||
| 1035 | - | git_deflate_init(&s, pack_compression_level); | |
| 1056 | + | git_deflate_init(&s, cfg->pack_compression_level); | |
| 1036 | 1057 | s.next_in = (void *)dat->buf; | |
| 1037 | 1058 | s.avail_in = dat->len; | |
| 1038 | 1059 | s.avail_out = git_deflate_bound(&s, s.avail_in); | |
| @@ -1115,6 +1136,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark) | |||
| 1115 | 1136 | struct git_hash_ctx c; | |
| 1116 | 1137 | git_zstream s; | |
| 1117 | 1138 | struct hashfile_checkpoint checkpoint; | |
| 1139 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 1118 | 1140 | int status = Z_OK; | |
| 1119 | 1141 | ||
| 1120 | 1142 | /* Determine if we should auto-checkpoint. */ | |
| @@ -1129,12 +1151,12 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark) | |||
| 1129 | 1151 | ||
| 1130 | 1152 | hdrlen = format_object_header((char *)out_buf, out_sz, OBJ_BLOB, len); | |
| 1131 | 1153 | ||
| 1132 | - | the_hash_algo->init_fn(&c); | |
| 1154 | + | git_hash_init(&c, the_hash_algo); | |
| 1133 | 1155 | git_hash_update(&c, out_buf, hdrlen); | |
| 1134 | 1156 | ||
| 1135 | 1157 | crc32_begin(pack_file); | |
| 1136 | 1158 | ||
| 1137 | - | git_deflate_init(&s, pack_compression_level); | |
| 1159 | + | git_deflate_init(&s, cfg->pack_compression_level); | |
| 1138 | 1160 | ||
| 1139 | 1161 | hdrlen = encode_in_pack_object_header(out_buf, out_sz, OBJ_BLOB, len); | |
| 1140 | 1162 | ||
| @@ -1214,6 +1236,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark) | |||
| 1214 | 1236 | out: | |
| 1215 | 1237 | free(in_buf); | |
| 1216 | 1238 | free(out_buf); | |
| 1239 | + | hashfile_checkpoint_release(&checkpoint); | |
| 1217 | 1240 | } | |
| 1218 | 1241 | ||
| 1219 | 1242 | /* All calls must be guarded by find_object() or find_mark() to | |
| @@ -1239,6 +1262,8 @@ static void *gfi_unpack_entry( | |||
| 1239 | 1262 | unsigned long *sizep) | |
| 1240 | 1263 | { | |
| 1241 | 1264 | enum object_type type; | |
| 1265 | + | size_t size_st = 0; | |
| 1266 | + | void *data; | |
| 1242 | 1267 | struct packed_git *p = all_packs[oe->pack_id]; | |
| 1243 | 1268 | if (p == pack_data && p->pack_size < (pack_size + the_hash_algo->rawsz)) { | |
| 1244 | 1269 | /* The object is stored in the packfile we are writing to | |
| @@ -1260,7 +1285,10 @@ static void *gfi_unpack_entry( | |||
| 1260 | 1285 | */ | |
| 1261 | 1286 | p->pack_size = pack_size + the_hash_algo->rawsz; | |
| 1262 | 1287 | } | |
| 1263 | - | return unpack_entry(the_repository, p, oe->idx.offset, &type, sizep); | |
| 1288 | + | data = unpack_entry(the_repository, p, oe->idx.offset, &type, &size_st); | |
| 1289 | + | if (sizep) | |
| 1290 | + | *sizep = cast_size_t_to_ulong(size_st); | |
| 1291 | + | return data; | |
| 1264 | 1292 | } | |
| 1265 | 1293 | ||
| 1266 | 1294 | static void load_tree(struct tree_entry *root) | |
| @@ -1286,7 +1314,10 @@ static void load_tree(struct tree_entry *root) | |||
| 1286 | 1314 | die(_("can't load tree %s"), oid_to_hex(oid)); | |
| 1287 | 1315 | } else { | |
| 1288 | 1316 | enum object_type type; | |
| 1289 | - | buf = odb_read_object(the_repository->objects, oid, &type, &size); | |
| 1317 | + | size_t size_st = 0; | |
| 1318 | + | buf = odb_read_object(the_repository->objects, oid, &type, | |
| 1319 | + | &size_st); | |
| 1320 | + | size = cast_size_t_to_ulong(size_st); | |
| 1290 | 1321 | if (!buf || type != OBJ_TREE) | |
| 1291 | 1322 | die(_("can't load tree %s"), oid_to_hex(oid)); | |
| 1292 | 1323 | } | |
| @@ -1834,7 +1865,7 @@ done: | |||
| 1834 | 1865 | } | |
| 1835 | 1866 | ||
| 1836 | 1867 | ||
| 1837 | - | static int read_next_command(void) | |
| 1868 | + | static int read_next_command(struct fast_import_state *state) | |
| 1838 | 1869 | { | |
| 1839 | 1870 | static int stdin_eof = 0; | |
| 1840 | 1871 | ||
| @@ -1853,10 +1884,10 @@ static int read_next_command(void) | |||
| 1853 | 1884 | if (stdin_eof) | |
| 1854 | 1885 | return EOF; | |
| 1855 | 1886 | ||
| 1856 | - | if (!seen_data_command | |
| 1887 | + | if (!state->seen_data_command | |
| 1857 | 1888 | && !starts_with(command_buf.buf, "feature ") | |
| 1858 | 1889 | && !starts_with(command_buf.buf, "option ")) { | |
| 1859 | - | parse_argv(); | |
| 1890 | + | parse_argv(state); | |
| 1860 | 1891 | } | |
| 1861 | 1892 | ||
| 1862 | 1893 | rc = rc_free; | |
| @@ -1888,22 +1919,22 @@ static void skip_optional_lf(void) | |||
| 1888 | 1919 | ungetc(term_char, stdin); | |
| 1889 | 1920 | } | |
| 1890 | 1921 | ||
| 1891 | - | static void parse_mark(void) | |
| 1922 | + | static void parse_mark(struct fast_import_state *state) | |
| 1892 | 1923 | { | |
| 1893 | 1924 | const char *v; | |
| 1894 | 1925 | if (skip_prefix(command_buf.buf, "mark :", &v)) { | |
| 1895 | 1926 | next_mark = strtoumax(v, NULL, 10); | |
| 1896 | - | read_next_command(); | |
| 1927 | + | read_next_command(state); | |
| 1897 | 1928 | } | |
| 1898 | 1929 | else | |
| 1899 | 1930 | next_mark = 0; | |
| 1900 | 1931 | } | |
| 1901 | 1932 | ||
| 1902 | - | static void parse_original_identifier(void) | |
| 1933 | + | static void parse_original_identifier(struct fast_import_state *state) | |
| 1903 | 1934 | { | |
| 1904 | 1935 | const char *v; | |
| 1905 | 1936 | if (skip_prefix(command_buf.buf, "original-oid ", &v)) | |
| 1906 | - | read_next_command(); | |
| 1937 | + | read_next_command(state); | |
| 1907 | 1938 | } | |
| 1908 | 1939 | ||
| 1909 | 1940 | static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res) | |
| @@ -2057,11 +2088,11 @@ static void parse_and_store_blob( | |||
| 2057 | 2088 | } | |
| 2058 | 2089 | } | |
| 2059 | 2090 | ||
| 2060 | - | static void parse_new_blob(void) | |
| 2091 | + | static void parse_new_blob(struct fast_import_state *state) | |
| 2061 | 2092 | { | |
| 2062 | - | read_next_command(); | |
| 2063 | - | parse_mark(); | |
| 2064 | - | parse_original_identifier(); | |
| 2093 | + | read_next_command(state); | |
| 2094 | + | parse_mark(state); | |
| 2095 | + | parse_original_identifier(state); | |
| 2065 | 2096 | parse_and_store_blob(&last_blob, NULL, next_mark); | |
| 2066 | 2097 | } | |
| 2067 | 2098 | ||
| @@ -2357,7 +2388,9 @@ static void parse_path_space(struct strbuf *sb, const char *p, | |||
| 2357 | 2388 | (*endp)++; | |
| 2358 | 2389 | } | |
| 2359 | 2390 | ||
| 2360 | - | static void file_change_m(const char *p, struct branch *b) | |
| 2391 | + | static void file_change_m(struct fast_import_state *state, | |
| 2392 | + | const char *p, | |
| 2393 | + | struct branch *b) | |
| 2361 | 2394 | { | |
| 2362 | 2395 | static struct strbuf path = STRBUF_INIT; | |
| 2363 | 2396 | struct object_entry *oe; | |
| @@ -2424,10 +2457,10 @@ static void file_change_m(const char *p, struct branch *b) | |||
| 2424 | 2457 | if (S_ISDIR(mode)) | |
| 2425 | 2458 | die(_("directories cannot be specified 'inline': %s"), | |
| 2426 | 2459 | command_buf.buf); | |
| 2427 | - | while (read_next_command() != EOF) { | |
| 2460 | + | while (read_next_command(state) != EOF) { | |
| 2428 | 2461 | const char *v; | |
| 2429 | 2462 | if (skip_prefix(command_buf.buf, "cat-blob ", &v)) | |
| 2430 | - | parse_cat_blob(v); | |
| 2463 | + | parse_cat_blob(state, v); | |
| 2431 | 2464 | else { | |
| 2432 | 2465 | parse_and_store_blob(&last_blob, &oid, 0); | |
| 2433 | 2466 | break; | |
| @@ -2501,7 +2534,10 @@ static void file_change_cr(const char *p, struct branch *b, int rename) | |||
| 2501 | 2534 | leaf.tree); | |
| 2502 | 2535 | } | |
| 2503 | 2536 | ||
| 2504 | - | static void note_change_n(const char *p, struct branch *b, unsigned char *old_fanout) | |
| 2537 | + | static void note_change_n(struct fast_import_state *state, | |
| 2538 | + | const char *p, | |
| 2539 | + | struct branch *b, | |
| 2540 | + | unsigned char *old_fanout) | |
| 2505 | 2541 | { | |
| 2506 | 2542 | struct object_entry *oe; | |
| 2507 | 2543 | struct branch *s; | |
| @@ -2555,7 +2591,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa | |||
| 2555 | 2591 | die(_("mark :%" PRIuMAX " not a commit"), commit_mark); | |
| 2556 | 2592 | oidcpy(&commit_oid, &commit_oe->idx.oid); | |
| 2557 | 2593 | } else if (!repo_get_oid(the_repository, p, &commit_oid)) { | |
| 2558 | - | unsigned long size; | |
| 2594 | + | size_t size; | |
| 2559 | 2595 | char *buf = odb_read_object_peeled(the_repository->objects, | |
| 2560 | 2596 | &commit_oid, OBJ_COMMIT, &size, | |
| 2561 | 2597 | &commit_oid); | |
| @@ -2566,7 +2602,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa | |||
| 2566 | 2602 | die(_("invalid ref name or SHA1 expression: %s"), p); | |
| 2567 | 2603 | ||
| 2568 | 2604 | if (inline_data) { | |
| 2569 | - | read_next_command(); | |
| 2605 | + | read_next_command(state); | |
| 2570 | 2606 | parse_and_store_blob(&last_blob, &oid, 0); | |
| 2571 | 2607 | } else if (oe) { | |
| 2572 | 2608 | if (oe->type != OBJ_BLOB) | |
| @@ -2622,16 +2658,20 @@ static void parse_from_existing(struct branch *b) | |||
| 2622 | 2658 | oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo); | |
| 2623 | 2659 | } else { | |
| 2624 | 2660 | unsigned long size; | |
| 2661 | + | size_t size_st = 0; | |
| 2625 | 2662 | char *buf; | |
| 2626 | 2663 | ||
| 2627 | 2664 | buf = odb_read_object_peeled(the_repository->objects, &b->oid, | |
| 2628 | - | OBJ_COMMIT, &size, &b->oid); | |
| 2665 | + | OBJ_COMMIT, &size_st, &b->oid); | |
| 2666 | + | size = cast_size_t_to_ulong(size_st); | |
| 2629 | 2667 | parse_from_commit(b, buf, size); | |
| 2630 | 2668 | free(buf); | |
| 2631 | 2669 | } | |
| 2632 | 2670 | } | |
| 2633 | 2671 | ||
| 2634 | - | static int parse_objectish(struct branch *b, const char *objectish) | |
| 2672 | + | static int parse_objectish(struct fast_import_state *state, | |
| 2673 | + | struct branch *b, | |
| 2674 | + | const char *objectish) | |
| 2635 | 2675 | { | |
| 2636 | 2676 | struct branch *s; | |
| 2637 | 2677 | struct object_id oid; | |
| @@ -2674,31 +2714,34 @@ static int parse_objectish(struct branch *b, const char *objectish) | |||
| 2674 | 2714 | b->branch_tree.tree = NULL; | |
| 2675 | 2715 | } | |
| 2676 | 2716 | ||
| 2677 | - | read_next_command(); | |
| 2717 | + | read_next_command(state); | |
| 2678 | 2718 | return 1; | |
| 2679 | 2719 | } | |
| 2680 | 2720 | ||
| 2681 | - | static int parse_from(struct branch *b) | |
| 2721 | + | static int parse_from(struct fast_import_state *state, struct branch *b) | |
| 2682 | 2722 | { | |
| 2683 | 2723 | const char *from; | |
| 2684 | 2724 | ||
| 2685 | 2725 | if (!skip_prefix(command_buf.buf, "from ", &from)) | |
| 2686 | 2726 | return 0; | |
| 2687 | 2727 | ||
| 2688 | - | return parse_objectish(b, from); | |
| 2728 | + | return parse_objectish(state, b, from); | |
| 2689 | 2729 | } | |
| 2690 | 2730 | ||
| 2691 | - | static int parse_objectish_with_prefix(struct branch *b, const char *prefix) | |
| 2731 | + | static int parse_objectish_with_prefix(struct fast_import_state *state, | |
| 2732 | + | struct branch *b, | |
| 2733 | + | const char *prefix) | |
| 2692 | 2734 | { | |
| 2693 | 2735 | const char *base; | |
| 2694 | 2736 | ||
| 2695 | 2737 | if (!skip_prefix(command_buf.buf, prefix, &base)) | |
| 2696 | 2738 | return 0; | |
| 2697 | 2739 | ||
| 2698 | - | return parse_objectish(b, base); | |
| 2740 | + | return parse_objectish(state, b, base); | |
| 2699 | 2741 | } | |
| 2700 | 2742 | ||
| 2701 | - | static struct hash_list *parse_merge(unsigned int *count) | |
| 2743 | + | static struct hash_list *parse_merge(struct fast_import_state *state, | |
| 2744 | + | unsigned int *count) | |
| 2702 | 2745 | { | |
| 2703 | 2746 | struct hash_list *list = NULL, **tail = &list, *n; | |
| 2704 | 2747 | const char *from; | |
| @@ -2717,7 +2760,7 @@ static struct hash_list *parse_merge(unsigned int *count) | |||
| 2717 | 2760 | die(_("mark :%" PRIuMAX " not a commit"), idnum); | |
| 2718 | 2761 | oidcpy(&n->oid, &oe->idx.oid); | |
| 2719 | 2762 | } else if (!repo_get_oid(the_repository, from, &n->oid)) { | |
| 2720 | - | unsigned long size; | |
| 2763 | + | size_t size; | |
| 2721 | 2764 | char *buf = odb_read_object_peeled(the_repository->objects, | |
| 2722 | 2765 | &n->oid, OBJ_COMMIT, | |
| 2723 | 2766 | &size, &n->oid); | |
| @@ -2732,7 +2775,7 @@ static struct hash_list *parse_merge(unsigned int *count) | |||
| 2732 | 2775 | tail = &n->next; | |
| 2733 | 2776 | ||
| 2734 | 2777 | (*count)++; | |
| 2735 | - | read_next_command(); | |
| 2778 | + | read_next_command(state); | |
| 2736 | 2779 | } | |
| 2737 | 2780 | return list; | |
| 2738 | 2781 | } | |
| @@ -2743,7 +2786,9 @@ struct signature_data { | |||
| 2743 | 2786 | struct strbuf data; /* The actual signature data */ | |
| 2744 | 2787 | }; | |
| 2745 | 2788 | ||
| 2746 | - | static void parse_one_signature(struct signature_data *sig, const char *v) | |
| 2789 | + | static void parse_one_signature(struct fast_import_state *state, | |
| 2790 | + | struct signature_data *sig, | |
| 2791 | + | const char *v) | |
| 2747 | 2792 | { | |
| 2748 | 2793 | char *args = xstrdup(v); /* Will be freed when sig->hash_algo is freed */ | |
| 2749 | 2794 | char *space = strchr(args, ' '); | |
| @@ -2768,15 +2813,15 @@ static void parse_one_signature(struct signature_data *sig, const char *v) | |||
| 2768 | 2813 | warning(_("'unknown' signature format in gpgsig")); | |
| 2769 | 2814 | ||
| 2770 | 2815 | /* Read signature data */ | |
| 2771 | - | read_next_command(); | |
| 2816 | + | read_next_command(state); | |
| 2772 | 2817 | parse_data(&sig->data, 0, NULL); | |
| 2773 | 2818 | } | |
| 2774 | 2819 | ||
| 2775 | - | static void discard_one_signature(void) | |
| 2820 | + | static void discard_one_signature(struct fast_import_state *state) | |
| 2776 | 2821 | { | |
| 2777 | 2822 | struct strbuf data = STRBUF_INIT; | |
| 2778 | 2823 | ||
| 2779 | - | read_next_command(); | |
| 2824 | + | read_next_command(state); | |
| 2780 | 2825 | parse_data(&data, 0, NULL); | |
| 2781 | 2826 | strbuf_release(&data); | |
| 2782 | 2827 | } | |
| @@ -2814,13 +2859,14 @@ static void store_signature(struct signature_data *stored_sig, | |||
| 2814 | 2859 | } | |
| 2815 | 2860 | } | |
| 2816 | 2861 | ||
| 2817 | - | static void import_one_signature(struct signature_data *sig_sha1, | |
| 2862 | + | static void import_one_signature(struct fast_import_state *state, | |
| 2863 | + | struct signature_data *sig_sha1, | |
| 2818 | 2864 | struct signature_data *sig_sha256, | |
| 2819 | 2865 | const char *v) | |
| 2820 | 2866 | { | |
| 2821 | 2867 | struct signature_data sig = { NULL, NULL, STRBUF_INIT }; | |
| 2822 | 2868 | ||
| 2823 | - | parse_one_signature(&sig, v); | |
| 2869 | + | parse_one_signature(state, &sig, v); | |
| 2824 | 2870 | ||
| 2825 | 2871 | if (!strcmp(sig.hash_algo, "sha1")) | |
| 2826 | 2872 | store_signature(sig_sha1, &sig, "SHA-1"); | |
| @@ -2934,7 +2980,7 @@ static void handle_signature_if_invalid(struct strbuf *new_data, | |||
| 2934 | 2980 | strbuf_release(&tmp_buf); | |
| 2935 | 2981 | } | |
| 2936 | 2982 | ||
| 2937 | - | static void parse_new_commit(const char *arg) | |
| 2983 | + | static void parse_new_commit(struct fast_import_state *state, const char *arg) | |
| 2938 | 2984 | { | |
| 2939 | 2985 | static struct strbuf msg = STRBUF_INIT; | |
| 2940 | 2986 | struct signature_data sig_sha1 = { NULL, NULL, STRBUF_INIT }; | |
| @@ -2952,16 +2998,16 @@ static void parse_new_commit(const char *arg) | |||
| 2952 | 2998 | if (!b) | |
| 2953 | 2999 | b = new_branch(arg); | |
| 2954 | 3000 | ||
| 2955 | - | read_next_command(); | |
| 2956 | - | parse_mark(); | |
| 2957 | - | parse_original_identifier(); | |
| 3001 | + | read_next_command(state); | |
| 3002 | + | parse_mark(state); | |
| 3003 | + | parse_original_identifier(state); | |
| 2958 | 3004 | if (skip_prefix(command_buf.buf, "author ", &v)) { | |
| 2959 | 3005 | author = parse_ident(v); | |
| 2960 | - | read_next_command(); | |
| 3006 | + | read_next_command(state); | |
| 2961 | 3007 | } | |
| 2962 | 3008 | if (skip_prefix(command_buf.buf, "committer ", &v)) { | |
| 2963 | 3009 | committer = parse_ident(v); | |
| 2964 | - | read_next_command(); | |
| 3010 | + | read_next_command(state); | |
| 2965 | 3011 | } | |
| 2966 | 3012 | if (!committer) | |
| 2967 | 3013 | die(_("expected committer but didn't get one")); | |
| @@ -2977,7 +3023,7 @@ static void parse_new_commit(const char *arg) | |||
| 2977 | 3023 | warning(_("stripping a commit signature")); | |
| 2978 | 3024 | /* fallthru */ | |
| 2979 | 3025 | case SIGN_STRIP: | |
| 2980 | - | discard_one_signature(); | |
| 3026 | + | discard_one_signature(state); | |
| 2981 | 3027 | break; | |
| 2982 | 3028 | ||
| 2983 | 3029 | /* Second, modes that parse the signature */ | |
| @@ -2988,24 +3034,24 @@ static void parse_new_commit(const char *arg) | |||
| 2988 | 3034 | case SIGN_STRIP_IF_INVALID: | |
| 2989 | 3035 | case SIGN_SIGN_IF_INVALID: | |
| 2990 | 3036 | case SIGN_ABORT_IF_INVALID: | |
| 2991 | - | import_one_signature(&sig_sha1, &sig_sha256, v); | |
| 3037 | + | import_one_signature(state, &sig_sha1, &sig_sha256, v); | |
| 2992 | 3038 | break; | |
| 2993 | 3039 | ||
| 2994 | 3040 | /* Third, BUG */ | |
| 2995 | 3041 | default: | |
| 2996 | 3042 | BUG("invalid signed_commit_mode value %d", signed_commit_mode); | |
| 2997 | 3043 | } | |
| 2998 | - | read_next_command(); | |
| 3044 | + | read_next_command(state); | |
| 2999 | 3045 | } | |
| 3000 | 3046 | ||
| 3001 | 3047 | if (skip_prefix(command_buf.buf, "encoding ", &v)) { | |
| 3002 | 3048 | encoding = xstrdup(v); | |
| 3003 | - | read_next_command(); | |
| 3049 | + | read_next_command(state); | |
| 3004 | 3050 | } | |
| 3005 | 3051 | parse_data(&msg, 0, NULL); | |
| 3006 | - | read_next_command(); | |
| 3007 | - | parse_from(b); | |
| 3008 | - | merge_list = parse_merge(&merge_count); | |
| 3052 | + | read_next_command(state); | |
| 3053 | + | parse_from(state, b); | |
| 3054 | + | merge_list = parse_merge(state, &merge_count); | |
| 3009 | 3055 | ||
| 3010 | 3056 | /* ensure the branch is active/loaded */ | |
| 3011 | 3057 | if (!b->branch_tree.tree || !max_active_branches) { | |
| @@ -3018,7 +3064,7 @@ static void parse_new_commit(const char *arg) | |||
| 3018 | 3064 | /* file_change* */ | |
| 3019 | 3065 | while (command_buf.len > 0) { | |
| 3020 | 3066 | if (skip_prefix(command_buf.buf, "M ", &v)) | |
| 3021 | - | file_change_m(v, b); | |
| 3067 | + | file_change_m(state, v, b); | |
| 3022 | 3068 | else if (skip_prefix(command_buf.buf, "D ", &v)) | |
| 3023 | 3069 | file_change_d(v, b); | |
| 3024 | 3070 | else if (skip_prefix(command_buf.buf, "R ", &v)) | |
| @@ -3026,18 +3072,18 @@ static void parse_new_commit(const char *arg) | |||
| 3026 | 3072 | else if (skip_prefix(command_buf.buf, "C ", &v)) | |
| 3027 | 3073 | file_change_cr(v, b, 0); | |
| 3028 | 3074 | else if (skip_prefix(command_buf.buf, "N ", &v)) | |
| 3029 | - | note_change_n(v, b, &prev_fanout); | |
| 3075 | + | note_change_n(state, v, b, &prev_fanout); | |
| 3030 | 3076 | else if (!strcmp("deleteall", command_buf.buf)) | |
| 3031 | 3077 | file_change_deleteall(b); | |
| 3032 | 3078 | else if (skip_prefix(command_buf.buf, "ls ", &v)) | |
| 3033 | - | parse_ls(v, b); | |
| 3079 | + | parse_ls(state, v, b); | |
| 3034 | 3080 | else if (skip_prefix(command_buf.buf, "cat-blob ", &v)) | |
| 3035 | - | parse_cat_blob(v); | |
| 3081 | + | parse_cat_blob(state, v); | |
| 3036 | 3082 | else { | |
| 3037 | 3083 | unread_command_buf = 1; | |
| 3038 | 3084 | break; | |
| 3039 | 3085 | } | |
| 3040 | - | if (read_next_command() == EOF) | |
| 3086 | + | if (read_next_command(state) == EOF) | |
| 3041 | 3087 | break; | |
| 3042 | 3088 | } | |
| 3043 | 3089 | ||
| @@ -3175,7 +3221,7 @@ static void handle_tag_signature(struct strbuf *buf, struct strbuf *msg, const c | |||
| 3175 | 3221 | } | |
| 3176 | 3222 | } | |
| 3177 | 3223 | ||
| 3178 | - | static void parse_new_tag(const char *arg) | |
| 3224 | + | static void parse_new_tag(struct fast_import_state *state, const char *arg) | |
| 3179 | 3225 | { | |
| 3180 | 3226 | static struct strbuf msg = STRBUF_INIT; | |
| 3181 | 3227 | const char *from; | |
| @@ -3194,8 +3240,8 @@ static void parse_new_tag(const char *arg) | |||
| 3194 | 3240 | else | |
| 3195 | 3241 | first_tag = t; | |
| 3196 | 3242 | last_tag = t; | |
| 3197 | - | read_next_command(); | |
| 3198 | - | parse_mark(); | |
| 3243 | + | read_next_command(state); | |
| 3244 | + | parse_mark(state); | |
| 3199 | 3245 | ||
| 3200 | 3246 | /* from ... */ | |
| 3201 | 3247 | if (!skip_prefix(command_buf.buf, "from ", &from)) | |
| @@ -3223,15 +3269,15 @@ static void parse_new_tag(const char *arg) | |||
| 3223 | 3269 | type = oe->type; | |
| 3224 | 3270 | } else | |
| 3225 | 3271 | die(_("invalid ref name or SHA1 expression: %s"), from); | |
| 3226 | - | read_next_command(); | |
| 3272 | + | read_next_command(state); | |
| 3227 | 3273 | ||
| 3228 | 3274 | /* original-oid ... */ | |
| 3229 | - | parse_original_identifier(); | |
| 3275 | + | parse_original_identifier(state); | |
| 3230 | 3276 | ||
| 3231 | 3277 | /* tagger ... */ | |
| 3232 | 3278 | if (skip_prefix(command_buf.buf, "tagger ", &v)) { | |
| 3233 | 3279 | tagger = parse_ident(v); | |
| 3234 | - | read_next_command(); | |
| 3280 | + | read_next_command(state); | |
| 3235 | 3281 | } else | |
| 3236 | 3282 | tagger = NULL; | |
| 3237 | 3283 | ||
| @@ -3262,7 +3308,7 @@ static void parse_new_tag(const char *arg) | |||
| 3262 | 3308 | t->pack_id = pack_id; | |
| 3263 | 3309 | } | |
| 3264 | 3310 | ||
| 3265 | - | static void parse_reset_branch(const char *arg) | |
| 3311 | + | static void parse_reset_branch(struct fast_import_state *state, const char *arg) | |
| 3266 | 3312 | { | |
| 3267 | 3313 | struct branch *b; | |
| 3268 | 3314 | const char *tag_name; | |
| @@ -3279,8 +3325,8 @@ static void parse_reset_branch(const char *arg) | |||
| 3279 | 3325 | } | |
| 3280 | 3326 | else | |
| 3281 | 3327 | b = new_branch(arg); | |
| 3282 | - | read_next_command(); | |
| 3283 | - | parse_from(b); | |
| 3328 | + | read_next_command(state); | |
| 3329 | + | parse_from(state, b); | |
| 3284 | 3330 | if (b->delete && skip_prefix(b->name, "refs/tags/", &tag_name)) { | |
| 3285 | 3331 | /* | |
| 3286 | 3332 | * Elsewhere, we call dump_branches() before dump_tags(), | |
| @@ -3320,12 +3366,16 @@ static void cat_blob_write(const char *buf, unsigned long size) | |||
| 3320 | 3366 | static void cat_blob(struct object_entry *oe, struct object_id *oid) | |
| 3321 | 3367 | { | |
| 3322 | 3368 | struct strbuf line = STRBUF_INIT; | |
| 3369 | + | struct iovec iov[3]; | |
| 3323 | 3370 | unsigned long size; | |
| 3324 | 3371 | enum object_type type = 0; | |
| 3325 | 3372 | char *buf; | |
| 3326 | 3373 | ||
| 3327 | 3374 | if (!oe || oe->pack_id == MAX_PACK_ID) { | |
| 3328 | - | buf = odb_read_object(the_repository->objects, oid, &type, &size); | |
| 3375 | + | size_t size_st = 0; | |
| 3376 | + | buf = odb_read_object(the_repository->objects, oid, &type, | |
| 3377 | + | &size_st); | |
| 3378 | + | size = cast_size_t_to_ulong(size_st); | |
| 3329 | 3379 | } else { | |
| 3330 | 3380 | type = oe->type; | |
| 3331 | 3381 | buf = gfi_unpack_entry(oe, &size); | |
| @@ -3350,10 +3400,21 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid) | |||
| 3350 | 3400 | strbuf_reset(&line); | |
| 3351 | 3401 | strbuf_addf(&line, "%s %s %"PRIuMAX"\n", oid_to_hex(oid), | |
| 3352 | 3402 | type_name(type), (uintmax_t)size); | |
| 3353 | - | cat_blob_write(line.buf, line.len); | |
| 3403 | + | ||
| 3404 | + | /* | |
| 3405 | + | * Write the header, the payload and the trailing newline with a | |
| 3406 | + | * single writev(3p) call instead of three separate write(3p) calls. | |
| 3407 | + | */ | |
| 3408 | + | iov[0].iov_base = line.buf; | |
| 3409 | + | iov[0].iov_len = line.len; | |
| 3410 | + | iov[1].iov_base = buf; | |
| 3411 | + | iov[1].iov_len = size; | |
| 3412 | + | iov[2].iov_base = (void *) "\n"; | |
| 3413 | + | iov[2].iov_len = 1; | |
| 3414 | + | ||
| 3415 | + | if (writev_in_full(cat_blob_fd, iov, ARRAY_SIZE(iov)) < 0) | |
| 3416 | + | die_errno(_("write to frontend failed")); | |
| 3354 | 3417 | strbuf_release(&line); | |
| 3355 | - | cat_blob_write(buf, size); | |
| 3356 | - | cat_blob_write("\n", 1); | |
| 3357 | 3418 | if (oe && oe->pack_id == pack_id) { | |
| 3358 | 3419 | last_blob.offset = oe->idx.offset; | |
| 3359 | 3420 | strbuf_attach(&last_blob.data, buf, size, size + 1); | |
| @@ -3362,7 +3423,8 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid) | |||
| 3362 | 3423 | free(buf); | |
| 3363 | 3424 | } | |
| 3364 | 3425 | ||
| 3365 | - | static void parse_get_mark(const char *p) | |
| 3426 | + | static void parse_get_mark(struct fast_import_state *state UNUSED, | |
| 3427 | + | const char *p) | |
| 3366 | 3428 | { | |
| 3367 | 3429 | struct object_entry *oe; | |
| 3368 | 3430 | char output[GIT_MAX_HEXSZ + 2]; | |
| @@ -3379,7 +3441,8 @@ static void parse_get_mark(const char *p) | |||
| 3379 | 3441 | cat_blob_write(output, the_hash_algo->hexsz + 1); | |
| 3380 | 3442 | } | |
| 3381 | 3443 | ||
| 3382 | - | static void parse_cat_blob(const char *p) | |
| 3444 | + | static void parse_cat_blob(struct fast_import_state *state UNUSED, | |
| 3445 | + | const char *p) | |
| 3383 | 3446 | { | |
| 3384 | 3447 | struct object_entry *oe; | |
| 3385 | 3448 | struct object_id oid; | |
| @@ -3433,8 +3496,10 @@ static struct object_entry *dereference(struct object_entry *oe, | |||
| 3433 | 3496 | buf = gfi_unpack_entry(oe, &size); | |
| 3434 | 3497 | } else { | |
| 3435 | 3498 | enum object_type unused; | |
| 3499 | + | size_t size_st = 0; | |
| 3436 | 3500 | buf = odb_read_object(the_repository->objects, oid, | |
| 3437 | - | &unused, &size); | |
| 3501 | + | &unused, &size_st); | |
| 3502 | + | size = cast_size_t_to_ulong(size_st); | |
| 3438 | 3503 | } | |
| 3439 | 3504 | if (!buf) | |
| 3440 | 3505 | die(_("can't load object %s"), oid_to_hex(oid)); | |
| @@ -3542,7 +3607,9 @@ static void print_ls(int mode, const unsigned char *hash, const char *path) | |||
| 3542 | 3607 | cat_blob_write(line.buf, line.len); | |
| 3543 | 3608 | } | |
| 3544 | 3609 | ||
| 3545 | - | static void parse_ls(const char *p, struct branch *b) | |
| 3610 | + | static void parse_ls(struct fast_import_state *state UNUSED, | |
| 3611 | + | const char *p, | |
| 3612 | + | struct branch *b) | |
| 3546 | 3613 | { | |
| 3547 | 3614 | static struct strbuf path = STRBUF_INIT; | |
| 3548 | 3615 | struct tree_entry *root = NULL; | |
| @@ -3589,13 +3656,13 @@ static void checkpoint(void) | |||
| 3589 | 3656 | dump_marks(); | |
| 3590 | 3657 | } | |
| 3591 | 3658 | ||
| 3592 | - | static void parse_checkpoint(void) | |
| 3659 | + | static void parse_checkpoint(struct fast_import_state *state UNUSED) | |
| 3593 | 3660 | { | |
| 3594 | 3661 | checkpoint_requested = 1; | |
| 3595 | 3662 | skip_optional_lf(); | |
| 3596 | 3663 | } | |
| 3597 | 3664 | ||
| 3598 | - | static void parse_progress(void) | |
| 3665 | + | static void parse_progress(struct fast_import_state *state UNUSED) | |
| 3599 | 3666 | { | |
| 3600 | 3667 | fwrite(command_buf.buf, 1, command_buf.len, stdout); | |
| 3601 | 3668 | fputc('\n', stdout); | |
| @@ -3603,37 +3670,40 @@ static void parse_progress(void) | |||
| 3603 | 3670 | skip_optional_lf(); | |
| 3604 | 3671 | } | |
| 3605 | 3672 | ||
| 3606 | - | static void parse_alias(void) | |
| 3673 | + | static void parse_alias(struct fast_import_state *state) | |
| 3607 | 3674 | { | |
| 3608 | 3675 | struct object_entry *e; | |
| 3609 | 3676 | struct branch b; | |
| 3610 | 3677 | ||
| 3611 | 3678 | skip_optional_lf(); | |
| 3612 | - | read_next_command(); | |
| 3679 | + | read_next_command(state); | |
| 3613 | 3680 | ||
| 3614 | 3681 | /* mark ... */ | |
| 3615 | - | parse_mark(); | |
| 3682 | + | parse_mark(state); | |
| 3616 | 3683 | if (!next_mark) | |
| 3617 | 3684 | die(_("expected 'mark' command, got %s"), command_buf.buf); | |
| 3618 | 3685 | ||
| 3619 | 3686 | /* to ... */ | |
| 3620 | 3687 | memset(&b, 0, sizeof(b)); | |
| 3621 | - | if (!parse_objectish_with_prefix(&b, "to ")) | |
| 3688 | + | if (!parse_objectish_with_prefix(state, &b, "to ")) | |
| 3622 | 3689 | die(_("expected 'to' command, got %s"), command_buf.buf); | |
| 3623 | 3690 | e = find_object(&b.oid); | |
| 3624 | 3691 | assert(e); | |
| 3625 | 3692 | insert_mark(&marks, next_mark, e); | |
| 3626 | 3693 | } | |
| 3627 | 3694 | ||
| 3628 | - | static char* make_fast_import_path(const char *path) | |
| 3695 | + | static char* make_fast_import_path(struct fast_import_state *state, | |
| 3696 | + | const char *path) | |
| 3629 | 3697 | { | |
| 3630 | 3698 | if (!relative_marks_paths || is_absolute_path(path)) | |
| 3631 | - | return prefix_filename(global_prefix, path); | |
| 3699 | + | return prefix_filename(state->prefix, path); | |
| 3632 | 3700 | return repo_git_path(the_repository, "info/fast-import/%s", path); | |
| 3633 | 3701 | } | |
| 3634 | 3702 | ||
| 3635 | - | static void option_import_marks(const char *marks, | |
| 3636 | - | int from_stream, int ignore_missing) | |
| 3703 | + | static void option_import_marks(struct fast_import_state *state, | |
| 3704 | + | const char *marks, | |
| 3705 | + | int from_stream, | |
| 3706 | + | int ignore_missing) | |
| 3637 | 3707 | { | |
| 3638 | 3708 | if (import_marks_file) { | |
| 3639 | 3709 | if (from_stream) | |
| @@ -3645,7 +3715,7 @@ static void option_import_marks(const char *marks, | |||
| 3645 | 3715 | } | |
| 3646 | 3716 | ||
| 3647 | 3717 | free(import_marks_file); | |
| 3648 | - | import_marks_file = make_fast_import_path(marks); | |
| 3718 | + | import_marks_file = make_fast_import_path(state, marks); | |
| 3649 | 3719 | import_marks_file_from_stream = from_stream; | |
| 3650 | 3720 | import_marks_file_ignore_missing = ignore_missing; | |
| 3651 | 3721 | } | |
| @@ -3685,13 +3755,15 @@ static void option_active_branches(const char *branches) | |||
| 3685 | 3755 | max_active_branches = ulong_arg("--active-branches", branches); | |
| 3686 | 3756 | } | |
| 3687 | 3757 | ||
| 3688 | - | static void option_export_marks(const char *marks) | |
| 3758 | + | static void option_export_marks(struct fast_import_state *state, | |
| 3759 | + | const char *marks) | |
| 3689 | 3760 | { | |
| 3690 | 3761 | free(export_marks_file); | |
| 3691 | - | export_marks_file = make_fast_import_path(marks); | |
| 3762 | + | export_marks_file = make_fast_import_path(state, marks); | |
| 3692 | 3763 | } | |
| 3693 | 3764 | ||
| 3694 | - | static void option_cat_blob_fd(const char *fd) | |
| 3765 | + | static void option_cat_blob_fd(struct fast_import_state *state UNUSED, | |
| 3766 | + | const char *fd) | |
| 3695 | 3767 | { | |
| 3696 | 3768 | unsigned long n = ulong_arg("--cat-blob-fd", fd); | |
| 3697 | 3769 | if (n > (unsigned long) INT_MAX) | |
| @@ -3699,16 +3771,19 @@ static void option_cat_blob_fd(const char *fd) | |||
| 3699 | 3771 | cat_blob_fd = (int) n; | |
| 3700 | 3772 | } | |
| 3701 | 3773 | ||
| 3702 | - | static void option_export_pack_edges(const char *edges) | |
| 3774 | + | static void option_export_pack_edges(struct fast_import_state *state, | |
| 3775 | + | const char *edges) | |
| 3703 | 3776 | { | |
| 3704 | - | char *fn = prefix_filename(global_prefix, edges); | |
| 3777 | + | char *fn = prefix_filename(state->prefix, edges); | |
| 3705 | 3778 | if (pack_edges) | |
| 3706 | 3779 | fclose(pack_edges); | |
| 3707 | 3780 | pack_edges = xfopen(fn, "a"); | |
| 3708 | 3781 | free(fn); | |
| 3709 | 3782 | } | |
| 3710 | 3783 | ||
| 3711 | - | static void option_rewrite_submodules(const char *arg, struct string_list *list) | |
| 3784 | + | static void option_rewrite_submodules(struct fast_import_state *state, | |
| 3785 | + | const char *arg, | |
| 3786 | + | struct string_list *list) | |
| 3712 | 3787 | { | |
| 3713 | 3788 | struct mark_set *ms; | |
| 3714 | 3789 | FILE *fp; | |
| @@ -3720,7 +3795,7 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list) | |||
| 3720 | 3795 | f++; | |
| 3721 | 3796 | CALLOC_ARRAY(ms, 1); | |
| 3722 | 3797 | ||
| 3723 | - | f = prefix_filename(global_prefix, f); | |
| 3798 | + | f = prefix_filename(state->prefix, f); | |
| 3724 | 3799 | fp = fopen(f, "r"); | |
| 3725 | 3800 | if (!fp) | |
| 3726 | 3801 | die_errno(_("cannot read '%s'"), f); | |
| @@ -3733,40 +3808,67 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list) | |||
| 3733 | 3808 | free(s); | |
| 3734 | 3809 | } | |
| 3735 | 3810 | ||
| 3736 | - | static int parse_one_option(const char *option) | |
| 3811 | + | static void option_max_pack_size(const char *arg) | |
| 3812 | + | { | |
| 3813 | + | unsigned long v; | |
| 3814 | + | ||
| 3815 | + | if (!git_parse_ulong(arg, &v)) | |
| 3816 | + | die(_("--max-pack-size: argument must be a non-negative integer")); | |
| 3817 | + | if (v < 8192) { | |
| 3818 | + | warning(_("max-pack-size is now in bytes, assuming --max-pack-size=%lum"), v); | |
| 3819 | + | v *= 1024 * 1024; | |
| 3820 | + | } else if (v < 1024 * 1024) { | |
| 3821 | + | warning(_("minimum max-pack-size is 1 MiB")); | |
| 3822 | + | v = 1024 * 1024; | |
| 3823 | + | } | |
| 3824 | + | max_packsize = v; | |
| 3825 | + | } | |
| 3826 | + | ||
| 3827 | + | static void option_big_file_threshold(const char *arg) | |
| 3828 | + | { | |
| 3829 | + | unsigned long v; | |
| 3830 | + | ||
| 3831 | + | if (!git_parse_ulong(arg, &v)) | |
| 3832 | + | die(_("--big-file-threshold: argument must be a non-negative integer")); | |
| 3833 | + | repo_settings_set_big_file_threshold(the_repository, v); | |
| 3834 | + | } | |
| 3835 | + | ||
| 3836 | + | static void option_signed_commits(const char *arg) | |
| 3837 | + | { | |
| 3838 | + | if (parse_sign_mode(arg, &signed_commit_mode, &signed_commit_keyid)) | |
| 3839 | + | usagef(_("unknown --signed-commits mode '%s'"), arg); | |
| 3840 | + | } | |
| 3841 | + | ||
| 3842 | + | static void option_signed_tags(const char *arg) | |
| 3843 | + | { | |
| 3844 | + | if (parse_sign_mode(arg, &signed_tag_mode, &signed_tag_keyid)) | |
| 3845 | + | usagef(_("unknown --signed-tags mode '%s'"), arg); | |
| 3846 | + | } | |
| 3847 | + | ||
| 3848 | + | static void option_quiet(void) | |
| 3849 | + | { | |
| 3850 | + | show_stats = 0; | |
| 3851 | + | quiet = 1; | |
| 3852 | + | } | |
| 3853 | + | ||
| 3854 | + | static int parse_one_option(struct fast_import_state *state, const char *option) | |
| 3737 | 3855 | { | |
| 3738 | 3856 | if (skip_prefix(option, "max-pack-size=", &option)) { | |
| 3739 | - | unsigned long v; | |
| 3740 | - | if (!git_parse_ulong(option, &v)) | |
| 3741 | - | return 0; | |
| 3742 | - | if (v < 8192) { | |
| 3743 | - | warning(_("max-pack-size is now in bytes, assuming --max-pack-size=%lum"), v); | |
| 3744 | - | v *= 1024 * 1024; | |
| 3745 | - | } else if (v < 1024 * 1024) { | |
| 3746 | - | warning(_("minimum max-pack-size is 1 MiB")); | |
| 3747 | - | v = 1024 * 1024; | |
| 3748 | - | } | |
| 3749 | - | max_packsize = v; | |
| 3857 | + | option_max_pack_size(option); | |
| 3750 | 3858 | } else if (skip_prefix(option, "big-file-threshold=", &option)) { | |
| 3751 | - | unsigned long v; | |
| 3752 | - | if (!git_parse_ulong(option, &v)) | |
| 3753 | - | return 0; | |
| 3754 | - | repo_settings_set_big_file_threshold(the_repository, v); | |
| 3859 | + | option_big_file_threshold(option); | |
| 3755 | 3860 | } else if (skip_prefix(option, "depth=", &option)) { | |
| 3756 | 3861 | option_depth(option); | |
| 3757 | 3862 | } else if (skip_prefix(option, "active-branches=", &option)) { | |
| 3758 | 3863 | option_active_branches(option); | |
| 3759 | 3864 | } else if (skip_prefix(option, "export-pack-edges=", &option)) { | |
| 3760 | - | option_export_pack_edges(option); | |
| 3865 | + | option_export_pack_edges(state, option); | |
| 3761 | 3866 | } else if (skip_prefix(option, "signed-commits=", &option)) { | |
| 3762 | - | if (parse_sign_mode(option, &signed_commit_mode, &signed_commit_keyid)) | |
| 3763 | - | usagef(_("unknown --signed-commits mode '%s'"), option); | |
| 3867 | + | option_signed_commits(option); | |
| 3764 | 3868 | } else if (skip_prefix(option, "signed-tags=", &option)) { | |
| 3765 | - | if (parse_sign_mode(option, &signed_tag_mode, &signed_tag_keyid)) | |
| 3766 | - | usagef(_("unknown --signed-tags mode '%s'"), option); | |
| 3869 | + | option_signed_tags(option); | |
| 3767 | 3870 | } else if (!strcmp(option, "quiet")) { | |
| 3768 | - | show_stats = 0; | |
| 3769 | - | quiet = 1; | |
| 3871 | + | option_quiet(); | |
| 3770 | 3872 | } else if (!strcmp(option, "stats")) { | |
| 3771 | 3873 | show_stats = 1; | |
| 3772 | 3874 | } else if (!strcmp(option, "allow-unsafe-features")) { | |
| @@ -3778,34 +3880,36 @@ static int parse_one_option(const char *option) | |||
| 3778 | 3880 | return 1; | |
| 3779 | 3881 | } | |
| 3780 | 3882 | ||
| 3781 | - | static void check_unsafe_feature(const char *feature, int from_stream) | |
| 3883 | + | static void check_unsafe_feature(struct fast_import_state *state, | |
| 3884 | + | const char *feature) | |
| 3782 | 3885 | { | |
| 3783 | - | if (from_stream && !allow_unsafe_features) | |
| 3886 | + | if (!state->allow_unsafe_features) | |
| 3784 | 3887 | die(_("feature '%s' forbidden in input without --allow-unsafe-features"), | |
| 3785 | 3888 | feature); | |
| 3786 | 3889 | } | |
| 3787 | 3890 | ||
| 3788 | - | static int parse_one_feature(const char *feature, int from_stream) | |
| 3891 | + | static int parse_one_feature(struct fast_import_state *state, | |
| 3892 | + | const char *feature) | |
| 3789 | 3893 | { | |
| 3790 | 3894 | const char *arg; | |
| 3791 | 3895 | ||
| 3792 | 3896 | if (skip_prefix(feature, "date-format=", &arg)) { | |
| 3793 | 3897 | option_date_format(arg); | |
| 3794 | 3898 | } else if (skip_prefix(feature, "import-marks=", &arg)) { | |
| 3795 | - | check_unsafe_feature("import-marks", from_stream); | |
| 3796 | - | option_import_marks(arg, from_stream, 0); | |
| 3899 | + | check_unsafe_feature(state, "import-marks"); | |
| 3900 | + | option_import_marks(state, arg, 1, 0); | |
| 3797 | 3901 | } else if (skip_prefix(feature, "import-marks-if-exists=", &arg)) { | |
| 3798 | - | check_unsafe_feature("import-marks-if-exists", from_stream); | |
| 3799 | - | option_import_marks(arg, from_stream, 1); | |
| 3902 | + | check_unsafe_feature(state, "import-marks-if-exists"); | |
| 3903 | + | option_import_marks(state, arg, 1, 1); | |
| 3800 | 3904 | } else if (skip_prefix(feature, "export-marks=", &arg)) { | |
| 3801 | - | check_unsafe_feature(feature, from_stream); | |
| 3802 | - | option_export_marks(arg); | |
| 3905 | + | check_unsafe_feature(state, feature); | |
| 3906 | + | option_export_marks(state, arg); | |
| 3803 | 3907 | } else if (!strcmp(feature, "alias")) { | |
| 3804 | 3908 | ; /* Don't die - this feature is supported */ | |
| 3805 | 3909 | } else if (skip_prefix(feature, "rewrite-submodules-to=", &arg)) { | |
| 3806 | - | option_rewrite_submodules(arg, &sub_marks_to); | |
| 3910 | + | option_rewrite_submodules(state, arg, &sub_marks_to); | |
| 3807 | 3911 | } else if (skip_prefix(feature, "rewrite-submodules-from=", &arg)) { | |
| 3808 | - | option_rewrite_submodules(arg, &sub_marks_from); | |
| 3912 | + | option_rewrite_submodules(state, arg, &sub_marks_from); | |
| 3809 | 3913 | } else if (!strcmp(feature, "get-mark")) { | |
| 3810 | 3914 | ; /* Don't die - this feature is supported */ | |
| 3811 | 3915 | } else if (!strcmp(feature, "cat-blob")) { | |
| @@ -3827,23 +3931,23 @@ static int parse_one_feature(const char *feature, int from_stream) | |||
| 3827 | 3931 | return 1; | |
| 3828 | 3932 | } | |
| 3829 | 3933 | ||
| 3830 | - | static void parse_feature(const char *feature) | |
| 3934 | + | static void parse_feature(struct fast_import_state *state, const char *feature) | |
| 3831 | 3935 | { | |
| 3832 | - | if (seen_data_command) | |
| 3936 | + | if (state->seen_data_command) | |
| 3833 | 3937 | die(_("got feature command '%s' after data command"), feature); | |
| 3834 | 3938 | ||
| 3835 | - | if (parse_one_feature(feature, 1)) | |
| 3939 | + | if (parse_one_feature(state, feature)) | |
| 3836 | 3940 | return; | |
| 3837 | 3941 | ||
| 3838 | 3942 | die(_("this version of fast-import does not support feature %s."), feature); | |
| 3839 | 3943 | } | |
| 3840 | 3944 | ||
| 3841 | - | static void parse_option(const char *option) | |
| 3945 | + | static void parse_option(struct fast_import_state *state, const char *option) | |
| 3842 | 3946 | { | |
| 3843 | - | if (seen_data_command) | |
| 3947 | + | if (state->seen_data_command) | |
| 3844 | 3948 | die(_("got option command '%s' after data command"), option); | |
| 3845 | 3949 | ||
| 3846 | - | if (parse_one_option(option)) | |
| 3950 | + | if (parse_one_option(state, option)) | |
| 3847 | 3951 | return; | |
| 3848 | 3952 | ||
| 3849 | 3953 | die(_("this version of fast-import does not support option: %s"), option); | |
| @@ -3876,42 +3980,144 @@ static void git_pack_config(void) | |||
| 3876 | 3980 | repo_config(the_repository, git_default_config, NULL); | |
| 3877 | 3981 | } | |
| 3878 | 3982 | ||
| 3879 | - | static const char fast_import_usage[] = | |
| 3880 | - | "git fast-import [--date-format=<f>] [--max-pack-size=<n>] [--big-file-threshold=<n>] [--depth=<n>] [--active-branches=<n>] [--export-marks=<marks.file>]"; | |
| 3983 | + | static const char *const fast_import_usage[] = { | |
| 3984 | + | N_("git fast-import [<options>]"), | |
| 3985 | + | NULL | |
| 3986 | + | }; | |
| 3881 | 3987 | ||
| 3882 | - | static void parse_argv(void) | |
| 3988 | + | static void parse_argv(struct fast_import_state *state) | |
| 3883 | 3989 | { | |
| 3884 | - | unsigned int i; | |
| 3990 | + | int argc = parse_options(state->argc, state->argv, state->prefix, | |
| 3991 | + | state->option, fast_import_usage, | |
| 3992 | + | PARSE_OPT_KEEP_ARGV0); | |
| 3885 | 3993 | ||
| 3886 | - | for (i = 1; i < global_argc; i++) { | |
| 3887 | - | const char *a = global_argv[i]; | |
| 3994 | + | if (argc > 1) | |
| 3995 | + | usage_with_options(fast_import_usage, state->option); | |
| 3888 | 3996 | ||
| 3889 | - | if (*a != '-' || !strcmp(a, "--")) | |
| 3890 | - | break; | |
| 3997 | + | state->seen_data_command = 1; | |
| 3998 | + | if (import_marks_file) | |
| 3999 | + | read_marks(); | |
| 4000 | + | build_mark_map(&sub_marks_from, &sub_marks_to); | |
| 4001 | + | } | |
| 3891 | 4002 | ||
| 3892 | - | if (!skip_prefix(a, "--", &a)) | |
| 3893 | - | die(_("unknown option %s"), a); | |
| 4003 | + | static int option_parse_date_format(const struct option *opt UNUSED, | |
| 4004 | + | const char *arg, int unset) | |
| 4005 | + | { | |
| 4006 | + | BUG_ON_OPT_NEG(unset); | |
| 4007 | + | option_date_format(arg); | |
| 4008 | + | return 0; | |
| 4009 | + | } | |
| 3894 | 4010 | ||
| 3895 | - | if (parse_one_option(a)) | |
| 3896 | - | continue; | |
| 4011 | + | static int option_parse_export_pack_edges(const struct option *opt, | |
| 4012 | + | const char *arg, int unset) | |
| 4013 | + | { | |
| 4014 | + | BUG_ON_OPT_NEG(unset); | |
| 4015 | + | option_export_pack_edges(opt->value, arg); | |
| 4016 | + | return 0; | |
| 4017 | + | } | |
| 3897 | 4018 | ||
| 3898 | - | if (parse_one_feature(a, 0)) | |
| 3899 | - | continue; | |
| 4019 | + | static int option_parse_max_pack_size(const struct option *opt UNUSED, | |
| 4020 | + | const char *arg, int unset) | |
| 4021 | + | { | |
| 4022 | + | BUG_ON_OPT_NEG(unset); | |
| 4023 | + | option_max_pack_size(arg); | |
| 4024 | + | return 0; | |
| 4025 | + | } | |
| 3900 | 4026 | ||
| 3901 | - | if (skip_prefix(a, "cat-blob-fd=", &a)) { | |
| 3902 | - | option_cat_blob_fd(a); | |
| 3903 | - | continue; | |
| 3904 | - | } | |
| 4027 | + | static int option_parse_big_file_threshold(const struct option *opt UNUSED, | |
| 4028 | + | const char *arg, int unset) | |
| 4029 | + | { | |
| 4030 | + | BUG_ON_OPT_NEG(unset); | |
| 4031 | + | option_big_file_threshold(arg); | |
| 4032 | + | return 0; | |
| 4033 | + | } | |
| 3905 | 4034 | ||
| 3906 | - | die(_("unknown option --%s"), a); | |
| 3907 | - | } | |
| 3908 | - | if (i != global_argc) | |
| 3909 | - | usage(fast_import_usage); | |
| 4035 | + | static int option_parse_signed_commits(const struct option *opt UNUSED, | |
| 4036 | + | const char *arg, int unset) | |
| 4037 | + | { | |
| 4038 | + | BUG_ON_OPT_NEG(unset); | |
| 4039 | + | option_signed_commits(arg); | |
| 4040 | + | return 0; | |
| 4041 | + | } | |
| 3910 | 4042 | ||
| 3911 | - | seen_data_command = 1; | |
| 3912 | - | if (import_marks_file) | |
| 3913 | - | read_marks(); | |
| 3914 | - | build_mark_map(&sub_marks_from, &sub_marks_to); | |
| 4043 | + | static int option_parse_signed_tags(const struct option *opt UNUSED, | |
| 4044 | + | const char *arg, int unset) | |
| 4045 | + | { | |
| 4046 | + | BUG_ON_OPT_NEG(unset); | |
| 4047 | + | option_signed_tags(arg); | |
| 4048 | + | return 0; | |
| 4049 | + | } | |
| 4050 | + | ||
| 4051 | + | static int option_parse_rewrite_submodules_from(const struct option *opt, | |
| 4052 | + | const char *arg, int unset) | |
| 4053 | + | { | |
| 4054 | + | BUG_ON_OPT_NEG(unset); | |
| 4055 | + | option_rewrite_submodules(opt->value, arg, &sub_marks_from); | |
| 4056 | + | return 0; | |
| 4057 | + | } | |
| 4058 | + | ||
| 4059 | + | static int option_parse_rewrite_submodules_to(const struct option *opt, | |
| 4060 | + | const char *arg, int unset) | |
| 4061 | + | { | |
| 4062 | + | BUG_ON_OPT_NEG(unset); | |
| 4063 | + | option_rewrite_submodules(opt->value, arg, &sub_marks_to); | |
| 4064 | + | return 0; | |
| 4065 | + | } | |
| 4066 | + | ||
| 4067 | + | static int option_parse_cat_blob_fd(const struct option *opt, | |
| 4068 | + | const char *arg, int unset) | |
| 4069 | + | { | |
| 4070 | + | BUG_ON_OPT_NEG(unset); | |
| 4071 | + | option_cat_blob_fd(opt->value, arg); | |
| 4072 | + | return 0; | |
| 4073 | + | } | |
| 4074 | + | ||
| 4075 | + | static int option_parse_import_marks(const struct option *opt, | |
| 4076 | + | const char *arg, int unset) | |
| 4077 | + | { | |
| 4078 | + | BUG_ON_OPT_NEG(unset); | |
| 4079 | + | option_import_marks(opt->value, arg, 0, 0); | |
| 4080 | + | return 0; | |
| 4081 | + | } | |
| 4082 | + | ||
| 4083 | + | static int option_parse_import_marks_if_exists(const struct option *opt, | |
| 4084 | + | const char *arg, int unset) | |
| 4085 | + | { | |
| 4086 | + | BUG_ON_OPT_NEG(unset); | |
| 4087 | + | option_import_marks(opt->value, arg, 0, 1); | |
| 4088 | + | return 0; | |
| 4089 | + | } | |
| 4090 | + | ||
| 4091 | + | static int option_parse_export_marks(const struct option *opt, | |
| 4092 | + | const char *arg, int unset) | |
| 4093 | + | { | |
| 4094 | + | BUG_ON_OPT_NEG(unset); | |
| 4095 | + | option_export_marks(opt->value, arg); | |
| 4096 | + | return 0; | |
| 4097 | + | } | |
| 4098 | + | ||
| 4099 | + | static int option_parse_depth(const struct option *opt UNUSED, | |
| 4100 | + | const char *arg, int unset) | |
| 4101 | + | { | |
| 4102 | + | BUG_ON_OPT_NEG(unset); | |
| 4103 | + | option_depth(arg); | |
| 4104 | + | return 0; | |
| 4105 | + | } | |
| 4106 | + | ||
| 4107 | + | static int option_parse_active_branches(const struct option *opt UNUSED, | |
| 4108 | + | const char *arg, int unset) | |
| 4109 | + | { | |
| 4110 | + | BUG_ON_OPT_NEG(unset); | |
| 4111 | + | option_active_branches(arg); | |
| 4112 | + | return 0; | |
| 4113 | + | } | |
| 4114 | + | ||
| 4115 | + | static int option_parse_quiet(const struct option *opt UNUSED, | |
| 4116 | + | const char *arg UNUSED, int unset) | |
| 4117 | + | { | |
| 4118 | + | BUG_ON_OPT_NEG(unset); | |
| 4119 | + | option_quiet(); | |
| 4120 | + | return 0; | |
| 3915 | 4121 | } | |
| 3916 | 4122 | ||
| 3917 | 4123 | int cmd_fast_import(int argc, | |
| @@ -3919,9 +4125,80 @@ int cmd_fast_import(int argc, | |||
| 3919 | 4125 | const char *prefix, | |
| 3920 | 4126 | struct repository *repo) | |
| 3921 | 4127 | { | |
| 3922 | - | unsigned int i; | |
| 3923 | - | ||
| 3924 | - | show_usage_if_asked(argc, argv, fast_import_usage); | |
| 4128 | + | struct fast_import_state state; | |
| 4129 | + | ||
| 4130 | + | struct option fast_import_options[] = { | |
| 4131 | + | OPT_GROUP(N_("Common")), | |
| 4132 | + | OPT_CALLBACK_F(0, "date-format", NULL, N_("fmt"), | |
| 4133 | + | N_("format of the commit/tag dates"), | |
| 4134 | + | PARSE_OPT_NONEG, option_parse_date_format), | |
| 4135 | + | OPT_BOOL_F(0, "stats", &show_stats, | |
| 4136 | + | N_("display some basic statistics (objects, packfiles and memory)"), | |
| 4137 | + | PARSE_OPT_NONEG), | |
| 4138 | + | OPT_CALLBACK_F(0, "quiet", NULL, NULL, | |
| 4139 | + | N_("disable the output shown by --stats"), | |
| 4140 | + | PARSE_OPT_NOARG | PARSE_OPT_NONEG, | |
| 4141 | + | option_parse_quiet), | |
| 4142 | + | OPT_BOOL_F(0, "force", &force_update, | |
| 4143 | + | N_("force updating modified existing branches"), PARSE_OPT_NONEG), | |
| 4144 | + | OPT_BOOL_F(0, "done", &require_explicit_termination, | |
| 4145 | + | N_("require a terminating 'done' command"), PARSE_OPT_NONEG), | |
| 4146 | + | OPT_CALLBACK_F(0, "max-pack-size", NULL, N_("n"), | |
| 4147 | + | N_("maximum size of each output pack file"), | |
| 4148 | + | PARSE_OPT_NONEG, option_parse_max_pack_size), | |
| 4149 | + | OPT_CALLBACK_F(0, "big-file-threshold", NULL, N_("n"), | |
| 4150 | + | N_("maximum size of a blob that will be deltified"), | |
| 4151 | + | PARSE_OPT_NONEG, option_parse_big_file_threshold), | |
| 4152 | + | OPT_CALLBACK_F(0, "depth", NULL, N_("n"), | |
| 4153 | + | N_("maximum delta depth"), | |
| 4154 | + | PARSE_OPT_NONEG, option_parse_depth), | |
| 4155 | + | OPT_CALLBACK_F(0, "active-branches", NULL, N_("n"), | |
| 4156 | + | N_("maximum number of branches to maintain active"), | |
| 4157 | + | PARSE_OPT_NONEG, option_parse_active_branches), | |
| 4158 | + | OPT_GROUP(N_("Marks")), | |
| 4159 | + | OPT_CALLBACK_F(0, "import-marks", &state, N_("file"), | |
| 4160 | + | N_("import marks from <file>"), | |
| 4161 | + | PARSE_OPT_NONEG, option_parse_import_marks), | |
| 4162 | + | OPT_CALLBACK_F(0, "import-marks-if-exists", &state, N_("file"), | |
| 4163 | + | N_("import marks from <file> if it exists"), | |
| 4164 | + | PARSE_OPT_NONEG, option_parse_import_marks_if_exists), | |
| 4165 | + | OPT_CALLBACK_F(0, "export-marks", &state, N_("file"), | |
| 4166 | + | N_("dump marks to <file>"), | |
| 4167 | + | PARSE_OPT_NONEG, option_parse_export_marks), | |
| 4168 | + | OPT_BOOL(0, "relative-marks", &relative_marks_paths, | |
| 4169 | + | N_("are --(import|export)-marks= paths relative to '.git/info/fast-import'?")), | |
| 4170 | + | OPT_GROUP(N_("Submodule rewrite")), | |
| 4171 | + | OPT_CALLBACK_F(0, "rewrite-submodules-from", &state, N_("name:filename"), | |
| 4172 | + | N_("rewrite object IDs for submodule <name> from <filename>"), | |
| 4173 | + | PARSE_OPT_NONEG, option_parse_rewrite_submodules_from), | |
| 4174 | + | OPT_CALLBACK_F(0, "rewrite-submodules-to", &state, N_("name:filename"), | |
| 4175 | + | N_("rewrite object IDs for submodule <name> to <filename>"), | |
| 4176 | + | PARSE_OPT_NONEG, option_parse_rewrite_submodules_to), | |
| 4177 | + | OPT_GROUP(N_("Signing")), | |
| 4178 | + | OPT_CALLBACK_F(0, "signed-commits", NULL, N_("mode"), | |
| 4179 | + | N_("how to handle signed commits"), | |
| 4180 | + | PARSE_OPT_NONEG, option_parse_signed_commits), | |
| 4181 | + | OPT_CALLBACK_F(0, "signed-tags", NULL, N_("mode"), | |
| 4182 | + | N_("how to handle signed tags"), | |
| 4183 | + | PARSE_OPT_NONEG, option_parse_signed_tags), | |
| 4184 | + | OPT_HIDDEN_GROUP(N_("Advanced")), | |
| 4185 | + | OPT_BOOL_F(0, "allow-unsafe-features", &state.allow_unsafe_features, | |
| 4186 | + | N_("allow unsafe mark commands from the stream"), | |
| 4187 | + | PARSE_OPT_HIDDEN | PARSE_OPT_NONEG), | |
| 4188 | + | OPT_CALLBACK_F(0, "export-pack-edges", &state, N_("file"), | |
| 4189 | + | N_("dump edge commits to <file>"), | |
| 4190 | + | PARSE_OPT_HIDDEN | PARSE_OPT_NONEG, | |
| 4191 | + | option_parse_export_pack_edges), | |
| 4192 | + | OPT_CALLBACK_F(0, "cat-blob-fd", &state, N_("fd"), | |
| 4193 | + | N_("write some responses to <fd> instead of stdout"), | |
| 4194 | + | PARSE_OPT_HIDDEN | PARSE_OPT_NONEG, | |
| 4195 | + | option_parse_cat_blob_fd), | |
| 4196 | + | OPT_END() | |
| 4197 | + | }; | |
| 4198 | + | ||
| 4199 | + | show_usage_with_options_if_asked(argc, argv, fast_import_usage, fast_import_options); | |
| 4200 | + | ||
| 4201 | + | fast_import_state_init(&state, argc, argv, prefix, fast_import_options); | |
| 3925 | 4202 | ||
| 3926 | 4203 | reset_pack_idx_option(&pack_idx_opts); | |
| 3927 | 4204 | git_pack_config(); | |
| @@ -3940,55 +4217,61 @@ int cmd_fast_import(int argc, | |||
| 3940 | 4217 | * "feature" lines at the start of the stream (which allows the command | |
| 3941 | 4218 | * line to override stream data). But we must do an early parse of any | |
| 3942 | 4219 | * command-line options that impact how we interpret the feature lines. | |
| 4220 | + | * | |
| 4221 | + | * NEEDSWORK: This scan only matches the exact "--allow-unsafe-features" | |
| 4222 | + | * spelling and stops at the first argument that doesn't start with a | |
| 4223 | + | * dash. As parse_options() below also accepts unambiguous abbreviations | |
| 4224 | + | * and values separated by a space from their option, the two disagree | |
| 4225 | + | * for command lines like "--allow-unsafe" or "--depth 5 | |
| 4226 | + | * --allow-unsafe-features": parse_options() accepts the option, but | |
| 4227 | + | * this scan doesn't see it, so unsafe features from the stream are | |
| 4228 | + | * still refused. This errs on the safe side, but should be fixed by | |
| 4229 | + | * teaching this scan about the options that take a value. | |
| 3943 | 4230 | */ | |
| 3944 | - | for (i = 1; i < argc; i++) { | |
| 4231 | + | for (int i = 1; i < argc; i++) { | |
| 3945 | 4232 | const char *arg = argv[i]; | |
| 3946 | 4233 | if (*arg != '-' || !strcmp(arg, "--")) | |
| 3947 | 4234 | break; | |
| 3948 | 4235 | if (!strcmp(arg, "--allow-unsafe-features")) | |
| 3949 | - | allow_unsafe_features = 1; | |
| 4236 | + | state.allow_unsafe_features = 1; | |
| 3950 | 4237 | } | |
| 3951 | 4238 | ||
| 3952 | - | global_argc = argc; | |
| 3953 | - | global_argv = argv; | |
| 3954 | - | global_prefix = prefix; | |
| 3955 | - | ||
| 3956 | 4239 | rc_free = mem_pool_alloc(&fi_mem_pool, cmd_save * sizeof(*rc_free)); | |
| 3957 | - | for (i = 0; i < (cmd_save - 1); i++) | |
| 4240 | + | for (unsigned int i = 0; i < (cmd_save - 1); i++) | |
| 3958 | 4241 | rc_free[i].next = &rc_free[i + 1]; | |
| 3959 | 4242 | rc_free[cmd_save - 1].next = NULL; | |
| 3960 | 4243 | ||
| 3961 | 4244 | start_packfile(); | |
| 3962 | 4245 | set_die_routine(die_nicely); | |
| 3963 | 4246 | set_checkpoint_signal(); | |
| 3964 | - | while (read_next_command() != EOF) { | |
| 4247 | + | while (read_next_command(&state) != EOF) { | |
| 3965 | 4248 | const char *v; | |
| 3966 | 4249 | if (!strcmp("blob", command_buf.buf)) | |
| 3967 | - | parse_new_blob(); | |
| 4250 | + | parse_new_blob(&state); | |
| 3968 | 4251 | else if (skip_prefix(command_buf.buf, "commit ", &v)) | |
| 3969 | - | parse_new_commit(v); | |
| 4252 | + | parse_new_commit(&state, v); | |
| 3970 | 4253 | else if (skip_prefix(command_buf.buf, "tag ", &v)) | |
| 3971 | - | parse_new_tag(v); | |
| 4254 | + | parse_new_tag(&state, v); | |
| 3972 | 4255 | else if (skip_prefix(command_buf.buf, "reset ", &v)) | |
| 3973 | - | parse_reset_branch(v); | |
| 4256 | + | parse_reset_branch(&state, v); | |
| 3974 | 4257 | else if (skip_prefix(command_buf.buf, "ls ", &v)) | |
| 3975 | - | parse_ls(v, NULL); | |
| 4258 | + | parse_ls(&state, v, NULL); | |
| 3976 | 4259 | else if (skip_prefix(command_buf.buf, "cat-blob ", &v)) | |
| 3977 | - | parse_cat_blob(v); | |
| 4260 | + | parse_cat_blob(&state, v); | |
| 3978 | 4261 | else if (skip_prefix(command_buf.buf, "get-mark ", &v)) | |
| 3979 | - | parse_get_mark(v); | |
| 4262 | + | parse_get_mark(&state, v); | |
| 3980 | 4263 | else if (!strcmp("checkpoint", command_buf.buf)) | |
| 3981 | - | parse_checkpoint(); | |
| 4264 | + | parse_checkpoint(&state); | |
| 3982 | 4265 | else if (!strcmp("done", command_buf.buf)) | |
| 3983 | 4266 | break; | |
| 3984 | 4267 | else if (!strcmp("alias", command_buf.buf)) | |
| 3985 | - | parse_alias(); | |
| 4268 | + | parse_alias(&state); | |
| 3986 | 4269 | else if (starts_with(command_buf.buf, "progress ")) | |
| 3987 | - | parse_progress(); | |
| 4270 | + | parse_progress(&state); | |
| 3988 | 4271 | else if (skip_prefix(command_buf.buf, "feature ", &v)) | |
| 3989 | - | parse_feature(v); | |
| 4272 | + | parse_feature(&state, v); | |
| 3990 | 4273 | else if (skip_prefix(command_buf.buf, "option git ", &v)) | |
| 3991 | - | parse_option(v); | |
| 4274 | + | parse_option(&state, v); | |
| 3992 | 4275 | else if (starts_with(command_buf.buf, "option ")) | |
| 3993 | 4276 | /* ignore non-git options*/; | |
| 3994 | 4277 | else | |
| @@ -3999,8 +4282,8 @@ int cmd_fast_import(int argc, | |||
| 3999 | 4282 | } | |
| 4000 | 4283 | ||
| 4001 | 4284 | /* argv hasn't been parsed yet, do so */ | |
| 4002 | - | if (!seen_data_command) | |
| 4003 | - | parse_argv(); | |
| 4285 | + | if (!state.seen_data_command) | |
| 4286 | + | parse_argv(&state); | |
| 4004 | 4287 | ||
| 4005 | 4288 | if (require_explicit_termination && feof(stdin)) | |
| 4006 | 4289 | die(_("stream ends early")); | |
| @@ -4017,9 +4300,9 @@ int cmd_fast_import(int argc, | |||
| 4017 | 4300 | ||
| 4018 | 4301 | if (show_stats) { | |
| 4019 | 4302 | uintmax_t total_count = 0, duplicate_count = 0; | |
| 4020 | - | for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++) | |
| 4303 | + | for (size_t i = 0; i < ARRAY_SIZE(object_count_by_type); i++) | |
| 4021 | 4304 | total_count += object_count_by_type[i]; | |
| 4022 | - | for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++) | |
| 4305 | + | for (size_t i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++) | |
| 4023 | 4306 | duplicate_count += duplicate_count_by_type[i]; | |
| 4024 | 4307 | ||
| 4025 | 4308 | fprintf(stderr, "%s statistics:\n", argv[0]); | |
modified builtin/fetch-pack.c
| @@ -49,7 +49,7 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc, | |||
| 49 | 49 | int cmd_fetch_pack(int argc, | |
| 50 | 50 | const char **argv, | |
| 51 | 51 | const char *prefix UNUSED, | |
| 52 | - | struct repository *repo UNUSED) | |
| 52 | + | struct repository *repo) | |
| 53 | 53 | { | |
| 54 | 54 | int i, ret; | |
| 55 | 55 | struct ref *fetched_refs = NULL, *remote_refs = NULL; | |
| @@ -67,8 +67,6 @@ int cmd_fetch_pack(int argc, | |||
| 67 | 67 | struct packet_reader reader; | |
| 68 | 68 | enum protocol_version version; | |
| 69 | 69 | ||
| 70 | - | fetch_if_missing = 0; | |
| 71 | - | ||
| 72 | 70 | packet_trace_identity("fetch-pack"); | |
| 73 | 71 | ||
| 74 | 72 | memset(&args, 0, sizeof(args)); | |
| @@ -77,6 +75,8 @@ int cmd_fetch_pack(int argc, | |||
| 77 | 75 | ||
| 78 | 76 | show_usage_if_asked(argc, argv, fetch_pack_usage); | |
| 79 | 77 | ||
| 78 | + | repo->fetch_if_missing = 0; | |
| 79 | + | ||
| 80 | 80 | for (i = 1; i < argc && *argv[i] == '-'; i++) { | |
| 81 | 81 | const char *arg = argv[i]; | |
| 82 | 82 | ||
| @@ -223,7 +223,7 @@ int cmd_fetch_pack(int argc, | |||
| 223 | 223 | int flags = args.verbose ? CONNECT_VERBOSE : 0; | |
| 224 | 224 | if (args.diag_url) | |
| 225 | 225 | flags |= CONNECT_DIAG_URL; | |
| 226 | - | conn = git_connect(fd, dest, "git-upload-pack", | |
| 226 | + | conn = git_connect(fd, dest, GIT_CONNECT_UPLOAD_PACK, | |
| 227 | 227 | args.uploadpack, flags); | |
| 228 | 228 | if (!conn) | |
| 229 | 229 | return args.diag_url ? 0 : 1; | |
modified builtin/fetch.c
| @@ -96,12 +96,14 @@ static struct string_list deepen_not = STRING_LIST_INIT_NODUP; | |||
| 96 | 96 | static struct strbuf default_rla = STRBUF_INIT; | |
| 97 | 97 | static struct transport *gtransport; | |
| 98 | 98 | static struct transport *gsecondary; | |
| 99 | - | static struct refspec refmap = REFSPEC_INIT_FETCH; | |
| 99 | + | static struct refspec refmap; | |
| 100 | 100 | static struct string_list server_options = STRING_LIST_INIT_DUP; | |
| 101 | - | static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP; | |
| 101 | + | static struct string_list negotiation_restrict = STRING_LIST_INIT_NODUP; | |
| 102 | + | static struct string_list negotiation_include = STRING_LIST_INIT_NODUP; | |
| 102 | 103 | ||
| 103 | 104 | struct fetch_config { | |
| 104 | 105 | enum display_format display_format; | |
| 106 | + | enum follow_remote_head_settings follow_remote_head; | |
| 105 | 107 | int all; | |
| 106 | 108 | int prune; | |
| 107 | 109 | int prune_tags; | |
| @@ -170,6 +172,23 @@ static int git_fetch_config(const char *k, const char *v, | |||
| 170 | 172 | else | |
| 171 | 173 | die(_("invalid value for '%s': '%s'"), | |
| 172 | 174 | "fetch.output", v); | |
| 175 | + | return 0; | |
| 176 | + | } | |
| 177 | + | ||
| 178 | + | if (!strcmp(k, "fetch.followremotehead")) { | |
| 179 | + | if (!v) | |
| 180 | + | return config_error_nonbool(k); | |
| 181 | + | else if (!strcmp(v, "never")) | |
| 182 | + | fetch_config->follow_remote_head = FOLLOW_REMOTE_NEVER; | |
| 183 | + | else if (!strcmp(v, "create")) | |
| 184 | + | fetch_config->follow_remote_head = FOLLOW_REMOTE_CREATE; | |
| 185 | + | else if (!strcmp(v, "warn")) | |
| 186 | + | fetch_config->follow_remote_head = FOLLOW_REMOTE_WARN; | |
| 187 | + | else if (!strcmp(v, "always")) | |
| 188 | + | fetch_config->follow_remote_head = FOLLOW_REMOTE_ALWAYS; | |
| 189 | + | else | |
| 190 | + | warning(_("unrecognized fetch.followRemoteHEAD value '%s' ignored"), v); | |
| 191 | + | return 0; | |
| 173 | 192 | } | |
| 174 | 193 | ||
| 175 | 194 | return git_default_config(k, v, ctx, cb); | |
| @@ -582,7 +601,8 @@ static struct ref *get_ref_map(struct remote *remote, | |||
| 582 | 601 | struct refspec_item tag_refspec; | |
| 583 | 602 | ||
| 584 | 603 | /* also fetch all tags */ | |
| 585 | - | refspec_item_init_push(&tag_refspec, TAG_REFSPEC); | |
| 604 | + | refspec_item_init_push(&tag_refspec, TAG_REFSPEC, | |
| 605 | + | the_hash_algo); | |
| 586 | 606 | get_fetch_map(remote_refs, &tag_refspec, &tail, 0); | |
| 587 | 607 | refspec_item_clear(&tag_refspec); | |
| 588 | 608 | } else if (tags == TAGS_DEFAULT && *autotags) { | |
| @@ -1534,23 +1554,29 @@ static int add_oid(const struct reference *ref, void *cb_data) | |||
| 1534 | 1554 | return 0; | |
| 1535 | 1555 | } | |
| 1536 | 1556 | ||
| 1537 | - | static void add_negotiation_tips(struct git_transport_options *smart_options) | |
| 1557 | + | static void add_negotiation_tips(struct string_list *input_list, | |
| 1558 | + | struct oid_array **output_list, | |
| 1559 | + | const char *argname) | |
| 1538 | 1560 | { | |
| 1539 | 1561 | struct oid_array *oids = xcalloc(1, sizeof(*oids)); | |
| 1540 | 1562 | int i; | |
| 1541 | 1563 | ||
| 1542 | - | for (i = 0; i < negotiation_tip.nr; i++) { | |
| 1543 | - | const char *s = negotiation_tip.items[i].string; | |
| 1564 | + | for (i = 0; i < input_list->nr; i++) { | |
| 1565 | + | const char *s = input_list->items[i].string; | |
| 1544 | 1566 | struct refs_for_each_ref_options opts = { | |
| 1545 | 1567 | .pattern = s, | |
| 1546 | 1568 | }; | |
| 1547 | 1569 | int old_nr; | |
| 1548 | 1570 | if (!has_glob_specials(s)) { | |
| 1549 | 1571 | struct object_id oid; | |
| 1572 | + | ||
| 1573 | + | /* Ignore missing reference. */ | |
| 1550 | 1574 | if (repo_get_oid(the_repository, s, &oid)) | |
| 1551 | - | die(_("%s is not a valid object"), s); | |
| 1575 | + | continue; | |
| 1576 | + | /* Fail on missing object pointed by ref. */ | |
| 1552 | 1577 | if (!odb_has_object(the_repository->objects, &oid, 0)) | |
| 1553 | 1578 | die(_("the object %s does not exist"), s); | |
| 1579 | + | ||
| 1554 | 1580 | oid_array_append(oids, &oid); | |
| 1555 | 1581 | continue; | |
| 1556 | 1582 | } | |
| @@ -1558,10 +1584,10 @@ static void add_negotiation_tips(struct git_transport_options *smart_options) | |||
| 1558 | 1584 | refs_for_each_ref_ext(get_main_ref_store(the_repository), | |
| 1559 | 1585 | add_oid, oids, &opts); | |
| 1560 | 1586 | if (old_nr == oids->nr) | |
| 1561 | - | warning("ignoring --negotiation-tip=%s because it does not match any refs", | |
| 1562 | - | s); | |
| 1587 | + | warning(_("ignoring %s=%s because it does not match any refs"), | |
| 1588 | + | argname, s); | |
| 1563 | 1589 | } | |
| 1564 | - | smart_options->negotiation_tips = oids; | |
| 1590 | + | *output_list = oids; | |
| 1565 | 1591 | } | |
| 1566 | 1592 | ||
| 1567 | 1593 | static struct transport *prepare_transport(struct remote *remote, int deepen, | |
| @@ -1595,11 +1621,50 @@ static struct transport *prepare_transport(struct remote *remote, int deepen, | |||
| 1595 | 1621 | set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER, spec); | |
| 1596 | 1622 | set_option(transport, TRANS_OPT_FROM_PROMISOR, "1"); | |
| 1597 | 1623 | } | |
| 1598 | - | if (negotiation_tip.nr) { | |
| 1624 | + | if (negotiation_restrict.nr) { | |
| 1599 | 1625 | if (transport->smart_options) | |
| 1600 | - | add_negotiation_tips(transport->smart_options); | |
| 1626 | + | add_negotiation_tips(&negotiation_restrict, | |
| 1627 | + | &transport->smart_options->negotiation_restrict_tips, | |
| 1628 | + | "--negotiation-restrict"); | |
| 1601 | 1629 | else | |
| 1602 | - | warning("ignoring --negotiation-tip because the protocol does not support it"); | |
| 1630 | + | warning(_("ignoring %s because the protocol does not support it"), | |
| 1631 | + | "--negotiation-restrict"); | |
| 1632 | + | } else if (remote->negotiation_restrict.nr) { | |
| 1633 | + | struct string_list_item *item; | |
| 1634 | + | for_each_string_list_item(item, &remote->negotiation_restrict) | |
| 1635 | + | string_list_append(&negotiation_restrict, item->string); | |
| 1636 | + | if (transport->smart_options) | |
| 1637 | + | add_negotiation_tips(&negotiation_restrict, | |
| 1638 | + | &transport->smart_options->negotiation_restrict_tips, | |
| 1639 | + | "--negotiation-restrict"); | |
| 1640 | + | else { | |
| 1641 | + | struct strbuf config_name = STRBUF_INIT; | |
| 1642 | + | strbuf_addf(&config_name, "remote.%s.negotiationRestrict", remote->name); | |
| 1643 | + | warning(_("ignoring %s because the protocol does not support it"), | |
| 1644 | + | config_name.buf); | |
| 1645 | + | strbuf_release(&config_name); | |
| 1646 | + | } | |
| 1647 | + | } | |
| 1648 | + | if (negotiation_include.nr) { | |
| 1649 | + | if (transport->smart_options) | |
| 1650 | + | add_negotiation_tips(&negotiation_include, | |
| 1651 | + | &transport->smart_options->negotiation_include_tips, | |
| 1652 | + | "--negotiation-include"); | |
| 1653 | + | else | |
| 1654 | + | warning(_("ignoring %s because the protocol does not support it"), | |
| 1655 | + | "--negotiation-include"); | |
| 1656 | + | } else if (remote->negotiation_include.nr) { | |
| 1657 | + | if (transport->smart_options) { | |
| 1658 | + | add_negotiation_tips(&remote->negotiation_include, | |
| 1659 | + | &transport->smart_options->negotiation_include_tips, | |
| 1660 | + | "--negotiation-include"); | |
| 1661 | + | } else { | |
| 1662 | + | struct strbuf config_name = STRBUF_INIT; | |
| 1663 | + | strbuf_addf(&config_name, "remote.%s.negotiationInclude", remote->name); | |
| 1664 | + | warning(_("ignoring %s because the protocol does not support it"), | |
| 1665 | + | config_name.buf); | |
| 1666 | + | strbuf_release(&config_name); | |
| 1667 | + | } | |
| 1603 | 1668 | } | |
| 1604 | 1669 | return transport; | |
| 1605 | 1670 | } | |
| @@ -1651,17 +1716,19 @@ static const char *strip_refshead(const char *name){ | |||
| 1651 | 1716 | static void set_head_advice_msg(const char *remote, const char *head_name) | |
| 1652 | 1717 | { | |
| 1653 | 1718 | const char message_advice_set_head[] = | |
| 1654 | - | N_("Run 'git remote set-head %s %s' to follow the change, or set\n" | |
| 1655 | - | "'remote.%s.followRemoteHEAD' configuration option to a different value\n" | |
| 1656 | - | "if you do not want to see this message. Specifically running\n" | |
| 1657 | - | "'git config set remote.%s.followRemoteHEAD warn-if-not-branch-%s'\n" | |
| 1658 | - | "will disable the warning until the remote changes HEAD to something else."); | |
| 1719 | + | N_("Run 'git remote set-head %s %s' to follow the change, or modify\n" | |
| 1720 | + | "either of the 'remote.%s.followRemoteHEAD' or 'fetch.followRemoteHEAD'\n" | |
| 1721 | + | "configuration variables to handle the situation differently.\n\n" | |
| 1722 | + | ||
| 1723 | + | "Using this specific setting\n\n" | |
| 1724 | + | " git config set remote.%s.followRemoteHEAD warn-if-not-%s\n\n" | |
| 1725 | + | "will suppress the warning until the remote changes HEAD to something else."); | |
| 1659 | 1726 | ||
| 1660 | 1727 | advise_if_enabled(ADVICE_FETCH_SET_HEAD_WARN, _(message_advice_set_head), | |
| 1661 | 1728 | remote, head_name, remote, remote, head_name); | |
| 1662 | 1729 | } | |
| 1663 | 1730 | ||
| 1664 | - | static void report_set_head(const char *remote, const char *head_name, | |
| 1731 | + | static void warn_set_head(const char *remote, const char *head_name, | |
| 1665 | 1732 | struct strbuf *buf_prev, int updateres) { | |
| 1666 | 1733 | struct strbuf buf_prefix = STRBUF_INIT; | |
| 1667 | 1734 | const char *prev_head = NULL; | |
| @@ -1683,12 +1750,12 @@ static void report_set_head(const char *remote, const char *head_name, | |||
| 1683 | 1750 | strbuf_release(&buf_prefix); | |
| 1684 | 1751 | } | |
| 1685 | 1752 | ||
| 1686 | - | static int set_head(const struct ref *remote_refs, struct remote *remote) | |
| 1753 | + | static int set_head(const struct ref *remote_refs, struct remote *remote, | |
| 1754 | + | int follow_remote_head) | |
| 1687 | 1755 | { | |
| 1688 | 1756 | int result = 0, create_only, baremirror, was_detached; | |
| 1689 | 1757 | struct strbuf b_head = STRBUF_INIT, b_remote_head = STRBUF_INIT, | |
| 1690 | 1758 | b_local_head = STRBUF_INIT; | |
| 1691 | - | int follow_remote_head = remote->follow_remote_head; | |
| 1692 | 1759 | const char *no_warn_branch = remote->no_warn_branch; | |
| 1693 | 1760 | char *head_name = NULL; | |
| 1694 | 1761 | struct ref *ref, *matches; | |
| @@ -1718,7 +1785,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote) | |||
| 1718 | 1785 | ||
| 1719 | 1786 | if (!head_name) | |
| 1720 | 1787 | goto cleanup; | |
| 1721 | - | baremirror = is_bare_repository() && remote->mirror; | |
| 1788 | + | baremirror = is_bare_repository(the_repository) && remote->mirror; | |
| 1722 | 1789 | create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !baremirror; | |
| 1723 | 1790 | if (baremirror) { | |
| 1724 | 1791 | strbuf_addstr(&b_head, "HEAD"); | |
| @@ -1727,7 +1794,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote) | |||
| 1727 | 1794 | strbuf_addf(&b_head, "refs/remotes/%s/HEAD", remote->name); | |
| 1728 | 1795 | strbuf_addf(&b_remote_head, "refs/remotes/%s/%s", remote->name, head_name); | |
| 1729 | 1796 | } | |
| 1730 | - | /* make sure it's valid */ | |
| 1797 | + | /* make sure it's valid */ | |
| 1731 | 1798 | if (!baremirror && !refs_ref_exists(refs, b_remote_head.buf)) { | |
| 1732 | 1799 | result = 1; | |
| 1733 | 1800 | goto cleanup; | |
| @@ -1741,7 +1808,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote) | |||
| 1741 | 1808 | if (verbosity >= 0 && | |
| 1742 | 1809 | follow_remote_head == FOLLOW_REMOTE_WARN && | |
| 1743 | 1810 | (!no_warn_branch || strcmp(no_warn_branch, head_name))) | |
| 1744 | - | report_set_head(remote->name, head_name, &b_local_head, was_detached); | |
| 1811 | + | warn_set_head(remote->name, head_name, &b_local_head, was_detached); | |
| 1745 | 1812 | ||
| 1746 | 1813 | cleanup: | |
| 1747 | 1814 | free(head_name); | |
| @@ -1773,7 +1840,7 @@ static void ref_transaction_rejection_handler(const char *refname, | |||
| 1773 | 1840 | { | |
| 1774 | 1841 | struct ref_rejection_data *data = cb_data; | |
| 1775 | 1842 | ||
| 1776 | - | if (err == REF_TRANSACTION_ERROR_CASE_CONFLICT && ignore_case && | |
| 1843 | + | if (err == REF_TRANSACTION_ERROR_CASE_CONFLICT && repo_ignore_case(the_repository) && | |
| 1777 | 1844 | !data->case_sensitive_msg_shown) { | |
| 1778 | 1845 | error(_("You're on a case-insensitive filesystem, and the remote you are\n" | |
| 1779 | 1846 | "trying to fetch from has references that only differ in casing. It\n" | |
| @@ -1855,6 +1922,7 @@ static int do_fetch(struct transport *transport, | |||
| 1855 | 1922 | struct ref_update_display_info_array display_array = { 0 }; | |
| 1856 | 1923 | struct strmap rejected_refs = STRMAP_INIT; | |
| 1857 | 1924 | int summary_width = 0; | |
| 1925 | + | int follow_remote_head; | |
| 1858 | 1926 | ||
| 1859 | 1927 | if (tags == TAGS_DEFAULT) { | |
| 1860 | 1928 | if (transport->remote->fetch_tags == 2) | |
| @@ -1870,6 +1938,22 @@ static int do_fetch(struct transport *transport, | |||
| 1870 | 1938 | goto cleanup; | |
| 1871 | 1939 | } | |
| 1872 | 1940 | ||
| 1941 | + | /* | |
| 1942 | + | * NEEDSWORK: By the time this function executes, we have already parsed | |
| 1943 | + | * all such followRemoteHEAD values from the external configuration, | |
| 1944 | + | * potentially emitting warning messages for bogus values. Ideally, if | |
| 1945 | + | * this fetch ends up not needing to consult these values, then git would | |
| 1946 | + | * not ever output a value warning. (eg: when pulling from a URL directly - | |
| 1947 | + | * rather than a configured remote, or when a remote's followRemoteHEAD | |
| 1948 | + | * overrides the fallback fetch setting) | |
| 1949 | + | */ | |
| 1950 | + | if (transport->remote->follow_remote_head) | |
| 1951 | + | follow_remote_head = transport->remote->follow_remote_head; | |
| 1952 | + | else if (config->follow_remote_head) | |
| 1953 | + | follow_remote_head = config->follow_remote_head; | |
| 1954 | + | else | |
| 1955 | + | follow_remote_head = BUILTIN_FOLLOW_REMOTE_HEAD_DFLT; | |
| 1956 | + | ||
| 1873 | 1957 | if (rs->nr) { | |
| 1874 | 1958 | refspec_ref_prefixes(rs, &transport_ls_refs_options.ref_prefixes); | |
| 1875 | 1959 | } else { | |
| @@ -1878,7 +1962,7 @@ static int do_fetch(struct transport *transport, | |||
| 1878 | 1962 | if (transport->remote->fetch.nr) { | |
| 1879 | 1963 | refspec_ref_prefixes(&transport->remote->fetch, | |
| 1880 | 1964 | &transport_ls_refs_options.ref_prefixes); | |
| 1881 | - | if (transport->remote->follow_remote_head != FOLLOW_REMOTE_NEVER) | |
| 1965 | + | if (follow_remote_head != FOLLOW_REMOTE_NEVER) | |
| 1882 | 1966 | do_set_head = 1; | |
| 1883 | 1967 | } | |
| 1884 | 1968 | if (branch && branch_has_merge_config(branch) && | |
| @@ -2085,7 +2169,7 @@ static int do_fetch(struct transport *transport, | |||
| 2085 | 2169 | * Way too many cases where this can go wrong so let's just | |
| 2086 | 2170 | * ignore errors and fail silently for now. | |
| 2087 | 2171 | */ | |
| 2088 | - | set_head(remote_refs, transport->remote); | |
| 2172 | + | set_head(remote_refs, transport->remote, follow_remote_head); | |
| 2089 | 2173 | } | |
| 2090 | 2174 | ||
| 2091 | 2175 | cleanup: | |
| @@ -2138,48 +2222,6 @@ static int get_one_remote_for_fetch(struct remote *remote, void *priv) | |||
| 2138 | 2222 | return 0; | |
| 2139 | 2223 | } | |
| 2140 | 2224 | ||
| 2141 | - | struct remote_group_data { | |
| 2142 | - | const char *name; | |
| 2143 | - | struct string_list *list; | |
| 2144 | - | }; | |
| 2145 | - | ||
| 2146 | - | static int get_remote_group(const char *key, const char *value, | |
| 2147 | - | const struct config_context *ctx UNUSED, | |
| 2148 | - | void *priv) | |
| 2149 | - | { | |
| 2150 | - | struct remote_group_data *g = priv; | |
| 2151 | - | ||
| 2152 | - | if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) { | |
| 2153 | - | /* split list by white space */ | |
| 2154 | - | while (*value) { | |
| 2155 | - | size_t wordlen = strcspn(value, " \t\n"); | |
| 2156 | - | ||
| 2157 | - | if (wordlen >= 1) | |
| 2158 | - | string_list_append_nodup(g->list, | |
| 2159 | - | xstrndup(value, wordlen)); | |
| 2160 | - | value += wordlen + (value[wordlen] != '\0'); | |
| 2161 | - | } | |
| 2162 | - | } | |
| 2163 | - | ||
| 2164 | - | return 0; | |
| 2165 | - | } | |
| 2166 | - | ||
| 2167 | - | static int add_remote_or_group(const char *name, struct string_list *list) | |
| 2168 | - | { | |
| 2169 | - | int prev_nr = list->nr; | |
| 2170 | - | struct remote_group_data g; | |
| 2171 | - | g.name = name; g.list = list; | |
| 2172 | - | ||
| 2173 | - | repo_config(the_repository, get_remote_group, &g); | |
| 2174 | - | if (list->nr == prev_nr) { | |
| 2175 | - | struct remote *remote = remote_get(name); | |
| 2176 | - | if (!remote_is_configured(remote, 0)) | |
| 2177 | - | return 0; | |
| 2178 | - | string_list_append(list, remote->name); | |
| 2179 | - | } | |
| 2180 | - | return 1; | |
| 2181 | - | } | |
| 2182 | - | ||
| 2183 | 2225 | static void add_options_to_argv(struct strvec *argv, | |
| 2184 | 2226 | const struct fetch_config *config) | |
| 2185 | 2227 | { | |
| @@ -2387,7 +2429,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv, | |||
| 2387 | 2429 | const struct fetch_config *config, | |
| 2388 | 2430 | struct list_objects_filter_options *filter_options) | |
| 2389 | 2431 | { | |
| 2390 | - | struct refspec rs = REFSPEC_INIT_FETCH; | |
| 2432 | + | struct refspec rs = REFSPEC_INIT_FETCH(the_hash_algo); | |
| 2391 | 2433 | int i; | |
| 2392 | 2434 | int exit_code; | |
| 2393 | 2435 | int maybe_prune_tags; | |
| @@ -2467,6 +2509,7 @@ int cmd_fetch(int argc, | |||
| 2467 | 2509 | { | |
| 2468 | 2510 | struct fetch_config config = { | |
| 2469 | 2511 | .display_format = DISPLAY_FORMAT_FULL, | |
| 2512 | + | .follow_remote_head = FOLLOW_REMOTE_UNCONFIGURED, | |
| 2470 | 2513 | .prune = -1, | |
| 2471 | 2514 | .prune_tags = -1, | |
| 2472 | 2515 | .show_forced_updates = 1, | |
| @@ -2565,8 +2608,11 @@ int cmd_fetch(int argc, | |||
| 2565 | 2608 | N_("specify fetch refmap"), PARSE_OPT_NONEG, parse_refmap_arg), | |
| 2566 | 2609 | OPT_STRING_LIST('o', "server-option", &server_options, N_("server-specific"), N_("option to transmit")), | |
| 2567 | 2610 | OPT_IPVERSION(&family), | |
| 2568 | - | OPT_STRING_LIST(0, "negotiation-tip", &negotiation_tip, N_("revision"), | |
| 2611 | + | OPT_STRING_LIST(0, "negotiation-restrict", &negotiation_restrict, N_("revision"), | |
| 2569 | 2612 | N_("report that we have only objects reachable from this object")), | |
| 2613 | + | OPT_ALIAS(0, "negotiation-tip", "negotiation-restrict"), | |
| 2614 | + | OPT_STRING_LIST(0, "negotiation-include", &negotiation_include, N_("revision"), | |
| 2615 | + | N_("ensure this ref is always sent as a negotiation have")), | |
| 2570 | 2616 | OPT_BOOL(0, "negotiate-only", &negotiate_only, | |
| 2571 | 2617 | N_("do not fetch a packfile; instead, print ancestors of negotiation tips")), | |
| 2572 | 2618 | OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), | |
| @@ -2585,6 +2631,8 @@ int cmd_fetch(int argc, | |||
| 2585 | 2631 | ||
| 2586 | 2632 | filter_options.allow_auto_filter = 1; | |
| 2587 | 2633 | ||
| 2634 | + | refspec_init_fetch(&refmap, the_hash_algo); | |
| 2635 | + | ||
| 2588 | 2636 | packet_trace_identity("fetch"); | |
| 2589 | 2637 | ||
| 2590 | 2638 | /* Record the command line for the reflog */ | |
| @@ -2633,7 +2681,7 @@ int cmd_fetch(int argc, | |||
| 2633 | 2681 | int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT | |
| 2634 | 2682 | ? &config.recurse_submodules : NULL; | |
| 2635 | 2683 | ||
| 2636 | - | fetch_config_from_gitmodules(sfjc, rs); | |
| 2684 | + | fetch_config_from_gitmodules(the_repository, sfjc, rs); | |
| 2637 | 2685 | } | |
| 2638 | 2686 | ||
| 2639 | 2687 | ||
| @@ -2656,9 +2704,6 @@ int cmd_fetch(int argc, | |||
| 2656 | 2704 | config.display_format = DISPLAY_FORMAT_PORCELAIN; | |
| 2657 | 2705 | } | |
| 2658 | 2706 | ||
| 2659 | - | if (negotiate_only && !negotiation_tip.nr) | |
| 2660 | - | die(_("--negotiate-only needs one or more --negotiation-tip=*")); | |
| 2661 | - | ||
| 2662 | 2707 | if (deepen_relative) { | |
| 2663 | 2708 | if (deepen_relative < 0) | |
| 2664 | 2709 | die(_("negative depth in --deepen is not supported")); | |
| @@ -2746,14 +2791,19 @@ int cmd_fetch(int argc, | |||
| 2746 | 2791 | if (!remote) | |
| 2747 | 2792 | die(_("must supply remote when using --negotiate-only")); | |
| 2748 | 2793 | gtransport = prepare_transport(remote, 1, &filter_options); | |
| 2749 | - | if (gtransport->smart_options) { | |
| 2750 | - | gtransport->smart_options->acked_commits = &acked_commits; | |
| 2751 | - | } else { | |
| 2794 | + | ||
| 2795 | + | if (!gtransport->smart_options) { | |
| 2752 | 2796 | warning(_("protocol does not support --negotiate-only, exiting")); | |
| 2753 | 2797 | result = 1; | |
| 2754 | 2798 | trace2_region_leave("fetch", "negotiate-only", the_repository); | |
| 2755 | 2799 | goto cleanup; | |
| 2756 | 2800 | } | |
| 2801 | + | if (!gtransport->smart_options->negotiation_restrict_tips) | |
| 2802 | + | die(_("%s needs one or more %s"), "--negotiate-only", | |
| 2803 | + | "--negotiation-restrict=*"); | |
| 2804 | + | ||
| 2805 | + | gtransport->smart_options->acked_commits = &acked_commits; | |
| 2806 | + | ||
| 2757 | 2807 | if (server_options.nr) | |
| 2758 | 2808 | gtransport->server_options = &server_options; | |
| 2759 | 2809 | result = transport_fetch_refs(gtransport, NULL); | |
modified builtin/fsck.c
| @@ -7,13 +7,11 @@ | |||
| 7 | 7 | #include "blob.h" | |
| 8 | 8 | #include "tag.h" | |
| 9 | 9 | #include "refs.h" | |
| 10 | - | #include "pack.h" | |
| 11 | 10 | #include "cache-tree.h" | |
| 12 | 11 | #include "fsck.h" | |
| 13 | 12 | #include "parse-options.h" | |
| 14 | 13 | #include "progress.h" | |
| 15 | 14 | #include "packfile.h" | |
| 16 | - | #include "object-file.h" | |
| 17 | 15 | #include "object-name.h" | |
| 18 | 16 | #include "odb.h" | |
| 19 | 17 | #include "odb/streaming.h" | |
| @@ -24,8 +22,6 @@ | |||
| 24 | 22 | #include "run-command.h" | |
| 25 | 23 | #include "sparse-index.h" | |
| 26 | 24 | #include "worktree.h" | |
| 27 | - | #include "pack-revindex.h" | |
| 28 | - | #include "pack-bitmap.h" | |
| 29 | 25 | ||
| 30 | 26 | #define REACHABLE 0x0001 | |
| 31 | 27 | #define SEEN 0x0002 | |
| @@ -37,10 +33,8 @@ static int show_root; | |||
| 37 | 33 | static int show_tags; | |
| 38 | 34 | static int show_unreachable; | |
| 39 | 35 | static int include_reflogs = 1; | |
| 40 | - | static int check_full = 1; | |
| 41 | 36 | static int connectivity_only; | |
| 42 | 37 | static int check_strict; | |
| 43 | - | static int keep_cache_objects; | |
| 44 | 38 | static struct fsck_options fsck_walk_options; | |
| 45 | 39 | static struct fsck_options fsck_obj_options; | |
| 46 | 40 | static int errors_found; | |
| @@ -48,17 +42,11 @@ static int write_lost_and_found; | |||
| 48 | 42 | static int verbose; | |
| 49 | 43 | static int show_progress = -1; | |
| 50 | 44 | static int show_dangling = 1; | |
| 51 | - | static int name_objects; | |
| 52 | - | static int check_references = 1; | |
| 53 | 45 | static timestamp_t now; | |
| 54 | 46 | #define ERROR_OBJECT 01 | |
| 55 | 47 | #define ERROR_REACHABLE 02 | |
| 56 | - | #define ERROR_PACK 04 | |
| 57 | 48 | #define ERROR_REFS 010 | |
| 58 | 49 | #define ERROR_COMMIT_GRAPH 020 | |
| 59 | - | #define ERROR_MULTI_PACK_INDEX 040 | |
| 60 | - | #define ERROR_PACK_REV_INDEX 0100 | |
| 61 | - | #define ERROR_BITMAP 0200 | |
| 62 | 50 | ||
| 63 | 51 | static const char *describe_object(const struct object_id *oid) | |
| 64 | 52 | { | |
| @@ -401,14 +389,27 @@ static void check_connectivity(struct repository *repo) | |||
| 401 | 389 | } | |
| 402 | 390 | } | |
| 403 | 391 | ||
| 404 | - | static int fsck_obj(struct repository *repo, | |
| 405 | - | struct object *obj, void *buffer, unsigned long size) | |
| 392 | + | static int fsck_obj_buffer(const struct object_id *oid, enum object_type type, | |
| 393 | + | unsigned long size, void *buffer, int *eaten, void *cb_data) | |
| 406 | 394 | { | |
| 395 | + | struct repository *repo = cb_data; | |
| 396 | + | struct object *obj; | |
| 407 | 397 | int err; | |
| 408 | 398 | ||
| 409 | - | if (obj->flags & SEEN) | |
| 410 | - | return 0; | |
| 411 | - | obj->flags |= SEEN; | |
| 399 | + | /* | |
| 400 | + | * Note, buffer may be NULL if type is OBJ_BLOB. See | |
| 401 | + | * verify_packfile(), data_valid variable for details. | |
| 402 | + | */ | |
| 403 | + | obj = parse_object_buffer(repo, oid, type, size, buffer, eaten); | |
| 404 | + | if (!obj) { | |
| 405 | + | errors_found |= ERROR_OBJECT; | |
| 406 | + | err = error(_("%s: object corrupt or missing"), | |
| 407 | + | oid_to_hex(oid)); | |
| 408 | + | goto out; | |
| 409 | + | } | |
| 410 | + | ||
| 411 | + | obj->flags &= ~REACHABLE; | |
| 412 | + | obj->flags |= HAS_OBJ | SEEN; | |
| 412 | 413 | ||
| 413 | 414 | if (verbose) | |
| 414 | 415 | fprintf_ln(stderr, _("Checking %s %s"), | |
| @@ -417,6 +418,7 @@ static int fsck_obj(struct repository *repo, | |||
| 417 | 418 | ||
| 418 | 419 | if (fsck_walk(obj, NULL, &fsck_obj_options)) | |
| 419 | 420 | objerror(repo, obj, _("broken links")); | |
| 421 | + | ||
| 420 | 422 | err = fsck_object(obj, buffer, size, &fsck_obj_options); | |
| 421 | 423 | if (err) | |
| 422 | 424 | goto out; | |
| @@ -442,32 +444,11 @@ static int fsck_obj(struct repository *repo, | |||
| 442 | 444 | } | |
| 443 | 445 | ||
| 444 | 446 | out: | |
| 445 | - | if (obj->type == OBJ_TREE) | |
| 447 | + | if (obj && obj->type == OBJ_TREE) | |
| 446 | 448 | free_tree_buffer((struct tree *)obj); | |
| 447 | 449 | return err; | |
| 448 | 450 | } | |
| 449 | 451 | ||
| 450 | - | static int fsck_obj_buffer(const struct object_id *oid, enum object_type type, | |
| 451 | - | unsigned long size, void *buffer, int *eaten, void *cb_data) | |
| 452 | - | { | |
| 453 | - | struct repository *repo = cb_data; | |
| 454 | - | struct object *obj; | |
| 455 | - | ||
| 456 | - | /* | |
| 457 | - | * Note, buffer may be NULL if type is OBJ_BLOB. See | |
| 458 | - | * verify_packfile(), data_valid variable for details. | |
| 459 | - | */ | |
| 460 | - | obj = parse_object_buffer(repo, oid, type, size, buffer, eaten); | |
| 461 | - | if (!obj) { | |
| 462 | - | errors_found |= ERROR_OBJECT; | |
| 463 | - | return error(_("%s: object corrupt or missing"), | |
| 464 | - | oid_to_hex(oid)); | |
| 465 | - | } | |
| 466 | - | obj->flags &= ~(REACHABLE | SEEN); | |
| 467 | - | obj->flags |= HAS_OBJ; | |
| 468 | - | return fsck_obj(repo, obj, buffer, size); | |
| 469 | - | } | |
| 470 | - | ||
| 471 | 452 | static int default_refs; | |
| 472 | 453 | ||
| 473 | 454 | static void fsck_handle_reflog_oid(struct repository *repo, | |
| @@ -632,7 +613,7 @@ static void snapshot_refs(struct repository *repo, | |||
| 632 | 613 | refs_for_each_ref_ext(get_main_ref_store(repo), | |
| 633 | 614 | snapshot_ref, &data, &opts); | |
| 634 | 615 | ||
| 635 | - | worktrees = get_worktrees(); | |
| 616 | + | worktrees = get_worktrees(repo); | |
| 636 | 617 | for (p = worktrees; *p; p++) { | |
| 637 | 618 | struct worktree *wt = *p; | |
| 638 | 619 | struct strbuf refname = STRBUF_INIT; | |
| @@ -685,7 +666,7 @@ static void process_refs(struct repository *repo, struct snapshot *snap) | |||
| 685 | 666 | } | |
| 686 | 667 | ||
| 687 | 668 | if (include_reflogs) { | |
| 688 | - | worktrees = get_worktrees(); | |
| 669 | + | worktrees = get_worktrees(repo); | |
| 689 | 670 | for (p = worktrees; *p; p++) { | |
| 690 | 671 | struct worktree *wt = *p; | |
| 691 | 672 | ||
| @@ -713,103 +694,6 @@ static void process_refs(struct repository *repo, struct snapshot *snap) | |||
| 713 | 694 | } | |
| 714 | 695 | } | |
| 715 | 696 | ||
| 716 | - | struct for_each_loose_cb { | |
| 717 | - | struct repository *repo; | |
| 718 | - | struct progress *progress; | |
| 719 | - | }; | |
| 720 | - | ||
| 721 | - | static int fsck_loose(const struct object_id *oid, const char *path, | |
| 722 | - | void *cb_data) | |
| 723 | - | { | |
| 724 | - | struct for_each_loose_cb *data = cb_data; | |
| 725 | - | struct object *obj; | |
| 726 | - | enum object_type type = OBJ_NONE; | |
| 727 | - | unsigned long size; | |
| 728 | - | void *contents = NULL; | |
| 729 | - | int eaten; | |
| 730 | - | struct object_info oi = OBJECT_INFO_INIT; | |
| 731 | - | struct object_id real_oid = *null_oid(data->repo->hash_algo); | |
| 732 | - | int err = 0; | |
| 733 | - | ||
| 734 | - | oi.sizep = &size; | |
| 735 | - | oi.typep = &type; | |
| 736 | - | ||
| 737 | - | if (read_loose_object(data->repo, path, oid, &real_oid, &contents, &oi) < 0) { | |
| 738 | - | if (contents && !oideq(&real_oid, oid)) | |
| 739 | - | err = error(_("%s: hash-path mismatch, found at: %s"), | |
| 740 | - | oid_to_hex(&real_oid), path); | |
| 741 | - | else | |
| 742 | - | err = error(_("%s: object corrupt or missing: %s"), | |
| 743 | - | oid_to_hex(oid), path); | |
| 744 | - | } | |
| 745 | - | if (err < 0) { | |
| 746 | - | errors_found |= ERROR_OBJECT; | |
| 747 | - | free(contents); | |
| 748 | - | return 0; /* keep checking other objects */ | |
| 749 | - | } | |
| 750 | - | ||
| 751 | - | if (!contents && type != OBJ_BLOB) | |
| 752 | - | BUG("read_loose_object streamed a non-blob"); | |
| 753 | - | ||
| 754 | - | obj = parse_object_buffer(data->repo, oid, type, size, | |
| 755 | - | contents, &eaten); | |
| 756 | - | ||
| 757 | - | if (!obj) { | |
| 758 | - | errors_found |= ERROR_OBJECT; | |
| 759 | - | error(_("%s: object could not be parsed: %s"), | |
| 760 | - | oid_to_hex(oid), path); | |
| 761 | - | if (!eaten) | |
| 762 | - | free(contents); | |
| 763 | - | return 0; /* keep checking other objects */ | |
| 764 | - | } | |
| 765 | - | ||
| 766 | - | obj->flags &= ~(REACHABLE | SEEN); | |
| 767 | - | obj->flags |= HAS_OBJ; | |
| 768 | - | if (fsck_obj(data->repo, obj, contents, size)) | |
| 769 | - | errors_found |= ERROR_OBJECT; | |
| 770 | - | ||
| 771 | - | if (!eaten) | |
| 772 | - | free(contents); | |
| 773 | - | return 0; /* keep checking other objects, even if we saw an error */ | |
| 774 | - | } | |
| 775 | - | ||
| 776 | - | static int fsck_cruft(const char *basename, const char *path, | |
| 777 | - | void *data UNUSED) | |
| 778 | - | { | |
| 779 | - | if (!starts_with(basename, "tmp_obj_")) | |
| 780 | - | fprintf_ln(stderr, _("bad sha1 file: %s"), path); | |
| 781 | - | return 0; | |
| 782 | - | } | |
| 783 | - | ||
| 784 | - | static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *data) | |
| 785 | - | { | |
| 786 | - | struct for_each_loose_cb *cb_data = data; | |
| 787 | - | struct progress *progress = cb_data->progress; | |
| 788 | - | display_progress(progress, nr + 1); | |
| 789 | - | return 0; | |
| 790 | - | } | |
| 791 | - | ||
| 792 | - | static void fsck_source(struct repository *repo, struct odb_source *source) | |
| 793 | - | { | |
| 794 | - | struct progress *progress = NULL; | |
| 795 | - | struct for_each_loose_cb cb_data = { | |
| 796 | - | .repo = source->odb->repo, | |
| 797 | - | .progress = progress, | |
| 798 | - | }; | |
| 799 | - | ||
| 800 | - | if (verbose) | |
| 801 | - | fprintf_ln(stderr, _("Checking object directory")); | |
| 802 | - | ||
| 803 | - | if (show_progress) | |
| 804 | - | progress = start_progress(repo, | |
| 805 | - | _("Checking object directories"), 256); | |
| 806 | - | ||
| 807 | - | for_each_loose_file_in_source(source, fsck_loose, | |
| 808 | - | fsck_cruft, fsck_subdir, &cb_data); | |
| 809 | - | display_progress(progress, 256); | |
| 810 | - | stop_progress(&progress); | |
| 811 | - | } | |
| 812 | - | ||
| 813 | 697 | static int fsck_cache_tree(struct repository *repo, struct cache_tree *it, const char *index_path) | |
| 814 | 698 | { | |
| 815 | 699 | int i; | |
| @@ -918,40 +802,6 @@ static int mark_object_for_connectivity(const struct object_id *oid, | |||
| 918 | 802 | return 0; | |
| 919 | 803 | } | |
| 920 | 804 | ||
| 921 | - | static int check_pack_rev_indexes(struct repository *r, int show_progress) | |
| 922 | - | { | |
| 923 | - | struct progress *progress = NULL; | |
| 924 | - | struct packed_git *p; | |
| 925 | - | uint32_t pack_count = 0; | |
| 926 | - | int res = 0; | |
| 927 | - | ||
| 928 | - | if (show_progress) { | |
| 929 | - | repo_for_each_pack(r, p) | |
| 930 | - | pack_count++; | |
| 931 | - | progress = start_delayed_progress(r, | |
| 932 | - | "Verifying reverse pack-indexes", pack_count); | |
| 933 | - | pack_count = 0; | |
| 934 | - | } | |
| 935 | - | ||
| 936 | - | repo_for_each_pack(r, p) { | |
| 937 | - | int load_error = load_pack_revindex_from_disk(p); | |
| 938 | - | ||
| 939 | - | if (load_error < 0) { | |
| 940 | - | error(_("unable to load rev-index for pack '%s'"), p->pack_name); | |
| 941 | - | res = ERROR_PACK_REV_INDEX; | |
| 942 | - | } else if (!load_error && | |
| 943 | - | !load_pack_revindex(r, p) && | |
| 944 | - | verify_pack_revindex(p)) { | |
| 945 | - | error(_("invalid rev-index for pack '%s'"), p->pack_name); | |
| 946 | - | res = ERROR_PACK_REV_INDEX; | |
| 947 | - | } | |
| 948 | - | display_progress(progress, ++pack_count); | |
| 949 | - | } | |
| 950 | - | stop_progress(&progress); | |
| 951 | - | ||
| 952 | - | return res; | |
| 953 | - | } | |
| 954 | - | ||
| 955 | 805 | static void fsck_refs(struct repository *r) | |
| 956 | 806 | { | |
| 957 | 807 | struct child_process refs_verify = CHILD_PROCESS_INIT; | |
| @@ -986,30 +836,38 @@ static char const * const fsck_usage[] = { | |||
| 986 | 836 | NULL | |
| 987 | 837 | }; | |
| 988 | 838 | ||
| 989 | - | static struct option fsck_opts[] = { | |
| 990 | - | OPT__VERBOSE(&verbose, N_("be verbose")), | |
| 991 | - | OPT_BOOL(0, "unreachable", &show_unreachable, N_("show unreachable objects")), | |
| 992 | - | OPT_BOOL(0, "dangling", &show_dangling, N_("show dangling objects")), | |
| 993 | - | OPT_BOOL(0, "tags", &show_tags, N_("report tags")), | |
| 994 | - | OPT_BOOL(0, "root", &show_root, N_("report root nodes")), | |
| 995 | - | OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")), | |
| 996 | - | OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")), | |
| 997 | - | OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")), | |
| 998 | - | OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")), | |
| 999 | - | OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")), | |
| 1000 | - | OPT_BOOL(0, "lost-found", &write_lost_and_found, | |
| 1001 | - | N_("write dangling objects in .git/lost-found")), | |
| 1002 | - | OPT_BOOL(0, "progress", &show_progress, N_("show progress")), | |
| 1003 | - | OPT_BOOL(0, "name-objects", &name_objects, N_("show verbose names for reachable objects")), | |
| 1004 | - | OPT_BOOL(0, "references", &check_references, N_("check reference database consistency")), | |
| 1005 | - | OPT_END(), | |
| 1006 | - | }; | |
| 1007 | - | ||
| 1008 | 839 | int cmd_fsck(int argc, | |
| 1009 | 840 | const char **argv, | |
| 1010 | 841 | const char *prefix, | |
| 1011 | 842 | struct repository *repo) | |
| 1012 | 843 | { | |
| 844 | + | struct odb_fsck_options odb_fsck_opts = { | |
| 845 | + | .flags = ODB_FSCK_FULL, | |
| 846 | + | .object_cb = fsck_obj_buffer, | |
| 847 | + | .object_payload = repo, | |
| 848 | + | }; | |
| 849 | + | int keep_cache_objects = 0; | |
| 850 | + | int name_objects = 0; | |
| 851 | + | int check_references = 1; | |
| 852 | + | struct option fsck_opts[] = { | |
| 853 | + | OPT__VERBOSE(&verbose, N_("be verbose")), | |
| 854 | + | OPT_BOOL(0, "unreachable", &show_unreachable, N_("show unreachable objects")), | |
| 855 | + | OPT_BOOL(0, "dangling", &show_dangling, N_("show dangling objects")), | |
| 856 | + | OPT_BOOL(0, "tags", &show_tags, N_("report tags")), | |
| 857 | + | OPT_BOOL(0, "root", &show_root, N_("report root nodes")), | |
| 858 | + | OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")), | |
| 859 | + | OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")), | |
| 860 | + | OPT_BIT(0, "full", &odb_fsck_opts.flags, | |
| 861 | + | N_("also consider packs and alternate objects"), ODB_FSCK_FULL), | |
| 862 | + | OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")), | |
| 863 | + | OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")), | |
| 864 | + | OPT_BOOL(0, "lost-found", &write_lost_and_found, | |
| 865 | + | N_("write dangling objects in .git/lost-found")), | |
| 866 | + | OPT_BOOL(0, "progress", &show_progress, N_("show progress")), | |
| 867 | + | OPT_BOOL(0, "name-objects", &name_objects, N_("show verbose names for reachable objects")), | |
| 868 | + | OPT_BOOL(0, "references", &check_references, N_("check reference database consistency")), | |
| 869 | + | OPT_END(), | |
| 870 | + | }; | |
| 1013 | 871 | struct odb_source *source; | |
| 1014 | 872 | struct snapshot snap = { | |
| 1015 | 873 | .nr = 0, | |
| @@ -1017,15 +875,15 @@ int cmd_fsck(int argc, | |||
| 1017 | 875 | .ref = NULL | |
| 1018 | 876 | }; | |
| 1019 | 877 | ||
| 1020 | - | /* fsck knows how to handle missing promisor objects */ | |
| 1021 | - | fetch_if_missing = 0; | |
| 1022 | - | ||
| 1023 | 878 | errors_found = 0; | |
| 1024 | 879 | disable_replace_refs(); | |
| 1025 | 880 | save_commit_buffer = 0; | |
| 1026 | 881 | ||
| 1027 | 882 | argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0); | |
| 1028 | 883 | ||
| 884 | + | /* fsck knows how to handle missing promisor objects */ | |
| 885 | + | repo->fetch_if_missing = 0; | |
| 886 | + | ||
| 1029 | 887 | fsck_options_init(&fsck_walk_options, repo, FSCK_OPTIONS_DEFAULT); | |
| 1030 | 888 | fsck_walk_options.walk = mark_object; | |
| 1031 | 889 | ||
| @@ -1037,11 +895,15 @@ int cmd_fsck(int argc, | |||
| 1037 | 895 | ||
| 1038 | 896 | if (show_progress == -1) | |
| 1039 | 897 | show_progress = isatty(2); | |
| 1040 | - | if (verbose) | |
| 898 | + | if (verbose) { | |
| 1041 | 899 | show_progress = 0; | |
| 900 | + | odb_fsck_opts.flags |= ODB_FSCK_VERBOSE; | |
| 901 | + | } | |
| 902 | + | if (show_progress) | |
| 903 | + | odb_fsck_opts.flags |= ODB_FSCK_PROGRESS; | |
| 1042 | 904 | ||
| 1043 | 905 | if (write_lost_and_found) { | |
| 1044 | - | check_full = 1; | |
| 906 | + | odb_fsck_opts.flags |= ODB_FSCK_FULL; | |
| 1045 | 907 | include_reflogs = 0; | |
| 1046 | 908 | } | |
| 1047 | 909 | ||
| @@ -1069,36 +931,8 @@ int cmd_fsck(int argc, | |||
| 1069 | 931 | odb_for_each_object(repo->objects, NULL, | |
| 1070 | 932 | mark_object_for_connectivity, repo, 0); | |
| 1071 | 933 | } else { | |
| 1072 | - | odb_prepare_alternates(repo->objects); | |
| 1073 | - | for (source = repo->objects->sources; source; source = source->next) | |
| 1074 | - | fsck_source(repo, source); | |
| 1075 | - | ||
| 1076 | - | if (check_full) { | |
| 1077 | - | struct packed_git *p; | |
| 1078 | - | uint32_t total = 0, count = 0; | |
| 1079 | - | struct progress *progress = NULL; | |
| 1080 | - | ||
| 1081 | - | if (show_progress) { | |
| 1082 | - | repo_for_each_pack(repo, p) { | |
| 1083 | - | if (open_pack_index(p)) | |
| 1084 | - | continue; | |
| 1085 | - | total += p->num_objects; | |
| 1086 | - | } | |
| 1087 | - | ||
| 1088 | - | progress = start_progress(repo, | |
| 1089 | - | _("Checking objects"), total); | |
| 1090 | - | } | |
| 1091 | - | ||
| 1092 | - | repo_for_each_pack(repo, p) { | |
| 1093 | - | /* verify gives error messages itself */ | |
| 1094 | - | if (verify_pack(repo, | |
| 1095 | - | p, fsck_obj_buffer, repo, | |
| 1096 | - | progress, count)) | |
| 1097 | - | errors_found |= ERROR_PACK; | |
| 1098 | - | count += p->num_objects; | |
| 1099 | - | } | |
| 1100 | - | stop_progress(&progress); | |
| 1101 | - | } | |
| 934 | + | if (odb_fsck(repo->objects, &odb_fsck_opts) < 0) | |
| 935 | + | errors_found |= ERROR_OBJECT; | |
| 1102 | 936 | ||
| 1103 | 937 | if (fsck_finish(&fsck_obj_options)) | |
| 1104 | 938 | errors_found |= ERROR_OBJECT; | |
| @@ -1121,7 +955,7 @@ int cmd_fsck(int argc, | |||
| 1121 | 955 | verify_index_checksum = 1; | |
| 1122 | 956 | verify_ce_order = 1; | |
| 1123 | 957 | ||
| 1124 | - | worktrees = get_worktrees(); | |
| 958 | + | worktrees = get_worktrees(repo); | |
| 1125 | 959 | for (p = worktrees; *p; p++) { | |
| 1126 | 960 | struct worktree *wt = *p; | |
| 1127 | 961 | struct index_state istate = | |
| @@ -1146,16 +980,11 @@ int cmd_fsck(int argc, | |||
| 1146 | 980 | free_worktrees(worktrees); | |
| 1147 | 981 | } | |
| 1148 | 982 | ||
| 1149 | - | errors_found |= check_pack_rev_indexes(repo, show_progress); | |
| 1150 | - | if (verify_bitmap_files(repo)) | |
| 1151 | - | errors_found |= ERROR_BITMAP; | |
| 1152 | - | ||
| 1153 | 983 | check_connectivity(repo); | |
| 1154 | 984 | ||
| 1155 | 985 | if (repo->settings.core_commit_graph) { | |
| 1156 | 986 | struct child_process commit_graph_verify = CHILD_PROCESS_INIT; | |
| 1157 | 987 | ||
| 1158 | - | odb_prepare_alternates(repo->objects); | |
| 1159 | 988 | for (source = repo->objects->sources; source; source = source->next) { | |
| 1160 | 989 | child_process_init(&commit_graph_verify); | |
| 1161 | 990 | commit_graph_verify.git_cmd = 1; | |
| @@ -1170,24 +999,6 @@ int cmd_fsck(int argc, | |||
| 1170 | 999 | } | |
| 1171 | 1000 | } | |
| 1172 | 1001 | ||
| 1173 | - | if (repo->settings.core_multi_pack_index) { | |
| 1174 | - | struct child_process midx_verify = CHILD_PROCESS_INIT; | |
| 1175 | - | ||
| 1176 | - | odb_prepare_alternates(repo->objects); | |
| 1177 | - | for (source = repo->objects->sources; source; source = source->next) { | |
| 1178 | - | child_process_init(&midx_verify); | |
| 1179 | - | midx_verify.git_cmd = 1; | |
| 1180 | - | strvec_pushl(&midx_verify.args, "multi-pack-index", | |
| 1181 | - | "verify", "--object-dir", source->path, NULL); | |
| 1182 | - | if (show_progress) | |
| 1183 | - | strvec_push(&midx_verify.args, "--progress"); | |
| 1184 | - | else | |
| 1185 | - | strvec_push(&midx_verify.args, "--no-progress"); | |
| 1186 | - | if (run_command(&midx_verify)) | |
| 1187 | - | errors_found |= ERROR_MULTI_PACK_INDEX; | |
| 1188 | - | } | |
| 1189 | - | } | |
| 1190 | - | ||
| 1191 | 1002 | free_snapshot_refs(&snap); | |
| 1192 | 1003 | return errors_found; | |
| 1193 | 1004 | } | |
modified builtin/fsmonitor--daemon.c
| @@ -16,7 +16,7 @@ | |||
| 16 | 16 | #include "fsmonitor--daemon.h" | |
| 17 | 17 | ||
| 18 | 18 | #include "simple-ipc.h" | |
| 19 | - | #include "khash.h" | |
| 19 | + | #include "strmap.h" | |
| 20 | 20 | #include "run-command.h" | |
| 21 | 21 | #include "trace.h" | |
| 22 | 22 | #include "trace2.h" | |
| @@ -86,6 +86,8 @@ static int do_as_client__send_stop(void) | |||
| 86 | 86 | { | |
| 87 | 87 | struct strbuf answer = STRBUF_INIT; | |
| 88 | 88 | int ret; | |
| 89 | + | int max_wait_ms = 30000; | |
| 90 | + | int elapsed_ms = 0; | |
| 89 | 91 | ||
| 90 | 92 | ret = fsmonitor_ipc__send_command("quit", &answer); | |
| 91 | 93 | ||
| @@ -96,8 +98,16 @@ static int do_as_client__send_stop(void) | |||
| 96 | 98 | return ret; | |
| 97 | 99 | ||
| 98 | 100 | trace2_region_enter("fsm_client", "polling-for-daemon-exit", NULL); | |
| 99 | - | while (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING) | |
| 101 | + | while (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING) { | |
| 102 | + | if (elapsed_ms >= max_wait_ms) { | |
| 103 | + | trace2_region_leave("fsm_client", | |
| 104 | + | "polling-for-daemon-exit", NULL); | |
| 105 | + | return error(_("daemon did not stop within %d seconds"), | |
| 106 | + | max_wait_ms / 1000); | |
| 107 | + | } | |
| 100 | 108 | sleep_millisec(50); | |
| 109 | + | elapsed_ms += 50; | |
| 110 | + | } | |
| 101 | 111 | trace2_region_leave("fsm_client", "polling-for-daemon-exit", NULL); | |
| 102 | 112 | ||
| 103 | 113 | return 0; | |
| @@ -197,20 +207,31 @@ static enum fsmonitor_cookie_item_result with_lock__wait_for_cookie( | |||
| 197 | 207 | unlink(cookie_pathname.buf); | |
| 198 | 208 | ||
| 199 | 209 | /* | |
| 200 | - | * Technically, this is an infinite wait (well, unless another | |
| 201 | - | * thread sends us an abort). I'd like to change this to | |
| 202 | - | * use `pthread_cond_timedwait()` and return an error/timeout | |
| 203 | - | * and let the caller do the trivial response thing, but we | |
| 204 | - | * don't have that routine in our thread-utils. | |
| 205 | - | * | |
| 206 | - | * After extensive beta testing I'm not really worried about | |
| 207 | - | * this. Also note that the above open() and unlink() calls | |
| 208 | - | * will cause at least two FS events on that path, so the odds | |
| 209 | - | * of getting stuck are pretty slim. | |
| 210 | + | * Wait for the listener thread to observe the cookie file. | |
| 211 | + | * Time out after a short interval so that the client | |
| 212 | + | * does not hang forever if the filesystem does not deliver | |
| 213 | + | * events (e.g., on certain container/overlay filesystems | |
| 214 | + | * where inotify watches succeed but events never arrive). | |
| 210 | 215 | */ | |
| 211 | - | while (cookie->result == FCIR_INIT) | |
| 212 | - | pthread_cond_wait(&state->cookies_cond, | |
| 213 | - | &state->main_lock); | |
| 216 | + | { | |
| 217 | + | struct timeval now; | |
| 218 | + | struct timespec ts; | |
| 219 | + | int err = 0; | |
| 220 | + | ||
| 221 | + | gettimeofday(&now, NULL); | |
| 222 | + | ts.tv_sec = now.tv_sec + 1; | |
| 223 | + | ts.tv_nsec = now.tv_usec * 1000; | |
| 224 | + | ||
| 225 | + | while (cookie->result == FCIR_INIT && !err) | |
| 226 | + | err = pthread_cond_timedwait(&state->cookies_cond, | |
| 227 | + | &state->main_lock, | |
| 228 | + | &ts); | |
| 229 | + | if (err == ETIMEDOUT && cookie->result == FCIR_INIT) { | |
| 230 | + | trace_printf_key(&trace_fsmonitor, | |
| 231 | + | "cookie_wait timed out"); | |
| 232 | + | cookie->result = FCIR_ERROR; | |
| 233 | + | } | |
| 234 | + | } | |
| 214 | 235 | ||
| 215 | 236 | done: | |
| 216 | 237 | hashmap_remove(&state->cookies, &cookie->entry, NULL); | |
| @@ -653,8 +674,6 @@ static int fsmonitor_parse_client_token(const char *buf_token, | |||
| 653 | 674 | return 0; | |
| 654 | 675 | } | |
| 655 | 676 | ||
| 656 | - | KHASH_INIT(str, const char *, int, 0, kh_str_hash_func, kh_str_hash_equal) | |
| 657 | - | ||
| 658 | 677 | static int do_handle_client(struct fsmonitor_daemon_state *state, | |
| 659 | 678 | const char *command, | |
| 660 | 679 | ipc_server_reply_cb *reply, | |
| @@ -671,8 +690,7 @@ static int do_handle_client(struct fsmonitor_daemon_state *state, | |||
| 671 | 690 | const struct fsmonitor_batch *batch; | |
| 672 | 691 | struct fsmonitor_batch *remainder = NULL; | |
| 673 | 692 | intmax_t count = 0, duplicates = 0; | |
| 674 | - | kh_str_t *shown; | |
| 675 | - | int hash_ret; | |
| 693 | + | struct strset shown = STRSET_INIT; | |
| 676 | 694 | int do_trivial = 0; | |
| 677 | 695 | int do_flush = 0; | |
| 678 | 696 | int do_cookie = 0; | |
| @@ -861,14 +879,14 @@ static int do_handle_client(struct fsmonitor_daemon_state *state, | |||
| 861 | 879 | * so walk the batch list backwards from the current head back | |
| 862 | 880 | * to the batch (sequence number) they named. | |
| 863 | 881 | * | |
| 864 | - | * We use khash to de-dup the list of pathnames. | |
| 882 | + | * We use a strset to de-dup the list of pathnames. | |
| 865 | 883 | * | |
| 866 | 884 | * NEEDSWORK: each batch contains a list of interned strings, | |
| 867 | 885 | * so we only need to do pointer comparisons here to build the | |
| 868 | 886 | * hash table. Currently, we're still comparing the string | |
| 869 | 887 | * values. | |
| 870 | 888 | */ | |
| 871 | - | shown = kh_init_str(); | |
| 889 | + | strset_init_with_options(&shown, NULL, 0); | |
| 872 | 890 | for (batch = batch_head; | |
| 873 | 891 | batch && batch->batch_seq_nr > requested_oldest_seq_nr; | |
| 874 | 892 | batch = batch->next) { | |
| @@ -878,11 +896,9 @@ static int do_handle_client(struct fsmonitor_daemon_state *state, | |||
| 878 | 896 | const char *s = batch->interned_paths[k]; | |
| 879 | 897 | size_t s_len; | |
| 880 | 898 | ||
| 881 | - | if (kh_get_str(shown, s) != kh_end(shown)) | |
| 899 | + | if (!strset_add(&shown, s)) | |
| 882 | 900 | duplicates++; | |
| 883 | 901 | else { | |
| 884 | - | kh_put_str(shown, s, &hash_ret); | |
| 885 | - | ||
| 886 | 902 | trace_printf_key(&trace_fsmonitor, | |
| 887 | 903 | "send[%"PRIuMAX"]: %s", | |
| 888 | 904 | count, s); | |
| @@ -909,8 +925,6 @@ static int do_handle_client(struct fsmonitor_daemon_state *state, | |||
| 909 | 925 | total_response_len += payload.len; | |
| 910 | 926 | } | |
| 911 | 927 | ||
| 912 | - | kh_release_str(shown); | |
| 913 | - | ||
| 914 | 928 | pthread_mutex_lock(&state->main_lock); | |
| 915 | 929 | ||
| 916 | 930 | if (token_data->client_ref_count > 0) | |
| @@ -954,6 +968,7 @@ static int do_handle_client(struct fsmonitor_daemon_state *state, | |||
| 954 | 968 | trace2_data_intmax("fsmonitor", the_repository, "response/count/duplicates", duplicates); | |
| 955 | 969 | ||
| 956 | 970 | cleanup: | |
| 971 | + | strset_clear(&shown); | |
| 957 | 972 | strbuf_release(&response_token); | |
| 958 | 973 | strbuf_release(&requested_token_id); | |
| 959 | 974 | strbuf_release(&payload); | |
| @@ -1403,8 +1418,19 @@ static int fsmonitor_run_daemon(void) | |||
| 1403 | 1418 | err = fsmonitor_run_daemon_1(&state); | |
| 1404 | 1419 | ||
| 1405 | 1420 | done: | |
| 1421 | + | fsmonitor_free_token_data(state.current_token_data); | |
| 1422 | + | state.current_token_data = NULL; | |
| 1406 | 1423 | pthread_cond_destroy(&state.cookies_cond); | |
| 1407 | 1424 | pthread_mutex_destroy(&state.main_lock); | |
| 1425 | + | { | |
| 1426 | + | struct hashmap_iter iter; | |
| 1427 | + | struct fsmonitor_cookie_item *cookie; | |
| 1428 | + | ||
| 1429 | + | hashmap_for_each_entry(&state.cookies, &iter, cookie, entry) | |
| 1430 | + | free(cookie->name); | |
| 1431 | + | hashmap_clear_and_free(&state.cookies, | |
| 1432 | + | struct fsmonitor_cookie_item, entry); | |
| 1433 | + | } | |
| 1408 | 1434 | fsm_listen__dtor(&state); | |
| 1409 | 1435 | fsm_health__dtor(&state); | |
| 1410 | 1436 | ||
| @@ -1420,7 +1446,7 @@ done: | |||
| 1420 | 1446 | return err; | |
| 1421 | 1447 | } | |
| 1422 | 1448 | ||
| 1423 | - | static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED) | |
| 1449 | + | static int try_to_run_foreground_daemon(int detach_console) | |
| 1424 | 1450 | { | |
| 1425 | 1451 | /* | |
| 1426 | 1452 | * Technically, we don't need to probe for an existing daemon | |
| @@ -1440,10 +1466,21 @@ static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED) | |||
| 1440 | 1466 | fflush(stderr); | |
| 1441 | 1467 | } | |
| 1442 | 1468 | ||
| 1469 | + | if (detach_console) { | |
| 1443 | 1470 | #ifdef GIT_WINDOWS_NATIVE | |
| 1444 | - | if (detach_console) | |
| 1445 | 1471 | FreeConsole(); | |
| 1472 | + | #else | |
| 1473 | + | /* | |
| 1474 | + | * Create a new session so that the daemon is detached | |
| 1475 | + | * from the parent's process group. This prevents | |
| 1476 | + | * shells with job control (e.g. bash with "set -m") | |
| 1477 | + | * from waiting on the daemon when they wait for a | |
| 1478 | + | * foreground command that implicitly spawned it. | |
| 1479 | + | */ | |
| 1480 | + | if (setsid() == -1) | |
| 1481 | + | warning_errno(_("setsid failed")); | |
| 1446 | 1482 | #endif | |
| 1483 | + | } | |
| 1447 | 1484 | ||
| 1448 | 1485 | return !!fsmonitor_run_daemon(); | |
| 1449 | 1486 | } | |
| @@ -1506,6 +1543,7 @@ static int try_to_start_background_daemon(void) | |||
| 1506 | 1543 | cp.no_stdin = 1; | |
| 1507 | 1544 | cp.no_stdout = 1; | |
| 1508 | 1545 | cp.no_stderr = 1; | |
| 1546 | + | cp.close_fd_above_stderr = 1; | |
| 1509 | 1547 | ||
| 1510 | 1548 | sbgr = start_bg_command(&cp, bg_wait_cb, NULL, | |
| 1511 | 1549 | fsmonitor__start_timeout_sec); | |
modified builtin/gc.c
| @@ -30,16 +30,11 @@ | |||
| 30 | 30 | #include "commit-graph.h" | |
| 31 | 31 | #include "packfile.h" | |
| 32 | 32 | #include "object-file.h" | |
| 33 | - | #include "pack.h" | |
| 34 | - | #include "pack-objects.h" | |
| 33 | + | #include "odb.h" | |
| 35 | 34 | #include "path.h" | |
| 36 | 35 | #include "reflog.h" | |
| 37 | - | #include "repack.h" | |
| 38 | 36 | #include "rerere.h" | |
| 39 | 37 | #include "revision.h" | |
| 40 | - | #include "blob.h" | |
| 41 | - | #include "tree.h" | |
| 42 | - | #include "promisor-remote.h" | |
| 43 | 38 | #include "refs.h" | |
| 44 | 39 | #include "remote.h" | |
| 45 | 40 | #include "exec-cmd.h" | |
| @@ -130,22 +125,11 @@ struct gc_config { | |||
| 130 | 125 | unsigned long max_cruft_size; | |
| 131 | 126 | int aggressive_depth; | |
| 132 | 127 | int aggressive_window; | |
| 133 | - | int gc_auto_threshold; | |
| 134 | - | int gc_auto_pack_limit; | |
| 135 | 128 | int detach_auto; | |
| 136 | 129 | char *gc_log_expire; | |
| 137 | 130 | char *prune_expire; | |
| 138 | 131 | char *prune_worktrees_expire; | |
| 139 | - | char *repack_filter; | |
| 140 | - | char *repack_filter_to; | |
| 141 | 132 | char *repack_expire_to; | |
| 142 | - | unsigned long big_pack_threshold; | |
| 143 | - | unsigned long max_delta_cache_size; | |
| 144 | - | /* | |
| 145 | - | * Remove this member from gc_config once repo_settings is passed | |
| 146 | - | * through the callchain. | |
| 147 | - | */ | |
| 148 | - | size_t delta_base_cache_limit; | |
| 149 | 133 | }; | |
| 150 | 134 | ||
| 151 | 135 | #define GC_CONFIG_INIT { \ | |
| @@ -154,14 +138,10 @@ struct gc_config { | |||
| 154 | 138 | .cruft_packs = 1, \ | |
| 155 | 139 | .aggressive_depth = 50, \ | |
| 156 | 140 | .aggressive_window = 250, \ | |
| 157 | - | .gc_auto_threshold = 6700, \ | |
| 158 | - | .gc_auto_pack_limit = 50, \ | |
| 159 | 141 | .detach_auto = 1, \ | |
| 160 | 142 | .gc_log_expire = xstrdup("1.day.ago"), \ | |
| 161 | 143 | .prune_expire = xstrdup("2.weeks.ago"), \ | |
| 162 | 144 | .prune_worktrees_expire = xstrdup("3.months.ago"), \ | |
| 163 | - | .max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE, \ | |
| 164 | - | .delta_base_cache_limit = DEFAULT_DELTA_BASE_CACHE_LIMIT, \ | |
| 165 | 145 | } | |
| 166 | 146 | ||
| 167 | 147 | static void gc_config_release(struct gc_config *cfg) | |
| @@ -169,15 +149,12 @@ static void gc_config_release(struct gc_config *cfg) | |||
| 169 | 149 | free(cfg->gc_log_expire); | |
| 170 | 150 | free(cfg->prune_expire); | |
| 171 | 151 | free(cfg->prune_worktrees_expire); | |
| 172 | - | free(cfg->repack_filter); | |
| 173 | - | free(cfg->repack_filter_to); | |
| 174 | 152 | } | |
| 175 | 153 | ||
| 176 | 154 | static void gc_config(struct gc_config *cfg) | |
| 177 | 155 | { | |
| 178 | 156 | const char *value; | |
| 179 | 157 | char *owned = NULL; | |
| 180 | - | unsigned long ulongval; | |
| 181 | 158 | ||
| 182 | 159 | if (!repo_config_get_value(the_repository, "gc.packrefs", &value)) { | |
| 183 | 160 | if (value && !strcmp(value, "notbare")) | |
| @@ -192,8 +169,6 @@ static void gc_config(struct gc_config *cfg) | |||
| 192 | 169 | ||
| 193 | 170 | repo_config_get_int(the_repository, "gc.aggressivewindow", &cfg->aggressive_window); | |
| 194 | 171 | repo_config_get_int(the_repository, "gc.aggressivedepth", &cfg->aggressive_depth); | |
| 195 | - | repo_config_get_int(the_repository, "gc.auto", &cfg->gc_auto_threshold); | |
| 196 | - | repo_config_get_int(the_repository, "gc.autopacklimit", &cfg->gc_auto_pack_limit); | |
| 197 | 172 | repo_config_get_bool(the_repository, "gc.autodetach", &cfg->detach_auto); | |
| 198 | 173 | repo_config_get_bool(the_repository, "gc.cruftpacks", &cfg->cruft_packs); | |
| 199 | 174 | repo_config_get_ulong(the_repository, "gc.maxcruftsize", &cfg->max_cruft_size); | |
| @@ -213,22 +188,6 @@ static void gc_config(struct gc_config *cfg) | |||
| 213 | 188 | cfg->gc_log_expire = owned; | |
| 214 | 189 | } | |
| 215 | 190 | ||
| 216 | - | repo_config_get_ulong(the_repository, "gc.bigpackthreshold", &cfg->big_pack_threshold); | |
| 217 | - | repo_config_get_ulong(the_repository, "pack.deltacachesize", &cfg->max_delta_cache_size); | |
| 218 | - | ||
| 219 | - | if (!repo_config_get_ulong(the_repository, "core.deltabasecachelimit", &ulongval)) | |
| 220 | - | cfg->delta_base_cache_limit = ulongval; | |
| 221 | - | ||
| 222 | - | if (!repo_config_get_string(the_repository, "gc.repackfilter", &owned)) { | |
| 223 | - | free(cfg->repack_filter); | |
| 224 | - | cfg->repack_filter = owned; | |
| 225 | - | } | |
| 226 | - | ||
| 227 | - | if (!repo_config_get_string(the_repository, "gc.repackfilterto", &owned)) { | |
| 228 | - | free(cfg->repack_filter_to); | |
| 229 | - | cfg->repack_filter_to = owned; | |
| 230 | - | } | |
| 231 | - | ||
| 232 | 191 | repo_config(the_repository, git_default_config, NULL); | |
| 233 | 192 | } | |
| 234 | 193 | ||
| @@ -412,7 +371,7 @@ static int worktree_prune_condition(struct gc_config *cfg) | |||
| 412 | 371 | while (limit && (d = readdir_skip_dot_and_dotdot(dir))) { | |
| 413 | 372 | char *wtpath; | |
| 414 | 373 | strbuf_reset(&buf); | |
| 415 | - | if (should_prune_worktree(d->d_name, &buf, &wtpath, expiry_date)) | |
| 374 | + | if (should_prune_worktree(the_repository, d->d_name, &buf, &wtpath, expiry_date)) | |
| 416 | 375 | limit--; | |
| 417 | 376 | free(wtpath); | |
| 418 | 377 | } | |
| @@ -437,282 +396,24 @@ static int maintenance_task_rerere_gc(struct maintenance_run_opts *opts UNUSED, | |||
| 437 | 396 | ||
| 438 | 397 | static int rerere_gc_condition(struct gc_config *cfg UNUSED) | |
| 439 | 398 | { | |
| 440 | - | struct strbuf path = STRBUF_INIT; | |
| 441 | - | int should_gc = 0, limit = 1; | |
| 442 | - | DIR *dir = NULL; | |
| 399 | + | int limit = 512; | |
| 443 | 400 | ||
| 444 | 401 | repo_config_get_int(the_repository, "maintenance.rerere-gc.auto", &limit); | |
| 445 | - | if (limit <= 0) { | |
| 446 | - | should_gc = limit < 0; | |
| 447 | - | goto out; | |
| 448 | - | } | |
| 449 | - | ||
| 450 | - | /* | |
| 451 | - | * We skip garbage collection in case we either have no "rr-cache" | |
| 452 | - | * directory or when it doesn't contain at least one entry. | |
| 453 | - | */ | |
| 454 | - | repo_git_path_replace(the_repository, &path, "rr-cache"); | |
| 455 | - | dir = opendir(path.buf); | |
| 456 | - | if (!dir) | |
| 457 | - | goto out; | |
| 458 | - | should_gc = !!readdir_skip_dot_and_dotdot(dir); | |
| 459 | - | ||
| 460 | - | out: | |
| 461 | - | strbuf_release(&path); | |
| 462 | - | if (dir) | |
| 463 | - | closedir(dir); | |
| 464 | - | return should_gc; | |
| 465 | - | } | |
| 466 | - | ||
| 467 | - | static int too_many_loose_objects(int limit) | |
| 468 | - | { | |
| 469 | - | /* | |
| 470 | - | * This is weird, but stems from legacy behaviour: the GC auto | |
| 471 | - | * threshold was always essentially interpreted as if it was rounded up | |
| 472 | - | * to the next multiple 256 of, so we retain this behaviour for now. | |
| 473 | - | */ | |
| 474 | - | int auto_threshold = DIV_ROUND_UP(limit, 256) * 256; | |
| 475 | - | unsigned long loose_count; | |
| 476 | - | ||
| 477 | - | if (odb_source_loose_count_objects(the_repository->objects->sources, | |
| 478 | - | ODB_COUNT_OBJECTS_APPROXIMATE, | |
| 479 | - | &loose_count) < 0) | |
| 480 | - | return 0; | |
| 481 | - | ||
| 482 | - | return loose_count > auto_threshold; | |
| 483 | - | } | |
| 484 | - | ||
| 485 | - | static struct packed_git *find_base_packs(struct string_list *packs, | |
| 486 | - | unsigned long limit) | |
| 487 | - | { | |
| 488 | - | struct packed_git *p, *base = NULL; | |
| 489 | - | ||
| 490 | - | repo_for_each_pack(the_repository, p) { | |
| 491 | - | if (!p->pack_local || p->is_cruft) | |
| 492 | - | continue; | |
| 493 | - | if (limit) { | |
| 494 | - | if (p->pack_size >= limit) | |
| 495 | - | string_list_append(packs, p->pack_name); | |
| 496 | - | } else if (!base || base->pack_size < p->pack_size) { | |
| 497 | - | base = p; | |
| 498 | - | } | |
| 499 | - | } | |
| 500 | - | ||
| 501 | - | if (base) | |
| 502 | - | string_list_append(packs, base->pack_name); | |
| 503 | - | ||
| 504 | - | return base; | |
| 505 | - | } | |
| 506 | - | ||
| 507 | - | static int too_many_packs(struct gc_config *cfg) | |
| 508 | - | { | |
| 509 | - | struct packed_git *p; | |
| 510 | - | int cnt = 0; | |
| 511 | - | ||
| 512 | - | if (cfg->gc_auto_pack_limit <= 0) | |
| 513 | - | return 0; | |
| 514 | - | ||
| 515 | - | repo_for_each_pack(the_repository, p) { | |
| 516 | - | if (!p->pack_local) | |
| 517 | - | continue; | |
| 518 | - | if (p->pack_keep) | |
| 519 | - | continue; | |
| 520 | - | /* | |
| 521 | - | * Perhaps check the size of the pack and count only | |
| 522 | - | * very small ones here? | |
| 523 | - | */ | |
| 524 | - | cnt++; | |
| 525 | - | } | |
| 526 | - | return cfg->gc_auto_pack_limit < cnt; | |
| 527 | - | } | |
| 528 | - | ||
| 529 | - | static uint64_t total_ram(void) | |
| 530 | - | { | |
| 531 | - | #if defined(HAVE_SYSINFO) | |
| 532 | - | struct sysinfo si; | |
| 533 | - | ||
| 534 | - | if (!sysinfo(&si)) { | |
| 535 | - | uint64_t total = si.totalram; | |
| 536 | - | ||
| 537 | - | if (si.mem_unit > 1) | |
| 538 | - | total *= (uint64_t)si.mem_unit; | |
| 539 | - | return total; | |
| 540 | - | } | |
| 541 | - | #elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM) || defined(HW_PHYSMEM64)) | |
| 542 | - | uint64_t physical_memory; | |
| 543 | - | int mib[2]; | |
| 544 | - | size_t length; | |
| 545 | - | ||
| 546 | - | mib[0] = CTL_HW; | |
| 547 | - | # if defined(HW_MEMSIZE) | |
| 548 | - | mib[1] = HW_MEMSIZE; | |
| 549 | - | # elif defined(HW_PHYSMEM64) | |
| 550 | - | mib[1] = HW_PHYSMEM64; | |
| 551 | - | # else | |
| 552 | - | mib[1] = HW_PHYSMEM; | |
| 553 | - | # endif | |
| 554 | - | length = sizeof(physical_memory); | |
| 555 | - | if (!sysctl(mib, 2, &physical_memory, &length, NULL, 0)) { | |
| 556 | - | if (length == 4) { | |
| 557 | - | uint32_t mem; | |
| 558 | - | ||
| 559 | - | if (!sysctl(mib, 2, &mem, &length, NULL, 0)) | |
| 560 | - | physical_memory = mem; | |
| 561 | - | } | |
| 562 | - | return physical_memory; | |
| 563 | - | } | |
| 564 | - | #elif defined(GIT_WINDOWS_NATIVE) | |
| 565 | - | MEMORYSTATUSEX memInfo; | |
| 566 | - | ||
| 567 | - | memInfo.dwLength = sizeof(MEMORYSTATUSEX); | |
| 568 | - | if (GlobalMemoryStatusEx(&memInfo)) | |
| 569 | - | return memInfo.ullTotalPhys; | |
| 570 | - | #endif | |
| 571 | - | return 0; | |
| 572 | - | } | |
| 573 | - | ||
| 574 | - | static uint64_t estimate_repack_memory(struct gc_config *cfg, | |
| 575 | - | struct packed_git *pack) | |
| 576 | - | { | |
| 577 | - | unsigned long nr_objects; | |
| 578 | - | size_t os_cache, heap; | |
| 579 | - | ||
| 580 | - | if (odb_count_objects(the_repository->objects, | |
| 581 | - | ODB_COUNT_OBJECTS_APPROXIMATE, &nr_objects) < 0) | |
| 582 | - | return 0; | |
| 583 | - | ||
| 584 | - | if (!pack || !nr_objects) | |
| 585 | - | return 0; | |
| 586 | - | ||
| 587 | - | /* | |
| 588 | - | * First we have to scan through at least one pack. | |
| 589 | - | * Assume enough room in OS file cache to keep the entire pack | |
| 590 | - | * or we may accidentally evict data of other processes from | |
| 591 | - | * the cache. | |
| 592 | - | */ | |
| 593 | - | os_cache = pack->pack_size + pack->index_size; | |
| 594 | - | /* then pack-objects needs lots more for book keeping */ | |
| 595 | - | heap = sizeof(struct object_entry) * nr_objects; | |
| 596 | - | /* | |
| 597 | - | * internal rev-list --all --objects takes up some memory too, | |
| 598 | - | * let's say half of it is for blobs | |
| 599 | - | */ | |
| 600 | - | heap += sizeof(struct blob) * nr_objects / 2; | |
| 601 | - | /* | |
| 602 | - | * and the other half is for trees (commits and tags are | |
| 603 | - | * usually insignificant) | |
| 604 | - | */ | |
| 605 | - | heap += sizeof(struct tree) * nr_objects / 2; | |
| 606 | - | /* and then obj_hash[], underestimated in fact */ | |
| 607 | - | heap += sizeof(struct object *) * nr_objects; | |
| 608 | - | /* revindex is used also */ | |
| 609 | - | heap += (sizeof(off_t) + sizeof(uint32_t)) * nr_objects; | |
| 610 | - | /* | |
| 611 | - | * read_sha1_file() (either at delta calculation phase, or | |
| 612 | - | * writing phase) also fills up the delta base cache | |
| 613 | - | */ | |
| 614 | - | heap += cfg->delta_base_cache_limit; | |
| 615 | - | /* and of course pack-objects has its own delta cache */ | |
| 616 | - | heap += cfg->max_delta_cache_size; | |
| 617 | - | ||
| 618 | - | return os_cache + heap; | |
| 619 | - | } | |
| 620 | - | ||
| 621 | - | static int keep_one_pack(struct string_list_item *item, void *data) | |
| 622 | - | { | |
| 623 | - | struct strvec *args = data; | |
| 624 | - | strvec_pushf(args, "--keep-pack=%s", basename(item->string)); | |
| 625 | - | return 0; | |
| 626 | - | } | |
| 627 | - | ||
| 628 | - | static void add_repack_all_option(struct gc_config *cfg, | |
| 629 | - | struct string_list *keep_pack, | |
| 630 | - | struct strvec *args) | |
| 631 | - | { | |
| 632 | - | if (cfg->prune_expire && !strcmp(cfg->prune_expire, "now") | |
| 633 | - | && !(cfg->cruft_packs && cfg->repack_expire_to)) | |
| 634 | - | strvec_push(args, "-a"); | |
| 635 | - | else if (cfg->cruft_packs) { | |
| 636 | - | strvec_push(args, "--cruft"); | |
| 637 | - | if (cfg->prune_expire) | |
| 638 | - | strvec_pushf(args, "--cruft-expiration=%s", cfg->prune_expire); | |
| 639 | - | if (cfg->max_cruft_size) | |
| 640 | - | strvec_pushf(args, "--max-cruft-size=%lu", | |
| 641 | - | cfg->max_cruft_size); | |
| 642 | - | if (cfg->repack_expire_to) | |
| 643 | - | strvec_pushf(args, "--expire-to=%s", cfg->repack_expire_to); | |
| 644 | - | } else { | |
| 645 | - | strvec_push(args, "-A"); | |
| 646 | - | if (cfg->prune_expire) | |
| 647 | - | strvec_pushf(args, "--unpack-unreachable=%s", cfg->prune_expire); | |
| 648 | - | } | |
| 649 | - | ||
| 650 | - | if (keep_pack) | |
| 651 | - | for_each_string_list(keep_pack, keep_one_pack, args); | |
| 652 | - | ||
| 653 | - | if (cfg->repack_filter && *cfg->repack_filter) | |
| 654 | - | strvec_pushf(args, "--filter=%s", cfg->repack_filter); | |
| 655 | - | if (cfg->repack_filter_to && *cfg->repack_filter_to) | |
| 656 | - | strvec_pushf(args, "--filter-to=%s", cfg->repack_filter_to); | |
| 657 | - | } | |
| 402 | + | if (!limit) | |
| 403 | + | return 0; /* never prune */ | |
| 404 | + | if (limit < 0) | |
| 405 | + | return 1; /* always prune */ | |
| 658 | 406 | ||
| 659 | - | static void add_repack_incremental_option(struct strvec *args) | |
| 660 | - | { | |
| 661 | - | strvec_push(args, "--no-write-bitmap-index"); | |
| 407 | + | return rerere_gc_needed(the_repository, (size_t)limit); | |
| 662 | 408 | } | |
| 663 | 409 | ||
| 664 | - | static int need_to_gc(struct gc_config *cfg, struct strvec *repack_args) | |
| 665 | - | { | |
| 666 | - | /* | |
| 667 | - | * Setting gc.auto to 0 or negative can disable the | |
| 668 | - | * automatic gc. | |
| 669 | - | */ | |
| 670 | - | if (cfg->gc_auto_threshold <= 0) | |
| 671 | - | return 0; | |
| 672 | - | ||
| 673 | - | /* | |
| 674 | - | * If there are too many loose objects, but not too many | |
| 675 | - | * packs, we run "repack -d -l". If there are too many packs, | |
| 676 | - | * we run "repack -A -d -l". Otherwise we tell the caller | |
| 677 | - | * there is no need. | |
| 678 | - | */ | |
| 679 | - | if (too_many_packs(cfg)) { | |
| 680 | - | struct string_list keep_pack = STRING_LIST_INIT_NODUP; | |
| 681 | - | ||
| 682 | - | if (cfg->big_pack_threshold) { | |
| 683 | - | find_base_packs(&keep_pack, cfg->big_pack_threshold); | |
| 684 | - | if (keep_pack.nr >= cfg->gc_auto_pack_limit) { | |
| 685 | - | cfg->big_pack_threshold = 0; | |
| 686 | - | string_list_clear(&keep_pack, 0); | |
| 687 | - | find_base_packs(&keep_pack, 0); | |
| 688 | - | } | |
| 689 | - | } else { | |
| 690 | - | struct packed_git *p = find_base_packs(&keep_pack, 0); | |
| 691 | - | uint64_t mem_have, mem_want; | |
| 692 | - | ||
| 693 | - | mem_have = total_ram(); | |
| 694 | - | mem_want = estimate_repack_memory(cfg, p); | |
| 695 | - | ||
| 696 | - | /* | |
| 697 | - | * Only allow 1/2 of memory for pack-objects, leave | |
| 698 | - | * the rest for the OS and other processes in the | |
| 699 | - | * system. | |
| 700 | - | */ | |
| 701 | - | if (!mem_have || mem_want < mem_have / 2) | |
| 702 | - | string_list_clear(&keep_pack, 0); | |
| 703 | - | } | |
| 704 | - | ||
| 705 | - | add_repack_all_option(cfg, &keep_pack, repack_args); | |
| 706 | - | string_list_clear(&keep_pack, 0); | |
| 707 | - | } else if (too_many_loose_objects(cfg->gc_auto_threshold)) | |
| 708 | - | add_repack_incremental_option(repack_args); | |
| 709 | - | else | |
| 710 | - | return 0; | |
| 711 | - | ||
| 712 | - | if (run_hooks(the_repository, "pre-auto-gc")) | |
| 713 | - | return 0; | |
| 714 | - | return 1; | |
| 715 | - | } | |
| 410 | + | #define OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, aggressive) \ | |
| 411 | + | .prune_expire = (cfg)->prune_expire, \ | |
| 412 | + | .expire_to = (cfg)->repack_expire_to, \ | |
| 413 | + | .cruft_packs = (cfg)->cruft_packs, \ | |
| 414 | + | .max_cruft_size = (cfg)->max_cruft_size, \ | |
| 415 | + | .window = (aggressive) ? (cfg)->aggressive_window : 0, \ | |
| 416 | + | .depth = (aggressive) ? (cfg)->aggressive_depth : 0 | |
| 716 | 417 | ||
| 717 | 418 | /* return NULL on success, else hostname running the gc */ | |
| 718 | 419 | static const char *lock_repo_for_gc(int force, pid_t* ret_pid) | |
| @@ -841,6 +542,27 @@ static int gc_foreground_tasks(struct maintenance_run_opts *opts, | |||
| 841 | 542 | return 0; | |
| 842 | 543 | } | |
| 843 | 544 | ||
| 545 | + | static int maintenance_task_odb(struct maintenance_run_opts *opts, | |
| 546 | + | struct gc_config *cfg, | |
| 547 | + | int keep_largest_pack, | |
| 548 | + | int aggressive) | |
| 549 | + | { | |
| 550 | + | struct odb_optimize_options odb_opts = { | |
| 551 | + | .strategy = ODB_OPTIMIZE_INCREMENTAL, | |
| 552 | + | .keep_largest_pack = keep_largest_pack, | |
| 553 | + | OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, aggressive), | |
| 554 | + | }; | |
| 555 | + | ||
| 556 | + | if (opts->auto_flag) | |
| 557 | + | odb_opts.flags |= ODB_OPTIMIZE_AUTO; | |
| 558 | + | if (!opts->quiet) | |
| 559 | + | odb_opts.flags |= ODB_OPTIMIZE_VERBOSE; | |
| 560 | + | if (aggressive) | |
| 561 | + | odb_opts.flags |= ODB_OPTIMIZE_NO_REUSE_DELTAS; | |
| 562 | + | ||
| 563 | + | return odb_optimize(the_repository->objects, &odb_opts); | |
| 564 | + | } | |
| 565 | + | ||
| 844 | 566 | int cmd_gc(int argc, | |
| 845 | 567 | const char **argv, | |
| 846 | 568 | const char *prefix, | |
| @@ -854,7 +576,6 @@ int cmd_gc(int argc, | |||
| 854 | 576 | int keep_largest_pack = -1; | |
| 855 | 577 | int skip_foreground_tasks = 0; | |
| 856 | 578 | timestamp_t dummy; | |
| 857 | - | struct strvec repack_args = STRVEC_INIT; | |
| 858 | 579 | struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT; | |
| 859 | 580 | struct gc_config cfg = GC_CONFIG_INIT; | |
| 860 | 581 | const char *prune_expire_sentinel = "sentinel"; | |
| @@ -894,15 +615,13 @@ int cmd_gc(int argc, | |||
| 894 | 615 | show_usage_with_options_if_asked(argc, argv, | |
| 895 | 616 | builtin_gc_usage, builtin_gc_options); | |
| 896 | 617 | ||
| 897 | - | strvec_pushl(&repack_args, "repack", "-d", "-l", NULL); | |
| 898 | - | ||
| 899 | 618 | gc_config(&cfg); | |
| 900 | 619 | ||
| 901 | 620 | if (parse_expiry_date(cfg.gc_log_expire, &gc_log_expire_time)) | |
| 902 | 621 | die(_("failed to parse gc.logExpiry value %s"), cfg.gc_log_expire); | |
| 903 | 622 | ||
| 904 | 623 | if (cfg.pack_refs < 0) | |
| 905 | - | cfg.pack_refs = !is_bare_repository(); | |
| 624 | + | cfg.pack_refs = !is_bare_repository(the_repository); | |
| 906 | 625 | ||
| 907 | 626 | argc = parse_options(argc, argv, prefix, builtin_gc_options, | |
| 908 | 627 | builtin_gc_usage, 0); | |
| @@ -916,24 +635,20 @@ int cmd_gc(int argc, | |||
| 916 | 635 | if (cfg.prune_expire && parse_expiry_date(cfg.prune_expire, &dummy)) | |
| 917 | 636 | die(_("failed to parse prune expiry value %s"), cfg.prune_expire); | |
| 918 | 637 | ||
| 919 | - | if (aggressive) { | |
| 920 | - | strvec_push(&repack_args, "-f"); | |
| 921 | - | if (cfg.aggressive_depth > 0) | |
| 922 | - | strvec_pushf(&repack_args, "--depth=%d", cfg.aggressive_depth); | |
| 923 | - | if (cfg.aggressive_window > 0) | |
| 924 | - | strvec_pushf(&repack_args, "--window=%d", cfg.aggressive_window); | |
| 925 | - | } | |
| 926 | - | if (opts.quiet) | |
| 927 | - | strvec_push(&repack_args, "-q"); | |
| 928 | - | ||
| 929 | 638 | if (opts.auto_flag) { | |
| 639 | + | struct odb_optimize_options optimize_opts = { | |
| 640 | + | .strategy = ODB_OPTIMIZE_INCREMENTAL, | |
| 641 | + | OPTIMIZE_FIELDS_FROM_GC_CONFIG(&cfg, 0), | |
| 642 | + | }; | |
| 643 | + | ||
| 930 | 644 | if (cfg.detach_auto && opts.detach < 0) | |
| 931 | 645 | opts.detach = 1; | |
| 932 | 646 | ||
| 933 | 647 | /* | |
| 934 | 648 | * Auto-gc should be least intrusive as possible. | |
| 935 | 649 | */ | |
| 936 | - | if (!need_to_gc(&cfg, &repack_args)) { | |
| 650 | + | if (!odb_optimize_required(the_repository->objects, &optimize_opts) || | |
| 651 | + | run_hooks(the_repository, "pre-auto-gc")) { | |
| 937 | 652 | ret = 0; | |
| 938 | 653 | goto out; | |
| 939 | 654 | } | |
| @@ -945,18 +660,6 @@ int cmd_gc(int argc, | |||
| 945 | 660 | fprintf(stderr, _("Auto packing the repository for optimum performance.\n")); | |
| 946 | 661 | fprintf(stderr, _("See \"git help gc\" for manual housekeeping.\n")); | |
| 947 | 662 | } | |
| 948 | - | } else { | |
| 949 | - | struct string_list keep_pack = STRING_LIST_INIT_NODUP; | |
| 950 | - | ||
| 951 | - | if (keep_largest_pack != -1) { | |
| 952 | - | if (keep_largest_pack) | |
| 953 | - | find_base_packs(&keep_pack, 0); | |
| 954 | - | } else if (cfg.big_pack_threshold) { | |
| 955 | - | find_base_packs(&keep_pack, cfg.big_pack_threshold); | |
| 956 | - | } | |
| 957 | - | ||
| 958 | - | add_repack_all_option(&cfg, &keep_pack, &repack_args); | |
| 959 | - | string_list_clear(&keep_pack, 0); | |
| 960 | 663 | } | |
| 961 | 664 | ||
| 962 | 665 | if (opts.detach > 0) { | |
| @@ -1012,33 +715,6 @@ int cmd_gc(int argc, | |||
| 1012 | 715 | if (opts.detach <= 0 && !skip_foreground_tasks) | |
| 1013 | 716 | gc_foreground_tasks(&opts, &cfg); | |
| 1014 | 717 | ||
| 1015 | - | if (!the_repository->repository_format_precious_objects) { | |
| 1016 | - | struct child_process repack_cmd = CHILD_PROCESS_INIT; | |
| 1017 | - | ||
| 1018 | - | repack_cmd.git_cmd = 1; | |
| 1019 | - | repack_cmd.odb_to_close = the_repository->objects; | |
| 1020 | - | strvec_pushv(&repack_cmd.args, repack_args.v); | |
| 1021 | - | if (run_command(&repack_cmd)) | |
| 1022 | - | die(FAILED_RUN, repack_args.v[0]); | |
| 1023 | - | ||
| 1024 | - | if (cfg.prune_expire) { | |
| 1025 | - | struct child_process prune_cmd = CHILD_PROCESS_INIT; | |
| 1026 | - | ||
| 1027 | - | strvec_pushl(&prune_cmd.args, "prune", "--expire", NULL); | |
| 1028 | - | /* run `git prune` even if using cruft packs */ | |
| 1029 | - | strvec_push(&prune_cmd.args, cfg.prune_expire); | |
| 1030 | - | if (opts.quiet) | |
| 1031 | - | strvec_push(&prune_cmd.args, "--no-progress"); | |
| 1032 | - | if (repo_has_promisor_remote(the_repository)) | |
| 1033 | - | strvec_push(&prune_cmd.args, | |
| 1034 | - | "--exclude-promisor-objects"); | |
| 1035 | - | prune_cmd.git_cmd = 1; | |
| 1036 | - | ||
| 1037 | - | if (run_command(&prune_cmd)) | |
| 1038 | - | die(FAILED_RUN, prune_cmd.args.v[0]); | |
| 1039 | - | } | |
| 1040 | - | } | |
| 1041 | - | ||
| 1042 | 718 | if (cfg.prune_worktrees_expire && | |
| 1043 | 719 | maintenance_task_worktree_prune(&opts, &cfg)) | |
| 1044 | 720 | die(FAILED_RUN, "worktree"); | |
| @@ -1046,6 +722,9 @@ int cmd_gc(int argc, | |||
| 1046 | 722 | if (maintenance_task_rerere_gc(&opts, &cfg)) | |
| 1047 | 723 | die(FAILED_RUN, "rerere"); | |
| 1048 | 724 | ||
| 725 | + | if (maintenance_task_odb(&opts, &cfg, keep_largest_pack, aggressive)) | |
| 726 | + | die(NULL); | |
| 727 | + | ||
| 1049 | 728 | report_garbage = report_pack_garbage; | |
| 1050 | 729 | odb_reprepare(the_repository->objects); | |
| 1051 | 730 | if (pack_garbage.nr > 0) { | |
| @@ -1058,10 +737,6 @@ int cmd_gc(int argc, | |||
| 1058 | 737 | !opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, | |
| 1059 | 738 | NULL); | |
| 1060 | 739 | ||
| 1061 | - | if (opts.auto_flag && too_many_loose_objects(cfg.gc_auto_threshold)) | |
| 1062 | - | warning(_("There are too many unreachable loose objects; " | |
| 1063 | - | "run 'git prune' to remove them.")); | |
| 1064 | - | ||
| 1065 | 740 | if (!daemonized) { | |
| 1066 | 741 | char *path = repo_git_path(the_repository, "gc.log"); | |
| 1067 | 742 | unlink(path); | |
| @@ -1070,7 +745,6 @@ int cmd_gc(int argc, | |||
| 1070 | 745 | ||
| 1071 | 746 | out: | |
| 1072 | 747 | maintenance_run_opts_release(&opts); | |
| 1073 | - | strvec_clear(&repack_args); | |
| 1074 | 748 | gc_config_release(&cfg); | |
| 1075 | 749 | return 0; | |
| 1076 | 750 | } | |
| @@ -1273,15 +947,11 @@ static int maintenance_task_gc_background(struct maintenance_run_opts *opts, | |||
| 1273 | 947 | ||
| 1274 | 948 | static int gc_condition(struct gc_config *cfg) | |
| 1275 | 949 | { | |
| 1276 | - | /* | |
| 1277 | - | * Note that it's fine to drop the repack arguments here, as we execute | |
| 1278 | - | * git-gc(1) as a separate child process anyway. So it knows to compute | |
| 1279 | - | * these arguments again. | |
| 1280 | - | */ | |
| 1281 | - | struct strvec repack_args = STRVEC_INIT; | |
| 1282 | - | int ret = need_to_gc(cfg, &repack_args); | |
| 1283 | - | strvec_clear(&repack_args); | |
| 1284 | - | return ret; | |
| 950 | + | struct odb_optimize_options opts = { | |
| 951 | + | .strategy = ODB_OPTIMIZE_INCREMENTAL, | |
| 952 | + | OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, 0), | |
| 953 | + | }; | |
| 954 | + | return odb_optimize_required(the_repository->objects, &opts); | |
| 1285 | 955 | } | |
| 1286 | 956 | ||
| 1287 | 957 | static int prune_packed(struct maintenance_run_opts *opts) | |
| @@ -1570,104 +1240,24 @@ static int maintenance_task_incremental_repack(struct maintenance_run_opts *opts | |||
| 1570 | 1240 | static int maintenance_task_geometric_repack(struct maintenance_run_opts *opts, | |
| 1571 | 1241 | struct gc_config *cfg) | |
| 1572 | 1242 | { | |
| 1573 | - | struct pack_geometry geometry = { | |
| 1574 | - | .split_factor = 2, | |
| 1575 | - | }; | |
| 1576 | - | struct pack_objects_args po_args = { | |
| 1577 | - | .local = 1, | |
| 1243 | + | struct odb_optimize_options odb_opts = { | |
| 1244 | + | .strategy = ODB_OPTIMIZE_GEOMETRIC, | |
| 1245 | + | OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, 0), | |
| 1578 | 1246 | }; | |
| 1579 | - | struct existing_packs existing_packs = EXISTING_PACKS_INIT; | |
| 1580 | - | struct string_list kept_packs = STRING_LIST_INIT_DUP; | |
| 1581 | - | struct child_process child = CHILD_PROCESS_INIT; | |
| 1582 | - | int ret; | |
| 1583 | - | ||
| 1584 | - | repo_config_get_int(the_repository, "maintenance.geometric-repack.splitFactor", | |
| 1585 | - | &geometry.split_factor); | |
| 1586 | - | ||
| 1587 | - | existing_packs.repo = the_repository; | |
| 1588 | - | existing_packs_collect(&existing_packs, &kept_packs); | |
| 1589 | - | pack_geometry_init(&geometry, &existing_packs, &po_args); | |
| 1590 | - | pack_geometry_split(&geometry); | |
| 1591 | - | ||
| 1592 | - | child.git_cmd = 1; | |
| 1593 | - | child.odb_to_close = the_repository->objects; | |
| 1594 | - | ||
| 1595 | - | strvec_pushl(&child.args, "repack", "-d", "-l", NULL); | |
| 1596 | - | if (geometry.split < geometry.pack_nr) | |
| 1597 | - | strvec_pushf(&child.args, "--geometric=%d", | |
| 1598 | - | geometry.split_factor); | |
| 1599 | - | else | |
| 1600 | - | add_repack_all_option(cfg, NULL, &child.args); | |
| 1601 | - | if (opts->quiet) | |
| 1602 | - | strvec_push(&child.args, "--quiet"); | |
| 1603 | - | if (the_repository->settings.core_multi_pack_index) | |
| 1604 | - | strvec_push(&child.args, "--write-midx"); | |
| 1605 | - | ||
| 1606 | - | if (run_command(&child)) { | |
| 1607 | - | ret = error(_("failed to perform geometric repack")); | |
| 1608 | - | goto out; | |
| 1609 | - | } | |
| 1610 | 1247 | ||
| 1611 | - | ret = 0; | |
| 1248 | + | if (!opts->quiet) | |
| 1249 | + | odb_opts.flags |= ODB_OPTIMIZE_VERBOSE; | |
| 1612 | 1250 | ||
| 1613 | - | out: | |
| 1614 | - | existing_packs_release(&existing_packs); | |
| 1615 | - | pack_geometry_release(&geometry); | |
| 1616 | - | return ret; | |
| 1251 | + | return odb_optimize(the_repository->objects, &odb_opts); | |
| 1617 | 1252 | } | |
| 1618 | 1253 | ||
| 1619 | - | static int geometric_repack_auto_condition(struct gc_config *cfg UNUSED) | |
| 1254 | + | static int geometric_repack_auto_condition(struct gc_config *cfg) | |
| 1620 | 1255 | { | |
| 1621 | - | struct pack_geometry geometry = { | |
| 1622 | - | .split_factor = 2, | |
| 1623 | - | }; | |
| 1624 | - | struct pack_objects_args po_args = { | |
| 1625 | - | .local = 1, | |
| 1256 | + | struct odb_optimize_options opts = { | |
| 1257 | + | .strategy = ODB_OPTIMIZE_GEOMETRIC, | |
| 1258 | + | OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, 0), | |
| 1626 | 1259 | }; | |
| 1627 | - | struct existing_packs existing_packs = EXISTING_PACKS_INIT; | |
| 1628 | - | struct string_list kept_packs = STRING_LIST_INIT_DUP; | |
| 1629 | - | int auto_value = 100; | |
| 1630 | - | int ret; | |
| 1631 | - | ||
| 1632 | - | repo_config_get_int(the_repository, "maintenance.geometric-repack.auto", | |
| 1633 | - | &auto_value); | |
| 1634 | - | if (!auto_value) | |
| 1635 | - | return 0; | |
| 1636 | - | if (auto_value < 0) | |
| 1637 | - | return 1; | |
| 1638 | - | ||
| 1639 | - | repo_config_get_int(the_repository, "maintenance.geometric-repack.splitFactor", | |
| 1640 | - | &geometry.split_factor); | |
| 1641 | - | ||
| 1642 | - | existing_packs.repo = the_repository; | |
| 1643 | - | existing_packs_collect(&existing_packs, &kept_packs); | |
| 1644 | - | pack_geometry_init(&geometry, &existing_packs, &po_args); | |
| 1645 | - | pack_geometry_split(&geometry); | |
| 1646 | - | ||
| 1647 | - | /* | |
| 1648 | - | * When we'd merge at least two packs with one another we always | |
| 1649 | - | * perform the repack. | |
| 1650 | - | */ | |
| 1651 | - | if (geometry.split) { | |
| 1652 | - | ret = 1; | |
| 1653 | - | goto out; | |
| 1654 | - | } | |
| 1655 | - | ||
| 1656 | - | /* | |
| 1657 | - | * Otherwise, we estimate the number of loose objects to determine | |
| 1658 | - | * whether we want to create a new packfile or not. | |
| 1659 | - | */ | |
| 1660 | - | if (too_many_loose_objects(auto_value)) { | |
| 1661 | - | ret = 1; | |
| 1662 | - | goto out; | |
| 1663 | - | } | |
| 1664 | - | ||
| 1665 | - | ret = 0; | |
| 1666 | - | ||
| 1667 | - | out: | |
| 1668 | - | existing_packs_release(&existing_packs); | |
| 1669 | - | pack_geometry_release(&geometry); | |
| 1670 | - | return ret; | |
| 1260 | + | return odb_optimize_required(the_repository->objects, &opts); | |
| 1671 | 1261 | } | |
| 1672 | 1262 | ||
| 1673 | 1263 | typedef int (*maintenance_task_fn)(struct maintenance_run_opts *opts, | |
| @@ -1755,11 +1345,18 @@ enum task_phase { | |||
| 1755 | 1345 | TASK_PHASE_BACKGROUND, | |
| 1756 | 1346 | }; | |
| 1757 | 1347 | ||
| 1348 | + | enum auto_gc_hook_result { | |
| 1349 | + | AUTO_GC_HOOK_UNDECIDED = 0, | |
| 1350 | + | AUTO_GC_HOOK_RUN = 1, | |
| 1351 | + | AUTO_GC_HOOK_SKIP = 2, | |
| 1352 | + | }; | |
| 1353 | + | ||
| 1758 | 1354 | static int maybe_run_task(const struct maintenance_task *task, | |
| 1759 | 1355 | struct repository *repo, | |
| 1760 | 1356 | struct maintenance_run_opts *opts, | |
| 1761 | 1357 | struct gc_config *cfg, | |
| 1762 | - | enum task_phase phase) | |
| 1358 | + | enum task_phase phase, | |
| 1359 | + | enum auto_gc_hook_result *auto_gc_hook_result) | |
| 1763 | 1360 | { | |
| 1764 | 1361 | int foreground = (phase == TASK_PHASE_FOREGROUND); | |
| 1765 | 1362 | maintenance_task_fn fn = foreground ? task->foreground : task->background; | |
| @@ -1768,9 +1365,19 @@ static int maybe_run_task(const struct maintenance_task *task, | |||
| 1768 | 1365 | ||
| 1769 | 1366 | if (!fn) | |
| 1770 | 1367 | return 0; | |
| 1771 | - | if (opts->auto_flag && | |
| 1772 | - | (!task->auto_condition || !task->auto_condition(cfg))) | |
| 1773 | - | return 0; | |
| 1368 | + | if (opts->auto_flag) { | |
| 1369 | + | if (*auto_gc_hook_result == AUTO_GC_HOOK_SKIP) | |
| 1370 | + | return 0; | |
| 1371 | + | ||
| 1372 | + | if (!task->auto_condition || !task->auto_condition(cfg)) | |
| 1373 | + | return 0; | |
| 1374 | + | ||
| 1375 | + | if (*auto_gc_hook_result == AUTO_GC_HOOK_UNDECIDED) | |
| 1376 | + | *auto_gc_hook_result = run_hooks(repo, "pre-auto-gc") ? | |
| 1377 | + | AUTO_GC_HOOK_SKIP : AUTO_GC_HOOK_RUN; | |
| 1378 | + | if (*auto_gc_hook_result == AUTO_GC_HOOK_SKIP) | |
| 1379 | + | return 0; | |
| 1380 | + | } | |
| 1774 | 1381 | ||
| 1775 | 1382 | trace2_region_enter(region, task->name, repo); | |
| 1776 | 1383 | if (fn(opts, cfg)) { | |
| @@ -1789,8 +1396,9 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts, | |||
| 1789 | 1396 | struct lock_file lk; | |
| 1790 | 1397 | struct repository *r = the_repository; | |
| 1791 | 1398 | char *lock_path = xstrfmt("%s/maintenance", r->objects->sources->path); | |
| 1399 | + | enum auto_gc_hook_result auto_gc_hook_result = AUTO_GC_HOOK_UNDECIDED; | |
| 1792 | 1400 | ||
| 1793 | - | if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) { | |
| 1401 | + | if (repo_hold_lock_file_for_update(r, &lk, lock_path, LOCK_NO_DEREF) < 0) { | |
| 1794 | 1402 | /* | |
| 1795 | 1403 | * Another maintenance command is running. | |
| 1796 | 1404 | * | |
| @@ -1808,7 +1416,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts, | |||
| 1808 | 1416 | ||
| 1809 | 1417 | for (size_t i = 0; i < opts->tasks_nr; i++) | |
| 1810 | 1418 | if (maybe_run_task(&tasks[opts->tasks[i]], r, opts, cfg, | |
| 1811 | - | TASK_PHASE_FOREGROUND)) | |
| 1419 | + | TASK_PHASE_FOREGROUND, &auto_gc_hook_result)) | |
| 1812 | 1420 | result = 1; | |
| 1813 | 1421 | ||
| 1814 | 1422 | /* Failure to daemonize is ok, we'll continue in foreground. */ | |
| @@ -1820,7 +1428,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts, | |||
| 1820 | 1428 | ||
| 1821 | 1429 | for (size_t i = 0; i < opts->tasks_nr; i++) | |
| 1822 | 1430 | if (maybe_run_task(&tasks[opts->tasks[i]], r, opts, cfg, | |
| 1823 | - | TASK_PHASE_BACKGROUND)) | |
| 1431 | + | TASK_PHASE_BACKGROUND, &auto_gc_hook_result)) | |
| 1824 | 1432 | result = 1; | |
| 1825 | 1433 | ||
| 1826 | 1434 | rollback_lock_file(&lk); | |
modified builtin/grep.c
| @@ -25,12 +25,14 @@ | |||
| 25 | 25 | #include "setup.h" | |
| 26 | 26 | #include "submodule.h" | |
| 27 | 27 | #include "submodule-config.h" | |
| 28 | - | #include "object-file.h" | |
| 29 | 28 | #include "object-name.h" | |
| 30 | 29 | #include "odb.h" | |
| 31 | - | #include "packfile.h" | |
| 30 | + | #include "odb/source.h" | |
| 31 | + | #include "oid-array.h" | |
| 32 | + | #include "oidset.h" | |
| 32 | 33 | #include "pager.h" | |
| 33 | 34 | #include "path.h" | |
| 35 | + | #include "promisor-remote.h" | |
| 34 | 36 | #include "read-cache-ll.h" | |
| 35 | 37 | #include "write-or-die.h" | |
| 36 | 38 | ||
| @@ -461,16 +463,6 @@ static int grep_submodule(struct grep_opt *opt, | |||
| 461 | 463 | ALLOC_GROW(repos_to_free, repos_to_free_nr + 1, repos_to_free_alloc); | |
| 462 | 464 | repos_to_free[repos_to_free_nr++] = subrepo; | |
| 463 | 465 | ||
| 464 | - | /* | |
| 465 | - | * NEEDSWORK: repo_read_gitmodules() might call | |
| 466 | - | * odb_add_to_alternates_memory() via config_from_gitmodules(). This | |
| 467 | - | * operation causes a race condition with concurrent object readings | |
| 468 | - | * performed by the worker threads. That's why we need obj_read_lock() | |
| 469 | - | * here. It should be removed once it's no longer necessary to add the | |
| 470 | - | * subrepo's odbs to the in-memory alternates list. | |
| 471 | - | */ | |
| 472 | - | obj_read_lock(); | |
| 473 | - | ||
| 474 | 466 | /* | |
| 475 | 467 | * NEEDSWORK: when reading a submodule, the sparsity settings in the | |
| 476 | 468 | * superproject are incorrectly forgotten or misused. For example: | |
| @@ -496,18 +488,14 @@ static int grep_submodule(struct grep_opt *opt, | |||
| 496 | 488 | * ditto. | |
| 497 | 489 | * | |
| 498 | 490 | * Note that this list is not exhaustive. | |
| 491 | + | * | |
| 492 | + | * NEEDSWORK: initializing the subrepository is not thread-safe, | |
| 493 | + | * either, as it may cause us to race around `get_main_ref_store()`. We | |
| 494 | + | * thus need to hold the object-read lock to serialize all readers with | |
| 495 | + | * one another. | |
| 499 | 496 | */ | |
| 497 | + | obj_read_lock(); | |
| 500 | 498 | repo_read_gitmodules(subrepo, 0); | |
| 501 | - | ||
| 502 | - | /* | |
| 503 | - | * All code paths tested by test code no longer need submodule ODBs to | |
| 504 | - | * be added as alternates, but add it to the list just in case. | |
| 505 | - | * Submodule ODBs added through add_submodule_odb_by_path() will be | |
| 506 | - | * lazily registered as alternates when needed (and except in an | |
| 507 | - | * unexpected code interaction, it won't be needed). | |
| 508 | - | */ | |
| 509 | - | odb_add_submodule_source_by_path(the_repository->objects, | |
| 510 | - | subrepo->objects->sources->path); | |
| 511 | 499 | obj_read_unlock(); | |
| 512 | 500 | ||
| 513 | 501 | memcpy(&subopt, opt, sizeof(subopt)); | |
| @@ -517,7 +505,7 @@ static int grep_submodule(struct grep_opt *opt, | |||
| 517 | 505 | enum object_type object_type; | |
| 518 | 506 | struct tree_desc tree; | |
| 519 | 507 | void *data; | |
| 520 | - | unsigned long size; | |
| 508 | + | size_t size; | |
| 521 | 509 | struct strbuf base = STRBUF_INIT; | |
| 522 | 510 | ||
| 523 | 511 | obj_read_lock(); | |
| @@ -570,7 +558,7 @@ static int grep_cache(struct grep_opt *opt, | |||
| 570 | 558 | enum object_type type; | |
| 571 | 559 | struct tree_desc tree; | |
| 572 | 560 | void *data; | |
| 573 | - | unsigned long size; | |
| 561 | + | size_t size; | |
| 574 | 562 | ||
| 575 | 563 | data = odb_read_object(the_repository->objects, &ce->oid, | |
| 576 | 564 | &type, &size); | |
| @@ -663,7 +651,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, | |||
| 663 | 651 | enum object_type type; | |
| 664 | 652 | struct tree_desc sub; | |
| 665 | 653 | void *data; | |
| 666 | - | unsigned long size; | |
| 654 | + | size_t size; | |
| 667 | 655 | ||
| 668 | 656 | data = odb_read_object(the_repository->objects, | |
| 669 | 657 | &entry.oid, &type, &size); | |
| @@ -692,6 +680,144 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, | |||
| 692 | 680 | return hit; | |
| 693 | 681 | } | |
| 694 | 682 | ||
| 683 | + | static void collect_blob_oids_for_tree(struct repository *repo, | |
| 684 | + | const struct pathspec *pathspec, | |
| 685 | + | struct tree_desc *tree, | |
| 686 | + | struct strbuf *base, | |
| 687 | + | int tn_len, | |
| 688 | + | struct oidset *blob_oids) | |
| 689 | + | { | |
| 690 | + | struct name_entry entry; | |
| 691 | + | int old_baselen = base->len; | |
| 692 | + | struct strbuf name = STRBUF_INIT; | |
| 693 | + | enum interesting match = entry_not_interesting; | |
| 694 | + | ||
| 695 | + | while (tree_entry(tree, &entry)) { | |
| 696 | + | if (match != all_entries_interesting) { | |
| 697 | + | strbuf_addstr(&name, base->buf + tn_len); | |
| 698 | + | match = tree_entry_interesting(repo->index, | |
| 699 | + | &entry, &name, | |
| 700 | + | pathspec); | |
| 701 | + | strbuf_reset(&name); | |
| 702 | + | ||
| 703 | + | if (match == all_entries_not_interesting) | |
| 704 | + | break; | |
| 705 | + | if (match == entry_not_interesting) | |
| 706 | + | continue; | |
| 707 | + | } | |
| 708 | + | ||
| 709 | + | strbuf_add(base, entry.path, tree_entry_len(&entry)); | |
| 710 | + | ||
| 711 | + | if (S_ISREG(entry.mode)) { | |
| 712 | + | if (!odb_has_object(repo->objects, &entry.oid, 0)) | |
| 713 | + | oidset_insert(blob_oids, &entry.oid); | |
| 714 | + | } else if (S_ISDIR(entry.mode)) { | |
| 715 | + | enum object_type type; | |
| 716 | + | struct tree_desc sub_tree; | |
| 717 | + | void *data; | |
| 718 | + | size_t size; | |
| 719 | + | ||
| 720 | + | data = odb_read_object(repo->objects, &entry.oid, | |
| 721 | + | &type, &size); | |
| 722 | + | if (!data) | |
| 723 | + | die(_("unable to read tree (%s)"), | |
| 724 | + | oid_to_hex(&entry.oid)); | |
| 725 | + | ||
| 726 | + | strbuf_addch(base, '/'); | |
| 727 | + | init_tree_desc(&sub_tree, &entry.oid, data, size); | |
| 728 | + | collect_blob_oids_for_tree(repo, pathspec, &sub_tree, | |
| 729 | + | base, tn_len, blob_oids); | |
| 730 | + | free(data); | |
| 731 | + | } | |
| 732 | + | /* | |
| 733 | + | * ...no else clause for S_ISGITLINK: submodules have their | |
| 734 | + | * own promisor configuration and would need separate fetches | |
| 735 | + | * anyway. | |
| 736 | + | */ | |
| 737 | + | ||
| 738 | + | strbuf_setlen(base, old_baselen); | |
| 739 | + | } | |
| 740 | + | ||
| 741 | + | strbuf_release(&name); | |
| 742 | + | } | |
| 743 | + | ||
| 744 | + | static void collect_blob_oids_for_treeish(struct grep_opt *opt, | |
| 745 | + | const struct pathspec *pathspec, | |
| 746 | + | const struct object_id *tree_ish_oid, | |
| 747 | + | const char *name, | |
| 748 | + | struct oidset *blob_oids) | |
| 749 | + | { | |
| 750 | + | struct tree_desc tree; | |
| 751 | + | void *data; | |
| 752 | + | size_t size; | |
| 753 | + | struct strbuf base = STRBUF_INIT; | |
| 754 | + | int len; | |
| 755 | + | ||
| 756 | + | data = odb_read_object_peeled(opt->repo->objects, tree_ish_oid, | |
| 757 | + | OBJ_TREE, &size, NULL); | |
| 758 | + | ||
| 759 | + | if (!data) | |
| 760 | + | return; | |
| 761 | + | ||
| 762 | + | len = name ? strlen(name) : 0; | |
| 763 | + | if (len) { | |
| 764 | + | strbuf_add(&base, name, len); | |
| 765 | + | strbuf_addch(&base, ':'); | |
| 766 | + | } | |
| 767 | + | init_tree_desc(&tree, tree_ish_oid, data, size); | |
| 768 | + | ||
| 769 | + | collect_blob_oids_for_tree(opt->repo, pathspec, &tree, | |
| 770 | + | &base, base.len, blob_oids); | |
| 771 | + | ||
| 772 | + | strbuf_release(&base); | |
| 773 | + | free(data); | |
| 774 | + | } | |
| 775 | + | ||
| 776 | + | static void prefetch_grep_blobs(struct grep_opt *opt, | |
| 777 | + | const struct pathspec *pathspec, | |
| 778 | + | const struct object_array *list) | |
| 779 | + | { | |
| 780 | + | struct oidset blob_oids = OIDSET_INIT; | |
| 781 | + | ||
| 782 | + | /* Exit if we're not in a partial clone */ | |
| 783 | + | if (!repo_has_promisor_remote(opt->repo)) | |
| 784 | + | return; | |
| 785 | + | ||
| 786 | + | /* For each tree, gather the blobs in it */ | |
| 787 | + | for (int i = 0; i < list->nr; i++) { | |
| 788 | + | struct object *real_obj; | |
| 789 | + | ||
| 790 | + | obj_read_lock(); | |
| 791 | + | real_obj = deref_tag(opt->repo, list->objects[i].item, | |
| 792 | + | NULL, 0); | |
| 793 | + | obj_read_unlock(); | |
| 794 | + | ||
| 795 | + | if (real_obj && | |
| 796 | + | (real_obj->type == OBJ_COMMIT || | |
| 797 | + | real_obj->type == OBJ_TREE)) | |
| 798 | + | collect_blob_oids_for_treeish(opt, pathspec, | |
| 799 | + | &real_obj->oid, | |
| 800 | + | list->objects[i].name, | |
| 801 | + | &blob_oids); | |
| 802 | + | } | |
| 803 | + | ||
| 804 | + | /* Prefetch the blobs we found */ | |
| 805 | + | if (oidset_size(&blob_oids)) { | |
| 806 | + | struct oid_array to_fetch = OID_ARRAY_INIT; | |
| 807 | + | struct oidset_iter iter; | |
| 808 | + | const struct object_id *oid; | |
| 809 | + | ||
| 810 | + | oidset_iter_init(&blob_oids, &iter); | |
| 811 | + | while ((oid = oidset_iter_next(&iter))) | |
| 812 | + | oid_array_append(&to_fetch, oid); | |
| 813 | + | ||
| 814 | + | promisor_remote_get_direct(opt->repo, to_fetch.oid, to_fetch.nr); | |
| 815 | + | ||
| 816 | + | oid_array_clear(&to_fetch); | |
| 817 | + | } | |
| 818 | + | oidset_clear(&blob_oids); | |
| 819 | + | } | |
| 820 | + | ||
| 695 | 821 | static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec, | |
| 696 | 822 | struct object *obj, const char *name, const char *path) | |
| 697 | 823 | { | |
| @@ -700,7 +826,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec, | |||
| 700 | 826 | if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) { | |
| 701 | 827 | struct tree_desc tree; | |
| 702 | 828 | void *data; | |
| 703 | - | unsigned long size; | |
| 829 | + | size_t size; | |
| 704 | 830 | struct strbuf base; | |
| 705 | 831 | int hit, len; | |
| 706 | 832 | ||
| @@ -732,6 +858,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec, | |||
| 732 | 858 | int hit = 0; | |
| 733 | 859 | const unsigned int nr = list->nr; | |
| 734 | 860 | ||
| 861 | + | prefetch_grep_blobs(opt, pathspec, list); | |
| 862 | + | ||
| 735 | 863 | for (i = 0; i < nr; i++) { | |
| 736 | 864 | struct object *real_obj; | |
| 737 | 865 | ||
| @@ -755,7 +883,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec, | |||
| 755 | 883 | if (recurse_submodules) { | |
| 756 | 884 | submodule_free(opt->repo); | |
| 757 | 885 | obj_read_lock(); | |
| 758 | - | gitmodules_config_oid(&real_obj->oid); | |
| 886 | + | gitmodules_config_oid(the_repository, &real_obj->oid); | |
| 759 | 887 | obj_read_unlock(); | |
| 760 | 888 | } | |
| 761 | 889 | if (grep_object(opt, pathspec, real_obj, list->objects[i].name, | |
| @@ -1064,7 +1192,7 @@ int cmd_grep(int argc, | |||
| 1064 | 1192 | use_index = 0; | |
| 1065 | 1193 | else | |
| 1066 | 1194 | /* die the same way as if we did it at the beginning */ | |
| 1067 | - | setup_git_directory(); | |
| 1195 | + | setup_git_directory(the_repository); | |
| 1068 | 1196 | } | |
| 1069 | 1197 | /* Ignore --recurse-submodules if --no-index is given or implied */ | |
| 1070 | 1198 | if (!use_index) | |
| @@ -1151,7 +1279,7 @@ int cmd_grep(int argc, | |||
| 1151 | 1279 | ||
| 1152 | 1280 | object = parse_object_or_die(the_repository, &oid, arg); | |
| 1153 | 1281 | if (!seen_dashdash) | |
| 1154 | - | verify_non_filename(prefix, arg); | |
| 1282 | + | verify_non_filename(the_repository, prefix, arg); | |
| 1155 | 1283 | add_object_array_with_path(object, arg, &list, oc.mode, oc.path); | |
| 1156 | 1284 | object_context_release(&oc); | |
| 1157 | 1285 | } | |
| @@ -1163,7 +1291,7 @@ int cmd_grep(int argc, | |||
| 1163 | 1291 | if (!seen_dashdash) { | |
| 1164 | 1292 | int j; | |
| 1165 | 1293 | for (j = i; j < argc; j++) | |
| 1166 | - | verify_filename(prefix, argv[j], j == i && allow_revs); | |
| 1294 | + | verify_filename(the_repository, prefix, argv[j], j == i && allow_revs); | |
| 1167 | 1295 | } | |
| 1168 | 1296 | ||
| 1169 | 1297 | parse_pathspec(&pathspec, 0, | |
| @@ -1214,15 +1342,8 @@ int cmd_grep(int argc, | |||
| 1214 | 1342 | if (recurse_submodules) | |
| 1215 | 1343 | repo_read_gitmodules(the_repository, 1); | |
| 1216 | 1344 | ||
| 1217 | - | if (startup_info->have_repository) { | |
| 1218 | - | struct odb_source *source; | |
| 1219 | - | ||
| 1220 | - | odb_prepare_alternates(the_repository->objects); | |
| 1221 | - | for (source = the_repository->objects->sources; source; source = source->next) { | |
| 1222 | - | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 1223 | - | packfile_store_prepare(files->packed); | |
| 1224 | - | } | |
| 1225 | - | } | |
| 1345 | + | if (startup_info->have_repository) | |
| 1346 | + | odb_prepare(the_repository->objects, 0); | |
| 1226 | 1347 | ||
| 1227 | 1348 | start_threads(&opt); | |
| 1228 | 1349 | } else { | |
| @@ -1272,7 +1393,7 @@ int cmd_grep(int argc, | |||
| 1272 | 1393 | die(_("--[no-]exclude-standard cannot be used for tracked contents")); | |
| 1273 | 1394 | } else if (!list.nr) { | |
| 1274 | 1395 | if (!cached) | |
| 1275 | - | setup_work_tree(); | |
| 1396 | + | setup_work_tree(the_repository); | |
| 1276 | 1397 | ||
| 1277 | 1398 | hit = grep_cache(&opt, &pathspec, cached); | |
| 1278 | 1399 | } else { | |
modified builtin/hash-object.c
| @@ -100,9 +100,9 @@ int cmd_hash_object(int argc, | |||
| 100 | 100 | hash_object_usage, 0); | |
| 101 | 101 | ||
| 102 | 102 | if (flags & INDEX_WRITE_OBJECT) | |
| 103 | - | prefix = setup_git_directory(); | |
| 103 | + | prefix = setup_git_directory(the_repository); | |
| 104 | 104 | else | |
| 105 | - | prefix = setup_git_directory_gently(&nongit); | |
| 105 | + | prefix = setup_git_directory_gently(the_repository, &nongit); | |
| 106 | 106 | ||
| 107 | 107 | if (nongit && !the_hash_algo) | |
| 108 | 108 | repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); | |
modified builtin/help.c
| @@ -740,7 +740,7 @@ int cmd_help(int argc, | |||
| 740 | 740 | return 0; | |
| 741 | 741 | } | |
| 742 | 742 | ||
| 743 | - | setup_git_directory_gently(&nongit); | |
| 743 | + | setup_git_directory_gently(the_repository, &nongit); | |
| 744 | 744 | repo_config(the_repository, git_help_config, NULL); | |
| 745 | 745 | ||
| 746 | 746 | if (parsed_help_format != HELP_FORMAT_NONE) | |
modified builtin/history.c
| @@ -10,19 +10,26 @@ | |||
| 10 | 10 | #include "gettext.h" | |
| 11 | 11 | #include "hex.h" | |
| 12 | 12 | #include "lockfile.h" | |
| 13 | + | #include "merge-ort.h" | |
| 13 | 14 | #include "oidmap.h" | |
| 14 | 15 | #include "parse-options.h" | |
| 15 | 16 | #include "path.h" | |
| 16 | 17 | #include "read-cache.h" | |
| 17 | 18 | #include "refs.h" | |
| 18 | 19 | #include "replay.h" | |
| 20 | + | #include "reset.h" | |
| 19 | 21 | #include "revision.h" | |
| 20 | 22 | #include "sequencer.h" | |
| 21 | 23 | #include "strvec.h" | |
| 22 | 24 | #include "tree.h" | |
| 25 | + | #include "tree-walk.h" | |
| 23 | 26 | #include "unpack-trees.h" | |
| 24 | 27 | #include "wt-status.h" | |
| 25 | 28 | ||
| 29 | + | #define GIT_HISTORY_DROP_USAGE \ | |
| 30 | + | N_("git history drop <commit> [--dry-run] [--update-refs=(branches|head)] [--empty=(drop|keep|abort)]") | |
| 31 | + | #define GIT_HISTORY_FIXUP_USAGE \ | |
| 32 | + | N_("git history fixup <commit> [--dry-run] [--update-refs=(branches|head)] [--reedit-message] [--empty=(drop|keep|abort)]") | |
| 26 | 33 | #define GIT_HISTORY_REWORD_USAGE \ | |
| 27 | 34 | N_("git history reword <commit> [--dry-run] [--update-refs=(branches|head)]") | |
| 28 | 35 | #define GIT_HISTORY_SPLIT_USAGE \ | |
| @@ -49,11 +56,6 @@ static int fill_commit_message(struct repository *repo, | |||
| 49 | 56 | " empty message aborts the commit.\n"); | |
| 50 | 57 | struct wt_status s; | |
| 51 | 58 | ||
| 52 | - | strbuf_addstr(out, default_message); | |
| 53 | - | strbuf_addch(out, '\n'); | |
| 54 | - | strbuf_commented_addf(out, comment_line_str, hint, action, comment_line_str); | |
| 55 | - | write_file_buf(path, out->buf, out->len); | |
| 56 | - | ||
| 57 | 59 | wt_status_prepare(repo, &s); | |
| 58 | 60 | FREE_AND_NULL(s.branch); | |
| 59 | 61 | s.ahead_behind_flags = AHEAD_BEHIND_QUICK; | |
| @@ -65,14 +67,22 @@ static int fill_commit_message(struct repository *repo, | |||
| 65 | 67 | s.whence = FROM_COMMIT; | |
| 66 | 68 | s.committable = 1; | |
| 67 | 69 | ||
| 68 | - | s.fp = fopen(git_path_commit_editmsg(), "a"); | |
| 70 | + | s.fp = fopen(path, "w"); | |
| 69 | 71 | if (!s.fp) | |
| 70 | - | return error_errno(_("could not open '%s'"), git_path_commit_editmsg()); | |
| 72 | + | return error_errno(_("could not open '%s'"), path); | |
| 73 | + | ||
| 74 | + | strbuf_addstr(out, default_message); | |
| 75 | + | strbuf_addch(out, '\n'); | |
| 76 | + | strbuf_commented_addf(out, comment_line_str, hint, action, comment_line_str); | |
| 77 | + | if (fwrite(out->buf, 1, out->len, s.fp) != out->len) | |
| 78 | + | die_errno(_("could not write to '%s'"), path); | |
| 71 | 79 | ||
| 72 | 80 | wt_status_collect_changes_trees(&s, old_tree, new_tree); | |
| 73 | 81 | wt_status_print(&s); | |
| 74 | 82 | wt_status_collect_free_buffers(&s); | |
| 75 | 83 | string_list_clear_func(&s.change, change_data_free); | |
| 84 | + | if (fclose(s.fp)) | |
| 85 | + | die_errno(_("could not write to '%s'"), path); | |
| 76 | 86 | ||
| 77 | 87 | strbuf_reset(out); | |
| 78 | 88 | if (launch_editor(path, out, NULL)) { | |
| @@ -91,13 +101,18 @@ static int fill_commit_message(struct repository *repo, | |||
| 91 | 101 | return 0; | |
| 92 | 102 | } | |
| 93 | 103 | ||
| 94 | - | static int commit_tree_with_edited_message_ext(struct repository *repo, | |
| 95 | - | const char *action, | |
| 96 | - | struct commit *commit_with_message, | |
| 97 | - | const struct commit_list *parents, | |
| 98 | - | const struct object_id *old_tree, | |
| 99 | - | const struct object_id *new_tree, | |
| 100 | - | struct commit **out) | |
| 104 | + | enum commit_tree_flags { | |
| 105 | + | COMMIT_TREE_EDIT_MESSAGE = (1 << 0), | |
| 106 | + | }; | |
| 107 | + | ||
| 108 | + | static int commit_tree_ext(struct repository *repo, | |
| 109 | + | const char *action, | |
| 110 | + | struct commit *commit_with_message, | |
| 111 | + | const struct commit_list *parents, | |
| 112 | + | const struct object_id *old_tree, | |
| 113 | + | const struct object_id *new_tree, | |
| 114 | + | struct commit **out, | |
| 115 | + | enum commit_tree_flags flags) | |
| 101 | 116 | { | |
| 102 | 117 | const char *exclude_gpgsig[] = { | |
| 103 | 118 | /* We reencode the message, so the encoding needs to be stripped. */ | |
| @@ -122,10 +137,14 @@ static int commit_tree_with_edited_message_ext(struct repository *repo, | |||
| 122 | 137 | original_author = xmemdupz(ptr, len); | |
| 123 | 138 | find_commit_subject(original_message, &original_body); | |
| 124 | 139 | ||
| 125 | - | ret = fill_commit_message(repo, old_tree, new_tree, | |
| 126 | - | original_body, action, &commit_message); | |
| 127 | - | if (ret < 0) | |
| 128 | - | goto out; | |
| 140 | + | if (flags & COMMIT_TREE_EDIT_MESSAGE) { | |
| 141 | + | ret = fill_commit_message(repo, old_tree, new_tree, | |
| 142 | + | original_body, action, &commit_message); | |
| 143 | + | if (ret < 0) | |
| 144 | + | goto out; | |
| 145 | + | } else { | |
| 146 | + | strbuf_addstr(&commit_message, original_body); | |
| 147 | + | } | |
| 129 | 148 | ||
| 130 | 149 | original_extra_headers = read_commit_extra_headers(commit_with_message, | |
| 131 | 150 | exclude_gpgsig); | |
| @@ -142,6 +161,7 @@ out: | |||
| 142 | 161 | free_commit_extra_headers(original_extra_headers); | |
| 143 | 162 | strbuf_release(&commit_message); | |
| 144 | 163 | free(original_author); | |
| 164 | + | repo_unuse_commit_buffer(repo, commit_with_message, original_message); | |
| 145 | 165 | return ret; | |
| 146 | 166 | } | |
| 147 | 167 | ||
| @@ -168,8 +188,8 @@ static int commit_tree_with_edited_message(struct repository *repo, | |||
| 168 | 188 | oidcpy(&parent_tree_oid, repo->hash_algo->empty_tree); | |
| 169 | 189 | } | |
| 170 | 190 | ||
| 171 | - | return commit_tree_with_edited_message_ext(repo, action, original, original->parents, | |
| 172 | - | &parent_tree_oid, tree_oid, out); | |
| 191 | + | return commit_tree_ext(repo, action, original, original->parents, | |
| 192 | + | &parent_tree_oid, tree_oid, out, COMMIT_TREE_EDIT_MESSAGE); | |
| 173 | 193 | } | |
| 174 | 194 | ||
| 175 | 195 | enum ref_action { | |
| @@ -272,7 +292,7 @@ static int setup_revwalk(struct repository *repo, | |||
| 272 | 292 | ||
| 273 | 293 | commit_list_insert(original, &from_list); | |
| 274 | 294 | ret = repo_is_descendant_of(repo, head, from_list); | |
| 275 | - | free_commit_list(from_list); | |
| 295 | + | commit_list_free(from_list); | |
| 276 | 296 | ||
| 277 | 297 | if (ret < 0) { | |
| 278 | 298 | ret = error(_("cannot determine descendance")); | |
| @@ -321,18 +341,17 @@ static int handle_ref_update(struct ref_transaction *transaction, | |||
| 321 | 341 | NULL, NULL, 0, reflog_msg, err); | |
| 322 | 342 | } | |
| 323 | 343 | ||
| 324 | - | static int handle_reference_updates(struct rev_info *revs, | |
| 325 | - | enum ref_action action, | |
| 326 | - | struct commit *original, | |
| 327 | - | struct commit *rewritten, | |
| 328 | - | const char *reflog_msg, | |
| 329 | - | int dry_run) | |
| 344 | + | static int compute_pending_ref_updates(struct rev_info *revs, | |
| 345 | + | enum ref_action action, | |
| 346 | + | struct commit *original, | |
| 347 | + | struct commit *rewritten, | |
| 348 | + | enum replay_empty_commit_action empty, | |
| 349 | + | struct replay_result *result) | |
| 330 | 350 | { | |
| 331 | 351 | const struct name_decoration *decoration; | |
| 332 | - | struct replay_revisions_options opts = { 0 }; | |
| 333 | - | struct replay_result result = { 0 }; | |
| 334 | - | struct ref_transaction *transaction = NULL; | |
| 335 | - | struct strbuf err = STRBUF_INIT; | |
| 352 | + | struct replay_revisions_options opts = { | |
| 353 | + | .empty = empty, | |
| 354 | + | }; | |
| 336 | 355 | char hex[GIT_MAX_HEXSZ + 1]; | |
| 337 | 356 | bool detached_head; | |
| 338 | 357 | int head_flags = 0; | |
| @@ -344,34 +363,13 @@ static int handle_reference_updates(struct rev_info *revs, | |||
| 344 | 363 | ||
| 345 | 364 | opts.onto = oid_to_hex_r(hex, &rewritten->object.oid); | |
| 346 | 365 | ||
| 347 | - | ret = replay_revisions(revs, &opts, &result); | |
| 366 | + | ret = replay_revisions(revs, &opts, result); | |
| 348 | 367 | if (ret) | |
| 349 | - | goto out; | |
| 368 | + | return ret; | |
| 350 | 369 | ||
| 351 | 370 | if (action != REF_ACTION_BRANCHES && action != REF_ACTION_HEAD) | |
| 352 | 371 | BUG("unsupported ref action %d", action); | |
| 353 | 372 | ||
| 354 | - | if (!dry_run) { | |
| 355 | - | transaction = ref_store_transaction_begin(get_main_ref_store(revs->repo), 0, &err); | |
| 356 | - | if (!transaction) { | |
| 357 | - | ret = error(_("failed to begin ref transaction: %s"), err.buf); | |
| 358 | - | goto out; | |
| 359 | - | } | |
| 360 | - | } | |
| 361 | - | ||
| 362 | - | for (size_t i = 0; i < result.updates_nr; i++) { | |
| 363 | - | ret = handle_ref_update(transaction, | |
| 364 | - | result.updates[i].refname, | |
| 365 | - | &result.updates[i].new_oid, | |
| 366 | - | &result.updates[i].old_oid, | |
| 367 | - | reflog_msg, &err); | |
| 368 | - | if (ret) { | |
| 369 | - | ret = error(_("failed to update ref '%s': %s"), | |
| 370 | - | result.updates[i].refname, err.buf); | |
| 371 | - | goto out; | |
| 372 | - | } | |
| 373 | - | } | |
| 374 | - | ||
| 375 | 373 | /* | |
| 376 | 374 | * `replay_revisions()` only updates references that are | |
| 377 | 375 | * ancestors of `rewritten`, so we need to manually | |
| @@ -399,14 +397,41 @@ static int handle_reference_updates(struct rev_info *revs, | |||
| 399 | 397 | !detached_head) | |
| 400 | 398 | continue; | |
| 401 | 399 | ||
| 400 | + | replay_result_queue_update(result, decoration->name, | |
| 401 | + | &original->object.oid, | |
| 402 | + | &rewritten->object.oid); | |
| 403 | + | } | |
| 404 | + | ||
| 405 | + | return 0; | |
| 406 | + | } | |
| 407 | + | ||
| 408 | + | static int apply_pending_ref_updates(struct repository *repo, | |
| 409 | + | const struct replay_result *result, | |
| 410 | + | const char *reflog_msg, | |
| 411 | + | int dry_run) | |
| 412 | + | { | |
| 413 | + | struct ref_transaction *transaction = NULL; | |
| 414 | + | struct strbuf err = STRBUF_INIT; | |
| 415 | + | int ret; | |
| 416 | + | ||
| 417 | + | if (!dry_run) { | |
| 418 | + | transaction = ref_store_transaction_begin(get_main_ref_store(repo), | |
| 419 | + | 0, &err); | |
| 420 | + | if (!transaction) { | |
| 421 | + | ret = error(_("failed to begin ref transaction: %s"), err.buf); | |
| 422 | + | goto out; | |
| 423 | + | } | |
| 424 | + | } | |
| 425 | + | ||
| 426 | + | for (size_t i = 0; i < result->updates_nr; i++) { | |
| 402 | 427 | ret = handle_ref_update(transaction, | |
| 403 | - | decoration->name, | |
| 404 | - | &rewritten->object.oid, | |
| 405 | - | &original->object.oid, | |
| 428 | + | result->updates[i].refname, | |
| 429 | + | &result->updates[i].new_oid, | |
| 430 | + | &result->updates[i].old_oid, | |
| 406 | 431 | reflog_msg, &err); | |
| 407 | 432 | if (ret) { | |
| 408 | 433 | ret = error(_("failed to update ref '%s': %s"), | |
| 409 | - | decoration->name, err.buf); | |
| 434 | + | result->updates[i].refname, err.buf); | |
| 410 | 435 | goto out; | |
| 411 | 436 | } | |
| 412 | 437 | } | |
| @@ -420,11 +445,263 @@ static int handle_reference_updates(struct rev_info *revs, | |||
| 420 | 445 | ||
| 421 | 446 | out: | |
| 422 | 447 | ref_transaction_free(transaction); | |
| 423 | - | replay_result_release(&result); | |
| 424 | 448 | strbuf_release(&err); | |
| 425 | 449 | return ret; | |
| 426 | 450 | } | |
| 427 | 451 | ||
| 452 | + | static int handle_reference_updates(struct rev_info *revs, | |
| 453 | + | enum ref_action action, | |
| 454 | + | struct commit *original, | |
| 455 | + | struct commit *rewritten, | |
| 456 | + | const char *reflog_msg, | |
| 457 | + | int dry_run, | |
| 458 | + | enum replay_empty_commit_action empty) | |
| 459 | + | { | |
| 460 | + | struct replay_result result = { 0 }; | |
| 461 | + | int ret; | |
| 462 | + | ||
| 463 | + | ret = compute_pending_ref_updates(revs, action, original, rewritten, | |
| 464 | + | empty, &result); | |
| 465 | + | if (ret) | |
| 466 | + | goto out; | |
| 467 | + | ||
| 468 | + | ret = apply_pending_ref_updates(revs->repo, &result, reflog_msg, dry_run); | |
| 469 | + | ||
| 470 | + | out: | |
| 471 | + | replay_result_release(&result); | |
| 472 | + | return ret; | |
| 473 | + | } | |
| 474 | + | ||
| 475 | + | static int commit_became_empty(struct repository *repo, | |
| 476 | + | struct commit *original, | |
| 477 | + | struct tree *result) | |
| 478 | + | { | |
| 479 | + | struct commit *parent = original->parents ? original->parents->item : NULL; | |
| 480 | + | struct object_id parent_tree_oid; | |
| 481 | + | ||
| 482 | + | if (parent) { | |
| 483 | + | if (repo_parse_commit(repo, parent)) | |
| 484 | + | return error(_("unable to parse parent of %s"), | |
| 485 | + | oid_to_hex(&original->object.oid)); | |
| 486 | + | ||
| 487 | + | parent_tree_oid = repo_get_commit_tree(repo, parent)->object.oid; | |
| 488 | + | } else { | |
| 489 | + | oidcpy(&parent_tree_oid, repo->hash_algo->empty_tree); | |
| 490 | + | } | |
| 491 | + | ||
| 492 | + | return oideq(&result->object.oid, &parent_tree_oid); | |
| 493 | + | } | |
| 494 | + | ||
| 495 | + | static int parse_opt_empty(const struct option *opt, const char *arg, int unset) | |
| 496 | + | { | |
| 497 | + | enum replay_empty_commit_action *value = opt->value; | |
| 498 | + | ||
| 499 | + | BUG_ON_OPT_NEG(unset); | |
| 500 | + | ||
| 501 | + | if (!strcmp(arg, "drop")) | |
| 502 | + | *value = REPLAY_EMPTY_COMMIT_DROP; | |
| 503 | + | else if (!strcmp(arg, "keep")) | |
| 504 | + | *value = REPLAY_EMPTY_COMMIT_KEEP; | |
| 505 | + | else if (!strcmp(arg, "abort")) | |
| 506 | + | *value = REPLAY_EMPTY_COMMIT_ABORT; | |
| 507 | + | else | |
| 508 | + | die(_("unrecognized '--empty=' action '%s'; " | |
| 509 | + | "valid values are \"drop\", \"keep\", and \"abort\"."), arg); | |
| 510 | + | ||
| 511 | + | return 0; | |
| 512 | + | } | |
| 513 | + | ||
| 514 | + | static int cmd_history_fixup(int argc, | |
| 515 | + | const char **argv, | |
| 516 | + | const char *prefix, | |
| 517 | + | struct repository *repo) | |
| 518 | + | { | |
| 519 | + | const char * const usage[] = { | |
| 520 | + | GIT_HISTORY_FIXUP_USAGE, | |
| 521 | + | NULL, | |
| 522 | + | }; | |
| 523 | + | enum replay_empty_commit_action empty = REPLAY_EMPTY_COMMIT_DROP; | |
| 524 | + | enum ref_action action = REF_ACTION_DEFAULT; | |
| 525 | + | enum commit_tree_flags flags = 0; | |
| 526 | + | int dry_run = 0; | |
| 527 | + | struct option options[] = { | |
| 528 | + | OPT_CALLBACK_F(0, "update-refs", &action, "(branches|head)", | |
| 529 | + | N_("control which refs should be updated"), | |
| 530 | + | PARSE_OPT_NONEG, parse_ref_action), | |
| 531 | + | OPT_BOOL('n', "dry-run", &dry_run, | |
| 532 | + | N_("perform a dry-run without updating any refs")), | |
| 533 | + | OPT_BIT(0, "reedit-message", &flags, | |
| 534 | + | N_("open an editor to modify the commit message"), | |
| 535 | + | COMMIT_TREE_EDIT_MESSAGE), | |
| 536 | + | OPT_CALLBACK_F(0, "empty", &empty, "(drop|keep|abort)", | |
| 537 | + | N_("how to handle commits that become empty"), | |
| 538 | + | PARSE_OPT_NONEG, parse_opt_empty), | |
| 539 | + | OPT_END(), | |
| 540 | + | }; | |
| 541 | + | struct merge_result merge_result = { 0 }; | |
| 542 | + | struct merge_options merge_opts = { 0 }; | |
| 543 | + | struct strbuf reflog_msg = STRBUF_INIT; | |
| 544 | + | struct commit *head_commit, *original, *rewritten; | |
| 545 | + | struct tree *head_tree, *original_tree, *index_tree; | |
| 546 | + | struct rev_info revs = { 0 }; | |
| 547 | + | bool skip_commit = false; | |
| 548 | + | int ret; | |
| 549 | + | ||
| 550 | + | argc = parse_options(argc, argv, prefix, options, usage, 0); | |
| 551 | + | if (argc != 1) { | |
| 552 | + | ret = error(_("command expects a single revision")); | |
| 553 | + | goto out; | |
| 554 | + | } | |
| 555 | + | repo_config(repo, git_default_config, NULL); | |
| 556 | + | ||
| 557 | + | if (action == REF_ACTION_DEFAULT) | |
| 558 | + | action = REF_ACTION_BRANCHES; | |
| 559 | + | ||
| 560 | + | if (is_bare_repository(repo)) { | |
| 561 | + | ret = error(_("cannot run fixup in a bare repository")); | |
| 562 | + | goto out; | |
| 563 | + | } | |
| 564 | + | ||
| 565 | + | /* Resolve the original commit, which is the one we want to fix up. */ | |
| 566 | + | original = lookup_commit_reference_by_name(argv[0]); | |
| 567 | + | if (!original) { | |
| 568 | + | ret = error(_("commit cannot be found: %s"), argv[0]); | |
| 569 | + | goto out; | |
| 570 | + | } | |
| 571 | + | ||
| 572 | + | /* | |
| 573 | + | * Resolve HEAD so we can use its tree as the merge base: the staged | |
| 574 | + | * changes are expressed as a diff from HEAD's tree to the index tree. | |
| 575 | + | */ | |
| 576 | + | head_commit = lookup_commit_reference_by_name("HEAD"); | |
| 577 | + | if (!head_commit) { | |
| 578 | + | ret = error(_("cannot look up HEAD")); | |
| 579 | + | goto out; | |
| 580 | + | } | |
| 581 | + | ||
| 582 | + | head_tree = repo_get_commit_tree(repo, head_commit); | |
| 583 | + | if (!head_tree) { | |
| 584 | + | ret = error(_("cannot get tree for HEAD")); | |
| 585 | + | goto out; | |
| 586 | + | } | |
| 587 | + | ||
| 588 | + | if (repo_read_index(repo) < 0) { | |
| 589 | + | ret = error(_("unable to read index")); | |
| 590 | + | goto out; | |
| 591 | + | } | |
| 592 | + | ||
| 593 | + | if (!repo_index_has_changes(repo, head_tree, NULL)) { | |
| 594 | + | ret = error(_("nothing to fixup: no staged changes")); | |
| 595 | + | goto out; | |
| 596 | + | } | |
| 597 | + | ||
| 598 | + | /* | |
| 599 | + | * Write the index as a tree object. This is the "theirs" side of the | |
| 600 | + | * three-way merge: it is HEAD's tree with the staged changes applied. | |
| 601 | + | */ | |
| 602 | + | index_tree = write_in_core_index_as_tree(repo, repo->index); | |
| 603 | + | if (!index_tree) { | |
| 604 | + | ret = error(_("unable to write index as a tree")); | |
| 605 | + | goto out; | |
| 606 | + | } | |
| 607 | + | ||
| 608 | + | original_tree = repo_get_commit_tree(repo, original); | |
| 609 | + | if (!original_tree) { | |
| 610 | + | ret = error(_("cannot get tree for commit %s"), argv[0]); | |
| 611 | + | goto out; | |
| 612 | + | } | |
| 613 | + | ||
| 614 | + | /* | |
| 615 | + | * Perform the three-way merge to reapply changes in the index onto the | |
| 616 | + | * target commit. This is using basically the same logic as a | |
| 617 | + | * cherry-pick, where the base commit is our HEAD, ours is the original | |
| 618 | + | * tree and theirs is the index tree. | |
| 619 | + | */ | |
| 620 | + | init_basic_merge_options(&merge_opts, repo); | |
| 621 | + | merge_opts.ancestor = "HEAD"; | |
| 622 | + | merge_opts.branch1 = argv[0]; | |
| 623 | + | merge_opts.branch2 = "staged"; | |
| 624 | + | merge_incore_nonrecursive(&merge_opts, head_tree, | |
| 625 | + | original_tree, index_tree, &merge_result); | |
| 626 | + | ||
| 627 | + | if (merge_result.clean < 0) { | |
| 628 | + | ret = error(_("merge failed while applying fixup")); | |
| 629 | + | goto out; | |
| 630 | + | } | |
| 631 | + | ||
| 632 | + | if (!merge_result.clean) { | |
| 633 | + | ret = error(_("fixup would produce conflicts; aborting")); | |
| 634 | + | goto out; | |
| 635 | + | } | |
| 636 | + | ||
| 637 | + | ret = commit_became_empty(repo, original, merge_result.tree); | |
| 638 | + | if (ret < 0) | |
| 639 | + | goto out; | |
| 640 | + | if (ret > 0) { | |
| 641 | + | switch (empty) { | |
| 642 | + | case REPLAY_EMPTY_COMMIT_DROP: | |
| 643 | + | /* | |
| 644 | + | * Drop the target commit by replaying its descendants | |
| 645 | + | * directly onto its parent. | |
| 646 | + | */ | |
| 647 | + | rewritten = original->parents ? original->parents->item : NULL; | |
| 648 | + | ||
| 649 | + | /* | |
| 650 | + | * TODO: we don't yet have the ability to drop root | |
| 651 | + | * commits, but there's ultimately no good reason for | |
| 652 | + | * this restriction to exist other than a technical | |
| 653 | + | * limitation. | |
| 654 | + | */ | |
| 655 | + | if (!rewritten) { | |
| 656 | + | ret = error(_("cannot drop root commit %s: " | |
| 657 | + | "it has no parent to replay onto"), | |
| 658 | + | argv[0]); | |
| 659 | + | goto out; | |
| 660 | + | } | |
| 661 | + | ||
| 662 | + | skip_commit = true; | |
| 663 | + | break; | |
| 664 | + | case REPLAY_EMPTY_COMMIT_KEEP: | |
| 665 | + | /* Proceed and record the empty commit. */ | |
| 666 | + | break; | |
| 667 | + | case REPLAY_EMPTY_COMMIT_ABORT: | |
| 668 | + | ret = error(_("fixup makes commit %s empty"), argv[0]); | |
| 669 | + | goto out; | |
| 670 | + | } | |
| 671 | + | } | |
| 672 | + | ||
| 673 | + | ret = setup_revwalk(repo, action, original, &revs); | |
| 674 | + | if (ret) | |
| 675 | + | goto out; | |
| 676 | + | ||
| 677 | + | if (!skip_commit) { | |
| 678 | + | ret = commit_tree_ext(repo, "fixup", original, original->parents, | |
| 679 | + | &original_tree->object.oid, &merge_result.tree->object.oid, | |
| 680 | + | &rewritten, flags); | |
| 681 | + | if (ret < 0) { | |
| 682 | + | ret = error(_("failed writing fixed-up commit")); | |
| 683 | + | goto out; | |
| 684 | + | } | |
| 685 | + | } | |
| 686 | + | ||
| 687 | + | strbuf_addf(&reflog_msg, "fixup: updating %s", argv[0]); | |
| 688 | + | ||
| 689 | + | ret = handle_reference_updates(&revs, action, original, rewritten, | |
| 690 | + | reflog_msg.buf, dry_run, empty); | |
| 691 | + | if (ret < 0) { | |
| 692 | + | ret = error(_("failed replaying descendants")); | |
| 693 | + | goto out; | |
| 694 | + | } | |
| 695 | + | ||
| 696 | + | ret = 0; | |
| 697 | + | ||
| 698 | + | out: | |
| 699 | + | merge_finalize(&merge_opts, &merge_result); | |
| 700 | + | strbuf_release(&reflog_msg); | |
| 701 | + | release_revisions(&revs); | |
| 702 | + | return ret; | |
| 703 | + | } | |
| 704 | + | ||
| 428 | 705 | static int cmd_history_reword(int argc, | |
| 429 | 706 | const char **argv, | |
| 430 | 707 | const char *prefix, | |
| @@ -478,7 +755,7 @@ static int cmd_history_reword(int argc, | |||
| 478 | 755 | strbuf_addf(&reflog_msg, "reword: updating %s", argv[0]); | |
| 479 | 756 | ||
| 480 | 757 | ret = handle_reference_updates(&revs, action, original, rewritten, | |
| 481 | - | reflog_msg.buf, dry_run); | |
| 758 | + | reflog_msg.buf, dry_run, REPLAY_EMPTY_COMMIT_ABORT); | |
| 482 | 759 | if (ret < 0) { | |
| 483 | 760 | ret = error(_("failed replaying descendants")); | |
| 484 | 761 | goto out; | |
| @@ -510,6 +787,10 @@ static int write_ondisk_index(struct repository *repo, | |||
| 510 | 787 | opts.dst_index = &index; | |
| 511 | 788 | ||
| 512 | 789 | tree = repo_parse_tree_indirect(repo, oid); | |
| 790 | + | if (!tree) { | |
| 791 | + | ret = error(_("unable to parse tree %s"), oid_to_hex(oid)); | |
| 792 | + | goto out; | |
| 793 | + | } | |
| 513 | 794 | init_tree_desc(&tree_desc, &tree->object.oid, tree->buffer, tree->size); | |
| 514 | 795 | ||
| 515 | 796 | if (unpack_trees(1, &tree_desc, &opts)) { | |
| @@ -519,7 +800,7 @@ static int write_ondisk_index(struct repository *repo, | |||
| 519 | 800 | ||
| 520 | 801 | prime_cache_tree(repo, &index, tree); | |
| 521 | 802 | ||
| 522 | - | if (hold_lock_file_for_update(&lock, path, 0) < 0) { | |
| 803 | + | if (repo_hold_lock_file_for_update(repo, &lock, path, 0) < 0) { | |
| 523 | 804 | ret = error_errno(_("unable to acquire index lock")); | |
| 524 | 805 | goto out; | |
| 525 | 806 | } | |
| @@ -616,9 +897,8 @@ static int split_commit(struct repository *repo, | |||
| 616 | 897 | * The first commit is constructed from the split-out tree. The base | |
| 617 | 898 | * that shall be diffed against is the parent of the original commit. | |
| 618 | 899 | */ | |
| 619 | - | ret = commit_tree_with_edited_message_ext(repo, "split-out", original, | |
| 620 | - | original->parents, &parent_tree_oid, | |
| 621 | - | &split_tree->object.oid, &first_commit); | |
| 900 | + | ret = commit_tree_ext(repo, "split-out", original, original->parents, &parent_tree_oid, | |
| 901 | + | &split_tree->object.oid, &first_commit, COMMIT_TREE_EDIT_MESSAGE); | |
| 622 | 902 | if (ret < 0) { | |
| 623 | 903 | ret = error(_("failed writing first commit")); | |
| 624 | 904 | goto out; | |
| @@ -634,9 +914,8 @@ static int split_commit(struct repository *repo, | |||
| 634 | 914 | old_tree_oid = &repo_get_commit_tree(repo, first_commit)->object.oid; | |
| 635 | 915 | new_tree_oid = &repo_get_commit_tree(repo, original)->object.oid; | |
| 636 | 916 | ||
| 637 | - | ret = commit_tree_with_edited_message_ext(repo, "split-out", original, | |
| 638 | - | parents, old_tree_oid, | |
| 639 | - | new_tree_oid, &second_commit); | |
| 917 | + | ret = commit_tree_ext(repo, "split-out", original, parents, old_tree_oid, | |
| 918 | + | new_tree_oid, &second_commit, COMMIT_TREE_EDIT_MESSAGE); | |
| 640 | 919 | if (ret < 0) { | |
| 641 | 920 | ret = error(_("failed writing second commit")); | |
| 642 | 921 | goto out; | |
| @@ -649,7 +928,7 @@ out: | |||
| 649 | 928 | if (index_file.len) | |
| 650 | 929 | unlink(index_file.buf); | |
| 651 | 930 | strbuf_release(&index_file); | |
| 652 | - | free_commit_list(parents); | |
| 931 | + | commit_list_free(parents); | |
| 653 | 932 | release_index(&index); | |
| 654 | 933 | return ret; | |
| 655 | 934 | } | |
| @@ -717,7 +996,7 @@ static int cmd_history_split(int argc, | |||
| 717 | 996 | strbuf_addf(&reflog_msg, "split: updating %s", argv[0]); | |
| 718 | 997 | ||
| 719 | 998 | ret = handle_reference_updates(&revs, action, original, rewritten, | |
| 720 | - | reflog_msg.buf, dry_run); | |
| 999 | + | reflog_msg.buf, dry_run, REPLAY_EMPTY_COMMIT_ABORT); | |
| 721 | 1000 | if (ret < 0) { | |
| 722 | 1001 | ret = error(_("failed replaying descendants")); | |
| 723 | 1002 | goto out; | |
| @@ -732,18 +1011,200 @@ out: | |||
| 732 | 1011 | return ret; | |
| 733 | 1012 | } | |
| 734 | 1013 | ||
| 1014 | + | static int update_worktree(struct repository *repo, | |
| 1015 | + | const struct commit *old_head, | |
| 1016 | + | const struct commit *new_head, | |
| 1017 | + | bool dry_run) | |
| 1018 | + | { | |
| 1019 | + | struct reset_working_tree_options opts = { | |
| 1020 | + | .oid_from = &old_head->object.oid, | |
| 1021 | + | .oid = &new_head->object.oid, | |
| 1022 | + | }; | |
| 1023 | + | if (dry_run) | |
| 1024 | + | opts.flags |= RESET_WORKING_TREE_DRY_RUN; | |
| 1025 | + | return reset_working_tree(repo, &opts); | |
| 1026 | + | } | |
| 1027 | + | ||
| 1028 | + | static int find_head_tree_change(struct repository *repo, | |
| 1029 | + | const struct replay_result *result, | |
| 1030 | + | struct commit **old_head, | |
| 1031 | + | struct commit **new_head, | |
| 1032 | + | bool *changed) | |
| 1033 | + | { | |
| 1034 | + | const struct replay_ref_update *head_update = NULL; | |
| 1035 | + | struct commit *old_head_commit, *new_head_commit; | |
| 1036 | + | struct tree *old_head_tree, *new_head_tree; | |
| 1037 | + | const char *head_target; | |
| 1038 | + | int head_flags; | |
| 1039 | + | ||
| 1040 | + | *changed = false; | |
| 1041 | + | ||
| 1042 | + | head_target = refs_resolve_ref_unsafe(get_main_ref_store(repo), "HEAD", | |
| 1043 | + | RESOLVE_REF_NO_RECURSE | RESOLVE_REF_READING, | |
| 1044 | + | NULL, &head_flags); | |
| 1045 | + | if (!head_target) | |
| 1046 | + | return error(_("cannot look up HEAD")); | |
| 1047 | + | ||
| 1048 | + | for (size_t i = 0; i < result->updates_nr; i++) { | |
| 1049 | + | if (!strcmp(result->updates[i].refname, head_target)) { | |
| 1050 | + | head_update = &result->updates[i]; | |
| 1051 | + | break; | |
| 1052 | + | } | |
| 1053 | + | } | |
| 1054 | + | ||
| 1055 | + | if (!head_update) | |
| 1056 | + | return 0; | |
| 1057 | + | ||
| 1058 | + | old_head_commit = lookup_commit_reference(repo, &head_update->old_oid); | |
| 1059 | + | new_head_commit = lookup_commit_reference(repo, &head_update->new_oid); | |
| 1060 | + | if (!old_head_commit || !new_head_commit) | |
| 1061 | + | return error(_("cannot resolve HEAD commit")); | |
| 1062 | + | ||
| 1063 | + | old_head_tree = repo_get_commit_tree(repo, old_head_commit); | |
| 1064 | + | new_head_tree = repo_get_commit_tree(repo, new_head_commit); | |
| 1065 | + | if (!old_head_tree || !new_head_tree) | |
| 1066 | + | return error(_("cannot resolve tree for HEAD")); | |
| 1067 | + | ||
| 1068 | + | if (oideq(&old_head_tree->object.oid, &new_head_tree->object.oid)) | |
| 1069 | + | return 0; | |
| 1070 | + | ||
| 1071 | + | *old_head = old_head_commit; | |
| 1072 | + | *new_head = new_head_commit; | |
| 1073 | + | *changed = true; | |
| 1074 | + | ||
| 1075 | + | return 0; | |
| 1076 | + | } | |
| 1077 | + | ||
| 1078 | + | static int cmd_history_drop(int argc, | |
| 1079 | + | const char **argv, | |
| 1080 | + | const char *prefix, | |
| 1081 | + | struct repository *repo) | |
| 1082 | + | { | |
| 1083 | + | const char * const usage[] = { | |
| 1084 | + | GIT_HISTORY_DROP_USAGE, | |
| 1085 | + | NULL, | |
| 1086 | + | }; | |
| 1087 | + | enum replay_empty_commit_action empty = REPLAY_EMPTY_COMMIT_DROP; | |
| 1088 | + | enum ref_action action = REF_ACTION_DEFAULT; | |
| 1089 | + | int dry_run = 0; | |
| 1090 | + | struct option options[] = { | |
| 1091 | + | OPT_CALLBACK_F(0, "update-refs", &action, "(branches|head)", | |
| 1092 | + | N_("control which refs should be updated"), | |
| 1093 | + | PARSE_OPT_NONEG, parse_ref_action), | |
| 1094 | + | OPT_BOOL('n', "dry-run", &dry_run, | |
| 1095 | + | N_("perform a dry-run without updating any refs")), | |
| 1096 | + | OPT_CALLBACK_F(0, "empty", &empty, "(drop|keep|abort)", | |
| 1097 | + | N_("how to handle descendants that become empty"), | |
| 1098 | + | PARSE_OPT_NONEG, parse_opt_empty), | |
| 1099 | + | OPT_END(), | |
| 1100 | + | }; | |
| 1101 | + | struct strbuf reflog_msg = STRBUF_INIT; | |
| 1102 | + | struct commit *original, *rewritten; | |
| 1103 | + | struct rev_info revs = { 0 }; | |
| 1104 | + | struct replay_result result = { 0 }; | |
| 1105 | + | struct commit *old_head, *new_head; | |
| 1106 | + | bool head_moves = false; | |
| 1107 | + | int ret; | |
| 1108 | + | ||
| 1109 | + | argc = parse_options(argc, argv, prefix, options, usage, 0); | |
| 1110 | + | if (argc != 1) { | |
| 1111 | + | ret = error(_("command expects a single revision")); | |
| 1112 | + | goto out; | |
| 1113 | + | } | |
| 1114 | + | repo_config(repo, git_default_config, NULL); | |
| 1115 | + | ||
| 1116 | + | if (action == REF_ACTION_DEFAULT) | |
| 1117 | + | action = REF_ACTION_BRANCHES; | |
| 1118 | + | ||
| 1119 | + | original = lookup_commit_reference_by_name(argv[0]); | |
| 1120 | + | if (!original) { | |
| 1121 | + | ret = error(_("commit cannot be found: %s"), argv[0]); | |
| 1122 | + | goto out; | |
| 1123 | + | } | |
| 1124 | + | ||
| 1125 | + | if (!original->parents) { | |
| 1126 | + | ret = error(_("cannot drop root commit %s: " | |
| 1127 | + | "it has no parent to replay onto"), | |
| 1128 | + | argv[0]); | |
| 1129 | + | goto out; | |
| 1130 | + | } else if (original->parents->next) { | |
| 1131 | + | ret = error(_("cannot drop merge commit: %s"), argv[0]); | |
| 1132 | + | goto out; | |
| 1133 | + | } | |
| 1134 | + | ||
| 1135 | + | ret = setup_revwalk(repo, action, original, &revs); | |
| 1136 | + | if (ret) | |
| 1137 | + | goto out; | |
| 1138 | + | ||
| 1139 | + | rewritten = original->parents->item; | |
| 1140 | + | ||
| 1141 | + | ret = compute_pending_ref_updates(&revs, action, original, rewritten, | |
| 1142 | + | empty, &result); | |
| 1143 | + | if (ret) { | |
| 1144 | + | ret = error(_("failed replaying descendants")); | |
| 1145 | + | goto out; | |
| 1146 | + | } | |
| 1147 | + | ||
| 1148 | + | /* | |
| 1149 | + | * If HEAD will move as a result of the rewrite then we'll have to | |
| 1150 | + | * merge in the changes into the worktree and index. This merge can of | |
| 1151 | + | * course conflict, which will cause the whole operation to abort. | |
| 1152 | + | * | |
| 1153 | + | * If we had already updated the refs at that point then we'd have an | |
| 1154 | + | * inconsistent repository state. So we first perform a dry-run merge | |
| 1155 | + | * here before updating refs. | |
| 1156 | + | */ | |
| 1157 | + | if (!is_bare_repository(repo)) { | |
| 1158 | + | ret = find_head_tree_change(repo, &result, &old_head, | |
| 1159 | + | &new_head, &head_moves); | |
| 1160 | + | if (ret < 0) | |
| 1161 | + | goto out; | |
| 1162 | + | ||
| 1163 | + | if (head_moves && update_worktree(repo, old_head, new_head, true) < 0) { | |
| 1164 | + | ret = error(_("dropping this commit would " | |
| 1165 | + | "overwrite local changes; aborting")); | |
| 1166 | + | goto out; | |
| 1167 | + | } | |
| 1168 | + | } | |
| 1169 | + | ||
| 1170 | + | strbuf_addf(&reflog_msg, "drop: dropping %s", argv[0]); | |
| 1171 | + | ret = apply_pending_ref_updates(repo, &result, reflog_msg.buf, dry_run); | |
| 1172 | + | if (ret < 0) { | |
| 1173 | + | ret = error(_("failed to update references")); | |
| 1174 | + | goto out; | |
| 1175 | + | } | |
| 1176 | + | ||
| 1177 | + | if (!dry_run && head_moves && update_worktree(repo, old_head, new_head, false) < 0) { | |
| 1178 | + | ret = error(_("could not update working tree to new commit %s"), | |
| 1179 | + | oid_to_hex(&new_head->object.oid)); | |
| 1180 | + | goto out; | |
| 1181 | + | } | |
| 1182 | + | ||
| 1183 | + | ret = 0; | |
| 1184 | + | ||
| 1185 | + | out: | |
| 1186 | + | replay_result_release(&result); | |
| 1187 | + | strbuf_release(&reflog_msg); | |
| 1188 | + | release_revisions(&revs); | |
| 1189 | + | return ret; | |
| 1190 | + | } | |
| 1191 | + | ||
| 735 | 1192 | int cmd_history(int argc, | |
| 736 | 1193 | const char **argv, | |
| 737 | 1194 | const char *prefix, | |
| 738 | 1195 | struct repository *repo) | |
| 739 | 1196 | { | |
| 740 | 1197 | const char * const usage[] = { | |
| 1198 | + | GIT_HISTORY_DROP_USAGE, | |
| 1199 | + | GIT_HISTORY_FIXUP_USAGE, | |
| 741 | 1200 | GIT_HISTORY_REWORD_USAGE, | |
| 742 | 1201 | GIT_HISTORY_SPLIT_USAGE, | |
| 743 | 1202 | NULL, | |
| 744 | 1203 | }; | |
| 745 | 1204 | parse_opt_subcommand_fn *fn = NULL; | |
| 746 | 1205 | struct option options[] = { | |
| 1206 | + | OPT_SUBCOMMAND("drop", &fn, cmd_history_drop), | |
| 1207 | + | OPT_SUBCOMMAND("fixup", &fn, cmd_history_fixup), | |
| 747 | 1208 | OPT_SUBCOMMAND("reword", &fn, cmd_history_reword), | |
| 748 | 1209 | OPT_SUBCOMMAND("split", &fn, cmd_history_split), | |
| 749 | 1210 | OPT_END(), | |
modified builtin/hook.c
| @@ -4,23 +4,15 @@ | |||
| 4 | 4 | #include "environment.h" | |
| 5 | 5 | #include "gettext.h" | |
| 6 | 6 | #include "hook.h" | |
| 7 | - | #include "hook-list.h" | |
| 8 | 7 | #include "parse-options.h" | |
| 8 | + | #include "thread-utils.h" | |
| 9 | 9 | ||
| 10 | 10 | #define BUILTIN_HOOK_RUN_USAGE \ | |
| 11 | - | N_("git hook run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]") | |
| 11 | + | N_("git hook run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] [(-j|--jobs) <n>]\n" \ | |
| 12 | + | "<hook-name> [-- <hook-args>]") | |
| 12 | 13 | #define BUILTIN_HOOK_LIST_USAGE \ | |
| 13 | 14 | N_("git hook list [--allow-unknown-hook-name] [-z] [--show-scope] <hook-name>") | |
| 14 | 15 | ||
| 15 | - | static int is_known_hook(const char *name) | |
| 16 | - | { | |
| 17 | - | const char **p; | |
| 18 | - | for (p = hook_name_list; *p; p++) | |
| 19 | - | if (!strcmp(*p, name)) | |
| 20 | - | return 1; | |
| 21 | - | return 0; | |
| 22 | - | } | |
| 23 | - | ||
| 24 | 16 | static const char * const builtin_hook_usage[] = { | |
| 25 | 17 | BUILTIN_HOOK_RUN_USAGE, | |
| 26 | 18 | BUILTIN_HOOK_LIST_USAGE, | |
| @@ -96,14 +88,22 @@ static int list(int argc, const char **argv, const char *prefix, | |||
| 96 | 88 | const char *name = h->u.configured.friendly_name; | |
| 97 | 89 | const char *scope = show_scope ? | |
| 98 | 90 | config_scope_name(h->u.configured.scope) : NULL; | |
| 91 | + | /* | |
| 92 | + | * Show the most relevant disable reason. Event-level | |
| 93 | + | * takes precedence: if the whole event is off, that | |
| 94 | + | * is what the user needs to know. The per-hook | |
| 95 | + | * "disabled" surfaces once the event is re-enabled. | |
| 96 | + | */ | |
| 97 | + | const char *disability = | |
| 98 | + | h->u.configured.event_disabled ? "event-disabled\t" : | |
| 99 | + | h->u.configured.disabled ? "disabled\t" : | |
| 100 | + | ""; | |
| 99 | 101 | if (scope) | |
| 100 | - | printf("%s\t%s%s%c", scope, | |
| 101 | - | h->u.configured.disabled ? "disabled\t" : "", | |
| 102 | - | name, line_terminator); | |
| 102 | + | printf("%s\t%s%s%c", scope, disability, name, | |
| 103 | + | line_terminator); | |
| 103 | 104 | else | |
| 104 | - | printf("%s%s%c", | |
| 105 | - | h->u.configured.disabled ? "disabled\t" : "", | |
| 106 | - | name, line_terminator); | |
| 105 | + | printf("%s%s%c", disability, name, | |
| 106 | + | line_terminator); | |
| 107 | 107 | break; | |
| 108 | 108 | } | |
| 109 | 109 | default: | |
| @@ -124,6 +124,7 @@ static int run(int argc, const char **argv, const char *prefix, | |||
| 124 | 124 | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT; | |
| 125 | 125 | int ignore_missing = 0; | |
| 126 | 126 | int allow_unknown = 0; | |
| 127 | + | int jobs = 0; | |
| 127 | 128 | const char *hook_name; | |
| 128 | 129 | struct option run_options[] = { | |
| 129 | 130 | OPT_BOOL(0, "allow-unknown-hook-name", &allow_unknown, | |
| @@ -132,6 +133,8 @@ static int run(int argc, const char **argv, const char *prefix, | |||
| 132 | 133 | N_("silently ignore missing requested <hook-name>")), | |
| 133 | 134 | OPT_STRING(0, "to-stdin", &opt.path_to_stdin, N_("path"), | |
| 134 | 135 | N_("file to read into hooks' stdin")), | |
| 136 | + | OPT_INTEGER('j', "jobs", &jobs, | |
| 137 | + | N_("run up to <n> hooks simultaneously (-1 for CPU count)")), | |
| 135 | 138 | OPT_END(), | |
| 136 | 139 | }; | |
| 137 | 140 | int ret; | |
| @@ -140,6 +143,15 @@ static int run(int argc, const char **argv, const char *prefix, | |||
| 140 | 143 | builtin_hook_run_usage, | |
| 141 | 144 | PARSE_OPT_KEEP_DASHDASH); | |
| 142 | 145 | ||
| 146 | + | if (jobs == -1) | |
| 147 | + | opt.jobs = online_cpus(); | |
| 148 | + | else if (jobs < 0) | |
| 149 | + | die(_("invalid value for -j: %d" | |
| 150 | + | " (use -1 for CPU count or a" | |
| 151 | + | " positive integer)"), jobs); | |
| 152 | + | else | |
| 153 | + | opt.jobs = jobs; | |
| 154 | + | ||
| 143 | 155 | if (!argc) | |
| 144 | 156 | goto usage; | |
| 145 | 157 | ||
modified builtin/index-pack.c
| @@ -37,7 +37,7 @@ static const char index_pack_usage[] = | |||
| 37 | 37 | ||
| 38 | 38 | struct object_entry { | |
| 39 | 39 | struct pack_idx_entry idx; | |
| 40 | - | unsigned long size; | |
| 40 | + | size_t size; | |
| 41 | 41 | unsigned char hdr_size; | |
| 42 | 42 | signed char type; | |
| 43 | 43 | signed char real_type; | |
| @@ -71,7 +71,7 @@ struct base_data { | |||
| 71 | 71 | /* Not initialized by make_base(). */ | |
| 72 | 72 | struct list_head list; | |
| 73 | 73 | void *data; | |
| 74 | - | unsigned long size; | |
| 74 | + | size_t size; | |
| 75 | 75 | }; | |
| 76 | 76 | ||
| 77 | 77 | /* | |
| @@ -145,8 +145,7 @@ static int check_self_contained_and_connected; | |||
| 145 | 145 | ||
| 146 | 146 | static struct progress *progress; | |
| 147 | 147 | ||
| 148 | - | /* We always read in 4kB chunks. */ | |
| 149 | - | static unsigned char input_buffer[4096]; | |
| 148 | + | static unsigned char input_buffer[DEFAULT_IO_BUFFER_SIZE]; | |
| 150 | 149 | static unsigned int input_offset, input_len; | |
| 151 | 150 | static off_t consumed_bytes; | |
| 152 | 151 | static off_t max_input_size; | |
| @@ -259,7 +258,7 @@ static unsigned check_object(struct object *obj) | |||
| 259 | 258 | return 0; | |
| 260 | 259 | ||
| 261 | 260 | if (!(obj->flags & FLAG_CHECKED)) { | |
| 262 | - | unsigned long size; | |
| 261 | + | size_t size; | |
| 263 | 262 | int type = odb_read_object_info(the_repository->objects, | |
| 264 | 263 | &obj->oid, &size); | |
| 265 | 264 | if (type <= 0) | |
| @@ -375,7 +374,7 @@ static const char *open_pack_file(const char *pack_name) | |||
| 375 | 374 | output_fd = -1; | |
| 376 | 375 | nothread_data.pack_fd = input_fd; | |
| 377 | 376 | } | |
| 378 | - | the_hash_algo->init_fn(&input_ctx); | |
| 377 | + | git_hash_init(&input_ctx, the_hash_algo); | |
| 379 | 378 | return pack_name; | |
| 380 | 379 | } | |
| 381 | 380 | ||
| @@ -469,7 +468,7 @@ static int is_delta_type(enum object_type type) | |||
| 469 | 468 | return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA); | |
| 470 | 469 | } | |
| 471 | 470 | ||
| 472 | - | static void *unpack_entry_data(off_t offset, unsigned long size, | |
| 471 | + | static void *unpack_entry_data(off_t offset, size_t size, | |
| 473 | 472 | enum object_type type, struct object_id *oid) | |
| 474 | 473 | { | |
| 475 | 474 | static char fixed_buf[8192]; | |
| @@ -482,7 +481,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size, | |||
| 482 | 481 | ||
| 483 | 482 | if (!is_delta_type(type)) { | |
| 484 | 483 | hdrlen = format_object_header(hdr, sizeof(hdr), type, size); | |
| 485 | - | the_hash_algo->init_fn(&c); | |
| 484 | + | git_hash_init(&c, the_hash_algo); | |
| 486 | 485 | git_hash_update(&c, hdr, hdrlen); | |
| 487 | 486 | } else | |
| 488 | 487 | oid = NULL; | |
| @@ -524,7 +523,7 @@ static void *unpack_raw_entry(struct object_entry *obj, | |||
| 524 | 523 | struct object_id *oid) | |
| 525 | 524 | { | |
| 526 | 525 | unsigned char *p; | |
| 527 | - | unsigned long size, c; | |
| 526 | + | size_t size, c; | |
| 528 | 527 | off_t base_offset; | |
| 529 | 528 | unsigned shift; | |
| 530 | 529 | void *data; | |
| @@ -539,6 +538,8 @@ static void *unpack_raw_entry(struct object_entry *obj, | |||
| 539 | 538 | size = (c & 15); | |
| 540 | 539 | shift = 4; | |
| 541 | 540 | while (c & 0x80) { | |
| 541 | + | if ((bitsizeof(size_t) - 7) < shift) | |
| 542 | + | die(_("object size too large for this platform")); | |
| 542 | 543 | p = fill(1); | |
| 543 | 544 | c = *p; | |
| 544 | 545 | use(1); | |
| @@ -762,7 +763,7 @@ static void find_ref_delta_children(const struct object_id *oid, | |||
| 762 | 763 | ||
| 763 | 764 | struct compare_data { | |
| 764 | 765 | struct object_entry *entry; | |
| 765 | - | struct odb_read_stream *st; | |
| 766 | + | struct odb_stream *st; | |
| 766 | 767 | unsigned char *buf; | |
| 767 | 768 | unsigned long buf_size; | |
| 768 | 769 | }; | |
| @@ -779,7 +780,7 @@ static int compare_objects(const unsigned char *buf, unsigned long size, | |||
| 779 | 780 | } | |
| 780 | 781 | ||
| 781 | 782 | while (size) { | |
| 782 | - | ssize_t len = odb_read_stream_read(data->st, data->buf, size); | |
| 783 | + | ssize_t len = odb_stream_read(data->st, data->buf, size); | |
| 783 | 784 | if (len == 0) | |
| 784 | 785 | die(_("SHA1 COLLISION FOUND WITH %s !"), | |
| 785 | 786 | oid_to_hex(&data->entry->idx.oid)); | |
| @@ -805,14 +806,14 @@ static int check_collison(struct object_entry *entry) | |||
| 805 | 806 | ||
| 806 | 807 | memset(&data, 0, sizeof(data)); | |
| 807 | 808 | data.entry = entry; | |
| 808 | - | data.st = odb_read_stream_open(the_repository->objects, &entry->idx.oid, NULL); | |
| 809 | + | data.st = odb_stream_from_object(the_repository->objects, &entry->idx.oid, NULL); | |
| 809 | 810 | if (!data.st) | |
| 810 | 811 | return -1; | |
| 811 | 812 | if (data.st->size != entry->size || data.st->type != entry->type) | |
| 812 | 813 | die(_("SHA1 COLLISION FOUND WITH %s !"), | |
| 813 | 814 | oid_to_hex(&entry->idx.oid)); | |
| 814 | 815 | unpack_data(entry, compare_objects, &data); | |
| 815 | - | odb_read_stream_close(data.st); | |
| 816 | + | odb_stream_close(data.st); | |
| 816 | 817 | free(data.buf); | |
| 817 | 818 | return 0; | |
| 818 | 819 | } | |
| @@ -904,7 +905,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, | |||
| 904 | 905 | if (collision_test_needed) { | |
| 905 | 906 | void *has_data; | |
| 906 | 907 | enum object_type has_type; | |
| 907 | - | unsigned long has_size; | |
| 908 | + | size_t has_size; | |
| 908 | 909 | read_lock(); | |
| 909 | 910 | has_type = odb_read_object_info(the_repository->objects, oid, &has_size); | |
| 910 | 911 | if (has_type < 0) | |
| @@ -1047,7 +1048,7 @@ static struct base_data *resolve_delta(struct object_entry *delta_obj, | |||
| 1047 | 1048 | { | |
| 1048 | 1049 | void *delta_data, *result_data; | |
| 1049 | 1050 | struct base_data *result; | |
| 1050 | - | unsigned long result_size; | |
| 1051 | + | size_t result_size; | |
| 1051 | 1052 | ||
| 1052 | 1053 | if (show_stat) { | |
| 1053 | 1054 | int i = delta_obj - objects; | |
| @@ -1211,7 +1212,6 @@ static void *threaded_second_pass(void *data) | |||
| 1211 | 1212 | list_add(&child->list, &work_head); | |
| 1212 | 1213 | base_cache_used += child->size; | |
| 1213 | 1214 | prune_base_data(NULL); | |
| 1214 | - | free_base_data(child); | |
| 1215 | 1215 | } else if (child) { | |
| 1216 | 1216 | /* | |
| 1217 | 1217 | * This child does not have its own children. It may be | |
| @@ -1291,7 +1291,7 @@ static void parse_pack_objects(unsigned char *hash) | |||
| 1291 | 1291 | ||
| 1292 | 1292 | /* Check pack integrity */ | |
| 1293 | 1293 | flush(); | |
| 1294 | - | the_hash_algo->init_fn(&tmp_ctx); | |
| 1294 | + | git_hash_init(&tmp_ctx, the_hash_algo); | |
| 1295 | 1295 | git_hash_clone(&tmp_ctx, &input_ctx); | |
| 1296 | 1296 | git_hash_final(hash, &tmp_ctx); | |
| 1297 | 1297 | if (!hasheq(fill(the_hash_algo->rawsz), hash, the_repository->hash_algo)) | |
| @@ -1416,8 +1416,9 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size) | |||
| 1416 | 1416 | git_zstream stream; | |
| 1417 | 1417 | int status; | |
| 1418 | 1418 | unsigned char outbuf[4096]; | |
| 1419 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 1419 | 1420 | ||
| 1420 | - | git_deflate_init(&stream, zlib_compression_level); | |
| 1421 | + | git_deflate_init(&stream, cfg->zlib_compression_level); | |
| 1421 | 1422 | stream.next_in = in; | |
| 1422 | 1423 | stream.avail_in = size; | |
| 1423 | 1424 | ||
| @@ -1514,7 +1515,7 @@ static void fix_unresolved_deltas(struct hashfile *f) | |||
| 1514 | 1515 | struct ref_delta_entry *d = sorted_by_pos[i]; | |
| 1515 | 1516 | enum object_type type; | |
| 1516 | 1517 | void *data; | |
| 1517 | - | unsigned long size; | |
| 1518 | + | size_t size; | |
| 1518 | 1519 | ||
| 1519 | 1520 | if (objects[d->obj_no].real_type != OBJ_REF_DELTA) | |
| 1520 | 1521 | continue; | |
| @@ -1824,11 +1825,16 @@ static void repack_local_links(void) | |||
| 1824 | 1825 | ||
| 1825 | 1826 | oidset_iter_init(&outgoing_links, &iter); | |
| 1826 | 1827 | while ((oid = oidset_iter_next(&iter))) { | |
| 1827 | - | struct object_info info = OBJECT_INFO_INIT; | |
| 1828 | + | struct odb_source_info source_info; | |
| 1829 | + | struct object_info info = { | |
| 1830 | + | .source_infop = &source_info, | |
| 1831 | + | }; | |
| 1832 | + | ||
| 1828 | 1833 | if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0)) | |
| 1829 | 1834 | /* Missing; assume it is a promisor object */ | |
| 1830 | 1835 | continue; | |
| 1831 | - | if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor) | |
| 1836 | + | if (source_info.source->type == ODB_SOURCE_PACKED && | |
| 1837 | + | source_info.u.packed.pack->pack_promisor) | |
| 1832 | 1838 | continue; | |
| 1833 | 1839 | ||
| 1834 | 1840 | if (!cmd.args.nr) { | |
| @@ -1880,7 +1886,7 @@ static void repack_local_links(void) | |||
| 1880 | 1886 | int cmd_index_pack(int argc, | |
| 1881 | 1887 | const char **argv, | |
| 1882 | 1888 | const char *prefix, | |
| 1883 | - | struct repository *repo UNUSED) | |
| 1889 | + | struct repository *repo) | |
| 1884 | 1890 | { | |
| 1885 | 1891 | int i, fix_thin_pack = 0, verify = 0, stat_only = 0, rev_index; | |
| 1886 | 1892 | const char *curr_index; | |
| @@ -1897,15 +1903,15 @@ int cmd_index_pack(int argc, | |||
| 1897 | 1903 | int report_end_of_input = 0; | |
| 1898 | 1904 | int hash_algo = 0; | |
| 1899 | 1905 | ||
| 1906 | + | show_usage_if_asked(argc, argv, index_pack_usage); | |
| 1907 | + | ||
| 1900 | 1908 | /* | |
| 1901 | 1909 | * index-pack never needs to fetch missing objects except when | |
| 1902 | 1910 | * REF_DELTA bases are missing (which are explicitly handled). It only | |
| 1903 | 1911 | * accesses the repo to do hash collision checks and to check which | |
| 1904 | 1912 | * REF_DELTA bases need to be fetched. | |
| 1905 | 1913 | */ | |
| 1906 | - | fetch_if_missing = 0; | |
| 1907 | - | ||
| 1908 | - | show_usage_if_asked(argc, argv, index_pack_usage); | |
| 1914 | + | (repo ? repo : the_repository)->fetch_if_missing = 0; | |
| 1909 | 1915 | ||
| 1910 | 1916 | disable_replace_refs(); | |
| 1911 | 1917 | ||
modified builtin/init-db.c
| @@ -81,6 +81,7 @@ int cmd_init_db(int argc, | |||
| 81 | 81 | const char *template_dir = NULL; | |
| 82 | 82 | char *template_dir_to_free = NULL; | |
| 83 | 83 | unsigned int flags = 0; | |
| 84 | + | int bare = startup_info->force_bare_repository ? 1 : -1; | |
| 84 | 85 | const char *object_format = NULL; | |
| 85 | 86 | const char *ref_format = NULL; | |
| 86 | 87 | const char *initial_branch = NULL; | |
| @@ -90,7 +91,7 @@ int cmd_init_db(int argc, | |||
| 90 | 91 | const struct option init_db_options[] = { | |
| 91 | 92 | OPT_STRING(0, "template", &template_dir, N_("template-directory"), | |
| 92 | 93 | N_("directory from which templates will be used")), | |
| 93 | - | OPT_SET_INT(0, "bare", &is_bare_repository_cfg, | |
| 94 | + | OPT_SET_INT(0, "bare", &bare, | |
| 94 | 95 | N_("create a bare repository"), 1), | |
| 95 | 96 | { | |
| 96 | 97 | .type = OPTION_CALLBACK, | |
| @@ -116,7 +117,7 @@ int cmd_init_db(int argc, | |||
| 116 | 117 | ||
| 117 | 118 | argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0); | |
| 118 | 119 | ||
| 119 | - | if (real_git_dir && is_bare_repository_cfg == 1) | |
| 120 | + | if (real_git_dir && bare == 1) | |
| 120 | 121 | die(_("options '%s' and '%s' cannot be used together"), "--separate-git-dir", "--bare"); | |
| 121 | 122 | ||
| 122 | 123 | if (real_git_dir && !is_absolute_path(real_git_dir)) | |
| @@ -160,7 +161,7 @@ int cmd_init_db(int argc, | |||
| 160 | 161 | } else if (0 < argc) { | |
| 161 | 162 | usage(init_db_usage[0]); | |
| 162 | 163 | } | |
| 163 | - | if (is_bare_repository_cfg == 1) { | |
| 164 | + | if (bare == 1) { | |
| 164 | 165 | char *cwd = xgetcwd(); | |
| 165 | 166 | setenv(GIT_DIR_ENVIRONMENT, cwd, argc > 0); | |
| 166 | 167 | free(cwd); | |
| @@ -187,7 +188,7 @@ int cmd_init_db(int argc, | |||
| 187 | 188 | */ | |
| 188 | 189 | git_dir = xstrdup_or_null(getenv(GIT_DIR_ENVIRONMENT)); | |
| 189 | 190 | work_tree = xstrdup_or_null(getenv(GIT_WORK_TREE_ENVIRONMENT)); | |
| 190 | - | if ((!git_dir || is_bare_repository_cfg == 1) && work_tree) | |
| 191 | + | if ((!git_dir || bare == 1) && work_tree) | |
| 191 | 192 | die(_("%s (or --work-tree=<directory>) not allowed without " | |
| 192 | 193 | "specifying %s (or --git-dir=<directory>)"), | |
| 193 | 194 | GIT_WORK_TREE_ENVIRONMENT, | |
| @@ -224,36 +225,31 @@ int cmd_init_db(int argc, | |||
| 224 | 225 | strbuf_release(&sb); | |
| 225 | 226 | } | |
| 226 | 227 | ||
| 227 | - | if (is_bare_repository_cfg < 0) | |
| 228 | - | is_bare_repository_cfg = guess_repository_type(git_dir); | |
| 228 | + | if (bare < 0) | |
| 229 | + | bare = guess_repository_type(git_dir); | |
| 229 | 230 | ||
| 230 | - | if (!is_bare_repository_cfg) { | |
| 231 | + | if (!bare) { | |
| 231 | 232 | const char *git_dir_parent = strrchr(git_dir, '/'); | |
| 232 | - | if (git_dir_parent) { | |
| 233 | - | char *rel = xstrndup(git_dir, git_dir_parent - git_dir); | |
| 234 | - | git_work_tree_cfg = real_pathdup(rel, 1); | |
| 235 | - | free(rel); | |
| 233 | + | ||
| 234 | + | if (!work_tree) { | |
| 235 | + | if (git_dir_parent) { | |
| 236 | + | char *rel = xstrndup(git_dir, git_dir_parent - git_dir); | |
| 237 | + | work_tree = real_pathdup(rel, 1); | |
| 238 | + | free(rel); | |
| 239 | + | } else { | |
| 240 | + | work_tree = xgetcwd(); | |
| 241 | + | } | |
| 236 | 242 | } | |
| 237 | - | if (!git_work_tree_cfg) | |
| 238 | - | git_work_tree_cfg = xgetcwd(); | |
| 239 | - | if (work_tree) | |
| 240 | - | set_git_work_tree(work_tree); | |
| 241 | - | else | |
| 242 | - | set_git_work_tree(git_work_tree_cfg); | |
| 243 | - | if (access(repo_get_work_tree(the_repository), X_OK)) | |
| 244 | - | die_errno (_("Cannot access work tree '%s'"), | |
| 245 | - | repo_get_work_tree(the_repository)); | |
| 246 | - | } | |
| 247 | - | else { | |
| 248 | - | if (real_git_dir) | |
| 249 | - | die(_("--separate-git-dir incompatible with bare repository")); | |
| 250 | - | if (work_tree) | |
| 251 | - | set_git_work_tree(work_tree); | |
| 243 | + | ||
| 244 | + | if (access(work_tree, X_OK)) | |
| 245 | + | die_errno (_("Cannot access work tree '%s'"), work_tree); | |
| 246 | + | } else if (real_git_dir) { | |
| 247 | + | die(_("--separate-git-dir incompatible with bare repository")); | |
| 252 | 248 | } | |
| 253 | 249 | ||
| 254 | 250 | flags |= INIT_DB_EXIST_OK; | |
| 255 | - | ret = init_db(git_dir, real_git_dir, template_dir, hash_algo, | |
| 256 | - | ref_storage_format, initial_branch, | |
| 251 | + | ret = init_db(the_repository, git_dir, real_git_dir, work_tree, | |
| 252 | + | template_dir, hash_algo, ref_storage_format, initial_branch, | |
| 257 | 253 | init_shared_repository, flags); | |
| 258 | 254 | ||
| 259 | 255 | free(template_dir_to_free); | |
modified builtin/last-modified.c
| @@ -290,7 +290,8 @@ static void process_parent(struct last_modified *lm, | |||
| 290 | 290 | { | |
| 291 | 291 | struct bitmap *active_p; | |
| 292 | 292 | ||
| 293 | - | repo_parse_commit(lm->rev.repo, parent); | |
| 293 | + | if (repo_parse_commit(lm->rev.repo, parent)) | |
| 294 | + | return; | |
| 294 | 295 | active_p = active_paths_for(lm, parent); | |
| 295 | 296 | ||
| 296 | 297 | /* | |
| @@ -344,6 +345,7 @@ static void process_parent(struct last_modified *lm, | |||
| 344 | 345 | static int last_modified_run(struct last_modified *lm) | |
| 345 | 346 | { | |
| 346 | 347 | int max_count, queue_popped = 0; | |
| 348 | + | struct commit *c, *n; | |
| 347 | 349 | struct prio_queue queue = { compare_commits_by_gen_then_commit_date }; | |
| 348 | 350 | struct prio_queue not_queue = { compare_commits_by_gen_then_commit_date }; | |
| 349 | 351 | struct commit_list *list; | |
| @@ -389,10 +391,9 @@ static int last_modified_run(struct last_modified *lm) | |||
| 389 | 391 | } | |
| 390 | 392 | } | |
| 391 | 393 | ||
| 392 | - | while (queue.nr) { | |
| 394 | + | while ((c = prio_queue_get(&queue))) { | |
| 393 | 395 | int parent_i; | |
| 394 | 396 | struct commit_list *p; | |
| 395 | - | struct commit *c = prio_queue_get(&queue); | |
| 396 | 397 | struct bitmap *active_c = active_paths_for(lm, c); | |
| 397 | 398 | ||
| 398 | 399 | if ((0 <= max_count && max_count < ++queue_popped) || | |
| @@ -414,13 +415,14 @@ static int last_modified_run(struct last_modified *lm) | |||
| 414 | 415 | * Otherwise, make sure that 'c' isn't reachable from anything | |
| 415 | 416 | * in the '--not' queue. | |
| 416 | 417 | */ | |
| 417 | - | repo_parse_commit(lm->rev.repo, c); | |
| 418 | + | if (repo_parse_commit(lm->rev.repo, c)) | |
| 419 | + | goto cleanup; | |
| 418 | 420 | ||
| 419 | - | while (not_queue.nr) { | |
| 421 | + | while ((n = prio_queue_get(¬_queue))) { | |
| 420 | 422 | struct commit_list *np; | |
| 421 | - | struct commit *n = prio_queue_get(¬_queue); | |
| 422 | 423 | ||
| 423 | - | repo_parse_commit(lm->rev.repo, n); | |
| 424 | + | if (repo_parse_commit(lm->rev.repo, n)) | |
| 425 | + | continue; | |
| 424 | 426 | ||
| 425 | 427 | for (np = n->parents; np; np = np->next) { | |
| 426 | 428 | if (!(np->item->object.flags & PARENT2)) { | |
modified builtin/log.c
| @@ -21,10 +21,12 @@ | |||
| 21 | 21 | #include "color.h" | |
| 22 | 22 | #include "commit.h" | |
| 23 | 23 | #include "diff.h" | |
| 24 | + | #include "diffcore.h" | |
| 24 | 25 | #include "diff-merges.h" | |
| 25 | 26 | #include "revision.h" | |
| 26 | 27 | #include "log-tree.h" | |
| 27 | 28 | #include "oid-array.h" | |
| 29 | + | #include "oidset.h" | |
| 28 | 30 | #include "tag.h" | |
| 29 | 31 | #include "reflog-walk.h" | |
| 30 | 32 | #include "patch-ids.h" | |
| @@ -43,9 +45,11 @@ | |||
| 43 | 45 | #include "utf8.h" | |
| 44 | 46 | ||
| 45 | 47 | #include "commit-reach.h" | |
| 48 | + | #include "promisor-remote.h" | |
| 46 | 49 | #include "range-diff.h" | |
| 47 | 50 | #include "tmp-objdir.h" | |
| 48 | 51 | #include "tree.h" | |
| 52 | + | #include "userdiff.h" | |
| 49 | 53 | #include "write-or-die.h" | |
| 50 | 54 | ||
| 51 | 55 | #define MAIL_DEFAULT_WRAP 72 | |
| @@ -609,7 +613,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c | |||
| 609 | 613 | ||
| 610 | 614 | static int show_tag_object(const struct object_id *oid, struct rev_info *rev) | |
| 611 | 615 | { | |
| 612 | - | unsigned long size; | |
| 616 | + | size_t size; | |
| 613 | 617 | enum object_type type; | |
| 614 | 618 | char *buf = odb_read_object(the_repository->objects, oid, &type, &size); | |
| 615 | 619 | unsigned long offset = 0; | |
| @@ -1884,6 +1888,7 @@ static void prepare_bases(struct base_tree_info *bases, | |||
| 1884 | 1888 | bases->nr_patch_id++; | |
| 1885 | 1889 | } | |
| 1886 | 1890 | clear_commit_base(&commit_base); | |
| 1891 | + | release_revisions(&revs); | |
| 1887 | 1892 | } | |
| 1888 | 1893 | ||
| 1889 | 1894 | static void print_bases(struct base_tree_info *bases, FILE *file) | |
| @@ -2602,6 +2607,131 @@ static void print_commit(char sign, struct commit *commit, int verbose, | |||
| 2602 | 2607 | } | |
| 2603 | 2608 | } | |
| 2604 | 2609 | ||
| 2610 | + | /* | |
| 2611 | + | * Enumerate blob OIDs from a single commit's diff, inserting them into blobs. | |
| 2612 | + | * Skips files whose userdiff driver explicitly declares binary status | |
| 2613 | + | * (drv->binary > 0), since patch-ID uses oid_to_hex() for those and | |
| 2614 | + | * never reads blob content. Use userdiff_find_by_path() since | |
| 2615 | + | * diff_filespec_load_driver() is static in diff.c. | |
| 2616 | + | * | |
| 2617 | + | * Clean up with diff_queue_clear() (from diffcore.h). | |
| 2618 | + | */ | |
| 2619 | + | static void collect_diff_blob_oids(struct commit *commit, | |
| 2620 | + | struct diff_options *opts, | |
| 2621 | + | struct oidset *blobs) | |
| 2622 | + | { | |
| 2623 | + | struct diff_queue_struct *q; | |
| 2624 | + | ||
| 2625 | + | /* | |
| 2626 | + | * Merge commits are filtered out by patch_id_defined() in patch-ids.c, | |
| 2627 | + | * so we'll never be called with one. | |
| 2628 | + | */ | |
| 2629 | + | assert(!commit->parents || !commit->parents->next); | |
| 2630 | + | ||
| 2631 | + | if (commit->parents) | |
| 2632 | + | diff_tree_oid(&commit->parents->item->object.oid, | |
| 2633 | + | &commit->object.oid, "", opts); | |
| 2634 | + | else | |
| 2635 | + | diff_root_tree_oid(&commit->object.oid, "", opts); | |
| 2636 | + | diffcore_std(opts); | |
| 2637 | + | ||
| 2638 | + | q = &diff_queued_diff; | |
| 2639 | + | for (int i = 0; i < q->nr; i++) { | |
| 2640 | + | struct diff_filepair *p = q->queue[i]; | |
| 2641 | + | struct userdiff_driver *drv; | |
| 2642 | + | ||
| 2643 | + | /* Skip binary files */ | |
| 2644 | + | drv = userdiff_find_by_path(opts->repo->index, p->one->path); | |
| 2645 | + | if (drv && drv->binary > 0) | |
| 2646 | + | continue; | |
| 2647 | + | ||
| 2648 | + | if (DIFF_FILE_VALID(p->one) && | |
| 2649 | + | odb_read_object_info_extended(opts->repo->objects, | |
| 2650 | + | &p->one->oid, NULL, | |
| 2651 | + | OBJECT_INFO_FOR_PREFETCH)) | |
| 2652 | + | oidset_insert(blobs, &p->one->oid); | |
| 2653 | + | if (DIFF_FILE_VALID(p->two) && | |
| 2654 | + | odb_read_object_info_extended(opts->repo->objects, | |
| 2655 | + | &p->two->oid, NULL, | |
| 2656 | + | OBJECT_INFO_FOR_PREFETCH)) | |
| 2657 | + | oidset_insert(blobs, &p->two->oid); | |
| 2658 | + | } | |
| 2659 | + | diff_queue_clear(q); | |
| 2660 | + | } | |
| 2661 | + | ||
| 2662 | + | static int always_match(const void *cmp_data UNUSED, | |
| 2663 | + | const struct hashmap_entry *entry1 UNUSED, | |
| 2664 | + | const struct hashmap_entry *entry2 UNUSED, | |
| 2665 | + | const void *keydata UNUSED) | |
| 2666 | + | { | |
| 2667 | + | return 0; | |
| 2668 | + | } | |
| 2669 | + | ||
| 2670 | + | /* | |
| 2671 | + | * Prefetch blobs for git cherry in partial clones. | |
| 2672 | + | * | |
| 2673 | + | * Called between the revision walk (which builds the head-side | |
| 2674 | + | * commit list) and the has_commit_patch_id() comparison loop. | |
| 2675 | + | * | |
| 2676 | + | * Uses a cmpfn-swap trick to avoid reading blobs: temporarily | |
| 2677 | + | * replaces the hashmap's comparison function with a trivial | |
| 2678 | + | * always-match function, so hashmap_get()/hashmap_get_next() match | |
| 2679 | + | * any entry with the same oidhash bucket. These are the set of oids | |
| 2680 | + | * that would trigger patch_id_neq() during normal lookup and cause | |
| 2681 | + | * blobs to be read on demand, and we want to prefetch them all at | |
| 2682 | + | * once instead. | |
| 2683 | + | */ | |
| 2684 | + | static void prefetch_cherry_blobs(struct repository *repo, | |
| 2685 | + | struct commit_list *list, | |
| 2686 | + | struct patch_ids *ids) | |
| 2687 | + | { | |
| 2688 | + | struct oidset blobs = OIDSET_INIT; | |
| 2689 | + | hashmap_cmp_fn original_cmpfn; | |
| 2690 | + | ||
| 2691 | + | /* Exit if we're not in a partial clone */ | |
| 2692 | + | if (!repo_has_promisor_remote(repo)) | |
| 2693 | + | return; | |
| 2694 | + | ||
| 2695 | + | /* Save original cmpfn, replace with always_match */ | |
| 2696 | + | original_cmpfn = ids->patches.cmpfn; | |
| 2697 | + | ids->patches.cmpfn = always_match; | |
| 2698 | + | ||
| 2699 | + | /* Find header-only collisions, gather blobs from those commits */ | |
| 2700 | + | for (struct commit_list *l = list; l; l = l->next) { | |
| 2701 | + | struct commit *c = l->item; | |
| 2702 | + | bool match_found = false; | |
| 2703 | + | for (struct patch_id *cur = patch_id_iter_first(c, ids); | |
| 2704 | + | cur; | |
| 2705 | + | cur = patch_id_iter_next(cur, ids)) { | |
| 2706 | + | match_found = true; | |
| 2707 | + | collect_diff_blob_oids(cur->commit, &ids->diffopts, | |
| 2708 | + | &blobs); | |
| 2709 | + | } | |
| 2710 | + | if (match_found) | |
| 2711 | + | collect_diff_blob_oids(c, &ids->diffopts, &blobs); | |
| 2712 | + | } | |
| 2713 | + | ||
| 2714 | + | /* Restore original cmpfn */ | |
| 2715 | + | ids->patches.cmpfn = original_cmpfn; | |
| 2716 | + | ||
| 2717 | + | /* If we have any blobs to fetch, fetch them */ | |
| 2718 | + | if (oidset_size(&blobs)) { | |
| 2719 | + | struct oid_array to_fetch = OID_ARRAY_INIT; | |
| 2720 | + | struct oidset_iter iter; | |
| 2721 | + | const struct object_id *oid; | |
| 2722 | + | ||
| 2723 | + | oidset_iter_init(&blobs, &iter); | |
| 2724 | + | while ((oid = oidset_iter_next(&iter))) | |
| 2725 | + | oid_array_append(&to_fetch, oid); | |
| 2726 | + | ||
| 2727 | + | promisor_remote_get_direct(repo, to_fetch.oid, to_fetch.nr); | |
| 2728 | + | ||
| 2729 | + | oid_array_clear(&to_fetch); | |
| 2730 | + | } | |
| 2731 | + | ||
| 2732 | + | oidset_clear(&blobs); | |
| 2733 | + | } | |
| 2734 | + | ||
| 2605 | 2735 | int cmd_cherry(int argc, | |
| 2606 | 2736 | const char **argv, | |
| 2607 | 2737 | const char *prefix, | |
| @@ -2673,6 +2803,8 @@ int cmd_cherry(int argc, | |||
| 2673 | 2803 | commit_list_insert(commit, &list); | |
| 2674 | 2804 | } | |
| 2675 | 2805 | ||
| 2806 | + | prefetch_cherry_blobs(the_repository, list, &ids); | |
| 2807 | + | ||
| 2676 | 2808 | for (struct commit_list *l = list; l; l = l->next) { | |
| 2677 | 2809 | char sign = '+'; | |
| 2678 | 2810 | ||
modified builtin/ls-files.c
| @@ -250,20 +250,23 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line, | |||
| 250 | 250 | const struct object_id *oid, | |
| 251 | 251 | const enum object_type type, unsigned int padded) | |
| 252 | 252 | { | |
| 253 | + | static const char padding[] = " "; | |
| 254 | + | size_t min_len = padded ? strlen(padding) : 0; | |
| 255 | + | size_t orig_len = line->len; | |
| 256 | + | size_t len; | |
| 257 | + | ||
| 253 | 258 | if (type == OBJ_BLOB) { | |
| 254 | - | unsigned long size; | |
| 259 | + | size_t size; | |
| 255 | 260 | if (odb_read_object_info(repo->objects, oid, &size) < 0) | |
| 256 | 261 | die(_("could not get object info about '%s'"), | |
| 257 | 262 | oid_to_hex(oid)); | |
| 258 | - | if (padded) | |
| 259 | - | strbuf_addf(line, "%7"PRIuMAX, (uintmax_t)size); | |
| 260 | - | else | |
| 261 | - | strbuf_addf(line, "%"PRIuMAX, (uintmax_t)size); | |
| 262 | - | } else if (padded) { | |
| 263 | - | strbuf_addf(line, "%7s", "-"); | |
| 263 | + | strbuf_add_uint(line, size); | |
| 264 | 264 | } else { | |
| 265 | 265 | strbuf_addstr(line, "-"); | |
| 266 | 266 | } | |
| 267 | + | len = line->len - orig_len; | |
| 268 | + | if (len < min_len) | |
| 269 | + | strbuf_insert(line, orig_len, padding, min_len - len); | |
| 267 | 270 | } | |
| 268 | 271 | ||
| 269 | 272 | static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce, | |
| @@ -450,6 +453,17 @@ static void show_files(struct repository *repo, struct dir_struct *dir) | |||
| 450 | 453 | continue; | |
| 451 | 454 | if (ce_skip_worktree(ce)) | |
| 452 | 455 | continue; | |
| 456 | + | /* | |
| 457 | + | * match_pathspec() is linear in pathspec.nr, so prefilter only | |
| 458 | + | * the single-pathspec case. Only entries shown by show_ce() | |
| 459 | + | * satisfy --error-unmatch. | |
| 460 | + | */ | |
| 461 | + | if (pathspec.nr == 1 && | |
| 462 | + | !match_pathspec(repo->index, &pathspec, fullname.buf, | |
| 463 | + | fullname.len, max_prefix_len, NULL, | |
| 464 | + | S_ISDIR(ce->ce_mode) || | |
| 465 | + | S_ISGITLINK(ce->ce_mode))) | |
| 466 | + | continue; | |
| 453 | 467 | stat_err = lstat(fullname.buf, &st); | |
| 454 | 468 | if (stat_err && (errno != ENOENT && errno != ENOTDIR)) | |
| 455 | 469 | error_errno("cannot lstat '%s'", fullname.buf); | |
| @@ -703,8 +717,8 @@ int cmd_ls_files(int argc, | |||
| 703 | 717 | if (dir.exclude_per_dir) | |
| 704 | 718 | exc_given = 1; | |
| 705 | 719 | ||
| 706 | - | if (require_work_tree && !is_inside_work_tree()) | |
| 707 | - | setup_work_tree(); | |
| 720 | + | if (require_work_tree && !is_inside_work_tree(repo)) | |
| 721 | + | setup_work_tree(repo); | |
| 708 | 722 | ||
| 709 | 723 | if (recurse_submodules && | |
| 710 | 724 | (show_deleted || show_others || show_unmerged || | |
modified builtin/ls-tree.c
| @@ -26,20 +26,23 @@ static const char * const ls_tree_usage[] = { | |||
| 26 | 26 | static void expand_objectsize(struct strbuf *line, const struct object_id *oid, | |
| 27 | 27 | const enum object_type type, unsigned int padded) | |
| 28 | 28 | { | |
| 29 | + | static const char padding[] = " "; | |
| 30 | + | size_t min_len = padded ? strlen(padding) : 0; | |
| 31 | + | size_t orig_len = line->len; | |
| 32 | + | size_t len; | |
| 33 | + | ||
| 29 | 34 | if (type == OBJ_BLOB) { | |
| 30 | - | unsigned long size; | |
| 35 | + | size_t size; | |
| 31 | 36 | if (odb_read_object_info(the_repository->objects, oid, &size) < 0) | |
| 32 | 37 | die(_("could not get object info about '%s'"), | |
| 33 | 38 | oid_to_hex(oid)); | |
| 34 | - | if (padded) | |
| 35 | - | strbuf_addf(line, "%7"PRIuMAX, (uintmax_t)size); | |
| 36 | - | else | |
| 37 | - | strbuf_addf(line, "%"PRIuMAX, (uintmax_t)size); | |
| 38 | - | } else if (padded) { | |
| 39 | - | strbuf_addf(line, "%7s", "-"); | |
| 39 | + | strbuf_add_uint(line, size); | |
| 40 | 40 | } else { | |
| 41 | 41 | strbuf_addstr(line, "-"); | |
| 42 | 42 | } | |
| 43 | + | len = line->len - orig_len; | |
| 44 | + | if (len < min_len) | |
| 45 | + | strbuf_insert(line, orig_len, padding, min_len - len); | |
| 43 | 46 | } | |
| 44 | 47 | ||
| 45 | 48 | struct ls_tree_options { | |
| @@ -217,7 +220,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base, | |||
| 217 | 220 | return early; | |
| 218 | 221 | ||
| 219 | 222 | if (type == OBJ_BLOB) { | |
| 220 | - | unsigned long size; | |
| 223 | + | size_t size; | |
| 221 | 224 | if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD) | |
| 222 | 225 | xsnprintf(size_text, sizeof(size_text), "BAD"); | |
| 223 | 226 | else | |
modified builtin/mailsplit.c
| @@ -225,14 +225,14 @@ static int split_mbox(const char *file, const char *dir, int allow_bare, | |||
| 225 | 225 | FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r"); | |
| 226 | 226 | int file_done = 0; | |
| 227 | 227 | ||
| 228 | - | if (isatty(fileno(f))) | |
| 229 | - | warning(_("reading patches from stdin/tty...")); | |
| 230 | - | ||
| 231 | 228 | if (!f) { | |
| 232 | 229 | error_errno("cannot open mbox %s", file); | |
| 233 | 230 | goto out; | |
| 234 | 231 | } | |
| 235 | 232 | ||
| 233 | + | if (isatty(fileno(f))) | |
| 234 | + | warning(_("reading patches from stdin/tty...")); | |
| 235 | + | ||
| 236 | 236 | do { | |
| 237 | 237 | peek = fgetc(f); | |
| 238 | 238 | if (peek == EOF) { | |
modified builtin/merge-base.c
| @@ -11,10 +11,12 @@ | |||
| 11 | 11 | ||
| 12 | 12 | static int show_merge_base(struct commit **rev, size_t rev_nr, int show_all) | |
| 13 | 13 | { | |
| 14 | + | enum merge_base_flags flags = show_all ? MERGE_BASE_FIND_ALL : 0; | |
| 14 | 15 | struct commit_list *result = NULL, *r; | |
| 15 | 16 | ||
| 16 | 17 | if (repo_get_merge_bases_many_dirty(the_repository, rev[0], | |
| 17 | - | rev_nr - 1, rev + 1, &result) < 0) { | |
| 18 | + | rev_nr - 1, rev + 1, | |
| 19 | + | flags, &result) < 0) { | |
| 18 | 20 | commit_list_free(result); | |
| 19 | 21 | return -1; | |
| 20 | 22 | } | |
modified builtin/merge-file.c
| @@ -110,7 +110,7 @@ int cmd_merge_file(int argc, | |||
| 110 | 110 | ||
| 111 | 111 | if (!repo && object_id) | |
| 112 | 112 | /* emit the correct "not a git repo" error in this case */ | |
| 113 | - | setup_git_directory(); | |
| 113 | + | setup_git_directory(the_repository); | |
| 114 | 114 | ||
| 115 | 115 | for (i = 0; i < 3; i++) { | |
| 116 | 116 | char *fname; | |
modified builtin/merge-tree.c
| @@ -69,7 +69,7 @@ static const char *explanation(struct merge_list *entry) | |||
| 69 | 69 | return "removed in remote"; | |
| 70 | 70 | } | |
| 71 | 71 | ||
| 72 | - | static void *result(struct merge_list *entry, unsigned long *size) | |
| 72 | + | static void *result(struct merge_list *entry, size_t *size) | |
| 73 | 73 | { | |
| 74 | 74 | enum object_type type; | |
| 75 | 75 | struct blob *base, *our, *their; | |
| @@ -96,7 +96,7 @@ static void *result(struct merge_list *entry, unsigned long *size) | |||
| 96 | 96 | base, our, their, size); | |
| 97 | 97 | } | |
| 98 | 98 | ||
| 99 | - | static void *origin(struct merge_list *entry, unsigned long *size) | |
| 99 | + | static void *origin(struct merge_list *entry, size_t *size) | |
| 100 | 100 | { | |
| 101 | 101 | enum object_type type; | |
| 102 | 102 | while (entry) { | |
| @@ -119,7 +119,7 @@ static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf) | |||
| 119 | 119 | ||
| 120 | 120 | static void show_diff(struct merge_list *entry) | |
| 121 | 121 | { | |
| 122 | - | unsigned long size; | |
| 122 | + | size_t size; | |
| 123 | 123 | mmfile_t src, dst; | |
| 124 | 124 | xpparam_t xpp; | |
| 125 | 125 | xdemitconf_t xecfg; | |
modified builtin/merge.c
| @@ -537,7 +537,8 @@ static void finish(struct commit *head_commit, | |||
| 537 | 537 | run_hooks_l(the_repository, "post-merge", squash ? "1" : "0", NULL); | |
| 538 | 538 | ||
| 539 | 539 | if (new_head) | |
| 540 | - | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH"); | |
| 540 | + | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH", | |
| 541 | + | NULL, NULL, NULL, NULL); | |
| 541 | 542 | strbuf_release(&reflog_message); | |
| 542 | 543 | } | |
| 543 | 544 | ||
| @@ -552,7 +553,7 @@ static void merge_name(const char *remote, struct strbuf *msg) | |||
| 552 | 553 | char *found_ref = NULL; | |
| 553 | 554 | int len, early; | |
| 554 | 555 | ||
| 555 | - | copy_branchname(&bname, remote, 0); | |
| 556 | + | copy_branchname(the_repository, &bname, remote, 0); | |
| 556 | 557 | remote = bname.buf; | |
| 557 | 558 | ||
| 558 | 559 | oidclr(&branch_head, the_repository->hash_algo); | |
| @@ -1372,7 +1373,7 @@ int cmd_merge(int argc, | |||
| 1372 | 1373 | struct commit_list *common = NULL; | |
| 1373 | 1374 | const char *best_strategy = NULL, *wt_strategy = NULL; | |
| 1374 | 1375 | struct commit_list *remoteheads = NULL, *p; | |
| 1375 | - | void *branch_to_free; | |
| 1376 | + | void *branch_to_free, *argv_to_free = NULL; | |
| 1376 | 1377 | int orig_argc = argc; | |
| 1377 | 1378 | int merge_log_config = -1; | |
| 1378 | 1379 | ||
| @@ -1516,8 +1517,10 @@ int cmd_merge(int argc, | |||
| 1516 | 1517 | option_commit = 1; | |
| 1517 | 1518 | ||
| 1518 | 1519 | if (!argc) { | |
| 1519 | - | if (default_to_upstream) | |
| 1520 | + | if (default_to_upstream) { | |
| 1520 | 1521 | argc = setup_with_upstream(&argv); | |
| 1522 | + | argv_to_free = argv; | |
| 1523 | + | } | |
| 1521 | 1524 | else | |
| 1522 | 1525 | die(_("No commit specified and merge.defaultToUpstream not set.")); | |
| 1523 | 1526 | } else if (argc == 1 && !strcmp(argv[0], "-")) { | |
| @@ -1672,12 +1675,14 @@ int cmd_merge(int argc, | |||
| 1672 | 1675 | } | |
| 1673 | 1676 | ||
| 1674 | 1677 | if (autostash) | |
| 1675 | - | create_autostash_ref(the_repository, "MERGE_AUTOSTASH"); | |
| 1678 | + | create_autostash_ref(the_repository, "MERGE_AUTOSTASH", | |
| 1679 | + | NULL, false); | |
| 1676 | 1680 | if (checkout_fast_forward(the_repository, | |
| 1677 | 1681 | &head_commit->object.oid, | |
| 1678 | 1682 | &commit->object.oid, | |
| 1679 | 1683 | overwrite_ignore)) { | |
| 1680 | - | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH"); | |
| 1684 | + | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH", | |
| 1685 | + | NULL, NULL, NULL, NULL); | |
| 1681 | 1686 | ret = 1; | |
| 1682 | 1687 | goto done; | |
| 1683 | 1688 | } | |
| @@ -1735,21 +1740,11 @@ int cmd_merge(int argc, | |||
| 1735 | 1740 | struct commit_list *j; | |
| 1736 | 1741 | ||
| 1737 | 1742 | for (j = remoteheads; j; j = j->next) { | |
| 1738 | - | struct commit_list *common_one = NULL; | |
| 1739 | - | struct commit *common_item; | |
| 1740 | - | ||
| 1741 | - | /* | |
| 1742 | - | * Here we *have* to calculate the individual | |
| 1743 | - | * merge_bases again, otherwise "git merge HEAD^ | |
| 1744 | - | * HEAD^^" would be missed. | |
| 1745 | - | */ | |
| 1746 | - | if (repo_get_merge_bases(the_repository, head_commit, | |
| 1747 | - | j->item, &common_one) < 0) | |
| 1743 | + | int ret = repo_in_merge_bases(the_repository, | |
| 1744 | + | j->item, head_commit); | |
| 1745 | + | if (ret < 0) | |
| 1748 | 1746 | exit(128); | |
| 1749 | - | ||
| 1750 | - | common_item = common_one->item; | |
| 1751 | - | commit_list_free(common_one); | |
| 1752 | - | if (!oideq(&common_item->object.oid, &j->item->object.oid)) { | |
| 1747 | + | if (!ret) { | |
| 1753 | 1748 | up_to_date = 0; | |
| 1754 | 1749 | break; | |
| 1755 | 1750 | } | |
| @@ -1764,7 +1759,8 @@ int cmd_merge(int argc, | |||
| 1764 | 1759 | die_ff_impossible(); | |
| 1765 | 1760 | ||
| 1766 | 1761 | if (autostash) | |
| 1767 | - | create_autostash_ref(the_repository, "MERGE_AUTOSTASH"); | |
| 1762 | + | create_autostash_ref(the_repository, "MERGE_AUTOSTASH", | |
| 1763 | + | NULL, false); | |
| 1768 | 1764 | ||
| 1769 | 1765 | /* We are going to make a new commit. */ | |
| 1770 | 1766 | git_committer_info(IDENT_STRICT); | |
| @@ -1849,7 +1845,8 @@ int cmd_merge(int argc, | |||
| 1849 | 1845 | else | |
| 1850 | 1846 | fprintf(stderr, _("Merge with strategy %s failed.\n"), | |
| 1851 | 1847 | use_strategies[0]->name); | |
| 1852 | - | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH"); | |
| 1848 | + | apply_autostash_ref(the_repository, "MERGE_AUTOSTASH", | |
| 1849 | + | NULL, NULL, NULL, NULL); | |
| 1853 | 1850 | ret = 2; | |
| 1854 | 1851 | goto done; | |
| 1855 | 1852 | } else if (best_strategy == wt_strategy) | |
| @@ -1885,6 +1882,7 @@ done: | |||
| 1885 | 1882 | } | |
| 1886 | 1883 | strbuf_release(&buf); | |
| 1887 | 1884 | free(branch_to_free); | |
| 1885 | + | free(argv_to_free); | |
| 1888 | 1886 | free(pull_twohead); | |
| 1889 | 1887 | free(pull_octopus); | |
| 1890 | 1888 | discard_index(the_repository->index); | |
modified builtin/mktag.c
| @@ -50,7 +50,7 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type) | |||
| 50 | 50 | { | |
| 51 | 51 | int ret; | |
| 52 | 52 | enum object_type type; | |
| 53 | - | unsigned long size; | |
| 53 | + | size_t size; | |
| 54 | 54 | void *buffer; | |
| 55 | 55 | const struct object_id *repl; | |
| 56 | 56 | ||
modified builtin/mktree.c
| @@ -125,7 +125,6 @@ static void mktree_line(struct repository *repo, char *buf, int nul_term_line, i | |||
| 125 | 125 | oi.typep = &obj_type; | |
| 126 | 126 | if (odb_read_object_info_extended(repo->objects, &oid, &oi, | |
| 127 | 127 | OBJECT_INFO_LOOKUP_REPLACE | | |
| 128 | - | OBJECT_INFO_QUICK | | |
| 129 | 128 | OBJECT_INFO_SKIP_FETCH_OBJECT) < 0) | |
| 130 | 129 | obj_type = -1; | |
| 131 | 130 | ||
| @@ -200,8 +199,11 @@ int cmd_mktree(int ac, | |||
| 200 | 199 | puts(oid_to_hex(&oid)); | |
| 201 | 200 | fflush(stdout); | |
| 202 | 201 | } | |
| 202 | + | for (int i = 0; i < used; i++) | |
| 203 | + | free(entries[i]); | |
| 203 | 204 | used=0; /* reset tree entry buffer for re-use in batch mode */ | |
| 204 | 205 | } | |
| 206 | + | free(entries); | |
| 205 | 207 | strbuf_release(&sb); | |
| 206 | 208 | ||
| 207 | 209 | return 0; | |
modified builtin/multi-pack-index.c
| @@ -10,17 +10,20 @@ | |||
| 10 | 10 | #include "trace2.h" | |
| 11 | 11 | #include "odb.h" | |
| 12 | 12 | #include "odb/source.h" | |
| 13 | + | #include "odb/source-files.h" | |
| 13 | 14 | #include "replace-object.h" | |
| 14 | 15 | #include "repository.h" | |
| 15 | 16 | ||
| 16 | 17 | #define BUILTIN_MIDX_WRITE_USAGE \ | |
| 17 | 18 | N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]\n" \ | |
| 18 | 19 | " [--[no-]bitmap] [--[no-]incremental] [--[no-]stdin-packs]\n" \ | |
| 19 | - | " [--refs-snapshot=<path>]") | |
| 20 | + | " [--refs-snapshot=<path>] [--[no-]write-chain-file]\n" \ | |
| 21 | + | " [--base=<checksum>]") | |
| 20 | 22 | ||
| 21 | 23 | #define BUILTIN_MIDX_COMPACT_USAGE \ | |
| 22 | 24 | N_("git multi-pack-index [<options>] compact [--[no-]incremental]\n" \ | |
| 23 | - | " [--[no-]bitmap] <from> <to>") | |
| 25 | + | " [--[no-]bitmap] [--base=<checksum>] [--[no-]write-chain-file]\n" \ | |
| 26 | + | " <from> <to>") | |
| 24 | 27 | ||
| 25 | 28 | #define BUILTIN_MIDX_VERIFY_USAGE \ | |
| 26 | 29 | N_("git multi-pack-index [<options>] verify") | |
| @@ -63,6 +66,7 @@ static char const * const builtin_multi_pack_index_usage[] = { | |||
| 63 | 66 | static struct opts_multi_pack_index { | |
| 64 | 67 | char *object_dir; | |
| 65 | 68 | const char *preferred_pack; | |
| 69 | + | const char *incremental_base; | |
| 66 | 70 | char *refs_snapshot; | |
| 67 | 71 | unsigned long batch_size; | |
| 68 | 72 | unsigned flags; | |
| @@ -82,12 +86,13 @@ static int parse_object_dir(const struct option *opt, const char *arg, | |||
| 82 | 86 | return 0; | |
| 83 | 87 | } | |
| 84 | 88 | ||
| 85 | - | static struct odb_source *handle_object_dir_option(struct repository *repo) | |
| 89 | + | static struct odb_source_files *handle_object_dir_option(struct repository *repo) | |
| 86 | 90 | { | |
| 87 | 91 | struct odb_source *source = odb_find_source(repo->objects, opts.object_dir); | |
| 88 | 92 | if (!source) | |
| 89 | - | source = odb_add_to_alternates_memory(repo->objects, opts.object_dir); | |
| 90 | - | return source; | |
| 93 | + | die(_("object directory is not an alternate of the current repository: '%s'"), | |
| 94 | + | opts.object_dir); | |
| 95 | + | return odb_source_files_downcast(source); | |
| 91 | 96 | } | |
| 92 | 97 | ||
| 93 | 98 | static struct option common_opts[] = { | |
| @@ -151,15 +156,20 @@ static int cmd_multi_pack_index_write(int argc, const char **argv, | |||
| 151 | 156 | N_("pack for reuse when computing a multi-pack bitmap")), | |
| 152 | 157 | OPT_BIT(0, "bitmap", &opts.flags, N_("write multi-pack bitmap"), | |
| 153 | 158 | MIDX_WRITE_BITMAP | MIDX_WRITE_REV_INDEX), | |
| 159 | + | OPT_STRING(0, "base", &opts.incremental_base, N_("checksum"), | |
| 160 | + | N_("base MIDX for incremental writes")), | |
| 154 | 161 | OPT_BIT(0, "incremental", &opts.flags, | |
| 155 | 162 | N_("write a new incremental MIDX"), MIDX_WRITE_INCREMENTAL), | |
| 163 | + | OPT_NEGBIT(0, "write-chain-file", &opts.flags, | |
| 164 | + | N_("write the multi-pack-index chain file"), | |
| 165 | + | MIDX_WRITE_NO_CHAIN), | |
| 156 | 166 | OPT_BOOL(0, "stdin-packs", &opts.stdin_packs, | |
| 157 | 167 | N_("write multi-pack index containing only given indexes")), | |
| 158 | 168 | OPT_FILENAME(0, "refs-snapshot", &opts.refs_snapshot, | |
| 159 | 169 | N_("refs snapshot for selecting bitmap commits")), | |
| 160 | 170 | OPT_END(), | |
| 161 | 171 | }; | |
| 162 | - | struct odb_source *source; | |
| 172 | + | struct odb_source_files *source; | |
| 163 | 173 | int ret; | |
| 164 | 174 | ||
| 165 | 175 | opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE; | |
| @@ -178,6 +188,22 @@ static int cmd_multi_pack_index_write(int argc, const char **argv, | |||
| 178 | 188 | if (argc) | |
| 179 | 189 | usage_with_options(builtin_multi_pack_index_write_usage, | |
| 180 | 190 | options); | |
| 191 | + | ||
| 192 | + | if (opts.flags & MIDX_WRITE_NO_CHAIN && | |
| 193 | + | !(opts.flags & MIDX_WRITE_INCREMENTAL)) { | |
| 194 | + | error(_("cannot use %s without %s"), | |
| 195 | + | "--no-write-chain-file", "--incremental"); | |
| 196 | + | usage_with_options(builtin_multi_pack_index_write_usage, | |
| 197 | + | options); | |
| 198 | + | } | |
| 199 | + | ||
| 200 | + | if (opts.incremental_base && | |
| 201 | + | !(opts.flags & MIDX_WRITE_NO_CHAIN)) { | |
| 202 | + | error(_("cannot use --base without --no-write-chain-file")); | |
| 203 | + | usage_with_options(builtin_multi_pack_index_write_usage, | |
| 204 | + | options); | |
| 205 | + | } | |
| 206 | + | ||
| 181 | 207 | source = handle_object_dir_option(repo); | |
| 182 | 208 | ||
| 183 | 209 | FREE_AND_NULL(options); | |
| @@ -187,9 +213,10 @@ static int cmd_multi_pack_index_write(int argc, const char **argv, | |||
| 187 | 213 | ||
| 188 | 214 | read_packs_from_stdin(&packs); | |
| 189 | 215 | ||
| 190 | - | ret = write_midx_file_only(source, &packs, | |
| 216 | + | ret = write_midx_file_only(source->packed, &packs, | |
| 191 | 217 | opts.preferred_pack, | |
| 192 | - | opts.refs_snapshot, opts.flags); | |
| 218 | + | opts.refs_snapshot, | |
| 219 | + | opts.incremental_base, opts.flags); | |
| 193 | 220 | ||
| 194 | 221 | string_list_clear(&packs, 0); | |
| 195 | 222 | free(opts.refs_snapshot); | |
| @@ -198,7 +225,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv, | |||
| 198 | 225 | ||
| 199 | 226 | } | |
| 200 | 227 | ||
| 201 | - | ret = write_midx_file(source, opts.preferred_pack, | |
| 228 | + | ret = write_midx_file(source->packed, opts.preferred_pack, | |
| 202 | 229 | opts.refs_snapshot, opts.flags); | |
| 203 | 230 | ||
| 204 | 231 | free(opts.refs_snapshot); | |
| @@ -212,15 +239,20 @@ static int cmd_multi_pack_index_compact(int argc, const char **argv, | |||
| 212 | 239 | struct multi_pack_index *m, *cur; | |
| 213 | 240 | struct multi_pack_index *from_midx = NULL; | |
| 214 | 241 | struct multi_pack_index *to_midx = NULL; | |
| 215 | - | struct odb_source *source; | |
| 242 | + | struct odb_source_files *source; | |
| 216 | 243 | int ret; | |
| 217 | 244 | ||
| 218 | 245 | struct option *options; | |
| 219 | 246 | static struct option builtin_multi_pack_index_compact_options[] = { | |
| 247 | + | OPT_STRING(0, "base", &opts.incremental_base, N_("checksum"), | |
| 248 | + | N_("base MIDX for incremental writes")), | |
| 220 | 249 | OPT_BIT(0, "bitmap", &opts.flags, N_("write multi-pack bitmap"), | |
| 221 | 250 | MIDX_WRITE_BITMAP | MIDX_WRITE_REV_INDEX), | |
| 222 | 251 | OPT_BIT(0, "incremental", &opts.flags, | |
| 223 | 252 | N_("write a new incremental MIDX"), MIDX_WRITE_INCREMENTAL), | |
| 253 | + | OPT_NEGBIT(0, "write-chain-file", &opts.flags, | |
| 254 | + | N_("write the multi-pack-index chain file"), | |
| 255 | + | MIDX_WRITE_NO_CHAIN), | |
| 224 | 256 | OPT_END(), | |
| 225 | 257 | }; | |
| 226 | 258 | ||
| @@ -239,11 +271,20 @@ static int cmd_multi_pack_index_compact(int argc, const char **argv, | |||
| 239 | 271 | if (argc != 2) | |
| 240 | 272 | usage_with_options(builtin_multi_pack_index_compact_usage, | |
| 241 | 273 | options); | |
| 274 | + | ||
| 275 | + | if (opts.flags & MIDX_WRITE_NO_CHAIN && | |
| 276 | + | !(opts.flags & MIDX_WRITE_INCREMENTAL)) { | |
| 277 | + | error(_("cannot use %s without %s"), | |
| 278 | + | "--no-write-chain-file", "--incremental"); | |
| 279 | + | usage_with_options(builtin_multi_pack_index_compact_usage, | |
| 280 | + | options); | |
| 281 | + | } | |
| 282 | + | ||
| 242 | 283 | source = handle_object_dir_option(the_repository); | |
| 243 | 284 | ||
| 244 | 285 | FREE_AND_NULL(options); | |
| 245 | 286 | ||
| 246 | - | m = get_multi_pack_index(source); | |
| 287 | + | m = get_multi_pack_index(source->packed); | |
| 247 | 288 | ||
| 248 | 289 | for (cur = m; cur && !(from_midx && to_midx); cur = cur->base_midx) { | |
| 249 | 290 | const char *midx_csum = midx_get_checksum_hex(cur); | |
| @@ -266,7 +307,8 @@ static int cmd_multi_pack_index_compact(int argc, const char **argv, | |||
| 266 | 307 | die(_("MIDX %s must be an ancestor of %s"), argv[0], argv[1]); | |
| 267 | 308 | } | |
| 268 | 309 | ||
| 269 | - | ret = write_midx_file_compact(source, from_midx, to_midx, opts.flags); | |
| 310 | + | ret = write_midx_file_compact(source->packed, from_midx, to_midx, | |
| 311 | + | opts.incremental_base, opts.flags); | |
| 270 | 312 | ||
| 271 | 313 | return ret; | |
| 272 | 314 | } | |
| @@ -279,7 +321,7 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv, | |||
| 279 | 321 | static struct option builtin_multi_pack_index_verify_options[] = { | |
| 280 | 322 | OPT_END(), | |
| 281 | 323 | }; | |
| 282 | - | struct odb_source *source; | |
| 324 | + | struct odb_source_files *source; | |
| 283 | 325 | ||
| 284 | 326 | options = add_common_options(builtin_multi_pack_index_verify_options); | |
| 285 | 327 | ||
| @@ -297,7 +339,7 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv, | |||
| 297 | 339 | ||
| 298 | 340 | FREE_AND_NULL(options); | |
| 299 | 341 | ||
| 300 | - | return verify_midx_file(source, opts.flags); | |
| 342 | + | return verify_midx_file(source->packed, opts.flags); | |
| 301 | 343 | } | |
| 302 | 344 | ||
| 303 | 345 | static int cmd_multi_pack_index_expire(int argc, const char **argv, | |
| @@ -308,7 +350,7 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv, | |||
| 308 | 350 | static struct option builtin_multi_pack_index_expire_options[] = { | |
| 309 | 351 | OPT_END(), | |
| 310 | 352 | }; | |
| 311 | - | struct odb_source *source; | |
| 353 | + | struct odb_source_files *source; | |
| 312 | 354 | ||
| 313 | 355 | options = add_common_options(builtin_multi_pack_index_expire_options); | |
| 314 | 356 | ||
| @@ -326,7 +368,7 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv, | |||
| 326 | 368 | ||
| 327 | 369 | FREE_AND_NULL(options); | |
| 328 | 370 | ||
| 329 | - | return expire_midx_packs(source, opts.flags); | |
| 371 | + | return expire_midx_packs(source->packed, opts.flags); | |
| 330 | 372 | } | |
| 331 | 373 | ||
| 332 | 374 | static int cmd_multi_pack_index_repack(int argc, const char **argv, | |
| @@ -339,7 +381,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv, | |||
| 339 | 381 | N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")), | |
| 340 | 382 | OPT_END(), | |
| 341 | 383 | }; | |
| 342 | - | struct odb_source *source; | |
| 384 | + | struct odb_source_files *source; | |
| 343 | 385 | ||
| 344 | 386 | options = add_common_options(builtin_multi_pack_index_repack_options); | |
| 345 | 387 | ||
| @@ -358,7 +400,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv, | |||
| 358 | 400 | ||
| 359 | 401 | FREE_AND_NULL(options); | |
| 360 | 402 | ||
| 361 | - | return midx_repack(source, (size_t)opts.batch_size, opts.flags); | |
| 403 | + | return midx_repack(source->packed, (size_t)opts.batch_size, opts.flags); | |
| 362 | 404 | } | |
| 363 | 405 | ||
| 364 | 406 | int cmd_multi_pack_index(int argc, | |
modified builtin/mv.c
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | #include "string-list.h" | |
| 23 | 23 | #include "parse-options.h" | |
| 24 | 24 | #include "read-cache-ll.h" | |
| 25 | + | #include "symlinks.h" | |
| 25 | 26 | ||
| 26 | 27 | #include "setup.h" | |
| 27 | 28 | #include "strvec.h" | |
| @@ -48,6 +49,12 @@ enum update_mode { | |||
| 48 | 49 | MOVE_VIA_PARENT_DIR = (1 << 5), | |
| 49 | 50 | }; | |
| 50 | 51 | ||
| 52 | + | static int needs_worktree_rename(enum update_mode mode, enum update_mode dst_mode) | |
| 53 | + | { | |
| 54 | + | return !(mode & (INDEX | SPARSE | SKIP_WORKTREE_DIR)) && | |
| 55 | + | !(dst_mode & (SKIP_WORKTREE_DIR | SPARSE)); | |
| 56 | + | } | |
| 57 | + | ||
| 51 | 58 | #define DUP_BASENAME 1 | |
| 52 | 59 | #define KEEP_TRAILING_SLASH 2 | |
| 53 | 60 | ||
| @@ -71,7 +78,7 @@ static void internal_prefix_pathspec(struct strvec *out, | |||
| 71 | 78 | ||
| 72 | 79 | trimmed = xmemdupz(pathspec[i], to_copy); | |
| 73 | 80 | maybe_basename = (flags & DUP_BASENAME) ? basename(trimmed) : trimmed; | |
| 74 | - | prefixed_path = prefix_path(prefix, prefixlen, maybe_basename); | |
| 81 | + | prefixed_path = prefix_path(the_repository, prefix, prefixlen, maybe_basename); | |
| 75 | 82 | strvec_push(out, prefixed_path); | |
| 76 | 83 | ||
| 77 | 84 | free(prefixed_path); | |
| @@ -394,7 +401,8 @@ dir_check: | |||
| 394 | 401 | for (j = 0; j < last - first; j++) { | |
| 395 | 402 | const struct cache_entry *ce = the_repository->index->cache[first + j]; | |
| 396 | 403 | const char *path = ce->name; | |
| 397 | - | char *prefixed_path = prefix_path(dst_with_slash, dst_with_slash_len, path + length + 1); | |
| 404 | + | char *prefixed_path = prefix_path(the_repository, dst_with_slash, | |
| 405 | + | dst_with_slash_len, path + length + 1); | |
| 398 | 406 | ||
| 399 | 407 | strvec_push(&sources, path); | |
| 400 | 408 | strvec_push(&destinations, prefixed_path); | |
| @@ -418,7 +426,7 @@ dir_check: | |||
| 418 | 426 | goto act_on_entry; | |
| 419 | 427 | } | |
| 420 | 428 | if (lstat(dst, &st) == 0 && | |
| 421 | - | (!ignore_case || strcasecmp(src, dst))) { | |
| 429 | + | (!repo_ignore_case(the_repository) || strcasecmp(src, dst))) { | |
| 422 | 430 | bad = _("destination exists"); | |
| 423 | 431 | if (force) { | |
| 424 | 432 | /* | |
| @@ -442,6 +450,41 @@ dir_check: | |||
| 442 | 450 | bad = _("destination directory does not exist"); | |
| 443 | 451 | goto act_on_entry; | |
| 444 | 452 | } | |
| 453 | + | if (has_symlink_leading_path(dst, strlen(dst))) { | |
| 454 | + | bad = _("destination is beyond a symbolic link"); | |
| 455 | + | goto act_on_entry; | |
| 456 | + | } | |
| 457 | + | ||
| 458 | + | /* | |
| 459 | + | * If we are going to move SRC to DST on disk, DST's leading | |
| 460 | + | * directories must already exist. | |
| 461 | + | */ | |
| 462 | + | if (needs_worktree_rename(modes[i], dst_mode)) { | |
| 463 | + | const char *slash_ = strrchr(dst, '/'); | |
| 464 | + | ||
| 465 | + | if (slash_) { | |
| 466 | + | struct stat dir_st; | |
| 467 | + | char *dst_dir = xstrdup(dst); | |
| 468 | + | char *slash = &dst_dir[slash_ - dst]; | |
| 469 | + | ||
| 470 | + | *slash = '\0'; | |
| 471 | + | if (lstat(dst_dir, &dir_st) < 0) { | |
| 472 | + | /* | |
| 473 | + | * other errors fall through to rename(), | |
| 474 | + | * which reports them | |
| 475 | + | */ | |
| 476 | + | if (errno == ENOENT || errno == ENOTDIR) | |
| 477 | + | bad = _("destination directory does not exist"); | |
| 478 | + | } else if (!S_ISDIR(dir_st.st_mode)) { | |
| 479 | + | bad = _("destination is not a directory"); | |
| 480 | + | } | |
| 481 | + | ||
| 482 | + | free(dst_dir); | |
| 483 | + | } | |
| 484 | + | ||
| 485 | + | if (bad) | |
| 486 | + | goto act_on_entry; | |
| 487 | + | } | |
| 445 | 488 | ||
| 446 | 489 | if (ignore_sparse && | |
| 447 | 490 | (dst_mode & (SKIP_WORKTREE_DIR | SPARSE)) && | |
| @@ -543,12 +586,11 @@ remove_entry: | |||
| 543 | 586 | printf(_("Renaming %s to %s\n"), src, dst); | |
| 544 | 587 | if (show_only) | |
| 545 | 588 | continue; | |
| 546 | - | if (!(mode & (INDEX | SPARSE | SKIP_WORKTREE_DIR)) && | |
| 547 | - | !(dst_mode & (SKIP_WORKTREE_DIR | SPARSE)) && | |
| 589 | + | if (needs_worktree_rename(mode, dst_mode) && | |
| 548 | 590 | rename(src, dst) < 0) { | |
| 549 | 591 | if (ignore_errors) | |
| 550 | 592 | continue; | |
| 551 | - | die_errno(_("renaming '%s' failed"), src); | |
| 593 | + | die_errno(_("renaming '%s' to '%s' failed"), src, dst); | |
| 552 | 594 | } | |
| 553 | 595 | if (submodule_gitfiles[i]) { | |
| 554 | 596 | if (!update_path_in_gitmodules(src, dst)) | |
| @@ -574,7 +616,7 @@ remove_entry: | |||
| 574 | 616 | ||
| 575 | 617 | if (ignore_sparse && | |
| 576 | 618 | cfg->apply_sparse_checkout && | |
| 577 | - | core_sparse_checkout_cone) { | |
| 619 | + | cfg->core_sparse_checkout_cone) { | |
| 578 | 620 | /* | |
| 579 | 621 | * NEEDSWORK: we are *not* paying attention to | |
| 580 | 622 | * "out-to-out" move (<source> is out-of-cone and | |
modified builtin/name-rev.c
| @@ -17,6 +17,10 @@ | |||
| 17 | 17 | #include "commit-graph.h" | |
| 18 | 18 | #include "wildmatch.h" | |
| 19 | 19 | #include "mem-pool.h" | |
| 20 | + | #include "pretty.h" | |
| 21 | + | #include "revision.h" | |
| 22 | + | #include "notes.h" | |
| 23 | + | #include "write-or-die.h" | |
| 20 | 24 | ||
| 21 | 25 | /* | |
| 22 | 26 | * One day. See the 'name a rev shortly after epoch' test in t6120 when | |
| @@ -270,6 +274,43 @@ struct name_ref_data { | |||
| 270 | 274 | struct string_list exclude_filters; | |
| 271 | 275 | }; | |
| 272 | 276 | ||
| 277 | + | struct pretty_format { | |
| 278 | + | struct pretty_print_context ctx; | |
| 279 | + | struct userformat_want want; | |
| 280 | + | }; | |
| 281 | + | ||
| 282 | + | enum command_type { | |
| 283 | + | NAME_REV = 1, | |
| 284 | + | FORMAT_REV = 2, | |
| 285 | + | }; | |
| 286 | + | ||
| 287 | + | enum stdin_mode { | |
| 288 | + | TEXT = 1, | |
| 289 | + | REVS = 2, | |
| 290 | + | }; | |
| 291 | + | ||
| 292 | + | struct command { | |
| 293 | + | enum command_type type; | |
| 294 | + | union { | |
| 295 | + | int name_only; | |
| 296 | + | struct pretty_format *pretty_format; | |
| 297 | + | } u; | |
| 298 | + | }; | |
| 299 | + | ||
| 300 | + | static void init_name_rev_command(struct command *cmd, | |
| 301 | + | int name_only) | |
| 302 | + | { | |
| 303 | + | cmd->type = NAME_REV; | |
| 304 | + | cmd->u.name_only = name_only; | |
| 305 | + | } | |
| 306 | + | ||
| 307 | + | static void init_format_rev_command(struct command *cmd, | |
| 308 | + | struct pretty_format *pretty_format) | |
| 309 | + | { | |
| 310 | + | cmd->type = FORMAT_REV; | |
| 311 | + | cmd->u.pretty_format = pretty_format; | |
| 312 | + | } | |
| 313 | + | ||
| 273 | 314 | static struct tip_table { | |
| 274 | 315 | struct tip_table_entry { | |
| 275 | 316 | struct object_id oid; | |
| @@ -464,9 +505,9 @@ static const char *get_rev_name(const struct object *o, struct strbuf *buf) | |||
| 464 | 505 | if (!n) | |
| 465 | 506 | return NULL; | |
| 466 | 507 | ||
| 467 | - | if (!n->generation) | |
| 508 | + | if (!n->generation) { | |
| 468 | 509 | return n->tip_name; | |
| 469 | - | else { | |
| 510 | + | } else { | |
| 470 | 511 | strbuf_reset(buf); | |
| 471 | 512 | strbuf_addstr(buf, n->tip_name); | |
| 472 | 513 | strbuf_strip_suffix(buf, "^0"); | |
| @@ -475,6 +516,27 @@ static const char *get_rev_name(const struct object *o, struct strbuf *buf) | |||
| 475 | 516 | } | |
| 476 | 517 | } | |
| 477 | 518 | ||
| 519 | + | static const char *get_format_rev(const struct commit *c, | |
| 520 | + | struct pretty_format *format_ctx, | |
| 521 | + | struct strbuf *buf) | |
| 522 | + | { | |
| 523 | + | strbuf_reset(buf); | |
| 524 | + | ||
| 525 | + | if (format_ctx->want.notes) { | |
| 526 | + | struct strbuf notebuf = STRBUF_INIT; | |
| 527 | + | ||
| 528 | + | format_display_notes(&c->object.oid, ¬ebuf, | |
| 529 | + | get_log_output_encoding(), | |
| 530 | + | format_ctx->ctx.fmt == CMIT_FMT_USERFORMAT); | |
| 531 | + | format_ctx->ctx.notes_message = strbuf_detach(¬ebuf, NULL); | |
| 532 | + | } | |
| 533 | + | ||
| 534 | + | pretty_print_commit(&format_ctx->ctx, c, buf); | |
| 535 | + | FREE_AND_NULL(format_ctx->ctx.notes_message); | |
| 536 | + | ||
| 537 | + | return buf->buf; | |
| 538 | + | } | |
| 539 | + | ||
| 478 | 540 | static void show_name(const struct object *obj, | |
| 479 | 541 | const char *caller_name, | |
| 480 | 542 | int always, int allow_undefined, int name_only) | |
| @@ -505,7 +567,7 @@ static char const * const name_rev_usage[] = { | |||
| 505 | 567 | NULL | |
| 506 | 568 | }; | |
| 507 | 569 | ||
| 508 | - | static void name_rev_line(char *p, struct name_ref_data *data) | |
| 570 | + | static void name_rev_line(char *p, struct command *cmd) | |
| 509 | 571 | { | |
| 510 | 572 | struct strbuf buf = STRBUF_INIT; | |
| 511 | 573 | int counter = 0; | |
| @@ -514,33 +576,52 @@ static void name_rev_line(char *p, struct name_ref_data *data) | |||
| 514 | 576 | ||
| 515 | 577 | for (p_start = p; *p; p++) { | |
| 516 | 578 | #define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f')) | |
| 517 | - | if (!ishex(*p)) | |
| 579 | + | if (!ishex(*p)) { | |
| 518 | 580 | counter = 0; | |
| 519 | - | else if (++counter == hexsz && | |
| 520 | - | !ishex(*(p+1))) { | |
| 581 | + | } else if (++counter == hexsz && | |
| 582 | + | !ishex(*(p + 1))) { | |
| 521 | 583 | struct object_id oid; | |
| 522 | 584 | const char *name = NULL; | |
| 523 | - | char c = *(p+1); | |
| 585 | + | char c = *(p + 1); | |
| 524 | 586 | int p_len = p - p_start + 1; | |
| 587 | + | struct object *o = NULL; | |
| 588 | + | int oid_ret = 1; | |
| 525 | 589 | ||
| 526 | 590 | counter = 0; | |
| 527 | 591 | ||
| 528 | - | *(p+1) = 0; | |
| 529 | - | if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) { | |
| 530 | - | struct object *o = | |
| 531 | - | lookup_object(the_repository, &oid); | |
| 592 | + | *(p + 1) = 0; | |
| 593 | + | oid_ret = repo_get_oid(the_repository, p - (hexsz - 1), &oid); | |
| 594 | + | *(p + 1) = c; | |
| 595 | + | ||
| 596 | + | switch (cmd->type) { | |
| 597 | + | case NAME_REV: | |
| 598 | + | if (!oid_ret) | |
| 599 | + | o = lookup_object(the_repository, &oid); | |
| 532 | 600 | if (o) | |
| 533 | 601 | name = get_rev_name(o, &buf); | |
| 602 | + | if (!name) | |
| 603 | + | continue; | |
| 604 | + | if (cmd->u.name_only) | |
| 605 | + | printf("%.*s%s", p_len - hexsz, p_start, name); | |
| 606 | + | else | |
| 607 | + | printf("%.*s (%s)", p_len, p_start, name); | |
| 608 | + | break; | |
| 609 | + | case FORMAT_REV: | |
| 610 | + | if (!oid_ret) | |
| 611 | + | o = parse_object(the_repository, &oid); | |
| 612 | + | if (o && o->type == OBJ_COMMIT) | |
| 613 | + | name = get_format_rev((const struct commit *)o, | |
| 614 | + | cmd->u.pretty_format, | |
| 615 | + | &buf); | |
| 616 | + | if (name) | |
| 617 | + | printf("%.*s%s", p_len - hexsz, p_start, name); | |
| 618 | + | else | |
| 619 | + | printf("%.*s", p_len, p_start); | |
| 620 | + | break; | |
| 621 | + | default: | |
| 622 | + | BUG("uncovered case: %d", cmd->type); | |
| 534 | 623 | } | |
| 535 | - | *(p+1) = c; | |
| 536 | 624 | ||
| 537 | - | if (!name) | |
| 538 | - | continue; | |
| 539 | - | ||
| 540 | - | if (data->name_only) | |
| 541 | - | printf("%.*s%s", p_len - hexsz, p_start, name); | |
| 542 | - | else | |
| 543 | - | printf("%.*s (%s)", p_len, p_start, name); | |
| 544 | 625 | p_start = p + 1; | |
| 545 | 626 | } | |
| 546 | 627 | } | |
| @@ -565,13 +646,14 @@ int cmd_name_rev(int argc, | |||
| 565 | 646 | #endif | |
| 566 | 647 | int all = 0, annotate_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; | |
| 567 | 648 | struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; | |
| 649 | + | struct command cmd; | |
| 568 | 650 | struct option opts[] = { | |
| 569 | 651 | OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), | |
| 570 | 652 | OPT_BOOL(0, "tags", &data.tags_only, N_("only use tags to name the commits")), | |
| 571 | 653 | OPT_STRING_LIST(0, "refs", &data.ref_filters, N_("pattern"), | |
| 572 | - | N_("only use refs matching <pattern>")), | |
| 654 | + | N_("only use refs matching <pattern>")), | |
| 573 | 655 | OPT_STRING_LIST(0, "exclude", &data.exclude_filters, N_("pattern"), | |
| 574 | - | N_("ignore refs matching <pattern>")), | |
| 656 | + | N_("ignore refs matching <pattern>")), | |
| 575 | 657 | OPT_GROUP(""), | |
| 576 | 658 | OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), | |
| 577 | 659 | #ifndef WITH_BREAKING_CHANGES | |
| @@ -583,10 +665,10 @@ int cmd_name_rev(int argc, | |||
| 583 | 665 | #endif /* WITH_BREAKING_CHANGES */ | |
| 584 | 666 | OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), | |
| 585 | 667 | OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), | |
| 586 | - | OPT_BOOL(0, "always", &always, | |
| 587 | - | N_("show abbreviated commit object as fallback")), | |
| 668 | + | OPT_BOOL(0, "always", &always, | |
| 669 | + | N_("show abbreviated commit object as fallback")), | |
| 588 | 670 | OPT_HIDDEN_BOOL(0, "peel-tag", &peel_tag, | |
| 589 | - | N_("dereference tags in the input (internal use)")), | |
| 671 | + | N_("dereference tags in the input (internal use)")), | |
| 590 | 672 | OPT_END(), | |
| 591 | 673 | }; | |
| 592 | 674 | ||
| @@ -594,6 +676,7 @@ int cmd_name_rev(int argc, | |||
| 594 | 676 | init_commit_rev_name(&rev_names); | |
| 595 | 677 | repo_config(the_repository, git_default_config, NULL); | |
| 596 | 678 | argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); | |
| 679 | + | init_name_rev_command(&cmd, data.name_only); | |
| 597 | 680 | ||
| 598 | 681 | #ifndef WITH_BREAKING_CHANGES | |
| 599 | 682 | if (transform_stdin) { | |
| @@ -661,7 +744,7 @@ int cmd_name_rev(int argc, | |||
| 661 | 744 | ||
| 662 | 745 | while (strbuf_getline(&sb, stdin) != EOF) { | |
| 663 | 746 | strbuf_addch(&sb, '\n'); | |
| 664 | - | name_rev_line(sb.buf, &data); | |
| 747 | + | name_rev_line(sb.buf, &cmd); | |
| 665 | 748 | } | |
| 666 | 749 | strbuf_release(&sb); | |
| 667 | 750 | } else if (all) { | |
| @@ -688,3 +771,170 @@ int cmd_name_rev(int argc, | |||
| 688 | 771 | object_array_clear(&revs); | |
| 689 | 772 | return 0; | |
| 690 | 773 | } | |
| 774 | + | ||
| 775 | + | struct format_nul_data { | |
| 776 | + | bool nul_input; | |
| 777 | + | bool nul_output; | |
| 778 | + | }; | |
| 779 | + | ||
| 780 | + | static int format_nul_cb(const struct option *option, | |
| 781 | + | const char *arg, | |
| 782 | + | int unset) | |
| 783 | + | { | |
| 784 | + | struct format_nul_data *data = option->value; | |
| 785 | + | data->nul_input = 1; | |
| 786 | + | data->nul_output = 1; | |
| 787 | + | BUG_ON_OPT_NEG(unset); | |
| 788 | + | BUG_ON_OPT_ARG(arg); | |
| 789 | + | return 0; | |
| 790 | + | } | |
| 791 | + | ||
| 792 | + | static enum stdin_mode parse_stdin_mode(const char *stdin_mode) | |
| 793 | + | { | |
| 794 | + | if (!strcmp(stdin_mode, "text")) | |
| 795 | + | return TEXT; | |
| 796 | + | else if (!strcmp(stdin_mode, "revs") || | |
| 797 | + | !strcmp(stdin_mode, "rev")) | |
| 798 | + | return REVS; | |
| 799 | + | else | |
| 800 | + | die(_("'%s' needs to be either text, revs, or rev"), | |
| 801 | + | "--stdin-mode"); | |
| 802 | + | } | |
| 803 | + | ||
| 804 | + | static char const *const format_rev_usage[] = { | |
| 805 | + | N_("(EXPERIMENTAL!) git format-rev --stdin-mode=<mode> " | |
| 806 | + | "--format=<pretty> [--[no-]notes=<ref>] " | |
| 807 | + | "[-z] [--[no-]null-output] [--[no-]null-input]"), | |
| 808 | + | NULL | |
| 809 | + | }; | |
| 810 | + | ||
| 811 | + | int cmd_format_rev(int argc, | |
| 812 | + | const char **argv, | |
| 813 | + | const char *prefix, | |
| 814 | + | struct repository *repo UNUSED) | |
| 815 | + | { | |
| 816 | + | const char *format = NULL; | |
| 817 | + | enum stdin_mode stdin_mode; | |
| 818 | + | const char *stdin_mode_arg = NULL; | |
| 819 | + | struct format_nul_data nul_data = { 0, 0 }; | |
| 820 | + | char output_terminator; | |
| 821 | + | strbuf_getline_fn getline_fn; | |
| 822 | + | struct display_notes_opt format_notes_opt; | |
| 823 | + | struct rev_info format_rev = REV_INFO_INIT; | |
| 824 | + | struct pretty_format format_pp = { 0 }; | |
| 825 | + | struct string_list notes = STRING_LIST_INIT_NODUP; | |
| 826 | + | struct strbuf scratch_buf = STRBUF_INIT; | |
| 827 | + | struct command cmd; | |
| 828 | + | struct option opts[] = { | |
| 829 | + | OPT_STRING(0, "format", &format, N_("format"), | |
| 830 | + | N_("pretty format to use")), | |
| 831 | + | OPT_STRING(0, "stdin-mode", &stdin_mode_arg, N_("stdin-mode"), | |
| 832 | + | N_("how revs are processed")), | |
| 833 | + | OPT_STRING_LIST(0, "notes", ¬es, N_("notes"), | |
| 834 | + | N_("display notes for pretty format")), | |
| 835 | + | OPT_CALLBACK_F('z', "null", &nul_data, N_("z"), | |
| 836 | + | N_("Use NUL for input and output termination"), | |
| 837 | + | PARSE_OPT_NOARG | PARSE_OPT_NONEG, format_nul_cb), | |
| 838 | + | OPT_BOOL(0, "null-input", &nul_data.nul_input, | |
| 839 | + | N_("Use NUL for input termination")), | |
| 840 | + | OPT_BOOL(0, "null-output", &nul_data.nul_output, | |
| 841 | + | N_("Use NUL for output termination")), | |
| 842 | + | OPT_END(), | |
| 843 | + | }; | |
| 844 | + | ||
| 845 | + | argc = parse_options(argc, argv, prefix, opts, format_rev_usage, 0); | |
| 846 | + | ||
| 847 | + | if (argc > 0) { | |
| 848 | + | error(_("too many arguments")); | |
| 849 | + | usage_with_options(format_rev_usage, opts); | |
| 850 | + | } | |
| 851 | + | ||
| 852 | + | if (!format) | |
| 853 | + | die(_("'%s' is required"), "--format"); | |
| 854 | + | if (!stdin_mode_arg) | |
| 855 | + | die(_("'%s' is required"), "--stdin-mode"); | |
| 856 | + | ||
| 857 | + | getline_fn = nul_data.nul_input ? strbuf_getline_nul : strbuf_getline_lf; | |
| 858 | + | output_terminator = nul_data.nul_output ? '\0' : '\n'; | |
| 859 | + | ||
| 860 | + | init_display_notes(&format_notes_opt); | |
| 861 | + | stdin_mode = parse_stdin_mode(stdin_mode_arg); | |
| 862 | + | ||
| 863 | + | get_commit_format(format, &format_rev); | |
| 864 | + | format_pp.ctx.rev = &format_rev; | |
| 865 | + | format_pp.ctx.fmt = format_rev.commit_format; | |
| 866 | + | format_pp.ctx.abbrev = format_rev.abbrev; | |
| 867 | + | format_pp.ctx.date_mode_explicit = format_rev.date_mode_explicit; | |
| 868 | + | format_pp.ctx.date_mode = format_rev.date_mode; | |
| 869 | + | format_pp.ctx.color = GIT_COLOR_AUTO; | |
| 870 | + | ||
| 871 | + | userformat_find_requirements(format, | |
| 872 | + | &format_pp.want); | |
| 873 | + | if (format_pp.want.notes) { | |
| 874 | + | int ignore_show_notes = 0; | |
| 875 | + | struct string_list_item *n; | |
| 876 | + | ||
| 877 | + | for_each_string_list_item(n, ¬es) | |
| 878 | + | enable_ref_display_notes(&format_notes_opt, | |
| 879 | + | &ignore_show_notes, | |
| 880 | + | n->string); | |
| 881 | + | load_display_notes(&format_notes_opt); | |
| 882 | + | } | |
| 883 | + | ||
| 884 | + | init_format_rev_command(&cmd, &format_pp); | |
| 885 | + | ||
| 886 | + | switch (stdin_mode) { | |
| 887 | + | case TEXT: | |
| 888 | + | while (getline_fn(&scratch_buf, stdin) != EOF) { | |
| 889 | + | name_rev_line(scratch_buf.buf, &cmd); | |
| 890 | + | /* | |
| 891 | + | * We do not pass on the terminator to name_rev_line, | |
| 892 | + | * unlike name-rev. | |
| 893 | + | */ | |
| 894 | + | printf("%c", output_terminator); | |
| 895 | + | maybe_flush_or_die(stdout, "stdout"); | |
| 896 | + | } | |
| 897 | + | break; | |
| 898 | + | case REVS: | |
| 899 | + | while (getline_fn(&scratch_buf, stdin) != EOF) { | |
| 900 | + | struct object_id oid; | |
| 901 | + | struct object *object; | |
| 902 | + | struct object *peeled; | |
| 903 | + | ||
| 904 | + | if (repo_get_oid(the_repository, scratch_buf.buf, &oid)) { | |
| 905 | + | fprintf(stderr, "Could not get object name for %s. Skipping.\n", | |
| 906 | + | scratch_buf.buf); | |
| 907 | + | continue; | |
| 908 | + | } | |
| 909 | + | ||
| 910 | + | object = parse_object(the_repository, &oid); | |
| 911 | + | if (!object) { | |
| 912 | + | fprintf(stderr, "Could not get object for %s. Skipping.\n", | |
| 913 | + | scratch_buf.buf); | |
| 914 | + | continue; | |
| 915 | + | } | |
| 916 | + | ||
| 917 | + | peeled = deref_tag(the_repository, object, scratch_buf.buf, 0); | |
| 918 | + | if (!peeled || peeled->type != OBJ_COMMIT) { | |
| 919 | + | fprintf(stderr, | |
| 920 | + | "Could not get commit for %s. Skipping.\n", | |
| 921 | + | scratch_buf.buf); | |
| 922 | + | continue; | |
| 923 | + | } | |
| 924 | + | ||
| 925 | + | get_format_rev((struct commit *)peeled, | |
| 926 | + | &format_pp, &scratch_buf); | |
| 927 | + | printf("%s%c", scratch_buf.buf, output_terminator); | |
| 928 | + | maybe_flush_or_die(stdout, "stdout"); | |
| 929 | + | strbuf_release(&scratch_buf); | |
| 930 | + | } | |
| 931 | + | break; | |
| 932 | + | default: | |
| 933 | + | BUG("uncovered case: %d", stdin_mode); | |
| 934 | + | } | |
| 935 | + | ||
| 936 | + | strbuf_release(&scratch_buf); | |
| 937 | + | string_list_clear(¬es, 0); | |
| 938 | + | release_display_notes(&format_notes_opt); | |
| 939 | + | return 0; | |
| 940 | + | } | |
modified builtin/notes.c
| @@ -150,7 +150,7 @@ static int list_each_note(const struct object_id *object_oid, | |||
| 150 | 150 | ||
| 151 | 151 | static void copy_obj_to_fd(int fd, const struct object_id *oid) | |
| 152 | 152 | { | |
| 153 | - | unsigned long size; | |
| 153 | + | size_t size; | |
| 154 | 154 | enum object_type type; | |
| 155 | 155 | char *buf = odb_read_object(the_repository->objects, oid, &type, &size); | |
| 156 | 156 | if (buf) { | |
| @@ -313,7 +313,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset) | |||
| 313 | 313 | char *value; | |
| 314 | 314 | struct object_id object; | |
| 315 | 315 | enum object_type type; | |
| 316 | - | unsigned long len; | |
| 316 | + | size_t len; | |
| 317 | 317 | ||
| 318 | 318 | BUG_ON_OPT_NEG(unset); | |
| 319 | 319 | ||
| @@ -721,7 +721,7 @@ static int append_edit(int argc, const char **argv, const char *prefix, | |||
| 721 | 721 | ||
| 722 | 722 | if (note && !edit) { | |
| 723 | 723 | /* Append buf to previous note contents */ | |
| 724 | - | unsigned long size; | |
| 724 | + | size_t size; | |
| 725 | 725 | enum object_type type; | |
| 726 | 726 | struct strbuf buf = STRBUF_INIT; | |
| 727 | 727 | char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size); | |
| @@ -989,7 +989,7 @@ static int merge(int argc, const char **argv, const char *prefix, | |||
| 989 | 989 | "NOTES_MERGE_PARTIAL", &result_oid, NULL, | |
| 990 | 990 | 0, UPDATE_REFS_DIE_ON_ERR); | |
| 991 | 991 | /* Store ref-to-be-updated into .git/NOTES_MERGE_REF */ | |
| 992 | - | worktrees = get_worktrees(); | |
| 992 | + | worktrees = get_worktrees(the_repository); | |
| 993 | 993 | wt = find_shared_symref(worktrees, "NOTES_MERGE_REF", | |
| 994 | 994 | notes_ref); | |
| 995 | 995 | if (wt) | |
modified builtin/pack-objects.c
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | #include "list.h" | |
| 33 | 33 | #include "packfile.h" | |
| 34 | 34 | #include "object-file.h" | |
| 35 | + | #include "object-file-convert.h" | |
| 35 | 36 | #include "odb.h" | |
| 36 | 37 | #include "odb/streaming.h" | |
| 37 | 38 | #include "replace-object.h" | |
| @@ -66,8 +67,8 @@ static inline struct object_entry *oe_delta( | |||
| 66 | 67 | return &pack->objects[e->delta_idx - 1]; | |
| 67 | 68 | } | |
| 68 | 69 | ||
| 69 | - | static inline unsigned long oe_delta_size(struct packing_data *pack, | |
| 70 | - | const struct object_entry *e) | |
| 70 | + | static inline size_t oe_delta_size(struct packing_data *pack, | |
| 71 | + | const struct object_entry *e) | |
| 71 | 72 | { | |
| 72 | 73 | if (e->delta_size_valid) | |
| 73 | 74 | return e->delta_size_; | |
| @@ -83,11 +84,11 @@ static inline unsigned long oe_delta_size(struct packing_data *pack, | |||
| 83 | 84 | return pack->delta_size[e - pack->objects]; | |
| 84 | 85 | } | |
| 85 | 86 | ||
| 86 | - | unsigned long oe_get_size_slow(struct packing_data *pack, | |
| 87 | - | const struct object_entry *e); | |
| 87 | + | size_t oe_get_size_slow(struct packing_data *pack, | |
| 88 | + | const struct object_entry *e); | |
| 88 | 89 | ||
| 89 | - | static inline unsigned long oe_size(struct packing_data *pack, | |
| 90 | - | const struct object_entry *e) | |
| 90 | + | static inline size_t oe_size(struct packing_data *pack, | |
| 91 | + | const struct object_entry *e) | |
| 91 | 92 | { | |
| 92 | 93 | if (e->size_valid) | |
| 93 | 94 | return e->size_; | |
| @@ -145,7 +146,7 @@ static inline void oe_set_delta_sibling(struct packing_data *pack, | |||
| 145 | 146 | ||
| 146 | 147 | static inline void oe_set_size(struct packing_data *pack, | |
| 147 | 148 | struct object_entry *e, | |
| 148 | - | unsigned long size) | |
| 149 | + | size_t size) | |
| 149 | 150 | { | |
| 150 | 151 | if (size < pack->oe_size_limit) { | |
| 151 | 152 | e->size_ = size; | |
| @@ -159,7 +160,7 @@ static inline void oe_set_size(struct packing_data *pack, | |||
| 159 | 160 | ||
| 160 | 161 | static inline void oe_set_delta_size(struct packing_data *pack, | |
| 161 | 162 | struct object_entry *e, | |
| 162 | - | unsigned long size) | |
| 163 | + | size_t size) | |
| 163 | 164 | { | |
| 164 | 165 | if (size < pack->oe_delta_size_limit) { | |
| 165 | 166 | e->delta_size_ = size; | |
| @@ -260,8 +261,8 @@ static int exclude_promisor_objects_best_effort; | |||
| 260 | 261 | ||
| 261 | 262 | static int use_delta_islands; | |
| 262 | 263 | ||
| 263 | - | static unsigned long delta_cache_size = 0; | |
| 264 | - | static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE; | |
| 264 | + | static size_t delta_cache_size = 0; | |
| 265 | + | static size_t max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE; | |
| 265 | 266 | static unsigned long cache_max_small_delta_size = 1000; | |
| 266 | 267 | ||
| 267 | 268 | static unsigned long window_memory_limit = 0; | |
| @@ -353,17 +354,21 @@ static void index_commit_for_bitmap(struct commit *commit) | |||
| 353 | 354 | ||
| 354 | 355 | static void *get_delta(struct object_entry *entry) | |
| 355 | 356 | { | |
| 356 | - | unsigned long size, base_size, delta_size; | |
| 357 | + | unsigned long size, base_size; | |
| 358 | + | size_t delta_size; | |
| 357 | 359 | void *buf, *base_buf, *delta_buf; | |
| 358 | 360 | enum object_type type; | |
| 361 | + | size_t size_st = 0, base_size_st = 0; | |
| 359 | 362 | ||
| 360 | 363 | buf = odb_read_object(the_repository->objects, &entry->idx.oid, | |
| 361 | - | &type, &size); | |
| 364 | + | &type, &size_st); | |
| 365 | + | size = cast_size_t_to_ulong(size_st); | |
| 362 | 366 | if (!buf) | |
| 363 | 367 | die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); | |
| 364 | 368 | base_buf = odb_read_object(the_repository->objects, | |
| 365 | 369 | &DELTA(entry)->idx.oid, &type, | |
| 366 | - | &base_size); | |
| 370 | + | &base_size_st); | |
| 371 | + | base_size = cast_size_t_to_ulong(base_size_st); | |
| 367 | 372 | if (!base_buf) | |
| 368 | 373 | die("unable to read %s", | |
| 369 | 374 | oid_to_hex(&DELTA(entry)->idx.oid)); | |
| @@ -386,8 +391,9 @@ static unsigned long do_compress(void **pptr, unsigned long size) | |||
| 386 | 391 | git_zstream stream; | |
| 387 | 392 | void *in, *out; | |
| 388 | 393 | unsigned long maxsize; | |
| 394 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 389 | 395 | ||
| 390 | - | git_deflate_init(&stream, pack_compression_level); | |
| 396 | + | git_deflate_init(&stream, cfg->pack_compression_level); | |
| 391 | 397 | maxsize = git_deflate_bound(&stream, size); | |
| 392 | 398 | ||
| 393 | 399 | in = *pptr; | |
| @@ -406,20 +412,21 @@ static unsigned long do_compress(void **pptr, unsigned long size) | |||
| 406 | 412 | return stream.total_out; | |
| 407 | 413 | } | |
| 408 | 414 | ||
| 409 | - | static unsigned long write_large_blob_data(struct odb_read_stream *st, struct hashfile *f, | |
| 415 | + | static unsigned long write_large_blob_data(struct odb_stream *st, struct hashfile *f, | |
| 410 | 416 | const struct object_id *oid) | |
| 411 | 417 | { | |
| 412 | 418 | git_zstream stream; | |
| 413 | 419 | unsigned char ibuf[1024 * 16]; | |
| 414 | 420 | unsigned char obuf[1024 * 16]; | |
| 415 | 421 | unsigned long olen = 0; | |
| 422 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 416 | 423 | ||
| 417 | - | git_deflate_init(&stream, pack_compression_level); | |
| 424 | + | git_deflate_init(&stream, cfg->pack_compression_level); | |
| 418 | 425 | ||
| 419 | 426 | for (;;) { | |
| 420 | 427 | ssize_t readlen; | |
| 421 | 428 | int zret = Z_OK; | |
| 422 | - | readlen = odb_read_stream_read(st, ibuf, sizeof(ibuf)); | |
| 429 | + | readlen = odb_stream_read(st, ibuf, sizeof(ibuf)); | |
| 423 | 430 | if (readlen == -1) | |
| 424 | 431 | die(_("unable to read %s"), oid_to_hex(oid)); | |
| 425 | 432 | ||
| @@ -453,7 +460,7 @@ static int check_pack_inflate(struct packed_git *p, | |||
| 453 | 460 | struct pack_window **w_curs, | |
| 454 | 461 | off_t offset, | |
| 455 | 462 | off_t len, | |
| 456 | - | unsigned long expect) | |
| 463 | + | size_t expect) | |
| 457 | 464 | { | |
| 458 | 465 | git_zstream stream; | |
| 459 | 466 | unsigned char fakebuf[4096], *in; | |
| @@ -482,7 +489,7 @@ static void copy_pack_data(struct hashfile *f, | |||
| 482 | 489 | off_t len) | |
| 483 | 490 | { | |
| 484 | 491 | unsigned char *in; | |
| 485 | - | unsigned long avail; | |
| 492 | + | size_t avail; | |
| 486 | 493 | ||
| 487 | 494 | while (len) { | |
| 488 | 495 | in = use_pack(p, w_curs, offset, &avail); | |
| @@ -496,7 +503,7 @@ static void copy_pack_data(struct hashfile *f, | |||
| 496 | 503 | ||
| 497 | 504 | static inline int oe_size_greater_than(struct packing_data *pack, | |
| 498 | 505 | const struct object_entry *lhs, | |
| 499 | - | unsigned long rhs) | |
| 506 | + | size_t rhs) | |
| 500 | 507 | { | |
| 501 | 508 | if (lhs->size_valid) | |
| 502 | 509 | return lhs->size_ > rhs; | |
| @@ -515,22 +522,24 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent | |||
| 515 | 522 | unsigned hdrlen; | |
| 516 | 523 | enum object_type type; | |
| 517 | 524 | void *buf; | |
| 518 | - | struct odb_read_stream *st = NULL; | |
| 525 | + | struct odb_stream *st = NULL; | |
| 519 | 526 | const unsigned hashsz = the_hash_algo->rawsz; | |
| 520 | 527 | ||
| 521 | 528 | if (!usable_delta) { | |
| 522 | 529 | if (oe_type(entry) == OBJ_BLOB && | |
| 523 | 530 | oe_size_greater_than(&to_pack, entry, | |
| 524 | 531 | repo_settings_get_big_file_threshold(the_repository)) && | |
| 525 | - | (st = odb_read_stream_open(the_repository->objects, &entry->idx.oid, | |
| 526 | - | NULL)) != NULL) { | |
| 532 | + | (st = odb_stream_from_object(the_repository->objects, &entry->idx.oid, | |
| 533 | + | NULL)) != NULL) { | |
| 527 | 534 | buf = NULL; | |
| 528 | 535 | type = st->type; | |
| 529 | 536 | size = st->size; | |
| 530 | 537 | } else { | |
| 538 | + | size_t size_st = 0; | |
| 531 | 539 | buf = odb_read_object(the_repository->objects, | |
| 532 | 540 | &entry->idx.oid, &type, | |
| 533 | - | &size); | |
| 541 | + | &size_st); | |
| 542 | + | size = cast_size_t_to_ulong(size_st); | |
| 534 | 543 | if (!buf) | |
| 535 | 544 | die(_("unable to read %s"), | |
| 536 | 545 | oid_to_hex(&entry->idx.oid)); | |
| @@ -581,7 +590,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent | |||
| 581 | 590 | dheader[--pos] = 128 | (--ofs & 127); | |
| 582 | 591 | if (limit && hdrlen + sizeof(dheader) - pos + datalen + hashsz >= limit) { | |
| 583 | 592 | if (st) | |
| 584 | - | odb_read_stream_close(st); | |
| 593 | + | odb_stream_close(st); | |
| 585 | 594 | free(buf); | |
| 586 | 595 | return 0; | |
| 587 | 596 | } | |
| @@ -595,7 +604,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent | |||
| 595 | 604 | */ | |
| 596 | 605 | if (limit && hdrlen + hashsz + datalen + hashsz >= limit) { | |
| 597 | 606 | if (st) | |
| 598 | - | odb_read_stream_close(st); | |
| 607 | + | odb_stream_close(st); | |
| 599 | 608 | free(buf); | |
| 600 | 609 | return 0; | |
| 601 | 610 | } | |
| @@ -605,7 +614,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent | |||
| 605 | 614 | } else { | |
| 606 | 615 | if (limit && hdrlen + datalen + hashsz >= limit) { | |
| 607 | 616 | if (st) | |
| 608 | - | odb_read_stream_close(st); | |
| 617 | + | odb_stream_close(st); | |
| 609 | 618 | free(buf); | |
| 610 | 619 | return 0; | |
| 611 | 620 | } | |
| @@ -613,7 +622,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent | |||
| 613 | 622 | } | |
| 614 | 623 | if (st) { | |
| 615 | 624 | datalen = write_large_blob_data(st, f, &entry->idx.oid); | |
| 616 | - | odb_read_stream_close(st); | |
| 625 | + | odb_stream_close(st); | |
| 617 | 626 | } else { | |
| 618 | 627 | hashwrite(f, buf, datalen); | |
| 619 | 628 | free(buf); | |
| @@ -629,14 +638,21 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry, | |||
| 629 | 638 | struct packed_git *p = IN_PACK(entry); | |
| 630 | 639 | struct pack_window *w_curs = NULL; | |
| 631 | 640 | uint32_t pos; | |
| 632 | - | off_t offset; | |
| 641 | + | off_t offset, cur; | |
| 633 | 642 | enum object_type type = oe_type(entry); | |
| 643 | + | enum object_type in_pack_type; | |
| 634 | 644 | off_t datalen; | |
| 635 | 645 | unsigned char header[MAX_PACK_OBJECT_HEADER], | |
| 636 | 646 | dheader[MAX_PACK_OBJECT_HEADER]; | |
| 637 | 647 | unsigned hdrlen; | |
| 638 | 648 | const unsigned hashsz = the_hash_algo->rawsz; | |
| 639 | - | unsigned long entry_size = SIZE(entry); | |
| 649 | + | size_t entry_size; | |
| 650 | + | ||
| 651 | + | cur = entry->in_pack_offset; | |
| 652 | + | in_pack_type = unpack_object_header(p, &w_curs, &cur, &entry_size); | |
| 653 | + | if (in_pack_type < 0) | |
| 654 | + | die(_("write_reuse_object: unable to parse object header of %s"), | |
| 655 | + | oid_to_hex(&entry->idx.oid)); | |
| 640 | 656 | ||
| 641 | 657 | if (DELTA(entry)) | |
| 642 | 658 | type = (allow_ofs_delta && DELTA(entry)->idx.offset) ? | |
| @@ -1087,7 +1103,7 @@ static void write_reused_pack_one(struct packed_git *reuse_packfile, | |||
| 1087 | 1103 | { | |
| 1088 | 1104 | off_t offset, next, cur; | |
| 1089 | 1105 | enum object_type type; | |
| 1090 | - | unsigned long size; | |
| 1106 | + | size_t size; | |
| 1091 | 1107 | ||
| 1092 | 1108 | offset = pack_pos_to_offset(reuse_packfile, pos); | |
| 1093 | 1109 | next = pack_pos_to_offset(reuse_packfile, pos + 1); | |
| @@ -1322,6 +1338,7 @@ static void write_pack_file(void) | |||
| 1322 | 1338 | uint32_t nr_remaining = nr_result; | |
| 1323 | 1339 | time_t last_mtime = 0; | |
| 1324 | 1340 | struct object_entry **write_order; | |
| 1341 | + | off_t bytes_written = 0; | |
| 1325 | 1342 | ||
| 1326 | 1343 | if (progress > pack_to_stdout) | |
| 1327 | 1344 | progress_state = start_progress(the_repository, | |
| @@ -1341,7 +1358,7 @@ static void write_pack_file(void) | |||
| 1341 | 1358 | * length of them as buffer length. | |
| 1342 | 1359 | * | |
| 1343 | 1360 | * Note that we need to subtract one though to | |
| 1344 | - | * accomodate for the sideband byte. | |
| 1361 | + | * accommodate for the sideband byte. | |
| 1345 | 1362 | */ | |
| 1346 | 1363 | struct hashfd_options opts = { | |
| 1347 | 1364 | .progress = progress_state, | |
| @@ -1374,6 +1391,8 @@ static void write_pack_file(void) | |||
| 1374 | 1391 | display_progress(progress_state, written); | |
| 1375 | 1392 | } | |
| 1376 | 1393 | ||
| 1394 | + | bytes_written += hashfile_total(f) + | |
| 1395 | + | the_repository->hash_algo->rawsz; | |
| 1377 | 1396 | if (pack_to_stdout) { | |
| 1378 | 1397 | /* | |
| 1379 | 1398 | * We never fsync when writing to stdout since we may | |
| @@ -1495,6 +1514,8 @@ static void write_pack_file(void) | |||
| 1495 | 1514 | written, nr_result); | |
| 1496 | 1515 | trace2_data_intmax("pack-objects", the_repository, | |
| 1497 | 1516 | "write_pack_file/wrote", nr_result); | |
| 1517 | + | trace2_data_intmax("pack-objects", the_repository, | |
| 1518 | + | "write_pack_file/wrote_bytes", bytes_written); | |
| 1498 | 1519 | } | |
| 1499 | 1520 | ||
| 1500 | 1521 | static int no_try_delta(const char *path) | |
| @@ -1742,9 +1763,11 @@ static int want_object_in_pack_mtime(const struct object_id *oid, | |||
| 1742 | 1763 | * skip the local object source. | |
| 1743 | 1764 | */ | |
| 1744 | 1765 | struct odb_source *source = the_repository->objects->sources->next; | |
| 1745 | - | for (; source; source = source->next) | |
| 1746 | - | if (odb_source_loose_has_object(source, oid)) | |
| 1766 | + | for (; source; source = source->next) { | |
| 1767 | + | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 1768 | + | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL)) | |
| 1747 | 1769 | return 0; | |
| 1770 | + | } | |
| 1748 | 1771 | } | |
| 1749 | 1772 | ||
| 1750 | 1773 | /* | |
| @@ -1762,13 +1785,12 @@ static int want_object_in_pack_mtime(const struct object_id *oid, | |||
| 1762 | 1785 | *found_offset = 0; | |
| 1763 | 1786 | } | |
| 1764 | 1787 | ||
| 1765 | - | odb_prepare_alternates(the_repository->objects); | |
| 1766 | - | ||
| 1767 | 1788 | for (source = the_repository->objects->sources; source; source = source->next) { | |
| 1768 | - | struct multi_pack_index *m = get_multi_pack_index(source); | |
| 1789 | + | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 1790 | + | struct multi_pack_index *m = get_multi_pack_index(files->packed); | |
| 1769 | 1791 | struct pack_entry e; | |
| 1770 | 1792 | ||
| 1771 | - | if (m && fill_midx_entry(m, oid, &e)) { | |
| 1793 | + | if (m && midx_fill_entry(m, oid, &e, NULL) == MIDX_FILL_HIT) { | |
| 1772 | 1794 | want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime); | |
| 1773 | 1795 | if (want != -1) | |
| 1774 | 1796 | return want; | |
| @@ -1850,8 +1872,8 @@ static const char no_closure_warning[] = N_( | |||
| 1850 | 1872 | "disabling bitmap writing, as some objects are not being packed" | |
| 1851 | 1873 | ); | |
| 1852 | 1874 | ||
| 1853 | - | static int add_object_entry(const struct object_id *oid, enum object_type type, | |
| 1854 | - | const char *name, int exclude) | |
| 1875 | + | static void add_object_entry(const struct object_id *oid, enum object_type type, | |
| 1876 | + | const char *name, int exclude) | |
| 1855 | 1877 | { | |
| 1856 | 1878 | struct packed_git *found_pack = NULL; | |
| 1857 | 1879 | off_t found_offset = 0; | |
| @@ -1859,7 +1881,7 @@ static int add_object_entry(const struct object_id *oid, enum object_type type, | |||
| 1859 | 1881 | display_progress(progress_state, ++nr_seen); | |
| 1860 | 1882 | ||
| 1861 | 1883 | if (have_duplicate_entry(oid, exclude)) | |
| 1862 | - | return 0; | |
| 1884 | + | return; | |
| 1863 | 1885 | ||
| 1864 | 1886 | if (!want_object_in_pack(oid, exclude, &found_pack, &found_offset)) { | |
| 1865 | 1887 | /* The pack is missing an object, so it will not have closure */ | |
| @@ -1868,13 +1890,12 @@ static int add_object_entry(const struct object_id *oid, enum object_type type, | |||
| 1868 | 1890 | warning(_(no_closure_warning)); | |
| 1869 | 1891 | write_bitmap_index = 0; | |
| 1870 | 1892 | } | |
| 1871 | - | return 0; | |
| 1893 | + | return; | |
| 1872 | 1894 | } | |
| 1873 | 1895 | ||
| 1874 | 1896 | create_object_entry(oid, type, pack_name_hash_fn(name), | |
| 1875 | 1897 | exclude, name && no_try_delta(name), | |
| 1876 | 1898 | found_pack, found_offset); | |
| 1877 | - | return 1; | |
| 1878 | 1899 | } | |
| 1879 | 1900 | ||
| 1880 | 1901 | static int add_object_entry_from_bitmap(const struct object_id *oid, | |
| @@ -1892,7 +1913,7 @@ static int add_object_entry_from_bitmap(const struct object_id *oid, | |||
| 1892 | 1913 | return 0; | |
| 1893 | 1914 | ||
| 1894 | 1915 | create_object_entry(oid, type, name_hash, 0, 0, pack, offset); | |
| 1895 | - | return 1; | |
| 1916 | + | return 0; | |
| 1896 | 1917 | } | |
| 1897 | 1918 | ||
| 1898 | 1919 | struct pbase_tree_cache { | |
| @@ -1928,6 +1949,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid) | |||
| 1928 | 1949 | struct pbase_tree_cache *ent, *nent; | |
| 1929 | 1950 | void *data; | |
| 1930 | 1951 | unsigned long size; | |
| 1952 | + | size_t size_st = 0; | |
| 1931 | 1953 | enum object_type type; | |
| 1932 | 1954 | int neigh; | |
| 1933 | 1955 | int my_ix = pbase_tree_cache_ix(oid); | |
| @@ -1955,7 +1977,8 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid) | |||
| 1955 | 1977 | /* Did not find one. Either we got a bogus request or | |
| 1956 | 1978 | * we need to read and perhaps cache. | |
| 1957 | 1979 | */ | |
| 1958 | - | data = odb_read_object(the_repository->objects, oid, &type, &size); | |
| 1980 | + | data = odb_read_object(the_repository->objects, oid, &type, &size_st); | |
| 1981 | + | size = cast_size_t_to_ulong(size_st); | |
| 1959 | 1982 | if (!data) | |
| 1960 | 1983 | return NULL; | |
| 1961 | 1984 | if (type != OBJ_TREE) { | |
| @@ -2110,13 +2133,15 @@ static void add_preferred_base(struct object_id *oid) | |||
| 2110 | 2133 | struct pbase_tree *it; | |
| 2111 | 2134 | void *data; | |
| 2112 | 2135 | unsigned long size; | |
| 2136 | + | size_t size_st = 0; | |
| 2113 | 2137 | struct object_id tree_oid; | |
| 2114 | 2138 | ||
| 2115 | 2139 | if (window <= num_preferred_base++) | |
| 2116 | 2140 | return; | |
| 2117 | 2141 | ||
| 2118 | 2142 | data = odb_read_object_peeled(the_repository->objects, oid, | |
| 2119 | - | OBJ_TREE, &size, &tree_oid); | |
| 2143 | + | OBJ_TREE, &size_st, &tree_oid); | |
| 2144 | + | size = cast_size_t_to_ulong(size_st); | |
| 2120 | 2145 | if (!data) | |
| 2121 | 2146 | return; | |
| 2122 | 2147 | ||
| @@ -2228,7 +2253,7 @@ static void prefetch_to_pack(uint32_t object_index_start) { | |||
| 2228 | 2253 | ||
| 2229 | 2254 | static void check_object(struct object_entry *entry, uint32_t object_index) | |
| 2230 | 2255 | { | |
| 2231 | - | unsigned long canonical_size; | |
| 2256 | + | size_t canonical_size; | |
| 2232 | 2257 | enum object_type type; | |
| 2233 | 2258 | struct object_info oi = {.typep = &type, .sizep = &canonical_size}; | |
| 2234 | 2259 | ||
| @@ -2238,12 +2263,11 @@ static void check_object(struct object_entry *entry, uint32_t object_index) | |||
| 2238 | 2263 | int have_base = 0; | |
| 2239 | 2264 | struct object_id base_ref; | |
| 2240 | 2265 | struct object_entry *base_entry; | |
| 2241 | - | unsigned long used, used_0; | |
| 2242 | - | unsigned long avail; | |
| 2266 | + | size_t used, used_0, avail; | |
| 2243 | 2267 | off_t ofs; | |
| 2244 | 2268 | unsigned char *buf, c; | |
| 2245 | 2269 | enum object_type type; | |
| 2246 | - | unsigned long in_pack_size; | |
| 2270 | + | size_t in_pack_size; | |
| 2247 | 2271 | ||
| 2248 | 2272 | buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail); | |
| 2249 | 2273 | ||
| @@ -2348,7 +2372,8 @@ static void check_object(struct object_entry *entry, uint32_t object_index) | |||
| 2348 | 2372 | * object size from the delta header. | |
| 2349 | 2373 | */ | |
| 2350 | 2374 | delta_pos = entry->in_pack_offset + entry->in_pack_header_size; | |
| 2351 | - | canonical_size = get_size_from_delta(p, &w_curs, delta_pos); | |
| 2375 | + | canonical_size = get_size_from_delta(p, &w_curs, | |
| 2376 | + | delta_pos); | |
| 2352 | 2377 | if (canonical_size == 0) | |
| 2353 | 2378 | goto give_up; | |
| 2354 | 2379 | SET_SIZE(entry, canonical_size); | |
| @@ -2426,7 +2451,7 @@ static void drop_reused_delta(struct object_entry *entry) | |||
| 2426 | 2451 | unsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx; | |
| 2427 | 2452 | struct object_info oi = OBJECT_INFO_INIT; | |
| 2428 | 2453 | enum object_type type; | |
| 2429 | - | unsigned long size; | |
| 2454 | + | size_t size; | |
| 2430 | 2455 | ||
| 2431 | 2456 | while (*idx) { | |
| 2432 | 2457 | struct object_entry *oe = &to_pack.objects[*idx - 1]; | |
| @@ -2441,7 +2466,7 @@ static void drop_reused_delta(struct object_entry *entry) | |||
| 2441 | 2466 | ||
| 2442 | 2467 | oi.sizep = &size; | |
| 2443 | 2468 | oi.typep = &type; | |
| 2444 | - | if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) { | |
| 2469 | + | if (packed_object_info(NULL, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) { | |
| 2445 | 2470 | /* | |
| 2446 | 2471 | * We failed to get the info from this pack for some reason; | |
| 2447 | 2472 | * fall back to odb_read_object_info, which may find another copy. | |
| @@ -2666,8 +2691,8 @@ struct unpacked { | |||
| 2666 | 2691 | unsigned depth; | |
| 2667 | 2692 | }; | |
| 2668 | 2693 | ||
| 2669 | - | static int delta_cacheable(unsigned long src_size, unsigned long trg_size, | |
| 2670 | - | unsigned long delta_size) | |
| 2694 | + | static int delta_cacheable(size_t src_size, size_t trg_size, | |
| 2695 | + | size_t delta_size) | |
| 2671 | 2696 | { | |
| 2672 | 2697 | if (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size) | |
| 2673 | 2698 | return 0; | |
| @@ -2704,7 +2729,7 @@ static pthread_mutex_t progress_mutex; | |||
| 2704 | 2729 | ||
| 2705 | 2730 | static inline int oe_size_less_than(struct packing_data *pack, | |
| 2706 | 2731 | const struct object_entry *lhs, | |
| 2707 | - | unsigned long rhs) | |
| 2732 | + | size_t rhs) | |
| 2708 | 2733 | { | |
| 2709 | 2734 | if (lhs->size_valid) | |
| 2710 | 2735 | return lhs->size_ < rhs; | |
| @@ -2722,28 +2747,45 @@ static inline void oe_set_tree_depth(struct packing_data *pack, | |||
| 2722 | 2747 | pack->tree_depth[e - pack->objects] = tree_depth; | |
| 2723 | 2748 | } | |
| 2724 | 2749 | ||
| 2750 | + | static void record_tree_depth(const struct object_id *oid, const char *name) | |
| 2751 | + | { | |
| 2752 | + | const char *p; | |
| 2753 | + | unsigned depth; | |
| 2754 | + | struct object_entry *ent; | |
| 2755 | + | ||
| 2756 | + | /* the empty string is a root tree, which is depth 0 */ | |
| 2757 | + | depth = *name ? 1 : 0; | |
| 2758 | + | for (p = strchr(name, '/'); p; p = strchr(p + 1, '/')) | |
| 2759 | + | depth++; | |
| 2760 | + | ||
| 2761 | + | ent = packlist_find(&to_pack, oid); | |
| 2762 | + | if (ent && depth > oe_tree_depth(&to_pack, ent)) | |
| 2763 | + | oe_set_tree_depth(&to_pack, ent, depth); | |
| 2764 | + | } | |
| 2765 | + | ||
| 2725 | 2766 | /* | |
| 2726 | 2767 | * Return the size of the object without doing any delta | |
| 2727 | 2768 | * reconstruction (so non-deltas are true object sizes, but deltas | |
| 2728 | 2769 | * return the size of the delta data). | |
| 2729 | 2770 | */ | |
| 2730 | - | unsigned long oe_get_size_slow(struct packing_data *pack, | |
| 2731 | - | const struct object_entry *e) | |
| 2771 | + | size_t oe_get_size_slow(struct packing_data *pack, | |
| 2772 | + | const struct object_entry *e) | |
| 2732 | 2773 | { | |
| 2733 | 2774 | struct packed_git *p; | |
| 2734 | 2775 | struct pack_window *w_curs; | |
| 2735 | 2776 | unsigned char *buf; | |
| 2736 | 2777 | enum object_type type; | |
| 2737 | - | unsigned long used, avail, size; | |
| 2778 | + | size_t used, avail, size; | |
| 2738 | 2779 | ||
| 2739 | 2780 | if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) { | |
| 2781 | + | size_t sz; | |
| 2740 | 2782 | packing_data_lock(&to_pack); | |
| 2741 | 2783 | if (odb_read_object_info(the_repository->objects, | |
| 2742 | - | &e->idx.oid, &size) < 0) | |
| 2784 | + | &e->idx.oid, &sz) < 0) | |
| 2743 | 2785 | die(_("unable to get size of %s"), | |
| 2744 | 2786 | oid_to_hex(&e->idx.oid)); | |
| 2745 | 2787 | packing_data_unlock(&to_pack); | |
| 2746 | - | return size; | |
| 2788 | + | return sz; | |
| 2747 | 2789 | } | |
| 2748 | 2790 | ||
| 2749 | 2791 | p = oe_in_pack(pack, e); | |
| @@ -2764,11 +2806,12 @@ unsigned long oe_get_size_slow(struct packing_data *pack, | |||
| 2764 | 2806 | } | |
| 2765 | 2807 | ||
| 2766 | 2808 | static int try_delta(struct unpacked *trg, struct unpacked *src, | |
| 2767 | - | unsigned max_depth, unsigned long *mem_usage) | |
| 2809 | + | unsigned max_depth, size_t *mem_usage) | |
| 2768 | 2810 | { | |
| 2769 | 2811 | struct object_entry *trg_entry = trg->entry; | |
| 2770 | 2812 | struct object_entry *src_entry = src->entry; | |
| 2771 | - | unsigned long trg_size, src_size, delta_size, sizediff, max_size, sz; | |
| 2813 | + | unsigned long trg_size, src_size, sizediff, max_size, sz; | |
| 2814 | + | size_t delta_size; | |
| 2772 | 2815 | unsigned ref_depth; | |
| 2773 | 2816 | enum object_type type; | |
| 2774 | 2817 | void *delta_buf; | |
| @@ -2821,10 +2864,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, | |||
| 2821 | 2864 | ||
| 2822 | 2865 | /* Load data if not already done */ | |
| 2823 | 2866 | if (!trg->data) { | |
| 2867 | + | size_t sz_st = 0; | |
| 2824 | 2868 | packing_data_lock(&to_pack); | |
| 2825 | 2869 | trg->data = odb_read_object(the_repository->objects, | |
| 2826 | 2870 | &trg_entry->idx.oid, &type, | |
| 2827 | - | &sz); | |
| 2871 | + | &sz_st); | |
| 2872 | + | sz = cast_size_t_to_ulong(sz_st); | |
| 2828 | 2873 | packing_data_unlock(&to_pack); | |
| 2829 | 2874 | if (!trg->data) | |
| 2830 | 2875 | die(_("object %s cannot be read"), | |
| @@ -2836,10 +2881,12 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, | |||
| 2836 | 2881 | *mem_usage += sz; | |
| 2837 | 2882 | } | |
| 2838 | 2883 | if (!src->data) { | |
| 2884 | + | size_t sz_st = 0; | |
| 2839 | 2885 | packing_data_lock(&to_pack); | |
| 2840 | 2886 | src->data = odb_read_object(the_repository->objects, | |
| 2841 | 2887 | &src_entry->idx.oid, &type, | |
| 2842 | - | &sz); | |
| 2888 | + | &sz_st); | |
| 2889 | + | sz = cast_size_t_to_ulong(sz_st); | |
| 2843 | 2890 | packing_data_unlock(&to_pack); | |
| 2844 | 2891 | if (!src->data) { | |
| 2845 | 2892 | if (src_entry->preferred_base) { | |
| @@ -2928,9 +2975,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n) | |||
| 2928 | 2975 | return m; | |
| 2929 | 2976 | } | |
| 2930 | 2977 | ||
| 2931 | - | static unsigned long free_unpacked(struct unpacked *n) | |
| 2978 | + | static size_t free_unpacked(struct unpacked *n) | |
| 2932 | 2979 | { | |
| 2933 | - | unsigned long freed_mem = sizeof_delta_index(n->index); | |
| 2980 | + | size_t freed_mem = sizeof_delta_index(n->index); | |
| 2934 | 2981 | free_delta_index(n->index); | |
| 2935 | 2982 | n->index = NULL; | |
| 2936 | 2983 | if (n->data) { | |
| @@ -2947,7 +2994,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size, | |||
| 2947 | 2994 | { | |
| 2948 | 2995 | uint32_t i, idx = 0, count = 0; | |
| 2949 | 2996 | struct unpacked *array; | |
| 2950 | - | unsigned long mem_usage = 0; | |
| 2997 | + | size_t mem_usage = 0; | |
| 2951 | 2998 | ||
| 2952 | 2999 | CALLOC_ARRAY(array, window); | |
| 2953 | 3000 | ||
| @@ -3657,7 +3704,7 @@ static int git_pack_config(const char *k, const char *v, | |||
| 3657 | 3704 | return 0; | |
| 3658 | 3705 | } | |
| 3659 | 3706 | if (!strcmp(k, "pack.deltacachesize")) { | |
| 3660 | - | max_delta_cache_size = git_config_int(k, v, ctx->kvi); | |
| 3707 | + | max_delta_cache_size = git_config_size_t(k, v, ctx->kvi); | |
| 3661 | 3708 | return 0; | |
| 3662 | 3709 | } | |
| 3663 | 3710 | if (!strcmp(k, "pack.deltacachelimit")) { | |
| @@ -3776,7 +3823,7 @@ static int add_object_entry_from_pack(const struct object_id *oid, | |||
| 3776 | 3823 | ofs = nth_packed_object_offset(p, pos); | |
| 3777 | 3824 | ||
| 3778 | 3825 | oi.typep = &type; | |
| 3779 | - | if (packed_object_info(p, ofs, &oi) < 0) { | |
| 3826 | + | if (packed_object_info(NULL, p, ofs, &oi) < 0) { | |
| 3780 | 3827 | die(_("could not get type of object %s in pack %s"), | |
| 3781 | 3828 | oid_to_hex(oid), p->pack_name); | |
| 3782 | 3829 | } else if (type == OBJ_COMMIT) { | |
| @@ -4043,9 +4090,10 @@ static void stdin_packs_read_input(struct rev_info *revs, | |||
| 4043 | 4090 | ||
| 4044 | 4091 | static void add_unreachable_loose_objects(struct rev_info *revs); | |
| 4045 | 4092 | ||
| 4046 | - | static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked) | |
| 4093 | + | static void read_stdin_packs(struct repository *repo, | |
| 4094 | + | enum stdin_packs_mode mode, int rev_list_unpacked) | |
| 4047 | 4095 | { | |
| 4048 | - | int prev_fetch_if_missing = fetch_if_missing; | |
| 4096 | + | int prev_fetch_if_missing = repo->fetch_if_missing; | |
| 4049 | 4097 | struct rev_info revs; | |
| 4050 | 4098 | ||
| 4051 | 4099 | /* | |
| @@ -4053,9 +4101,9 @@ static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked) | |||
| 4053 | 4101 | * walk is best-effort though we don't want to perform backfill fetches | |
| 4054 | 4102 | * for them. | |
| 4055 | 4103 | */ | |
| 4056 | - | fetch_if_missing = 0; | |
| 4104 | + | repo->fetch_if_missing = 0; | |
| 4057 | 4105 | ||
| 4058 | - | repo_init_revisions(the_repository, &revs, NULL); | |
| 4106 | + | repo_init_revisions(repo, &revs, NULL); | |
| 4059 | 4107 | /* | |
| 4060 | 4108 | * Use a revision walk to fill in the namehash of objects in the include | |
| 4061 | 4109 | * packs. To save time, we'll avoid traversing through objects that are | |
| @@ -4101,7 +4149,7 @@ static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked) | |||
| 4101 | 4149 | trace2_data_intmax("pack-objects", the_repository, "stdin_packs_hints", | |
| 4102 | 4150 | stdin_packs_hints_nr); | |
| 4103 | 4151 | ||
| 4104 | - | fetch_if_missing = prev_fetch_if_missing; | |
| 4152 | + | repo->fetch_if_missing = prev_fetch_if_missing; | |
| 4105 | 4153 | } | |
| 4106 | 4154 | ||
| 4107 | 4155 | static void add_cruft_object_entry(const struct object_id *oid, enum object_type type, | |
| @@ -4125,9 +4173,11 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type | |||
| 4125 | 4173 | struct odb_source *source = the_repository->objects->sources; | |
| 4126 | 4174 | int found = 0; | |
| 4127 | 4175 | ||
| 4128 | - | for (; !found && source; source = source->next) | |
| 4129 | - | if (odb_source_loose_has_object(source, oid)) | |
| 4176 | + | for (; !found && source; source = source->next) { | |
| 4177 | + | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 4178 | + | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL)) | |
| 4130 | 4179 | found = 1; | |
| 4180 | + | } | |
| 4131 | 4181 | ||
| 4132 | 4182 | /* | |
| 4133 | 4183 | * If a traversed tree has a missing blob then we want | |
| @@ -4265,6 +4315,7 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs | |||
| 4265 | 4315 | traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL); | |
| 4266 | 4316 | ||
| 4267 | 4317 | stop_progress(&progress_state); | |
| 4318 | + | release_revisions(&revs); | |
| 4268 | 4319 | } | |
| 4269 | 4320 | ||
| 4270 | 4321 | static void read_cruft_objects(void) | |
| @@ -4375,20 +4426,8 @@ static void show_object(struct object *obj, const char *name, | |||
| 4375 | 4426 | add_preferred_base_object(name); | |
| 4376 | 4427 | add_object_entry(&obj->oid, obj->type, name, 0); | |
| 4377 | 4428 | ||
| 4378 | - | if (use_delta_islands) { | |
| 4379 | - | const char *p; | |
| 4380 | - | unsigned depth; | |
| 4381 | - | struct object_entry *ent; | |
| 4382 | - | ||
| 4383 | - | /* the empty string is a root tree, which is depth 0 */ | |
| 4384 | - | depth = *name ? 1 : 0; | |
| 4385 | - | for (p = strchr(name, '/'); p; p = strchr(p + 1, '/')) | |
| 4386 | - | depth++; | |
| 4387 | - | ||
| 4388 | - | ent = packlist_find(&to_pack, &obj->oid); | |
| 4389 | - | if (ent && depth > oe_tree_depth(&to_pack, ent)) | |
| 4390 | - | oe_set_tree_depth(&to_pack, ent, depth); | |
| 4391 | - | } | |
| 4429 | + | if (use_delta_islands) | |
| 4430 | + | record_tree_depth(&obj->oid, name); | |
| 4392 | 4431 | } | |
| 4393 | 4432 | ||
| 4394 | 4433 | static void show_object__ma_allow_any(struct object *obj, const char *name, void *data) | |
| @@ -4420,9 +4459,11 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name, | |||
| 4420 | 4459 | show_object(obj, name, data); | |
| 4421 | 4460 | } | |
| 4422 | 4461 | ||
| 4423 | - | static int option_parse_missing_action(const struct option *opt UNUSED, | |
| 4462 | + | static int option_parse_missing_action(const struct option *opt, | |
| 4424 | 4463 | const char *arg, int unset) | |
| 4425 | 4464 | { | |
| 4465 | + | struct repository *repo = opt->value; | |
| 4466 | + | ||
| 4426 | 4467 | assert(arg); | |
| 4427 | 4468 | assert(!unset); | |
| 4428 | 4469 | ||
| @@ -4434,14 +4475,14 @@ static int option_parse_missing_action(const struct option *opt UNUSED, | |||
| 4434 | 4475 | ||
| 4435 | 4476 | if (!strcmp(arg, "allow-any")) { | |
| 4436 | 4477 | arg_missing_action = MA_ALLOW_ANY; | |
| 4437 | - | fetch_if_missing = 0; | |
| 4478 | + | repo->fetch_if_missing = 0; | |
| 4438 | 4479 | fn_show_object = show_object__ma_allow_any; | |
| 4439 | 4480 | return 0; | |
| 4440 | 4481 | } | |
| 4441 | 4482 | ||
| 4442 | 4483 | if (!strcmp(arg, "allow-promisor")) { | |
| 4443 | 4484 | arg_missing_action = MA_ALLOW_PROMISOR; | |
| 4444 | - | fetch_if_missing = 0; | |
| 4485 | + | repo->fetch_if_missing = 0; | |
| 4445 | 4486 | fn_show_object = show_object__ma_allow_promisor; | |
| 4446 | 4487 | return 0; | |
| 4447 | 4488 | } | |
| @@ -4460,8 +4501,9 @@ static int add_object_in_unpacked_pack(const struct object_id *oid, | |||
| 4460 | 4501 | void *data UNUSED) | |
| 4461 | 4502 | { | |
| 4462 | 4503 | if (cruft) { | |
| 4463 | - | add_cruft_object_entry(oid, OBJ_NONE, oi->u.packed.pack, | |
| 4464 | - | oi->u.packed.offset, NULL, *oi->mtimep); | |
| 4504 | + | add_cruft_object_entry(oid, OBJ_NONE, oi->source_infop->u.packed.pack, | |
| 4505 | + | oi->source_infop->u.packed.offset, NULL, | |
| 4506 | + | *oi->mtimep); | |
| 4465 | 4507 | } else { | |
| 4466 | 4508 | add_object_entry(oid, OBJ_NONE, "", 0); | |
| 4467 | 4509 | } | |
| @@ -4478,19 +4520,20 @@ static void add_objects_in_unpacked_packs(void) | |||
| 4478 | 4520 | ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS | | |
| 4479 | 4521 | ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS, | |
| 4480 | 4522 | }; | |
| 4523 | + | struct odb_source_info source_info; | |
| 4481 | 4524 | struct object_info oi = { | |
| 4482 | 4525 | .mtimep = &mtime, | |
| 4526 | + | .source_infop = &source_info, | |
| 4483 | 4527 | }; | |
| 4484 | 4528 | ||
| 4485 | - | odb_prepare_alternates(to_pack.repo->objects); | |
| 4486 | 4529 | for (source = to_pack.repo->objects->sources; source; source = source->next) { | |
| 4487 | 4530 | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 4488 | 4531 | ||
| 4489 | 4532 | if (!source->local) | |
| 4490 | 4533 | continue; | |
| 4491 | 4534 | ||
| 4492 | - | if (packfile_store_for_each_object(files->packed, &oi, | |
| 4493 | - | add_object_in_unpacked_pack, NULL, &opts)) | |
| 4535 | + | if (odb_source_for_each_object(&files->packed->base, &oi, | |
| 4536 | + | add_object_in_unpacked_pack, NULL, &opts)) | |
| 4494 | 4537 | die(_("cannot open pack index")); | |
| 4495 | 4538 | } | |
| 4496 | 4539 | } | |
| @@ -4584,6 +4627,51 @@ static int loosened_object_can_be_discarded(const struct object_id *oid, | |||
| 4584 | 4627 | return 1; | |
| 4585 | 4628 | } | |
| 4586 | 4629 | ||
| 4630 | + | static int force_object_loose(struct odb_source *source, | |
| 4631 | + | const struct object_id *oid, | |
| 4632 | + | const time_t *mtime) | |
| 4633 | + | { | |
| 4634 | + | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 4635 | + | const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo; | |
| 4636 | + | struct object_info oi = OBJECT_INFO_INIT; | |
| 4637 | + | struct object_id compat_oid, *compat_oid_p = NULL; | |
| 4638 | + | enum object_type type; | |
| 4639 | + | void *buf = NULL; | |
| 4640 | + | size_t len; | |
| 4641 | + | int ret; | |
| 4642 | + | ||
| 4643 | + | for (struct odb_source *s = source->odb->sources; s; s = s->next) { | |
| 4644 | + | struct odb_source_files *files = odb_source_files_downcast(s); | |
| 4645 | + | if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL)) | |
| 4646 | + | return 0; | |
| 4647 | + | } | |
| 4648 | + | ||
| 4649 | + | oi.typep = &type; | |
| 4650 | + | oi.sizep = &len; | |
| 4651 | + | oi.contentp = &buf; | |
| 4652 | + | if (odb_read_object_info_extended(source->odb, oid, &oi, 0)) { | |
| 4653 | + | ret = error(_("cannot read object for %s"), oid_to_hex(oid)); | |
| 4654 | + | goto out; | |
| 4655 | + | } | |
| 4656 | + | ||
| 4657 | + | if (compat) { | |
| 4658 | + | if (repo_oid_to_algop(source->odb->repo, oid, compat, &compat_oid)) { | |
| 4659 | + | ret = error(_("cannot map object %s to %s"), | |
| 4660 | + | oid_to_hex(oid), compat->name); | |
| 4661 | + | goto out; | |
| 4662 | + | } | |
| 4663 | + | ||
| 4664 | + | compat_oid_p = &compat_oid; | |
| 4665 | + | } | |
| 4666 | + | ||
| 4667 | + | ret = odb_source_write_object(&files->loose->base, buf, len, type, oid, | |
| 4668 | + | compat_oid_p, mtime, 0); | |
| 4669 | + | ||
| 4670 | + | out: | |
| 4671 | + | free(buf); | |
| 4672 | + | return ret; | |
| 4673 | + | } | |
| 4674 | + | ||
| 4587 | 4675 | static void loosen_unused_packed_objects(void) | |
| 4588 | 4676 | { | |
| 4589 | 4677 | struct packed_git *p; | |
| @@ -4604,7 +4692,7 @@ static void loosen_unused_packed_objects(void) | |||
| 4604 | 4692 | !has_sha1_pack_kept_or_nonlocal(&oid) && | |
| 4605 | 4693 | !loosened_object_can_be_discarded(&oid, p->mtime)) { | |
| 4606 | 4694 | if (force_object_loose(the_repository->objects->sources, | |
| 4607 | - | &oid, p->mtime)) | |
| 4695 | + | &oid, &p->mtime)) | |
| 4608 | 4696 | die(_("unable to force loose object")); | |
| 4609 | 4697 | loosened_objects_nr++; | |
| 4610 | 4698 | } | |
| @@ -4732,6 +4820,31 @@ static int add_objects_by_path(const char *path, | |||
| 4732 | 4820 | continue; | |
| 4733 | 4821 | ||
| 4734 | 4822 | add_object_entry(oid, type, path, exclude); | |
| 4823 | + | ||
| 4824 | + | if (type == OBJ_COMMIT) { | |
| 4825 | + | struct commit *commit; | |
| 4826 | + | ||
| 4827 | + | if (!write_bitmap_index && !use_delta_islands) | |
| 4828 | + | continue; | |
| 4829 | + | ||
| 4830 | + | commit = lookup_commit(the_repository, oid); | |
| 4831 | + | if (!commit) | |
| 4832 | + | die(_("could not find commit %s"), oid_to_hex(oid)); | |
| 4833 | + | if (write_bitmap_index) | |
| 4834 | + | index_commit_for_bitmap(commit); | |
| 4835 | + | /* | |
| 4836 | + | * Skip island propagation for boundary commits. | |
| 4837 | + | * The regular traversal's show_commit() is only | |
| 4838 | + | * called for interesting commits; matching that | |
| 4839 | + | * here keeps path-walk from doing extra work that | |
| 4840 | + | * would only be a no-op anyway (boundary commits | |
| 4841 | + | * are not in island_marks). | |
| 4842 | + | */ | |
| 4843 | + | if (use_delta_islands && !exclude) | |
| 4844 | + | propagate_island_marks(the_repository, commit); | |
| 4845 | + | } else if (type == OBJ_TREE && use_delta_islands) { | |
| 4846 | + | record_tree_depth(oid, path); | |
| 4847 | + | } | |
| 4735 | 4848 | } | |
| 4736 | 4849 | ||
| 4737 | 4850 | oe_end = to_pack.nr_objects; | |
| @@ -4754,7 +4867,7 @@ static int add_objects_by_path(const char *path, | |||
| 4754 | 4867 | return 0; | |
| 4755 | 4868 | } | |
| 4756 | 4869 | ||
| 4757 | - | static void get_object_list_path_walk(struct rev_info *revs) | |
| 4870 | + | static int get_object_list_path_walk(struct rev_info *revs) | |
| 4758 | 4871 | { | |
| 4759 | 4872 | struct path_walk_info info = PATH_WALK_INFO_INIT; | |
| 4760 | 4873 | unsigned int processed = 0; | |
| @@ -4764,6 +4877,13 @@ static void get_object_list_path_walk(struct rev_info *revs) | |||
| 4764 | 4877 | info.path_fn = add_objects_by_path; | |
| 4765 | 4878 | info.path_fn_data = &processed; | |
| 4766 | 4879 | ||
| 4880 | + | /* | |
| 4881 | + | * Path-walk needs boundary commits to discover thin-pack bases, but | |
| 4882 | + | * bitmap traversal does not understand the boundary state. Set it | |
| 4883 | + | * here so any prior bitmap attempt sees the usual non-boundary walk. | |
| 4884 | + | */ | |
| 4885 | + | revs->boundary = 1; | |
| 4886 | + | ||
| 4767 | 4887 | /* | |
| 4768 | 4888 | * Allow the --[no-]sparse option to be interesting here, if only | |
| 4769 | 4889 | * for testing purposes. Paths with no interesting objects will not | |
| @@ -4777,8 +4897,9 @@ static void get_object_list_path_walk(struct rev_info *revs) | |||
| 4777 | 4897 | result = walk_objects_by_path(&info); | |
| 4778 | 4898 | trace2_region_leave("pack-objects", "path-walk", revs->repo); | |
| 4779 | 4899 | ||
| 4780 | - | if (result) | |
| 4781 | - | die(_("failed to pack objects via path-walk")); | |
| 4900 | + | path_walk_info_clear(&info); | |
| 4901 | + | ||
| 4902 | + | return result; | |
| 4782 | 4903 | } | |
| 4783 | 4904 | ||
| 4784 | 4905 | static void get_object_list(struct rev_info *revs, struct strvec *argv) | |
| @@ -4786,6 +4907,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv) | |||
| 4786 | 4907 | struct setup_revision_opt s_r_opt = { | |
| 4787 | 4908 | .allow_exclude_promisor_objects = 1, | |
| 4788 | 4909 | }; | |
| 4910 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 4789 | 4911 | char line[1000]; | |
| 4790 | 4912 | int flags = 0; | |
| 4791 | 4913 | int save_warning; | |
| @@ -4796,8 +4918,8 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv) | |||
| 4796 | 4918 | /* make sure shallows are read */ | |
| 4797 | 4919 | is_repository_shallow(the_repository); | |
| 4798 | 4920 | ||
| 4799 | - | save_warning = warn_on_object_refname_ambiguity; | |
| 4800 | - | warn_on_object_refname_ambiguity = 0; | |
| 4921 | + | save_warning = cfg->warn_on_object_refname_ambiguity; | |
| 4922 | + | cfg->warn_on_object_refname_ambiguity = 0; | |
| 4801 | 4923 | ||
| 4802 | 4924 | while (fgets(line, sizeof(line), stdin) != NULL) { | |
| 4803 | 4925 | int len = strlen(line); | |
| @@ -4825,7 +4947,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv) | |||
| 4825 | 4947 | die(_("bad revision '%s'"), line); | |
| 4826 | 4948 | } | |
| 4827 | 4949 | ||
| 4828 | - | warn_on_object_refname_ambiguity = save_warning; | |
| 4950 | + | cfg->warn_on_object_refname_ambiguity = save_warning; | |
| 4829 | 4951 | ||
| 4830 | 4952 | if (use_bitmap_index && !get_object_list_from_bitmap(revs)) | |
| 4831 | 4953 | return; | |
| @@ -4841,8 +4963,13 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv) | |||
| 4841 | 4963 | fn_show_object = show_object; | |
| 4842 | 4964 | ||
| 4843 | 4965 | if (path_walk) { | |
| 4844 | - | get_object_list_path_walk(revs); | |
| 4845 | - | } else { | |
| 4966 | + | if (get_object_list_path_walk(revs)) { | |
| 4967 | + | warning(_("failed to pack objects via path-walk")); | |
| 4968 | + | path_walk = 0; | |
| 4969 | + | } | |
| 4970 | + | } | |
| 4971 | + | ||
| 4972 | + | if (!path_walk) { | |
| 4846 | 4973 | if (prepare_revision_walk(revs)) | |
| 4847 | 4974 | die(_("revision walk setup failed")); | |
| 4848 | 4975 | mark_edges_uninteresting(revs, show_edge, sparse); | |
| @@ -4962,10 +5089,14 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED, | |||
| 4962 | 5089 | ||
| 4963 | 5090 | static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED) | |
| 4964 | 5091 | { | |
| 4965 | - | struct object_info info = OBJECT_INFO_INIT; | |
| 5092 | + | struct odb_source_info source_info; | |
| 5093 | + | struct object_info info = { | |
| 5094 | + | .source_infop = &source_info, | |
| 5095 | + | }; | |
| 5096 | + | ||
| 4966 | 5097 | if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0)) | |
| 4967 | 5098 | BUG("should_include_obj should only be called on existing objects"); | |
| 4968 | - | return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor; | |
| 5099 | + | return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor; | |
| 4969 | 5100 | } | |
| 4970 | 5101 | ||
| 4971 | 5102 | static int is_not_in_promisor_pack(struct commit *commit, void *data) { | |
| @@ -4992,7 +5123,7 @@ static int parse_stdin_packs_mode(const struct option *opt, const char *arg, | |||
| 4992 | 5123 | int cmd_pack_objects(int argc, | |
| 4993 | 5124 | const char **argv, | |
| 4994 | 5125 | const char *prefix, | |
| 4995 | - | struct repository *repo UNUSED) | |
| 5126 | + | struct repository *repo) | |
| 4996 | 5127 | { | |
| 4997 | 5128 | int use_internal_rev_list = 0; | |
| 4998 | 5129 | int all_progress_implied = 0; | |
| @@ -5003,6 +5134,7 @@ int cmd_pack_objects(int argc, | |||
| 5003 | 5134 | struct string_list keep_pack_list = STRING_LIST_INIT_NODUP; | |
| 5004 | 5135 | struct list_objects_filter_options filter_options = | |
| 5005 | 5136 | LIST_OBJECTS_FILTER_INIT; | |
| 5137 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 5006 | 5138 | ||
| 5007 | 5139 | struct option pack_objects_options[] = { | |
| 5008 | 5140 | OPT_CALLBACK_F('q', "quiet", &progress, NULL, | |
| @@ -5084,7 +5216,7 @@ int cmd_pack_objects(int argc, | |||
| 5084 | 5216 | N_("ignore packs that have companion .keep file")), | |
| 5085 | 5217 | OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"), | |
| 5086 | 5218 | N_("ignore this pack")), | |
| 5087 | - | OPT_INTEGER(0, "compression", &pack_compression_level, | |
| 5219 | + | OPT_INTEGER(0, "compression", &cfg->pack_compression_level, | |
| 5088 | 5220 | N_("pack compression level")), | |
| 5089 | 5221 | OPT_BOOL(0, "keep-true-parents", &grafts_keep_true_parents, | |
| 5090 | 5222 | N_("do not hide commits by grafts")), | |
| @@ -5098,7 +5230,7 @@ int cmd_pack_objects(int argc, | |||
| 5098 | 5230 | N_("write a bitmap index if possible"), | |
| 5099 | 5231 | WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN), | |
| 5100 | 5232 | OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), | |
| 5101 | - | OPT_CALLBACK_F(0, "missing", NULL, N_("action"), | |
| 5233 | + | OPT_CALLBACK_F(0, "missing", repo, N_("action"), | |
| 5102 | 5234 | N_("handling for missing objects"), PARSE_OPT_NONEG, | |
| 5103 | 5235 | option_parse_missing_action), | |
| 5104 | 5236 | OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects, | |
| @@ -5177,10 +5309,8 @@ int cmd_pack_objects(int argc, | |||
| 5177 | 5309 | ||
| 5178 | 5310 | if (path_walk) { | |
| 5179 | 5311 | const char *option = NULL; | |
| 5180 | - | if (filter_options.choice) | |
| 5312 | + | if (!path_walk_filter_compatible(&filter_options)) | |
| 5181 | 5313 | option = "--filter"; | |
| 5182 | - | else if (use_delta_islands) | |
| 5183 | - | option = "--delta-islands"; | |
| 5184 | 5314 | ||
| 5185 | 5315 | if (option) { | |
| 5186 | 5316 | warning(_("cannot use %s with %s"), | |
| @@ -5189,12 +5319,7 @@ int cmd_pack_objects(int argc, | |||
| 5189 | 5319 | } | |
| 5190 | 5320 | } | |
| 5191 | 5321 | if (path_walk) { | |
| 5192 | - | strvec_push(&rp, "--boundary"); | |
| 5193 | - | /* | |
| 5194 | - | * We must disable the bitmaps because we are removing | |
| 5195 | - | * the --objects / --objects-edge[-aggressive] options. | |
| 5196 | - | */ | |
| 5197 | - | use_bitmap_index = 0; | |
| 5322 | + | strvec_push(&rp, "--objects"); | |
| 5198 | 5323 | } else if (thin) { | |
| 5199 | 5324 | use_internal_rev_list = 1; | |
| 5200 | 5325 | strvec_push(&rp, shallow | |
| @@ -5225,7 +5350,7 @@ int cmd_pack_objects(int argc, | |||
| 5225 | 5350 | exclude_promisor_objects_best_effort, | |
| 5226 | 5351 | "--exclude-promisor-objects-best-effort"); | |
| 5227 | 5352 | if (exclude_promisor_objects) { | |
| 5228 | - | fetch_if_missing = 0; | |
| 5353 | + | repo->fetch_if_missing = 0; | |
| 5229 | 5354 | ||
| 5230 | 5355 | /* --stdin-packs handles promisor objects separately. */ | |
| 5231 | 5356 | if (!stdin_packs) { | |
| @@ -5234,8 +5359,9 @@ int cmd_pack_objects(int argc, | |||
| 5234 | 5359 | } | |
| 5235 | 5360 | } else if (exclude_promisor_objects_best_effort) { | |
| 5236 | 5361 | use_internal_rev_list = 1; | |
| 5237 | - | fetch_if_missing = 0; | |
| 5238 | - | option_parse_missing_action(NULL, "allow-any", 0); | |
| 5362 | + | arg_missing_action = MA_ALLOW_ANY; | |
| 5363 | + | repo->fetch_if_missing = 0; | |
| 5364 | + | fn_show_object = show_object__ma_allow_any; | |
| 5239 | 5365 | /* revs configured below */ | |
| 5240 | 5366 | } | |
| 5241 | 5367 | if (unpack_unreachable || keep_unreachable || pack_loose_unreachable) | |
| @@ -5243,10 +5369,10 @@ int cmd_pack_objects(int argc, | |||
| 5243 | 5369 | ||
| 5244 | 5370 | if (!reuse_object) | |
| 5245 | 5371 | reuse_delta = 0; | |
| 5246 | - | if (pack_compression_level == -1) | |
| 5247 | - | pack_compression_level = Z_DEFAULT_COMPRESSION; | |
| 5248 | - | else if (pack_compression_level < 0 || pack_compression_level > Z_BEST_COMPRESSION) | |
| 5249 | - | die(_("bad pack compression level %d"), pack_compression_level); | |
| 5372 | + | if (cfg->pack_compression_level == -1) | |
| 5373 | + | cfg->pack_compression_level = Z_DEFAULT_COMPRESSION; | |
| 5374 | + | else if (cfg->pack_compression_level < 0 || cfg->pack_compression_level > Z_BEST_COMPRESSION) | |
| 5375 | + | die(_("bad pack compression level %d"), cfg->pack_compression_level); | |
| 5250 | 5376 | ||
| 5251 | 5377 | if (!delta_search_threads) /* --threads=0 means autodetect */ | |
| 5252 | 5378 | delta_search_threads = online_cpus(); | |
| @@ -5351,7 +5477,7 @@ int cmd_pack_objects(int argc, | |||
| 5351 | 5477 | progress_state = start_progress(the_repository, | |
| 5352 | 5478 | _("Enumerating objects"), 0); | |
| 5353 | 5479 | if (stdin_packs) { | |
| 5354 | - | read_stdin_packs(stdin_packs, rev_list_unpacked); | |
| 5480 | + | read_stdin_packs(repo, stdin_packs, rev_list_unpacked); | |
| 5355 | 5481 | } else if (cruft) { | |
| 5356 | 5482 | read_cruft_objects(); | |
| 5357 | 5483 | } else if (!use_internal_rev_list) { | |
modified builtin/patch-id.c
| @@ -73,7 +73,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu | |||
| 73 | 73 | char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1]; | |
| 74 | 74 | struct git_hash_ctx ctx; | |
| 75 | 75 | ||
| 76 | - | the_hash_algo->init_fn(&ctx); | |
| 76 | + | git_hash_init(&ctx, the_hash_algo); | |
| 77 | 77 | oidclr(result, the_repository->hash_algo); | |
| 78 | 78 | ||
| 79 | 79 | while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) { | |
| @@ -173,6 +173,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu | |||
| 173 | 173 | oidclr(next_oid, the_repository->hash_algo); | |
| 174 | 174 | ||
| 175 | 175 | flush_one_hunk(result, &ctx); | |
| 176 | + | git_hash_discard(&ctx); | |
| 176 | 177 | ||
| 177 | 178 | return patchlen; | |
| 178 | 179 | } | |
modified builtin/prune.c
| @@ -194,7 +194,7 @@ int cmd_prune(int argc, | |||
| 194 | 194 | if (show_progress == -1) | |
| 195 | 195 | show_progress = isatty(2); | |
| 196 | 196 | if (exclude_promisor_objects) { | |
| 197 | - | fetch_if_missing = 0; | |
| 197 | + | repo->fetch_if_missing = 0; | |
| 198 | 198 | revs.exclude_promisor_objects = 1; | |
| 199 | 199 | } | |
| 200 | 200 | ||
modified builtin/pull.c
| @@ -612,7 +612,7 @@ static const char *get_tracking_branch(const char *remote, const char *refspec) | |||
| 612 | 612 | const char *spec_src; | |
| 613 | 613 | const char *merge_branch; | |
| 614 | 614 | ||
| 615 | - | if (!refspec_item_init_fetch(&spec, refspec)) | |
| 615 | + | if (!refspec_item_init_fetch(&spec, refspec, the_hash_algo)) | |
| 616 | 616 | die(_("invalid refspec '%s'"), refspec); | |
| 617 | 617 | spec_src = spec.src; | |
| 618 | 618 | if (!*spec_src || !strcmp(spec_src, "HEAD")) | |
| @@ -996,9 +996,13 @@ int cmd_pull(int argc, | |||
| 996 | 996 | OPT_PASSTHRU('6', "ipv6", &opt_ipv6, NULL, | |
| 997 | 997 | N_("use IPv6 addresses only"), | |
| 998 | 998 | PARSE_OPT_NOARG), | |
| 999 | - | OPT_PASSTHRU_ARGV(0, "negotiation-tip", &opt_fetch, N_("revision"), | |
| 999 | + | OPT_PASSTHRU_ARGV(0, "negotiation-restrict", &opt_fetch, N_("revision"), | |
| 1000 | 1000 | N_("report that we have only objects reachable from this object"), | |
| 1001 | 1001 | 0), | |
| 1002 | + | OPT_ALIAS(0, "negotiation-tip", "negotiation-restrict"), | |
| 1003 | + | OPT_PASSTHRU_ARGV(0, "negotiation-include", &opt_fetch, N_("revision"), | |
| 1004 | + | N_("ensure this ref is always sent as a negotiation have"), | |
| 1005 | + | 0), | |
| 1002 | 1006 | OPT_BOOL(0, "show-forced-updates", &opt_show_forced_updates, | |
| 1003 | 1007 | N_("check for forced-updates on all updated branches")), | |
| 1004 | 1008 | OPT_PASSTHRU(0, "set-upstream", &set_upstream, NULL, | |
modified builtin/push.c
| @@ -8,8 +8,10 @@ | |||
| 8 | 8 | #include "advice.h" | |
| 9 | 9 | #include "branch.h" | |
| 10 | 10 | #include "config.h" | |
| 11 | + | #include "dir.h" | |
| 11 | 12 | #include "environment.h" | |
| 12 | 13 | #include "gettext.h" | |
| 14 | + | #include "hex.h" | |
| 13 | 15 | #include "refspec.h" | |
| 14 | 16 | #include "run-command.h" | |
| 15 | 17 | #include "remote.h" | |
| @@ -64,7 +66,7 @@ static enum transport_family family; | |||
| 64 | 66 | ||
| 65 | 67 | static struct push_cas_option cas; | |
| 66 | 68 | ||
| 67 | - | static struct refspec rs = REFSPEC_INIT_PUSH; | |
| 69 | + | static struct refspec rs; | |
| 68 | 70 | ||
| 69 | 71 | static struct string_list push_options_config = STRING_LIST_INIT_DUP; | |
| 70 | 72 | ||
| @@ -72,6 +74,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref, | |||
| 72 | 74 | struct remote *remote, struct ref *matched) | |
| 73 | 75 | { | |
| 74 | 76 | const char *branch_name; | |
| 77 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 75 | 78 | ||
| 76 | 79 | if (remote->push.nr) { | |
| 77 | 80 | struct refspec_item query = { | |
| @@ -87,7 +90,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref, | |||
| 87 | 90 | } | |
| 88 | 91 | } | |
| 89 | 92 | ||
| 90 | - | if (push_default == PUSH_DEFAULT_UPSTREAM && | |
| 93 | + | if (cfg->push_default == PUSH_DEFAULT_UPSTREAM && | |
| 91 | 94 | skip_prefix(matched->name, "refs/heads/", &branch_name)) { | |
| 92 | 95 | struct branch *branch = branch_get(branch_name); | |
| 93 | 96 | if (branch->merge_nr == 1 && branch->merge[0]->src) { | |
| @@ -159,7 +162,7 @@ static NORETURN void die_push_simple(struct branch *branch, | |||
| 159 | 162 | * Don't show advice for people who explicitly set | |
| 160 | 163 | * push.default. | |
| 161 | 164 | */ | |
| 162 | - | if (push_default == PUSH_DEFAULT_UNSPECIFIED) | |
| 165 | + | if (cfg->push_default == PUSH_DEFAULT_UNSPECIFIED) | |
| 163 | 166 | advice_pushdefault_maybe = _("\n" | |
| 164 | 167 | "To choose either option permanently, " | |
| 165 | 168 | "see push.default in 'git help config'.\n"); | |
| @@ -230,8 +233,9 @@ static void setup_default_push_refspecs(int *flags, struct remote *remote) | |||
| 230 | 233 | struct branch *branch; | |
| 231 | 234 | const char *dst; | |
| 232 | 235 | int same_remote; | |
| 236 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 233 | 237 | ||
| 234 | - | switch (push_default) { | |
| 238 | + | switch (cfg->push_default) { | |
| 235 | 239 | case PUSH_DEFAULT_MATCHING: | |
| 236 | 240 | refspec_append(&rs, ":"); | |
| 237 | 241 | return; | |
| @@ -251,7 +255,7 @@ static void setup_default_push_refspecs(int *flags, struct remote *remote) | |||
| 251 | 255 | dst = branch->refname; | |
| 252 | 256 | same_remote = !strcmp(remote->name, remote_for_branch(branch, NULL)); | |
| 253 | 257 | ||
| 254 | - | switch (push_default) { | |
| 258 | + | switch (cfg->push_default) { | |
| 255 | 259 | default: | |
| 256 | 260 | case PUSH_DEFAULT_UNSPECIFIED: | |
| 257 | 261 | case PUSH_DEFAULT_SIMPLE: | |
| @@ -544,6 +548,146 @@ static int git_push_config(const char *k, const char *v, | |||
| 544 | 548 | return git_default_config(k, v, ctx, NULL); | |
| 545 | 549 | } | |
| 546 | 550 | ||
| 551 | + | static int push_multiple(struct string_list *list, | |
| 552 | + | const struct string_list *push_options, | |
| 553 | + | int flags, | |
| 554 | + | int tags, | |
| 555 | + | const char **refspecs, | |
| 556 | + | int refspec_nr) | |
| 557 | + | { | |
| 558 | + | int result = 0; | |
| 559 | + | size_t i; | |
| 560 | + | struct strvec argv = STRVEC_INIT; | |
| 561 | + | ||
| 562 | + | strvec_push(&argv, "push"); | |
| 563 | + | ||
| 564 | + | if (flags & TRANSPORT_PUSH_FORCE) | |
| 565 | + | strvec_push(&argv, "--force"); | |
| 566 | + | if (flags & TRANSPORT_PUSH_DRY_RUN) | |
| 567 | + | strvec_push(&argv, "--dry-run"); | |
| 568 | + | if (flags & TRANSPORT_PUSH_PORCELAIN) | |
| 569 | + | strvec_push(&argv, "--porcelain"); | |
| 570 | + | if (flags & TRANSPORT_PUSH_PRUNE) | |
| 571 | + | strvec_push(&argv, "--prune"); | |
| 572 | + | if (flags & TRANSPORT_PUSH_NO_HOOK) | |
| 573 | + | strvec_push(&argv, "--no-verify"); | |
| 574 | + | if (flags & TRANSPORT_PUSH_FOLLOW_TAGS) | |
| 575 | + | strvec_push(&argv, "--follow-tags"); | |
| 576 | + | if (flags & TRANSPORT_PUSH_SET_UPSTREAM) | |
| 577 | + | strvec_push(&argv, "--set-upstream"); | |
| 578 | + | if (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES) | |
| 579 | + | strvec_push(&argv, "--force-if-includes"); | |
| 580 | + | if (flags & TRANSPORT_PUSH_ALL) | |
| 581 | + | strvec_push(&argv, "--all"); | |
| 582 | + | if (flags & TRANSPORT_PUSH_MIRROR) | |
| 583 | + | strvec_push(&argv, "--mirror"); | |
| 584 | + | ||
| 585 | + | if (flags & TRANSPORT_PUSH_CERT_ALWAYS) | |
| 586 | + | strvec_push(&argv, "--signed=yes"); | |
| 587 | + | else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED) | |
| 588 | + | strvec_push(&argv, "--signed=if-asked"); | |
| 589 | + | if (!thin) | |
| 590 | + | strvec_push(&argv, "--no-thin"); | |
| 591 | + | ||
| 592 | + | if (deleterefs) | |
| 593 | + | strvec_push(&argv, "--delete"); | |
| 594 | + | ||
| 595 | + | if (receivepack) | |
| 596 | + | strvec_pushf(&argv, "--receive-pack=%s", receivepack); | |
| 597 | + | if (verbosity >= 2) | |
| 598 | + | strvec_push(&argv, "-v"); | |
| 599 | + | if (verbosity >= 1) | |
| 600 | + | strvec_push(&argv, "-v"); | |
| 601 | + | else if (verbosity < 0) | |
| 602 | + | strvec_push(&argv, "-q"); | |
| 603 | + | if (progress > 0) | |
| 604 | + | strvec_push(&argv, "--progress"); | |
| 605 | + | else if (progress == 0) | |
| 606 | + | strvec_push(&argv, "--no-progress"); | |
| 607 | + | ||
| 608 | + | if (family == TRANSPORT_FAMILY_IPV4) | |
| 609 | + | strvec_push(&argv, "--ipv4"); | |
| 610 | + | else if (family == TRANSPORT_FAMILY_IPV6) | |
| 611 | + | strvec_push(&argv, "--ipv6"); | |
| 612 | + | ||
| 613 | + | if (recurse_submodules == RECURSE_SUBMODULES_CHECK) | |
| 614 | + | strvec_push(&argv, "--recurse-submodules=check"); | |
| 615 | + | else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) | |
| 616 | + | strvec_push(&argv, "--recurse-submodules=on-demand"); | |
| 617 | + | else if (recurse_submodules == RECURSE_SUBMODULES_ONLY) | |
| 618 | + | strvec_push(&argv, "--recurse-submodules=only"); | |
| 619 | + | else if (recurse_submodules == RECURSE_SUBMODULES_OFF) | |
| 620 | + | strvec_push(&argv, "--recurse-submodules=no"); | |
| 621 | + | ||
| 622 | + | ||
| 623 | + | if (tags) | |
| 624 | + | strvec_push(&argv, "--tags"); | |
| 625 | + | ||
| 626 | + | for (i = 0; i < push_options->nr; i++) | |
| 627 | + | strvec_pushf(&argv, "--push-option=%s", | |
| 628 | + | push_options->items[i].string); | |
| 629 | + | ||
| 630 | + | for (i = 0; i < cas.nr; i++) { | |
| 631 | + | if (cas.entry[i].use_tracking) { | |
| 632 | + | strvec_pushf(&argv, "--force-with-lease=%s", | |
| 633 | + | cas.entry[i].refname); | |
| 634 | + | } else if (!is_null_oid(&cas.entry[i].expect)) { | |
| 635 | + | strvec_pushf(&argv, "--force-with-lease=%s:%s", | |
| 636 | + | cas.entry[i].refname, | |
| 637 | + | oid_to_hex(&cas.entry[i].expect)); | |
| 638 | + | } else { | |
| 639 | + | strvec_push(&argv, "--force-with-lease"); | |
| 640 | + | } | |
| 641 | + | } | |
| 642 | + | ||
| 643 | + | for (i = 0; i < list->nr; i++) { | |
| 644 | + | const char *name = list->items[i].string; | |
| 645 | + | struct child_process cmd = CHILD_PROCESS_INIT; | |
| 646 | + | int j; | |
| 647 | + | ||
| 648 | + | strvec_pushv(&cmd.args, argv.v); | |
| 649 | + | strvec_push(&cmd.args, name); | |
| 650 | + | ||
| 651 | + | for (j = 0; j < refspec_nr; j++) | |
| 652 | + | strvec_push(&cmd.args, refspecs[j]); | |
| 653 | + | ||
| 654 | + | if (verbosity >= 0) | |
| 655 | + | printf(_("Pushing to %s\n"), name); | |
| 656 | + | ||
| 657 | + | cmd.git_cmd = 1; | |
| 658 | + | if (run_command(&cmd)) { | |
| 659 | + | error(_("could not push to %s"), name); | |
| 660 | + | result = 1; | |
| 661 | + | } | |
| 662 | + | } | |
| 663 | + | ||
| 664 | + | strvec_clear(&argv); | |
| 665 | + | return result; | |
| 666 | + | } | |
| 667 | + | ||
| 668 | + | static void die_if_repo_looks_like_ref(const char *repo) | |
| 669 | + | { | |
| 670 | + | const char *slash = strchr(repo, '/'); | |
| 671 | + | struct strbuf name = STRBUF_INIT; | |
| 672 | + | int code; | |
| 673 | + | ||
| 674 | + | if (!slash || !slash[1] || file_exists(repo)) | |
| 675 | + | return; | |
| 676 | + | ||
| 677 | + | strbuf_add(&name, repo, slash - repo); | |
| 678 | + | if (!remote_is_configured(remote_get(name.buf), 0)) { | |
| 679 | + | strbuf_release(&name); | |
| 680 | + | return; | |
| 681 | + | } | |
| 682 | + | ||
| 683 | + | code = die_message(_("'%s' is not a valid push target"), repo); | |
| 684 | + | advise_if_enabled(ADVICE_PUSH_REPO_LOOKS_LIKE_REF, | |
| 685 | + | _("Did you mean to use: git push %s %s?"), | |
| 686 | + | name.buf, slash + 1); | |
| 687 | + | strbuf_release(&name); | |
| 688 | + | exit(code); | |
| 689 | + | } | |
| 690 | + | ||
| 547 | 691 | int cmd_push(int argc, | |
| 548 | 692 | const char **argv, | |
| 549 | 693 | const char *prefix, | |
| @@ -552,12 +696,13 @@ int cmd_push(int argc, | |||
| 552 | 696 | int flags = 0; | |
| 553 | 697 | int tags = 0; | |
| 554 | 698 | int push_cert = -1; | |
| 555 | - | int rc; | |
| 699 | + | int rc = 0; | |
| 700 | + | int base_flags; | |
| 556 | 701 | const char *repo = NULL; /* default repository */ | |
| 557 | 702 | struct string_list push_options_cmdline = STRING_LIST_INIT_DUP; | |
| 703 | + | struct string_list remote_group = STRING_LIST_INIT_DUP; | |
| 558 | 704 | struct string_list *push_options; | |
| 559 | 705 | const struct string_list_item *item; | |
| 560 | - | struct remote *remote; | |
| 561 | 706 | ||
| 562 | 707 | struct option options[] = { | |
| 563 | 708 | OPT__VERBOSITY(&verbosity), | |
| @@ -606,6 +751,8 @@ int cmd_push(int argc, | |||
| 606 | 751 | : &push_options_config); | |
| 607 | 752 | set_push_cert_flags(&flags, push_cert); | |
| 608 | 753 | ||
| 754 | + | refspec_init_push(&rs, the_hash_algo); | |
| 755 | + | ||
| 609 | 756 | die_for_incompatible_opt4(deleterefs, "--delete", | |
| 610 | 757 | tags, "--tags", | |
| 611 | 758 | flags & TRANSPORT_PUSH_ALL, "--all/--branches", | |
| @@ -620,39 +767,56 @@ int cmd_push(int argc, | |||
| 620 | 767 | else if (recurse_submodules == RECURSE_SUBMODULES_ONLY) | |
| 621 | 768 | flags |= TRANSPORT_RECURSE_SUBMODULES_ONLY; | |
| 622 | 769 | ||
| 623 | - | if (tags) | |
| 624 | - | refspec_append(&rs, "refs/tags/*"); | |
| 625 | - | ||
| 626 | 770 | if (argc > 0) | |
| 627 | 771 | repo = argv[0]; | |
| 628 | 772 | ||
| 629 | - | remote = pushremote_get(repo); | |
| 630 | - | if (!remote) { | |
| 631 | - | if (repo) | |
| 632 | - | die(_("bad repository '%s'"), repo); | |
| 633 | - | die(_("No configured push destination.\n" | |
| 634 | - | "Either specify the URL from the command-line or configure a remote repository using\n" | |
| 635 | - | "\n" | |
| 636 | - | " git remote add <name> <url>\n" | |
| 637 | - | "\n" | |
| 638 | - | "and then push using the remote name\n" | |
| 639 | - | "\n" | |
| 640 | - | " git push <name>\n")); | |
| 641 | - | } | |
| 642 | - | ||
| 643 | - | if (argc > 0) | |
| 644 | - | set_refspecs(argv + 1, argc - 1, remote); | |
| 645 | - | ||
| 646 | - | if (remote->mirror) | |
| 647 | - | flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE); | |
| 648 | - | ||
| 649 | - | if (flags & TRANSPORT_PUSH_ALL) { | |
| 650 | - | if (argc >= 2) | |
| 651 | - | die(_("--all can't be combined with refspecs")); | |
| 652 | - | } | |
| 653 | - | if (flags & TRANSPORT_PUSH_MIRROR) { | |
| 654 | - | if (argc >= 2) | |
| 655 | - | die(_("--mirror can't be combined with refspecs")); | |
| 773 | + | if (repo) { | |
| 774 | + | if (!add_remote_or_group(repo, &remote_group)) { | |
| 775 | + | struct remote *r; | |
| 776 | + | ||
| 777 | + | /* | |
| 778 | + | * Check the advice up front to avoid the remote | |
| 779 | + | * lookup when the hint is off. The helper still | |
| 780 | + | * calls advise_if_enabled() so the hint carries the | |
| 781 | + | * standard "disable this message" instructions. | |
| 782 | + | */ | |
| 783 | + | if (advice_enabled(ADVICE_PUSH_REPO_LOOKS_LIKE_REF)) | |
| 784 | + | die_if_repo_looks_like_ref(repo); | |
| 785 | + | ||
| 786 | + | /* | |
| 787 | + | * Not a configured remote name or group name. | |
| 788 | + | * Try treating it as a direct URL or path, e.g. | |
| 789 | + | * git push /tmp/foo.git | |
| 790 | + | * git push https://github.com/user/repo.git | |
| 791 | + | * pushremote_get() creates an anonymous remote | |
| 792 | + | * from the URL so the loop below can handle it | |
| 793 | + | * identically to a named remote. | |
| 794 | + | */ | |
| 795 | + | r = pushremote_get(repo); | |
| 796 | + | if (!r) | |
| 797 | + | die(_("bad repository '%s'"), repo); | |
| 798 | + | string_list_append(&remote_group, r->name); | |
| 799 | + | } | |
| 800 | + | } else { | |
| 801 | + | struct remote *r = pushremote_get(NULL); | |
| 802 | + | if (!r) | |
| 803 | + | die(_("No configured push destination.\n" | |
| 804 | + | "Either specify the URL from the command-line or configure a remote repository using\n" | |
| 805 | + | "\n" | |
| 806 | + | " git remote add <name> <url>\n" | |
| 807 | + | "\n" | |
| 808 | + | "and then push using the remote name\n" | |
| 809 | + | "\n" | |
| 810 | + | " git push <name>\n" | |
| 811 | + | "\n" | |
| 812 | + | "To push to multiple remotes at once, configure a remote group using\n" | |
| 813 | + | "\n" | |
| 814 | + | " git config remotes.<groupname> \"<remote1> <remote2>\"\n" | |
| 815 | + | "\n" | |
| 816 | + | "and then push using the group name\n" | |
| 817 | + | "\n" | |
| 818 | + | " git push <groupname>\n")); | |
| 819 | + | string_list_append(&remote_group, r->name); | |
| 656 | 820 | } | |
| 657 | 821 | ||
| 658 | 822 | if (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES)) | |
| @@ -662,10 +826,70 @@ int cmd_push(int argc, | |||
| 662 | 826 | if (strchr(item->string, '\n')) | |
| 663 | 827 | die(_("push options must not have new line characters")); | |
| 664 | 828 | ||
| 665 | - | rc = do_push(flags, push_options, remote); | |
| 829 | + | if (remote_group.nr == 1) { | |
| 830 | + | /* | |
| 831 | + | * Single remote (the common case): run do_push() directly | |
| 832 | + | * in this process. The loop runs exactly once. | |
| 833 | + | * | |
| 834 | + | * Mirror detection and the --mirror/--all + refspec conflict | |
| 835 | + | * checks are done here. rs is rebuilt so that per-remote push | |
| 836 | + | * mappings (remote.NAME.push config) are resolved against the | |
| 837 | + | * correct remote. inner_flags is a snapshot of flags so that a | |
| 838 | + | * mirror remote cannot bleed TRANSPORT_PUSH_FORCE into any | |
| 839 | + | * subsequent call. | |
| 840 | + | */ | |
| 841 | + | base_flags = flags; | |
| 842 | + | { | |
| 843 | + | int inner_flags = base_flags; | |
| 844 | + | struct remote *r = pushremote_get(remote_group.items[0].string); | |
| 845 | + | if (!r) | |
| 846 | + | die(_("no such remote or remote group: %s"), | |
| 847 | + | remote_group.items[0].string); | |
| 848 | + | ||
| 849 | + | if (r->mirror) | |
| 850 | + | inner_flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE); | |
| 851 | + | ||
| 852 | + | if (inner_flags & TRANSPORT_PUSH_ALL) { | |
| 853 | + | if (argc >= 2) | |
| 854 | + | die(_("--all can't be combined with refspecs")); | |
| 855 | + | } | |
| 856 | + | if (inner_flags & TRANSPORT_PUSH_MIRROR) { | |
| 857 | + | if (argc >= 2) | |
| 858 | + | die(_("--mirror can't be combined with refspecs")); | |
| 859 | + | } | |
| 860 | + | ||
| 861 | + | refspec_clear(&rs); | |
| 862 | + | rs = (struct refspec) REFSPEC_INIT_PUSH(the_hash_algo); | |
| 863 | + | ||
| 864 | + | if (tags) | |
| 865 | + | refspec_append(&rs, "refs/tags/*"); | |
| 866 | + | if (argc > 0) | |
| 867 | + | set_refspecs(argv + 1, argc - 1, r); | |
| 868 | + | ||
| 869 | + | rc = do_push(inner_flags, push_options, r); | |
| 870 | + | } | |
| 871 | + | } else { | |
| 872 | + | /* | |
| 873 | + | * Multiple remotes: spawn one "git push <remote> [<refspecs>]" | |
| 874 | + | * subprocess per remote, sequentially. | |
| 875 | + | * | |
| 876 | + | * Options that only make sense for a single transport connection | |
| 877 | + | * are rejected here. | |
| 878 | + | */ | |
| 879 | + | if (flags & TRANSPORT_PUSH_ATOMIC) | |
| 880 | + | die(_("--atomic can only be used when pushing to one remote")); | |
| 881 | + | ||
| 882 | + | rc = push_multiple(&remote_group, push_options, flags, | |
| 883 | + | tags, | |
| 884 | + | argc > 1 ? argv + 1 : NULL, | |
| 885 | + | argc > 1 ? argc - 1 : 0); | |
| 886 | + | } | |
| 887 | + | ||
| 666 | 888 | string_list_clear(&push_options_cmdline, 0); | |
| 667 | 889 | string_list_clear(&push_options_config, 0); | |
| 890 | + | string_list_clear(&remote_group, 0); | |
| 668 | 891 | clear_cas_option(&cas); | |
| 892 | + | ||
| 669 | 893 | if (rc == -1) | |
| 670 | 894 | usage_with_options(push_usage, options); | |
| 671 | 895 | else | |
modified builtin/read-tree.c
| @@ -229,7 +229,7 @@ int cmd_read_tree(int argc, | |||
| 229 | 229 | opts.preserve_ignored = 0; | |
| 230 | 230 | /* otherwise, opts.preserve_ignored is irrelevant */ | |
| 231 | 231 | if (opts.merge && !opts.index_only) | |
| 232 | - | setup_work_tree(); | |
| 232 | + | setup_work_tree(the_repository); | |
| 233 | 233 | ||
| 234 | 234 | if (opts.skip_sparse_checkout) | |
| 235 | 235 | ensure_full_index(the_repository->index); | |
modified builtin/rebase.c
| @@ -592,7 +592,7 @@ static int finish_rebase(struct rebase_options *opts) | |||
| 592 | 592 | static int move_to_original_branch(struct rebase_options *opts) | |
| 593 | 593 | { | |
| 594 | 594 | struct strbuf branch_reflog = STRBUF_INIT, head_reflog = STRBUF_INIT; | |
| 595 | - | struct reset_head_opts ropts = { 0 }; | |
| 595 | + | struct reset_working_tree_options ropts = { 0 }; | |
| 596 | 596 | int ret; | |
| 597 | 597 | ||
| 598 | 598 | if (!opts->head_name) | |
| @@ -607,10 +607,11 @@ static int move_to_original_branch(struct rebase_options *opts) | |||
| 607 | 607 | strbuf_addf(&head_reflog, "%s (finish): returning to %s", | |
| 608 | 608 | opts->reflog_action, opts->head_name); | |
| 609 | 609 | ropts.branch = opts->head_name; | |
| 610 | - | ropts.flags = RESET_HEAD_REFS_ONLY; | |
| 610 | + | ropts.flags = RESET_WORKING_TREE_REFS_ONLY | | |
| 611 | + | RESET_WORKING_TREE_UPDATE_HEAD; | |
| 611 | 612 | ropts.branch_msg = branch_reflog.buf; | |
| 612 | 613 | ropts.head_msg = head_reflog.buf; | |
| 613 | - | ret = reset_head(the_repository, &ropts); | |
| 614 | + | ret = reset_working_tree(the_repository, &ropts); | |
| 614 | 615 | ||
| 615 | 616 | strbuf_release(&branch_reflog); | |
| 616 | 617 | strbuf_release(&head_reflog); | |
| @@ -685,7 +686,7 @@ static int run_am(struct rebase_options *opts) | |||
| 685 | 686 | ||
| 686 | 687 | status = run_command(&format_patch); | |
| 687 | 688 | if (status) { | |
| 688 | - | struct reset_head_opts ropts = { 0 }; | |
| 689 | + | struct reset_working_tree_options ropts = { 0 }; | |
| 689 | 690 | unlink(rebased_patches); | |
| 690 | 691 | free(rebased_patches); | |
| 691 | 692 | child_process_clear(&am); | |
| @@ -693,7 +694,8 @@ static int run_am(struct rebase_options *opts) | |||
| 693 | 694 | ropts.oid = &opts->orig_head->object.oid; | |
| 694 | 695 | ropts.branch = opts->head_name; | |
| 695 | 696 | ropts.default_reflog_action = opts->reflog_action; | |
| 696 | - | reset_head(the_repository, &ropts); | |
| 697 | + | ropts.flags = RESET_WORKING_TREE_UPDATE_HEAD; | |
| 698 | + | reset_working_tree(the_repository, &ropts); | |
| 697 | 699 | error(_("\ngit encountered an error while preparing the " | |
| 698 | 700 | "patches to replay\n" | |
| 699 | 701 | "these revisions:\n" | |
| @@ -855,18 +857,19 @@ static int rebase_config(const char *var, const char *value, | |||
| 855 | 857 | static int checkout_up_to_date(struct rebase_options *options) | |
| 856 | 858 | { | |
| 857 | 859 | struct strbuf buf = STRBUF_INIT; | |
| 858 | - | struct reset_head_opts ropts = { 0 }; | |
| 860 | + | struct reset_working_tree_options ropts = { 0 }; | |
| 859 | 861 | int ret = 0; | |
| 860 | 862 | ||
| 861 | 863 | strbuf_addf(&buf, "%s: checkout %s", | |
| 862 | 864 | options->reflog_action, options->switch_to); | |
| 863 | 865 | ropts.oid = &options->orig_head->object.oid; | |
| 864 | 866 | ropts.branch = options->head_name; | |
| 865 | - | ropts.flags = RESET_HEAD_RUN_POST_CHECKOUT_HOOK; | |
| 867 | + | ropts.flags = RESET_WORKING_TREE_RUN_POST_CHECKOUT_HOOK | | |
| 868 | + | RESET_WORKING_TREE_UPDATE_HEAD; | |
| 866 | 869 | if (!ropts.branch) | |
| 867 | - | ropts.flags |= RESET_HEAD_DETACH; | |
| 870 | + | ropts.flags |= RESET_WORKING_TREE_DETACH; | |
| 868 | 871 | ropts.head_msg = buf.buf; | |
| 869 | - | if (reset_head(the_repository, &ropts) < 0) | |
| 872 | + | if (reset_working_tree(the_repository, &ropts) < 0) | |
| 870 | 873 | ret = error(_("could not switch to %s"), options->switch_to); | |
| 871 | 874 | strbuf_release(&buf); | |
| 872 | 875 | ||
| @@ -1116,7 +1119,7 @@ int cmd_rebase(int argc, | |||
| 1116 | 1119 | int reschedule_failed_exec = -1; | |
| 1117 | 1120 | int allow_preemptive_ff = 1; | |
| 1118 | 1121 | int preserve_merges_selected = 0; | |
| 1119 | - | struct reset_head_opts ropts = { 0 }; | |
| 1122 | + | struct reset_working_tree_options ropts = { 0 }; | |
| 1120 | 1123 | struct option builtin_rebase_options[] = { | |
| 1121 | 1124 | OPT_STRING(0, "onto", &options.onto_name, | |
| 1122 | 1125 | N_("revision"), | |
| @@ -1384,8 +1387,9 @@ int cmd_rebase(int argc, | |||
| 1384 | 1387 | ||
| 1385 | 1388 | rerere_clear(the_repository, &merge_rr); | |
| 1386 | 1389 | string_list_clear(&merge_rr, 1); | |
| 1387 | - | ropts.flags = RESET_HEAD_HARD; | |
| 1388 | - | if (reset_head(the_repository, &ropts) < 0) | |
| 1390 | + | ropts.flags = RESET_WORKING_TREE_HARD | | |
| 1391 | + | RESET_WORKING_TREE_UPDATE_HEAD; | |
| 1392 | + | if (reset_working_tree(the_repository, &ropts) < 0) | |
| 1389 | 1393 | die(_("could not discard worktree changes")); | |
| 1390 | 1394 | remove_branch_state(the_repository, 0); | |
| 1391 | 1395 | if (read_basic_state(&options)) | |
| @@ -1409,8 +1413,9 @@ int cmd_rebase(int argc, | |||
| 1409 | 1413 | ropts.oid = &options.orig_head->object.oid; | |
| 1410 | 1414 | ropts.head_msg = head_msg.buf; | |
| 1411 | 1415 | ropts.branch = options.head_name; | |
| 1412 | - | ropts.flags = RESET_HEAD_HARD; | |
| 1413 | - | if (reset_head(the_repository, &ropts) < 0) | |
| 1416 | + | ropts.flags = RESET_WORKING_TREE_HARD | | |
| 1417 | + | RESET_WORKING_TREE_UPDATE_HEAD; | |
| 1418 | + | if (reset_working_tree(the_repository, &ropts) < 0) | |
| 1414 | 1419 | die(_("could not move back to %s"), | |
| 1415 | 1420 | oid_to_hex(&options.orig_head->object.oid)); | |
| 1416 | 1421 | strbuf_release(&head_msg); | |
| @@ -1876,11 +1881,13 @@ int cmd_rebase(int argc, | |||
| 1876 | 1881 | options.reflog_action, options.onto_name); | |
| 1877 | 1882 | ropts.oid = &options.onto->object.oid; | |
| 1878 | 1883 | ropts.orig_head = &options.orig_head->object.oid; | |
| 1879 | - | ropts.flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD | | |
| 1880 | - | RESET_HEAD_RUN_POST_CHECKOUT_HOOK; | |
| 1884 | + | ropts.flags = RESET_WORKING_TREE_DETACH | | |
| 1885 | + | RESET_WORKING_TREE_UPDATE_HEAD | | |
| 1886 | + | RESET_WORKING_TREE_UPDATE_ORIG_HEAD | | |
| 1887 | + | RESET_WORKING_TREE_RUN_POST_CHECKOUT_HOOK; | |
| 1881 | 1888 | ropts.head_msg = msg.buf; | |
| 1882 | 1889 | ropts.default_reflog_action = options.reflog_action; | |
| 1883 | - | if (reset_head(the_repository, &ropts)) { | |
| 1890 | + | if (reset_working_tree(the_repository, &ropts)) { | |
| 1884 | 1891 | ret = error(_("Could not detach HEAD")); | |
| 1885 | 1892 | goto cleanup_autostash; | |
| 1886 | 1893 | } | |
modified builtin/receive-pack.c
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | #include "gpg-interface.h" | |
| 16 | 16 | #include "hex.h" | |
| 17 | 17 | #include "hook.h" | |
| 18 | - | #include "lockfile.h" | |
| 19 | 18 | #include "object.h" | |
| 20 | 19 | #include "object-file.h" | |
| 21 | 20 | #include "object-name.h" | |
| @@ -23,7 +22,6 @@ | |||
| 23 | 22 | #include "oid-array.h" | |
| 24 | 23 | #include "oidset.h" | |
| 25 | 24 | #include "pack.h" | |
| 26 | - | #include "packfile.h" | |
| 27 | 25 | #include "parse-options.h" | |
| 28 | 26 | #include "pkt-line.h" | |
| 29 | 27 | #include "protocol.h" | |
| @@ -37,7 +35,6 @@ | |||
| 37 | 35 | #include "sigchain.h" | |
| 38 | 36 | #include "string-list.h" | |
| 39 | 37 | #include "strvec.h" | |
| 40 | - | #include "tmp-objdir.h" | |
| 41 | 38 | #include "trace.h" | |
| 42 | 39 | #include "trace2.h" | |
| 43 | 40 | #include "version.h" | |
| @@ -63,12 +60,9 @@ static enum deny_action deny_delete_current = DENY_UNCONFIGURED; | |||
| 63 | 60 | static int receive_fsck_objects = -1; | |
| 64 | 61 | static int transfer_fsck_objects = -1; | |
| 65 | 62 | static struct strbuf fsck_msg_types = STRBUF_INIT; | |
| 66 | - | static int receive_unpack_limit = -1; | |
| 67 | - | static int transfer_unpack_limit = -1; | |
| 68 | 63 | static int advertise_atomic_push = 1; | |
| 69 | 64 | static int advertise_push_options; | |
| 70 | 65 | static int advertise_sid; | |
| 71 | - | static int unpack_limit = 100; | |
| 72 | 66 | static off_t max_input_size; | |
| 73 | 67 | static int report_status; | |
| 74 | 68 | static int report_status_v2; | |
| @@ -87,7 +81,6 @@ static const char *head_name; | |||
| 87 | 81 | static void *head_name_to_free; | |
| 88 | 82 | static int sent_capabilities; | |
| 89 | 83 | static int shallow_update; | |
| 90 | - | static const char *alt_shallow_file; | |
| 91 | 84 | static struct strbuf push_cert = STRBUF_INIT; | |
| 92 | 85 | static struct object_id push_cert_oid; | |
| 93 | 86 | static struct signature_check sigcheck; | |
| @@ -112,8 +105,6 @@ static enum { | |||
| 112 | 105 | } use_keepalive; | |
| 113 | 106 | static int keepalive_in_sec = 5; | |
| 114 | 107 | ||
| 115 | - | static struct tmp_objdir *tmp_objdir; | |
| 116 | - | ||
| 117 | 108 | static struct proc_receive_ref { | |
| 118 | 109 | unsigned int want_add:1, | |
| 119 | 110 | want_delete:1, | |
| @@ -161,16 +152,6 @@ static int receive_pack_config(const char *var, const char *value, | |||
| 161 | 152 | return 0; | |
| 162 | 153 | } | |
| 163 | 154 | ||
| 164 | - | if (strcmp(var, "receive.unpacklimit") == 0) { | |
| 165 | - | receive_unpack_limit = git_config_int(var, value, ctx->kvi); | |
| 166 | - | return 0; | |
| 167 | - | } | |
| 168 | - | ||
| 169 | - | if (strcmp(var, "transfer.unpacklimit") == 0) { | |
| 170 | - | transfer_unpack_limit = git_config_int(var, value, ctx->kvi); | |
| 171 | - | return 0; | |
| 172 | - | } | |
| 173 | - | ||
| 174 | 155 | if (strcmp(var, "receive.fsck.skiplist") == 0) { | |
| 175 | 156 | char *path; | |
| 176 | 157 | ||
| @@ -615,7 +596,7 @@ static void hmac_hash(unsigned char *out, | |||
| 615 | 596 | /* RFC 2104 2. (1) */ | |
| 616 | 597 | memset(key, '\0', GIT_MAX_BLKSZ); | |
| 617 | 598 | if (the_hash_algo->blksz < key_len) { | |
| 618 | - | the_hash_algo->init_fn(&ctx); | |
| 599 | + | git_hash_init(&ctx, the_hash_algo); | |
| 619 | 600 | git_hash_update(&ctx, key_in, key_len); | |
| 620 | 601 | git_hash_final(key, &ctx); | |
| 621 | 602 | } else { | |
| @@ -629,13 +610,13 @@ static void hmac_hash(unsigned char *out, | |||
| 629 | 610 | } | |
| 630 | 611 | ||
| 631 | 612 | /* RFC 2104 2. (3) & (4) */ | |
| 632 | - | the_hash_algo->init_fn(&ctx); | |
| 613 | + | git_hash_init(&ctx, the_hash_algo); | |
| 633 | 614 | git_hash_update(&ctx, k_ipad, sizeof(k_ipad)); | |
| 634 | 615 | git_hash_update(&ctx, text, text_len); | |
| 635 | 616 | git_hash_final(out, &ctx); | |
| 636 | 617 | ||
| 637 | 618 | /* RFC 2104 2. (6) & (7) */ | |
| 638 | - | the_hash_algo->init_fn(&ctx); | |
| 619 | + | git_hash_init(&ctx, the_hash_algo); | |
| 639 | 620 | git_hash_update(&ctx, k_opad, sizeof(k_opad)); | |
| 640 | 621 | git_hash_update(&ctx, out, the_hash_algo->rawsz); | |
| 641 | 622 | git_hash_final(out, &ctx); | |
| @@ -926,6 +907,7 @@ static void receive_hook_feed_state_free(void *data) | |||
| 926 | 907 | static int run_receive_hook(struct command *commands, | |
| 927 | 908 | const char *hook_name, | |
| 928 | 909 | int skip_broken, | |
| 910 | + | struct odb_transaction *transaction, | |
| 929 | 911 | const struct string_list *push_options) | |
| 930 | 912 | { | |
| 931 | 913 | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT; | |
| @@ -959,8 +941,8 @@ static int run_receive_hook(struct command *commands, | |||
| 959 | 941 | strvec_push(&opt.env, "GIT_PUSH_OPTION_COUNT"); | |
| 960 | 942 | } | |
| 961 | 943 | ||
| 962 | - | if (tmp_objdir) | |
| 963 | - | strvec_pushv(&opt.env, tmp_objdir_env(tmp_objdir)); | |
| 944 | + | if (transaction) | |
| 945 | + | odb_transaction_env(transaction, &opt.env); | |
| 964 | 946 | ||
| 965 | 947 | prepare_push_cert_sha1(&opt); | |
| 966 | 948 | ||
| @@ -1363,7 +1345,6 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si) | |||
| 1363 | 1345 | !delayed_reachability_test(si, i)) | |
| 1364 | 1346 | oid_array_append(&extra, &si->shallow->oid[i]); | |
| 1365 | 1347 | ||
| 1366 | - | opt.env = tmp_objdir_env(tmp_objdir); | |
| 1367 | 1348 | setup_alternate_shallow(&shallow_lock, &opt.shallow_file, &extra); | |
| 1368 | 1349 | if (check_connected(command_singleton_iterator, cmd, &opt)) { | |
| 1369 | 1350 | rollback_shallow_file(the_repository, &shallow_lock); | |
| @@ -1456,11 +1437,12 @@ static const char *push_to_checkout(unsigned char *hash, | |||
| 1456 | 1437 | struct strvec *env, | |
| 1457 | 1438 | const char *work_tree) | |
| 1458 | 1439 | { | |
| 1459 | - | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT; | |
| 1440 | + | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; | |
| 1441 | + | ||
| 1460 | 1442 | opt.invoked_hook = invoked_hook; | |
| 1461 | 1443 | ||
| 1462 | - | strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree)); | |
| 1463 | 1444 | strvec_pushv(&opt.env, env->v); | |
| 1445 | + | strvec_pushf(&opt.env, "GIT_WORK_TREE=%s", absolute_path(work_tree)); | |
| 1464 | 1446 | strvec_push(&opt.args, hash_to_hex(hash)); | |
| 1465 | 1447 | if (run_hooks_opt(the_repository, push_to_checkout_hook, &opt)) | |
| 1466 | 1448 | return "push-to-checkout hook declined"; | |
| @@ -1502,7 +1484,7 @@ static const char *update(struct command *cmd, struct shallow_info *si) | |||
| 1502 | 1484 | struct object_id *old_oid = &cmd->old_oid; | |
| 1503 | 1485 | struct object_id *new_oid = &cmd->new_oid; | |
| 1504 | 1486 | int do_update_worktree = 0; | |
| 1505 | - | struct worktree **worktrees = get_worktrees(); | |
| 1487 | + | struct worktree **worktrees = get_worktrees(the_repository); | |
| 1506 | 1488 | const struct worktree *worktree = | |
| 1507 | 1489 | find_shared_symref(worktrees, "HEAD", name); | |
| 1508 | 1490 | ||
| @@ -1641,8 +1623,8 @@ static const char *update(struct command *cmd, struct shallow_info *si) | |||
| 1641 | 1623 | ret = NULL; /* good */ | |
| 1642 | 1624 | } | |
| 1643 | 1625 | strbuf_release(&err); | |
| 1644 | - | } | |
| 1645 | - | else { | |
| 1626 | + | } else { | |
| 1627 | + | enum ref_transaction_error tx_err; | |
| 1646 | 1628 | struct strbuf err = STRBUF_INIT; | |
| 1647 | 1629 | if (shallow_update && si->shallow_ref[cmd->index] && | |
| 1648 | 1630 | update_shallow_ref(cmd, si)) { | |
| @@ -1650,14 +1632,18 @@ static const char *update(struct command *cmd, struct shallow_info *si) | |||
| 1650 | 1632 | goto out; | |
| 1651 | 1633 | } | |
| 1652 | 1634 | ||
| 1653 | - | if (ref_transaction_update(transaction, | |
| 1654 | - | namespaced_name, | |
| 1655 | - | new_oid, old_oid, | |
| 1656 | - | NULL, NULL, | |
| 1657 | - | 0, "push", | |
| 1658 | - | &err)) { | |
| 1635 | + | tx_err = ref_transaction_update(transaction, | |
| 1636 | + | namespaced_name, | |
| 1637 | + | new_oid, old_oid, | |
| 1638 | + | NULL, NULL, | |
| 1639 | + | 0, "push", | |
| 1640 | + | &err); | |
| 1641 | + | if (tx_err) { | |
| 1659 | 1642 | rp_error("%s", err.buf); | |
| 1660 | - | ret = "failed to update ref"; | |
| 1643 | + | if (tx_err == REF_TRANSACTION_ERROR_GENERIC) | |
| 1644 | + | ret = "failed to update ref"; | |
| 1645 | + | else | |
| 1646 | + | ret = ref_transaction_error_msg(tx_err); | |
| 1661 | 1647 | } else { | |
| 1662 | 1648 | ret = NULL; /* good */ | |
| 1663 | 1649 | } | |
| @@ -1785,24 +1771,30 @@ static const struct object_id *command_singleton_iterator(void *cb_data) | |||
| 1785 | 1771 | } | |
| 1786 | 1772 | ||
| 1787 | 1773 | static void set_connectivity_errors(struct command *commands, | |
| 1788 | - | struct shallow_info *si) | |
| 1774 | + | struct shallow_info *si, | |
| 1775 | + | struct odb_transaction *transaction) | |
| 1789 | 1776 | { | |
| 1790 | 1777 | struct command *cmd; | |
| 1791 | 1778 | ||
| 1792 | 1779 | for (cmd = commands; cmd; cmd = cmd->next) { | |
| 1793 | 1780 | struct command *singleton = cmd; | |
| 1794 | 1781 | struct check_connected_options opt = CHECK_CONNECTED_INIT; | |
| 1782 | + | struct strvec env = STRVEC_INIT; | |
| 1795 | 1783 | ||
| 1796 | 1784 | if (shallow_update && si->shallow_ref[cmd->index]) | |
| 1797 | 1785 | /* to be checked in update_shallow_ref() */ | |
| 1798 | 1786 | continue; | |
| 1799 | 1787 | ||
| 1800 | - | opt.env = tmp_objdir_env(tmp_objdir); | |
| 1788 | + | odb_transaction_env(transaction, &env); | |
| 1789 | + | opt.env = env.v; | |
| 1790 | + | ||
| 1801 | 1791 | if (!check_connected(command_singleton_iterator, &singleton, | |
| 1802 | 1792 | &opt)) | |
| 1803 | 1793 | continue; | |
| 1804 | 1794 | ||
| 1805 | 1795 | cmd->error_string = "missing necessary objects"; | |
| 1796 | + | ||
| 1797 | + | strvec_clear(&env); | |
| 1806 | 1798 | } | |
| 1807 | 1799 | } | |
| 1808 | 1800 | ||
| @@ -2021,8 +2013,9 @@ cleanup: | |||
| 2021 | 2013 | } | |
| 2022 | 2014 | ||
| 2023 | 2015 | static void execute_commands(struct command *commands, | |
| 2024 | - | const char *unpacker_error, | |
| 2016 | + | int unpacker_error, | |
| 2025 | 2017 | struct shallow_info *si, | |
| 2018 | + | struct odb_transaction *transaction, | |
| 2026 | 2019 | const struct string_list *push_options) | |
| 2027 | 2020 | { | |
| 2028 | 2021 | struct check_connected_options opt = CHECK_CONNECTED_INIT; | |
| @@ -2039,6 +2032,8 @@ static void execute_commands(struct command *commands, | |||
| 2039 | 2032 | } | |
| 2040 | 2033 | ||
| 2041 | 2034 | if (!skip_connectivity_check) { | |
| 2035 | + | struct strvec env = STRVEC_INIT; | |
| 2036 | + | ||
| 2042 | 2037 | if (use_sideband) { | |
| 2043 | 2038 | memset(&muxer, 0, sizeof(muxer)); | |
| 2044 | 2039 | muxer.proc = copy_to_sideband; | |
| @@ -2052,14 +2047,17 @@ static void execute_commands(struct command *commands, | |||
| 2052 | 2047 | data.si = si; | |
| 2053 | 2048 | opt.err_fd = err_fd; | |
| 2054 | 2049 | opt.progress = err_fd && !quiet; | |
| 2055 | - | opt.env = tmp_objdir_env(tmp_objdir); | |
| 2050 | + | odb_transaction_env(transaction, &env); | |
| 2051 | + | opt.env = env.v; | |
| 2056 | 2052 | opt.exclude_hidden_refs_section = "receive"; | |
| 2057 | 2053 | ||
| 2058 | 2054 | if (check_connected(iterate_receive_command_list, &data, &opt)) | |
| 2059 | - | set_connectivity_errors(commands, si); | |
| 2055 | + | set_connectivity_errors(commands, si, transaction); | |
| 2060 | 2056 | ||
| 2061 | 2057 | if (use_sideband) | |
| 2062 | 2058 | finish_async(&muxer); | |
| 2059 | + | ||
| 2060 | + | strvec_clear(&env); | |
| 2063 | 2061 | } | |
| 2064 | 2062 | ||
| 2065 | 2063 | reject_updates_to_hidden(commands); | |
| @@ -2080,7 +2078,7 @@ static void execute_commands(struct command *commands, | |||
| 2080 | 2078 | } | |
| 2081 | 2079 | } | |
| 2082 | 2080 | ||
| 2083 | - | if (run_receive_hook(commands, "pre-receive", 0, push_options)) { | |
| 2081 | + | if (run_receive_hook(commands, "pre-receive", 0, transaction, push_options)) { | |
| 2084 | 2082 | for (cmd = commands; cmd; cmd = cmd->next) { | |
| 2085 | 2083 | if (!cmd->error_string) | |
| 2086 | 2084 | cmd->error_string = "pre-receive hook declined"; | |
| @@ -2101,14 +2099,13 @@ static void execute_commands(struct command *commands, | |||
| 2101 | 2099 | * Now we'll start writing out refs, which means the objects need | |
| 2102 | 2100 | * to be in their final positions so that other processes can see them. | |
| 2103 | 2101 | */ | |
| 2104 | - | if (tmp_objdir_migrate(tmp_objdir) < 0) { | |
| 2102 | + | if (odb_transaction_commit(transaction)) { | |
| 2105 | 2103 | for (cmd = commands; cmd; cmd = cmd->next) { | |
| 2106 | 2104 | if (!cmd->error_string) | |
| 2107 | 2105 | cmd->error_string = "unable to migrate objects to permanent storage"; | |
| 2108 | 2106 | } | |
| 2109 | 2107 | return; | |
| 2110 | 2108 | } | |
| 2111 | - | tmp_objdir = NULL; | |
| 2112 | 2109 | ||
| 2113 | 2110 | check_aliased_updates(commands); | |
| 2114 | 2111 | ||
| @@ -2293,161 +2290,44 @@ static void read_push_options(struct packet_reader *reader, | |||
| 2293 | 2290 | } | |
| 2294 | 2291 | } | |
| 2295 | 2292 | ||
| 2296 | - | static const char *parse_pack_header(struct pack_header *hdr) | |
| 2297 | - | { | |
| 2298 | - | switch (read_pack_header(0, hdr)) { | |
| 2299 | - | case PH_ERROR_EOF: | |
| 2300 | - | return "eof before pack header was fully read"; | |
| 2301 | - | ||
| 2302 | - | case PH_ERROR_PACK_SIGNATURE: | |
| 2303 | - | return "protocol error (pack signature mismatch detected)"; | |
| 2304 | - | ||
| 2305 | - | case PH_ERROR_PROTOCOL: | |
| 2306 | - | return "protocol error (pack version unsupported)"; | |
| 2307 | - | ||
| 2308 | - | default: | |
| 2309 | - | return "unknown error in parse_pack_header"; | |
| 2310 | - | ||
| 2311 | - | case 0: | |
| 2312 | - | return NULL; | |
| 2313 | - | } | |
| 2314 | - | } | |
| 2315 | - | ||
| 2316 | - | static struct tempfile *pack_lockfile; | |
| 2317 | - | ||
| 2318 | - | static void push_header_arg(struct strvec *args, struct pack_header *hdr) | |
| 2319 | - | { | |
| 2320 | - | strvec_pushf(args, "--pack_header=%"PRIu32",%"PRIu32, | |
| 2321 | - | ntohl(hdr->hdr_version), ntohl(hdr->hdr_entries)); | |
| 2322 | - | } | |
| 2323 | - | ||
| 2324 | - | static const char *unpack(int err_fd, struct shallow_info *si) | |
| 2325 | - | { | |
| 2326 | - | struct pack_header hdr; | |
| 2327 | - | const char *hdr_err; | |
| 2328 | - | int status; | |
| 2329 | - | struct child_process child = CHILD_PROCESS_INIT; | |
| 2330 | - | int fsck_objects = (receive_fsck_objects >= 0 | |
| 2331 | - | ? receive_fsck_objects | |
| 2332 | - | : transfer_fsck_objects >= 0 | |
| 2333 | - | ? transfer_fsck_objects | |
| 2334 | - | : 0); | |
| 2335 | - | ||
| 2336 | - | hdr_err = parse_pack_header(&hdr); | |
| 2337 | - | if (hdr_err) { | |
| 2338 | - | if (err_fd > 0) | |
| 2339 | - | close(err_fd); | |
| 2340 | - | return hdr_err; | |
| 2341 | - | } | |
| 2342 | - | ||
| 2343 | - | if (si->nr_ours || si->nr_theirs) { | |
| 2344 | - | alt_shallow_file = setup_temporary_shallow(si->shallow); | |
| 2345 | - | strvec_push(&child.args, "--shallow-file"); | |
| 2346 | - | strvec_push(&child.args, alt_shallow_file); | |
| 2347 | - | } | |
| 2348 | - | ||
| 2349 | - | tmp_objdir = tmp_objdir_create(the_repository, "incoming"); | |
| 2350 | - | if (!tmp_objdir) { | |
| 2351 | - | if (err_fd > 0) | |
| 2352 | - | close(err_fd); | |
| 2353 | - | return "unable to create temporary object directory"; | |
| 2354 | - | } | |
| 2355 | - | strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir)); | |
| 2356 | - | ||
| 2357 | - | /* | |
| 2358 | - | * Normally we just pass the tmp_objdir environment to the child | |
| 2359 | - | * processes that do the heavy lifting, but we may need to see these | |
| 2360 | - | * objects ourselves to set up shallow information. | |
| 2361 | - | */ | |
| 2362 | - | tmp_objdir_add_as_alternate(tmp_objdir); | |
| 2363 | - | ||
| 2364 | - | if (ntohl(hdr.hdr_entries) < unpack_limit) { | |
| 2365 | - | strvec_push(&child.args, "unpack-objects"); | |
| 2366 | - | push_header_arg(&child.args, &hdr); | |
| 2367 | - | if (quiet) | |
| 2368 | - | strvec_push(&child.args, "-q"); | |
| 2369 | - | if (fsck_objects) | |
| 2370 | - | strvec_pushf(&child.args, "--strict%s", | |
| 2371 | - | fsck_msg_types.buf); | |
| 2372 | - | if (max_input_size) | |
| 2373 | - | strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX, | |
| 2374 | - | (uintmax_t)max_input_size); | |
| 2375 | - | child.no_stdout = 1; | |
| 2376 | - | child.err = err_fd; | |
| 2377 | - | child.git_cmd = 1; | |
| 2378 | - | status = run_command(&child); | |
| 2379 | - | if (status) | |
| 2380 | - | return "unpack-objects abnormal exit"; | |
| 2381 | - | } else { | |
| 2382 | - | char hostname[HOST_NAME_MAX + 1]; | |
| 2383 | - | char *lockfile; | |
| 2384 | - | ||
| 2385 | - | strvec_pushl(&child.args, "index-pack", "--stdin", NULL); | |
| 2386 | - | push_header_arg(&child.args, &hdr); | |
| 2387 | - | ||
| 2388 | - | if (xgethostname(hostname, sizeof(hostname))) | |
| 2389 | - | xsnprintf(hostname, sizeof(hostname), "localhost"); | |
| 2390 | - | strvec_pushf(&child.args, | |
| 2391 | - | "--keep=receive-pack %"PRIuMAX" on %s", | |
| 2392 | - | (uintmax_t)getpid(), | |
| 2393 | - | hostname); | |
| 2394 | - | ||
| 2395 | - | if (!quiet && err_fd) | |
| 2396 | - | strvec_push(&child.args, "--show-resolving-progress"); | |
| 2397 | - | if (use_sideband) | |
| 2398 | - | strvec_push(&child.args, "--report-end-of-input"); | |
| 2399 | - | if (fsck_objects) | |
| 2400 | - | strvec_pushf(&child.args, "--strict%s", | |
| 2401 | - | fsck_msg_types.buf); | |
| 2402 | - | if (!reject_thin) | |
| 2403 | - | strvec_push(&child.args, "--fix-thin"); | |
| 2404 | - | if (max_input_size) | |
| 2405 | - | strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX, | |
| 2406 | - | (uintmax_t)max_input_size); | |
| 2407 | - | child.out = -1; | |
| 2408 | - | child.err = err_fd; | |
| 2409 | - | child.git_cmd = 1; | |
| 2410 | - | status = start_command(&child); | |
| 2411 | - | if (status) | |
| 2412 | - | return "index-pack fork failed"; | |
| 2413 | - | ||
| 2414 | - | lockfile = index_pack_lockfile(the_repository, child.out, NULL); | |
| 2415 | - | if (lockfile) { | |
| 2416 | - | pack_lockfile = register_tempfile(lockfile); | |
| 2417 | - | free(lockfile); | |
| 2418 | - | } | |
| 2419 | - | close(child.out); | |
| 2420 | - | ||
| 2421 | - | status = finish_command(&child); | |
| 2422 | - | if (status) | |
| 2423 | - | return "index-pack abnormal exit"; | |
| 2424 | - | odb_reprepare(the_repository->objects); | |
| 2425 | - | } | |
| 2426 | - | return NULL; | |
| 2427 | - | } | |
| 2428 | - | ||
| 2429 | - | static const char *unpack_with_sideband(struct shallow_info *si) | |
| 2293 | + | static int unpack_with_sideband(struct odb_transaction *transaction, | |
| 2294 | + | const char *shallow_file, | |
| 2295 | + | struct strbuf *err_msg) | |
| 2430 | 2296 | { | |
| 2297 | + | struct odb_transaction_write_pack_opts opts = { | |
| 2298 | + | .fsck_objects = (receive_fsck_objects >= 0 | |
| 2299 | + | ? receive_fsck_objects | |
| 2300 | + | : transfer_fsck_objects >= 0 | |
| 2301 | + | ? transfer_fsck_objects | |
| 2302 | + | : 0), | |
| 2303 | + | .fsck_msg_types = fsck_msg_types.buf, | |
| 2304 | + | .max_input_size = max_input_size, | |
| 2305 | + | .shallow_file = shallow_file, | |
| 2306 | + | .reject_thin = reject_thin, | |
| 2307 | + | .quiet = quiet, | |
| 2308 | + | }; | |
| 2431 | 2309 | struct async muxer; | |
| 2432 | - | const char *ret; | |
| 2310 | + | int ret; | |
| 2433 | 2311 | ||
| 2434 | 2312 | if (!use_sideband) | |
| 2435 | - | return unpack(0, si); | |
| 2313 | + | return odb_transaction_write_pack(transaction, 0, err_msg, &opts); | |
| 2436 | 2314 | ||
| 2437 | 2315 | use_keepalive = KEEPALIVE_AFTER_NUL; | |
| 2438 | 2316 | memset(&muxer, 0, sizeof(muxer)); | |
| 2439 | 2317 | muxer.proc = copy_to_sideband; | |
| 2440 | 2318 | muxer.in = -1; | |
| 2441 | 2319 | if (start_async(&muxer)) | |
| 2442 | - | return NULL; | |
| 2320 | + | return 0; | |
| 2443 | 2321 | ||
| 2444 | - | ret = unpack(muxer.in, si); | |
| 2322 | + | opts.err_fd = muxer.in; | |
| 2323 | + | ret = odb_transaction_write_pack(transaction, 0, err_msg, &opts); | |
| 2445 | 2324 | ||
| 2446 | 2325 | finish_async(&muxer); | |
| 2447 | 2326 | return ret; | |
| 2448 | 2327 | } | |
| 2449 | 2328 | ||
| 2450 | - | static void prepare_shallow_update(struct shallow_info *si) | |
| 2329 | + | static void prepare_shallow_update(struct shallow_info *si, | |
| 2330 | + | const char *shallow_file) | |
| 2451 | 2331 | { | |
| 2452 | 2332 | int i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32); | |
| 2453 | 2333 | ||
| @@ -2487,12 +2367,13 @@ static void prepare_shallow_update(struct shallow_info *si) | |||
| 2487 | 2367 | * command. check_connected() will be done with | |
| 2488 | 2368 | * true .git/shallow though. | |
| 2489 | 2369 | */ | |
| 2490 | - | setenv(GIT_SHALLOW_FILE_ENVIRONMENT, alt_shallow_file, 1); | |
| 2370 | + | setenv(GIT_SHALLOW_FILE_ENVIRONMENT, shallow_file, 1); | |
| 2491 | 2371 | } | |
| 2492 | 2372 | ||
| 2493 | 2373 | static void update_shallow_info(struct command *commands, | |
| 2494 | 2374 | struct shallow_info *si, | |
| 2495 | - | struct oid_array *ref) | |
| 2375 | + | struct oid_array *ref, | |
| 2376 | + | const char *shallow_file) | |
| 2496 | 2377 | { | |
| 2497 | 2378 | struct command *cmd; | |
| 2498 | 2379 | int *ref_status; | |
| @@ -2511,7 +2392,7 @@ static void update_shallow_info(struct command *commands, | |||
| 2511 | 2392 | si->ref = ref; | |
| 2512 | 2393 | ||
| 2513 | 2394 | if (shallow_update) { | |
| 2514 | - | prepare_shallow_update(si); | |
| 2395 | + | prepare_shallow_update(si, shallow_file); | |
| 2515 | 2396 | return; | |
| 2516 | 2397 | } | |
| 2517 | 2398 | ||
| @@ -2528,13 +2409,13 @@ static void update_shallow_info(struct command *commands, | |||
| 2528 | 2409 | free(ref_status); | |
| 2529 | 2410 | } | |
| 2530 | 2411 | ||
| 2531 | - | static void report(struct command *commands, const char *unpack_status) | |
| 2412 | + | static void report(struct command *commands, const struct strbuf *unpack_status) | |
| 2532 | 2413 | { | |
| 2533 | 2414 | struct command *cmd; | |
| 2534 | 2415 | struct strbuf buf = STRBUF_INIT; | |
| 2535 | 2416 | ||
| 2536 | 2417 | packet_buf_write(&buf, "unpack %s\n", | |
| 2537 | - | unpack_status ? unpack_status : "ok"); | |
| 2418 | + | unpack_status->len ? unpack_status->buf : "ok"); | |
| 2538 | 2419 | for (cmd = commands; cmd; cmd = cmd->next) { | |
| 2539 | 2420 | if (!cmd->error_string) | |
| 2540 | 2421 | packet_buf_write(&buf, "ok %s\n", | |
| @@ -2552,14 +2433,14 @@ static void report(struct command *commands, const char *unpack_status) | |||
| 2552 | 2433 | strbuf_release(&buf); | |
| 2553 | 2434 | } | |
| 2554 | 2435 | ||
| 2555 | - | static void report_v2(struct command *commands, const char *unpack_status) | |
| 2436 | + | static void report_v2(struct command *commands, const struct strbuf *unpack_status) | |
| 2556 | 2437 | { | |
| 2557 | 2438 | struct command *cmd; | |
| 2558 | 2439 | struct strbuf buf = STRBUF_INIT; | |
| 2559 | 2440 | struct ref_push_report *report; | |
| 2560 | 2441 | ||
| 2561 | 2442 | packet_buf_write(&buf, "unpack %s\n", | |
| 2562 | - | unpack_status ? unpack_status : "ok"); | |
| 2443 | + | unpack_status->len ? unpack_status->buf : "ok"); | |
| 2563 | 2444 | for (cmd = commands; cmd; cmd = cmd->next) { | |
| 2564 | 2445 | int count = 0; | |
| 2565 | 2446 | ||
| @@ -2618,6 +2499,7 @@ int cmd_receive_pack(int argc, | |||
| 2618 | 2499 | struct oid_array ref = OID_ARRAY_INIT; | |
| 2619 | 2500 | struct shallow_info si; | |
| 2620 | 2501 | struct packet_reader reader; | |
| 2502 | + | struct odb_transaction *transaction = NULL; | |
| 2621 | 2503 | ||
| 2622 | 2504 | struct option options[] = { | |
| 2623 | 2505 | OPT__QUIET(&quiet, N_("quiet")), | |
| @@ -2642,18 +2524,13 @@ int cmd_receive_pack(int argc, | |||
| 2642 | 2524 | ||
| 2643 | 2525 | setup_path(); | |
| 2644 | 2526 | ||
| 2645 | - | if (!enter_repo(service_dir, 0)) | |
| 2527 | + | if (!enter_repo(the_repository, service_dir, 0)) | |
| 2646 | 2528 | die("'%s' does not appear to be a git repository", service_dir); | |
| 2647 | 2529 | ||
| 2648 | 2530 | repo_config(the_repository, receive_pack_config, NULL); | |
| 2649 | 2531 | if (cert_nonce_seed) | |
| 2650 | 2532 | push_cert_nonce = prepare_push_cert_nonce(service_dir, time(NULL)); | |
| 2651 | 2533 | ||
| 2652 | - | if (0 <= receive_unpack_limit) | |
| 2653 | - | unpack_limit = receive_unpack_limit; | |
| 2654 | - | else if (0 <= transfer_unpack_limit) | |
| 2655 | - | unpack_limit = transfer_unpack_limit; | |
| 2656 | - | ||
| 2657 | 2534 | switch (determine_protocol_version_server()) { | |
| 2658 | 2535 | case protocol_v2: | |
| 2659 | 2536 | /* | |
| @@ -2687,8 +2564,8 @@ int cmd_receive_pack(int argc, | |||
| 2687 | 2564 | PACKET_READ_DIE_ON_ERR_PACKET); | |
| 2688 | 2565 | ||
| 2689 | 2566 | if ((commands = read_head_info(&reader, &shallow))) { | |
| 2690 | - | const char *unpack_status = NULL; | |
| 2691 | 2567 | struct string_list push_options = STRING_LIST_INIT_DUP; | |
| 2568 | + | struct strbuf unpack_status = STRBUF_INIT; | |
| 2692 | 2569 | ||
| 2693 | 2570 | if (use_push_options) | |
| 2694 | 2571 | read_push_options(&reader, &push_options); | |
| @@ -2702,20 +2579,29 @@ int cmd_receive_pack(int argc, | |||
| 2702 | 2579 | if (!si.nr_ours && !si.nr_theirs) | |
| 2703 | 2580 | shallow_update = 0; | |
| 2704 | 2581 | if (!delete_only(commands)) { | |
| 2705 | - | unpack_status = unpack_with_sideband(&si); | |
| 2706 | - | update_shallow_info(commands, &si, &ref); | |
| 2582 | + | const char *alt_shallow_file = NULL; | |
| 2583 | + | ||
| 2584 | + | if (si.nr_ours || si.nr_theirs) | |
| 2585 | + | alt_shallow_file = setup_temporary_shallow(si.shallow); | |
| 2586 | + | ||
| 2587 | + | if (odb_transaction_begin(the_repository->objects, &transaction, ODB_TRANSACTION_RECEIVE)) | |
| 2588 | + | strbuf_addstr(&unpack_status, "unable to start object transaction"); | |
| 2589 | + | else | |
| 2590 | + | unpack_with_sideband(transaction, alt_shallow_file, &unpack_status); | |
| 2591 | + | ||
| 2592 | + | update_shallow_info(commands, &si, &ref, alt_shallow_file); | |
| 2707 | 2593 | } | |
| 2708 | 2594 | use_keepalive = KEEPALIVE_ALWAYS; | |
| 2709 | - | execute_commands(commands, unpack_status, &si, | |
| 2595 | + | execute_commands(commands, !!unpack_status.len, &si, transaction, | |
| 2710 | 2596 | &push_options); | |
| 2711 | - | delete_tempfile(&pack_lockfile); | |
| 2597 | + | odb_transaction_finalize(transaction); | |
| 2712 | 2598 | sigchain_push(SIGPIPE, SIG_IGN); | |
| 2713 | 2599 | if (report_status_v2) | |
| 2714 | - | report_v2(commands, unpack_status); | |
| 2600 | + | report_v2(commands, &unpack_status); | |
| 2715 | 2601 | else if (report_status) | |
| 2716 | - | report(commands, unpack_status); | |
| 2602 | + | report(commands, &unpack_status); | |
| 2717 | 2603 | sigchain_pop(SIGPIPE); | |
| 2718 | - | run_receive_hook(commands, "post-receive", 1, | |
| 2604 | + | run_receive_hook(commands, "post-receive", 1, NULL, | |
| 2719 | 2605 | &push_options); | |
| 2720 | 2606 | run_update_post_hook(commands); | |
| 2721 | 2607 | free_commands(commands); | |
| @@ -2738,6 +2624,7 @@ int cmd_receive_pack(int argc, | |||
| 2738 | 2624 | if (auto_update_server_info) | |
| 2739 | 2625 | update_server_info(the_repository, 0); | |
| 2740 | 2626 | clear_shallow_info(&si); | |
| 2627 | + | strbuf_release(&unpack_status); | |
| 2741 | 2628 | } | |
| 2742 | 2629 | if (use_sideband) | |
| 2743 | 2630 | packet_flush(1); | |
modified builtin/reflog.c
| @@ -250,7 +250,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix, | |||
| 250 | 250 | struct string_list_item *item; | |
| 251 | 251 | struct worktree **worktrees, **p; | |
| 252 | 252 | ||
| 253 | - | worktrees = get_worktrees(); | |
| 253 | + | worktrees = get_worktrees(the_repository); | |
| 254 | 254 | for (p = worktrees; *p; p++) { | |
| 255 | 255 | if (single_worktree && !(*p)->is_current) | |
| 256 | 256 | continue; | |
| @@ -374,7 +374,7 @@ static int cmd_reflog_drop(int argc, const char **argv, const char *prefix, | |||
| 374 | 374 | struct string_list_item *item; | |
| 375 | 375 | struct worktree **worktrees, **p; | |
| 376 | 376 | ||
| 377 | - | worktrees = get_worktrees(); | |
| 377 | + | worktrees = get_worktrees(the_repository); | |
| 378 | 378 | for (p = worktrees; *p; p++) { | |
| 379 | 379 | if (single_worktree && !(*p)->is_current) | |
| 380 | 380 | continue; | |
modified builtin/refs.c
| @@ -1,4 +1,3 @@ | |||
| 1 | - | #define USE_THE_REPOSITORY_VARIABLE | |
| 2 | 1 | #include "builtin.h" | |
| 3 | 2 | #include "config.h" | |
| 4 | 3 | #include "fsck.h" | |
| @@ -22,8 +21,20 @@ | |||
| 22 | 21 | #define REFS_OPTIMIZE_USAGE \ | |
| 23 | 22 | N_("git refs optimize " PACK_REFS_OPTS) | |
| 24 | 23 | ||
| 24 | + | #define REFS_CREATE_USAGE \ | |
| 25 | + | N_("git refs create [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value>") | |
| 26 | + | ||
| 27 | + | #define REFS_DELETE_USAGE \ | |
| 28 | + | N_("git refs delete [--message=<reason>] [--no-deref] <ref> [<old-value>]") | |
| 29 | + | ||
| 30 | + | #define REFS_UPDATE_USAGE \ | |
| 31 | + | N_("git refs update [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value> [<old-value>]") | |
| 32 | + | ||
| 33 | + | #define REFS_RENAME_USAGE \ | |
| 34 | + | N_("git refs rename [--message=<reason>] <old-ref> <new-ref>") | |
| 35 | + | ||
| 25 | 36 | static int cmd_refs_migrate(int argc, const char **argv, const char *prefix, | |
| 26 | - | struct repository *repo UNUSED) | |
| 37 | + | struct repository *repo) | |
| 27 | 38 | { | |
| 28 | 39 | const char * const migrate_usage[] = { | |
| 29 | 40 | REFS_MIGRATE_USAGE, | |
| @@ -59,13 +70,13 @@ static int cmd_refs_migrate(int argc, const char **argv, const char *prefix, | |||
| 59 | 70 | goto out; | |
| 60 | 71 | } | |
| 61 | 72 | ||
| 62 | - | if (the_repository->ref_storage_format == format) { | |
| 73 | + | if (repo->ref_storage_format == format) { | |
| 63 | 74 | err = error(_("repository already uses '%s' format"), | |
| 64 | 75 | ref_storage_format_to_name(format)); | |
| 65 | 76 | goto out; | |
| 66 | 77 | } | |
| 67 | 78 | ||
| 68 | - | if (repo_migrate_ref_storage_format(the_repository, format, flags, &errbuf) < 0) { | |
| 79 | + | if (repo_migrate_ref_storage_format(repo, format, flags, &errbuf) < 0) { | |
| 69 | 80 | err = error("%s", errbuf.buf); | |
| 70 | 81 | goto out; | |
| 71 | 82 | } | |
| @@ -99,10 +110,10 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix, | |||
| 99 | 110 | if (argc) | |
| 100 | 111 | usage(_("'git refs verify' takes no arguments")); | |
| 101 | 112 | ||
| 102 | - | repo_config(the_repository, git_fsck_config, &fsck_refs_options); | |
| 103 | - | prepare_repo_settings(the_repository); | |
| 113 | + | repo_config(repo, git_fsck_config, &fsck_refs_options); | |
| 114 | + | prepare_repo_settings(repo); | |
| 104 | 115 | ||
| 105 | - | worktrees = get_worktrees_without_reading_head(); | |
| 116 | + | worktrees = get_worktrees_without_reading_head(repo); | |
| 106 | 117 | for (size_t i = 0; worktrees[i]; i++) | |
| 107 | 118 | ret |= refs_fsck(get_worktree_ref_store(worktrees[i]), | |
| 108 | 119 | &fsck_refs_options, worktrees[i]); | |
| @@ -124,7 +135,7 @@ static int cmd_refs_list(int argc, const char **argv, const char *prefix, | |||
| 124 | 135 | } | |
| 125 | 136 | ||
| 126 | 137 | static int cmd_refs_exists(int argc, const char **argv, const char *prefix, | |
| 127 | - | struct repository *repo UNUSED) | |
| 138 | + | struct repository *repo) | |
| 128 | 139 | { | |
| 129 | 140 | struct strbuf unused_referent = STRBUF_INIT; | |
| 130 | 141 | struct object_id unused_oid; | |
| @@ -145,7 +156,7 @@ static int cmd_refs_exists(int argc, const char **argv, const char *prefix, | |||
| 145 | 156 | die(_("'git refs exists' requires a reference")); | |
| 146 | 157 | ||
| 147 | 158 | ref = *argv++; | |
| 148 | - | if (refs_read_raw_ref(get_main_ref_store(the_repository), ref, | |
| 159 | + | if (refs_read_raw_ref(get_main_ref_store(repo), ref, | |
| 149 | 160 | &unused_oid, &unused_referent, &unused_type, | |
| 150 | 161 | &failure_errno)) { | |
| 151 | 162 | if (failure_errno == ENOENT || failure_errno == EISDIR) { | |
| @@ -176,6 +187,193 @@ static int cmd_refs_optimize(int argc, const char **argv, const char *prefix, | |||
| 176 | 187 | return pack_refs_core(argc, argv, prefix, repo, refs_optimize_usage); | |
| 177 | 188 | } | |
| 178 | 189 | ||
| 190 | + | static int cmd_refs_create(int argc, const char **argv, const char *prefix, | |
| 191 | + | struct repository *repo) | |
| 192 | + | { | |
| 193 | + | static char const * const refs_create_usage[] = { | |
| 194 | + | REFS_CREATE_USAGE, | |
| 195 | + | NULL | |
| 196 | + | }; | |
| 197 | + | const char *message = NULL; | |
| 198 | + | unsigned flags = 0; | |
| 199 | + | struct option opts[] = { | |
| 200 | + | OPT_STRING(0, "message", &message, N_("reason"), | |
| 201 | + | N_("reason of the update")), | |
| 202 | + | OPT_BIT(0 ,"no-deref", &flags, | |
| 203 | + | N_("update <refname> not the one it points to"), | |
| 204 | + | REF_NO_DEREF), | |
| 205 | + | OPT_BIT(0, "create-reflog", &flags, N_("create a reflog"), | |
| 206 | + | REF_FORCE_CREATE_REFLOG), | |
| 207 | + | OPT_END(), | |
| 208 | + | }; | |
| 209 | + | struct object_id newoid; | |
| 210 | + | const char *refname; | |
| 211 | + | int ret; | |
| 212 | + | ||
| 213 | + | argc = parse_options(argc, argv, prefix, opts, refs_create_usage, 0); | |
| 214 | + | if (argc != 2) | |
| 215 | + | usage(_("create requires reference name and an object ID")); | |
| 216 | + | ||
| 217 | + | if (message && !*message) | |
| 218 | + | die(_("refusing to perform update with empty message")); | |
| 219 | + | ||
| 220 | + | repo_config(repo, git_default_config, NULL); | |
| 221 | + | ||
| 222 | + | refname = argv[0]; | |
| 223 | + | if (repo_get_oid_with_flags(repo, argv[1], &newoid, GET_OID_SKIP_AMBIGUITY_CHECK)) | |
| 224 | + | die(_("invalid object ID: '%s'"), argv[1]); | |
| 225 | + | if (is_null_oid(&newoid)) | |
| 226 | + | die(_("cannot create reference with null new object ID")); | |
| 227 | + | ||
| 228 | + | ret = refs_update_ref(get_main_ref_store(repo), message, refname, | |
| 229 | + | &newoid, null_oid(repo->hash_algo), flags, | |
| 230 | + | UPDATE_REFS_MSG_ON_ERR); | |
| 231 | + | ||
| 232 | + | if (ret < 0) | |
| 233 | + | ret = 1; | |
| 234 | + | return ret; | |
| 235 | + | } | |
| 236 | + | ||
| 237 | + | static int cmd_refs_delete(int argc, const char **argv, const char *prefix, | |
| 238 | + | struct repository *repo) | |
| 239 | + | { | |
| 240 | + | static char const * const refs_delete_usage[] = { | |
| 241 | + | REFS_DELETE_USAGE, | |
| 242 | + | NULL | |
| 243 | + | }; | |
| 244 | + | const char *message = NULL; | |
| 245 | + | unsigned flags = 0; | |
| 246 | + | struct option opts[] = { | |
| 247 | + | OPT_STRING(0, "message", &message, N_("reason"), | |
| 248 | + | N_("reason of the update")), | |
| 249 | + | OPT_BIT(0 ,"no-deref", &flags, | |
| 250 | + | N_("update <refname> not the one it points to"), | |
| 251 | + | REF_NO_DEREF), | |
| 252 | + | OPT_END(), | |
| 253 | + | }; | |
| 254 | + | struct object_id oldoid; | |
| 255 | + | const char *refname; | |
| 256 | + | int ret; | |
| 257 | + | ||
| 258 | + | argc = parse_options(argc, argv, prefix, opts, refs_delete_usage, 0); | |
| 259 | + | if (argc < 1 || argc > 2) | |
| 260 | + | usage(_("delete requires reference name and an optional old object ID")); | |
| 261 | + | ||
| 262 | + | if (message && !*message) | |
| 263 | + | die(_("refusing to perform update with empty message")); | |
| 264 | + | ||
| 265 | + | repo_config(repo, git_default_config, NULL); | |
| 266 | + | ||
| 267 | + | refname = argv[0]; | |
| 268 | + | if (argc == 2) { | |
| 269 | + | if (repo_get_oid_with_flags(repo, argv[1], &oldoid, GET_OID_SKIP_AMBIGUITY_CHECK)) | |
| 270 | + | die(_("invalid old object ID: '%s'"), argv[1]); | |
| 271 | + | if (is_null_oid(&oldoid)) | |
| 272 | + | die(_("cannot delete reference with null old object ID")); | |
| 273 | + | } | |
| 274 | + | ||
| 275 | + | ret = refs_delete_ref(get_main_ref_store(repo), message, refname, | |
| 276 | + | argc == 2 ? &oldoid : NULL, flags); | |
| 277 | + | ||
| 278 | + | if (ret < 0) | |
| 279 | + | ret = 1; | |
| 280 | + | return ret; | |
| 281 | + | } | |
| 282 | + | ||
| 283 | + | static int cmd_refs_update(int argc, const char **argv, const char *prefix, | |
| 284 | + | struct repository *repo) | |
| 285 | + | { | |
| 286 | + | static char const * const refs_update_usage[] = { | |
| 287 | + | REFS_UPDATE_USAGE, | |
| 288 | + | NULL | |
| 289 | + | }; | |
| 290 | + | const char *message = NULL; | |
| 291 | + | unsigned flags = 0; | |
| 292 | + | struct option opts[] = { | |
| 293 | + | OPT_STRING(0, "message", &message, N_("reason"), | |
| 294 | + | N_("reason of the update")), | |
| 295 | + | OPT_BIT(0 ,"no-deref", &flags, | |
| 296 | + | N_("update <refname> not the one it points to"), | |
| 297 | + | REF_NO_DEREF), | |
| 298 | + | OPT_BIT(0, "create-reflog", &flags, N_("create a reflog"), | |
| 299 | + | REF_FORCE_CREATE_REFLOG), | |
| 300 | + | OPT_END(), | |
| 301 | + | }; | |
| 302 | + | struct object_id newoid, oldoid; | |
| 303 | + | const char *refname; | |
| 304 | + | int ret; | |
| 305 | + | ||
| 306 | + | argc = parse_options(argc, argv, prefix, opts, refs_update_usage, 0); | |
| 307 | + | if (argc < 2 || argc > 3) | |
| 308 | + | usage(_("update requires reference name, new value and an optional old value")); | |
| 309 | + | ||
| 310 | + | if (message && !*message) | |
| 311 | + | die(_("refusing to perform update with empty message")); | |
| 312 | + | ||
| 313 | + | repo_config(repo, git_default_config, NULL); | |
| 314 | + | ||
| 315 | + | refname = argv[0]; | |
| 316 | + | if (repo_get_oid_with_flags(repo, argv[1], &newoid, | |
| 317 | + | GET_OID_SKIP_AMBIGUITY_CHECK)) | |
| 318 | + | die(_("invalid new object ID: '%s'"), argv[1]); | |
| 319 | + | if (argc == 3 && | |
| 320 | + | repo_get_oid_with_flags(repo, argv[2], &oldoid, | |
| 321 | + | GET_OID_SKIP_AMBIGUITY_CHECK)) | |
| 322 | + | die(_("invalid old object ID: '%s'"), argv[2]); | |
| 323 | + | ||
| 324 | + | ret = refs_update_ref(get_main_ref_store(repo), message, refname, | |
| 325 | + | &newoid, argc == 3 ? &oldoid : NULL, flags, | |
| 326 | + | UPDATE_REFS_MSG_ON_ERR); | |
| 327 | + | ||
| 328 | + | if (ret < 0) | |
| 329 | + | ret = 1; | |
| 330 | + | return ret; | |
| 331 | + | } | |
| 332 | + | ||
| 333 | + | static int cmd_refs_rename(int argc, const char **argv, const char *prefix, | |
| 334 | + | struct repository *repo) | |
| 335 | + | { | |
| 336 | + | static char const * const refs_rename_usage[] = { | |
| 337 | + | REFS_RENAME_USAGE, | |
| 338 | + | NULL | |
| 339 | + | }; | |
| 340 | + | const char *message = NULL; | |
| 341 | + | struct option opts[] = { | |
| 342 | + | OPT_STRING(0, "message", &message, N_("reason"), | |
| 343 | + | N_("reason of the update")), | |
| 344 | + | OPT_END(), | |
| 345 | + | }; | |
| 346 | + | const char *oldref, *newref; | |
| 347 | + | int ret; | |
| 348 | + | ||
| 349 | + | argc = parse_options(argc, argv, prefix, opts, refs_rename_usage, 0); | |
| 350 | + | if (argc != 2) | |
| 351 | + | usage(_("rename requires old and new reference name")); | |
| 352 | + | if (message && !*message) | |
| 353 | + | die(_("refusing to perform update with empty message")); | |
| 354 | + | ||
| 355 | + | repo_config(repo, git_default_config, NULL); | |
| 356 | + | ||
| 357 | + | oldref = argv[0]; | |
| 358 | + | newref = argv[1]; | |
| 359 | + | ||
| 360 | + | if (check_refname_format(oldref, 0)) | |
| 361 | + | die(_("invalid ref format: '%s'"), oldref); | |
| 362 | + | if (check_refname_format(newref, 0)) | |
| 363 | + | die(_("invalid ref format: '%s'"), newref); | |
| 364 | + | ||
| 365 | + | if (!refs_ref_exists(get_main_ref_store(repo), oldref)) | |
| 366 | + | die(_("reference does not exist: '%s'"), oldref); | |
| 367 | + | if (refs_ref_exists(get_main_ref_store(repo), newref)) | |
| 368 | + | die(_("reference already exists: '%s'"), newref); | |
| 369 | + | ||
| 370 | + | ret = refs_rename_ref(get_main_ref_store(repo), oldref, newref, message); | |
| 371 | + | ||
| 372 | + | if (ret < 0) | |
| 373 | + | ret = 1; | |
| 374 | + | return ret; | |
| 375 | + | } | |
| 376 | + | ||
| 179 | 377 | int cmd_refs(int argc, | |
| 180 | 378 | const char **argv, | |
| 181 | 379 | const char *prefix, | |
| @@ -187,6 +385,10 @@ int cmd_refs(int argc, | |||
| 187 | 385 | "git refs list " COMMON_USAGE_FOR_EACH_REF, | |
| 188 | 386 | REFS_EXISTS_USAGE, | |
| 189 | 387 | REFS_OPTIMIZE_USAGE, | |
| 388 | + | REFS_CREATE_USAGE, | |
| 389 | + | REFS_DELETE_USAGE, | |
| 390 | + | REFS_UPDATE_USAGE, | |
| 391 | + | REFS_RENAME_USAGE, | |
| 190 | 392 | NULL, | |
| 191 | 393 | }; | |
| 192 | 394 | parse_opt_subcommand_fn *fn = NULL; | |
| @@ -196,6 +398,10 @@ int cmd_refs(int argc, | |||
| 196 | 398 | OPT_SUBCOMMAND("list", &fn, cmd_refs_list), | |
| 197 | 399 | OPT_SUBCOMMAND("exists", &fn, cmd_refs_exists), | |
| 198 | 400 | OPT_SUBCOMMAND("optimize", &fn, cmd_refs_optimize), | |
| 401 | + | OPT_SUBCOMMAND("create", &fn, cmd_refs_create), | |
| 402 | + | OPT_SUBCOMMAND("delete", &fn, cmd_refs_delete), | |
| 403 | + | OPT_SUBCOMMAND("update", &fn, cmd_refs_update), | |
| 404 | + | OPT_SUBCOMMAND("rename", &fn, cmd_refs_rename), | |
| 199 | 405 | OPT_END(), | |
| 200 | 406 | }; | |
| 201 | 407 | ||
modified builtin/repack.c
| @@ -1,4 +1,3 @@ | |||
| 1 | - | #define USE_THE_REPOSITORY_VARIABLE | |
| 2 | 1 | #define DISABLE_SIGN_COMPARE_WARNINGS | |
| 3 | 2 | ||
| 4 | 3 | #include "builtin.h" | |
| @@ -15,6 +14,11 @@ | |||
| 15 | 14 | #include "promisor-remote.h" | |
| 16 | 15 | #include "repack.h" | |
| 17 | 16 | #include "shallow.h" | |
| 17 | + | #include "list-objects-filter-options.h" | |
| 18 | + | #include "oidset.h" | |
| 19 | + | #include "hex.h" | |
| 20 | + | #include "wt-status.h" | |
| 21 | + | #include "read-cache-ll.h" | |
| 18 | 22 | ||
| 19 | 23 | #define ALL_INTO_ONE 1 | |
| 20 | 24 | #define LOOSEN_UNREACHABLE 2 | |
| @@ -29,11 +33,15 @@ static int use_delta_islands; | |||
| 29 | 33 | static int run_update_server_info = 1; | |
| 30 | 34 | static char *packdir, *packtmp_name, *packtmp; | |
| 31 | 35 | static int midx_must_contain_cruft = 1; | |
| 36 | + | static int drop_filtered; | |
| 37 | + | static int dry_run; | |
| 38 | + | static int write_bitmaps_given; | |
| 32 | 39 | ||
| 33 | 40 | static const char *const git_repack_usage[] = { | |
| 34 | 41 | N_("git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]\n" | |
| 35 | 42 | "[--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]\n" | |
| 36 | - | "[--write-midx] [--name-hash-version=<n>] [--path-walk]"), | |
| 43 | + | "[--write-midx[=<mode>]] [--name-hash-version=<n>] [--path-walk]\n" | |
| 44 | + | "[--filter=<filter-spec>] [--drop-filtered [--dry-run]]"), | |
| 37 | 45 | NULL | |
| 38 | 46 | }; | |
| 39 | 47 | ||
| @@ -42,9 +50,14 @@ static const char incremental_bitmap_conflict_error[] = N_( | |||
| 42 | 50 | "--no-write-bitmap-index or disable the pack.writeBitmaps configuration." | |
| 43 | 51 | ); | |
| 44 | 52 | ||
| 53 | + | #define DEFAULT_MIDX_SPLIT_FACTOR 2 | |
| 54 | + | #define DEFAULT_MIDX_NEW_LAYER_THRESHOLD 8 | |
| 55 | + | ||
| 45 | 56 | struct repack_config_ctx { | |
| 46 | 57 | struct pack_objects_args *po_args; | |
| 47 | 58 | struct pack_objects_args *cruft_po_args; | |
| 59 | + | int midx_split_factor; | |
| 60 | + | int midx_new_layer_threshold; | |
| 48 | 61 | }; | |
| 49 | 62 | ||
| 50 | 63 | static int repack_config(const char *var, const char *value, | |
| @@ -94,9 +107,54 @@ static int repack_config(const char *var, const char *value, | |||
| 94 | 107 | midx_must_contain_cruft = git_config_bool(var, value); | |
| 95 | 108 | return 0; | |
| 96 | 109 | } | |
| 110 | + | if (!strcmp(var, "repack.midxsplitfactor")) { | |
| 111 | + | repack_ctx->midx_split_factor = git_config_int(var, value, | |
| 112 | + | ctx->kvi); | |
| 113 | + | return 0; | |
| 114 | + | } | |
| 115 | + | if (!strcmp(var, "repack.midxnewlayerthreshold")) { | |
| 116 | + | repack_ctx->midx_new_layer_threshold = git_config_int(var, value, | |
| 117 | + | ctx->kvi); | |
| 118 | + | return 0; | |
| 119 | + | } | |
| 97 | 120 | return git_default_config(var, value, ctx, cb); | |
| 98 | 121 | } | |
| 99 | 122 | ||
| 123 | + | static int option_parse_write_bitmaps(const struct option *opt, const char *arg, | |
| 124 | + | int unset) | |
| 125 | + | { | |
| 126 | + | int *value = opt->value; | |
| 127 | + | ||
| 128 | + | BUG_ON_OPT_ARG(arg); | |
| 129 | + | if (unset) | |
| 130 | + | *value = 0; | |
| 131 | + | else | |
| 132 | + | *value = 1; | |
| 133 | + | ||
| 134 | + | write_bitmaps_given = 1; | |
| 135 | + | return 0; | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | static int option_parse_write_midx(const struct option *opt, const char *arg, | |
| 139 | + | int unset) | |
| 140 | + | { | |
| 141 | + | enum repack_write_midx_mode *cfg = opt->value; | |
| 142 | + | ||
| 143 | + | if (unset) { | |
| 144 | + | *cfg = REPACK_WRITE_MIDX_NONE; | |
| 145 | + | return 0; | |
| 146 | + | } | |
| 147 | + | ||
| 148 | + | if (!arg || !*arg) | |
| 149 | + | *cfg = REPACK_WRITE_MIDX_DEFAULT; | |
| 150 | + | else if (!strcmp(arg, "incremental")) | |
| 151 | + | *cfg = REPACK_WRITE_MIDX_INCREMENTAL; | |
| 152 | + | else | |
| 153 | + | return error(_("unknown value for %s: %s"), opt->long_name, arg); | |
| 154 | + | ||
| 155 | + | return 0; | |
| 156 | + | } | |
| 157 | + | ||
| 100 | 158 | int cmd_repack(int argc, | |
| 101 | 159 | const char **argv, | |
| 102 | 160 | const char *prefix, | |
| @@ -106,6 +164,7 @@ int cmd_repack(int argc, | |||
| 106 | 164 | struct string_list_item *item; | |
| 107 | 165 | struct string_list names = STRING_LIST_INIT_DUP; | |
| 108 | 166 | struct existing_packs existing = EXISTING_PACKS_INIT; | |
| 167 | + | struct oidset drop_oids = OIDSET_INIT; | |
| 109 | 168 | struct pack_geometry geometry = { 0 }; | |
| 110 | 169 | struct tempfile *refs_snapshot = NULL; | |
| 111 | 170 | int i, ret; | |
| @@ -119,7 +178,7 @@ int cmd_repack(int argc, | |||
| 119 | 178 | struct string_list keep_pack_list = STRING_LIST_INIT_NODUP; | |
| 120 | 179 | struct pack_objects_args po_args = PACK_OBJECTS_ARGS_INIT; | |
| 121 | 180 | struct pack_objects_args cruft_po_args = PACK_OBJECTS_ARGS_INIT; | |
| 122 | - | int write_midx = 0; | |
| 181 | + | enum repack_write_midx_mode write_midx = REPACK_WRITE_MIDX_NONE; | |
| 123 | 182 | const char *cruft_expiration = NULL; | |
| 124 | 183 | const char *expire_to = NULL; | |
| 125 | 184 | const char *filter_to = NULL; | |
| @@ -160,8 +219,9 @@ int cmd_repack(int argc, | |||
| 160 | 219 | OPT__QUIET(&po_args.quiet, N_("be quiet")), | |
| 161 | 220 | OPT_BOOL('l', "local", &po_args.local, | |
| 162 | 221 | N_("pass --local to git-pack-objects")), | |
| 163 | - | OPT_BOOL('b', "write-bitmap-index", &write_bitmaps, | |
| 164 | - | N_("write bitmap index")), | |
| 222 | + | OPT_CALLBACK_F('b', "write-bitmap-index", &write_bitmaps, NULL, | |
| 223 | + | N_("write bitmap index"), | |
| 224 | + | PARSE_OPT_NOARG, option_parse_write_bitmaps), | |
| 165 | 225 | OPT_BOOL('i', "delta-islands", &use_delta_islands, | |
| 166 | 226 | N_("pass --delta-islands to git-pack-objects")), | |
| 167 | 227 | OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"), | |
| @@ -185,12 +245,22 @@ int cmd_repack(int argc, | |||
| 185 | 245 | N_("do not repack this pack")), | |
| 186 | 246 | OPT_INTEGER('g', "geometric", &geometry.split_factor, | |
| 187 | 247 | N_("find a geometric progression with factor <N>")), | |
| 188 | - | OPT_BOOL('m', "write-midx", &write_midx, | |
| 189 | - | N_("write a multi-pack index of the resulting packs")), | |
| 248 | + | OPT_CALLBACK_F(0, "write-midx", &write_midx, | |
| 249 | + | N_("mode"), | |
| 250 | + | N_("write a multi-pack index of the resulting packs"), | |
| 251 | + | PARSE_OPT_OPTARG, option_parse_write_midx), | |
| 252 | + | OPT_SET_INT_F('m', NULL, &write_midx, | |
| 253 | + | N_("write a multi-pack index of the resulting packs"), | |
| 254 | + | REPACK_WRITE_MIDX_DEFAULT, | |
| 255 | + | PARSE_OPT_HIDDEN), | |
| 190 | 256 | OPT_STRING(0, "expire-to", &expire_to, N_("dir"), | |
| 191 | 257 | N_("pack prefix to store a pack containing pruned objects")), | |
| 192 | 258 | OPT_STRING(0, "filter-to", &filter_to, N_("dir"), | |
| 193 | 259 | N_("pack prefix to store a pack containing filtered out objects")), | |
| 260 | + | OPT_BOOL(0, "drop-filtered", &drop_filtered, | |
| 261 | + | N_("delete filtered out objects (requires --filter)")), | |
| 262 | + | OPT_BOOL(0, "dry-run", &dry_run, | |
| 263 | + | N_("only show which objects would be dropped")), | |
| 194 | 264 | OPT_END() | |
| 195 | 265 | }; | |
| 196 | 266 | ||
| @@ -199,6 +269,8 @@ int cmd_repack(int argc, | |||
| 199 | 269 | memset(&config_ctx, 0, sizeof(config_ctx)); | |
| 200 | 270 | config_ctx.po_args = &po_args; | |
| 201 | 271 | config_ctx.cruft_po_args = &cruft_po_args; | |
| 272 | + | config_ctx.midx_split_factor = DEFAULT_MIDX_SPLIT_FACTOR; | |
| 273 | + | config_ctx.midx_new_layer_threshold = DEFAULT_MIDX_NEW_LAYER_THRESHOLD; | |
| 202 | 274 | ||
| 203 | 275 | repo_config(repo, repack_config, &config_ctx); | |
| 204 | 276 | ||
| @@ -210,6 +282,118 @@ int cmd_repack(int argc, | |||
| 210 | 282 | po_args.depth = xstrdup_or_null(opt_depth); | |
| 211 | 283 | po_args.threads = xstrdup_or_null(opt_threads); | |
| 212 | 284 | ||
| 285 | + | die_for_incompatible_opt2(drop_filtered, "--drop-filtered", | |
| 286 | + | !!filter_to, "--filter-to"); | |
| 287 | + | ||
| 288 | + | if (dry_run && !drop_filtered) | |
| 289 | + | die(_("--dry-run only takes effect with --drop-filtered")); | |
| 290 | + | ||
| 291 | + | if (drop_filtered) { | |
| 292 | + | if (!po_args.filter_options.choice) | |
| 293 | + | die(_("--drop-filtered requires --filter")); | |
| 294 | + | ||
| 295 | + | if (!(pack_everything & ALL_INTO_ONE)) | |
| 296 | + | die(_("--drop-filtered requires -a")); | |
| 297 | + | ||
| 298 | + | /* | |
| 299 | + | * Only blob:limit=<n> is supported for now. Reject other | |
| 300 | + | * filter choices early, before walking the object database. | |
| 301 | + | */ | |
| 302 | + | if (po_args.filter_options.choice != LOFC_BLOB_LIMIT) | |
| 303 | + | die(_("--drop-filtered only supports --filter=blob:limit=<n> for now")); | |
| 304 | + | ||
| 305 | + | /* | |
| 306 | + | * An explicit -b on the command line is a conflict we have to | |
| 307 | + | * report; a bitmap setting from config is silently overridden | |
| 308 | + | * for the duration of the command. | |
| 309 | + | */ | |
| 310 | + | if (write_bitmaps_given && write_bitmaps > 0) | |
| 311 | + | die(_("options '%s' and '%s' cannot be used together"), | |
| 312 | + | "--drop-filtered", "--write-bitmap-index"); | |
| 313 | + | ||
| 314 | + | /* | |
| 315 | + | * Without a promisor remote there is nowhere to re-fetch the | |
| 316 | + | * dropped objects from, so dropping them would be permanent | |
| 317 | + | * data loss. | |
| 318 | + | */ | |
| 319 | + | if (!repo_has_promisor_remote(repo)) | |
| 320 | + | die(_("--drop-filtered requires a promisor remote")); | |
| 321 | + | ||
| 322 | + | /* | |
| 323 | + | * Refuse to run while another operation is in progress. A | |
| 324 | + | * dropped object would just be lazily re-fetched when the | |
| 325 | + | * operation resumes, but triggering a network fetch in the | |
| 326 | + | * middle of a half-finished | |
| 327 | + | * merge/rebase/cherry-pick/revert/bisect is a poor | |
| 328 | + | * experience, so this is a UX convenience rather than a | |
| 329 | + | * safety measure. Bare repositories have no such state, so | |
| 330 | + | * the check is skipped there. | |
| 331 | + | */ | |
| 332 | + | if (!is_bare_repository(repo)) { | |
| 333 | + | struct wt_status_state state = { 0 }; | |
| 334 | + | ||
| 335 | + | wt_status_get_state(repo, &state, 0); | |
| 336 | + | if (state.merge_in_progress || state.revert_in_progress || | |
| 337 | + | state.rebase_in_progress || state.bisect_in_progress || | |
| 338 | + | state.cherry_pick_in_progress || state.am_in_progress || | |
| 339 | + | state.rebase_interactive_in_progress) { | |
| 340 | + | wt_status_state_free_buffers(&state); | |
| 341 | + | die(_("--drop-filtered cannot be used while " | |
| 342 | + | "another operation (merge, rebase, am, " | |
| 343 | + | "cherry-pick, revert, or bisect) is in " | |
| 344 | + | "progress")); | |
| 345 | + | } | |
| 346 | + | wt_status_state_free_buffers(&state); | |
| 347 | + | } | |
| 348 | + | ||
| 349 | + | write_bitmaps = 0; | |
| 350 | + | ||
| 351 | + | /* | |
| 352 | + | * Dropping objects means rebuilding the promisor packs | |
| 353 | + | * without them and then removing the old packs, so the | |
| 354 | + | * redundant packs must be deleted. Imply -d on a real run. | |
| 355 | + | */ | |
| 356 | + | if (!dry_run) | |
| 357 | + | delete_redundant = 1; | |
| 358 | + | ||
| 359 | + | ret = enumerate_promisor_blobs(repo, &po_args.filter_options, &drop_oids); | |
| 360 | + | ||
| 361 | + | if (ret) | |
| 362 | + | goto cleanup; | |
| 363 | + | ||
| 364 | + | /* | |
| 365 | + | * Refuse to drop blobs that the current index references. | |
| 366 | + | * Such a blob would only be lazily re-fetched by the next | |
| 367 | + | * command that touches the worktree, so dropping it reclaims | |
| 368 | + | * nothing. This guard just avoids that churn. Bare | |
| 369 | + | * repositories have no index, so the check is skipped there. | |
| 370 | + | */ | |
| 371 | + | if (!is_bare_repository(repo) && oidset_size(&drop_oids)) { | |
| 372 | + | struct index_state *istate = repo->index; | |
| 373 | + | unsigned int i; | |
| 374 | + | ||
| 375 | + | if (repo_read_index(repo) < 0) | |
| 376 | + | die(_("could not read the index")); | |
| 377 | + | ||
| 378 | + | for (i = 0; i < istate->cache_nr; i++) { | |
| 379 | + | const struct cache_entry *ce = istate->cache[i]; | |
| 380 | + | ||
| 381 | + | if (oidset_contains(&drop_oids, &ce->oid)) | |
| 382 | + | die(_("cannot drop '%s' (%s): it is referenced by the current index"), | |
| 383 | + | ce->name, oid_to_hex(&ce->oid)); | |
| 384 | + | } | |
| 385 | + | } | |
| 386 | + | ||
| 387 | + | if (dry_run) { | |
| 388 | + | struct oidset_iter iter; | |
| 389 | + | const struct object_id *oid; | |
| 390 | + | ||
| 391 | + | oidset_iter_init(&drop_oids, &iter); | |
| 392 | + | while ((oid = oidset_iter_next(&iter))) | |
| 393 | + | printf("%s\n", oid_to_hex(oid)); | |
| 394 | + | } | |
| 395 | + | } | |
| 396 | + | ||
| 213 | 397 | if (delete_redundant && repo->repository_format_precious_objects) | |
| 214 | 398 | die(_("cannot delete packs in a precious-objects repo")); | |
| 215 | 399 | ||
| @@ -221,14 +405,16 @@ int cmd_repack(int argc, | |||
| 221 | 405 | pack_everything |= ALL_INTO_ONE; | |
| 222 | 406 | ||
| 223 | 407 | if (write_bitmaps < 0) { | |
| 224 | - | if (!write_midx && | |
| 225 | - | (!(pack_everything & ALL_INTO_ONE) || !is_bare_repository())) | |
| 408 | + | if (write_midx == REPACK_WRITE_MIDX_NONE && | |
| 409 | + | (!(pack_everything & ALL_INTO_ONE) || !is_bare_repository(repo))) | |
| 226 | 410 | write_bitmaps = 0; | |
| 227 | 411 | } | |
| 228 | 412 | if (po_args.pack_kept_objects < 0) | |
| 229 | - | po_args.pack_kept_objects = write_bitmaps > 0 && !write_midx; | |
| 413 | + | po_args.pack_kept_objects = write_bitmaps > 0 && | |
| 414 | + | write_midx == REPACK_WRITE_MIDX_NONE; | |
| 230 | 415 | ||
| 231 | - | if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx) | |
| 416 | + | if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && | |
| 417 | + | write_midx == REPACK_WRITE_MIDX_NONE) | |
| 232 | 418 | die(_(incremental_bitmap_conflict_error)); | |
| 233 | 419 | ||
| 234 | 420 | if (write_bitmaps && po_args.local && | |
| @@ -244,7 +430,14 @@ int cmd_repack(int argc, | |||
| 244 | 430 | write_bitmaps = 0; | |
| 245 | 431 | } | |
| 246 | 432 | ||
| 247 | - | if (write_midx && write_bitmaps) { | |
| 433 | + | if (config_ctx.midx_split_factor < 2) | |
| 434 | + | die(_("invalid value for %s: %d"), "--midx-split-factor", | |
| 435 | + | config_ctx.midx_split_factor); | |
| 436 | + | if (config_ctx.midx_new_layer_threshold < 1) | |
| 437 | + | die(_("invalid value for %s: %d"), "--midx-new-layer-threshold", | |
| 438 | + | config_ctx.midx_new_layer_threshold); | |
| 439 | + | ||
| 440 | + | if (write_midx != REPACK_WRITE_MIDX_NONE && write_bitmaps) { | |
| 248 | 441 | struct strbuf path = STRBUF_INIT; | |
| 249 | 442 | ||
| 250 | 443 | strbuf_addf(&path, "%s/%s_XXXXXX", | |
| @@ -267,6 +460,10 @@ int cmd_repack(int argc, | |||
| 267 | 460 | if (geometry.split_factor) { | |
| 268 | 461 | if (pack_everything) | |
| 269 | 462 | die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a"); | |
| 463 | + | if (write_midx == REPACK_WRITE_MIDX_INCREMENTAL) { | |
| 464 | + | geometry.midx_layer_threshold = config_ctx.midx_new_layer_threshold; | |
| 465 | + | geometry.midx_layer_threshold_set = true; | |
| 466 | + | } | |
| 270 | 467 | pack_geometry_init(&geometry, &existing, &po_args); | |
| 271 | 468 | pack_geometry_split(&geometry); | |
| 272 | 469 | } | |
| @@ -297,7 +494,7 @@ int cmd_repack(int argc, | |||
| 297 | 494 | } | |
| 298 | 495 | if (repo_has_promisor_remote(repo)) | |
| 299 | 496 | strvec_push(&cmd.args, "--exclude-promisor-objects"); | |
| 300 | - | if (!write_midx) { | |
| 497 | + | if (write_midx == REPACK_WRITE_MIDX_NONE) { | |
| 301 | 498 | if (write_bitmaps > 0) | |
| 302 | 499 | strvec_push(&cmd.args, "--write-bitmap-index"); | |
| 303 | 500 | else if (write_bitmaps < 0) | |
| @@ -307,7 +504,8 @@ int cmd_repack(int argc, | |||
| 307 | 504 | strvec_push(&cmd.args, "--delta-islands"); | |
| 308 | 505 | ||
| 309 | 506 | if (pack_everything & ALL_INTO_ONE) { | |
| 310 | - | repack_promisor_objects(repo, &po_args, &names, packtmp); | |
| 507 | + | repack_promisor_objects(repo, &po_args, &names, packtmp, | |
| 508 | + | (drop_filtered && !dry_run) ? &drop_oids : NULL); | |
| 311 | 509 | ||
| 312 | 510 | if (existing_packs_has_non_kept(&existing) && | |
| 313 | 511 | delete_redundant && | |
| @@ -402,6 +600,8 @@ int cmd_repack(int argc, | |||
| 402 | 600 | } | |
| 403 | 601 | ||
| 404 | 602 | if (!names.nr) { | |
| 603 | + | struct odb_source_files *files = odb_source_files_downcast(existing.source); | |
| 604 | + | ||
| 405 | 605 | if (!po_args.quiet) | |
| 406 | 606 | printf_ln(_("Nothing new to pack.")); | |
| 407 | 607 | /* | |
| @@ -417,7 +617,7 @@ int cmd_repack(int argc, | |||
| 417 | 617 | * midx_has_unknown_packs() will make the decision for | |
| 418 | 618 | * us. | |
| 419 | 619 | */ | |
| 420 | - | if (!get_multi_pack_index(repo->objects->sources)) | |
| 620 | + | if (!get_multi_pack_index(files->packed)) | |
| 421 | 621 | midx_must_contain_cruft = 1; | |
| 422 | 622 | } | |
| 423 | 623 | ||
| @@ -488,7 +688,7 @@ int cmd_repack(int argc, | |||
| 488 | 688 | } | |
| 489 | 689 | } | |
| 490 | 690 | ||
| 491 | - | if (po_args.filter_options.choice) { | |
| 691 | + | if (po_args.filter_options.choice && !drop_filtered) { | |
| 492 | 692 | struct write_pack_opts opts = { | |
| 493 | 693 | .po_args = &po_args, | |
| 494 | 694 | .destination = filter_to, | |
| @@ -516,10 +716,13 @@ int cmd_repack(int argc, | |||
| 516 | 716 | packtmp); | |
| 517 | 717 | /* End of pack replacement. */ | |
| 518 | 718 | ||
| 519 | - | if (delete_redundant && pack_everything & ALL_INTO_ONE) | |
| 719 | + | if (delete_redundant && pack_everything & ALL_INTO_ONE) { | |
| 720 | + | if (write_midx == REPACK_WRITE_MIDX_INCREMENTAL) | |
| 721 | + | existing_packs_retain_midx_packs(&existing); | |
| 520 | 722 | existing_packs_mark_for_deletion(&existing, &names); | |
| 723 | + | } | |
| 521 | 724 | ||
| 522 | - | if (write_midx) { | |
| 725 | + | if (write_midx != REPACK_WRITE_MIDX_NONE) { | |
| 523 | 726 | struct repack_write_midx_opts opts = { | |
| 524 | 727 | .existing = &existing, | |
| 525 | 728 | .geometry = &geometry, | |
| @@ -528,11 +731,13 @@ int cmd_repack(int argc, | |||
| 528 | 731 | .packdir = packdir, | |
| 529 | 732 | .show_progress = show_progress, | |
| 530 | 733 | .write_bitmaps = write_bitmaps > 0, | |
| 531 | - | .midx_must_contain_cruft = midx_must_contain_cruft | |
| 734 | + | .midx_must_contain_cruft = midx_must_contain_cruft, | |
| 735 | + | .midx_split_factor = config_ctx.midx_split_factor, | |
| 736 | + | .midx_new_layer_threshold = config_ctx.midx_new_layer_threshold, | |
| 737 | + | .mode = write_midx, | |
| 532 | 738 | }; | |
| 533 | 739 | ||
| 534 | - | ret = write_midx_included_packs(&opts); | |
| 535 | - | ||
| 740 | + | ret = repack_write_midx(&opts); | |
| 536 | 741 | if (ret) | |
| 537 | 742 | goto cleanup; | |
| 538 | 743 | } | |
| @@ -541,11 +746,15 @@ int cmd_repack(int argc, | |||
| 541 | 746 | ||
| 542 | 747 | if (delete_redundant) { | |
| 543 | 748 | int opts = 0; | |
| 544 | - | existing_packs_remove_redundant(&existing, packdir); | |
| 749 | + | bool wrote_incremental_midx = write_midx == REPACK_WRITE_MIDX_INCREMENTAL; | |
| 750 | + | ||
| 751 | + | existing_packs_remove_redundant(&existing, packdir, | |
| 752 | + | wrote_incremental_midx); | |
| 545 | 753 | ||
| 546 | 754 | if (geometry.split_factor) | |
| 547 | 755 | pack_geometry_remove_redundant(&geometry, &names, | |
| 548 | - | &existing, packdir); | |
| 756 | + | &existing, packdir, | |
| 757 | + | wrote_incremental_midx); | |
| 549 | 758 | if (show_progress) | |
| 550 | 759 | opts |= PRUNE_PACKED_VERBOSE; | |
| 551 | 760 | prune_packed_objects(opts); | |
| @@ -561,16 +770,18 @@ int cmd_repack(int argc, | |||
| 561 | 770 | update_server_info(repo, 0); | |
| 562 | 771 | ||
| 563 | 772 | if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) { | |
| 773 | + | struct odb_source_files *files = odb_source_files_downcast(existing.source); | |
| 564 | 774 | unsigned flags = 0; | |
| 775 | + | ||
| 565 | 776 | if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0)) | |
| 566 | 777 | flags |= MIDX_WRITE_INCREMENTAL; | |
| 567 | - | write_midx_file(repo->objects->sources, | |
| 568 | - | NULL, NULL, flags); | |
| 778 | + | write_midx_file(files->packed, NULL, NULL, flags); | |
| 569 | 779 | } | |
| 570 | 780 | ||
| 571 | 781 | cleanup: | |
| 572 | 782 | string_list_clear(&keep_pack_list, 0); | |
| 573 | 783 | string_list_clear(&names, 1); | |
| 784 | + | oidset_clear(&drop_oids); | |
| 574 | 785 | existing_packs_release(&existing); | |
| 575 | 786 | pack_geometry_release(&geometry); | |
| 576 | 787 | pack_objects_args_release(&po_args); | |
modified builtin/replace.c
| @@ -127,7 +127,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn) | |||
| 127 | 127 | } | |
| 128 | 128 | ||
| 129 | 129 | strbuf_setlen(&ref, base_len); | |
| 130 | - | strbuf_addstr(&ref, oid_to_hex(&oid)); | |
| 130 | + | strbuf_add_oid_hex(&ref, &oid); | |
| 131 | 131 | full_hex = ref.buf + base_len; | |
| 132 | 132 | ||
| 133 | 133 | if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &oid)) { | |
modified builtin/replay.c
| @@ -85,7 +85,7 @@ int cmd_replay(int argc, | |||
| 85 | 85 | const char *const replay_usage[] = { | |
| 86 | 86 | N_("(EXPERIMENTAL!) git replay " | |
| 87 | 87 | "([--contained] --onto=<newbase> | --advance=<branch> | --revert=<branch>)\n" | |
| 88 | - | "[--ref=<ref>] [--ref-action=<mode>] <revision-range>"), | |
| 88 | + | "[--ref=<ref>] [--ref-action=<mode>] [--linearize] <revision-range>"), | |
| 89 | 89 | NULL | |
| 90 | 90 | }; | |
| 91 | 91 | struct option replay_options[] = { | |
| @@ -111,6 +111,8 @@ int cmd_replay(int argc, | |||
| 111 | 111 | N_("mode"), | |
| 112 | 112 | N_("control ref update behavior (update|print)"), | |
| 113 | 113 | PARSE_OPT_NONEG), | |
| 114 | + | OPT_BOOL(0, "linearize", &opts.linearize, | |
| 115 | + | N_("drop merge commits, replaying only non-merge commits")), | |
| 114 | 116 | OPT_END() | |
| 115 | 117 | }; | |
| 116 | 118 | ||
| @@ -132,6 +134,8 @@ int cmd_replay(int argc, | |||
| 132 | 134 | opts.contained, "--contained"); | |
| 133 | 135 | die_for_incompatible_opt2(!!opts.ref, "--ref", | |
| 134 | 136 | !!opts.contained, "--contained"); | |
| 137 | + | die_for_incompatible_opt2(opts.linearize, "--linearize", | |
| 138 | + | !!opts.contained, "--contained"); | |
| 135 | 139 | ||
| 136 | 140 | /* Parse ref action mode from command line or config */ | |
| 137 | 141 | ref_mode = get_ref_action_mode(repo, ref_action); | |
modified builtin/repo.c
| @@ -7,12 +7,14 @@ | |||
| 7 | 7 | #include "hex.h" | |
| 8 | 8 | #include "odb.h" | |
| 9 | 9 | #include "parse-options.h" | |
| 10 | + | #include "path.h" | |
| 10 | 11 | #include "path-walk.h" | |
| 11 | 12 | #include "progress.h" | |
| 12 | 13 | #include "quote.h" | |
| 13 | 14 | #include "ref-filter.h" | |
| 14 | 15 | #include "refs.h" | |
| 15 | 16 | #include "revision.h" | |
| 17 | + | #include "setup.h" | |
| 16 | 18 | #include "strbuf.h" | |
| 17 | 19 | #include "string-list.h" | |
| 18 | 20 | #include "shallow.h" | |
| @@ -58,7 +60,7 @@ struct repo_info_field { | |||
| 58 | 60 | ||
| 59 | 61 | static int get_layout_bare(struct repository *repo UNUSED, struct strbuf *buf) | |
| 60 | 62 | { | |
| 61 | - | strbuf_addstr(buf, is_bare_repository() ? "true" : "false"); | |
| 63 | + | strbuf_addstr(buf, is_bare_repository(the_repository) ? "true" : "false"); | |
| 62 | 64 | return 0; | |
| 63 | 65 | } | |
| 64 | 66 | ||
| @@ -75,6 +77,50 @@ static int get_object_format(struct repository *repo, struct strbuf *buf) | |||
| 75 | 77 | return 0; | |
| 76 | 78 | } | |
| 77 | 79 | ||
| 80 | + | static int get_path_commondir_absolute(struct repository *repo, struct strbuf *buf) | |
| 81 | + | { | |
| 82 | + | const char *common_dir = repo_get_common_dir(repo); | |
| 83 | + | ||
| 84 | + | if (!common_dir) | |
| 85 | + | return error(_("unable to get common directory")); | |
| 86 | + | ||
| 87 | + | format_path(buf, common_dir, repo->prefix, PATH_FORMAT_CANONICAL); | |
| 88 | + | return 0; | |
| 89 | + | } | |
| 90 | + | ||
| 91 | + | static int get_path_commondir_relative(struct repository *repo, struct strbuf *buf) | |
| 92 | + | { | |
| 93 | + | const char *common_dir = repo_get_common_dir(repo); | |
| 94 | + | ||
| 95 | + | if (!common_dir) | |
| 96 | + | return error(_("unable to get common directory")); | |
| 97 | + | ||
| 98 | + | format_path(buf, common_dir, repo->prefix, PATH_FORMAT_RELATIVE); | |
| 99 | + | return 0; | |
| 100 | + | } | |
| 101 | + | ||
| 102 | + | static int get_path_gitdir_absolute(struct repository *repo, struct strbuf *buf) | |
| 103 | + | { | |
| 104 | + | const char *git_dir = repo_get_git_dir(repo); | |
| 105 | + | ||
| 106 | + | if (!git_dir) | |
| 107 | + | return error(_("unable to get git directory")); | |
| 108 | + | ||
| 109 | + | format_path(buf, git_dir, repo->prefix, PATH_FORMAT_CANONICAL); | |
| 110 | + | return 0; | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf) | |
| 114 | + | { | |
| 115 | + | const char *git_dir = repo_get_git_dir(repo); | |
| 116 | + | ||
| 117 | + | if (!git_dir) | |
| 118 | + | return error(_("unable to get git directory")); | |
| 119 | + | ||
| 120 | + | format_path(buf, git_dir, repo->prefix, PATH_FORMAT_RELATIVE); | |
| 121 | + | return 0; | |
| 122 | + | } | |
| 123 | + | ||
| 78 | 124 | static int get_references_format(struct repository *repo, struct strbuf *buf) | |
| 79 | 125 | { | |
| 80 | 126 | strbuf_addstr(buf, | |
| @@ -87,6 +133,10 @@ static const struct repo_info_field repo_info_field[] = { | |||
| 87 | 133 | { "layout.bare", get_layout_bare }, | |
| 88 | 134 | { "layout.shallow", get_layout_shallow }, | |
| 89 | 135 | { "object.format", get_object_format }, | |
| 136 | + | { "path.commondir.absolute", get_path_commondir_absolute }, | |
| 137 | + | { "path.commondir.relative", get_path_commondir_relative }, | |
| 138 | + | { "path.gitdir.absolute", get_path_gitdir_absolute }, | |
| 139 | + | { "path.gitdir.relative", get_path_gitdir_relative }, | |
| 90 | 140 | { "references.format", get_references_format }, | |
| 91 | 141 | }; | |
| 92 | 142 | ||
| @@ -784,13 +834,14 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids, | |||
| 784 | 834 | for (size_t i = 0; i < oids->nr; i++) { | |
| 785 | 835 | struct object_info oi = OBJECT_INFO_INIT; | |
| 786 | 836 | unsigned long inflated; | |
| 837 | + | size_t inflated_st = 0; | |
| 787 | 838 | struct commit *commit; | |
| 788 | 839 | struct object *obj; | |
| 789 | 840 | void *content; | |
| 790 | 841 | off_t disk; | |
| 791 | 842 | int eaten; | |
| 792 | 843 | ||
| 793 | - | oi.sizep = &inflated; | |
| 844 | + | oi.sizep = &inflated_st; | |
| 794 | 845 | oi.disk_sizep = &disk; | |
| 795 | 846 | oi.contentp = &content; | |
| 796 | 847 | ||
| @@ -798,6 +849,7 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids, | |||
| 798 | 849 | OBJECT_INFO_SKIP_FETCH_OBJECT | | |
| 799 | 850 | OBJECT_INFO_QUICK) < 0) | |
| 800 | 851 | continue; | |
| 852 | + | inflated = cast_size_t_to_ulong(inflated_st); | |
| 801 | 853 | ||
| 802 | 854 | obj = parse_object_buffer(the_repository, &oids->oid[i], type, | |
| 803 | 855 | inflated, content, &eaten); | |
modified builtin/reset.c
| @@ -281,11 +281,11 @@ static void parse_args(struct pathspec *pathspec, | |||
| 281 | 281 | * Ok, argv[0] looks like a commit/tree; it should not | |
| 282 | 282 | * be a filename. | |
| 283 | 283 | */ | |
| 284 | - | verify_non_filename(prefix, argv[0]); | |
| 284 | + | verify_non_filename(the_repository, prefix, argv[0]); | |
| 285 | 285 | rev = *argv++; | |
| 286 | 286 | } else { | |
| 287 | 287 | /* Otherwise we treat this as a filename */ | |
| 288 | - | verify_filename(prefix, argv[0], 1); | |
| 288 | + | verify_filename(the_repository, prefix, argv[0], 1); | |
| 289 | 289 | } | |
| 290 | 290 | } | |
| 291 | 291 | ||
| @@ -468,9 +468,9 @@ int cmd_reset(int argc, | |||
| 468 | 468 | trace2_cmd_mode(reset_type_names[reset_type]); | |
| 469 | 469 | ||
| 470 | 470 | if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository))) | |
| 471 | - | setup_work_tree(); | |
| 471 | + | setup_work_tree(the_repository); | |
| 472 | 472 | ||
| 473 | - | if (reset_type == MIXED && is_bare_repository()) | |
| 473 | + | if (reset_type == MIXED && is_bare_repository(the_repository)) | |
| 474 | 474 | die(_("%s reset is not allowed in a bare repository"), | |
| 475 | 475 | _(reset_type_names[reset_type])); | |
| 476 | 476 | ||
modified builtin/rev-list.c
| @@ -111,6 +111,13 @@ enum missing_action { | |||
| 111 | 111 | MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */ | |
| 112 | 112 | }; | |
| 113 | 113 | static enum missing_action arg_missing_action; | |
| 114 | + | static int arg_missing_only; | |
| 115 | + | ||
| 116 | + | static inline int should_collect_missing(void) | |
| 117 | + | { | |
| 118 | + | return arg_missing_action == MA_PRINT || | |
| 119 | + | arg_missing_action == MA_PRINT_INFO; | |
| 120 | + | } | |
| 114 | 121 | ||
| 115 | 122 | /* display only the oid of each object encountered */ | |
| 116 | 123 | static int arg_show_object_names = 1; | |
| @@ -156,7 +163,14 @@ static void print_missing_object(struct missing_objects_map_entry *entry, | |||
| 156 | 163 | { | |
| 157 | 164 | struct strbuf sb = STRBUF_INIT; | |
| 158 | 165 | ||
| 159 | - | if (line_term) | |
| 166 | + | /* | |
| 167 | + | * --missing-only filters present objects out of the walk output. | |
| 168 | + | * It still uses the selected --missing= format for missing ones, | |
| 169 | + | * except the human "?" prefix is omitted (script-friendly OIDs). | |
| 170 | + | */ | |
| 171 | + | if (arg_missing_only && line_term) | |
| 172 | + | printf("%s", oid_to_hex(&entry->entry.oid)); | |
| 173 | + | else if (line_term) | |
| 160 | 174 | printf("?%s", oid_to_hex(&entry->entry.oid)); | |
| 161 | 175 | else | |
| 162 | 176 | printf("%s%cmissing=yes", oid_to_hex(&entry->entry.oid), | |
| @@ -246,6 +260,11 @@ static void show_commit(struct commit *commit, void *data) | |||
| 246 | 260 | return; | |
| 247 | 261 | } | |
| 248 | 262 | ||
| 263 | + | if (arg_missing_only) { | |
| 264 | + | finish_commit(commit); | |
| 265 | + | return; | |
| 266 | + | } | |
| 267 | + | ||
| 249 | 268 | if (show_disk_usage) | |
| 250 | 269 | total_disk_usage += get_object_disk_usage(&commit->object); | |
| 251 | 270 | ||
| @@ -384,6 +403,8 @@ static void show_object(struct object *obj, const char *name, void *cb_data) | |||
| 384 | 403 | if (finish_object(obj, name, cb_data)) | |
| 385 | 404 | return; | |
| 386 | 405 | display_progress(progress, ++progress_counter); | |
| 406 | + | if (arg_missing_only) | |
| 407 | + | return; | |
| 387 | 408 | if (show_disk_usage) | |
| 388 | 409 | total_disk_usage += get_object_disk_usage(obj); | |
| 389 | 410 | if (info->flags & REV_LIST_QUIET) | |
| @@ -486,7 +507,7 @@ static int show_object_fast( | |||
| 486 | 507 | void *payload UNUSED) | |
| 487 | 508 | { | |
| 488 | 509 | fprintf(stdout, "%s\n", oid_to_hex(oid)); | |
| 489 | - | return 1; | |
| 510 | + | return 0; | |
| 490 | 511 | } | |
| 491 | 512 | ||
| 492 | 513 | static void print_disk_usage(off_t size) | |
| @@ -500,7 +521,8 @@ static void print_disk_usage(off_t size) | |||
| 500 | 521 | strbuf_release(&sb); | |
| 501 | 522 | } | |
| 502 | 523 | ||
| 503 | - | static inline int parse_missing_action_value(const char *value) | |
| 524 | + | static inline int parse_missing_action_value(struct repository *repo, | |
| 525 | + | const char *value) | |
| 504 | 526 | { | |
| 505 | 527 | if (!strcmp(value, "error")) { | |
| 506 | 528 | arg_missing_action = MA_ERROR; | |
| @@ -509,25 +531,25 @@ static inline int parse_missing_action_value(const char *value) | |||
| 509 | 531 | ||
| 510 | 532 | if (!strcmp(value, "allow-any")) { | |
| 511 | 533 | arg_missing_action = MA_ALLOW_ANY; | |
| 512 | - | fetch_if_missing = 0; | |
| 534 | + | repo->fetch_if_missing = 0; | |
| 513 | 535 | return 1; | |
| 514 | 536 | } | |
| 515 | 537 | ||
| 516 | 538 | if (!strcmp(value, "print")) { | |
| 517 | 539 | arg_missing_action = MA_PRINT; | |
| 518 | - | fetch_if_missing = 0; | |
| 540 | + | repo->fetch_if_missing = 0; | |
| 519 | 541 | return 1; | |
| 520 | 542 | } | |
| 521 | 543 | ||
| 522 | 544 | if (!strcmp(value, "print-info")) { | |
| 523 | 545 | arg_missing_action = MA_PRINT_INFO; | |
| 524 | - | fetch_if_missing = 0; | |
| 546 | + | repo->fetch_if_missing = 0; | |
| 525 | 547 | return 1; | |
| 526 | 548 | } | |
| 527 | 549 | ||
| 528 | 550 | if (!strcmp(value, "allow-promisor")) { | |
| 529 | 551 | arg_missing_action = MA_ALLOW_PROMISOR; | |
| 530 | - | fetch_if_missing = 0; | |
| 552 | + | repo->fetch_if_missing = 0; | |
| 531 | 553 | return 1; | |
| 532 | 554 | } | |
| 533 | 555 | ||
| @@ -692,7 +714,7 @@ static void prepare_maximal_independent(struct rev_info *revs) | |||
| 692 | 714 | int cmd_rev_list(int argc, | |
| 693 | 715 | const char **argv, | |
| 694 | 716 | const char *prefix, | |
| 695 | - | struct repository *repo UNUSED) | |
| 717 | + | struct repository *repo) | |
| 696 | 718 | { | |
| 697 | 719 | struct rev_info revs; | |
| 698 | 720 | struct rev_list_info info; | |
| @@ -745,16 +767,21 @@ int cmd_rev_list(int argc, | |||
| 745 | 767 | for (i = 1; i < argc; i++) { | |
| 746 | 768 | const char *arg = argv[i]; | |
| 747 | 769 | if (!strcmp(arg, "--exclude-promisor-objects")) { | |
| 748 | - | fetch_if_missing = 0; | |
| 770 | + | repo->fetch_if_missing = 0; | |
| 749 | 771 | revs.exclude_promisor_objects = 1; | |
| 750 | 772 | } else if (skip_prefix(arg, "--missing=", &arg)) { | |
| 751 | - | parse_missing_action_value(arg); | |
| 773 | + | parse_missing_action_value(repo, arg); | |
| 774 | + | } else if (!strcmp(arg, "--missing-only")) { | |
| 775 | + | arg_missing_only = 1; | |
| 752 | 776 | } else if (!strcmp(arg, "-z")) { | |
| 753 | 777 | line_term = '\0'; | |
| 754 | 778 | info_term = '\0'; | |
| 755 | 779 | } | |
| 756 | 780 | } | |
| 757 | 781 | ||
| 782 | + | if (arg_missing_only && !should_collect_missing()) | |
| 783 | + | die(_("--missing-only requires --missing=print or --missing=print-info")); | |
| 784 | + | ||
| 758 | 785 | die_for_incompatible_opt2(revs.exclude_promisor_objects, | |
| 759 | 786 | "--exclude_promisor_objects", | |
| 760 | 787 | arg_missing_action, "--missing"); | |
| @@ -864,6 +891,9 @@ int cmd_rev_list(int argc, | |||
| 864 | 891 | continue; | |
| 865 | 892 | } | |
| 866 | 893 | ||
| 894 | + | if (!strcmp(arg, "--missing-only")) | |
| 895 | + | continue; | |
| 896 | + | ||
| 867 | 897 | usage(rev_list_usage); | |
| 868 | 898 | ||
| 869 | 899 | } | |
| @@ -910,6 +940,11 @@ int cmd_rev_list(int argc, | |||
| 910 | 940 | (revs.left_right || revs.cherry_mark)) | |
| 911 | 941 | die(_("marked counting and '%s' cannot be used together"), "--objects"); | |
| 912 | 942 | ||
| 943 | + | die_for_incompatible_opt2(arg_missing_only, "--missing-only", | |
| 944 | + | revs.count, "--count"); | |
| 945 | + | die_for_incompatible_opt2(arg_missing_only, "--missing-only", | |
| 946 | + | show_disk_usage, "--disk-usage"); | |
| 947 | + | ||
| 913 | 948 | save_commit_buffer = (revs.verbose_header || | |
| 914 | 949 | revs.grep_filter.pattern_list || | |
| 915 | 950 | revs.grep_filter.header_list); | |
| @@ -967,8 +1002,7 @@ int cmd_rev_list(int argc, | |||
| 967 | 1002 | ||
| 968 | 1003 | if (arg_print_omitted) | |
| 969 | 1004 | oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE); | |
| 970 | - | if (arg_missing_action == MA_PRINT || | |
| 971 | - | arg_missing_action == MA_PRINT_INFO) { | |
| 1005 | + | if (should_collect_missing()) { | |
| 972 | 1006 | struct oidset_iter iter; | |
| 973 | 1007 | struct object_id *oid; | |
| 974 | 1008 | ||
| @@ -994,8 +1028,7 @@ int cmd_rev_list(int argc, | |||
| 994 | 1028 | printf("~%s\n", oid_to_hex(oid)); | |
| 995 | 1029 | oidset_clear(&omitted_objects); | |
| 996 | 1030 | } | |
| 997 | - | if (arg_missing_action == MA_PRINT || | |
| 998 | - | arg_missing_action == MA_PRINT_INFO) { | |
| 1031 | + | if (should_collect_missing()) { | |
| 999 | 1032 | struct missing_objects_map_entry *entry; | |
| 1000 | 1033 | struct oidmap_iter iter; | |
| 1001 | 1034 | ||
modified builtin/rev-parse.c
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | #include "builtin.h" | |
| 11 | 11 | ||
| 12 | 12 | #include "abspath.h" | |
| 13 | + | #include "bisect.h" | |
| 13 | 14 | #include "config.h" | |
| 14 | 15 | #include "commit.h" | |
| 15 | 16 | #include "environment.h" | |
| @@ -254,7 +255,7 @@ static int show_file(const char *arg, int output_prefix) | |||
| 254 | 255 | show_default(); | |
| 255 | 256 | if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) { | |
| 256 | 257 | if (output_prefix) { | |
| 257 | - | const char *prefix = startup_info->prefix; | |
| 258 | + | const char *prefix = the_repository->prefix; | |
| 258 | 259 | char *fname = prefix_filename(prefix, arg); | |
| 259 | 260 | show(fname); | |
| 260 | 261 | free(fname); | |
| @@ -652,53 +653,46 @@ enum default_type { | |||
| 652 | 653 | DEFAULT_UNMODIFIED, | |
| 653 | 654 | }; | |
| 654 | 655 | ||
| 655 | - | static void print_path(const char *path, const char *prefix, enum format_type format, enum default_type def) | |
| 656 | + | static void print_path(const char *path, const char *prefix, | |
| 657 | + | enum format_type format, enum default_type def) | |
| 656 | 658 | { | |
| 657 | - | char *cwd = NULL; | |
| 658 | - | /* | |
| 659 | - | * We don't ever produce a relative path if prefix is NULL, so set the | |
| 660 | - | * prefix to the current directory so that we can produce a relative | |
| 661 | - | * path whenever possible. If we're using RELATIVE_IF_SHARED mode, then | |
| 662 | - | * we want an absolute path unless the two share a common prefix, so don't | |
| 663 | - | * set it in that case, since doing so causes a relative path to always | |
| 664 | - | * be produced if possible. | |
| 665 | - | */ | |
| 666 | - | if (!prefix && (format != FORMAT_DEFAULT || def != DEFAULT_RELATIVE_IF_SHARED)) | |
| 667 | - | prefix = cwd = xgetcwd(); | |
| 668 | - | if (format == FORMAT_DEFAULT && def == DEFAULT_UNMODIFIED) { | |
| 669 | - | puts(path); | |
| 670 | - | } else if (format == FORMAT_RELATIVE || | |
| 671 | - | (format == FORMAT_DEFAULT && def == DEFAULT_RELATIVE)) { | |
| 672 | - | /* | |
| 673 | - | * In order for relative_path to work as expected, we need to | |
| 674 | - | * make sure that both paths are absolute paths. If we don't, | |
| 675 | - | * we can end up with an unexpected absolute path that the user | |
| 676 | - | * didn't want. | |
| 677 | - | */ | |
| 678 | - | struct strbuf buf = STRBUF_INIT, realbuf = STRBUF_INIT, prefixbuf = STRBUF_INIT; | |
| 679 | - | if (!is_absolute_path(path)) { | |
| 680 | - | strbuf_realpath_forgiving(&realbuf, path, 1); | |
| 681 | - | path = realbuf.buf; | |
| 682 | - | } | |
| 683 | - | if (!is_absolute_path(prefix)) { | |
| 684 | - | strbuf_realpath_forgiving(&prefixbuf, prefix, 1); | |
| 685 | - | prefix = prefixbuf.buf; | |
| 659 | + | struct strbuf sb = STRBUF_INIT; | |
| 660 | + | enum path_format fmt; | |
| 661 | + | ||
| 662 | + | if (format == FORMAT_DEFAULT) { | |
| 663 | + | switch (def) { | |
| 664 | + | case DEFAULT_RELATIVE: | |
| 665 | + | fmt = PATH_FORMAT_RELATIVE; | |
| 666 | + | break; | |
| 667 | + | case DEFAULT_RELATIVE_IF_SHARED: | |
| 668 | + | fmt = PATH_FORMAT_RELATIVE_IF_SHARED; | |
| 669 | + | break; | |
| 670 | + | case DEFAULT_CANONICAL: | |
| 671 | + | fmt = PATH_FORMAT_CANONICAL; | |
| 672 | + | break; | |
| 673 | + | case DEFAULT_UNMODIFIED: | |
| 674 | + | default: | |
| 675 | + | fmt = PATH_FORMAT_UNMODIFIED; | |
| 676 | + | break; | |
| 686 | 677 | } | |
| 687 | - | puts(relative_path(path, prefix, &buf)); | |
| 688 | - | strbuf_release(&buf); | |
| 689 | - | strbuf_release(&realbuf); | |
| 690 | - | strbuf_release(&prefixbuf); | |
| 691 | - | } else if (format == FORMAT_DEFAULT && def == DEFAULT_RELATIVE_IF_SHARED) { | |
| 692 | - | struct strbuf buf = STRBUF_INIT; | |
| 693 | - | puts(relative_path(path, prefix, &buf)); | |
| 694 | - | strbuf_release(&buf); | |
| 695 | 678 | } else { | |
| 696 | - | struct strbuf buf = STRBUF_INIT; | |
| 697 | - | strbuf_realpath_forgiving(&buf, path, 1); | |
| 698 | - | puts(buf.buf); | |
| 699 | - | strbuf_release(&buf); | |
| 679 | + | switch (format) { | |
| 680 | + | case FORMAT_RELATIVE: | |
| 681 | + | fmt = PATH_FORMAT_RELATIVE; | |
| 682 | + | break; | |
| 683 | + | case FORMAT_CANONICAL: | |
| 684 | + | fmt = PATH_FORMAT_CANONICAL; | |
| 685 | + | break; | |
| 686 | + | default: | |
| 687 | + | fmt = PATH_FORMAT_UNMODIFIED; | |
| 688 | + | break; | |
| 689 | + | } | |
| 700 | 690 | } | |
| 701 | - | free(cwd); | |
| 691 | + | ||
| 692 | + | format_path(&sb, path, prefix, fmt); | |
| 693 | + | puts(sb.buf); | |
| 694 | + | ||
| 695 | + | strbuf_release(&sb); | |
| 702 | 696 | } | |
| 703 | 697 | ||
| 704 | 698 | int cmd_rev_parse(int argc, | |
| @@ -739,7 +733,7 @@ int cmd_rev_parse(int argc, | |||
| 739 | 733 | ||
| 740 | 734 | /* No options; just report on whether we're in a git repo or not. */ | |
| 741 | 735 | if (argc == 1) { | |
| 742 | - | setup_git_directory(); | |
| 736 | + | setup_git_directory(the_repository); | |
| 743 | 737 | repo_config(the_repository, git_default_config, NULL); | |
| 744 | 738 | return 0; | |
| 745 | 739 | } | |
| @@ -749,7 +743,7 @@ int cmd_rev_parse(int argc, | |||
| 749 | 743 | ||
| 750 | 744 | if (as_is) { | |
| 751 | 745 | if (show_file(arg, output_prefix) && as_is < 2) | |
| 752 | - | verify_filename(prefix, arg, 0); | |
| 746 | + | verify_filename(the_repository, prefix, arg, 0); | |
| 753 | 747 | continue; | |
| 754 | 748 | } | |
| 755 | 749 | ||
| @@ -774,7 +768,7 @@ int cmd_rev_parse(int argc, | |||
| 774 | 768 | ||
| 775 | 769 | /* The rest of the options require a git repository. */ | |
| 776 | 770 | if (!did_repo_setup) { | |
| 777 | - | prefix = setup_git_directory(); | |
| 771 | + | prefix = setup_git_directory(the_repository); | |
| 778 | 772 | repo_config(the_repository, git_default_config, NULL); | |
| 779 | 773 | did_repo_setup = 1; | |
| 780 | 774 | ||
| @@ -838,7 +832,8 @@ int cmd_rev_parse(int argc, | |||
| 838 | 832 | prefix = argv[++i]; | |
| 839 | 833 | if (!prefix) | |
| 840 | 834 | die(_("--prefix requires an argument")); | |
| 841 | - | startup_info->prefix = prefix; | |
| 835 | + | FREE_AND_NULL(the_repository->prefix); | |
| 836 | + | the_repository->prefix = xstrdup(prefix); | |
| 842 | 837 | output_prefix = 1; | |
| 843 | 838 | continue; | |
| 844 | 839 | } | |
| @@ -940,13 +935,23 @@ int cmd_rev_parse(int argc, | |||
| 940 | 935 | continue; | |
| 941 | 936 | } | |
| 942 | 937 | if (!strcmp(arg, "--bisect")) { | |
| 938 | + | char *prefix; | |
| 939 | + | char *term_bad = NULL; | |
| 940 | + | char *term_good = NULL; | |
| 943 | 941 | struct refs_for_each_ref_options opts = { 0 }; | |
| 944 | - | opts.prefix = "refs/bisect/bad"; | |
| 942 | + | read_bisect_terms(&term_bad, &term_good); | |
| 943 | + | prefix = xstrfmt("refs/bisect/%s", term_bad); | |
| 944 | + | opts.prefix = prefix; | |
| 945 | 945 | refs_for_each_ref_ext(get_main_ref_store(the_repository), | |
| 946 | 946 | show_reference, NULL, &opts); | |
| 947 | - | opts.prefix = "refs/bisect/good"; | |
| 947 | + | free(prefix); | |
| 948 | + | prefix = xstrfmt("refs/bisect/%s", term_good); | |
| 949 | + | opts.prefix = prefix; | |
| 948 | 950 | refs_for_each_ref_ext(get_main_ref_store(the_repository), | |
| 949 | 951 | anti_reference, NULL, &opts); | |
| 952 | + | free(prefix); | |
| 953 | + | free(term_good); | |
| 954 | + | free(term_bad); | |
| 950 | 955 | continue; | |
| 951 | 956 | } | |
| 952 | 957 | if (opt_with_value(arg, "--branches", &arg)) { | |
| @@ -1006,7 +1011,7 @@ int cmd_rev_parse(int argc, | |||
| 1006 | 1011 | } | |
| 1007 | 1012 | if (!strcmp(arg, "--show-cdup")) { | |
| 1008 | 1013 | const char *pfx = prefix; | |
| 1009 | - | if (!is_inside_work_tree()) { | |
| 1014 | + | if (!is_inside_work_tree(the_repository)) { | |
| 1010 | 1015 | const char *work_tree = | |
| 1011 | 1016 | repo_get_work_tree(the_repository); | |
| 1012 | 1017 | if (work_tree) | |
| @@ -1063,17 +1068,17 @@ int cmd_rev_parse(int argc, | |||
| 1063 | 1068 | continue; | |
| 1064 | 1069 | } | |
| 1065 | 1070 | if (!strcmp(arg, "--is-inside-git-dir")) { | |
| 1066 | - | printf("%s\n", is_inside_git_dir() ? "true" | |
| 1071 | + | printf("%s\n", is_inside_git_dir(the_repository) ? "true" | |
| 1067 | 1072 | : "false"); | |
| 1068 | 1073 | continue; | |
| 1069 | 1074 | } | |
| 1070 | 1075 | if (!strcmp(arg, "--is-inside-work-tree")) { | |
| 1071 | - | printf("%s\n", is_inside_work_tree() ? "true" | |
| 1076 | + | printf("%s\n", is_inside_work_tree(the_repository) ? "true" | |
| 1072 | 1077 | : "false"); | |
| 1073 | 1078 | continue; | |
| 1074 | 1079 | } | |
| 1075 | 1080 | if (!strcmp(arg, "--is-bare-repository")) { | |
| 1076 | - | printf("%s\n", is_bare_repository() ? "true" | |
| 1081 | + | printf("%s\n", is_bare_repository(the_repository) ? "true" | |
| 1077 | 1082 | : "false"); | |
| 1078 | 1083 | continue; | |
| 1079 | 1084 | } | |
| @@ -1173,7 +1178,7 @@ int cmd_rev_parse(int argc, | |||
| 1173 | 1178 | as_is = 1; | |
| 1174 | 1179 | if (!show_file(arg, output_prefix)) | |
| 1175 | 1180 | continue; | |
| 1176 | - | verify_filename(prefix, arg, 1); | |
| 1181 | + | verify_filename(the_repository, prefix, arg, 1); | |
| 1177 | 1182 | } | |
| 1178 | 1183 | strbuf_release(&buf); | |
| 1179 | 1184 | if (verify) { | |
modified builtin/rm.c
| @@ -296,7 +296,7 @@ int cmd_rm(int argc, | |||
| 296 | 296 | die(_("No pathspec was given. Which files should I remove?")); | |
| 297 | 297 | ||
| 298 | 298 | if (!index_only) | |
| 299 | - | setup_work_tree(); | |
| 299 | + | setup_work_tree(the_repository); | |
| 300 | 300 | ||
| 301 | 301 | prepare_repo_settings(the_repository); | |
| 302 | 302 | the_repository->settings.command_requires_full_index = 0; | |
modified builtin/send-pack.c
| @@ -153,7 +153,7 @@ int cmd_send_pack(int argc, | |||
| 153 | 153 | const char *prefix, | |
| 154 | 154 | struct repository *repo) | |
| 155 | 155 | { | |
| 156 | - | struct refspec rs = REFSPEC_INIT_PUSH; | |
| 156 | + | struct refspec rs; | |
| 157 | 157 | const char *remote_name = NULL; | |
| 158 | 158 | struct remote *remote = NULL; | |
| 159 | 159 | const char *dest = NULL; | |
| @@ -214,6 +214,9 @@ int cmd_send_pack(int argc, | |||
| 214 | 214 | ||
| 215 | 215 | repo_config(repo, send_pack_config, NULL); | |
| 216 | 216 | argc = parse_options(argc, argv, prefix, options, send_pack_usage, 0); | |
| 217 | + | ||
| 218 | + | refspec_init_push(&rs, repo->hash_algo); | |
| 219 | + | ||
| 217 | 220 | if (argc > 0) { | |
| 218 | 221 | dest = argv[0]; | |
| 219 | 222 | refspec_appendn(&rs, argv + 1, argc - 1); | |
| @@ -273,8 +276,9 @@ int cmd_send_pack(int argc, | |||
| 273 | 276 | fd[0] = 0; | |
| 274 | 277 | fd[1] = 1; | |
| 275 | 278 | } else { | |
| 276 | - | conn = git_connect(fd, dest, "git-receive-pack", receivepack, | |
| 277 | - | args.verbose ? CONNECT_VERBOSE : 0); | |
| 279 | + | conn = git_connect(fd, dest, GIT_CONNECT_RECEIVE_PACK, | |
| 280 | + | receivepack, | |
| 281 | + | args.verbose ? CONNECT_VERBOSE : 0); | |
| 278 | 282 | } | |
| 279 | 283 | ||
| 280 | 284 | packet_reader_init(&reader, fd[0], NULL, 0, | |
modified builtin/shortlog.c
| @@ -433,6 +433,8 @@ int cmd_shortlog(int argc, | |||
| 433 | 433 | case PARSE_OPT_UNKNOWN: | |
| 434 | 434 | break; | |
| 435 | 435 | case PARSE_OPT_HELP: | |
| 436 | + | exit(0); | |
| 437 | + | case PARSE_OPT_HELP_ERROR: | |
| 436 | 438 | case PARSE_OPT_ERROR: | |
| 437 | 439 | case PARSE_OPT_SUBCOMMAND: | |
| 438 | 440 | exit(129); | |
modified builtin/show-branch.c
| @@ -62,11 +62,10 @@ static const char *get_color_reset_code(void) | |||
| 62 | 62 | ||
| 63 | 63 | static struct commit *interesting(struct prio_queue *queue) | |
| 64 | 64 | { | |
| 65 | - | for (size_t i = 0; i < queue->nr; i++) { | |
| 66 | - | struct commit *commit = queue->array[i].data; | |
| 67 | - | if (commit->object.flags & UNINTERESTING) | |
| 68 | - | continue; | |
| 69 | - | return commit; | |
| 65 | + | struct commit *commit; | |
| 66 | + | prio_queue_for_each(queue, commit) { | |
| 67 | + | if (!(commit->object.flags & UNINTERESTING)) | |
| 68 | + | return commit; | |
| 70 | 69 | } | |
| 71 | 70 | return NULL; | |
| 72 | 71 | } | |
| @@ -228,17 +227,18 @@ static void join_revs(struct prio_queue *queue, | |||
| 228 | 227 | { | |
| 229 | 228 | int all_mask = ((1u << (REV_SHIFT + num_rev)) - 1); | |
| 230 | 229 | int all_revs = all_mask & ~((1u << REV_SHIFT) - 1); | |
| 230 | + | struct commit *commit; | |
| 231 | 231 | ||
| 232 | - | while (queue->nr) { | |
| 232 | + | while ((commit = prio_queue_peek(queue))) { | |
| 233 | 233 | struct commit_list *parents; | |
| 234 | 234 | int still_interesting = !!interesting(queue); | |
| 235 | - | struct commit *commit = prio_queue_peek(queue); | |
| 236 | - | bool get_pending = true; | |
| 237 | 235 | int flags = commit->object.flags & all_mask; | |
| 238 | 236 | ||
| 239 | 237 | if (!still_interesting && extra <= 0) | |
| 240 | 238 | break; | |
| 241 | 239 | ||
| 240 | + | prio_queue_get(queue); | |
| 241 | + | ||
| 242 | 242 | mark_seen(commit, seen_p); | |
| 243 | 243 | if ((flags & all_revs) == all_revs) | |
| 244 | 244 | flags |= UNINTERESTING; | |
| @@ -254,14 +254,8 @@ static void join_revs(struct prio_queue *queue, | |||
| 254 | 254 | if (mark_seen(p, seen_p) && !still_interesting) | |
| 255 | 255 | extra--; | |
| 256 | 256 | p->object.flags |= flags; | |
| 257 | - | if (get_pending) | |
| 258 | - | prio_queue_replace(queue, p); | |
| 259 | - | else | |
| 260 | - | prio_queue_put(queue, p); | |
| 261 | - | get_pending = false; | |
| 257 | + | prio_queue_put(queue, p); | |
| 262 | 258 | } | |
| 263 | - | if (get_pending) | |
| 264 | - | prio_queue_get(queue); | |
| 265 | 259 | } | |
| 266 | 260 | ||
| 267 | 261 | /* | |
modified builtin/sparse-checkout.c
| @@ -63,7 +63,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix, | |||
| 63 | 63 | int res; | |
| 64 | 64 | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 65 | 65 | ||
| 66 | - | setup_work_tree(); | |
| 66 | + | setup_work_tree(the_repository); | |
| 67 | 67 | if (!cfg->apply_sparse_checkout) | |
| 68 | 68 | die(_("this worktree is not sparse")); | |
| 69 | 69 | ||
| @@ -73,7 +73,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix, | |||
| 73 | 73 | ||
| 74 | 74 | memset(&pl, 0, sizeof(pl)); | |
| 75 | 75 | ||
| 76 | - | pl.use_cone_patterns = core_sparse_checkout_cone; | |
| 76 | + | pl.use_cone_patterns = cfg->core_sparse_checkout_cone; | |
| 77 | 77 | ||
| 78 | 78 | sparse_filename = get_sparse_checkout_filename(); | |
| 79 | 79 | res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL, 0); | |
| @@ -229,7 +229,7 @@ static int update_working_directory(struct repository *r, | |||
| 229 | 229 | o.dst_index = r->index; | |
| 230 | 230 | o.skip_sparse_checkout = 0; | |
| 231 | 231 | ||
| 232 | - | setup_work_tree(); | |
| 232 | + | setup_work_tree(the_repository); | |
| 233 | 233 | ||
| 234 | 234 | repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR); | |
| 235 | 235 | ||
| @@ -334,13 +334,15 @@ static int write_patterns_and_update(struct repository *repo, | |||
| 334 | 334 | FILE *fp; | |
| 335 | 335 | struct lock_file lk = LOCK_INIT; | |
| 336 | 336 | int result; | |
| 337 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 337 | 338 | ||
| 338 | 339 | sparse_filename = get_sparse_checkout_filename(); | |
| 339 | 340 | ||
| 340 | 341 | if (safe_create_leading_directories(repo, sparse_filename)) | |
| 341 | 342 | die(_("failed to create directory for sparse-checkout file")); | |
| 342 | 343 | ||
| 343 | - | hold_lock_file_for_update(&lk, sparse_filename, LOCK_DIE_ON_ERROR); | |
| 344 | + | repo_hold_lock_file_for_update(repo, &lk, sparse_filename, | |
| 345 | + | LOCK_DIE_ON_ERROR); | |
| 344 | 346 | ||
| 345 | 347 | result = update_working_directory(repo, pl); | |
| 346 | 348 | if (result) { | |
| @@ -353,7 +355,7 @@ static int write_patterns_and_update(struct repository *repo, | |||
| 353 | 355 | if (!fp) | |
| 354 | 356 | die_errno(_("unable to fdopen %s"), get_lock_file_path(&lk)); | |
| 355 | 357 | ||
| 356 | - | if (core_sparse_checkout_cone) | |
| 358 | + | if (cfg->core_sparse_checkout_cone) | |
| 357 | 359 | write_cone_to_file(fp, pl); | |
| 358 | 360 | else | |
| 359 | 361 | write_patterns_to_file(fp, pl); | |
| @@ -402,15 +404,15 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) { | |||
| 402 | 404 | ||
| 403 | 405 | /* If not specified, use previous definition of cone mode */ | |
| 404 | 406 | if (*cone_mode == -1 && cfg->apply_sparse_checkout) | |
| 405 | - | *cone_mode = core_sparse_checkout_cone; | |
| 407 | + | *cone_mode = cfg->core_sparse_checkout_cone; | |
| 406 | 408 | ||
| 407 | 409 | /* Set cone/non-cone mode appropriately */ | |
| 408 | 410 | cfg->apply_sparse_checkout = 1; | |
| 409 | 411 | if (*cone_mode == 1 || *cone_mode == -1) { | |
| 410 | - | core_sparse_checkout_cone = 1; | |
| 412 | + | cfg->core_sparse_checkout_cone = 1; | |
| 411 | 413 | return MODE_CONE_PATTERNS; | |
| 412 | 414 | } | |
| 413 | - | core_sparse_checkout_cone = 0; | |
| 415 | + | cfg->core_sparse_checkout_cone = 0; | |
| 414 | 416 | return MODE_ALL_PATTERNS; | |
| 415 | 417 | } | |
| 416 | 418 | ||
| @@ -468,7 +470,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix, | |||
| 468 | 470 | OPT_END(), | |
| 469 | 471 | }; | |
| 470 | 472 | ||
| 471 | - | setup_work_tree(); | |
| 473 | + | setup_work_tree(the_repository); | |
| 472 | 474 | repo_read_index(repo); | |
| 473 | 475 | ||
| 474 | 476 | init_opts.cone_mode = -1; | |
| @@ -577,7 +579,9 @@ static void add_patterns_from_input(struct pattern_list *pl, | |||
| 577 | 579 | FILE *file) | |
| 578 | 580 | { | |
| 579 | 581 | int i; | |
| 580 | - | if (core_sparse_checkout_cone) { | |
| 582 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 583 | + | ||
| 584 | + | if (cfg->core_sparse_checkout_cone) { | |
| 581 | 585 | struct strbuf line = STRBUF_INIT; | |
| 582 | 586 | ||
| 583 | 587 | hashmap_init(&pl->recursive_hashmap, pl_hashmap_cmp, NULL, 0); | |
| @@ -636,13 +640,14 @@ static void add_patterns_cone_mode(int argc, const char **argv, | |||
| 636 | 640 | struct pattern_entry *pe; | |
| 637 | 641 | struct hashmap_iter iter; | |
| 638 | 642 | struct pattern_list existing; | |
| 643 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 639 | 644 | char *sparse_filename = get_sparse_checkout_filename(); | |
| 640 | 645 | ||
| 641 | 646 | add_patterns_from_input(pl, argc, argv, | |
| 642 | 647 | use_stdin ? stdin : NULL); | |
| 643 | 648 | ||
| 644 | 649 | memset(&existing, 0, sizeof(existing)); | |
| 645 | - | existing.use_cone_patterns = core_sparse_checkout_cone; | |
| 650 | + | existing.use_cone_patterns = cfg->core_sparse_checkout_cone; | |
| 646 | 651 | ||
| 647 | 652 | if (add_patterns_from_file_to_list(sparse_filename, "", 0, | |
| 648 | 653 | &existing, NULL, 0)) | |
| @@ -690,7 +695,7 @@ static int modify_pattern_list(struct repository *repo, | |||
| 690 | 695 | ||
| 691 | 696 | switch (m) { | |
| 692 | 697 | case ADD: | |
| 693 | - | if (core_sparse_checkout_cone) | |
| 698 | + | if (cfg->core_sparse_checkout_cone) | |
| 694 | 699 | add_patterns_cone_mode(args->nr, args->v, pl, use_stdin); | |
| 695 | 700 | else | |
| 696 | 701 | add_patterns_literal(args->nr, args->v, pl, use_stdin); | |
| @@ -723,11 +728,12 @@ static void sanitize_paths(struct repository *repo, | |||
| 723 | 728 | const char *prefix, int skip_checks) | |
| 724 | 729 | { | |
| 725 | 730 | int i; | |
| 731 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 726 | 732 | ||
| 727 | 733 | if (!args->nr) | |
| 728 | 734 | return; | |
| 729 | 735 | ||
| 730 | - | if (prefix && *prefix && core_sparse_checkout_cone) { | |
| 736 | + | if (prefix && *prefix && cfg->core_sparse_checkout_cone) { | |
| 731 | 737 | /* | |
| 732 | 738 | * The args are not pathspecs, so unfortunately we | |
| 733 | 739 | * cannot imitate how cmd_add() uses parse_pathspec(). | |
| @@ -735,7 +741,8 @@ static void sanitize_paths(struct repository *repo, | |||
| 735 | 741 | int prefix_len = strlen(prefix); | |
| 736 | 742 | ||
| 737 | 743 | for (i = 0; i < args->nr; i++) { | |
| 738 | - | char *prefixed_path = prefix_path(prefix, prefix_len, args->v[i]); | |
| 744 | + | char *prefixed_path = prefix_path(the_repository, prefix, | |
| 745 | + | prefix_len, args->v[i]); | |
| 739 | 746 | strvec_replace(args, i, prefixed_path); | |
| 740 | 747 | free(prefixed_path); | |
| 741 | 748 | } | |
| @@ -744,10 +751,10 @@ static void sanitize_paths(struct repository *repo, | |||
| 744 | 751 | if (skip_checks) | |
| 745 | 752 | return; | |
| 746 | 753 | ||
| 747 | - | if (prefix && *prefix && !core_sparse_checkout_cone) | |
| 754 | + | if (prefix && *prefix && !cfg->core_sparse_checkout_cone) | |
| 748 | 755 | die(_("please run from the toplevel directory in non-cone mode")); | |
| 749 | 756 | ||
| 750 | - | if (core_sparse_checkout_cone) { | |
| 757 | + | if (cfg->core_sparse_checkout_cone) { | |
| 751 | 758 | for (i = 0; i < args->nr; i++) { | |
| 752 | 759 | if (args->v[i][0] == '/') | |
| 753 | 760 | die(_("specify directories rather than patterns (no leading slash)")); | |
| @@ -769,7 +776,7 @@ static void sanitize_paths(struct repository *repo, | |||
| 769 | 776 | if (S_ISSPARSEDIR(ce->ce_mode)) | |
| 770 | 777 | continue; | |
| 771 | 778 | ||
| 772 | - | if (core_sparse_checkout_cone) | |
| 779 | + | if (cfg->core_sparse_checkout_cone) | |
| 773 | 780 | die(_("'%s' is not a directory; to treat it as a directory anyway, rerun with --skip-checks"), args->v[i]); | |
| 774 | 781 | else | |
| 775 | 782 | warning(_("pass a leading slash before paths such as '%s' if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)."), args->v[i]); | |
| @@ -801,7 +808,7 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix, | |||
| 801 | 808 | int ret; | |
| 802 | 809 | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 803 | 810 | ||
| 804 | - | setup_work_tree(); | |
| 811 | + | setup_work_tree(the_repository); | |
| 805 | 812 | if (!cfg->apply_sparse_checkout) | |
| 806 | 813 | die(_("no sparse-checkout to add to")); | |
| 807 | 814 | ||
| @@ -836,6 +843,7 @@ static struct sparse_checkout_set_opts { | |||
| 836 | 843 | static int sparse_checkout_set(int argc, const char **argv, const char *prefix, | |
| 837 | 844 | struct repository *repo) | |
| 838 | 845 | { | |
| 846 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 839 | 847 | int default_patterns_nr = 2; | |
| 840 | 848 | const char *default_patterns[] = {"/*", "!/*/", NULL}; | |
| 841 | 849 | ||
| @@ -855,7 +863,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix, | |||
| 855 | 863 | struct strvec patterns = STRVEC_INIT; | |
| 856 | 864 | int ret; | |
| 857 | 865 | ||
| 858 | - | setup_work_tree(); | |
| 866 | + | setup_work_tree(the_repository); | |
| 859 | 867 | repo_read_index(repo); | |
| 860 | 868 | ||
| 861 | 869 | set_opts.cone_mode = -1; | |
| @@ -873,7 +881,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix, | |||
| 873 | 881 | * non-cone mode, if nothing is specified, manually select just the | |
| 874 | 882 | * top-level directory (much as 'init' would do). | |
| 875 | 883 | */ | |
| 876 | - | if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) { | |
| 884 | + | if (!cfg->core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) { | |
| 877 | 885 | for (int i = 0; i < default_patterns_nr; i++) | |
| 878 | 886 | strvec_push(&patterns, default_patterns[i]); | |
| 879 | 887 | } else { | |
| @@ -911,7 +919,7 @@ static int sparse_checkout_reapply(int argc, const char **argv, | |||
| 911 | 919 | }; | |
| 912 | 920 | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 913 | 921 | ||
| 914 | - | setup_work_tree(); | |
| 922 | + | setup_work_tree(the_repository); | |
| 915 | 923 | if (!cfg->apply_sparse_checkout) | |
| 916 | 924 | die(_("must be in a sparse-checkout to reapply sparsity patterns")); | |
| 917 | 925 | ||
| @@ -974,10 +982,10 @@ static int sparse_checkout_clean(int argc, const char **argv, | |||
| 974 | 982 | OPT_END(), | |
| 975 | 983 | }; | |
| 976 | 984 | ||
| 977 | - | setup_work_tree(); | |
| 985 | + | setup_work_tree(the_repository); | |
| 978 | 986 | if (!cfg->apply_sparse_checkout) | |
| 979 | 987 | die(_("must be in a sparse-checkout to clean directories")); | |
| 980 | - | if (!core_sparse_checkout_cone) | |
| 988 | + | if (!cfg->core_sparse_checkout_cone) | |
| 981 | 989 | die(_("must be in a cone-mode sparse-checkout to clean directories")); | |
| 982 | 990 | ||
| 983 | 991 | argc = parse_options(argc, argv, prefix, | |
| @@ -1052,7 +1060,7 @@ static int sparse_checkout_disable(int argc, const char **argv, | |||
| 1052 | 1060 | * forcibly return to a dense checkout regardless of initial state. | |
| 1053 | 1061 | */ | |
| 1054 | 1062 | ||
| 1055 | - | setup_work_tree(); | |
| 1063 | + | setup_work_tree(the_repository); | |
| 1056 | 1064 | argc = parse_options(argc, argv, prefix, | |
| 1057 | 1065 | builtin_sparse_checkout_disable_options, | |
| 1058 | 1066 | builtin_sparse_checkout_disable_usage, 0); | |
| @@ -1141,6 +1149,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char * | |||
| 1141 | 1149 | FILE *fp; | |
| 1142 | 1150 | int ret; | |
| 1143 | 1151 | struct pattern_list pl = {0}; | |
| 1152 | + | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 1144 | 1153 | char *sparse_filename; | |
| 1145 | 1154 | check_rules_opts.cone_mode = -1; | |
| 1146 | 1155 | ||
| @@ -1152,7 +1161,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char * | |||
| 1152 | 1161 | check_rules_opts.cone_mode = 1; | |
| 1153 | 1162 | ||
| 1154 | 1163 | update_cone_mode(&check_rules_opts.cone_mode); | |
| 1155 | - | pl.use_cone_patterns = core_sparse_checkout_cone; | |
| 1164 | + | pl.use_cone_patterns = cfg->core_sparse_checkout_cone; | |
| 1156 | 1165 | if (check_rules_opts.rules_file) { | |
| 1157 | 1166 | fp = xfopen(check_rules_opts.rules_file, "r"); | |
| 1158 | 1167 | add_patterns_from_input(&pl, argc, argv, fp); | |
modified builtin/stash.c
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | #include "object-name.h" | |
| 11 | 11 | #include "parse-options.h" | |
| 12 | 12 | #include "refs.h" | |
| 13 | + | #include "stash.h" | |
| 13 | 14 | #include "lockfile.h" | |
| 14 | 15 | #include "cache-tree.h" | |
| 15 | 16 | #include "unpack-trees.h" | |
| @@ -44,7 +45,7 @@ | |||
| 44 | 45 | #define BUILTIN_STASH_POP_USAGE \ | |
| 45 | 46 | N_("git stash pop [--index] [-q | --quiet] [<stash>]") | |
| 46 | 47 | #define BUILTIN_STASH_APPLY_USAGE \ | |
| 47 | - | N_("git stash apply [--index] [-q | --quiet] [<stash>]") | |
| 48 | + | N_("git stash apply [--index] [-q | --quiet] [--label-ours=<label>] [--label-theirs=<label>] [--label-base=<label>] [<stash>]") | |
| 48 | 49 | #define BUILTIN_STASH_BRANCH_USAGE \ | |
| 49 | 50 | N_("git stash branch <branchname> [<stash>]") | |
| 50 | 51 | #define BUILTIN_STASH_STORE_USAGE \ | |
| @@ -372,6 +373,56 @@ static int reset_tree(struct object_id *i_tree, int update, int reset) | |||
| 372 | 373 | return 0; | |
| 373 | 374 | } | |
| 374 | 375 | ||
| 376 | + | static int create_index_from_tree(const struct object_id *tree_id, | |
| 377 | + | const char *index_path) | |
| 378 | + | { | |
| 379 | + | int nr_trees = 1; | |
| 380 | + | int ret = 0; | |
| 381 | + | struct unpack_trees_options opts; | |
| 382 | + | struct tree_desc t[MAX_UNPACK_TREES]; | |
| 383 | + | struct tree *tree; | |
| 384 | + | struct index_state dst_istate = INDEX_STATE_INIT(the_repository); | |
| 385 | + | struct lock_file lock_file = LOCK_INIT; | |
| 386 | + | ||
| 387 | + | repo_read_index_preload(the_repository, NULL, 0); | |
| 388 | + | refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL); | |
| 389 | + | ||
| 390 | + | hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR); | |
| 391 | + | ||
| 392 | + | memset(&opts, 0, sizeof(opts)); | |
| 393 | + | ||
| 394 | + | tree = repo_parse_tree_indirect(the_repository, tree_id); | |
| 395 | + | if (!tree || repo_parse_tree(the_repository, tree)) { | |
| 396 | + | ret = -1; | |
| 397 | + | goto done; | |
| 398 | + | } | |
| 399 | + | ||
| 400 | + | init_tree_desc(t, &tree->object.oid, tree->buffer, tree->size); | |
| 401 | + | ||
| 402 | + | opts.head_idx = 1; | |
| 403 | + | opts.src_index = the_repository->index; | |
| 404 | + | opts.dst_index = &dst_istate; | |
| 405 | + | opts.merge = 1; | |
| 406 | + | opts.reset = UNPACK_RESET_PROTECT_UNTRACKED; | |
| 407 | + | opts.fn = oneway_merge; | |
| 408 | + | ||
| 409 | + | if (unpack_trees(nr_trees, t, &opts)) { | |
| 410 | + | ret = -1; | |
| 411 | + | goto done; | |
| 412 | + | } | |
| 413 | + | ||
| 414 | + | if (write_locked_index(&dst_istate, &lock_file, COMMIT_LOCK)) { | |
| 415 | + | ret = error(_("unable to write new index file")); | |
| 416 | + | goto done; | |
| 417 | + | } | |
| 418 | + | ||
| 419 | + | done: | |
| 420 | + | release_index(&dst_istate); | |
| 421 | + | if (ret) | |
| 422 | + | rollback_lock_file(&lock_file); | |
| 423 | + | return ret; | |
| 424 | + | } | |
| 425 | + | ||
| 375 | 426 | static int diff_tree_binary(struct strbuf *out, struct object_id *w_commit) | |
| 376 | 427 | { | |
| 377 | 428 | struct child_process cp = CHILD_PROCESS_INIT; | |
| @@ -590,8 +641,12 @@ static void unstage_changes_unless_new(struct object_id *orig_tree) | |||
| 590 | 641 | die(_("could not write index")); | |
| 591 | 642 | } | |
| 592 | 643 | ||
| 593 | - | static int do_apply_stash(const char *prefix, struct stash_info *info, | |
| 594 | - | int index, int quiet) | |
| 644 | + | static enum stash_apply_result do_apply_stash(const char *prefix, | |
| 645 | + | struct stash_info *info, | |
| 646 | + | int index, int quiet, | |
| 647 | + | const char *label_ours, | |
| 648 | + | const char *label_theirs, | |
| 649 | + | const char *label_base) | |
| 595 | 650 | { | |
| 596 | 651 | int clean, ret; | |
| 597 | 652 | int has_index = index; | |
| @@ -643,9 +698,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, | |||
| 643 | 698 | ||
| 644 | 699 | init_ui_merge_options(&o, the_repository); | |
| 645 | 700 | ||
| 646 | - | o.branch1 = "Updated upstream"; | |
| 647 | - | o.branch2 = "Stashed changes"; | |
| 648 | - | o.ancestor = "Stash base"; | |
| 701 | + | o.branch1 = label_ours ? label_ours : "Updated upstream"; | |
| 702 | + | o.branch2 = label_theirs ? label_theirs : "Stashed changes"; | |
| 703 | + | o.ancestor = label_base ? label_base : "Stash base"; | |
| 649 | 704 | ||
| 650 | 705 | if (oideq(&info->b_tree, &c_tree)) | |
| 651 | 706 | o.branch1 = "Version stash was based on"; | |
| @@ -665,8 +720,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, | |||
| 665 | 720 | ||
| 666 | 721 | /* | |
| 667 | 722 | * If 'clean' >= 0, reverse the value for 'ret' so 'ret' is 0 when the | |
| 668 | - | * merge was clean, and nonzero if the merge was unclean or encountered | |
| 669 | - | * an error. | |
| 723 | + | * merge was clean, and 1 if the merge was unclean or a negative value | |
| 724 | + | * if it encountered an error. | |
| 670 | 725 | */ | |
| 671 | 726 | ret = clean >= 0 ? !clean : clean; | |
| 672 | 727 | ||
| @@ -723,11 +778,18 @@ static int apply_stash(int argc, const char **argv, const char *prefix, | |||
| 723 | 778 | int ret = -1; | |
| 724 | 779 | int quiet = 0; | |
| 725 | 780 | int index = use_index; | |
| 781 | + | const char *label_ours = NULL, *label_theirs = NULL, *label_base = NULL; | |
| 726 | 782 | struct stash_info info = STASH_INFO_INIT; | |
| 727 | 783 | struct option options[] = { | |
| 728 | 784 | OPT__QUIET(&quiet, N_("be quiet, only report errors")), | |
| 729 | 785 | OPT_BOOL(0, "index", &index, | |
| 730 | 786 | N_("attempt to recreate the index")), | |
| 787 | + | OPT_STRING(0, "label-ours", &label_ours, N_("label"), | |
| 788 | + | N_("label for the upstream side in conflict markers")), | |
| 789 | + | OPT_STRING(0, "label-theirs", &label_theirs, N_("label"), | |
| 790 | + | N_("label for the stashed side in conflict markers")), | |
| 791 | + | OPT_STRING(0, "label-base", &label_base, N_("label"), | |
| 792 | + | N_("label for the base in diff3 conflict markers")), | |
| 731 | 793 | OPT_END() | |
| 732 | 794 | }; | |
| 733 | 795 | ||
| @@ -737,7 +799,8 @@ static int apply_stash(int argc, const char **argv, const char *prefix, | |||
| 737 | 799 | if (get_stash_info(&info, argc, argv)) | |
| 738 | 800 | goto cleanup; | |
| 739 | 801 | ||
| 740 | - | ret = do_apply_stash(prefix, &info, index, quiet); | |
| 802 | + | ret = do_apply_stash(prefix, &info, index, quiet, | |
| 803 | + | label_ours, label_theirs, label_base); | |
| 741 | 804 | cleanup: | |
| 742 | 805 | free_stash_info(&info); | |
| 743 | 806 | return ret; | |
| @@ -836,7 +899,8 @@ static int pop_stash(int argc, const char **argv, const char *prefix, | |||
| 836 | 899 | if (get_stash_info_assert(&info, argc, argv)) | |
| 837 | 900 | goto cleanup; | |
| 838 | 901 | ||
| 839 | - | if ((ret = do_apply_stash(prefix, &info, index, quiet))) | |
| 902 | + | if ((ret = do_apply_stash(prefix, &info, index, quiet, | |
| 903 | + | NULL, NULL, NULL))) | |
| 840 | 904 | printf_ln(_("The stash entry is kept in case " | |
| 841 | 905 | "you need it again.")); | |
| 842 | 906 | else | |
| @@ -877,7 +941,8 @@ static int branch_stash(int argc, const char **argv, const char *prefix, | |||
| 877 | 941 | strvec_push(&cp.args, oid_to_hex(&info.b_commit)); | |
| 878 | 942 | ret = run_command(&cp); | |
| 879 | 943 | if (!ret) | |
| 880 | - | ret = do_apply_stash(prefix, &info, 1, 0); | |
| 944 | + | ret = do_apply_stash(prefix, &info, 1, 0, | |
| 945 | + | NULL, NULL, NULL); | |
| 881 | 946 | if (!ret && info.is_stash_ref) | |
| 882 | 947 | ret = do_drop_stash(&info, 0); | |
| 883 | 948 | ||
| @@ -1309,18 +1374,26 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, | |||
| 1309 | 1374 | struct interactive_options *interactive_opts) | |
| 1310 | 1375 | { | |
| 1311 | 1376 | int ret = 0; | |
| 1312 | - | struct child_process cp_read_tree = CHILD_PROCESS_INIT; | |
| 1313 | 1377 | struct child_process cp_diff_tree = CHILD_PROCESS_INIT; | |
| 1378 | + | struct commit *head_commit; | |
| 1379 | + | const struct object_id *head_tree; | |
| 1314 | 1380 | struct index_state istate = INDEX_STATE_INIT(the_repository); | |
| 1315 | 1381 | char *old_index_env = NULL, *old_repo_index_file; | |
| 1316 | 1382 | ||
| 1317 | 1383 | remove_path(stash_index_path.buf); | |
| 1318 | 1384 | ||
| 1319 | - | cp_read_tree.git_cmd = 1; | |
| 1320 | - | strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL); | |
| 1321 | - | strvec_pushf(&cp_read_tree.env, "GIT_INDEX_FILE=%s", | |
| 1322 | - | stash_index_path.buf); | |
| 1323 | - | if (run_command(&cp_read_tree)) { | |
| 1385 | + | head_commit = lookup_commit(the_repository, &info->b_commit); | |
| 1386 | + | if (!head_commit || repo_parse_commit(the_repository, head_commit)) { | |
| 1387 | + | ret = -1; | |
| 1388 | + | goto done; | |
| 1389 | + | } | |
| 1390 | + | head_tree = get_commit_tree_oid(head_commit); | |
| 1391 | + | if (!head_tree) { | |
| 1392 | + | ret = -1; | |
| 1393 | + | goto done; | |
| 1394 | + | } | |
| 1395 | + | ||
| 1396 | + | if (create_index_from_tree(head_tree, stash_index_path.buf)) { | |
| 1324 | 1397 | ret = -1; | |
| 1325 | 1398 | goto done; | |
| 1326 | 1399 | } | |
| @@ -1632,8 +1705,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q | |||
| 1632 | 1705 | if (!include_untracked && ps->nr) { | |
| 1633 | 1706 | char *ps_matched = xcalloc(ps->nr, 1); | |
| 1634 | 1707 | ||
| 1635 | - | /* TODO: audit for interaction with sparse-index. */ | |
| 1636 | - | ensure_full_index(the_repository->index); | |
| 1708 | + | if (pathspec_needs_expanded_index(the_repository->index, ps)) | |
| 1709 | + | ensure_full_index(the_repository->index); | |
| 1637 | 1710 | for (size_t i = 0; i < the_repository->index->cache_nr; i++) | |
| 1638 | 1711 | ce_path_match(the_repository->index, the_repository->index->cache[i], ps, | |
| 1639 | 1712 | ps_matched); | |
| @@ -2422,10 +2495,22 @@ int cmd_stash(int argc, | |||
| 2422 | 2495 | strbuf_addf(&stash_index_path, "%s.stash.%" PRIuMAX, index_file, | |
| 2423 | 2496 | (uintmax_t)pid); | |
| 2424 | 2497 | ||
| 2425 | - | if (fn) | |
| 2426 | - | return !!fn(argc, argv, prefix, repo); | |
| 2427 | - | else if (!argc) | |
| 2498 | + | if (fn) { | |
| 2499 | + | ret = fn(argc, argv, prefix, repo); | |
| 2500 | + | ||
| 2501 | + | /* | |
| 2502 | + | * The subcommand implementations return 0 on success, a | |
| 2503 | + | * negative value on failure, and STASH_APPLY_CONFLICT | |
| 2504 | + | * when applying a stash entry resulted in conflicts. | |
| 2505 | + | * Map failures to 128, the status die() uses, so that | |
| 2506 | + | * exit status 1 unambiguously indicates conflicts. | |
| 2507 | + | */ | |
| 2508 | + | if (ret < 0) | |
| 2509 | + | return 128; | |
| 2510 | + | return ret; | |
| 2511 | + | } else if (!argc) { | |
| 2428 | 2512 | return !!push_stash_unassumed(0, NULL, prefix, repo); | |
| 2513 | + | } | |
| 2429 | 2514 | ||
| 2430 | 2515 | /* Assume 'stash push' */ | |
| 2431 | 2516 | strvec_push(&args, "push"); | |
modified builtin/stripspace.c
| @@ -54,7 +54,7 @@ int cmd_stripspace(int argc, | |||
| 54 | 54 | usage_with_options(stripspace_usage, options); | |
| 55 | 55 | ||
| 56 | 56 | if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) { | |
| 57 | - | setup_git_directory_gently(&nongit); | |
| 57 | + | setup_git_directory_gently(the_repository, &nongit); | |
| 58 | 58 | repo_config(the_repository, git_default_config, NULL); | |
| 59 | 59 | } | |
| 60 | 60 | ||
modified builtin/submodule--helper.c
| @@ -80,6 +80,7 @@ static int get_default_remote_submodule(const char *module_path, char **default_ | |||
| 80 | 80 | struct repository subrepo; | |
| 81 | 81 | const char *remote_name = NULL; | |
| 82 | 82 | char *url = NULL; | |
| 83 | + | int ret = 0; | |
| 83 | 84 | ||
| 84 | 85 | sub = submodule_from_path(the_repository, null_oid(the_hash_algo), module_path); | |
| 85 | 86 | if (sub && sub->url) { | |
| @@ -96,9 +97,11 @@ static int get_default_remote_submodule(const char *module_path, char **default_ | |||
| 96 | 97 | } | |
| 97 | 98 | ||
| 98 | 99 | if (repo_submodule_init(&subrepo, the_repository, module_path, | |
| 99 | - | null_oid(the_hash_algo)) < 0) | |
| 100 | - | return die_message(_("could not get a repository handle for submodule '%s'"), | |
| 100 | + | null_oid(the_hash_algo)) < 0) { | |
| 101 | + | ret = die_message(_("could not get a repository handle for submodule '%s'"), | |
| 101 | 102 | module_path); | |
| 103 | + | goto out; | |
| 104 | + | } | |
| 102 | 105 | ||
| 103 | 106 | /* Look up by URL first */ | |
| 104 | 107 | if (url) | |
| @@ -108,10 +111,11 @@ static int get_default_remote_submodule(const char *module_path, char **default_ | |||
| 108 | 111 | ||
| 109 | 112 | *default_remote = xstrdup(remote_name); | |
| 110 | 113 | ||
| 114 | + | out: | |
| 111 | 115 | repo_clear(&subrepo); | |
| 112 | 116 | free(url); | |
| 113 | 117 | ||
| 114 | - | return 0; | |
| 118 | + | return ret; | |
| 115 | 119 | } | |
| 116 | 120 | ||
| 117 | 121 | static int module_get_default_remote(int argc, const char **argv, const char *prefix, | |
| @@ -549,12 +553,13 @@ static void create_default_gitdir_config(const char *submodule_name) | |||
| 549 | 553 | } | |
| 550 | 554 | ||
| 551 | 555 | /* Case 2.4: If all the above failed, try a hash of the name as a last resort */ | |
| 552 | - | header_len = snprintf(header, sizeof(header), "blob %zu", strlen(submodule_name)); | |
| 553 | - | the_hash_algo->init_fn(&ctx); | |
| 554 | - | the_hash_algo->update_fn(&ctx, header, header_len); | |
| 555 | - | the_hash_algo->update_fn(&ctx, "\0", 1); | |
| 556 | - | the_hash_algo->update_fn(&ctx, submodule_name, strlen(submodule_name)); | |
| 557 | - | the_hash_algo->final_fn(raw_name_hash, &ctx); | |
| 556 | + | header_len = snprintf(header, sizeof(header), | |
| 557 | + | "blob %"PRIuMAX, (uintmax_t)strlen(submodule_name)); | |
| 558 | + | git_hash_init(&ctx, the_hash_algo); | |
| 559 | + | git_hash_update(&ctx, header, header_len); | |
| 560 | + | git_hash_update(&ctx, "\0", 1); | |
| 561 | + | git_hash_update(&ctx, submodule_name, strlen(submodule_name)); | |
| 562 | + | git_hash_final(raw_name_hash, &ctx); | |
| 558 | 563 | hash_to_hex_algop_r(hex_name_hash, raw_name_hash, the_hash_algo); | |
| 559 | 564 | strbuf_reset(&gitdir_path); | |
| 560 | 565 | repo_git_path_append(the_repository, &gitdir_path, "modules/%s", hex_name_hash); | |
| @@ -1250,7 +1255,7 @@ static int compute_summary_module_list(struct object_id *head_oid, | |||
| 1250 | 1255 | ||
| 1251 | 1256 | if (!info->cached) { | |
| 1252 | 1257 | if (diff_cmd == DIFF_INDEX) | |
| 1253 | - | setup_work_tree(); | |
| 1258 | + | setup_work_tree(the_repository); | |
| 1254 | 1259 | if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) { | |
| 1255 | 1260 | perror("repo_read_index_preload"); | |
| 1256 | 1261 | ret = -1; | |
| @@ -2990,7 +2995,7 @@ static int module_update(int argc, const char **argv, const char *prefix, | |||
| 2990 | 2995 | struct option module_update_options[] = { | |
| 2991 | 2996 | OPT__SUPER_PREFIX(&opt.super_prefix), | |
| 2992 | 2997 | OPT__FORCE(&opt.force, N_("force checkout updates"), 0), | |
| 2993 | - | OPT_BOOL(0, "init", &opt.init, | |
| 2998 | + | OPT_BOOL('i', "init", &opt.init, | |
| 2994 | 2999 | N_("initialize uninitialized submodules before update")), | |
| 2995 | 3000 | OPT_BOOL(0, "remote", &opt.remote, | |
| 2996 | 3001 | N_("use SHA-1 of submodule's remote tracking branch")), | |
| @@ -3040,7 +3045,7 @@ static int module_update(int argc, const char **argv, const char *prefix, | |||
| 3040 | 3045 | NULL | |
| 3041 | 3046 | }; | |
| 3042 | 3047 | ||
| 3043 | - | update_clone_config_from_gitmodules(&opt.max_jobs); | |
| 3048 | + | update_clone_config_from_gitmodules(the_repository, &opt.max_jobs); | |
| 3044 | 3049 | repo_config(the_repository, git_update_clone_config, &opt.max_jobs); | |
| 3045 | 3050 | ||
| 3046 | 3051 | argc = parse_options(argc, argv, prefix, module_update_options, | |
| @@ -3150,7 +3155,7 @@ static int push_check(int argc, const char **argv, const char *prefix UNUSED, | |||
| 3150 | 3155 | if (argc > 2) { | |
| 3151 | 3156 | int i; | |
| 3152 | 3157 | struct ref *local_refs = get_local_heads(); | |
| 3153 | - | struct refspec refspec = REFSPEC_INIT_PUSH; | |
| 3158 | + | struct refspec refspec = REFSPEC_INIT_PUSH(the_hash_algo); | |
| 3154 | 3159 | ||
| 3155 | 3160 | refspec_appendn(&refspec, argv + 2, argc - 2); | |
| 3156 | 3161 | ||
| @@ -3254,7 +3259,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix, | |||
| 3254 | 3259 | path); | |
| 3255 | 3260 | ||
| 3256 | 3261 | config_name = xstrfmt("submodule.%s.url", sub->name); | |
| 3257 | - | ret = config_set_in_gitmodules_file_gently(config_name, newurl); | |
| 3262 | + | ret = config_set_in_gitmodules_file_gently(the_repository, config_name, newurl); | |
| 3258 | 3263 | ||
| 3259 | 3264 | if (!ret) { | |
| 3260 | 3265 | repo_read_gitmodules(the_repository, 0); | |
| @@ -3310,7 +3315,7 @@ static int module_set_branch(int argc, const char **argv, const char *prefix, | |||
| 3310 | 3315 | path); | |
| 3311 | 3316 | ||
| 3312 | 3317 | config_name = xstrfmt("submodule.%s.branch", sub->name); | |
| 3313 | - | ret = config_set_in_gitmodules_file_gently(config_name, opt_branch); | |
| 3318 | + | ret = config_set_in_gitmodules_file_gently(the_repository, config_name, opt_branch); | |
| 3314 | 3319 | ||
| 3315 | 3320 | free(config_name); | |
| 3316 | 3321 | return !!ret; | |
| @@ -3509,7 +3514,7 @@ static int config_submodule_in_gitmodules(const char *name, const char *var, con | |||
| 3509 | 3514 | die(_("please make sure that the .gitmodules file is in the working tree")); | |
| 3510 | 3515 | ||
| 3511 | 3516 | key = xstrfmt("submodule.%s.%s", name, var); | |
| 3512 | - | ret = config_set_in_gitmodules_file_gently(key, value); | |
| 3517 | + | ret = config_set_in_gitmodules_file_gently(the_repository, key, value); | |
| 3513 | 3518 | free(key); | |
| 3514 | 3519 | ||
| 3515 | 3520 | return ret; | |
modified builtin/tag.c
| @@ -238,7 +238,7 @@ static int git_tag_config(const char *var, const char *value, | |||
| 238 | 238 | ||
| 239 | 239 | static void write_tag_body(int fd, const struct object_id *oid) | |
| 240 | 240 | { | |
| 241 | - | unsigned long size; | |
| 241 | + | size_t size; | |
| 242 | 242 | enum object_type type; | |
| 243 | 243 | char *buf, *sp, *orig; | |
| 244 | 244 | struct strbuf payload = STRBUF_INIT; | |
| @@ -388,7 +388,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb) | |||
| 388 | 388 | enum object_type type; | |
| 389 | 389 | struct commit *c; | |
| 390 | 390 | char *buf; | |
| 391 | - | unsigned long size; | |
| 391 | + | size_t size; | |
| 392 | 392 | int subject_len = 0; | |
| 393 | 393 | const char *subject_start; | |
| 394 | 394 | ||
modified builtin/unpack-file.c
| @@ -12,7 +12,7 @@ static char *create_temp_file(struct object_id *oid) | |||
| 12 | 12 | static char path[50]; | |
| 13 | 13 | void *buf; | |
| 14 | 14 | enum object_type type; | |
| 15 | - | unsigned long size; | |
| 15 | + | size_t size; | |
| 16 | 16 | int fd; | |
| 17 | 17 | ||
| 18 | 18 | buf = odb_read_object(the_repository->objects, oid, &type, &size); | |
modified builtin/unpack-objects.c
| @@ -9,6 +9,8 @@ | |||
| 9 | 9 | #include "hex.h" | |
| 10 | 10 | #include "object-file.h" | |
| 11 | 11 | #include "odb.h" | |
| 12 | + | #include "odb/streaming.h" | |
| 13 | + | #include "odb/transaction.h" | |
| 12 | 14 | #include "object.h" | |
| 13 | 15 | #include "delta.h" | |
| 14 | 16 | #include "pack.h" | |
| @@ -23,8 +25,7 @@ | |||
| 23 | 25 | static int dry_run, quiet, recover, has_errors, strict; | |
| 24 | 26 | static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict]"; | |
| 25 | 27 | ||
| 26 | - | /* We always read in 4kB chunks. */ | |
| 27 | - | static unsigned char buffer[4096]; | |
| 28 | + | static unsigned char buffer[DEFAULT_IO_BUFFER_SIZE]; | |
| 28 | 29 | static unsigned int offset, len; | |
| 29 | 30 | static off_t consumed_bytes; | |
| 30 | 31 | static off_t max_input_size; | |
| @@ -230,7 +231,7 @@ static int check_object(struct object *obj, enum object_type type, | |||
| 230 | 231 | die("object type mismatch"); | |
| 231 | 232 | ||
| 232 | 233 | if (!(obj->flags & FLAG_OPEN)) { | |
| 233 | - | unsigned long size; | |
| 234 | + | size_t size; | |
| 234 | 235 | int type = odb_read_object_info(the_repository->objects, &obj->oid, &size); | |
| 235 | 236 | if (type != obj->type || type <= 0) | |
| 236 | 237 | die("object of unexpected type"); | |
| @@ -313,7 +314,7 @@ static void resolve_delta(unsigned nr, enum object_type type, | |||
| 313 | 314 | void *delta, unsigned long delta_size) | |
| 314 | 315 | { | |
| 315 | 316 | void *result; | |
| 316 | - | unsigned long result_size; | |
| 317 | + | size_t result_size; | |
| 317 | 318 | ||
| 318 | 319 | result = patch_delta(base, base_size, | |
| 319 | 320 | delta, delta_size, | |
| @@ -357,56 +358,55 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size, | |||
| 357 | 358 | write_object(nr, type, buf, size); | |
| 358 | 359 | } | |
| 359 | 360 | ||
| 360 | - | struct input_zstream_data { | |
| 361 | + | struct zlib_stream { | |
| 362 | + | struct odb_stream base; | |
| 361 | 363 | git_zstream *zstream; | |
| 362 | - | unsigned char buf[8192]; | |
| 363 | 364 | int status; | |
| 364 | 365 | }; | |
| 365 | 366 | ||
| 366 | - | static const void *feed_input_zstream(struct odb_write_stream *in_stream, | |
| 367 | - | unsigned long *readlen) | |
| 367 | + | static ssize_t zlib_stream_read(struct odb_stream *in_stream, | |
| 368 | + | char *buf, size_t buf_len) | |
| 368 | 369 | { | |
| 369 | - | struct input_zstream_data *data = in_stream->data; | |
| 370 | + | struct zlib_stream *data = container_of(in_stream, struct zlib_stream, base); | |
| 370 | 371 | git_zstream *zstream = data->zstream; | |
| 371 | - | void *in = fill(1); | |
| 372 | 372 | ||
| 373 | - | if (in_stream->is_finished) { | |
| 374 | - | *readlen = 0; | |
| 375 | - | return NULL; | |
| 376 | - | } | |
| 377 | - | ||
| 378 | - | zstream->next_out = data->buf; | |
| 379 | - | zstream->avail_out = sizeof(data->buf); | |
| 380 | - | zstream->next_in = in; | |
| 381 | - | zstream->avail_in = len; | |
| 373 | + | if (data->status != Z_OK) | |
| 374 | + | return 0; | |
| 382 | 375 | ||
| 383 | - | data->status = git_inflate(zstream, 0); | |
| 376 | + | zstream->next_out = (unsigned char *) buf; | |
| 377 | + | zstream->avail_out = buf_len; | |
| 384 | 378 | ||
| 385 | - | in_stream->is_finished = data->status != Z_OK; | |
| 386 | - | use(len - zstream->avail_in); | |
| 387 | - | *readlen = sizeof(data->buf) - zstream->avail_out; | |
| 379 | + | while (data->status == Z_OK && zstream->avail_out == buf_len) { | |
| 380 | + | zstream->next_in = fill(1); | |
| 381 | + | zstream->avail_in = len; | |
| 382 | + | data->status = git_inflate(zstream, 0); | |
| 383 | + | use(len - zstream->avail_in); | |
| 384 | + | } | |
| 388 | 385 | ||
| 389 | - | return data->buf; | |
| 386 | + | return buf_len - zstream->avail_out; | |
| 390 | 387 | } | |
| 391 | 388 | ||
| 392 | 389 | static void stream_blob(unsigned long size, unsigned nr) | |
| 393 | 390 | { | |
| 394 | 391 | git_zstream zstream = { 0 }; | |
| 395 | - | struct input_zstream_data data = { 0 }; | |
| 396 | - | struct odb_write_stream in_stream = { | |
| 397 | - | .read = feed_input_zstream, | |
| 398 | - | .data = &data, | |
| 392 | + | struct zlib_stream in_stream = { | |
| 393 | + | .base = { | |
| 394 | + | .read = zlib_stream_read, | |
| 395 | + | .size = size, | |
| 396 | + | .type = OBJ_BLOB, | |
| 397 | + | }, | |
| 398 | + | .zstream = &zstream, | |
| 399 | + | .status = Z_OK, | |
| 399 | 400 | }; | |
| 400 | 401 | struct obj_info *info = &obj_list[nr]; | |
| 401 | 402 | ||
| 402 | - | data.zstream = &zstream; | |
| 403 | 403 | git_inflate_init(&zstream); | |
| 404 | 404 | ||
| 405 | - | if (odb_write_object_stream(the_repository->objects, &in_stream, size, &info->oid)) | |
| 405 | + | if (odb_write_object_stream(the_repository->objects, &in_stream.base, &info->oid)) | |
| 406 | 406 | die(_("failed to write object in stream")); | |
| 407 | 407 | ||
| 408 | - | if (data.status != Z_STREAM_END) | |
| 409 | - | die(_("inflate returned (%d)"), data.status); | |
| 408 | + | if (in_stream.status != Z_STREAM_END) | |
| 409 | + | die(_("inflate returned (%d)"), in_stream.status); | |
| 410 | 410 | git_inflate_end(&zstream); | |
| 411 | 411 | ||
| 412 | 412 | if (strict) { | |
| @@ -440,6 +440,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, | |||
| 440 | 440 | { | |
| 441 | 441 | void *delta_data, *base; | |
| 442 | 442 | unsigned long base_size; | |
| 443 | + | size_t base_size_st = 0; | |
| 443 | 444 | struct object_id base_oid; | |
| 444 | 445 | ||
| 445 | 446 | if (type == OBJ_REF_DELTA) { | |
| @@ -516,7 +517,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, | |||
| 516 | 517 | return; | |
| 517 | 518 | ||
| 518 | 519 | base = odb_read_object(the_repository->objects, &base_oid, | |
| 519 | - | &type, &base_size); | |
| 520 | + | &type, &base_size_st); | |
| 521 | + | base_size = cast_size_t_to_ulong(base_size_st); | |
| 520 | 522 | if (!base) { | |
| 521 | 523 | error("failed to read delta-pack base object %s", | |
| 522 | 524 | oid_to_hex(&base_oid)); | |
| @@ -533,7 +535,7 @@ static void unpack_one(unsigned nr) | |||
| 533 | 535 | { | |
| 534 | 536 | unsigned shift; | |
| 535 | 537 | unsigned char *pack; | |
| 536 | - | unsigned long size, c; | |
| 538 | + | size_t size, c; | |
| 537 | 539 | enum object_type type; | |
| 538 | 540 | ||
| 539 | 541 | obj_list[nr].offset = consumed_bytes; | |
| @@ -545,6 +547,8 @@ static void unpack_one(unsigned nr) | |||
| 545 | 547 | size = (c & 15); | |
| 546 | 548 | shift = 4; | |
| 547 | 549 | while (c & 0x80) { | |
| 550 | + | if ((bitsizeof(size_t) - 7) < shift) | |
| 551 | + | die(_("object size too large for this platform")); | |
| 548 | 552 | pack = fill(1); | |
| 549 | 553 | c = *pack; | |
| 550 | 554 | use(1); | |
| @@ -598,12 +602,12 @@ static void unpack_all(void) | |||
| 598 | 602 | progress = start_progress(the_repository, | |
| 599 | 603 | _("Unpacking objects"), nr_objects); | |
| 600 | 604 | CALLOC_ARRAY(obj_list, nr_objects); | |
| 601 | - | transaction = odb_transaction_begin(the_repository->objects); | |
| 605 | + | odb_transaction_begin_or_die(the_repository->objects, &transaction, 0); | |
| 602 | 606 | for (i = 0; i < nr_objects; i++) { | |
| 603 | 607 | unpack_one(i); | |
| 604 | 608 | display_progress(progress, i + 1); | |
| 605 | 609 | } | |
| 606 | - | odb_transaction_commit(transaction); | |
| 610 | + | odb_transaction_commit_and_finalize_or_die(transaction); | |
| 607 | 611 | stop_progress(&progress); | |
| 608 | 612 | ||
| 609 | 613 | if (delta_list) | |
| @@ -670,10 +674,10 @@ int cmd_unpack_objects(int argc, | |||
| 670 | 674 | /* We don't take any non-flag arguments now.. Maybe some day */ | |
| 671 | 675 | usage(unpack_usage); | |
| 672 | 676 | } | |
| 673 | - | the_hash_algo->init_fn(&ctx); | |
| 677 | + | git_hash_init(&ctx, the_hash_algo); | |
| 674 | 678 | unpack_all(); | |
| 675 | 679 | git_hash_update(&ctx, buffer, offset); | |
| 676 | - | the_hash_algo->init_fn(&tmp_ctx); | |
| 680 | + | git_hash_init(&tmp_ctx, the_hash_algo); | |
| 677 | 681 | git_hash_clone(&tmp_ctx, &ctx); | |
| 678 | 682 | git_hash_final_oid(&oid, &tmp_ctx); | |
| 679 | 683 | if (strict) { | |
modified builtin/update-index.c
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | #include "tree-walk.h" | |
| 20 | 20 | #include "object-file.h" | |
| 21 | 21 | #include "odb.h" | |
| 22 | + | #include "odb/transaction.h" | |
| 22 | 23 | #include "refs.h" | |
| 23 | 24 | #include "resolve-undo.h" | |
| 24 | 25 | #include "parse-options.h" | |
| @@ -293,7 +294,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len | |||
| 293 | 294 | ce->ce_flags = create_ce_flags(0); | |
| 294 | 295 | ce->ce_namelen = len; | |
| 295 | 296 | fill_stat_cache_info(the_repository->index, ce, st); | |
| 296 | - | ce->ce_mode = ce_mode_from_stat(old, st->st_mode); | |
| 297 | + | ce->ce_mode = ce_mode_from_stat(the_repository, old, st->st_mode); | |
| 297 | 298 | ||
| 298 | 299 | if (index_path(the_repository->index, &ce->oid, path, st, | |
| 299 | 300 | info_only ? 0 : INDEX_WRITE_OBJECT)) { | |
| @@ -655,7 +656,7 @@ static int do_unresolve(int ac, const char **av, | |||
| 655 | 656 | ||
| 656 | 657 | for (i = 1; i < ac; i++) { | |
| 657 | 658 | const char *arg = av[i]; | |
| 658 | - | char *p = prefix_path(prefix, prefix_length, arg); | |
| 659 | + | char *p = prefix_path(the_repository, prefix, prefix_length, arg); | |
| 659 | 660 | err |= unresolve_one(p); | |
| 660 | 661 | free(p); | |
| 661 | 662 | } | |
| @@ -732,7 +733,7 @@ struct refresh_params { | |||
| 732 | 733 | ||
| 733 | 734 | static int refresh(struct refresh_params *o, unsigned int flag) | |
| 734 | 735 | { | |
| 735 | - | setup_work_tree(); | |
| 736 | + | setup_work_tree(the_repository); | |
| 736 | 737 | repo_read_index(the_repository); | |
| 737 | 738 | *o->has_errors |= refresh_index(the_repository->index, o->flags | flag, NULL, | |
| 738 | 739 | NULL, NULL); | |
| @@ -874,7 +875,7 @@ static enum parse_opt_result unresolve_callback( | |||
| 874 | 875 | const char *arg, int unset) | |
| 875 | 876 | { | |
| 876 | 877 | int *has_errors = opt->value; | |
| 877 | - | const char *prefix = startup_info->prefix; | |
| 878 | + | const char *prefix = the_repository->prefix; | |
| 878 | 879 | ||
| 879 | 880 | BUG_ON_OPT_NEG(unset); | |
| 880 | 881 | BUG_ON_OPT_ARG(arg); | |
| @@ -895,13 +896,13 @@ static enum parse_opt_result reupdate_callback( | |||
| 895 | 896 | const char *arg, int unset) | |
| 896 | 897 | { | |
| 897 | 898 | int *has_errors = opt->value; | |
| 898 | - | const char *prefix = startup_info->prefix; | |
| 899 | + | const char *prefix = the_repository->prefix; | |
| 899 | 900 | ||
| 900 | 901 | BUG_ON_OPT_NEG(unset); | |
| 901 | 902 | BUG_ON_OPT_ARG(arg); | |
| 902 | 903 | ||
| 903 | 904 | /* consume remaining arguments. */ | |
| 904 | - | setup_work_tree(); | |
| 905 | + | setup_work_tree(the_repository); | |
| 905 | 906 | *has_errors = do_reupdate(ctx->argv + 1, prefix); | |
| 906 | 907 | if (*has_errors) | |
| 907 | 908 | the_repository->index->cache_changed = 0; | |
| @@ -1123,7 +1124,7 @@ int cmd_update_index(int argc, | |||
| 1123 | 1124 | * Allow the object layer to optimize adding multiple objects in | |
| 1124 | 1125 | * a batch. | |
| 1125 | 1126 | */ | |
| 1126 | - | transaction = odb_transaction_begin(the_repository->objects); | |
| 1127 | + | odb_transaction_begin_or_die(the_repository->objects, &transaction, 0); | |
| 1127 | 1128 | while (ctx.argc) { | |
| 1128 | 1129 | if (parseopt_state != PARSE_OPT_DONE) | |
| 1129 | 1130 | parseopt_state = parse_options_step(&ctx, options, | |
| @@ -1132,6 +1133,8 @@ int cmd_update_index(int argc, | |||
| 1132 | 1133 | break; | |
| 1133 | 1134 | switch (parseopt_state) { | |
| 1134 | 1135 | case PARSE_OPT_HELP: | |
| 1136 | + | exit(0); | |
| 1137 | + | case PARSE_OPT_HELP_ERROR: | |
| 1135 | 1138 | case PARSE_OPT_ERROR: | |
| 1136 | 1139 | exit(129); | |
| 1137 | 1140 | case PARSE_OPT_COMPLETE: | |
| @@ -1153,12 +1156,12 @@ int cmd_update_index(int argc, | |||
| 1153 | 1156 | * a transaction. | |
| 1154 | 1157 | */ | |
| 1155 | 1158 | if (transaction && verbose) { | |
| 1156 | - | odb_transaction_commit(transaction); | |
| 1159 | + | odb_transaction_commit_and_finalize_or_die(transaction); | |
| 1157 | 1160 | transaction = NULL; | |
| 1158 | 1161 | } | |
| 1159 | 1162 | ||
| 1160 | - | setup_work_tree(); | |
| 1161 | - | p = prefix_path(prefix, prefix_length, path); | |
| 1163 | + | setup_work_tree(the_repository); | |
| 1164 | + | p = prefix_path(the_repository, prefix, prefix_length, path); | |
| 1162 | 1165 | update_one(p); | |
| 1163 | 1166 | if (set_executable_bit) | |
| 1164 | 1167 | chmod_path(set_executable_bit, p); | |
| @@ -1199,7 +1202,7 @@ int cmd_update_index(int argc, | |||
| 1199 | 1202 | struct strbuf buf = STRBUF_INIT; | |
| 1200 | 1203 | struct strbuf unquoted = STRBUF_INIT; | |
| 1201 | 1204 | ||
| 1202 | - | setup_work_tree(); | |
| 1205 | + | setup_work_tree(the_repository); | |
| 1203 | 1206 | while (getline_fn(&buf, stdin) != EOF) { | |
| 1204 | 1207 | char *p; | |
| 1205 | 1208 | if (!nul_term_line && buf.buf[0] == '"') { | |
| @@ -1208,7 +1211,7 @@ int cmd_update_index(int argc, | |||
| 1208 | 1211 | die("line is badly quoted"); | |
| 1209 | 1212 | strbuf_swap(&buf, &unquoted); | |
| 1210 | 1213 | } | |
| 1211 | - | p = prefix_path(prefix, prefix_length, buf.buf); | |
| 1214 | + | p = prefix_path(the_repository, prefix, prefix_length, buf.buf); | |
| 1212 | 1215 | update_one(p); | |
| 1213 | 1216 | if (set_executable_bit) | |
| 1214 | 1217 | chmod_path(set_executable_bit, p); | |
| @@ -1221,7 +1224,7 @@ int cmd_update_index(int argc, | |||
| 1221 | 1224 | /* | |
| 1222 | 1225 | * By now we have added all of the new objects | |
| 1223 | 1226 | */ | |
| 1224 | - | odb_transaction_commit(transaction); | |
| 1227 | + | odb_transaction_commit_and_finalize_or_die(transaction); | |
| 1225 | 1228 | ||
| 1226 | 1229 | if (split_index > 0) { | |
| 1227 | 1230 | if (repo_config_get_split_index(the_repository) == 0) | |
| @@ -1253,7 +1256,7 @@ int cmd_update_index(int argc, | |||
| 1253 | 1256 | report(_("Untracked cache disabled")); | |
| 1254 | 1257 | break; | |
| 1255 | 1258 | case UC_TEST: | |
| 1256 | - | setup_work_tree(); | |
| 1259 | + | setup_work_tree(the_repository); | |
| 1257 | 1260 | return !test_if_untracked_cache_is_supported(); | |
| 1258 | 1261 | case UC_ENABLE: | |
| 1259 | 1262 | case UC_FORCE: | |
modified builtin/update-ref.c
| @@ -25,6 +25,15 @@ static unsigned int default_flags; | |||
| 25 | 25 | static unsigned create_reflog_flag; | |
| 26 | 26 | static const char *msg; | |
| 27 | 27 | ||
| 28 | + | struct command_options { | |
| 29 | + | /* | |
| 30 | + | * Individual updates are allowed to fail without causing | |
| 31 | + | * update-ref to exit. This is set when using the | |
| 32 | + | * '--batch-updates' flag. | |
| 33 | + | */ | |
| 34 | + | bool allow_update_failures; | |
| 35 | + | }; | |
| 36 | + | ||
| 28 | 37 | /* | |
| 29 | 38 | * Parse one whitespace- or NUL-terminated, possibly C-quoted argument | |
| 30 | 39 | * and append the result to arg. Return a pointer to the terminator. | |
| @@ -234,6 +243,53 @@ static int parse_next_oid(const char **next, const char *end, | |||
| 234 | 243 | command, refname); | |
| 235 | 244 | } | |
| 236 | 245 | ||
| 246 | + | static void print_rejected_refs(const char *refname, | |
| 247 | + | const struct object_id *old_oid, | |
| 248 | + | const struct object_id *new_oid, | |
| 249 | + | const char *old_target, | |
| 250 | + | const char *new_target, | |
| 251 | + | enum ref_transaction_error err, | |
| 252 | + | const char *details, | |
| 253 | + | void *cb_data UNUSED) | |
| 254 | + | { | |
| 255 | + | struct strbuf sb = STRBUF_INIT; | |
| 256 | + | ||
| 257 | + | if (details && *details) | |
| 258 | + | error("%s", details); | |
| 259 | + | ||
| 260 | + | strbuf_addf(&sb, "rejected %s %s %s %s\n", refname, | |
| 261 | + | new_oid ? oid_to_hex(new_oid) : new_target, | |
| 262 | + | old_oid ? oid_to_hex(old_oid) : old_target, | |
| 263 | + | ref_transaction_error_msg(err)); | |
| 264 | + | ||
| 265 | + | fwrite(sb.buf, sb.len, 1, stdout); | |
| 266 | + | strbuf_release(&sb); | |
| 267 | + | } | |
| 268 | + | ||
| 269 | + | /* | |
| 270 | + | * Handle transaction errors. If we're using batches updates, we want to only | |
| 271 | + | * die for generic errors and print the remaining to the user. | |
| 272 | + | */ | |
| 273 | + | static void handle_ref_transaction_error(const char *refname, | |
| 274 | + | struct object_id *new_oid, | |
| 275 | + | struct object_id *old_oid, | |
| 276 | + | const char *new_target, | |
| 277 | + | const char *old_target, | |
| 278 | + | enum ref_transaction_error tx_err, | |
| 279 | + | struct strbuf *err, | |
| 280 | + | struct command_options *opts) | |
| 281 | + | { | |
| 282 | + | if (!tx_err) | |
| 283 | + | return; | |
| 284 | + | ||
| 285 | + | if (tx_err != REF_TRANSACTION_ERROR_GENERIC && opts->allow_update_failures) { | |
| 286 | + | print_rejected_refs(refname, old_oid, new_oid, old_target, | |
| 287 | + | new_target, tx_err, err->buf, NULL); | |
| 288 | + | return; | |
| 289 | + | } | |
| 290 | + | ||
| 291 | + | die("%s", err->buf); | |
| 292 | + | } | |
| 237 | 293 | ||
| 238 | 294 | /* | |
| 239 | 295 | * The following five parse_cmd_*() functions parse the corresponding | |
| @@ -246,11 +302,13 @@ static int parse_next_oid(const char **next, const char *end, | |||
| 246 | 302 | */ | |
| 247 | 303 | ||
| 248 | 304 | static void parse_cmd_update(struct ref_transaction *transaction, | |
| 249 | - | const char *next, const char *end) | |
| 305 | + | const char *next, const char *end, | |
| 306 | + | struct command_options *opts) | |
| 250 | 307 | { | |
| 251 | 308 | struct strbuf err = STRBUF_INIT; | |
| 252 | 309 | char *refname; | |
| 253 | 310 | struct object_id new_oid, old_oid; | |
| 311 | + | enum ref_transaction_error tx_err; | |
| 254 | 312 | int have_old; | |
| 255 | 313 | ||
| 256 | 314 | refname = parse_refname(&next); | |
| @@ -267,12 +325,14 @@ static void parse_cmd_update(struct ref_transaction *transaction, | |||
| 267 | 325 | if (*next != line_termination) | |
| 268 | 326 | die("update %s: extra input: %s", refname, next); | |
| 269 | 327 | ||
| 270 | - | if (ref_transaction_update(transaction, refname, | |
| 271 | - | &new_oid, have_old ? &old_oid : NULL, | |
| 272 | - | NULL, NULL, | |
| 273 | - | update_flags | create_reflog_flag, | |
| 274 | - | msg, &err)) | |
| 275 | - | die("%s", err.buf); | |
| 328 | + | tx_err = ref_transaction_update(transaction, refname, | |
| 329 | + | &new_oid, have_old ? &old_oid : NULL, | |
| 330 | + | NULL, NULL, | |
| 331 | + | update_flags | create_reflog_flag, | |
| 332 | + | msg, &err); | |
| 333 | + | handle_ref_transaction_error(refname, &new_oid, have_old ? &old_oid : NULL, | |
| 334 | + | NULL, NULL, tx_err, &err, opts); | |
| 335 | + | ||
| 276 | 336 | ||
| 277 | 337 | update_flags = default_flags; | |
| 278 | 338 | free(refname); | |
| @@ -280,9 +340,11 @@ static void parse_cmd_update(struct ref_transaction *transaction, | |||
| 280 | 340 | } | |
| 281 | 341 | ||
| 282 | 342 | static void parse_cmd_symref_update(struct ref_transaction *transaction, | |
| 283 | - | const char *next, const char *end UNUSED) | |
| 343 | + | const char *next, const char *end UNUSED, | |
| 344 | + | struct command_options *opts) | |
| 284 | 345 | { | |
| 285 | 346 | char *refname, *new_target, *old_arg; | |
| 347 | + | enum ref_transaction_error tx_err; | |
| 286 | 348 | char *old_target = NULL; | |
| 287 | 349 | struct strbuf err = STRBUF_INIT; | |
| 288 | 350 | struct object_id old_oid; | |
| @@ -319,13 +381,15 @@ static void parse_cmd_symref_update(struct ref_transaction *transaction, | |||
| 319 | 381 | if (*next != line_termination) | |
| 320 | 382 | die("symref-update %s: extra input: %s", refname, next); | |
| 321 | 383 | ||
| 322 | - | if (ref_transaction_update(transaction, refname, NULL, | |
| 323 | - | have_old_oid ? &old_oid : NULL, | |
| 324 | - | new_target, | |
| 325 | - | have_old_oid ? NULL : old_target, | |
| 326 | - | update_flags | create_reflog_flag, | |
| 327 | - | msg, &err)) | |
| 328 | - | die("%s", err.buf); | |
| 384 | + | tx_err = ref_transaction_update(transaction, refname, NULL, | |
| 385 | + | have_old_oid ? &old_oid : NULL, | |
| 386 | + | new_target, | |
| 387 | + | have_old_oid ? NULL : old_target, | |
| 388 | + | update_flags | create_reflog_flag, | |
| 389 | + | msg, &err); | |
| 390 | + | handle_ref_transaction_error(refname, NULL, have_old_oid ? &old_oid : NULL, | |
| 391 | + | new_target, have_old_oid ? NULL : old_target, | |
| 392 | + | tx_err, &err, opts); | |
| 329 | 393 | ||
| 330 | 394 | update_flags = default_flags; | |
| 331 | 395 | free(refname); | |
| @@ -336,11 +400,13 @@ static void parse_cmd_symref_update(struct ref_transaction *transaction, | |||
| 336 | 400 | } | |
| 337 | 401 | ||
| 338 | 402 | static void parse_cmd_create(struct ref_transaction *transaction, | |
| 339 | - | const char *next, const char *end) | |
| 403 | + | const char *next, const char *end, | |
| 404 | + | struct command_options *opts) | |
| 340 | 405 | { | |
| 341 | 406 | struct strbuf err = STRBUF_INIT; | |
| 342 | 407 | char *refname; | |
| 343 | 408 | struct object_id new_oid; | |
| 409 | + | enum ref_transaction_error tx_err; | |
| 344 | 410 | ||
| 345 | 411 | refname = parse_refname(&next); | |
| 346 | 412 | if (!refname) | |
| @@ -355,22 +421,24 @@ static void parse_cmd_create(struct ref_transaction *transaction, | |||
| 355 | 421 | if (*next != line_termination) | |
| 356 | 422 | die("create %s: extra input: %s", refname, next); | |
| 357 | 423 | ||
| 358 | - | if (ref_transaction_create(transaction, refname, &new_oid, NULL, | |
| 359 | - | update_flags | create_reflog_flag, | |
| 360 | - | msg, &err)) | |
| 361 | - | die("%s", err.buf); | |
| 424 | + | tx_err = ref_transaction_create(transaction, refname, &new_oid, NULL, | |
| 425 | + | update_flags | create_reflog_flag, | |
| 426 | + | msg, &err); | |
| 427 | + | handle_ref_transaction_error(refname, &new_oid, NULL, NULL, NULL, tx_err, | |
| 428 | + | &err, opts); | |
| 362 | 429 | ||
| 363 | 430 | update_flags = default_flags; | |
| 364 | 431 | free(refname); | |
| 365 | 432 | strbuf_release(&err); | |
| 366 | 433 | } | |
| 367 | 434 | ||
| 368 | - | ||
| 369 | 435 | static void parse_cmd_symref_create(struct ref_transaction *transaction, | |
| 370 | - | const char *next, const char *end UNUSED) | |
| 436 | + | const char *next, const char *end UNUSED, | |
| 437 | + | struct command_options *opts) | |
| 371 | 438 | { | |
| 372 | 439 | struct strbuf err = STRBUF_INIT; | |
| 373 | 440 | char *refname, *new_target; | |
| 441 | + | enum ref_transaction_error tx_err; | |
| 374 | 442 | ||
| 375 | 443 | refname = parse_refname(&next); | |
| 376 | 444 | if (!refname) | |
| @@ -383,10 +451,11 @@ static void parse_cmd_symref_create(struct ref_transaction *transaction, | |||
| 383 | 451 | if (*next != line_termination) | |
| 384 | 452 | die("symref-create %s: extra input: %s", refname, next); | |
| 385 | 453 | ||
| 386 | - | if (ref_transaction_create(transaction, refname, NULL, new_target, | |
| 387 | - | update_flags | create_reflog_flag, | |
| 388 | - | msg, &err)) | |
| 389 | - | die("%s", err.buf); | |
| 454 | + | tx_err = ref_transaction_create(transaction, refname, NULL, new_target, | |
| 455 | + | update_flags | create_reflog_flag, | |
| 456 | + | msg, &err); | |
| 457 | + | handle_ref_transaction_error(refname, NULL, NULL, new_target, NULL, | |
| 458 | + | tx_err, &err, opts); | |
| 390 | 459 | ||
| 391 | 460 | update_flags = default_flags; | |
| 392 | 461 | free(refname); | |
| @@ -395,7 +464,8 @@ static void parse_cmd_symref_create(struct ref_transaction *transaction, | |||
| 395 | 464 | } | |
| 396 | 465 | ||
| 397 | 466 | static void parse_cmd_delete(struct ref_transaction *transaction, | |
| 398 | - | const char *next, const char *end) | |
| 467 | + | const char *next, const char *end, | |
| 468 | + | struct command_options *opts UNUSED) | |
| 399 | 469 | { | |
| 400 | 470 | struct strbuf err = STRBUF_INIT; | |
| 401 | 471 | char *refname; | |
| @@ -428,9 +498,9 @@ static void parse_cmd_delete(struct ref_transaction *transaction, | |||
| 428 | 498 | strbuf_release(&err); | |
| 429 | 499 | } | |
| 430 | 500 | ||
| 431 | - | ||
| 432 | 501 | static void parse_cmd_symref_delete(struct ref_transaction *transaction, | |
| 433 | - | const char *next, const char *end UNUSED) | |
| 502 | + | const char *next, const char *end UNUSED, | |
| 503 | + | struct command_options *opts UNUSED) | |
| 434 | 504 | { | |
| 435 | 505 | struct strbuf err = STRBUF_INIT; | |
| 436 | 506 | char *refname, *old_target; | |
| @@ -457,9 +527,9 @@ static void parse_cmd_symref_delete(struct ref_transaction *transaction, | |||
| 457 | 527 | strbuf_release(&err); | |
| 458 | 528 | } | |
| 459 | 529 | ||
| 460 | - | ||
| 461 | 530 | static void parse_cmd_verify(struct ref_transaction *transaction, | |
| 462 | - | const char *next, const char *end) | |
| 531 | + | const char *next, const char *end, | |
| 532 | + | struct command_options *opts UNUSED) | |
| 463 | 533 | { | |
| 464 | 534 | struct strbuf err = STRBUF_INIT; | |
| 465 | 535 | char *refname; | |
| @@ -486,7 +556,8 @@ static void parse_cmd_verify(struct ref_transaction *transaction, | |||
| 486 | 556 | } | |
| 487 | 557 | ||
| 488 | 558 | static void parse_cmd_symref_verify(struct ref_transaction *transaction, | |
| 489 | - | const char *next, const char *end UNUSED) | |
| 559 | + | const char *next, const char *end UNUSED, | |
| 560 | + | struct command_options *opts UNUSED) | |
| 490 | 561 | { | |
| 491 | 562 | struct strbuf err = STRBUF_INIT; | |
| 492 | 563 | struct object_id old_oid; | |
| @@ -528,7 +599,8 @@ static void report_ok(const char *command) | |||
| 528 | 599 | } | |
| 529 | 600 | ||
| 530 | 601 | static void parse_cmd_option(struct ref_transaction *transaction UNUSED, | |
| 531 | - | const char *next, const char *end UNUSED) | |
| 602 | + | const char *next, const char *end UNUSED, | |
| 603 | + | struct command_options *opts UNUSED) | |
| 532 | 604 | { | |
| 533 | 605 | const char *rest; | |
| 534 | 606 | if (skip_prefix(next, "no-deref", &rest) && *rest == line_termination) | |
| @@ -538,7 +610,8 @@ static void parse_cmd_option(struct ref_transaction *transaction UNUSED, | |||
| 538 | 610 | } | |
| 539 | 611 | ||
| 540 | 612 | static void parse_cmd_start(struct ref_transaction *transaction UNUSED, | |
| 541 | - | const char *next, const char *end UNUSED) | |
| 613 | + | const char *next, const char *end UNUSED, | |
| 614 | + | struct command_options *opts UNUSED) | |
| 542 | 615 | { | |
| 543 | 616 | if (*next != line_termination) | |
| 544 | 617 | die("start: extra input: %s", next); | |
| @@ -546,7 +619,8 @@ static void parse_cmd_start(struct ref_transaction *transaction UNUSED, | |||
| 546 | 619 | } | |
| 547 | 620 | ||
| 548 | 621 | static void parse_cmd_prepare(struct ref_transaction *transaction, | |
| 549 | - | const char *next, const char *end UNUSED) | |
| 622 | + | const char *next, const char *end UNUSED, | |
| 623 | + | struct command_options *opts UNUSED) | |
| 550 | 624 | { | |
| 551 | 625 | struct strbuf error = STRBUF_INIT; | |
| 552 | 626 | if (*next != line_termination) | |
| @@ -557,7 +631,8 @@ static void parse_cmd_prepare(struct ref_transaction *transaction, | |||
| 557 | 631 | } | |
| 558 | 632 | ||
| 559 | 633 | static void parse_cmd_abort(struct ref_transaction *transaction, | |
| 560 | - | const char *next, const char *end UNUSED) | |
| 634 | + | const char *next, const char *end UNUSED, | |
| 635 | + | struct command_options *opts UNUSED) | |
| 561 | 636 | { | |
| 562 | 637 | struct strbuf error = STRBUF_INIT; | |
| 563 | 638 | if (*next != line_termination) | |
| @@ -567,31 +642,9 @@ static void parse_cmd_abort(struct ref_transaction *transaction, | |||
| 567 | 642 | report_ok("abort"); | |
| 568 | 643 | } | |
| 569 | 644 | ||
| 570 | - | static void print_rejected_refs(const char *refname, | |
| 571 | - | const struct object_id *old_oid, | |
| 572 | - | const struct object_id *new_oid, | |
| 573 | - | const char *old_target, | |
| 574 | - | const char *new_target, | |
| 575 | - | enum ref_transaction_error err, | |
| 576 | - | const char *details, | |
| 577 | - | void *cb_data UNUSED) | |
| 578 | - | { | |
| 579 | - | struct strbuf sb = STRBUF_INIT; | |
| 580 | - | ||
| 581 | - | if (details && *details) | |
| 582 | - | error("%s", details); | |
| 583 | - | ||
| 584 | - | strbuf_addf(&sb, "rejected %s %s %s %s\n", refname, | |
| 585 | - | new_oid ? oid_to_hex(new_oid) : new_target, | |
| 586 | - | old_oid ? oid_to_hex(old_oid) : old_target, | |
| 587 | - | ref_transaction_error_msg(err)); | |
| 588 | - | ||
| 589 | - | fwrite(sb.buf, sb.len, 1, stdout); | |
| 590 | - | strbuf_release(&sb); | |
| 591 | - | } | |
| 592 | - | ||
| 593 | 645 | static void parse_cmd_commit(struct ref_transaction *transaction, | |
| 594 | - | const char *next, const char *end UNUSED) | |
| 646 | + | const char *next, const char *end UNUSED, | |
| 647 | + | struct command_options *opts UNUSED) | |
| 595 | 648 | { | |
| 596 | 649 | struct strbuf error = STRBUF_INIT; | |
| 597 | 650 | if (*next != line_termination) | |
| @@ -619,7 +672,8 @@ enum update_refs_state { | |||
| 619 | 672 | ||
| 620 | 673 | static const struct parse_cmd { | |
| 621 | 674 | const char *prefix; | |
| 622 | - | void (*fn)(struct ref_transaction *, const char *, const char *); | |
| 675 | + | void (*fn)(struct ref_transaction *, const char *, const char *, | |
| 676 | + | struct command_options *); | |
| 623 | 677 | unsigned args; | |
| 624 | 678 | enum update_refs_state state; | |
| 625 | 679 | } command[] = { | |
| @@ -645,6 +699,10 @@ static void update_refs_stdin(unsigned int flags) | |||
| 645 | 699 | struct ref_transaction *transaction; | |
| 646 | 700 | int i, j; | |
| 647 | 701 | ||
| 702 | + | struct command_options opts = { | |
| 703 | + | .allow_update_failures = flags & REF_TRANSACTION_ALLOW_FAILURE, | |
| 704 | + | }; | |
| 705 | + | ||
| 648 | 706 | transaction = ref_store_transaction_begin(get_main_ref_store(the_repository), | |
| 649 | 707 | flags, &err); | |
| 650 | 708 | if (!transaction) | |
| @@ -722,7 +780,7 @@ static void update_refs_stdin(unsigned int flags) | |||
| 722 | 780 | } | |
| 723 | 781 | ||
| 724 | 782 | cmd->fn(transaction, input.buf + strlen(cmd->prefix) + !!cmd->args, | |
| 725 | - | input.buf + input.len); | |
| 783 | + | input.buf + input.len, &opts); | |
| 726 | 784 | } | |
| 727 | 785 | ||
| 728 | 786 | switch (state) { | |
modified builtin/upload-archive.c
| @@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc, | |||
| 31 | 31 | if (argc != 2) | |
| 32 | 32 | usage(upload_archive_usage); | |
| 33 | 33 | ||
| 34 | - | if (!enter_repo(argv[1], 0)) | |
| 34 | + | if (!enter_repo(the_repository, argv[1], 0)) | |
| 35 | 35 | die("'%s' does not appear to be a git repository", argv[1]); | |
| 36 | 36 | ||
| 37 | 37 | init_archivers(); | |
modified builtin/upload-pack.c
| @@ -59,7 +59,7 @@ int cmd_upload_pack(int argc, | |||
| 59 | 59 | ||
| 60 | 60 | if (strict) | |
| 61 | 61 | enter_repo_flags |= ENTER_REPO_STRICT; | |
| 62 | - | if (!enter_repo(dir, enter_repo_flags)) | |
| 62 | + | if (!enter_repo(the_repository, dir, enter_repo_flags)) | |
| 63 | 63 | die("'%s' does not appear to be a git repository", dir); | |
| 64 | 64 | ||
| 65 | 65 | switch (determine_protocol_version_server()) { | |
added builtin/url-parse.c mode 100644
| @@ -0,0 +1,135 @@ | |||
| 1 | + | #include "builtin.h" | |
| 2 | + | #include "gettext.h" | |
| 3 | + | #include "parse-options.h" | |
| 4 | + | #include "url.h" | |
| 5 | + | #include "urlmatch.h" | |
| 6 | + | ||
| 7 | + | static const char * const builtin_url_parse_usage[] = { | |
| 8 | + | N_("git url-parse [-c <component>] [--] <url>..."), | |
| 9 | + | NULL | |
| 10 | + | }; | |
| 11 | + | ||
| 12 | + | static char *component_arg; | |
| 13 | + | ||
| 14 | + | static struct option builtin_url_parse_options[] = { | |
| 15 | + | OPT_STRING('c', "component", &component_arg, N_("component"), | |
| 16 | + | N_("which URL component to extract")), | |
| 17 | + | OPT_END(), | |
| 18 | + | }; | |
| 19 | + | ||
| 20 | + | enum url_component { | |
| 21 | + | URL_NONE = 0, | |
| 22 | + | URL_SCHEME, | |
| 23 | + | URL_USER, | |
| 24 | + | URL_PASSWORD, | |
| 25 | + | URL_HOST, | |
| 26 | + | URL_PORT, | |
| 27 | + | URL_PATH, | |
| 28 | + | }; | |
| 29 | + | ||
| 30 | + | static void parse_or_die(const char *url, struct url_info *info) | |
| 31 | + | { | |
| 32 | + | if (url_is_local_not_ssh(url)) { | |
| 33 | + | if (*url == '/') | |
| 34 | + | die("'%s' is not a URL; if you meant a local " | |
| 35 | + | "repository, use 'file://%s'", url, url); | |
| 36 | + | if (has_dos_drive_prefix(url)) | |
| 37 | + | die("'%s' is not a URL; if you meant a local " | |
| 38 | + | "repository, use 'file:///%s'", url, url); | |
| 39 | + | die("'%s' is not a URL; if you meant a local repository, " | |
| 40 | + | "use a 'file://' URL with an absolute path", url); | |
| 41 | + | } | |
| 42 | + | if (!url_parse(url, info)) | |
| 43 | + | die("invalid git URL '%s': %s", url, info->err); | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | static enum url_component get_component_or_die(const char *arg) | |
| 47 | + | { | |
| 48 | + | if (!strcmp("path", arg)) | |
| 49 | + | return URL_PATH; | |
| 50 | + | if (!strcmp("host", arg)) | |
| 51 | + | return URL_HOST; | |
| 52 | + | if (!strcmp("scheme", arg)) | |
| 53 | + | return URL_SCHEME; | |
| 54 | + | if (!strcmp("user", arg)) | |
| 55 | + | return URL_USER; | |
| 56 | + | if (!strcmp("password", arg)) | |
| 57 | + | return URL_PASSWORD; | |
| 58 | + | if (!strcmp("port", arg)) | |
| 59 | + | return URL_PORT; | |
| 60 | + | die("invalid git URL component '%s'", arg); | |
| 61 | + | } | |
| 62 | + | ||
| 63 | + | static char *extract_component(enum url_component component, | |
| 64 | + | struct url_info *info) | |
| 65 | + | { | |
| 66 | + | size_t offset, length; | |
| 67 | + | ||
| 68 | + | switch (component) { | |
| 69 | + | case URL_SCHEME: | |
| 70 | + | offset = 0; | |
| 71 | + | length = info->scheme_len; | |
| 72 | + | break; | |
| 73 | + | case URL_USER: | |
| 74 | + | offset = info->user_off; | |
| 75 | + | length = info->user_len; | |
| 76 | + | break; | |
| 77 | + | case URL_PASSWORD: | |
| 78 | + | offset = info->passwd_off; | |
| 79 | + | length = info->passwd_len; | |
| 80 | + | break; | |
| 81 | + | case URL_HOST: | |
| 82 | + | offset = info->host_off; | |
| 83 | + | length = info->host_len; | |
| 84 | + | break; | |
| 85 | + | case URL_PORT: | |
| 86 | + | offset = info->port_off; | |
| 87 | + | length = info->port_len; | |
| 88 | + | break; | |
| 89 | + | case URL_PATH: | |
| 90 | + | offset = info->path_off; | |
| 91 | + | length = info->path_len; | |
| 92 | + | break; | |
| 93 | + | case URL_NONE: | |
| 94 | + | return NULL; | |
| 95 | + | } | |
| 96 | + | ||
| 97 | + | return xstrndup(info->url + offset, length); | |
| 98 | + | } | |
| 99 | + | ||
| 100 | + | int cmd_url_parse(int argc, | |
| 101 | + | const char **argv, | |
| 102 | + | const char *prefix, | |
| 103 | + | struct repository *repo UNUSED) | |
| 104 | + | { | |
| 105 | + | struct url_info info; | |
| 106 | + | enum url_component selected = URL_NONE; | |
| 107 | + | char *extracted; | |
| 108 | + | int i; | |
| 109 | + | ||
| 110 | + | argc = parse_options(argc, argv, prefix, builtin_url_parse_options, | |
| 111 | + | builtin_url_parse_usage, 0); | |
| 112 | + | ||
| 113 | + | if (argc == 0) | |
| 114 | + | usage_with_options(builtin_url_parse_usage, | |
| 115 | + | builtin_url_parse_options); | |
| 116 | + | ||
| 117 | + | if (component_arg) | |
| 118 | + | selected = get_component_or_die(component_arg); | |
| 119 | + | ||
| 120 | + | for (i = 0; i < argc; i++) { | |
| 121 | + | parse_or_die(argv[i], &info); | |
| 122 | + | ||
| 123 | + | if (selected != URL_NONE) { | |
| 124 | + | extracted = extract_component(selected, &info); | |
| 125 | + | if (extracted) { | |
| 126 | + | puts(extracted); | |
| 127 | + | free(extracted); | |
| 128 | + | } | |
| 129 | + | } | |
| 130 | + | ||
| 131 | + | free(info.url); | |
| 132 | + | } | |
| 133 | + | ||
| 134 | + | return 0; | |
| 135 | + | } | |
modified builtin/worktree.c
| @@ -226,7 +226,7 @@ static void prune_worktrees(void) | |||
| 226 | 226 | while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) { | |
| 227 | 227 | char *path; | |
| 228 | 228 | strbuf_reset(&reason); | |
| 229 | - | if (should_prune_worktree(d->d_name, &reason, &path, expire)) | |
| 229 | + | if (should_prune_worktree(the_repository, d->d_name, &reason, &path, expire)) | |
| 230 | 230 | prune_worktree(d->d_name, reason.buf); | |
| 231 | 231 | else if (path) | |
| 232 | 232 | string_list_append_nodup(&kept, path)->util = xstrdup(d->d_name); | |
| @@ -294,7 +294,7 @@ static void remove_junk_on_signal(int signo) | |||
| 294 | 294 | raise(signo); | |
| 295 | 295 | } | |
| 296 | 296 | ||
| 297 | - | static const char *worktree_basename(const char *path, int *olen) | |
| 297 | + | static char *worktree_basename_dup(const char *path) | |
| 298 | 298 | { | |
| 299 | 299 | const char *name; | |
| 300 | 300 | int len; | |
| @@ -303,14 +303,11 @@ static const char *worktree_basename(const char *path, int *olen) | |||
| 303 | 303 | while (len && is_dir_sep(path[len - 1])) | |
| 304 | 304 | len--; | |
| 305 | 305 | ||
| 306 | - | for (name = path + len - 1; name > path; name--) | |
| 307 | - | if (is_dir_sep(*name)) { | |
| 308 | - | name++; | |
| 309 | - | break; | |
| 310 | - | } | |
| 306 | + | name = path + len; | |
| 307 | + | while (name > path && !is_dir_sep(name[-1])) | |
| 308 | + | name--; | |
| 311 | 309 | ||
| 312 | - | *olen = len; | |
| 313 | - | return name; | |
| 310 | + | return xmemdupz(name, path + len - name); | |
| 314 | 311 | } | |
| 315 | 312 | ||
| 316 | 313 | /* check that path is viable location for worktree */ | |
| @@ -349,7 +346,7 @@ static void copy_sparse_checkout(const char *worktree_git_dir) | |||
| 349 | 346 | ||
| 350 | 347 | if (file_exists(from_file)) { | |
| 351 | 348 | if (safe_create_leading_directories(the_repository, to_file) || | |
| 352 | - | copy_file(to_file, from_file, 0666)) | |
| 349 | + | copy_file(the_repository, to_file, from_file, 0666)) | |
| 353 | 350 | error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"), | |
| 354 | 351 | from_file, to_file); | |
| 355 | 352 | } | |
| @@ -368,7 +365,7 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir) | |||
| 368 | 365 | int bare; | |
| 369 | 366 | ||
| 370 | 367 | if (safe_create_leading_directories(the_repository, to_file) || | |
| 371 | - | copy_file(to_file, from_file, 0666)) { | |
| 368 | + | copy_file(the_repository, to_file, from_file, 0666)) { | |
| 372 | 369 | error(_("failed to copy worktree config from '%s' to '%s'"), | |
| 373 | 370 | from_file, to_file); | |
| 374 | 371 | goto worktree_copy_cleanup; | |
| @@ -464,6 +461,7 @@ static int add_worktree(const char *path, const char *refname, | |||
| 464 | 461 | struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT; | |
| 465 | 462 | struct strbuf sb = STRBUF_INIT; | |
| 466 | 463 | const char *name; | |
| 464 | + | char *name_to_free = NULL; | |
| 467 | 465 | struct strvec child_env = STRVEC_INIT; | |
| 468 | 466 | unsigned int counter = 0; | |
| 469 | 467 | int len, ret; | |
| @@ -475,13 +473,13 @@ static int add_worktree(const char *path, const char *refname, | |||
| 475 | 473 | struct ref_store *wt_refs; | |
| 476 | 474 | struct repo_config_values *cfg = repo_config_values(the_repository); | |
| 477 | 475 | ||
| 478 | - | worktrees = get_worktrees(); | |
| 476 | + | worktrees = get_worktrees(the_repository); | |
| 479 | 477 | check_candidate_path(path, opts->force, worktrees, "add"); | |
| 480 | 478 | free_worktrees(worktrees); | |
| 481 | 479 | worktrees = NULL; | |
| 482 | 480 | ||
| 483 | 481 | /* is 'refname' a branch or commit? */ | |
| 484 | - | if (!opts->detach && !check_branch_ref(&symref, refname) && | |
| 482 | + | if (!opts->detach && !check_branch_ref(the_repository, &symref, refname) && | |
| 485 | 483 | refs_ref_exists(get_main_ref_store(the_repository), symref.buf)) { | |
| 486 | 484 | is_branch = 1; | |
| 487 | 485 | if (!opts->force) | |
| @@ -491,12 +489,12 @@ static int add_worktree(const char *path, const char *refname, | |||
| 491 | 489 | if (!commit && !opts->orphan) | |
| 492 | 490 | die(_("invalid reference: %s"), refname); | |
| 493 | 491 | ||
| 494 | - | name = worktree_basename(path, &len); | |
| 495 | - | strbuf_add(&sb, name, path + len - name); | |
| 496 | - | sanitize_refname_component(sb.buf, &sb_name); | |
| 492 | + | name = name_to_free = worktree_basename_dup(path); | |
| 493 | + | if (!*name) | |
| 494 | + | die(_("invalid path '%s'"), path); | |
| 495 | + | sanitize_refname_component(name, &sb_name); | |
| 497 | 496 | if (!sb_name.len) | |
| 498 | - | BUG("How come '%s' becomes empty after sanitization?", sb.buf); | |
| 499 | - | strbuf_reset(&sb); | |
| 497 | + | BUG("How come '%s' becomes empty after sanitization?", name); | |
| 500 | 498 | name = sb_name.buf; | |
| 501 | 499 | repo_git_path_replace(the_repository, &sb_repo, "worktrees/%s", name); | |
| 502 | 500 | len = sb_repo.len; | |
| @@ -539,7 +537,8 @@ static int add_worktree(const char *path, const char *refname, | |||
| 539 | 537 | ||
| 540 | 538 | strbuf_reset(&sb); | |
| 541 | 539 | strbuf_addf(&sb, "%s/gitdir", sb_repo.buf); | |
| 542 | - | write_worktree_linking_files(sb_git.buf, sb.buf, opts->relative_paths); | |
| 540 | + | write_worktree_linking_files(the_repository, sb_git.buf, | |
| 541 | + | sb.buf, opts->relative_paths); | |
| 543 | 542 | strbuf_reset(&sb); | |
| 544 | 543 | strbuf_addf(&sb, "%s/commondir", sb_repo.buf); | |
| 545 | 544 | write_file(sb.buf, "../.."); | |
| @@ -547,7 +546,7 @@ static int add_worktree(const char *path, const char *refname, | |||
| 547 | 546 | /* | |
| 548 | 547 | * Set up the ref store of the worktree and create the HEAD reference. | |
| 549 | 548 | */ | |
| 550 | - | wt = get_linked_worktree(name, 1); | |
| 549 | + | wt = get_linked_worktree(the_repository, name, 1); | |
| 551 | 550 | if (!wt) { | |
| 552 | 551 | ret = error(_("could not find created worktree '%s'"), name); | |
| 553 | 552 | goto done; | |
| @@ -609,7 +608,7 @@ done: | |||
| 609 | 608 | * is_junk is cleared, but do return appropriate code when hook fails. | |
| 610 | 609 | */ | |
| 611 | 610 | if (!ret && opts->checkout && !opts->orphan) { | |
| 612 | - | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT; | |
| 611 | + | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; | |
| 613 | 612 | ||
| 614 | 613 | strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL); | |
| 615 | 614 | strvec_pushl(&opt.args, | |
| @@ -629,6 +628,7 @@ done: | |||
| 629 | 628 | strbuf_release(&sb_git); | |
| 630 | 629 | strbuf_release(&sb_name); | |
| 631 | 630 | free_worktree(wt); | |
| 631 | + | free(name_to_free); | |
| 632 | 632 | return ret; | |
| 633 | 633 | } | |
| 634 | 634 | ||
| @@ -649,7 +649,7 @@ static void print_preparing_worktree_line(int detach, | |||
| 649 | 649 | fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch); | |
| 650 | 650 | } else { | |
| 651 | 651 | struct strbuf s = STRBUF_INIT; | |
| 652 | - | if (!detach && !check_branch_ref(&s, branch) && | |
| 652 | + | if (!detach && !check_branch_ref(the_repository, &s, branch) && | |
| 653 | 653 | refs_ref_exists(get_main_ref_store(the_repository), s.buf)) | |
| 654 | 654 | fprintf_ln(stderr, _("Preparing worktree (checking out '%s')"), | |
| 655 | 655 | branch); | |
| @@ -763,15 +763,32 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote) | |||
| 763 | 763 | return 1; | |
| 764 | 764 | } | |
| 765 | 765 | ||
| 766 | - | static char *dwim_branch(const char *path, char **new_branch) | |
| 766 | + | static void advise_disambiguating_remotes(const char *path, const char *branch, | |
| 767 | + | const struct string_list *matched_remote_names) | |
| 768 | + | { | |
| 769 | + | struct string_list_item *item; | |
| 770 | + | ||
| 771 | + | advise(_("Branch name '%s' appears in multiple remotes:"), branch); | |
| 772 | + | for_each_string_list_item(item, matched_remote_names) { | |
| 773 | + | advise(_(" %s"), item->string); | |
| 774 | + | } | |
| 775 | + | advise(_("If you meant to create a worktree from a remote tracking branch on\n" | |
| 776 | + | "<remote>, you can do so by:\n" | |
| 777 | + | "\n" | |
| 778 | + | " git worktree add -b %s %s <remote>/%s\n" | |
| 779 | + | "\n" | |
| 780 | + | "If you'd like to always prefer some remote, e.g. 'origin',\n" | |
| 781 | + | "consider setting checkout.defaultRemote=origin in your config."), | |
| 782 | + | branch, path, branch); | |
| 783 | + | } | |
| 784 | + | ||
| 785 | + | static char *dwim_branch(const struct add_opts *opts, const char *path, char **new_branch) | |
| 767 | 786 | { | |
| 768 | - | int n; | |
| 769 | 787 | int branch_exists; | |
| 770 | - | const char *s = worktree_basename(path, &n); | |
| 771 | - | char *branchname = xstrndup(s, n); | |
| 788 | + | char *branchname = worktree_basename_dup(path); | |
| 772 | 789 | struct strbuf ref = STRBUF_INIT; | |
| 773 | 790 | ||
| 774 | - | branch_exists = !check_branch_ref(&ref, branchname) && | |
| 791 | + | branch_exists = !check_branch_ref(the_repository, &ref, branchname) && | |
| 775 | 792 | refs_ref_exists(get_main_ref_store(the_repository), | |
| 776 | 793 | ref.buf); | |
| 777 | 794 | strbuf_release(&ref); | |
| @@ -781,7 +798,21 @@ static char *dwim_branch(const char *path, char **new_branch) | |||
| 781 | 798 | *new_branch = branchname; | |
| 782 | 799 | if (guess_remote) { | |
| 783 | 800 | struct object_id oid; | |
| 784 | - | char *remote = unique_tracking_name(*new_branch, &oid, NULL); | |
| 801 | + | char *remote; | |
| 802 | + | int num_matches = 0; | |
| 803 | + | struct string_list matched_remote_names = STRING_LIST_INIT_DUP; | |
| 804 | + | ||
| 805 | + | remote = unique_tracking_name(*new_branch, &oid, &num_matches, | |
| 806 | + | &matched_remote_names); | |
| 807 | + | if (!remote && num_matches > 1) { | |
| 808 | + | if (!opts->quiet && | |
| 809 | + | advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) | |
| 810 | + | advise_disambiguating_remotes(path, *new_branch, | |
| 811 | + | &matched_remote_names); | |
| 812 | + | die(_("'%s' matched multiple (%d) remote tracking branches"), | |
| 813 | + | *new_branch, num_matches); | |
| 814 | + | } | |
| 815 | + | string_list_clear(&matched_remote_names, 0); | |
| 785 | 816 | return remote; | |
| 786 | 817 | } | |
| 787 | 818 | return NULL; | |
| @@ -868,16 +899,14 @@ static int add(int ac, const char **av, const char *prefix, | |||
| 868 | 899 | new_branch = new_branch_force; | |
| 869 | 900 | ||
| 870 | 901 | if (!opts.force && | |
| 871 | - | !check_branch_ref(&symref, new_branch) && | |
| 902 | + | !check_branch_ref(the_repository, &symref, new_branch) && | |
| 872 | 903 | refs_ref_exists(get_main_ref_store(the_repository), symref.buf)) | |
| 873 | 904 | die_if_checked_out(symref.buf, 0); | |
| 874 | 905 | strbuf_release(&symref); | |
| 875 | 906 | } | |
| 876 | 907 | ||
| 877 | 908 | if (opts.orphan && !new_branch) { | |
| 878 | - | int n; | |
| 879 | - | const char *s = worktree_basename(path, &n); | |
| 880 | - | new_branch = new_branch_to_free = xstrndup(s, n); | |
| 909 | + | new_branch = new_branch_to_free = worktree_basename_dup(path); | |
| 881 | 910 | } else if (opts.orphan) { | |
| 882 | 911 | ; /* no-op */ | |
| 883 | 912 | } else if (opts.detach) { | |
| @@ -889,25 +918,40 @@ static int add(int ac, const char **av, const char *prefix, | |||
| 889 | 918 | opts.orphan = dwim_orphan(&opts, !!opt_track, 0); | |
| 890 | 919 | } else if (ac < 2) { | |
| 891 | 920 | /* DWIM: Guess branch name from path. */ | |
| 892 | - | char *s = dwim_branch(path, &new_branch_to_free); | |
| 921 | + | char *s = dwim_branch(&opts, path, &new_branch_to_free); | |
| 893 | 922 | if (s) | |
| 894 | 923 | branch = branch_to_free = s; | |
| 895 | 924 | new_branch = new_branch_to_free; | |
| 896 | 925 | ||
| 897 | 926 | /* DWIM: Infer --orphan when repo has no refs. */ | |
| 898 | 927 | opts.orphan = (!s) && dwim_orphan(&opts, !!opt_track, 1); | |
| 928 | + | } else if (ac == 2 && new_branch) { | |
| 929 | + | if (!strcmp(branch, "HEAD")) | |
| 930 | + | can_use_local_refs(&opts); | |
| 899 | 931 | } else if (ac == 2) { | |
| 900 | - | struct object_id oid; | |
| 901 | 932 | struct commit *commit; | |
| 902 | - | char *remote; | |
| 903 | 933 | ||
| 904 | 934 | commit = lookup_commit_reference_by_name(branch); | |
| 905 | 935 | if (!commit) { | |
| 906 | - | remote = unique_tracking_name(branch, &oid, NULL); | |
| 936 | + | struct object_id oid; | |
| 937 | + | char *remote; | |
| 938 | + | int num_matches = 0; | |
| 939 | + | struct string_list matched_remote_names = STRING_LIST_INIT_DUP; | |
| 940 | + | ||
| 941 | + | remote = unique_tracking_name(branch, &oid, &num_matches, | |
| 942 | + | &matched_remote_names); | |
| 907 | 943 | if (remote) { | |
| 908 | 944 | new_branch = branch; | |
| 909 | 945 | branch = new_branch_to_free = remote; | |
| 946 | + | } else if (num_matches > 1) { | |
| 947 | + | if (!opts.quiet && | |
| 948 | + | advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) | |
| 949 | + | advise_disambiguating_remotes(path, branch, | |
| 950 | + | &matched_remote_names); | |
| 951 | + | die(_("'%s' matched multiple (%d) remote tracking branches"), | |
| 952 | + | branch, num_matches); | |
| 910 | 953 | } | |
| 954 | + | string_list_clear(&matched_remote_names, 0); | |
| 911 | 955 | } | |
| 912 | 956 | ||
| 913 | 957 | if (!strcmp(branch, "HEAD")) | |
| @@ -945,14 +989,17 @@ static int add(int ac, const char **av, const char *prefix, | |||
| 945 | 989 | strvec_push(&cp.args, branch); | |
| 946 | 990 | if (opt_track) | |
| 947 | 991 | strvec_push(&cp.args, opt_track); | |
| 948 | - | if (run_command(&cp)) | |
| 949 | - | return -1; | |
| 992 | + | if (run_command(&cp)) { | |
| 993 | + | ret = -1; | |
| 994 | + | goto cleanup; | |
| 995 | + | } | |
| 950 | 996 | branch = new_branch; | |
| 951 | 997 | } else if (opt_track) { | |
| 952 | 998 | die(_("--[no-]track can only be used if a new branch is created")); | |
| 953 | 999 | } | |
| 954 | 1000 | ||
| 955 | 1001 | ret = add_worktree(path, branch, &opts); | |
| 1002 | + | cleanup: | |
| 956 | 1003 | free(path); | |
| 957 | 1004 | free(opt_track); | |
| 958 | 1005 | free(branch_to_free); | |
| @@ -1103,7 +1150,7 @@ static int list(int ac, const char **av, const char *prefix, | |||
| 1103 | 1150 | else if (!line_terminator && !porcelain) | |
| 1104 | 1151 | die(_("the option '%s' requires '%s'"), "-z", "--porcelain"); | |
| 1105 | 1152 | else { | |
| 1106 | - | struct worktree **worktrees = get_worktrees(); | |
| 1153 | + | struct worktree **worktrees = get_worktrees(the_repository); | |
| 1107 | 1154 | int path_maxwidth = 0, abbrev = DEFAULT_ABBREV, i; | |
| 1108 | 1155 | struct worktree_display *display = NULL; | |
| 1109 | 1156 | ||
| @@ -1146,7 +1193,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix, | |||
| 1146 | 1193 | if (ac != 1) | |
| 1147 | 1194 | usage_with_options(git_worktree_lock_usage, options); | |
| 1148 | 1195 | ||
| 1149 | - | worktrees = get_worktrees(); | |
| 1196 | + | worktrees = get_worktrees(the_repository); | |
| 1150 | 1197 | wt = find_worktree(worktrees, prefix, av[0]); | |
| 1151 | 1198 | if (!wt) | |
| 1152 | 1199 | die(_("'%s' is not a working tree"), av[0]); | |
| @@ -1183,7 +1230,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix, | |||
| 1183 | 1230 | if (ac != 1) | |
| 1184 | 1231 | usage_with_options(git_worktree_unlock_usage, options); | |
| 1185 | 1232 | ||
| 1186 | - | worktrees = get_worktrees(); | |
| 1233 | + | worktrees = get_worktrees(the_repository); | |
| 1187 | 1234 | wt = find_worktree(worktrees, prefix, av[0]); | |
| 1188 | 1235 | if (!wt) | |
| 1189 | 1236 | die(_("'%s' is not a working tree"), av[0]); | |
| @@ -1269,7 +1316,7 @@ static int move_worktree(int ac, const char **av, const char *prefix, | |||
| 1269 | 1316 | strbuf_addstr(&dst, path); | |
| 1270 | 1317 | free(path); | |
| 1271 | 1318 | ||
| 1272 | - | worktrees = get_worktrees(); | |
| 1319 | + | worktrees = get_worktrees(the_repository); | |
| 1273 | 1320 | wt = find_worktree(worktrees, prefix, av[0]); | |
| 1274 | 1321 | if (!wt) | |
| 1275 | 1322 | die(_("'%s' is not a working tree"), av[0]); | |
| @@ -1394,7 +1441,7 @@ static int remove_worktree(int ac, const char **av, const char *prefix, | |||
| 1394 | 1441 | if (ac != 1) | |
| 1395 | 1442 | usage_with_options(git_worktree_remove_usage, options); | |
| 1396 | 1443 | ||
| 1397 | - | worktrees = get_worktrees(); | |
| 1444 | + | worktrees = get_worktrees(the_repository); | |
| 1398 | 1445 | wt = find_worktree(worktrees, prefix, av[0]); | |
| 1399 | 1446 | if (!wt) | |
| 1400 | 1447 | die(_("'%s' is not a working tree"), av[0]); | |
| @@ -1456,8 +1503,9 @@ static int repair(int ac, const char **av, const char *prefix, | |||
| 1456 | 1503 | ac = parse_options(ac, av, prefix, options, git_worktree_repair_usage, 0); | |
| 1457 | 1504 | p = ac > 0 ? av : self; | |
| 1458 | 1505 | for (; *p; p++) | |
| 1459 | - | repair_worktree_at_path(*p, report_repair, &rc, use_relative_paths); | |
| 1460 | - | repair_worktrees(report_repair, &rc, use_relative_paths); | |
| 1506 | + | repair_worktree_at_path(the_repository, *p, report_repair, | |
| 1507 | + | &rc, use_relative_paths); | |
| 1508 | + | repair_worktrees(the_repository, report_repair, &rc, use_relative_paths); | |
| 1461 | 1509 | return rc; | |
| 1462 | 1510 | } | |
| 1463 | 1511 | ||
modified bundle-uri.c
| @@ -378,7 +378,7 @@ cleanup: | |||
| 378 | 378 | if (child_in) | |
| 379 | 379 | fclose(child_in); | |
| 380 | 380 | if (finish_command(&cp)) | |
| 381 | - | return 1; | |
| 381 | + | result = 1; | |
| 382 | 382 | if (child_out) | |
| 383 | 383 | fclose(child_out); | |
| 384 | 384 | return result; | |
| @@ -396,7 +396,7 @@ static int copy_uri_to_file(const char *filename, const char *uri) | |||
| 396 | 396 | uri = out; | |
| 397 | 397 | ||
| 398 | 398 | /* Copy as a file */ | |
| 399 | - | return copy_file(filename, uri, 0); | |
| 399 | + | return copy_file(the_repository, filename, uri, 0); | |
| 400 | 400 | } | |
| 401 | 401 | ||
| 402 | 402 | static int unbundle_from_file(struct repository *r, const char *file) | |
| @@ -946,8 +946,12 @@ static int config_to_packet_line(const char *key, const char *value, | |||
| 946 | 946 | { | |
| 947 | 947 | struct packet_reader *writer = data; | |
| 948 | 948 | ||
| 949 | - | if (starts_with(key, "bundle.")) | |
| 950 | - | packet_write_fmt(writer->fd, "%s=%s", key, value); | |
| 949 | + | if (starts_with(key, "bundle.")) { | |
| 950 | + | if (value && *value) | |
| 951 | + | packet_write_fmt(writer->fd, "%s=%s", key, value); | |
| 952 | + | else | |
| 953 | + | warning(_("config '%s' has no value"), key); | |
| 954 | + | } | |
| 951 | 955 | ||
| 952 | 956 | return 0; | |
| 953 | 957 | } | |
modified bundle.c
| @@ -1,4 +1,3 @@ | |||
| 1 | - | #define USE_THE_REPOSITORY_VARIABLE | |
| 2 | 1 | #define DISABLE_SIGN_COMPARE_WARNINGS | |
| 3 | 2 | ||
| 4 | 3 | #include "git-compat-util.h" | |
| @@ -21,6 +20,13 @@ | |||
| 21 | 20 | #include "connected.h" | |
| 22 | 21 | #include "write-or-die.h" | |
| 23 | 22 | ||
| 23 | + | /* | |
| 24 | + | * NEEDSWORK: this function implicitly depends on `the_repository` and is not | |
| 25 | + | * available because we dropped USE_THE_REPOSITORY_VARIABLE. We can remove the | |
| 26 | + | * declaration once it's accessible via `repo_config_values`. | |
| 27 | + | */ | |
| 28 | + | extern const char *get_log_output_encoding(void); | |
| 29 | + | ||
| 24 | 30 | static const char v2_bundle_signature[] = "# v2 git bundle\n"; | |
| 25 | 31 | static const char v3_bundle_signature[] = "# v3 git bundle\n"; | |
| 26 | 32 | static struct { | |
| @@ -294,9 +300,10 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv) | |||
| 294 | 300 | return list_refs(&header->references, argc, argv); | |
| 295 | 301 | } | |
| 296 | 302 | ||
| 297 | - | static int is_tag_in_date_range(struct object *tag, struct rev_info *revs) | |
| 303 | + | static int is_tag_in_date_range(struct repository *repo, | |
| 304 | + | struct object *tag, struct rev_info *revs) | |
| 298 | 305 | { | |
| 299 | - | unsigned long size; | |
| 306 | + | size_t size; | |
| 300 | 307 | enum object_type type; | |
| 301 | 308 | char *buf = NULL, *line, *lineend; | |
| 302 | 309 | timestamp_t date; | |
| @@ -305,7 +312,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs) | |||
| 305 | 312 | if (revs->max_age == -1 && revs->min_age == -1) | |
| 306 | 313 | goto out; | |
| 307 | 314 | ||
| 308 | - | buf = odb_read_object(the_repository->objects, &tag->oid, &type, &size); | |
| 315 | + | buf = odb_read_object(repo->objects, &tag->oid, &type, &size); | |
| 309 | 316 | if (!buf) | |
| 310 | 317 | goto out; | |
| 311 | 318 | line = memmem(buf, size, "\ntagger ", 8); | |
| @@ -325,50 +332,52 @@ out: | |||
| 325 | 332 | ||
| 326 | 333 | ||
| 327 | 334 | /* Write the pack data to bundle_fd */ | |
| 328 | - | static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options) | |
| 335 | + | static int write_pack_data(int bundle_fd, struct rev_info *revs, int progress) | |
| 329 | 336 | { | |
| 330 | - | struct child_process pack_objects = CHILD_PROCESS_INIT; | |
| 337 | + | struct odb_generate_pack_options opts = ODB_GENERATE_PACK_OPTIONS_INIT; | |
| 338 | + | struct odb_pack_generator *generator; | |
| 339 | + | int ret = 0; | |
| 331 | 340 | int i; | |
| 332 | 341 | ||
| 333 | - | strvec_pushl(&pack_objects.args, | |
| 334 | - | "pack-objects", | |
| 335 | - | "--stdout", "--thin", "--delta-base-offset", | |
| 336 | - | NULL); | |
| 337 | - | strvec_pushv(&pack_objects.args, pack_options->v); | |
| 342 | + | opts.thin = 1; | |
| 343 | + | opts.ofs_delta = 1; | |
| 344 | + | if (progress) | |
| 345 | + | opts.progress = ODB_GENERATE_PACK_PROGRESS_VERBOSE; | |
| 338 | 346 | if (revs->filter.choice) | |
| 339 | - | strvec_pushf(&pack_objects.args, "--filter=%s", | |
| 340 | - | list_objects_filter_spec(&revs->filter)); | |
| 341 | - | pack_objects.in = -1; | |
| 342 | - | pack_objects.out = bundle_fd; | |
| 343 | - | pack_objects.git_cmd = 1; | |
| 347 | + | opts.filter_spec = list_objects_filter_spec(&revs->filter); | |
| 344 | 348 | ||
| 345 | 349 | /* | |
| 346 | - | * start_command() will close our descriptor if it's >1. Duplicate it | |
| 347 | - | * to avoid surprising the caller. | |
| 350 | + | * The pack generator will consume our descriptor if it's >1. | |
| 351 | + | * Duplicate it to avoid surprising the caller. | |
| 348 | 352 | */ | |
| 349 | - | if (pack_objects.out > 1) { | |
| 350 | - | pack_objects.out = dup(pack_objects.out); | |
| 351 | - | if (pack_objects.out < 0) { | |
| 352 | - | error_errno(_("unable to dup bundle descriptor")); | |
| 353 | - | child_process_clear(&pack_objects); | |
| 354 | - | return -1; | |
| 355 | - | } | |
| 353 | + | opts.pack_fd = bundle_fd; | |
| 354 | + | if (opts.pack_fd > 1) { | |
| 355 | + | opts.pack_fd = dup(bundle_fd); | |
| 356 | + | if (opts.pack_fd < 0) | |
| 357 | + | return error_errno(_("unable to dup bundle descriptor")); | |
| 356 | 358 | } | |
| 357 | 359 | ||
| 358 | - | if (start_command(&pack_objects)) | |
| 359 | - | return error(_("Could not spawn pack-objects")); | |
| 360 | - | ||
| 361 | 360 | for (i = 0; i < revs->pending.nr; i++) { | |
| 362 | 361 | struct object *object = revs->pending.objects[i].item; | |
| 363 | 362 | if (object->flags & UNINTERESTING) | |
| 364 | - | write_or_die(pack_objects.in, "^", 1); | |
| 365 | - | write_or_die(pack_objects.in, oid_to_hex(&object->oid), the_hash_algo->hexsz); | |
| 366 | - | write_or_die(pack_objects.in, "\n", 1); | |
| 363 | + | oid_array_append(&opts.haves, &object->oid); | |
| 364 | + | else | |
| 365 | + | oid_array_append(&opts.wants, &object->oid); | |
| 367 | 366 | } | |
| 368 | - | close(pack_objects.in); | |
| 369 | - | if (finish_command(&pack_objects)) | |
| 370 | - | return error(_("pack-objects died")); | |
| 371 | - | return 0; | |
| 367 | + | ||
| 368 | + | if (odb_generate_pack(revs->repo->objects, &generator, &opts)) { | |
| 369 | + | ret = error(_("Could not spawn pack-objects")); | |
| 370 | + | goto out; | |
| 371 | + | } | |
| 372 | + | ||
| 373 | + | if (odb_pack_generator_finish(generator)) { | |
| 374 | + | ret = error(_("pack-objects died")); | |
| 375 | + | goto out; | |
| 376 | + | } | |
| 377 | + | ||
| 378 | + | out: | |
| 379 | + | odb_generate_pack_options_release(&opts); | |
| 380 | + | return ret; | |
| 372 | 381 | } | |
| 373 | 382 | ||
| 374 | 383 | /* | |
| @@ -395,10 +404,10 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) | |||
| 395 | 404 | ||
| 396 | 405 | if (e->item->flags & UNINTERESTING) | |
| 397 | 406 | continue; | |
| 398 | - | if (repo_dwim_ref(the_repository, e->name, strlen(e->name), | |
| 407 | + | if (repo_dwim_ref(revs->repo, e->name, strlen(e->name), | |
| 399 | 408 | &oid, &ref, 0) != 1) | |
| 400 | 409 | goto skip_write_ref; | |
| 401 | - | if (refs_read_ref_full(get_main_ref_store(the_repository), e->name, RESOLVE_REF_READING, &oid, &flag)) | |
| 410 | + | if (refs_read_ref_full(get_main_ref_store(revs->repo), e->name, RESOLVE_REF_READING, &oid, &flag)) | |
| 402 | 411 | flag = 0; | |
| 403 | 412 | display_ref = (flag & REF_ISSYMREF) ? e->name : ref; | |
| 404 | 413 | ||
| @@ -406,7 +415,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) | |||
| 406 | 415 | goto skip_write_ref; | |
| 407 | 416 | ||
| 408 | 417 | if (e->item->type == OBJ_TAG && | |
| 409 | - | !is_tag_in_date_range(e->item, revs)) { | |
| 418 | + | !is_tag_in_date_range(revs->repo, e->item, revs)) { | |
| 410 | 419 | e->item->flags |= UNINTERESTING; | |
| 411 | 420 | goto skip_write_ref; | |
| 412 | 421 | } | |
| @@ -428,7 +437,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) | |||
| 428 | 437 | ||
| 429 | 438 | ref_count++; | |
| 430 | 439 | strset_add(&objects, display_ref); | |
| 431 | - | write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz); | |
| 440 | + | write_or_die(bundle_fd, oid_to_hex(&e->item->oid), | |
| 441 | + | revs->repo->hash_algo->hexsz); | |
| 432 | 442 | write_or_die(bundle_fd, " ", 1); | |
| 433 | 443 | write_or_die(bundle_fd, display_ref, strlen(display_ref)); | |
| 434 | 444 | write_or_die(bundle_fd, "\n", 1); | |
| @@ -476,7 +486,7 @@ static void write_bundle_prerequisites(struct commit *commit, void *data) | |||
| 476 | 486 | } | |
| 477 | 487 | ||
| 478 | 488 | int create_bundle(struct repository *r, const char *path, | |
| 479 | - | int argc, const char **argv, struct strvec *pack_options, int version) | |
| 489 | + | int argc, const char **argv, int version, int progress) | |
| 480 | 490 | { | |
| 481 | 491 | struct lock_file lock = LOCK_INIT; | |
| 482 | 492 | int bundle_fd = -1; | |
| @@ -507,7 +517,7 @@ int create_bundle(struct repository *r, const char *path, | |||
| 507 | 517 | * SHA1. | |
| 508 | 518 | * 2. @filter is required because we parsed an object filter. | |
| 509 | 519 | */ | |
| 510 | - | if (the_hash_algo != &hash_algos[GIT_HASH_SHA1_LEGACY] || revs.filter.choice) | |
| 520 | + | if (r->hash_algo != &hash_algos[GIT_HASH_SHA1_LEGACY] || revs.filter.choice) | |
| 511 | 521 | min_version = 3; | |
| 512 | 522 | ||
| 513 | 523 | if (argc > 1) { | |
| @@ -519,8 +529,8 @@ int create_bundle(struct repository *r, const char *path, | |||
| 519 | 529 | if (bundle_to_stdout) | |
| 520 | 530 | bundle_fd = 1; | |
| 521 | 531 | else | |
| 522 | - | bundle_fd = hold_lock_file_for_update(&lock, path, | |
| 523 | - | LOCK_DIE_ON_ERROR); | |
| 532 | + | bundle_fd = repo_hold_lock_file_for_update(r, &lock, path, | |
| 533 | + | LOCK_DIE_ON_ERROR); | |
| 524 | 534 | ||
| 525 | 535 | if (version == -1) | |
| 526 | 536 | version = min_version; | |
| @@ -528,14 +538,15 @@ int create_bundle(struct repository *r, const char *path, | |||
| 528 | 538 | if (version < 2 || version > 3) { | |
| 529 | 539 | die(_("unsupported bundle version %d"), version); | |
| 530 | 540 | } else if (version < min_version) { | |
| 531 | - | die(_("cannot write bundle version %d with algorithm %s"), version, the_hash_algo->name); | |
| 541 | + | die(_("cannot write bundle version %d with algorithm %s"), version, | |
| 542 | + | r->hash_algo->name); | |
| 532 | 543 | } else if (version == 2) { | |
| 533 | 544 | write_or_die(bundle_fd, v2_bundle_signature, strlen(v2_bundle_signature)); | |
| 534 | 545 | } else { | |
| 535 | 546 | const char *capability = "@object-format="; | |
| 536 | 547 | write_or_die(bundle_fd, v3_bundle_signature, strlen(v3_bundle_signature)); | |
| 537 | 548 | write_or_die(bundle_fd, capability, strlen(capability)); | |
| 538 | - | write_or_die(bundle_fd, the_hash_algo->name, strlen(the_hash_algo->name)); | |
| 549 | + | write_or_die(bundle_fd, r->hash_algo->name, strlen(r->hash_algo->name)); | |
| 539 | 550 | write_or_die(bundle_fd, "\n", 1); | |
| 540 | 551 | ||
| 541 | 552 | if (revs.filter.choice) { | |
| @@ -584,7 +595,7 @@ int create_bundle(struct repository *r, const char *path, | |||
| 584 | 595 | } | |
| 585 | 596 | ||
| 586 | 597 | /* write pack */ | |
| 587 | - | if (write_pack_data(bundle_fd, &revs_copy, pack_options)) { | |
| 598 | + | if (write_pack_data(bundle_fd, &revs_copy, progress)) { | |
| 588 | 599 | ret = -1; | |
| 589 | 600 | goto out; | |
| 590 | 601 | } | |
modified bundle.h
| @@ -27,8 +27,7 @@ int read_bundle_header(const char *path, struct bundle_header *header); | |||
| 27 | 27 | int read_bundle_header_fd(int fd, struct bundle_header *header, | |
| 28 | 28 | const char *report_path); | |
| 29 | 29 | int create_bundle(struct repository *r, const char *path, | |
| 30 | - | int argc, const char **argv, struct strvec *pack_options, | |
| 31 | - | int version); | |
| 30 | + | int argc, const char **argv, int version, int progress); | |
| 32 | 31 | ||
| 33 | 32 | enum verify_bundle_flags { | |
| 34 | 33 | VERIFY_BUNDLE_VERBOSE = (1 << 0), | |
modified cache-tree.c
| @@ -1,4 +1,3 @@ | |||
| 1 | - | #define USE_THE_REPOSITORY_VARIABLE | |
| 2 | 1 | #define DISABLE_SIGN_COMPARE_WARNINGS | |
| 3 | 2 | ||
| 4 | 3 | #include "git-compat-util.h" | |
| @@ -10,6 +9,7 @@ | |||
| 10 | 9 | #include "cache-tree.h" | |
| 11 | 10 | #include "object-file.h" | |
| 12 | 11 | #include "odb.h" | |
| 12 | + | #include "odb/transaction.h" | |
| 13 | 13 | #include "read-cache-ll.h" | |
| 14 | 14 | #include "replace-object.h" | |
| 15 | 15 | #include "repository.h" | |
| @@ -161,6 +161,54 @@ void cache_tree_invalidate_path(struct index_state *istate, const char *path) | |||
| 161 | 161 | istate->cache_changed |= CACHE_TREE_CHANGED; | |
| 162 | 162 | } | |
| 163 | 163 | ||
| 164 | + | /* | |
| 165 | + | * Check whether this_ce and the next entry in the index form a D/F | |
| 166 | + | * conflict ("path" vs "path/file"). Returns the conflicting "path/..." | |
| 167 | + | * name when one is found, or NULL otherwise. | |
| 168 | + | * | |
| 169 | + | * The cache is sorted, so "path/file" sorts after "path" and the | |
| 170 | + | * conflict is usually visible as adjacent entries. But other entries | |
| 171 | + | * can sort between them -- e.g. "path-internal" sits between "path" | |
| 172 | + | * and "path/file" because '-' (0x2D) precedes '/' (0x2F) -- so when | |
| 173 | + | * the immediately following entry shares our prefix but starts with a | |
| 174 | + | * character that sorts before '/', binary search for "path/" instead. | |
| 175 | + | */ | |
| 176 | + | static const char *find_df_conflict(struct index_state *istate, | |
| 177 | + | const struct cache_entry *this_ce, | |
| 178 | + | const struct cache_entry *next_ce) | |
| 179 | + | { | |
| 180 | + | const char *this_name = this_ce->name; | |
| 181 | + | const char *next_name = next_ce->name; | |
| 182 | + | int this_len = ce_namelen(this_ce); | |
| 183 | + | const struct cache_entry *other; | |
| 184 | + | struct strbuf probe = STRBUF_INIT; | |
| 185 | + | int pos; | |
| 186 | + | ||
| 187 | + | if (this_len >= ce_namelen(next_ce) || | |
| 188 | + | next_name[this_len] > '/' || | |
| 189 | + | strncmp(this_name, next_name, this_len)) | |
| 190 | + | return NULL; | |
| 191 | + | ||
| 192 | + | if (next_name[this_len] == '/') | |
| 193 | + | return next_name; | |
| 194 | + | ||
| 195 | + | strbuf_add(&probe, this_name, this_len); | |
| 196 | + | strbuf_addch(&probe, '/'); | |
| 197 | + | pos = index_name_pos_sparse(istate, probe.buf, probe.len); | |
| 198 | + | strbuf_release(&probe); | |
| 199 | + | ||
| 200 | + | if (pos < 0) | |
| 201 | + | pos = -pos - 1; | |
| 202 | + | if (pos >= (int)istate->cache_nr) | |
| 203 | + | return NULL; | |
| 204 | + | other = istate->cache[pos]; | |
| 205 | + | if (ce_namelen(other) > this_len && | |
| 206 | + | other->name[this_len] == '/' && | |
| 207 | + | !strncmp(this_name, other->name, this_len)) | |
| 208 | + | return other->name; | |
| 209 | + | return NULL; | |
| 210 | + | } | |
| 211 | + | ||
| 164 | 212 | static int verify_cache(struct index_state *istate, int flags) | |
| 165 | 213 | { | |
| 166 | 214 | unsigned i, funny; | |
| @@ -190,24 +238,18 @@ static int verify_cache(struct index_state *istate, int flags) | |||
| 190 | 238 | */ | |
| 191 | 239 | funny = 0; | |
| 192 | 240 | for (i = 0; i + 1 < istate->cache_nr; i++) { | |
| 193 | - | /* path/file always comes after path because of the way | |
| 194 | - | * the cache is sorted. Also path can appear only once, | |
| 195 | - | * which means conflicting one would immediately follow. | |
| 196 | - | */ | |
| 197 | 241 | const struct cache_entry *this_ce = istate->cache[i]; | |
| 198 | 242 | const struct cache_entry *next_ce = istate->cache[i + 1]; | |
| 199 | - | const char *this_name = this_ce->name; | |
| 200 | - | const char *next_name = next_ce->name; | |
| 201 | - | int this_len = ce_namelen(this_ce); | |
| 202 | - | if (this_len < ce_namelen(next_ce) && | |
| 203 | - | next_name[this_len] == '/' && | |
| 204 | - | strncmp(this_name, next_name, this_len) == 0) { | |
| 243 | + | const char *conflict_name; | |
| 244 | + | ||
| 245 | + | conflict_name = find_df_conflict(istate, this_ce, next_ce); | |
| 246 | + | if (conflict_name) { | |
| 205 | 247 | if (10 < ++funny) { | |
| 206 | 248 | fprintf(stderr, "...\n"); | |
| 207 | 249 | break; | |
| 208 | 250 | } | |
| 209 | 251 | fprintf(stderr, "You have both %s and %s\n", | |
| 210 | - | this_name, next_name); | |
| 252 | + | this_ce->name, conflict_name); | |
| 211 | 253 | } | |
| 212 | 254 | } | |
| 213 | 255 | if (funny) | |
| @@ -232,28 +274,37 @@ static void discard_unused_subtrees(struct cache_tree *it) | |||
| 232 | 274 | } | |
| 233 | 275 | } | |
| 234 | 276 | ||
| 235 | - | int cache_tree_fully_valid(struct cache_tree *it) | |
| 277 | + | static int cache_tree_fully_valid_recursive(struct object_database *odb, | |
| 278 | + | struct cache_tree *it) | |
| 236 | 279 | { | |
| 237 | 280 | int i; | |
| 238 | 281 | if (!it) | |
| 239 | 282 | return 0; | |
| 240 | 283 | if (it->entry_count < 0 || | |
| 241 | - | odb_has_object(the_repository->objects, &it->oid, | |
| 242 | - | ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) | |
| 284 | + | !odb_has_object(odb, &it->oid, | |
| 285 | + | ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) | |
| 243 | 286 | return 0; | |
| 244 | 287 | for (i = 0; i < it->subtree_nr; i++) { | |
| 245 | - | if (!cache_tree_fully_valid(it->down[i]->cache_tree)) | |
| 288 | + | if (!cache_tree_fully_valid_recursive(odb, it->down[i]->cache_tree)) | |
| 246 | 289 | return 0; | |
| 247 | 290 | } | |
| 248 | 291 | return 1; | |
| 249 | 292 | } | |
| 250 | 293 | ||
| 251 | - | static int must_check_existence(const struct cache_entry *ce) | |
| 294 | + | int cache_tree_fully_valid(struct index_state *istate) | |
| 252 | 295 | { | |
| 253 | - | return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce)); | |
| 296 | + | return cache_tree_fully_valid_recursive(istate->repo->objects, | |
| 297 | + | istate->cache_tree); | |
| 254 | 298 | } | |
| 255 | 299 | ||
| 256 | - | static int update_one(struct cache_tree *it, | |
| 300 | + | static int must_check_existence(const struct cache_entry *ce, void *cb_data) | |
| 301 | + | { | |
| 302 | + | struct repository *repo = cb_data; | |
| 303 | + | return !(repo_has_promisor_remote(repo) && ce_skip_worktree(ce)); | |
| 304 | + | } | |
| 305 | + | ||
| 306 | + | static int update_one(struct repository *repo, | |
| 307 | + | struct cache_tree *it, | |
| 257 | 308 | struct cache_entry **cache, | |
| 258 | 309 | int entries, | |
| 259 | 310 | const char *base, | |
| @@ -291,7 +342,7 @@ static int update_one(struct cache_tree *it, | |||
| 291 | 342 | } | |
| 292 | 343 | ||
| 293 | 344 | if (0 <= it->entry_count && | |
| 294 | - | odb_has_object(the_repository->objects, &it->oid, | |
| 345 | + | odb_has_object(repo->objects, &it->oid, | |
| 295 | 346 | ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) | |
| 296 | 347 | return it->entry_count; | |
| 297 | 348 | ||
| @@ -332,7 +383,8 @@ static int update_one(struct cache_tree *it, | |||
| 332 | 383 | sub = find_subtree(it, path + baselen, sublen, 1); | |
| 333 | 384 | if (!sub->cache_tree) | |
| 334 | 385 | sub->cache_tree = cache_tree(); | |
| 335 | - | subcnt = update_one(sub->cache_tree, | |
| 386 | + | subcnt = update_one(repo, | |
| 387 | + | sub->cache_tree, | |
| 336 | 388 | cache + i, entries - i, | |
| 337 | 389 | path, | |
| 338 | 390 | baselen + sublen + 1, | |
| @@ -396,10 +448,10 @@ static int update_one(struct cache_tree *it, | |||
| 396 | 448 | } | |
| 397 | 449 | ||
| 398 | 450 | ce_missing_ok = mode == S_IFGITLINK || missing_ok || | |
| 399 | - | !must_check_existence(ce); | |
| 451 | + | !must_check_existence(ce, repo); | |
| 400 | 452 | if (is_null_oid(oid) || | |
| 401 | 453 | (!ce_missing_ok && | |
| 402 | - | !odb_has_object(the_repository->objects, oid, | |
| 454 | + | !odb_has_object(repo->objects, oid, | |
| 403 | 455 | ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))) { | |
| 404 | 456 | strbuf_release(&buffer); | |
| 405 | 457 | if (expected_missing) | |
| @@ -431,12 +483,12 @@ static int update_one(struct cache_tree *it, | |||
| 431 | 483 | /* | |
| 432 | 484 | * "sub" can be an empty tree if all subentries are i-t-a. | |
| 433 | 485 | */ | |
| 434 | - | if (contains_ita && is_empty_tree_oid(oid, the_repository->hash_algo)) | |
| 486 | + | if (contains_ita && is_empty_tree_oid(oid, repo->hash_algo)) | |
| 435 | 487 | continue; | |
| 436 | 488 | ||
| 437 | 489 | strbuf_grow(&buffer, entlen + 100); | |
| 438 | 490 | strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0'); | |
| 439 | - | strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz); | |
| 491 | + | strbuf_add(&buffer, oid->hash, repo->hash_algo->rawsz); | |
| 440 | 492 | ||
| 441 | 493 | #if DEBUG_CACHE_TREE | |
| 442 | 494 | fprintf(stderr, "cache-tree update-one %o %.*s\n", | |
| @@ -446,16 +498,16 @@ static int update_one(struct cache_tree *it, | |||
| 446 | 498 | ||
| 447 | 499 | if (repair) { | |
| 448 | 500 | struct object_id oid; | |
| 449 | - | hash_object_file(the_hash_algo, buffer.buf, buffer.len, | |
| 501 | + | hash_object_file(repo->hash_algo, buffer.buf, buffer.len, | |
| 450 | 502 | OBJ_TREE, &oid); | |
| 451 | - | if (odb_has_object(the_repository->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED)) | |
| 503 | + | if (odb_has_object(repo->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED)) | |
| 452 | 504 | oidcpy(&it->oid, &oid); | |
| 453 | 505 | else | |
| 454 | 506 | to_invalidate = 1; | |
| 455 | 507 | } else if (dryrun) { | |
| 456 | - | hash_object_file(the_hash_algo, buffer.buf, buffer.len, | |
| 508 | + | hash_object_file(repo->hash_algo, buffer.buf, buffer.len, | |
| 457 | 509 | OBJ_TREE, &it->oid); | |
| 458 | - | } else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE, | |
| 510 | + | } else if (odb_write_object_ext(repo->objects, buffer.buf, buffer.len, OBJ_TREE, | |
| 459 | 511 | &it->oid, NULL, flags & WRITE_TREE_SILENT ? ODB_WRITE_OBJECT_SILENT : 0)) { | |
| 460 | 512 | strbuf_release(&buffer); | |
| 461 | 513 | return -1; | |
| @@ -473,6 +525,7 @@ static int update_one(struct cache_tree *it, | |||
| 473 | 525 | ||
| 474 | 526 | int cache_tree_update(struct index_state *istate, int flags) | |
| 475 | 527 | { | |
| 528 | + | int inflight = !!istate->repo->objects->transaction; | |
| 476 | 529 | struct odb_transaction *transaction; | |
| 477 | 530 | int skip, i; | |
| 478 | 531 | ||
| @@ -484,15 +537,17 @@ int cache_tree_update(struct index_state *istate, int flags) | |||
| 484 | 537 | if (!istate->cache_tree) | |
| 485 | 538 | istate->cache_tree = cache_tree(); | |
| 486 | 539 | ||
| 487 | - | if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository)) | |
| 488 | - | prefetch_cache_entries(istate, must_check_existence); | |
| 540 | + | if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(istate->repo)) | |
| 541 | + | prefetch_cache_entries(istate, must_check_existence, istate->repo); | |
| 489 | 542 | ||
| 490 | 543 | trace_performance_enter(); | |
| 491 | 544 | trace2_region_enter("cache_tree", "update", istate->repo); | |
| 492 | - | transaction = odb_transaction_begin(the_repository->objects); | |
| 493 | - | i = update_one(istate->cache_tree, istate->cache, istate->cache_nr, | |
| 545 | + | if (!inflight) | |
| 546 | + | odb_transaction_begin_or_die(istate->repo->objects, &transaction, 0); | |
| 547 | + | i = update_one(istate->repo, istate->cache_tree, istate->cache, istate->cache_nr, | |
| 494 | 548 | "", 0, &skip, flags); | |
| 495 | - | odb_transaction_commit(transaction); | |
| 549 | + | if (!inflight) | |
| 550 | + | odb_transaction_commit_and_finalize_or_die(transaction); | |
| 496 | 551 | trace2_region_leave("cache_tree", "update", istate->repo); | |
| 497 | 552 | trace_performance_leave("cache_tree_update"); | |
| 498 | 553 | if (i < 0) | |
| @@ -501,7 +556,8 @@ int cache_tree_update(struct index_state *istate, int flags) | |||
| 501 | 556 | return 0; | |
| 502 | 557 | } | |
| 503 | 558 | ||
| 504 | - | static void write_one(struct strbuf *buffer, struct cache_tree *it, | |
| 559 | + | static void write_one(struct repository *repo, | |
| 560 | + | struct strbuf *buffer, struct cache_tree *it, | |
| 505 | 561 | const char *path, int pathlen) | |
| 506 | 562 | { | |
| 507 | 563 | int i; | |
| @@ -527,7 +583,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it, | |||
| 527 | 583 | #endif | |
| 528 | 584 | ||
| 529 | 585 | if (0 <= it->entry_count) { | |
| 530 | - | strbuf_add(buffer, it->oid.hash, the_hash_algo->rawsz); | |
| 586 | + | strbuf_add(buffer, it->oid.hash, repo->hash_algo->rawsz); | |
| 531 | 587 | } | |
| 532 | 588 | for (i = 0; i < it->subtree_nr; i++) { | |
| 533 | 589 | struct cache_tree_sub *down = it->down[i]; | |
| @@ -537,15 +593,16 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it, | |||
| 537 | 593 | prev->name, prev->namelen) <= 0) | |
| 538 | 594 | die("fatal - unsorted cache subtree"); | |
| 539 | 595 | } | |
| 540 | - | write_one(buffer, down->cache_tree, down->name, down->namelen); | |
| 596 | + | write_one(repo, buffer, down->cache_tree, down->name, down->namelen); | |
| 541 | 597 | } | |
| 542 | 598 | } | |
| 543 | 599 | ||
| 544 | - | void cache_tree_write(struct strbuf *sb, struct cache_tree *root) | |
| 600 | + | void cache_tree_write(struct repository *repo, | |
| 601 | + | struct strbuf *sb, struct cache_tree *root) | |
| 545 | 602 | { | |
| 546 | - | trace2_region_enter("cache_tree", "write", the_repository); | |
| 547 | - | write_one(sb, root, "", 0); | |
| 548 | - | trace2_region_leave("cache_tree", "write", the_repository); | |
| 603 | + | trace2_region_enter("cache_tree", "write", repo); | |
| 604 | + | write_one(repo, sb, root, "", 0); | |
| 605 | + | trace2_region_leave("cache_tree", "write", repo); | |
| 549 | 606 | } | |
| 550 | 607 | ||
| 551 | 608 | static int parse_int(const char **ptr, unsigned long *len_p, int *out) | |
| @@ -579,13 +636,14 @@ static int parse_int(const char **ptr, unsigned long *len_p, int *out) | |||
| 579 | 636 | return 0; | |
| 580 | 637 | } | |
| 581 | 638 | ||
| 582 | - | static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) | |
| 639 | + | static struct cache_tree *read_one(struct repository *repo, | |
| 640 | + | const char **buffer, unsigned long *size_p) | |
| 583 | 641 | { | |
| 584 | 642 | const char *buf = *buffer; | |
| 585 | 643 | unsigned long size = *size_p; | |
| 586 | 644 | struct cache_tree *it; | |
| 587 | 645 | int i, subtree_nr; | |
| 588 | - | const unsigned rawsz = the_hash_algo->rawsz; | |
| 646 | + | const unsigned rawsz = repo->hash_algo->rawsz; | |
| 589 | 647 | ||
| 590 | 648 | it = NULL; | |
| 591 | 649 | /* skip name, but make sure name exists */ | |
| @@ -612,7 +670,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) | |||
| 612 | 670 | if (size < rawsz) | |
| 613 | 671 | goto free_return; | |
| 614 | 672 | oidread(&it->oid, (const unsigned char *)buf, | |
| 615 | - | the_repository->hash_algo); | |
| 673 | + | repo->hash_algo); | |
| 616 | 674 | buf += rawsz; | |
| 617 | 675 | size -= rawsz; | |
| 618 | 676 | } | |
| @@ -640,7 +698,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) | |||
| 640 | 698 | struct cache_tree_sub *subtree; | |
| 641 | 699 | const char *name = buf; | |
| 642 | 700 | ||
| 643 | - | sub = read_one(&buf, &size); | |
| 701 | + | sub = read_one(repo, &buf, &size); | |
| 644 | 702 | if (!sub) | |
| 645 | 703 | goto free_return; | |
| 646 | 704 | subtree = cache_tree_sub(it, name); | |
| @@ -657,16 +715,17 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p) | |||
| 657 | 715 | return NULL; | |
| 658 | 716 | } | |
| 659 | 717 | ||
| 660 | - | struct cache_tree *cache_tree_read(const char *buffer, unsigned long size) | |
| 718 | + | struct cache_tree *cache_tree_read(struct repository *repo, | |
| 719 | + | const char *buffer, unsigned long size) | |
| 661 | 720 | { | |
| 662 | 721 | struct cache_tree *result; | |
| 663 | 722 | ||
| 664 | 723 | if (buffer[0]) | |
| 665 | 724 | return NULL; /* not the whole tree */ | |
| 666 | 725 | ||
| 667 | - | trace2_region_enter("cache_tree", "read", the_repository); | |
| 668 | - | result = read_one(&buffer, &size); | |
| 669 | - | trace2_region_leave("cache_tree", "read", the_repository); | |
| 726 | + | trace2_region_enter("cache_tree", "read", repo); | |
| 727 | + | result = read_one(repo, &buffer, &size); | |
| 728 | + | trace2_region_leave("cache_tree", "read", repo); | |
| 670 | 729 | ||
| 671 | 730 | return result; | |
| 672 | 731 | } | |
| @@ -729,7 +788,7 @@ struct tree *write_in_core_index_as_tree(struct repository *repo, | |||
| 729 | 788 | int was_valid, ret; | |
| 730 | 789 | ||
| 731 | 790 | was_valid = index_state->cache_tree && | |
| 732 | - | cache_tree_fully_valid(index_state->cache_tree); | |
| 791 | + | cache_tree_fully_valid(index_state); | |
| 733 | 792 | ||
| 734 | 793 | ret = write_index_as_tree_internal(&o, index_state, was_valid, 0, NULL); | |
| 735 | 794 | if (ret == WRITE_TREE_UNMERGED_INDEX) { | |
| @@ -757,7 +816,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state, | |||
| 757 | 816 | hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR); | |
| 758 | 817 | ||
| 759 | 818 | entries = read_index_from(index_state, index_path, | |
| 760 | - | repo_get_git_dir(the_repository)); | |
| 819 | + | repo_get_git_dir(index_state->repo)); | |
| 761 | 820 | if (entries < 0) { | |
| 762 | 821 | ret = WRITE_TREE_UNREADABLE_INDEX; | |
| 763 | 822 | goto out; | |
| @@ -765,7 +824,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state, | |||
| 765 | 824 | ||
| 766 | 825 | was_valid = !(flags & WRITE_TREE_IGNORE_CACHE_TREE) && | |
| 767 | 826 | index_state->cache_tree && | |
| 768 | - | cache_tree_fully_valid(index_state->cache_tree); | |
| 827 | + | cache_tree_fully_valid(index_state); | |
| 769 | 828 | ||
| 770 | 829 | ret = write_index_as_tree_internal(oid, index_state, was_valid, flags, | |
| 771 | 830 | prefix); | |
| @@ -813,7 +872,7 @@ static void prime_cache_tree_rec(struct repository *r, | |||
| 813 | 872 | struct cache_tree_sub *sub; | |
| 814 | 873 | struct tree *subtree = lookup_tree(r, &entry.oid); | |
| 815 | 874 | ||
| 816 | - | if (repo_parse_tree(the_repository, subtree) < 0) | |
| 875 | + | if (repo_parse_tree(r, subtree) < 0) | |
| 817 | 876 | exit(128); | |
| 818 | 877 | sub = cache_tree_sub(it, entry.path); | |
| 819 | 878 | sub->cache_tree = cache_tree(); | |
modified cache-tree.h
| @@ -28,10 +28,11 @@ struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *); | |||
| 28 | 28 | ||
| 29 | 29 | int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen); | |
| 30 | 30 | ||
| 31 | - | void cache_tree_write(struct strbuf *, struct cache_tree *root); | |
| 32 | - | struct cache_tree *cache_tree_read(const char *buffer, unsigned long size); | |
| 31 | + | void cache_tree_write(struct repository *repo, struct strbuf *, struct cache_tree *root); | |
| 32 | + | struct cache_tree *cache_tree_read(struct repository *repo, | |
| 33 | + | const char *buffer, unsigned long size); | |
| 33 | 34 | ||
| 34 | - | int cache_tree_fully_valid(struct cache_tree *); | |
| 35 | + | int cache_tree_fully_valid(struct index_state *); | |
| 35 | 36 | int cache_tree_update(struct index_state *, int); | |
| 36 | 37 | int cache_tree_verify(struct repository *, struct index_state *); | |
| 37 | 38 | ||
modified cbtree.c
| @@ -7,6 +7,11 @@ | |||
| 7 | 7 | #include "git-compat-util.h" | |
| 8 | 8 | #include "cbtree.h" | |
| 9 | 9 | ||
| 10 | + | static inline uint8_t *cb_node_key(struct cb_tree *t, struct cb_node *node) | |
| 11 | + | { | |
| 12 | + | return (uint8_t *) node + t->key_offset; | |
| 13 | + | } | |
| 14 | + | ||
| 10 | 15 | static struct cb_node *cb_node_of(const void *p) | |
| 11 | 16 | { | |
| 12 | 17 | return (struct cb_node *)((uintptr_t)p - 1); | |
| @@ -33,6 +38,7 @@ struct cb_node *cb_insert(struct cb_tree *t, struct cb_node *node, size_t klen) | |||
| 33 | 38 | uint8_t c; | |
| 34 | 39 | int newdirection; | |
| 35 | 40 | struct cb_node **wherep, *p; | |
| 41 | + | uint8_t *node_key, *p_key; | |
| 36 | 42 | ||
| 37 | 43 | assert(!((uintptr_t)node & 1)); /* allocations must be aligned */ | |
| 38 | 44 | ||
| @@ -41,23 +47,26 @@ struct cb_node *cb_insert(struct cb_tree *t, struct cb_node *node, size_t klen) | |||
| 41 | 47 | return NULL; /* success */ | |
| 42 | 48 | } | |
| 43 | 49 | ||
| 50 | + | node_key = cb_node_key(t, node); | |
| 51 | + | ||
| 44 | 52 | /* see if a node already exists */ | |
| 45 | - | p = cb_internal_best_match(t->root, node->k, klen); | |
| 53 | + | p = cb_internal_best_match(t->root, node_key, klen); | |
| 54 | + | p_key = cb_node_key(t, p); | |
| 46 | 55 | ||
| 47 | 56 | /* find first differing byte */ | |
| 48 | 57 | for (newbyte = 0; newbyte < klen; newbyte++) { | |
| 49 | - | if (p->k[newbyte] != node->k[newbyte]) | |
| 58 | + | if (p_key[newbyte] != node_key[newbyte]) | |
| 50 | 59 | goto different_byte_found; | |
| 51 | 60 | } | |
| 52 | 61 | return p; /* element exists, let user deal with it */ | |
| 53 | 62 | ||
| 54 | 63 | different_byte_found: | |
| 55 | - | newotherbits = p->k[newbyte] ^ node->k[newbyte]; | |
| 64 | + | newotherbits = p_key[newbyte] ^ node_key[newbyte]; | |
| 56 | 65 | newotherbits |= newotherbits >> 1; | |
| 57 | 66 | newotherbits |= newotherbits >> 2; | |
| 58 | 67 | newotherbits |= newotherbits >> 4; | |
| 59 | 68 | newotherbits = (newotherbits & ~(newotherbits >> 1)) ^ 255; | |
| 60 | - | c = p->k[newbyte]; | |
| 69 | + | c = p_key[newbyte]; | |
| 61 | 70 | newdirection = (1 + (newotherbits | c)) >> 8; | |
| 62 | 71 | ||
| 63 | 72 | node->byte = newbyte; | |
| @@ -78,7 +87,7 @@ different_byte_found: | |||
| 78 | 87 | break; | |
| 79 | 88 | if (q->byte == newbyte && q->otherbits > newotherbits) | |
| 80 | 89 | break; | |
| 81 | - | c = q->byte < klen ? node->k[q->byte] : 0; | |
| 90 | + | c = q->byte < klen ? node_key[q->byte] : 0; | |
| 82 | 91 | direction = (1 + (q->otherbits | c)) >> 8; | |
| 83 | 92 | wherep = q->child + direction; | |
| 84 | 93 | } | |
| @@ -93,7 +102,7 @@ struct cb_node *cb_lookup(struct cb_tree *t, const uint8_t *k, size_t klen) | |||
| 93 | 102 | { | |
| 94 | 103 | struct cb_node *p = cb_internal_best_match(t->root, k, klen); | |
| 95 | 104 | ||
| 96 | - | return p && !memcmp(p->k, k, klen) ? p : NULL; | |
| 105 | + | return p && !memcmp(cb_node_key(t, p), k, klen) ? p : NULL; | |
| 97 | 106 | } | |
| 98 | 107 | ||
| 99 | 108 | static int cb_descend(struct cb_node *p, cb_iter fn, void *arg) | |
| @@ -115,6 +124,7 @@ int cb_each(struct cb_tree *t, const uint8_t *kpfx, size_t klen, | |||
| 115 | 124 | struct cb_node *p = t->root; | |
| 116 | 125 | struct cb_node *top = p; | |
| 117 | 126 | size_t i = 0; | |
| 127 | + | uint8_t *p_key; | |
| 118 | 128 | ||
| 119 | 129 | if (!p) | |
| 120 | 130 | return 0; /* empty tree */ | |
| @@ -130,8 +140,9 @@ int cb_each(struct cb_tree *t, const uint8_t *kpfx, size_t klen, | |||
| 130 | 140 | top = p; | |
| 131 | 141 | } | |
| 132 | 142 | ||
| 143 | + | p_key = cb_node_key(t, p); | |
| 133 | 144 | for (i = 0; i < klen; i++) { | |
| 134 | - | if (p->k[i] != kpfx[i]) | |
| 145 | + | if (p_key[i] != kpfx[i]) | |
| 135 | 146 | return 0; /* "best" match failed */ | |
| 136 | 147 | } | |
| 137 | 148 | ||
modified cbtree.h
| @@ -6,9 +6,9 @@ | |||
| 6 | 6 | * | |
| 7 | 7 | * This is adapted to store arbitrary data (not just NUL-terminated C strings | |
| 8 | 8 | * and allocates no memory internally. The user needs to allocate | |
| 9 | - | * "struct cb_node" and fill cb_node.k[] with arbitrary match data | |
| 10 | - | * for memcmp. | |
| 11 | - | * If "klen" is variable, then it should be embedded into "c_node.k[]" | |
| 9 | + | * "struct cb_node" and provide `key_offset` to indicate where the key can be | |
| 10 | + | * found relative to the `struct cb_node` for memcmp. | |
| 11 | + | * If "klen" is variable, then it should be embedded into the key. | |
| 12 | 12 | * Recursion is bound by the maximum value of "klen" used. | |
| 13 | 13 | */ | |
| 14 | 14 | #ifndef CBTREE_H | |
| @@ -23,18 +23,19 @@ struct cb_node { | |||
| 23 | 23 | */ | |
| 24 | 24 | uint32_t byte; | |
| 25 | 25 | uint8_t otherbits; | |
| 26 | - | uint8_t k[FLEX_ARRAY]; /* arbitrary data, unaligned */ | |
| 27 | 26 | }; | |
| 28 | 27 | ||
| 29 | 28 | struct cb_tree { | |
| 30 | 29 | struct cb_node *root; | |
| 30 | + | ptrdiff_t key_offset; | |
| 31 | 31 | }; | |
| 32 | 32 | ||
| 33 | - | #define CBTREE_INIT { 0 } | |
| 34 | - | ||
| 35 | - | static inline void cb_init(struct cb_tree *t) | |
| 33 | + | static inline void cb_init(struct cb_tree *t, | |
| 34 | + | ptrdiff_t key_offset) | |
| 36 | 35 | { | |
| 37 | - | struct cb_tree blank = CBTREE_INIT; | |
| 36 | + | struct cb_tree blank = { | |
| 37 | + | .key_offset = key_offset, | |
| 38 | + | }; | |
| 38 | 39 | memcpy(t, &blank, sizeof(*t)); | |
| 39 | 40 | } | |
| 40 | 41 | ||
modified chdir-notify.c
| @@ -7,25 +7,22 @@ | |||
| 7 | 7 | #include "trace.h" | |
| 8 | 8 | ||
| 9 | 9 | struct chdir_notify_entry { | |
| 10 | - | const char *name; | |
| 11 | 10 | chdir_notify_callback cb; | |
| 12 | 11 | void *data; | |
| 13 | 12 | struct list_head list; | |
| 14 | 13 | }; | |
| 15 | 14 | static LIST_HEAD(chdir_notify_entries); | |
| 16 | 15 | ||
| 17 | - | void chdir_notify_register(const char *name, | |
| 18 | - | chdir_notify_callback cb, | |
| 16 | + | void chdir_notify_register(chdir_notify_callback cb, | |
| 19 | 17 | void *data) | |
| 20 | 18 | { | |
| 21 | 19 | struct chdir_notify_entry *e = xmalloc(sizeof(*e)); | |
| 22 | - | e->name = name; | |
| 23 | 20 | e->cb = cb; | |
| 24 | 21 | e->data = data; | |
| 25 | 22 | list_add_tail(&e->list, &chdir_notify_entries); | |
| 26 | 23 | } | |
| 27 | 24 | ||
| 28 | - | void chdir_notify_unregister(const char *name, chdir_notify_callback cb, | |
| 25 | + | void chdir_notify_unregister(chdir_notify_callback cb, | |
| 29 | 26 | void *data) | |
| 30 | 27 | { | |
| 31 | 28 | struct list_head *pos, *p; | |
| @@ -34,8 +31,7 @@ void chdir_notify_unregister(const char *name, chdir_notify_callback cb, | |||
| 34 | 31 | struct chdir_notify_entry *e = | |
| 35 | 32 | list_entry(pos, struct chdir_notify_entry, list); | |
| 36 | 33 | ||
| 37 | - | if (e->cb != cb || e->data != data || !e->name != !name || | |
| 38 | - | (e->name && strcmp(e->name, name))) | |
| 34 | + | if (e->cb != cb || e->data != data) | |
| 39 | 35 | continue; | |
| 40 | 36 | ||
| 41 | 37 | list_del(pos); | |
| @@ -43,32 +39,6 @@ void chdir_notify_unregister(const char *name, chdir_notify_callback cb, | |||
| 43 | 39 | } | |
| 44 | 40 | } | |
| 45 | 41 | ||
| 46 | - | static void reparent_cb(const char *name, | |
| 47 | - | const char *old_cwd, | |
| 48 | - | const char *new_cwd, | |
| 49 | - | void *data) | |
| 50 | - | { | |
| 51 | - | char **path = data; | |
| 52 | - | char *tmp = *path; | |
| 53 | - | ||
| 54 | - | if (!tmp) | |
| 55 | - | return; | |
| 56 | - | ||
| 57 | - | *path = reparent_relative_path(old_cwd, new_cwd, tmp); | |
| 58 | - | free(tmp); | |
| 59 | - | ||
| 60 | - | if (name) { | |
| 61 | - | trace_printf_key(&trace_setup_key, | |
| 62 | - | "setup: reparent %s to '%s'", | |
| 63 | - | name, *path); | |
| 64 | - | } | |
| 65 | - | } | |
| 66 | - | ||
| 67 | - | void chdir_notify_reparent(const char *name, char **path) | |
| 68 | - | { | |
| 69 | - | chdir_notify_register(name, reparent_cb, path); | |
| 70 | - | } | |
| 71 | - | ||
| 72 | 42 | int chdir_notify(const char *new_cwd) | |
| 73 | 43 | { | |
| 74 | 44 | struct strbuf old_cwd = STRBUF_INIT; | |
| @@ -90,7 +60,7 @@ int chdir_notify(const char *new_cwd) | |||
| 90 | 60 | list_for_each(pos, &chdir_notify_entries) { | |
| 91 | 61 | struct chdir_notify_entry *e = | |
| 92 | 62 | list_entry(pos, struct chdir_notify_entry, list); | |
| 93 | - | e->cb(e->name, old_cwd.buf, new_cwd, e->data); | |
| 63 | + | e->cb(old_cwd.buf, new_cwd, e->data); | |
| 94 | 64 | } | |
| 95 | 65 | ||
| 96 | 66 | strbuf_release(&old_cwd); | |
modified chdir-notify.h
| @@ -19,10 +19,7 @@ | |||
| 19 | 19 | * chdir_notify_register("description", foo, data); | |
| 20 | 20 | * | |
| 21 | 21 | * In practice most callers will want to move a relative path to the new root; | |
| 22 | - | * they can use the reparent_relative_path() helper for that. If that's all | |
| 23 | - | * you're doing, you can also use the convenience function: | |
| 24 | - | * | |
| 25 | - | * chdir_notify_reparent("description", &my_path); | |
| 22 | + | * they can use the reparent_relative_path() helper for that. | |
| 26 | 23 | * | |
| 27 | 24 | * Whenever a chdir event occurs, that will update my_path (if it's relative) | |
| 28 | 25 | * to adjust for the new cwd by freeing any existing string and allocating a | |
| @@ -36,14 +33,11 @@ | |||
| 36 | 33 | * $GIT_TRACE_SETUP. It may be NULL, but if non-NULL should point to | |
| 37 | 34 | * storage which lasts as long as the registration is active. | |
| 38 | 35 | */ | |
| 39 | - | typedef void (*chdir_notify_callback)(const char *name, | |
| 40 | - | const char *old_cwd, | |
| 36 | + | typedef void (*chdir_notify_callback)(const char *old_cwd, | |
| 41 | 37 | const char *new_cwd, | |
| 42 | 38 | void *data); | |
| 43 | - | void chdir_notify_register(const char *name, chdir_notify_callback cb, void *data); | |
| 44 | - | void chdir_notify_unregister(const char *name, chdir_notify_callback cb, | |
| 45 | - | void *data); | |
| 46 | - | void chdir_notify_reparent(const char *name, char **path); | |
| 39 | + | void chdir_notify_register(chdir_notify_callback cb, void *data); | |
| 40 | + | void chdir_notify_unregister(chdir_notify_callback cb, void *data); | |
| 47 | 41 | ||
| 48 | 42 | /* | |
| 49 | 43 | * | |
modified checkout.c
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | #include "checkout.h" | |
| 9 | 9 | #include "config.h" | |
| 10 | 10 | #include "strbuf.h" | |
| 11 | + | #include "string-list.h" | |
| 11 | 12 | ||
| 12 | 13 | struct tracking_name_data { | |
| 13 | 14 | /* const */ char *src_ref; | |
| @@ -17,6 +18,7 @@ struct tracking_name_data { | |||
| 17 | 18 | const char *default_remote; | |
| 18 | 19 | char *default_dst_ref; | |
| 19 | 20 | struct object_id *default_dst_oid; | |
| 21 | + | struct string_list *remote_names; | |
| 20 | 22 | }; | |
| 21 | 23 | ||
| 22 | 24 | #define TRACKING_NAME_DATA_INIT { 0 } | |
| @@ -39,6 +41,8 @@ static int check_tracking_name(struct remote *remote, void *cb_data) | |||
| 39 | 41 | oidcpy(dst, cb->dst_oid); | |
| 40 | 42 | cb->default_dst_oid = dst; | |
| 41 | 43 | } | |
| 44 | + | if (cb->remote_names) | |
| 45 | + | string_list_append(cb->remote_names, remote->name); | |
| 42 | 46 | if (cb->dst_ref) { | |
| 43 | 47 | free(query.dst); | |
| 44 | 48 | return 0; | |
| @@ -48,14 +52,19 @@ static int check_tracking_name(struct remote *remote, void *cb_data) | |||
| 48 | 52 | } | |
| 49 | 53 | ||
| 50 | 54 | char *unique_tracking_name(const char *name, struct object_id *oid, | |
| 51 | - | int *dwim_remotes_matched) | |
| 55 | + | int *dwim_remotes_matched, | |
| 56 | + | struct string_list *dwim_remote_names) | |
| 52 | 57 | { | |
| 53 | 58 | struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT; | |
| 54 | 59 | const char *default_remote = NULL; | |
| 55 | - | if (!repo_config_get_string_tmp(the_repository, "checkout.defaultremote", &default_remote)) | |
| 60 | + | ||
| 61 | + | if (!repo_config_get_string_tmp(the_repository, | |
| 62 | + | "checkout.defaultremote", | |
| 63 | + | &default_remote)) | |
| 56 | 64 | cb_data.default_remote = default_remote; | |
| 57 | 65 | cb_data.src_ref = xstrfmt("refs/heads/%s", name); | |
| 58 | 66 | cb_data.dst_oid = oid; | |
| 67 | + | cb_data.remote_names = dwim_remote_names; | |
| 59 | 68 | for_each_remote(check_tracking_name, &cb_data); | |
| 60 | 69 | if (dwim_remotes_matched) | |
| 61 | 70 | *dwim_remotes_matched = cb_data.num_matches; | |
modified checkout.h
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | 4 | #include "hash.h" | |
| 5 | 5 | ||
| 6 | + | struct string_list; | |
| 7 | + | ||
| 6 | 8 | /* | |
| 7 | 9 | * Check if the branch name uniquely matches a branch name on a remote | |
| 8 | 10 | * tracking branch. Return the name of the remote if such a branch | |
| @@ -10,6 +12,7 @@ | |||
| 10 | 12 | */ | |
| 11 | 13 | char *unique_tracking_name(const char *name, | |
| 12 | 14 | struct object_id *oid, | |
| 13 | - | int *dwim_remotes_matched); | |
| 15 | + | int *dwim_remotes_matched, | |
| 16 | + | struct string_list *dwim_remote_names); | |
| 14 | 17 | ||
| 15 | 18 | #endif /* CHECKOUT_H */ | |
added ci/install-dependencies.ps1 mode 100755
| @@ -0,0 +1,55 @@ | |||
| 1 | + | param( | |
| 2 | + | [string]$DownloadDirectory = '.dependencies' | |
| 3 | + | ) | |
| 4 | + | ||
| 5 | + | $ErrorActionPreference = 'Stop' | |
| 6 | + | $ProgressPreference = 'SilentlyContinue' | |
| 7 | + | ||
| 8 | + | $GitVersion = '2.54.0.windows.1' | |
| 9 | + | $MesonVersion = '1.11.0' | |
| 10 | + | $RustVersion = '1.96.0' | |
| 11 | + | ||
| 12 | + | New-Item -Path $DownloadDirectory -ItemType Directory -Force | Out-Null | |
| 13 | + | New-Item -Path .git/info -ItemType Directory -Force | Out-Null | |
| 14 | + | New-Item -Path .git/info/exclude -ItemType File -Force | Out-Null | |
| 15 | + | Add-Content -Path .git/info/exclude -Value "/$DownloadDirectory" | |
| 16 | + | ||
| 17 | + | function Get-Installer { | |
| 18 | + | param( | |
| 19 | + | [Parameter(Mandatory = $true)][string]$Name, | |
| 20 | + | [Parameter(Mandatory = $true)][string]$Url | |
| 21 | + | ) | |
| 22 | + | ||
| 23 | + | $path = Join-Path $DownloadDirectory $Name | |
| 24 | + | if (-not (Test-Path $path)) { | |
| 25 | + | Write-Host "Downloading $Url" | |
| 26 | + | Invoke-WebRequest $Url -OutFile $path -TimeoutSec 300 | |
| 27 | + | } | |
| 28 | + | return $path | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | function Invoke-Installer { | |
| 32 | + | param( | |
| 33 | + | [Parameter(Mandatory = $true)][string]$FilePath, | |
| 34 | + | [Parameter(Mandatory = $true)][string[]]$ArgumentList | |
| 35 | + | ) | |
| 36 | + | ||
| 37 | + | Write-Host "Running $FilePath $($ArgumentList -join ' ')" | |
| 38 | + | $process = Start-Process -Wait -PassThru -FilePath $FilePath -ArgumentList $ArgumentList | |
| 39 | + | if ($process.ExitCode -ne 0) { | |
| 40 | + | throw "$FilePath failed with exit code $($process.ExitCode)" | |
| 41 | + | } | |
| 42 | + | } | |
| 43 | + | ||
| 44 | + | $gitAssetVersion = $GitVersion -replace '\.windows\.\d+$', '' | |
| 45 | + | $gitInstaller = Get-Installer "Git-Installer.exe" ` | |
| 46 | + | "https://github.com/git-for-windows/git/releases/download/v$GitVersion/PortableGit-$gitAssetVersion-64-bit.7z.exe" | |
| 47 | + | Invoke-Installer $gitInstaller @('-y', '-o"C:\Program Files\Git"') | |
| 48 | + | ||
| 49 | + | $mesonMsi = Get-Installer "meson.msi" ` | |
| 50 | + | "https://github.com/mesonbuild/meson/releases/download/$MesonVersion/meson-$MesonVersion-64.msi" | |
| 51 | + | Invoke-Installer msiexec.exe @('/i', $mesonMsi, 'INSTALLDIR=C:\Meson', '/quiet', '/norestart') | |
| 52 | + | ||
| 53 | + | $rustMsi = Get-Installer "rust.msi" ` | |
| 54 | + | "https://static.rust-lang.org/dist/rust-$RustVersion-x86_64-pc-windows-msvc.msi" | |
| 55 | + | Invoke-Installer msiexec.exe @('/i', $rustMsi, 'INSTALLDIR=C:\Rust', 'ADDLOCAL=Rustc,Cargo,Std', '/quiet', '/norestart') | |
modified ci/install-dependencies.sh
| @@ -29,7 +29,7 @@ alpine-*) | |||
| 29 | 29 | apk add --update shadow sudo meson ninja-build gcc libc-dev curl-dev openssl-dev expat-dev gettext \ | |
| 30 | 30 | zlib-ng-dev pcre2-dev python3 musl-libintl perl-utils ncurses \ | |
| 31 | 31 | apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \ | |
| 32 | - | bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null | |
| 32 | + | bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty cargo >/dev/null | |
| 33 | 33 | ;; | |
| 34 | 34 | fedora-*|almalinux-*) | |
| 35 | 35 | case "$jobname" in | |
| @@ -164,10 +164,9 @@ sparse) | |||
| 164 | 164 | libexpat-dev gettext zlib1g-dev sparse | |
| 165 | 165 | ;; | |
| 166 | 166 | Documentation) | |
| 167 | - | sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make | |
| 167 | + | sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make ruby \ | |
| 168 | + | asciidoctor | |
| 168 | 169 | ||
| 169 | - | test -n "$ALREADY_HAVE_ASCIIDOCTOR" || | |
| 170 | - | sudo gem install --version 1.5.8 asciidoctor | |
| 171 | 170 | sudo gem install concurrent-ruby | |
| 172 | 171 | ;; | |
| 173 | 172 | esac | |
modified ci/lib.sh
| @@ -215,6 +215,7 @@ then | |||
| 215 | 215 | test macos != "$CI_OS_NAME" || CI_OS_NAME=osx | |
| 216 | 216 | CI_REPO_SLUG="$GITHUB_REPOSITORY" | |
| 217 | 217 | CI_JOB_ID="$GITHUB_RUN_ID" | |
| 218 | + | CI_EVENT="$GITHUB_EVENT_NAME" | |
| 218 | 219 | CC="${CC_PACKAGE:-${CC:-gcc}}" | |
| 219 | 220 | DONT_SKIP_TAGS=t | |
| 220 | 221 | handle_failed_tests () { | |
| @@ -239,6 +240,13 @@ then | |||
| 239 | 240 | CI_BRANCH="$CI_COMMIT_REF_NAME" | |
| 240 | 241 | CI_COMMIT="$CI_COMMIT_SHA" | |
| 241 | 242 | ||
| 243 | + | case "$CI_PIPELINE_SOURCE" in | |
| 244 | + | merge_request_event) | |
| 245 | + | CI_EVENT=pull_request;; | |
| 246 | + | *) | |
| 247 | + | CI_EVENT="$CI_PIPELINE_SOURCE";; | |
| 248 | + | esac | |
| 249 | + | ||
| 242 | 250 | case "$OS,$CI_JOB_IMAGE" in | |
| 243 | 251 | Windows_NT,*) | |
| 244 | 252 | CI_OS_NAME=windows | |
| @@ -254,7 +262,7 @@ then | |||
| 254 | 262 | CI_OS_NAME=osx | |
| 255 | 263 | JOBS=$(nproc) | |
| 256 | 264 | ;; | |
| 257 | - | *,alpine:*|*,fedora:*|*,ubuntu:*|*,i386/ubuntu:*) | |
| 265 | + | *,almalinux:*|*,alpine:*|*,debian:*|*,fedora:*|*,ubuntu:*|*,i386/ubuntu:*) | |
| 258 | 266 | CI_OS_NAME=linux | |
| 259 | 267 | JOBS=$(nproc) | |
| 260 | 268 | ;; | |
| @@ -314,6 +322,17 @@ export DEFAULT_TEST_TARGET=prove | |||
| 314 | 322 | export GIT_TEST_CLONE_2GB=true | |
| 315 | 323 | export SKIP_DASHED_BUILT_INS=YesPlease | |
| 316 | 324 | ||
| 325 | + | # In order to give maximum test coverage to contributor builds, | |
| 326 | + | # preferrably even before the changes consume public review bandwidth, | |
| 327 | + | # enable "expensive" tests for PR events. | |
| 328 | + | # In order to catch bugs introduced at integration time by mismerges, | |
| 329 | + | # enable the long tests for pushes to the integration branches as well. | |
| 330 | + | case "$CI_EVENT,$CI_BRANCH" in | |
| 331 | + | pull_request,*|push,*next*|push,*master*|push,*main*|push,*maint*) | |
| 332 | + | export GIT_TEST_LONG=${GIT_TEST_LONG:-true} | |
| 333 | + | ;; | |
| 334 | + | esac | |
| 335 | + | ||
| 317 | 336 | case "$distro" in | |
| 318 | 337 | ubuntu-*) | |
| 319 | 338 | # Python 2 is end of life, and Ubuntu 23.04 and newer don't actually | |
modified ci/run-build-and-minimal-fuzzers.sh
| @@ -21,6 +21,7 @@ date | |||
| 21 | 21 | pack-headers | |
| 22 | 22 | pack-idx | |
| 23 | 23 | parse-attr-line | |
| 24 | + | reftable | |
| 24 | 25 | url-decode-mem | |
| 25 | 26 | " | |
| 26 | 27 | ||
modified ci/run-build-and-tests.sh
| @@ -7,12 +7,20 @@ | |||
| 7 | 7 | ||
| 8 | 8 | export TEST_CONTRIB_TOO=yes | |
| 9 | 9 | ||
| 10 | + | case "$jobname" in | |
| 11 | + | linux-musl-meson) | |
| 12 | + | MESONFLAGS="$MESONFLAGS -Drust=disabled" | |
| 13 | + | export GIT_TEST_USE_SET_E=yes | |
| 14 | + | ;; | |
| 15 | + | almalinux-*|debian-*|fedora-*|linux-*) | |
| 16 | + | export GIT_TEST_USE_SET_E=yes | |
| 17 | + | ;; | |
| 18 | + | esac | |
| 19 | + | ||
| 10 | 20 | case "$jobname" in | |
| 11 | 21 | fedora-breaking-changes-musl|linux-breaking-changes) | |
| 12 | 22 | export WITH_BREAKING_CHANGES=YesPlease | |
| 13 | - | export WITH_RUST=YesPlease | |
| 14 | 23 | MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true" | |
| 15 | - | MESONFLAGS="$MESONFLAGS -Drust=enabled" | |
| 16 | 24 | ;; | |
| 17 | 25 | linux-TEST-vars) | |
| 18 | 26 | export OPENSSL_SHA1_UNSAFE=YesPlease | |
| @@ -30,6 +38,7 @@ linux-TEST-vars) | |||
| 30 | 38 | export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 | |
| 31 | 39 | ;; | |
| 32 | 40 | linux-clang) | |
| 41 | + | export NO_RUST=UnfortunatelyYes | |
| 33 | 42 | export GIT_TEST_DEFAULT_HASH=sha1 | |
| 34 | 43 | ;; | |
| 35 | 44 | linux-sha256) | |
modified combine-diff.c
| @@ -325,7 +325,9 @@ static char *grab_blob(struct repository *r, | |||
| 325 | 325 | *size = fill_textconv(r, textconv, df, &blob); | |
| 326 | 326 | free_filespec(df); | |
| 327 | 327 | } else { | |
| 328 | - | blob = odb_read_object(r->objects, oid, &type, size); | |
| 328 | + | size_t size_st = 0; | |
| 329 | + | blob = odb_read_object(r->objects, oid, &type, &size_st); | |
| 330 | + | *size = cast_size_t_to_ulong(size_st); | |
| 329 | 331 | if (!blob) | |
| 330 | 332 | die(_("unable to read %s"), oid_to_hex(oid)); | |
| 331 | 333 | if (type != OBJ_BLOB) | |
| @@ -666,7 +668,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt, | |||
| 666 | 668 | * (-) line, which records from what parents the line | |
| 667 | 669 | * was removed; this line does not appear in the result. | |
| 668 | 670 | * then check the set of parents the result has difference | |
| 669 | - | * from, from all lines. If there are lines that has | |
| 671 | + | * from, from all lines. If there are lines that have | |
| 670 | 672 | * different set of parents that the result has differences | |
| 671 | 673 | * from, that means we have more than two versions. | |
| 672 | 674 | * | |
| @@ -1078,7 +1080,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, | |||
| 1078 | 1080 | /* if symlinks don't work, assume symlink if all parents | |
| 1079 | 1081 | * are symlinks | |
| 1080 | 1082 | */ | |
| 1081 | - | is_file = has_symlinks; | |
| 1083 | + | is_file = repo_has_symlinks(rev->repo); | |
| 1082 | 1084 | for (i = 0; !is_file && i < num_parent; i++) | |
| 1083 | 1085 | is_file = !S_ISLNK(elem->parent[i].mode); | |
| 1084 | 1086 | if (!is_file) | |
modified command-list.txt
| @@ -108,6 +108,7 @@ git-fmt-merge-msg purehelpers | |||
| 108 | 108 | git-for-each-ref plumbinginterrogators | |
| 109 | 109 | git-for-each-repo plumbinginterrogators | |
| 110 | 110 | git-format-patch mainporcelain | |
| 111 | + | git-format-rev plumbinginterrogators | |
| 111 | 112 | git-fsck ancillaryinterrogators complete | |
| 112 | 113 | git-gc mainporcelain | |
| 113 | 114 | git-get-tar-commit-id plumbinginterrogators | |
| @@ -202,6 +203,7 @@ git-update-ref plumbingmanipulators | |||
| 202 | 203 | git-update-server-info synchingrepositories | |
| 203 | 204 | git-upload-archive synchelpers | |
| 204 | 205 | git-upload-pack synchelpers | |
| 206 | + | git-url-parse purehelpers | |
| 205 | 207 | git-var plumbinginterrogators | |
| 206 | 208 | git-verify-commit ancillaryinterrogators | |
| 207 | 209 | git-verify-pack plumbinginterrogators | |
| @@ -215,6 +217,7 @@ gitcli userinterfaces | |||
| 215 | 217 | gitcore-tutorial guide | |
| 216 | 218 | gitcredentials guide | |
| 217 | 219 | gitcvs-migration guide | |
| 220 | + | gitdatamodel guide | |
| 218 | 221 | gitdiffcore guide | |
| 219 | 222 | giteveryday guide | |
| 220 | 223 | gitfaq guide | |
modified commit-graph.c
| @@ -651,8 +651,6 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb, | |||
| 651 | 651 | count = st->st_size / (odb->repo->hash_algo->hexsz + 1); | |
| 652 | 652 | CALLOC_ARRAY(oids, count); | |
| 653 | 653 | ||
| 654 | - | odb_prepare_alternates(odb); | |
| 655 | - | ||
| 656 | 654 | for (i = 0; i < count; i++) { | |
| 657 | 655 | struct odb_source *source; | |
| 658 | 656 | ||
| @@ -740,13 +738,13 @@ static struct commit_graph *prepare_commit_graph(struct repository *r) | |||
| 740 | 738 | struct odb_source *source; | |
| 741 | 739 | ||
| 742 | 740 | /* | |
| 743 | - | * Early return if there is no git dir or if the commit graph is | |
| 741 | + | * Early return if there is no object database or if the commit graph is | |
| 744 | 742 | * disabled. | |
| 745 | 743 | * | |
| 746 | 744 | * This must come before the "already attempted?" check below, because | |
| 747 | 745 | * we want to disable even an already-loaded graph file. | |
| 748 | 746 | */ | |
| 749 | - | if (!r->gitdir || r->commit_graph_disabled) | |
| 747 | + | if (!r->objects || r->commit_graph_disabled) | |
| 750 | 748 | return NULL; | |
| 751 | 749 | ||
| 752 | 750 | if (r->objects->commit_graph_attempted) | |
| @@ -768,7 +766,6 @@ static struct commit_graph *prepare_commit_graph(struct repository *r) | |||
| 768 | 766 | if (!commit_graph_compatible(r)) | |
| 769 | 767 | return NULL; | |
| 770 | 768 | ||
| 771 | - | odb_prepare_alternates(r->objects); | |
| 772 | 769 | for (source = r->objects->sources; source; source = source->next) { | |
| 773 | 770 | r->objects->commit_graph = read_commit_graph_one(source); | |
| 774 | 771 | if (r->objects->commit_graph) | |
| @@ -1538,7 +1535,7 @@ static int add_packed_commits(const struct object_id *oid, | |||
| 1538 | 1535 | struct object_info oi = OBJECT_INFO_INIT; | |
| 1539 | 1536 | ||
| 1540 | 1537 | oi.typep = &type; | |
| 1541 | - | if (packed_object_info(pack, offset, &oi) < 0) | |
| 1538 | + | if (packed_object_info(NULL, pack, offset, &oi) < 0) | |
| 1542 | 1539 | die(_("unable to get type of object %s"), oid_to_hex(oid)); | |
| 1543 | 1540 | ||
| 1544 | 1541 | return add_packed_commits_oi(oid, &oi, data); | |
| @@ -1653,6 +1650,7 @@ static void compute_reachable_generation_numbers( | |||
| 1653 | 1650 | { | |
| 1654 | 1651 | int i; | |
| 1655 | 1652 | struct commit_list *list = NULL; | |
| 1653 | + | intmax_t steps = 0; | |
| 1656 | 1654 | ||
| 1657 | 1655 | for (i = 0; i < info->commits->nr; i++) { | |
| 1658 | 1656 | struct commit *c = info->commits->items[i]; | |
| @@ -1669,8 +1667,9 @@ static void compute_reachable_generation_numbers( | |||
| 1669 | 1667 | struct commit *current = list->item; | |
| 1670 | 1668 | struct commit_list *parent; | |
| 1671 | 1669 | int all_parents_computed = 1; | |
| 1672 | - | uint32_t max_gen = 0; | |
| 1670 | + | timestamp_t max_gen = 0; | |
| 1673 | 1671 | ||
| 1672 | + | steps++; | |
| 1674 | 1673 | for (parent = current->parents; parent; parent = parent->next) { | |
| 1675 | 1674 | repo_parse_commit(info->r, parent->item); | |
| 1676 | 1675 | gen = info->get_generation(parent->item, info->data); | |
| @@ -1694,6 +1693,9 @@ static void compute_reachable_generation_numbers( | |||
| 1694 | 1693 | } | |
| 1695 | 1694 | } | |
| 1696 | 1695 | } | |
| 1696 | + | ||
| 1697 | + | trace2_data_intmax("commit-graph", info->r, | |
| 1698 | + | "generation-dfs-steps", steps); | |
| 1697 | 1699 | } | |
| 1698 | 1700 | ||
| 1699 | 1701 | static timestamp_t get_topo_level(struct commit *c, void *data) | |
| @@ -2013,11 +2015,10 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx) | |||
| 2013 | 2015 | _("Finding commits for commit graph among packed objects"), | |
| 2014 | 2016 | ctx->approx_nr_objects); | |
| 2015 | 2017 | ||
| 2016 | - | odb_prepare_alternates(ctx->r->objects); | |
| 2017 | 2018 | for (source = ctx->r->objects->sources; source; source = source->next) { | |
| 2018 | 2019 | struct odb_source_files *files = odb_source_files_downcast(source); | |
| 2019 | - | packfile_store_for_each_object(files->packed, &oi, add_packed_commits_oi, | |
| 2020 | - | ctx, &opts); | |
| 2020 | + | odb_source_for_each_object(&files->packed->base, &oi, add_packed_commits_oi, | |
| 2021 | + | ctx, &opts); | |
| 2021 | 2022 | } | |
| 2022 | 2023 | ||
| 2023 | 2024 | if (ctx->progress_done < ctx->approx_nr_objects) | |
| @@ -2122,8 +2123,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) | |||
| 2122 | 2123 | if (ctx->split) { | |
| 2123 | 2124 | char *lock_name = get_commit_graph_chain_filename(ctx->odb_source); | |
| 2124 | 2125 | ||
| 2125 | - | hold_lock_file_for_update_mode(&lk, lock_name, | |
| 2126 | - | LOCK_DIE_ON_ERROR, 0444); | |
| 2126 | + | repo_hold_lock_file_for_update_mode(ctx->r, &lk, lock_name, | |
| 2127 | + | LOCK_DIE_ON_ERROR, 0444); | |
| 2127 | 2128 | free(lock_name); | |
| 2128 | 2129 | ||
| 2129 | 2130 | graph_layer = mks_tempfile_m(ctx->graph_name, 0444); | |
| @@ -2141,8 +2142,9 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) | |||
| 2141 | 2142 | f = hashfd(ctx->r->hash_algo, | |
| 2142 | 2143 | get_tempfile_fd(graph_layer), get_tempfile_path(graph_layer)); | |
| 2143 | 2144 | } else { | |
| 2144 | - | hold_lock_file_for_update_mode(&lk, ctx->graph_name, | |
| 2145 | - | LOCK_DIE_ON_ERROR, 0444); | |
| 2145 | + | repo_hold_lock_file_for_update_mode(ctx->r, &lk, | |
| 2146 | + | ctx->graph_name, | |
| 2147 | + | LOCK_DIE_ON_ERROR, 0444); | |
| 2146 | 2148 | f = hashfd(ctx->r->hash_algo, | |
| 2147 | 2149 | get_lock_file_fd(&lk), get_lock_file_path(&lk)); | |
| 2148 | 2150 | } | |
| @@ -2605,7 +2607,7 @@ int write_commit_graph(struct odb_source *source, | |||
| 2605 | 2607 | ||
| 2606 | 2608 | g = prepare_commit_graph(ctx.r); | |
| 2607 | 2609 | for (struct commit_graph *chain = g; chain; chain = chain->base_graph) | |
| 2608 | - | g->topo_levels = &topo_levels; | |
| 2610 | + | chain->topo_levels = &topo_levels; | |
| 2609 | 2611 | ||
| 2610 | 2612 | if (flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS) | |
| 2611 | 2613 | ctx.changed_paths = 1; | |
modified commit-graph.h
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | * This method is only used to enhance coverage of the commit-graph | |
| 19 | 19 | * feature in the test suite with the GIT_TEST_COMMIT_GRAPH and | |
| 20 | 20 | * GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS environment variables. Do not | |
| 21 | - | * call this method oustide of a builtin, and only if you know what | |
| 21 | + | * call this method outside of a builtin, and only if you know what | |
| 22 | 22 | * you are doing! | |
| 23 | 23 | */ | |
| 24 | 24 | void git_test_write_commit_graph_or_die(struct odb_source *source); | |
modified commit-reach.c
| @@ -11,14 +11,16 @@ | |||
| 11 | 11 | #include "tag.h" | |
| 12 | 12 | #include "commit-reach.h" | |
| 13 | 13 | #include "ewah/ewok.h" | |
| 14 | + | #include "trace2.h" | |
| 14 | 15 | ||
| 15 | 16 | /* Remember to update object flag allocation in object.h */ | |
| 16 | 17 | #define PARENT1 (1u<<16) | |
| 17 | 18 | #define PARENT2 (1u<<17) | |
| 18 | 19 | #define STALE (1u<<18) | |
| 19 | 20 | #define RESULT (1u<<19) | |
| 21 | + | #define ENQUEUED (1u<<20) | |
| 20 | 22 | ||
| 21 | - | static const unsigned all_flags = (PARENT1 | PARENT2 | STALE | RESULT); | |
| 23 | + | static const unsigned all_flags = (PARENT1 | PARENT2 | STALE | RESULT | ENQUEUED); | |
| 22 | 24 | ||
| 23 | 25 | static int compare_commits_by_gen(const void *_a, const void *_b) | |
| 24 | 26 | { | |
| @@ -39,64 +41,204 @@ static int compare_commits_by_gen(const void *_a, const void *_b) | |||
| 39 | 41 | return 0; | |
| 40 | 42 | } | |
| 41 | 43 | ||
| 42 | - | static int queue_has_nonstale(struct prio_queue *queue) | |
| 44 | + | /* | |
| 45 | + | * A prio_queue with O(1) termination check. 'max_nonstale' tracks | |
| 46 | + | * the lowest-priority non-stale commit enqueued so far; once it is | |
| 47 | + | * popped, every remaining entry is known to be STALE. | |
| 48 | + | */ | |
| 49 | + | struct nonstale_queue { | |
| 50 | + | struct prio_queue pq; | |
| 51 | + | struct commit *max_nonstale; | |
| 52 | + | }; | |
| 53 | + | ||
| 54 | + | static void nonstale_queue_put(struct nonstale_queue *queue, | |
| 55 | + | struct commit *c) | |
| 43 | 56 | { | |
| 44 | - | for (size_t i = 0; i < queue->nr; i++) { | |
| 45 | - | struct commit *commit = queue->array[i].data; | |
| 46 | - | if (!(commit->object.flags & STALE)) | |
| 47 | - | return 1; | |
| 57 | + | struct commit *old = queue->max_nonstale; | |
| 58 | + | ||
| 59 | + | prio_queue_put(&queue->pq, c); | |
| 60 | + | if (c->object.flags & STALE) | |
| 61 | + | return; | |
| 62 | + | if (!old || queue->pq.compare(old, c, queue->pq.cb_data) <= 0) | |
| 63 | + | queue->max_nonstale = c; | |
| 64 | + | } | |
| 65 | + | ||
| 66 | + | static struct commit *nonstale_queue_get(struct nonstale_queue *queue) | |
| 67 | + | { | |
| 68 | + | struct commit *commit = prio_queue_get(&queue->pq); | |
| 69 | + | ||
| 70 | + | if (commit == queue->max_nonstale) | |
| 71 | + | queue->max_nonstale = NULL; | |
| 72 | + | ||
| 73 | + | return commit; | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | static void clear_nonstale_queue(struct nonstale_queue *queue) | |
| 77 | + | { | |
| 78 | + | clear_prio_queue(&queue->pq); | |
| 79 | + | queue->max_nonstale = NULL; | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | /* | |
| 83 | + | * Priority queue with per-side commit counters for paint_down_to_common(). | |
| 84 | + | * Each non-stale queued commit occupies exactly one bucket: PARENT1-only, | |
| 85 | + | * PARENT2-only, or both (a pending merge-base candidate). | |
| 86 | + | */ | |
| 87 | + | struct paint_state { | |
| 88 | + | struct prio_queue queue; | |
| 89 | + | size_t parent1_count; | |
| 90 | + | size_t parent2_count; | |
| 91 | + | size_t mb_candidate_count; | |
| 92 | + | timestamp_t min_generation; | |
| 93 | + | timestamp_t last_gen; | |
| 94 | + | timestamp_t topo_ceiling; | |
| 95 | + | }; | |
| 96 | + | ||
| 97 | + | static void paint_count_update(struct paint_state *state, | |
| 98 | + | unsigned flags, int delta) | |
| 99 | + | { | |
| 100 | + | switch (flags & (PARENT1 | PARENT2 | STALE)) { | |
| 101 | + | case PARENT1: | |
| 102 | + | state->parent1_count += delta; | |
| 103 | + | break; | |
| 104 | + | ||
| 105 | + | case PARENT2: | |
| 106 | + | state->parent2_count += delta; | |
| 107 | + | break; | |
| 108 | + | ||
| 109 | + | case PARENT1 | PARENT2: | |
| 110 | + | state->mb_candidate_count += delta; | |
| 111 | + | break; | |
| 112 | + | ||
| 113 | + | case PARENT1 | PARENT2 | STALE: | |
| 114 | + | break; | |
| 115 | + | ||
| 116 | + | default: | |
| 117 | + | BUG("unexpected paint state"); | |
| 118 | + | } | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | static void paint_queue_put(struct paint_state *state, | |
| 122 | + | struct commit *c, unsigned add_flags) | |
| 123 | + | { | |
| 124 | + | unsigned old_flags = c->object.flags; | |
| 125 | + | c->object.flags |= add_flags; | |
| 126 | + | ||
| 127 | + | if (old_flags & ENQUEUED) { | |
| 128 | + | paint_count_update(state, old_flags, -1); | |
| 129 | + | paint_count_update(state, c->object.flags, 1); | |
| 130 | + | } else { | |
| 131 | + | c->object.flags |= ENQUEUED; | |
| 132 | + | prio_queue_put(&state->queue, c); | |
| 133 | + | paint_count_update(state, c->object.flags, 1); | |
| 48 | 134 | } | |
| 49 | - | return 0; | |
| 50 | 135 | } | |
| 51 | 136 | ||
| 52 | - | /* all input commits in one and twos[] must have been parsed! */ | |
| 137 | + | /* | |
| 138 | + | * Dequeue the next commit for the paint walk, or return NULL when | |
| 139 | + | * no more merge bases can be discovered. | |
| 140 | + | */ | |
| 141 | + | static struct commit *paint_queue_get(struct paint_state *state) | |
| 142 | + | { | |
| 143 | + | struct commit *commit = prio_queue_get(&state->queue); | |
| 144 | + | timestamp_t generation; | |
| 145 | + | ||
| 146 | + | if (!commit) | |
| 147 | + | return NULL; | |
| 148 | + | ||
| 149 | + | commit->object.flags &= ~ENQUEUED; | |
| 150 | + | generation = commit_graph_generation(commit); | |
| 151 | + | ||
| 152 | + | if (state->min_generation && generation > state->last_gen) | |
| 153 | + | BUG("bad generation skip %"PRItime" > %"PRItime" at %s", | |
| 154 | + | generation, state->last_gen, | |
| 155 | + | oid_to_hex(&commit->object.oid)); | |
| 156 | + | state->last_gen = generation; | |
| 157 | + | ||
| 158 | + | /* generation cutoff */ | |
| 159 | + | if (generation < state->min_generation) | |
| 160 | + | return NULL; | |
| 161 | + | ||
| 162 | + | /* | |
| 163 | + | * Check exit condition before decrementing: the counters | |
| 164 | + | * still include this commit, so the last non-stale commit | |
| 165 | + | * sees a non-zero count and is returned for processing. | |
| 166 | + | */ | |
| 167 | + | if (!state->mb_candidate_count) { | |
| 168 | + | /* only stale entries remain */ | |
| 169 | + | if (!state->parent1_count && !state->parent2_count) | |
| 170 | + | return NULL; | |
| 171 | + | ||
| 172 | + | /* one side is exhausted */ | |
| 173 | + | if ((!state->parent1_count || !state->parent2_count) && | |
| 174 | + | generation < state->topo_ceiling) | |
| 175 | + | return NULL; | |
| 176 | + | } | |
| 177 | + | ||
| 178 | + | paint_count_update(state, commit->object.flags, -1); | |
| 179 | + | return commit; | |
| 180 | + | } | |
| 181 | + | ||
| 182 | + | /* | |
| 183 | + | * See Documentation/technical/paint-down-to-common.adoc | |
| 184 | + | * | |
| 185 | + | * All input commits in one and twos[] must have been parsed! | |
| 186 | + | */ | |
| 53 | 187 | static int paint_down_to_common(struct repository *r, | |
| 54 | 188 | struct commit *one, int n, | |
| 55 | 189 | struct commit **twos, | |
| 56 | 190 | timestamp_t min_generation, | |
| 57 | - | int ignore_missing_commits, | |
| 191 | + | enum merge_base_flags mb_flags, | |
| 58 | 192 | struct commit_list **result) | |
| 59 | 193 | { | |
| 60 | - | struct prio_queue queue = { compare_commits_by_gen_then_commit_date }; | |
| 194 | + | /* | |
| 195 | + | * Generation ordering is required for the side-exhaustion and | |
| 196 | + | * single-result early exits, which rely on topological traversal | |
| 197 | + | * order (children visited before parents) in the ordered region. | |
| 198 | + | */ | |
| 199 | + | struct paint_state state = { | |
| 200 | + | .queue = { compare_commits_by_gen_then_commit_date } | |
| 201 | + | }; | |
| 202 | + | struct commit *commit; | |
| 61 | 203 | int i; | |
| 62 | - | timestamp_t last_gen = GENERATION_NUMBER_INFINITY; | |
| 204 | + | int steps = 0; | |
| 63 | 205 | struct commit_list **tail = result; | |
| 64 | 206 | ||
| 65 | - | if (!min_generation && !corrected_commit_dates_enabled(r)) | |
| 66 | - | queue.compare = compare_commits_by_commit_date; | |
| 207 | + | state.min_generation = min_generation; | |
| 208 | + | state.last_gen = GENERATION_NUMBER_INFINITY; | |
| 209 | + | state.topo_ceiling = corrected_commit_dates_enabled(r) | |
| 210 | + | ? GENERATION_NUMBER_INFINITY | |
| 211 | + | : GENERATION_NUMBER_V1_MAX; | |
| 212 | + | ||
| 67 | 213 | ||
| 68 | 214 | one->object.flags |= PARENT1; | |
| 69 | 215 | if (!n) { | |
| 70 | 216 | commit_list_append(one, result); | |
| 71 | 217 | return 0; | |
| 72 | 218 | } | |
| 73 | - | prio_queue_put(&queue, one); | |
| 219 | + | paint_queue_put(&state, one, 0); | |
| 74 | 220 | ||
| 75 | - | for (i = 0; i < n; i++) { | |
| 76 | - | twos[i]->object.flags |= PARENT2; | |
| 77 | - | prio_queue_put(&queue, twos[i]); | |
| 78 | - | } | |
| 221 | + | for (i = 0; i < n; i++) | |
| 222 | + | paint_queue_put(&state, twos[i], PARENT2); | |
| 79 | 223 | ||
| 80 | - | while (queue_has_nonstale(&queue)) { | |
| 81 | - | struct commit *commit = prio_queue_get(&queue); | |
| 224 | + | while ((commit = paint_queue_get(&state))) { | |
| 82 | 225 | struct commit_list *parents; | |
| 83 | 226 | int flags; | |
| 84 | - | timestamp_t generation = commit_graph_generation(commit); | |
| 85 | - | ||
| 86 | - | if (min_generation && generation > last_gen) | |
| 87 | - | BUG("bad generation skip %"PRItime" > %"PRItime" at %s", | |
| 88 | - | generation, last_gen, | |
| 89 | - | oid_to_hex(&commit->object.oid)); | |
| 90 | - | last_gen = generation; | |
| 91 | - | ||
| 92 | - | if (generation < min_generation) | |
| 93 | - | break; | |
| 227 | + | steps++; | |
| 94 | 228 | ||
| 95 | 229 | flags = commit->object.flags & (PARENT1 | PARENT2 | STALE); | |
| 96 | 230 | if (flags == (PARENT1 | PARENT2)) { | |
| 97 | 231 | if (!(commit->object.flags & RESULT)) { | |
| 98 | 232 | commit->object.flags |= RESULT; | |
| 99 | 233 | tail = commit_list_append(commit, tail); | |
| 234 | + | /* | |
| 235 | + | * When the queue is generation-ordered, | |
| 236 | + | * no remaining common ancestor can be a | |
| 237 | + | * descendant of this one. | |
| 238 | + | */ | |
| 239 | + | if (!(mb_flags & MERGE_BASE_FIND_ALL) && | |
| 240 | + | state.last_gen < state.topo_ceiling) | |
| 241 | + | break; | |
| 100 | 242 | } | |
| 101 | 243 | /* Mark parents of a found merge stale */ | |
| 102 | 244 | flags |= STALE; | |
| @@ -108,7 +250,7 @@ static int paint_down_to_common(struct repository *r, | |||
| 108 | 250 | if ((p->object.flags & flags) == flags) | |
| 109 | 251 | continue; | |
| 110 | 252 | if (repo_parse_commit(r, p)) { | |
| 111 | - | clear_prio_queue(&queue); | |
| 253 | + | clear_prio_queue(&state.queue); | |
| 112 | 254 | commit_list_free(*result); | |
| 113 | 255 | *result = NULL; | |
| 114 | 256 | /* | |
| @@ -118,17 +260,18 @@ static int paint_down_to_common(struct repository *r, | |||
| 118 | 260 | * corrupt commits would already have been | |
| 119 | 261 | * dispatched with a `die()`. | |
| 120 | 262 | */ | |
| 121 | - | if (ignore_missing_commits) | |
| 263 | + | if (mb_flags & MERGE_BASE_IGNORE_MISSING_COMMITS) | |
| 122 | 264 | return 0; | |
| 123 | 265 | return error(_("could not parse commit %s"), | |
| 124 | 266 | oid_to_hex(&p->object.oid)); | |
| 125 | 267 | } | |
| 126 | - | p->object.flags |= flags; | |
| 127 | - | prio_queue_put(&queue, p); | |
| 268 | + | paint_queue_put(&state, p, flags); | |
| 128 | 269 | } | |
| 129 | 270 | } | |
| 130 | 271 | ||
| 131 | - | clear_prio_queue(&queue); | |
| 272 | + | clear_prio_queue(&state.queue); | |
| 273 | + | trace2_data_intmax("paint_down_to_common", r, | |
| 274 | + | "steps", steps); | |
| 132 | 275 | commit_list_sort_by_date(result); | |
| 133 | 276 | return 0; | |
| 134 | 277 | } | |
| @@ -136,6 +279,7 @@ static int paint_down_to_common(struct repository *r, | |||
| 136 | 279 | static int merge_bases_many(struct repository *r, | |
| 137 | 280 | struct commit *one, int n, | |
| 138 | 281 | struct commit **twos, | |
| 282 | + | enum merge_base_flags mb_flags, | |
| 139 | 283 | struct commit_list **result) | |
| 140 | 284 | { | |
| 141 | 285 | struct commit_list *list = NULL, **tail = result; | |
| @@ -165,7 +309,7 @@ static int merge_bases_many(struct repository *r, | |||
| 165 | 309 | oid_to_hex(&twos[i]->object.oid)); | |
| 166 | 310 | } | |
| 167 | 311 | ||
| 168 | - | if (paint_down_to_common(r, one, n, twos, 0, 0, &list)) { | |
| 312 | + | if (paint_down_to_common(r, one, n, twos, 0, mb_flags, &list)) { | |
| 169 | 313 | commit_list_free(list); | |
| 170 | 314 | return -1; | |
| 171 | 315 | } | |
| @@ -246,7 +390,8 @@ static int remove_redundant_no_gen(struct repository *r, | |||
| 246 | 390 | min_generation = curr_generation; | |
| 247 | 391 | } | |
| 248 | 392 | if (paint_down_to_common(r, array[i], filled, | |
| 249 | - | work, min_generation, 0, &common)) { | |
| 393 | + | work, min_generation, | |
| 394 | + | MERGE_BASE_FIND_ALL, &common)) { | |
| 250 | 395 | clear_commit_marks(array[i], all_flags); | |
| 251 | 396 | clear_commit_marks_many(filled, work, all_flags); | |
| 252 | 397 | commit_list_free(common); | |
| @@ -425,6 +570,7 @@ static int get_merge_bases_many_0(struct repository *r, | |||
| 425 | 570 | size_t n, | |
| 426 | 571 | struct commit **twos, | |
| 427 | 572 | int cleanup, | |
| 573 | + | enum merge_base_flags mb_flags, | |
| 428 | 574 | struct commit_list **result) | |
| 429 | 575 | { | |
| 430 | 576 | struct commit_list *list, **tail = result; | |
| @@ -432,7 +578,7 @@ static int get_merge_bases_many_0(struct repository *r, | |||
| 432 | 578 | size_t cnt, i; | |
| 433 | 579 | int ret; | |
| 434 | 580 | ||
| 435 | - | if (merge_bases_many(r, one, n, twos, result) < 0) | |
| 581 | + | if (merge_bases_many(r, one, n, twos, mb_flags, result) < 0) | |
| 436 | 582 | return -1; | |
| 437 | 583 | for (i = 0; i < n; i++) { | |
| 438 | 584 | if (one == twos[i]) | |
| @@ -475,16 +621,18 @@ int repo_get_merge_bases_many(struct repository *r, | |||
| 475 | 621 | struct commit **twos, | |
| 476 | 622 | struct commit_list **result) | |
| 477 | 623 | { | |
| 478 | - | return get_merge_bases_many_0(r, one, n, twos, 1, result); | |
| 624 | + | return get_merge_bases_many_0(r, one, n, twos, 1, | |
| 625 | + | MERGE_BASE_FIND_ALL, result); | |
| 479 | 626 | } | |
| 480 | 627 | ||
| 481 | 628 | int repo_get_merge_bases_many_dirty(struct repository *r, | |
| 482 | 629 | struct commit *one, | |
| 483 | 630 | size_t n, | |
| 484 | 631 | struct commit **twos, | |
| 632 | + | enum merge_base_flags mb_flags, | |
| 485 | 633 | struct commit_list **result) | |
| 486 | 634 | { | |
| 487 | - | return get_merge_bases_many_0(r, one, n, twos, 0, result); | |
| 635 | + | return get_merge_bases_many_0(r, one, n, twos, 0, mb_flags, result); | |
| 488 | 636 | } | |
| 489 | 637 | ||
| 490 | 638 | int repo_get_merge_bases(struct repository *r, | |
| @@ -492,7 +640,8 @@ int repo_get_merge_bases(struct repository *r, | |||
| 492 | 640 | struct commit *two, | |
| 493 | 641 | struct commit_list **result) | |
| 494 | 642 | { | |
| 495 | - | return get_merge_bases_many_0(r, one, 1, &two, 1, result); | |
| 643 | + | return get_merge_bases_many_0(r, one, 1, &two, 1, | |
| 644 | + | MERGE_BASE_FIND_ALL, result); | |
| 496 | 645 | } | |
| 497 | 646 | ||
| 498 | 647 | /* | |
| @@ -537,6 +686,10 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit, | |||
| 537 | 686 | struct commit_list *bases = NULL; | |
| 538 | 687 | int ret = 0, i; | |
| 539 | 688 | timestamp_t generation, max_generation = GENERATION_NUMBER_ZERO; | |
| 689 | + | enum merge_base_flags mb_flags = MERGE_BASE_FIND_ALL; | |
| 690 | + | ||
| 691 | + | if (ignore_missing_commits) | |
| 692 | + | mb_flags |= MERGE_BASE_IGNORE_MISSING_COMMITS; | |
| 540 | 693 | ||
| 541 | 694 | if (repo_parse_commit(r, commit)) | |
| 542 | 695 | return ignore_missing_commits ? 0 : -1; | |
| @@ -555,7 +708,7 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit, | |||
| 555 | 708 | ||
| 556 | 709 | if (paint_down_to_common(r, commit, | |
| 557 | 710 | nr_reference, reference, | |
| 558 | - | generation, ignore_missing_commits, &bases)) | |
| 711 | + | generation, mb_flags, &bases)) | |
| 559 | 712 | ret = -1; | |
| 560 | 713 | else if (commit->object.flags & PARENT2) | |
| 561 | 714 | ret = 1; | |
| @@ -690,7 +843,8 @@ static int in_commit_list(const struct commit_list *want, struct commit *c) | |||
| 690 | 843 | ||
| 691 | 844 | /* | |
| 692 | 845 | * Test whether the candidate is contained in the list. | |
| 693 | - | * Do not recurse to find out, though, but return -1 if inconclusive. | |
| 846 | + | * Do not recurse to find out, though, but return CONTAINS_UNKNOWN if | |
| 847 | + | * inconclusive. | |
| 694 | 848 | */ | |
| 695 | 849 | static enum contains_result contains_test(struct commit *candidate, | |
| 696 | 850 | const struct commit_list *want, | |
| @@ -747,6 +901,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate, | |||
| 747 | 901 | if (result != CONTAINS_UNKNOWN) | |
| 748 | 902 | return result; | |
| 749 | 903 | ||
| 904 | + | *contains_cache_at(cache, candidate) = CONTAINS_IN_PROGRESS; | |
| 750 | 905 | push_to_contains_stack(candidate, &contains_stack); | |
| 751 | 906 | while (contains_stack.nr) { | |
| 752 | 907 | struct contains_stack_entry *entry = &contains_stack.contains_stack[contains_stack.nr - 1]; | |
| @@ -758,8 +913,8 @@ static enum contains_result contains_tag_algo(struct commit *candidate, | |||
| 758 | 913 | contains_stack.nr--; | |
| 759 | 914 | } | |
| 760 | 915 | /* | |
| 761 | - | * If we just popped the stack, parents->item has been marked, | |
| 762 | - | * therefore contains_test will return a meaningful yes/no. | |
| 916 | + | * A parent may have just been popped and marked, or may still | |
| 917 | + | * be active when replacement refs create a cycle. | |
| 763 | 918 | */ | |
| 764 | 919 | else switch (contains_test(parents->item, want, cache, cutoff)) { | |
| 765 | 920 | case CONTAINS_YES: | |
| @@ -769,7 +924,11 @@ static enum contains_result contains_tag_algo(struct commit *candidate, | |||
| 769 | 924 | case CONTAINS_NO: | |
| 770 | 925 | entry->parents = parents->next; | |
| 771 | 926 | break; | |
| 927 | + | case CONTAINS_IN_PROGRESS: | |
| 928 | + | die(_("commit ancestry contains a cycle")); | |
| 772 | 929 | case CONTAINS_UNKNOWN: | |
| 930 | + | *contains_cache_at(cache, parents->item) = | |
| 931 | + | CONTAINS_IN_PROGRESS; | |
| 773 | 932 | push_to_contains_stack(parents->item, &contains_stack); | |
| 774 | 933 | break; | |
| 775 | 934 | } | |
| @@ -781,9 +940,16 @@ static enum contains_result contains_tag_algo(struct commit *candidate, | |||
| 781 | 940 | int commit_contains(struct ref_filter *filter, struct commit *commit, | |
| 782 | 941 | struct commit_list *list, struct contains_cache *cache) | |
| 783 | 942 | { | |
| 784 | - | if (filter->with_commit_tag_algo) | |
| 943 | + | int result; | |
| 944 | + | ||
| 945 | + | if (filter->with_commit_tag_algo || | |
| 946 | + | generation_numbers_enabled(the_repository)) | |
| 785 | 947 | return contains_tag_algo(commit, list, cache) == CONTAINS_YES; | |
| 786 | - | return repo_is_descendant_of(the_repository, commit, list); | |
| 948 | + | ||
| 949 | + | result = repo_is_descendant_of(the_repository, commit, list); | |
| 950 | + | if (result < 0) | |
| 951 | + | die(_("failed to check reachability")); | |
| 952 | + | return result; | |
| 787 | 953 | } | |
| 788 | 954 | ||
| 789 | 955 | int can_all_from_reach_with_flag(struct object_array *from, | |
| @@ -1022,11 +1188,11 @@ struct commit_list *get_reachable_subset(struct commit **from, size_t nr_from, | |||
| 1022 | 1188 | define_commit_slab(bit_arrays, struct bitmap *); | |
| 1023 | 1189 | static struct bit_arrays bit_arrays; | |
| 1024 | 1190 | ||
| 1025 | - | static void insert_no_dup(struct prio_queue *queue, struct commit *c) | |
| 1191 | + | static void insert_no_dup(struct nonstale_queue *queue, struct commit *c) | |
| 1026 | 1192 | { | |
| 1027 | 1193 | if (c->object.flags & PARENT2) | |
| 1028 | 1194 | return; | |
| 1029 | - | prio_queue_put(queue, c); | |
| 1195 | + | nonstale_queue_put(queue, c); | |
| 1030 | 1196 | c->object.flags |= PARENT2; | |
| 1031 | 1197 | } | |
| 1032 | 1198 | ||
| @@ -1051,7 +1217,10 @@ void ahead_behind(struct repository *r, | |||
| 1051 | 1217 | struct commit **commits, size_t commits_nr, | |
| 1052 | 1218 | struct ahead_behind_count *counts, size_t counts_nr) | |
| 1053 | 1219 | { | |
| 1054 | - | struct prio_queue queue = { .compare = compare_commits_by_gen_then_commit_date }; | |
| 1220 | + | struct nonstale_queue queue = { | |
| 1221 | + | { .compare = compare_commits_by_gen_then_commit_date } | |
| 1222 | + | }; | |
| 1223 | + | void *entry; | |
| 1055 | 1224 | size_t width = DIV_ROUND_UP(commits_nr, BITS_IN_EWORD); | |
| 1056 | 1225 | ||
| 1057 | 1226 | if (!commits_nr || !counts_nr) | |
| @@ -1074,8 +1243,8 @@ void ahead_behind(struct repository *r, | |||
| 1074 | 1243 | insert_no_dup(&queue, c); | |
| 1075 | 1244 | } | |
| 1076 | 1245 | ||
| 1077 | - | while (queue_has_nonstale(&queue)) { | |
| 1078 | - | struct commit *c = prio_queue_get(&queue); | |
| 1246 | + | while (queue.max_nonstale) { | |
| 1247 | + | struct commit *c = nonstale_queue_get(&queue); | |
| 1079 | 1248 | struct commit_list *p; | |
| 1080 | 1249 | struct bitmap *bitmap_c = get_bit_array(c, width); | |
| 1081 | 1250 | ||
| @@ -1117,15 +1286,14 @@ void ahead_behind(struct repository *r, | |||
| 1117 | 1286 | ||
| 1118 | 1287 | /* STALE is used here, PARENT2 is used by insert_no_dup(). */ | |
| 1119 | 1288 | repo_clear_commit_marks(r, PARENT2 | STALE); | |
| 1120 | - | for (size_t i = 0; i < queue.nr; i++) | |
| 1121 | - | free_bit_array(queue.array[i].data); | |
| 1289 | + | prio_queue_for_each(&queue.pq, entry) | |
| 1290 | + | free_bit_array(entry); | |
| 1122 | 1291 | clear_bit_arrays(&bit_arrays); | |
| 1123 | - | clear_prio_queue(&queue); | |
| 1292 | + | clear_nonstale_queue(&queue); | |
| 1124 | 1293 | } | |
| 1125 | 1294 | ||
| 1126 | 1295 | struct commit_and_index { | |
| 1127 | 1296 | struct commit *commit; | |
| 1128 | - | unsigned int index; | |
| 1129 | 1297 | timestamp_t generation; | |
| 1130 | 1298 | }; | |
| 1131 | 1299 | ||
| @@ -1165,7 +1333,6 @@ void tips_reachable_from_bases(struct repository *r, | |||
| 1165 | 1333 | ||
| 1166 | 1334 | for (size_t i = 0; i < tips_nr; i++) { | |
| 1167 | 1335 | commits[i].commit = tips[i]; | |
| 1168 | - | commits[i].index = i; | |
| 1169 | 1336 | commits[i].generation = commit_graph_generation(tips[i]); | |
| 1170 | 1337 | } | |
| 1171 | 1338 | ||
| @@ -1173,6 +1340,9 @@ void tips_reachable_from_bases(struct repository *r, | |||
| 1173 | 1340 | QSORT(commits, tips_nr, compare_commit_and_index_by_generation); | |
| 1174 | 1341 | min_generation = commits[0].generation; | |
| 1175 | 1342 | ||
| 1343 | + | for (size_t i = 0; i < tips_nr; i++) | |
| 1344 | + | commits[i].commit->object.flags |= RESULT; | |
| 1345 | + | ||
| 1176 | 1346 | while (bases) { | |
| 1177 | 1347 | repo_parse_commit(r, bases->item); | |
| 1178 | 1348 | commit_list_insert(bases->item, &stack); | |
| @@ -1183,20 +1353,16 @@ void tips_reachable_from_bases(struct repository *r, | |||
| 1183 | 1353 | int explored_all_parents = 1; | |
| 1184 | 1354 | struct commit_list *p; | |
| 1185 | 1355 | struct commit *c = stack->item; | |
| 1186 | - | timestamp_t c_gen = commit_graph_generation(c); | |
| 1187 | 1356 | ||
| 1188 | 1357 | /* Does it match any of our tips? */ | |
| 1189 | - | for (size_t j = min_generation_index; j < tips_nr; j++) { | |
| 1190 | - | if (c_gen < commits[j].generation) | |
| 1191 | - | break; | |
| 1192 | - | ||
| 1193 | - | if (commits[j].commit == c) { | |
| 1194 | - | tips[commits[j].index]->object.flags |= mark; | |
| 1358 | + | { | |
| 1359 | + | if (c->object.flags & RESULT) { | |
| 1360 | + | c->object.flags |= mark; | |
| 1195 | 1361 | ||
| 1196 | - | if (j == min_generation_index) { | |
| 1197 | - | unsigned int k = j + 1; | |
| 1362 | + | if (commits[min_generation_index].commit->object.flags & mark) { | |
| 1363 | + | unsigned int k = min_generation_index + 1; | |
| 1198 | 1364 | while (k < tips_nr && | |
| 1199 | - | (tips[commits[k].index]->object.flags & mark)) | |
| 1365 | + | (commits[k].commit->object.flags & mark)) | |
| 1200 | 1366 | k++; | |
| 1201 | 1367 | ||
| 1202 | 1368 | /* Terminate early if all found. */ | |
| @@ -1232,6 +1398,8 @@ void tips_reachable_from_bases(struct repository *r, | |||
| 1232 | 1398 | } | |
| 1233 | 1399 | ||
| 1234 | 1400 | done: | |
| 1401 | + | for (size_t i = 0; i < tips_nr; i++) | |
| 1402 | + | commits[i].commit->object.flags &= ~RESULT; | |
| 1235 | 1403 | free(commits); | |
| 1236 | 1404 | repo_clear_commit_marks(r, SEEN); | |
| 1237 | 1405 | commit_list_free(stack); | |
| @@ -1252,7 +1420,7 @@ int get_branch_base_for_tip(struct repository *r, | |||
| 1252 | 1420 | size_t bases_nr) | |
| 1253 | 1421 | { | |
| 1254 | 1422 | int best_index = -1; | |
| 1255 | - | struct commit *branch_point = NULL; | |
| 1423 | + | struct commit *c, *branch_point = NULL; | |
| 1256 | 1424 | struct prio_queue queue = { compare_commits_by_gen_then_commit_date }; | |
| 1257 | 1425 | int found_missing_gen = 0; | |
| 1258 | 1426 | ||
| @@ -1305,8 +1473,7 @@ int get_branch_base_for_tip(struct repository *r, | |||
| 1305 | 1473 | prio_queue_put(&queue, c); | |
| 1306 | 1474 | } | |
| 1307 | 1475 | ||
| 1308 | - | while (queue.nr) { | |
| 1309 | - | struct commit *c = prio_queue_get(&queue); | |
| 1476 | + | while ((c = prio_queue_get(&queue))) { | |
| 1310 | 1477 | int best_for_c = get_best(c); | |
| 1311 | 1478 | int best_for_p, positive; | |
| 1312 | 1479 | struct commit *parent; | |
modified commit-reach.h
| @@ -17,10 +17,20 @@ int repo_get_merge_bases_many(struct repository *r, | |||
| 17 | 17 | struct commit *one, size_t n, | |
| 18 | 18 | struct commit **twos, | |
| 19 | 19 | struct commit_list **result); | |
| 20 | - | /* To be used only when object flags after this call no longer matter */ | |
| 20 | + | enum merge_base_flags { | |
| 21 | + | MERGE_BASE_IGNORE_MISSING_COMMITS = (1 << 0), | |
| 22 | + | MERGE_BASE_FIND_ALL = (1 << 1), | |
| 23 | + | }; | |
| 24 | + | ||
| 25 | + | /* | |
| 26 | + | * To be used only when object flags after this call no longer matter. | |
| 27 | + | * Without MERGE_BASE_FIND_ALL and with generation numbers available, | |
| 28 | + | * returns after finding the first merge-base, skipping the STALE drain. | |
| 29 | + | */ | |
| 21 | 30 | int repo_get_merge_bases_many_dirty(struct repository *r, | |
| 22 | 31 | struct commit *one, size_t n, | |
| 23 | 32 | struct commit **twos, | |
| 33 | + | enum merge_base_flags mb_flags, | |
| 24 | 34 | struct commit_list **result); | |
| 25 | 35 | ||
| 26 | 36 | int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result); | |
| @@ -63,7 +73,8 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid); | |||
| 63 | 73 | enum contains_result { | |
| 64 | 74 | CONTAINS_UNKNOWN = 0, | |
| 65 | 75 | CONTAINS_NO, | |
| 66 | - | CONTAINS_YES | |
| 76 | + | CONTAINS_YES, | |
| 77 | + | CONTAINS_IN_PROGRESS | |
| 67 | 78 | }; | |
| 68 | 79 | ||
| 69 | 80 | define_commit_slab(contains_cache, enum contains_result); | |
modified commit.c
| @@ -395,7 +395,7 @@ const void *repo_get_commit_buffer(struct repository *r, | |||
| 395 | 395 | const void *ret = get_cached_commit_buffer(r, commit, sizep); | |
| 396 | 396 | if (!ret) { | |
| 397 | 397 | enum object_type type; | |
| 398 | - | unsigned long size; | |
| 398 | + | size_t size; | |
| 399 | 399 | ret = odb_read_object(r->objects, &commit->object.oid, &type, &size); | |
| 400 | 400 | if (!ret) | |
| 401 | 401 | die("cannot read commit object %s", | |
| @@ -404,7 +404,7 @@ const void *repo_get_commit_buffer(struct repository *r, | |||
| 404 | 404 | die("expected commit for %s, got %s", | |
| 405 | 405 | oid_to_hex(&commit->object.oid), type_name(type)); | |
| 406 | 406 | if (sizep) | |
| 407 | - | *sizep = size; | |
| 407 | + | *sizep = cast_size_t_to_ulong(size); | |
| 408 | 408 | } | |
| 409 | 409 | return ret; | |
| 410 | 410 | } | |
| @@ -434,6 +434,27 @@ static inline void set_commit_tree(struct commit *c, struct tree *t) | |||
| 434 | 434 | c->maybe_tree = t; | |
| 435 | 435 | } | |
| 436 | 436 | ||
| 437 | + | static void load_tree_from_commit_contents(struct repository *r, struct commit *commit) | |
| 438 | + | { | |
| 439 | + | enum object_type type; | |
| 440 | + | size_t size; | |
| 441 | + | char *buf; | |
| 442 | + | const char *p; | |
| 443 | + | struct object_id tree_oid; | |
| 444 | + | ||
| 445 | + | buf = odb_read_object(r->objects, &commit->object.oid, &type, &size); | |
| 446 | + | if (!buf) | |
| 447 | + | return; | |
| 448 | + | ||
| 449 | + | if (type == OBJ_COMMIT && | |
| 450 | + | skip_prefix(buf, "tree ", &p) && | |
| 451 | + | !parse_oid_hex_algop(p, &tree_oid, &p, r->hash_algo) && | |
| 452 | + | *p == '\n') | |
| 453 | + | set_commit_tree(commit, lookup_tree(r, &tree_oid)); | |
| 454 | + | ||
| 455 | + | free(buf); | |
| 456 | + | } | |
| 457 | + | ||
| 437 | 458 | struct tree *repo_get_commit_tree(struct repository *r, | |
| 438 | 459 | const struct commit *commit) | |
| 439 | 460 | { | |
| @@ -443,7 +464,17 @@ struct tree *repo_get_commit_tree(struct repository *r, | |||
| 443 | 464 | if (commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH) | |
| 444 | 465 | return get_commit_tree_in_graph(r, commit); | |
| 445 | 466 | ||
| 446 | - | return NULL; | |
| 467 | + | /* | |
| 468 | + | * This is either a corrupt commit, or one which we partially loaded | |
| 469 | + | * from a graph file but then subsequently threw away the graph data. | |
| 470 | + | * | |
| 471 | + | * Optimistically assume it's the latter and try to reload from | |
| 472 | + | * scratch. This gives a performance penalty if it really is a corrupt | |
| 473 | + | * commit, but presumably that happens rarely (and only once per | |
| 474 | + | * process). | |
| 475 | + | */ | |
| 476 | + | load_tree_from_commit_contents(r, (struct commit *)commit); | |
| 477 | + | return commit->maybe_tree; | |
| 447 | 478 | } | |
| 448 | 479 | ||
| 449 | 480 | struct object_id *get_commit_tree_oid(const struct commit *commit) | |
| @@ -573,7 +604,7 @@ int repo_parse_commit_internal(struct repository *r, | |||
| 573 | 604 | { | |
| 574 | 605 | enum object_type type; | |
| 575 | 606 | void *buffer; | |
| 576 | - | unsigned long size; | |
| 607 | + | size_t size; | |
| 577 | 608 | struct object_info oi = { | |
| 578 | 609 | .typep = &type, | |
| 579 | 610 | .sizep = &size, | |
| @@ -729,19 +760,6 @@ void commit_list_free(struct commit_list *list) | |||
| 729 | 760 | pop_commit(&list); | |
| 730 | 761 | } | |
| 731 | 762 | ||
| 732 | - | struct commit_list * commit_list_insert_by_date(struct commit *item, struct commit_list **list) | |
| 733 | - | { | |
| 734 | - | struct commit_list **pp = list; | |
| 735 | - | struct commit_list *p; | |
| 736 | - | while ((p = *pp) != NULL) { | |
| 737 | - | if (p->item->date < item->date) { | |
| 738 | - | break; | |
| 739 | - | } | |
| 740 | - | pp = &p->next; | |
| 741 | - | } | |
| 742 | - | return commit_list_insert(item, pp); | |
| 743 | - | } | |
| 744 | - | ||
| 745 | 763 | static int commit_list_compare_by_date(const struct commit_list *a, | |
| 746 | 764 | const struct commit_list *b) | |
| 747 | 765 | { | |
| @@ -764,24 +782,17 @@ void commit_list_sort_by_date(struct commit_list **list) | |||
| 764 | 782 | struct commit *pop_most_recent_commit(struct prio_queue *queue, | |
| 765 | 783 | unsigned int mark) | |
| 766 | 784 | { | |
| 767 | - | struct commit *ret = prio_queue_peek(queue); | |
| 768 | - | int get_pending = 1; | |
| 785 | + | struct commit *ret = prio_queue_get(queue); | |
| 769 | 786 | struct commit_list *parents = ret->parents; | |
| 770 | 787 | ||
| 771 | 788 | while (parents) { | |
| 772 | 789 | struct commit *commit = parents->item; | |
| 773 | 790 | if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) { | |
| 774 | 791 | commit->object.flags |= mark; | |
| 775 | - | if (get_pending) | |
| 776 | - | prio_queue_replace(queue, commit); | |
| 777 | - | else | |
| 778 | - | prio_queue_put(queue, commit); | |
| 779 | - | get_pending = 0; | |
| 792 | + | prio_queue_put(queue, commit); | |
| 780 | 793 | } | |
| 781 | 794 | parents = parents->next; | |
| 782 | 795 | } | |
| 783 | - | if (get_pending) | |
| 784 | - | prio_queue_get(queue); | |
| 785 | 796 | return ret; | |
| 786 | 797 | } | |
| 787 | 798 | ||
| @@ -1282,7 +1293,7 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h | |||
| 1282 | 1293 | struct merge_remote_desc *desc; | |
| 1283 | 1294 | struct commit_extra_header *mergetag; | |
| 1284 | 1295 | char *buf; | |
| 1285 | - | unsigned long size; | |
| 1296 | + | size_t size; | |
| 1286 | 1297 | enum object_type type; | |
| 1287 | 1298 | struct strbuf payload = STRBUF_INIT; | |
| 1288 | 1299 | struct strbuf signature = STRBUF_INIT; | |
| @@ -1558,16 +1569,16 @@ int commit_tree(const char *msg, size_t msg_len, const struct object_id *tree, | |||
| 1558 | 1569 | return result; | |
| 1559 | 1570 | } | |
| 1560 | 1571 | ||
| 1561 | - | static int find_invalid_utf8(const char *buf, int len) | |
| 1572 | + | static bool has_invalid_utf8(const char *buf, size_t len, size_t *bad_offset) | |
| 1562 | 1573 | { | |
| 1563 | - | int offset = 0; | |
| 1574 | + | size_t offset = 0; | |
| 1564 | 1575 | static const unsigned int max_codepoint[] = { | |
| 1565 | 1576 | 0x7f, 0x7ff, 0xffff, 0x10ffff | |
| 1566 | 1577 | }; | |
| 1567 | 1578 | ||
| 1568 | 1579 | while (len) { | |
| 1569 | 1580 | unsigned char c = *buf++; | |
| 1570 | - | int bytes, bad_offset; | |
| 1581 | + | unsigned bytes; | |
| 1571 | 1582 | unsigned int codepoint; | |
| 1572 | 1583 | unsigned int min_val, max_val; | |
| 1573 | 1584 | ||
| @@ -1578,7 +1589,7 @@ static int find_invalid_utf8(const char *buf, int len) | |||
| 1578 | 1589 | if (c < 0x80) | |
| 1579 | 1590 | continue; | |
| 1580 | 1591 | ||
| 1581 | - | bad_offset = offset-1; | |
| 1592 | + | *bad_offset = offset-1; | |
| 1582 | 1593 | ||
| 1583 | 1594 | /* | |
| 1584 | 1595 | * Count how many more high bits set: that's how | |
| @@ -1595,11 +1606,11 @@ static int find_invalid_utf8(const char *buf, int len) | |||
| 1595 | 1606 | * codepoints beyond U+10FFFF, which are guaranteed never to exist. | |
| 1596 | 1607 | */ | |
| 1597 | 1608 | if (bytes < 1 || 3 < bytes) | |
| 1598 | - | return bad_offset; | |
| 1609 | + | return true; | |
| 1599 | 1610 | ||
| 1600 | 1611 | /* Do we *have* that many bytes? */ | |
| 1601 | 1612 | if (len < bytes) | |
| 1602 | - | return bad_offset; | |
| 1613 | + | return true; | |
| 1603 | 1614 | ||
| 1604 | 1615 | /* | |
| 1605 | 1616 | * Place the encoded bits at the bottom of the value and compute the | |
| @@ -1617,43 +1628,42 @@ static int find_invalid_utf8(const char *buf, int len) | |||
| 1617 | 1628 | codepoint <<= 6; | |
| 1618 | 1629 | codepoint |= *buf & 0x3f; | |
| 1619 | 1630 | if ((*buf++ & 0xc0) != 0x80) | |
| 1620 | - | return bad_offset; | |
| 1631 | + | return true; | |
| 1621 | 1632 | } while (--bytes); | |
| 1622 | 1633 | ||
| 1623 | 1634 | /* Reject codepoints that are out of range for the sequence length. */ | |
| 1624 | 1635 | if (codepoint < min_val || codepoint > max_val) | |
| 1625 | - | return bad_offset; | |
| 1636 | + | return true; | |
| 1626 | 1637 | /* Surrogates are only for UTF-16 and cannot be encoded in UTF-8. */ | |
| 1627 | 1638 | if ((codepoint & 0x1ff800) == 0xd800) | |
| 1628 | - | return bad_offset; | |
| 1639 | + | return true; | |
| 1629 | 1640 | /* U+xxFFFE and U+xxFFFF are guaranteed non-characters. */ | |
| 1630 | 1641 | if ((codepoint & 0xfffe) == 0xfffe) | |
| 1631 | - | return bad_offset; | |
| 1642 | + | return true; | |
| 1632 | 1643 | /* So are anything in the range U+FDD0..U+FDEF. */ | |
| 1633 | 1644 | if (codepoint >= 0xfdd0 && codepoint <= 0xfdef) | |
| 1634 | - | return bad_offset; | |
| 1645 | + | return true; | |
| 1635 | 1646 | } | |
| 1636 | - | return -1; | |
| 1647 | + | return false; | |
| 1637 | 1648 | } | |
| 1638 | 1649 | ||
| 1639 | 1650 | /* | |
| 1640 | - | * This verifies that the buffer is in proper utf8 format. | |
| 1651 | + | * This ensures that the buffer is in proper utf8 format. | |
| 1641 | 1652 | * | |
| 1642 | 1653 | * If it isn't, it assumes any non-utf8 characters are Latin1, | |
| 1643 | 1654 | * and does the conversion. | |
| 1644 | 1655 | */ | |
| 1645 | - | static int verify_utf8(struct strbuf *buf) | |
| 1656 | + | static int ensure_utf8(struct strbuf *buf) | |
| 1646 | 1657 | { | |
| 1647 | 1658 | int ok = 1; | |
| 1648 | - | long pos = 0; | |
| 1659 | + | size_t pos = 0; | |
| 1649 | 1660 | ||
| 1650 | 1661 | for (;;) { | |
| 1651 | - | int bad; | |
| 1662 | + | size_t bad; | |
| 1652 | 1663 | unsigned char c; | |
| 1653 | 1664 | unsigned char replace[2]; | |
| 1654 | 1665 | ||
| 1655 | - | bad = find_invalid_utf8(buf->buf + pos, buf->len - pos); | |
| 1656 | - | if (bad < 0) | |
| 1666 | + | if (!has_invalid_utf8(buf->buf + pos, buf->len - pos, &bad)) | |
| 1657 | 1667 | return ok; | |
| 1658 | 1668 | pos += bad; | |
| 1659 | 1669 | ok = 0; | |
| @@ -1726,6 +1736,7 @@ int commit_tree_extended(const char *msg, size_t msg_len, | |||
| 1726 | 1736 | struct repository *r = the_repository; | |
| 1727 | 1737 | int result = 0; | |
| 1728 | 1738 | int encoding_is_utf8; | |
| 1739 | + | bool warned = false; | |
| 1729 | 1740 | struct strbuf buffer = STRBUF_INIT, compat_buffer = STRBUF_INIT; | |
| 1730 | 1741 | struct strbuf sig = STRBUF_INIT, compat_sig = STRBUF_INIT; | |
| 1731 | 1742 | struct object_id *parent_buf = NULL, *compat_oid = NULL; | |
| @@ -1747,6 +1758,13 @@ int commit_tree_extended(const char *msg, size_t msg_len, | |||
| 1747 | 1758 | oidcpy(&parent_buf[i++], &p->item->object.oid); | |
| 1748 | 1759 | ||
| 1749 | 1760 | write_commit_tree(&buffer, msg, msg_len, tree, parent_buf, nparents, author, committer, extra); | |
| 1761 | + | ||
| 1762 | + | /* And check the encoding. */ | |
| 1763 | + | if (encoding_is_utf8 && !ensure_utf8(&buffer)) { | |
| 1764 | + | fprintf(stderr, _(commit_utf8_warn)); | |
| 1765 | + | warned = true; | |
| 1766 | + | } | |
| 1767 | + | ||
| 1750 | 1768 | if (sign_commit && sign_buffer(&buffer, &sig, sign_commit, | |
| 1751 | 1769 | SIGN_BUFFER_USE_DEFAULT_KEY)) { | |
| 1752 | 1770 | result = -1; | |
| @@ -1780,6 +1798,9 @@ int commit_tree_extended(const char *msg, size_t msg_len, | |||
| 1780 | 1798 | free_commit_extra_headers(compat_extra); | |
| 1781 | 1799 | free(mapped_parents); | |
| 1782 | 1800 | ||
| 1801 | + | if (encoding_is_utf8 && !ensure_utf8(&compat_buffer) && !warned) | |
| 1802 | + | fprintf(stderr, _(commit_utf8_warn)); | |
| 1803 | + | ||
| 1783 | 1804 | if (sign_commit && sign_buffer(&compat_buffer, &compat_sig, | |
| 1784 | 1805 | sign_commit, | |
| 1785 | 1806 | SIGN_BUFFER_USE_DEFAULT_KEY)) { | |
| @@ -1818,10 +1839,6 @@ int commit_tree_extended(const char *msg, size_t msg_len, | |||
| 1818 | 1839 | } | |
| 1819 | 1840 | } | |
| 1820 | 1841 | ||
| 1821 | - | /* And check the encoding. */ | |
| 1822 | - | if (encoding_is_utf8 && (!verify_utf8(&buffer) || !verify_utf8(&compat_buffer))) | |
| 1823 | - | fprintf(stderr, _(commit_utf8_warn)); | |
| 1824 | - | ||
| 1825 | 1842 | if (r->compat_hash_algo) { | |
| 1826 | 1843 | hash_object_file(r->compat_hash_algo, compat_buffer.buf, compat_buffer.len, | |
| 1827 | 1844 | OBJ_COMMIT, &compat_oid_buf); | |
| @@ -1970,7 +1987,7 @@ size_t ignored_log_message_bytes(const char *buf, size_t len) | |||
| 1970 | 1987 | int run_commit_hook(int editor_is_used, const char *index_file, | |
| 1971 | 1988 | int *invoked_hook, const char *name, ...) | |
| 1972 | 1989 | { | |
| 1973 | - | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT; | |
| 1990 | + | struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; | |
| 1974 | 1991 | va_list args; | |
| 1975 | 1992 | const char *arg; | |
| 1976 | 1993 | ||
modified commit.h
| @@ -191,8 +191,6 @@ int commit_list_contains(struct commit *item, | |||
| 191 | 191 | struct commit_list **commit_list_append(struct commit *commit, | |
| 192 | 192 | struct commit_list **next); | |
| 193 | 193 | unsigned commit_list_count(const struct commit_list *l); | |
| 194 | - | struct commit_list *commit_list_insert_by_date(struct commit *item, | |
| 195 | - | struct commit_list **list); | |
| 196 | 194 | void commit_list_sort_by_date(struct commit_list **list); | |
| 197 | 195 | ||
| 198 | 196 | /* Shallow copy of the input list */ | |
| @@ -203,25 +201,6 @@ struct commit_list *commit_list_reverse(struct commit_list *list); | |||
| 203 | 201 | ||
| 204 | 202 | void commit_list_free(struct commit_list *list); | |
| 205 | 203 | ||
| 206 | - | /* | |
| 207 | - | * Deprecated compatibility functions for `struct commit_list`, to be removed | |
| 208 | - | * once Git 2.53 is released. | |
| 209 | - | */ | |
| 210 | - | static inline struct commit_list *copy_commit_list(struct commit_list *l) | |
| 211 | - | { | |
| 212 | - | return commit_list_copy(l); | |
| 213 | - | } | |
| 214 | - | ||
| 215 | - | static inline struct commit_list *reverse_commit_list(struct commit_list *l) | |
| 216 | - | { | |
| 217 | - | return commit_list_reverse(l); | |
| 218 | - | } | |
| 219 | - | ||
| 220 | - | static inline void free_commit_list(struct commit_list *l) | |
| 221 | - | { | |
| 222 | - | commit_list_free(l); | |
| 223 | - | } | |
| 224 | - | ||
| 225 | 204 | struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ | |
| 226 | 205 | ||
| 227 | 206 | const char *repo_logmsg_reencode(struct repository *r, | |
modified common-init.c
| @@ -5,7 +5,10 @@ | |||
| 5 | 5 | #include "exec-cmd.h" | |
| 6 | 6 | #include "gettext.h" | |
| 7 | 7 | #include "attr.h" | |
| 8 | + | #include "odb.h" | |
| 9 | + | #include "parse.h" | |
| 8 | 10 | #include "repository.h" | |
| 11 | + | #include "replace-object.h" | |
| 9 | 12 | #include "setup.h" | |
| 10 | 13 | #include "strbuf.h" | |
| 11 | 14 | #include "trace2.h" | |
| @@ -31,6 +34,22 @@ static void restore_sigpipe_to_default(void) | |||
| 31 | 34 | signal(SIGPIPE, SIG_DFL); | |
| 32 | 35 | } | |
| 33 | 36 | ||
| 37 | + | static void setup_environment(void) | |
| 38 | + | { | |
| 39 | + | char *git_replace_ref_base; | |
| 40 | + | const char *replace_ref_base; | |
| 41 | + | ||
| 42 | + | if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT)) | |
| 43 | + | disable_replace_refs(); | |
| 44 | + | replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT); | |
| 45 | + | git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base | |
| 46 | + | : "refs/replace/"); | |
| 47 | + | update_ref_namespace(NAMESPACE_REPLACE, git_replace_ref_base); | |
| 48 | + | ||
| 49 | + | if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0)) | |
| 50 | + | the_repository->fetch_if_missing = 0; | |
| 51 | + | } | |
| 52 | + | ||
| 34 | 53 | void init_git(const char **argv) | |
| 35 | 54 | { | |
| 36 | 55 | struct strbuf tmp = STRBUF_INIT; | |
| @@ -51,6 +70,7 @@ void init_git(const char **argv) | |||
| 51 | 70 | git_setup_gettext(); | |
| 52 | 71 | ||
| 53 | 72 | initialize_repository(the_repository); | |
| 73 | + | setup_environment(); | |
| 54 | 74 | ||
| 55 | 75 | attr_start(); | |
| 56 | 76 | ||
added compat/fsmonitor/fsm-health-linux.c mode 100644
| @@ -0,0 +1,33 @@ | |||
| 1 | + | #include "git-compat-util.h" | |
| 2 | + | #include "config.h" | |
| 3 | + | #include "fsmonitor-ll.h" | |
| 4 | + | #include "fsm-health.h" | |
| 5 | + | #include "fsmonitor--daemon.h" | |
| 6 | + | ||
| 7 | + | /* | |
| 8 | + | * The Linux fsmonitor implementation uses inotify which has its own | |
| 9 | + | * mechanisms for detecting filesystem unmount and other events that | |
| 10 | + | * would require the daemon to shutdown. Therefore, we don't need | |
| 11 | + | * a separate health thread like Windows does. | |
| 12 | + | * | |
| 13 | + | * These stub functions satisfy the interface requirements. | |
| 14 | + | */ | |
| 15 | + | ||
| 16 | + | int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED) | |
| 17 | + | { | |
| 18 | + | return 0; | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | void fsm_health__dtor(struct fsmonitor_daemon_state *state UNUSED) | |
| 22 | + | { | |
| 23 | + | return; | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | void fsm_health__loop(struct fsmonitor_daemon_state *state UNUSED) | |
| 27 | + | { | |
| 28 | + | return; | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | void fsm_health__stop_async(struct fsmonitor_daemon_state *state UNUSED) | |
| 32 | + | { | |
| 33 | + | } | |
renamed 100% compat/fsmonitor/fsm-ipc-darwin.c โ compat/fsmonitor/fsm-ipc-unix.c
No content changes.
added compat/fsmonitor/fsm-listen-linux.c mode 100644
| @@ -0,0 +1,746 @@ | |||
| 1 | + | #include "git-compat-util.h" | |
| 2 | + | #include "dir.h" | |
| 3 | + | #include "fsmonitor-ll.h" | |
| 4 | + | #include "fsm-listen.h" | |
| 5 | + | #include "fsmonitor--daemon.h" | |
| 6 | + | #include "fsmonitor-path-utils.h" | |
| 7 | + | #include "gettext.h" | |
| 8 | + | #include "simple-ipc.h" | |
| 9 | + | #include "string-list.h" | |
| 10 | + | #include "trace.h" | |
| 11 | + | ||
| 12 | + | #include <sys/inotify.h> | |
| 13 | + | ||
| 14 | + | /* | |
| 15 | + | * Safe value to bitwise OR with rest of mask for | |
| 16 | + | * kernels that do not support IN_MASK_CREATE | |
| 17 | + | */ | |
| 18 | + | #ifndef IN_MASK_CREATE | |
| 19 | + | #define IN_MASK_CREATE 0x00000000 | |
| 20 | + | #endif | |
| 21 | + | ||
| 22 | + | enum shutdown_reason { | |
| 23 | + | SHUTDOWN_CONTINUE = 0, | |
| 24 | + | SHUTDOWN_STOP, | |
| 25 | + | SHUTDOWN_ERROR, | |
| 26 | + | SHUTDOWN_FORCE | |
| 27 | + | }; | |
| 28 | + | ||
| 29 | + | struct watch_entry { | |
| 30 | + | struct hashmap_entry ent; | |
| 31 | + | int wd; | |
| 32 | + | uint32_t cookie; | |
| 33 | + | const char *dir; | |
| 34 | + | }; | |
| 35 | + | ||
| 36 | + | struct rename_entry { | |
| 37 | + | struct hashmap_entry ent; | |
| 38 | + | time_t whence; | |
| 39 | + | uint32_t cookie; | |
| 40 | + | const char *dir; | |
| 41 | + | }; | |
| 42 | + | ||
| 43 | + | struct fsm_listen_data { | |
| 44 | + | int fd_inotify; | |
| 45 | + | enum shutdown_reason shutdown; | |
| 46 | + | struct hashmap watches; | |
| 47 | + | struct hashmap renames; | |
| 48 | + | struct hashmap revwatches; | |
| 49 | + | }; | |
| 50 | + | ||
| 51 | + | static int watch_entry_cmp(const void *cmp_data UNUSED, | |
| 52 | + | const struct hashmap_entry *eptr, | |
| 53 | + | const struct hashmap_entry *entry_or_key, | |
| 54 | + | const void *keydata UNUSED) | |
| 55 | + | { | |
| 56 | + | const struct watch_entry *e1, *e2; | |
| 57 | + | ||
| 58 | + | e1 = container_of(eptr, const struct watch_entry, ent); | |
| 59 | + | e2 = container_of(entry_or_key, const struct watch_entry, ent); | |
| 60 | + | return e1->wd != e2->wd; | |
| 61 | + | } | |
| 62 | + | ||
| 63 | + | static int revwatches_entry_cmp(const void *cmp_data UNUSED, | |
| 64 | + | const struct hashmap_entry *eptr, | |
| 65 | + | const struct hashmap_entry *entry_or_key, | |
| 66 | + | const void *keydata UNUSED) | |
| 67 | + | { | |
| 68 | + | const struct watch_entry *e1, *e2; | |
| 69 | + | ||
| 70 | + | e1 = container_of(eptr, const struct watch_entry, ent); | |
This diff is too large to show in full - only the first part is shown.