]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jt/commit-redundant-scissors-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 7 Mar 2024 23:59:41 +0000 (15:59 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Mar 2024 23:59:41 +0000 (15:59 -0800)
"git commit -v --cleanup=scissors" used to add the scissors line
twice in the log message buffer, which has been corrected.

* jt/commit-redundant-scissors-fix:
  commit: unify logic to avoid multiple scissors lines when merging
  commit: avoid redundant scissor line with --cleanup=scissors -v

427 files changed:
.cirrus.yml
.github/workflows/check-whitespace.yml
.github/workflows/coverity.yml
.github/workflows/l10n.yml
.github/workflows/main.yml
.gitignore
.gitlab-ci.yml
Documentation/CodingGuidelines
Documentation/Makefile
Documentation/RelNotes/2.44.0.txt [new file with mode: 0644]
Documentation/RelNotes/2.45.0.txt [new file with mode: 0644]
Documentation/config/advice.txt
Documentation/config/diff.txt
Documentation/config/extensions.txt
Documentation/config/feature.txt
Documentation/config/fetch.txt
Documentation/config/interactive.txt
Documentation/config/mergetool.txt
Documentation/config/pack.txt
Documentation/config/rebase.txt
Documentation/config/sendemail.txt
Documentation/diff-options.txt
Documentation/fetch-options.txt
Documentation/git-add.txt
Documentation/git-am.txt
Documentation/git-bisect.txt
Documentation/git-blame.txt
Documentation/git-branch.txt
Documentation/git-bugreport.txt
Documentation/git-checkout.txt
Documentation/git-clone.txt
Documentation/git-commit-graph.txt
Documentation/git-config.txt
Documentation/git-cvsserver.txt
Documentation/git-daemon.txt
Documentation/git-diagnose.txt
Documentation/git-difftool.txt
Documentation/git-fast-export.txt
Documentation/git-fast-import.txt
Documentation/git-fetch.txt
Documentation/git-filter-branch.txt
Documentation/git-for-each-ref.txt
Documentation/git-format-patch.txt
Documentation/git-index-pack.txt
Documentation/git-init.txt
Documentation/git-ls-files.txt
Documentation/git-merge-file.txt
Documentation/git-merge-tree.txt
Documentation/git-mv.txt
Documentation/git-notes.txt
Documentation/git-rebase.txt
Documentation/git-reflog.txt
Documentation/git-remote.txt
Documentation/git-replace.txt
Documentation/git-replay.txt [new file with mode: 0644]
Documentation/git-rev-parse.txt
Documentation/git-revert.txt
Documentation/git-send-email.txt
Documentation/git-status.txt
Documentation/git-submodule.txt
Documentation/git-svn.txt
Documentation/git-switch.txt
Documentation/git-tag.txt
Documentation/git.txt
Documentation/gitattributes.txt
Documentation/gitdiffcore.txt
Documentation/gitformat-index.txt
Documentation/gitformat-pack.txt
Documentation/githooks.txt
Documentation/gitk.txt
Documentation/gitprotocol-capabilities.txt
Documentation/gitprotocol-http.txt
Documentation/gitprotocol-v2.txt
Documentation/gitsubmodules.txt
Documentation/gitweb.conf.txt
Documentation/gitweb.txt
Documentation/glossary-content.txt
Documentation/mergetools/vimdiff.txt
Documentation/ref-storage-format.txt [new file with mode: 0644]
Documentation/rev-list-options.txt
Documentation/technical/repository-version.txt
Documentation/technical/unit-tests.txt [new file with mode: 0644]
Documentation/trace2-target-values.txt
Documentation/urls.txt
Documentation/user-manual.txt
GIT-VERSION-GEN
Makefile
RelNotes
add-patch.c
advice.c
advice.h
apply.c
archive-tar.c
attr.c
bisect.c
branch.c
builtin.h
builtin/add.c
builtin/bisect.c
builtin/branch.c
builtin/cat-file.c
builtin/checkout.c
builtin/clone.c
builtin/column.c
builtin/commit-graph.c
builtin/commit.c
builtin/config.c
builtin/fast-export.c
builtin/fetch.c
builtin/for-each-ref.c
builtin/fsck.c
builtin/gc.c
builtin/grep.c
builtin/index-pack.c
builtin/init-db.c
builtin/log.c
builtin/ls-remote.c
builtin/merge-file.c
builtin/merge-tree.c
builtin/merge.c
builtin/name-rev.c
builtin/notes.c
builtin/pack-objects.c
builtin/read-tree.c
builtin/rebase.c
builtin/receive-pack.c
builtin/reflog.c
builtin/replay.c [new file with mode: 0644]
builtin/reset.c
builtin/rev-list.c
builtin/rev-parse.c
builtin/send-pack.c
builtin/show-ref.c
builtin/sparse-checkout.c
builtin/tag.c
builtin/var.c
builtin/worktree.c
cache-tree.c
ci/install-dependencies.sh
ci/install-docker-dependencies.sh
ci/lib.sh
ci/print-test-failures.sh
ci/run-build-and-minimal-fuzzers.sh [new file with mode: 0755]
ci/run-build-and-tests.sh
ci/run-test-slice.sh
column.c
combine-diff.c
command-list.txt
commit-graph.c
compat/compiler.h
compat/disk.h
compat/mingw.c
config.c
config.h
config.mak.uname
configure.ac
contrib/buildsystems/CMakeLists.txt
contrib/coccinelle/xstrncmpz.cocci [new file with mode: 0644]
contrib/completion/git-completion.bash
contrib/completion/git-prompt.sh
contrib/credential/libsecret/git-credential-libsecret.c
contrib/credential/wincred/git-credential-wincred.c
contrib/subtree/git-subtree.sh
contrib/subtree/t/t7900-subtree.sh
contrib/workdir/git-new-workdir
convert.c
diff-lib.c
diff.c
dir-iterator.c
dir-iterator.h
dir.c
environment.c
environment.h
ewah/bitmap.c
ewah/ewok.h
fsck.c
git-compat-util.h
git-difftool--helper.sh
git-p4.py
git.c
gitweb/gitweb.perl
http-backend.c
http-push.c
list-objects-filter.c
mem-pool.c
mem-pool.h
merge-ll.c
merge-ort.c
merge-recursive.c
merge.c
mergetools/vimdiff
midx.c
midx.h
object-name.c
object.c
oidset.c
oidset.h
oss-fuzz/.gitignore
oss-fuzz/dummy-cmd-main.c [new file with mode: 0644]
oss-fuzz/fuzz-date.c [new file with mode: 0644]
pack-bitmap-write.c
pack-bitmap.c
pack-bitmap.h
pack-objects.c
pack-objects.h
pack-revindex.c
pack-revindex.h
path.c
path.h
pathspec.c
po/bg.po
po/ca.po
po/de.po
po/fr.po
po/id.po
po/sv.po
po/tr.po
po/uk.po
po/zh_CN.po
po/zh_TW.po
reachable.c
read-cache-ll.h
read-cache.c
ref-filter.c
ref-filter.h
refs.c
refs.h
refs/debug.c
refs/files-backend.c
refs/iterator.c
refs/packed-backend.c
refs/ref-cache.c
refs/refs-internal.h
refs/reftable-backend.c [new file with mode: 0644]
reftable/basics.c
reftable/basics.h
reftable/block.c
reftable/block_test.c
reftable/blocksource.c
reftable/iter.c
reftable/merged.c
reftable/merged.h
reftable/merged_test.c
reftable/pq.c
reftable/publicbasics.c
reftable/reader.c
reftable/readwrite_test.c
reftable/record.c
reftable/record.h
reftable/record_test.c
reftable/refname.c
reftable/refname_test.c
reftable/reftable-merged.h
reftable/reftable-record.h
reftable/reftable-writer.h
reftable/stack.c
reftable/stack.h
reftable/stack_test.c
reftable/test_framework.c
reftable/test_framework.h
reftable/tree.c
reftable/writer.c
reftable/writer.h
remote-curl.c
remote.c
remote.h
repo-settings.c
repository.c
repository.h
rerere.c
reset.c
revision.c
sequencer.c
sequencer.h
setup.c
setup.h
shared.mak
sparse-index.c
statinfo.c
statinfo.h
submodule-config.c
submodule-config.h
submodule.c
t/Makefile
t/README
t/helper/test-ctype.c [deleted file]
t/helper/test-fast-rebase.c [deleted file]
t/helper/test-prio-queue.c [deleted file]
t/helper/test-read-midx.c
t/helper/test-ref-store.c
t/helper/test-submodule.c
t/helper/test-tool.c
t/helper/test-tool.h
t/lib-credential.sh
t/lib-httpd.sh
t/lib-httpd/passwd
t/lib-httpd/proxy-passwd
t/perf/p5332-multi-pack-reuse.sh [new file with mode: 0755]
t/perf/p6300-for-each-ref.sh [new file with mode: 0755]
t/perf/perf-lib.sh
t/perf/run
t/t0001-init.sh
t/t0003-attributes.sh
t/t0009-prio-queue.sh [deleted file]
t/t0018-advice.sh
t/t0024-crlf-archive.sh
t/t0035-safe-bare-repository.sh
t/t0070-fundamental.sh
t/t0080-unit-test-output.sh [new file with mode: 0755]
t/t0091-bugreport.sh
t/t0303-credential-external.sh
t/t0410-partial-clone.sh
t/t0600-reffiles-backend.sh [new file with mode: 0755]
t/t0601-reffiles-pack-refs.sh [moved from t/t3210-pack-refs.sh with 81% similarity]
t/t0610-reftable-basics.sh [new file with mode: 0755]
t/t0611-reftable-httpd.sh [new file with mode: 0755]
t/t1091-sparse-checkout-builtin.sh
t/t1300-config.sh
t/t1301-shared-repo.sh
t/t1302-repo-version.sh
t/t1400-update-ref.sh
t/t1401-symbolic-ref.sh
t/t1403-show-ref.sh
t/t1404-update-ref-errors.sh
t/t1405-main-ref-store.sh
t/t1406-submodule-ref-store.sh
t/t1407-worktree-ref-store.sh
t/t1409-avoid-packing-refs.sh
t/t1410-reflog.sh
t/t1414-reflog-walk.sh
t/t1415-worktree-refs.sh
t/t1419-exclude-refs.sh
t/t1430-bad-ref-name.sh
t/t1450-fsck.sh
t/t1500-rev-parse.sh
t/t1503-rev-parse-verify.sh
t/t2011-checkout-invalid-head.sh
t/t2016-checkout-patch.sh
t/t2017-checkout-orphan.sh
t/t2020-checkout-detach.sh
t/t2024-checkout-dwim.sh
t/t2060-switch.sh
t/t2071-restore-patch.sh
t/t2400-worktree-add.sh
t/t3200-branch.sh
t/t3202-show-branch.sh
t/t3400-rebase.sh
t/t3404-rebase-interactive.sh
t/t3407-rebase-abort.sh
t/t3415-rebase-autosquash.sh
t/t3420-rebase-autostash.sh
t/t3422-rebase-incompatible-options.sh
t/t3650-replay-basics.sh [new file with mode: 0755]
t/t3903-stash.sh
t/t3904-stash-patch.sh
t/t4013-diff-various.sh
t/t4014-format-patch.sh
t/t4042-diff-textconv-caching.sh
t/t4129-apply-samemode.sh
t/t4202-log.sh
t/t4207-log-decoration-colors.sh
t/t4301-merge-tree-write-tree.sh
t/t5003-archive-zip.sh
t/t5300-pack-object.sh
t/t5312-prune-corruption.sh
t/t5318-commit-graph.sh
t/t5319-multi-pack-index.sh
t/t5332-multi-pack-reuse.sh [new file with mode: 0755]
t/t5510-fetch.sh
t/t5514-fetch-multiple.sh
t/t5526-fetch-submodules.sh
t/t5541-http-push-smart.sh
t/t5550-http-fetch-dumb.sh
t/t5551-http-fetch-smart.sh
t/t5558-clone-bundle-uri.sh
t/t5601-clone.sh
t/t5605-clone-local.sh
t/t5702-protocol-v2.sh
t/t6022-rev-list-missing.sh
t/t6030-bisect-porcelain.sh
t/t6113-rev-list-bitmap-filters.sh
t/t6135-pathspec-with-attrs.sh
t/t6300-for-each-ref.sh
t/t6302-for-each-ref-filter.sh
t/t6403-merge-file.sh
t/t6406-merge-attr.sh
t/t6429-merge-sequence-rename-caching.sh
t/t6437-submodule-merge.sh
t/t7003-filter-branch.sh
t/t7004-tag.sh
t/t7105-reset-patch.sh
t/t7106-reset-unborn-branch.sh
t/t7300-clean.sh
t/t7402-submodule-rebase.sh
t/t7450-bad-git-dotfiles.sh
t/t7501-commit-basic-functionality.sh
t/t7514-commit-patch.sh
t/t7527-builtin-fsmonitor.sh
t/t7800-difftool.sh
t/t7900-maintenance.sh
t/t9002-column.sh
t/t9133-git-svn-nested-git-repo.sh
t/t9146-git-svn-empty-dirs.sh
t/t9164-git-svn-dcommit-concurrent.sh
t/t9210-scalar.sh
t/t9500-gitweb-standalone-no-errors.sh
t/t9902-completion.sh
t/test-lib-functions.sh
t/test-lib-github-workflow-markup.sh
t/test-lib.sh
t/unit-tests/.gitignore [new file with mode: 0644]
t/unit-tests/t-basic.c [new file with mode: 0644]
t/unit-tests/t-ctype.c [new file with mode: 0644]
t/unit-tests/t-mem-pool.c [new file with mode: 0644]
t/unit-tests/t-prio-queue.c [new file with mode: 0644]
t/unit-tests/t-strbuf.c [new file with mode: 0644]
t/unit-tests/test-lib.c [new file with mode: 0644]
t/unit-tests/test-lib.h [new file with mode: 0644]
t/valgrind/valgrind.sh
transport-helper.c
transport.c
tree-walk.c
upload-pack.c
userdiff.c
worktree.c
worktree.h
wt-status.c

index 4860bebd32f8d3f34c2382f097ac50c0b972d3a0..77346a4929d4eb6af398cbf0761016d8c6d34347 100644 (file)
@@ -1,7 +1,7 @@
 env:
   CIRRUS_CLONE_DEPTH: 1
 
-freebsd_12_task:
+freebsd_task:
   env:
     GIT_PROVE_OPTS: "--timer --jobs 10"
     GIT_TEST_OPTS: "--no-chain-lint --no-bin-wrappers"
@@ -9,7 +9,7 @@ freebsd_12_task:
     DEFAULT_TEST_TARGET: prove
     DEVELOPER: 1
   freebsd_instance:
-    image_family: freebsd-12-3
+    image_family: freebsd-13-2
     memory: 2G
   install_script:
     pkg install -y gettext gmake perl5
@@ -19,4 +19,4 @@ freebsd_12_task:
   build_script:
     - su git -c gmake
   test_script:
-    - su git -c 'gmake test'
+    - su git -c 'gmake DEFAULT_UNIT_TEST_TARGET=unit-tests-prove test unit-tests'
index a58e2dc8ad6279d792635c4034ed0d113d489695..a241a63428bd20e0c28a61ab6de56cbb39966c42 100644 (file)
@@ -19,7 +19,7 @@ jobs:
   check-whitespace:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
       with:
         fetch-depth: 0
 
index e5532d381bcb15cb74a5e4b91927815d489aa0c3..53cf12fe04442561e94f7176eb69c1e8e14a62f3 100644 (file)
@@ -38,7 +38,7 @@ jobs:
       COVERITY_LANGUAGE: cxx
       COVERITY_PLATFORM: overridden-below
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: install minimal Git for Windows SDK
         if: contains(matrix.os, 'windows')
         uses: git-for-windows/setup-git-for-windows-sdk@v1
@@ -98,7 +98,7 @@ jobs:
       # A cache miss will add ~30s to create, but a cache hit will save minutes.
       - name: restore the Coverity Build Tool
         id: cache
-        uses: actions/cache/restore@v3
+        uses: actions/cache/restore@v4
         with:
           path: ${{ runner.temp }}/cov-analysis
           key: cov-build-${{ env.COVERITY_LANGUAGE }}-${{ env.COVERITY_PLATFORM }}-${{ steps.lookup.outputs.hash }}
@@ -141,7 +141,7 @@ jobs:
           esac
       - name: cache the Coverity Build Tool
         if: steps.cache.outputs.cache-hit != 'true'
-        uses: actions/cache/save@v3
+        uses: actions/cache/save@v4
         with:
           path: ${{ runner.temp }}/cov-analysis
           key: cov-build-${{ env.COVERITY_LANGUAGE }}-${{ env.COVERITY_PLATFORM }}-${{ steps.lookup.outputs.hash }}
index 6c3849658aa061b89ced8e0464b3b580519c3a34..e2c3dbdcb50f0cedbf990677e234e7114ecd7746 100644 (file)
@@ -63,9 +63,10 @@ jobs:
             origin \
             ${{ github.ref }} \
             $args
-      - uses: actions/setup-go@v2
+      - uses: actions/setup-go@v5
         with:
           go-version: '>=1.16'
+          cache: false
       - name: Install git-po-helper
         run: go install github.com/git-l10n/git-po-helper@main
       - name: Install other dependencies
@@ -91,14 +92,13 @@ jobs:
           cat git-po-helper.out
           exit $exit_code
       - name: Create comment in pull request for report
-        uses: mshick/add-pr-comment@v1
+        uses: mshick/add-pr-comment@v2
         if: >-
           always() &&
           github.event_name == 'pull_request_target' &&
           env.COMMENT_BODY != ''
         with:
           repo-token: ${{ secrets.GITHUB_TOKEN }}
-          repo-token-user-login: 'github-actions[bot]'
           message: >
             ${{ steps.check-commits.outcome == 'failure' && 'Errors and warnings' || 'Warnings' }}
             found by [git-po-helper](https://github.com/git-l10n/git-po-helper#readme) in workflow
index 9fdbd5402898bf1c8a188bfd24262109c96e5e0f..683a2d633ed5a95f7daab4ffb8ba5cf1ed8d0634 100644 (file)
@@ -63,7 +63,7 @@ jobs:
           echo "skip_concurrent=$skip_concurrent" >>$GITHUB_OUTPUT
       - name: skip if the commit or tree was already tested
         id: skip-if-redundant
-        uses: actions/github-script@v6
+        uses: actions/github-script@v7
         if: steps.check-ref.outputs.enabled == 'yes'
         with:
           github-token: ${{secrets.GITHUB_TOKEN}}
@@ -112,7 +112,7 @@ jobs:
       group: windows-build-${{ github.ref }}
       cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - uses: git-for-windows/setup-git-for-windows-sdk@v1
     - name: build
       shell: bash
@@ -123,7 +123,7 @@ jobs:
     - name: zip up tracked files
       run: git archive -o artifacts/tracked.tar.gz HEAD
     - name: upload tracked files and build artifacts
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       with:
         name: windows-artifacts
         path: artifacts
@@ -140,7 +140,7 @@ jobs:
       cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
     steps:
     - name: download tracked files and build artifacts
-      uses: actions/download-artifact@v3
+      uses: actions/download-artifact@v4
       with:
         name: windows-artifacts
         path: ${{github.workspace}}
@@ -157,7 +157,7 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       with:
         name: failed-tests-windows
         path: ${{env.FAILED_TEST_ARTIFACTS}}
@@ -173,10 +173,10 @@ jobs:
       group: vs-build-${{ github.ref }}
       cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - uses: git-for-windows/setup-git-for-windows-sdk@v1
     - name: initialize vcpkg
-      uses: actions/checkout@v3
+      uses: actions/checkout@v4
       with:
         repository: 'microsoft/vcpkg'
         path: 'compat/vcbuild/vcpkg'
@@ -212,7 +212,7 @@ jobs:
     - name: zip up tracked files
       run: git archive -o artifacts/tracked.tar.gz HEAD
     - name: upload tracked files and build artifacts
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       with:
         name: vs-artifacts
         path: artifacts
@@ -230,7 +230,7 @@ jobs:
     steps:
     - uses: git-for-windows/setup-git-for-windows-sdk@v1
     - name: download tracked files and build artifacts
-      uses: actions/download-artifact@v3
+      uses: actions/download-artifact@v4
       with:
         name: vs-artifacts
         path: ${{github.workspace}}
@@ -248,7 +248,7 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       with:
         name: failed-tests-windows
         path: ${{env.FAILED_TEST_ARTIFACTS}}
@@ -266,6 +266,9 @@ jobs:
           - jobname: linux-sha256
             cc: clang
             pool: ubuntu-latest
+          - jobname: linux-reftable
+            cc: clang
+            pool: ubuntu-latest
           - jobname: linux-gcc
             cc: gcc
             cc_package: gcc-8
@@ -277,6 +280,9 @@ jobs:
           - jobname: osx-clang
             cc: clang
             pool: macos-13
+          - jobname: osx-reftable
+            cc: clang
+            pool: macos-13
           - jobname: osx-gcc
             cc: gcc
             cc_package: gcc-13
@@ -287,6 +293,9 @@ jobs:
           - jobname: linux-leaks
             cc: gcc
             pool: ubuntu-latest
+          - jobname: linux-reftable-leaks
+            cc: gcc
+            pool: ubuntu-latest
           - jobname: linux-asan-ubsan
             cc: clang
             pool: ubuntu-latest
@@ -297,7 +306,7 @@ jobs:
       runs_on_pool: ${{matrix.vector.pool}}
     runs-on: ${{matrix.vector.pool}}
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - run: ci/install-dependencies.sh
     - run: ci/run-build-and-tests.sh
     - name: print test failures
@@ -305,10 +314,21 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       with:
         name: failed-tests-${{matrix.vector.jobname}}
         path: ${{env.FAILED_TEST_ARTIFACTS}}
+  fuzz-smoke-test:
+    name: fuzz smoke test
+    needs: ci-config
+    if: needs.ci-config.outputs.enabled == 'yes'
+    env:
+      CC: clang
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v4
+    - run: ci/install-dependencies.sh
+    - run: ci/run-build-and-minimal-fuzzers.sh
   dockerized:
     name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})
     needs: ci-config
@@ -331,9 +351,9 @@ jobs:
     runs-on: ubuntu-latest
     container: ${{matrix.vector.image}}
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
       if: matrix.vector.jobname != 'linux32'
-    - uses: actions/checkout@v1
+    - uses: actions/checkout@v1 # cannot be upgraded because Node.js Actions aren't supported in this container
       if: matrix.vector.jobname == 'linux32'
     - run: ci/install-docker-dependencies.sh
     - run: ci/run-build-and-tests.sh
@@ -342,13 +362,13 @@ jobs:
       run: ci/print-test-failures.sh
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname != 'linux32'
-      uses: actions/upload-artifact@v3
+      uses: actions/upload-artifact@v4
       with:
         name: failed-tests-${{matrix.vector.jobname}}
         path: ${{env.FAILED_TEST_ARTIFACTS}}
     - name: Upload failed tests' directories
       if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname == 'linux32'
-      uses: actions/upload-artifact@v1
+      uses: actions/upload-artifact@v1 # cannot be upgraded because Node.js Actions aren't supported in this container
       with:
         name: failed-tests-${{matrix.vector.jobname}}
         path: ${{env.FAILED_TEST_ARTIFACTS}}
@@ -362,7 +382,7 @@ jobs:
       group: static-analysis-${{ github.ref }}
       cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - run: ci/install-dependencies.sh
     - run: ci/run-static-analysis.sh
     - run: ci/check-directional-formatting.bash
@@ -385,7 +405,7 @@ jobs:
         artifact: sparse-20.04
     - name: Install the current `sparse` package
       run: sudo dpkg -i sparse-20.04/sparse_*.deb
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - name: Install other dependencies
       run: ci/install-dependencies.sh
     - run: make sparse
@@ -400,6 +420,6 @@ jobs:
       jobname: Documentation
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
+    - uses: actions/checkout@v4
     - run: ci/install-dependencies.sh
     - run: ci/test-documentation.sh
index 5e56e471b344ef45e026847a6865645d61908be7..612c0f6a0ff1aa37415b275424a4e01942f5a2dd 100644 (file)
 /git-remote-ext
 /git-repack
 /git-replace
+/git-replay
 /git-request-pull
 /git-rerere
 /git-reset
index cd98bcb18aa38aca55f577466f7d44f06c50177f..c0fa2fe90b4b81aad0d1ce6f50770cbbbebcebf9 100644 (file)
@@ -7,7 +7,7 @@ workflow:
     - if: $CI_COMMIT_TAG
     - if: $CI_COMMIT_REF_PROTECTED == "true"
 
-test:
+test:linux:
   image: $image
   before_script:
     - ./ci/install-docker-dependencies.sh
@@ -26,6 +26,9 @@ test:
       - jobname: linux-sha256
         image: ubuntu:latest
         CC: clang
+      - jobname: linux-reftable
+        image: ubuntu:latest
+        CC: clang
       - jobname: linux-gcc
         image: ubuntu:20.04
         CC: gcc
@@ -40,6 +43,9 @@ test:
       - jobname: linux-leaks
         image: ubuntu:latest
         CC: gcc
+      - jobname: linux-reftable-leaks
+        image: ubuntu:latest
+        CC: gcc
       - jobname: linux-asan-ubsan
         image: ubuntu:latest
         CC: clang
@@ -51,3 +57,48 @@ test:
     paths:
       - t/failed-test-artifacts
     when: on_failure
+
+test:osx:
+  image: $image
+  tags:
+    - saas-macos-medium-m1
+  variables:
+    TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk"
+  before_script:
+    # Create a 4GB RAM disk that we use to store test output on. This small hack
+    # significantly speeds up tests by more than a factor of 2 because the
+    # macOS runners use network-attached storage as disks, which is _really_
+    # slow with the many small writes that our tests do.
+    - sudo diskutil apfs create $(hdiutil attach -nomount ram://8192000) RAMDisk
+    - ./ci/install-dependencies.sh
+  script:
+    - ./ci/run-build-and-tests.sh
+  after_script:
+    - |
+      if test "$CI_JOB_STATUS" != 'success'
+      then
+        ./ci/print-test-failures.sh
+        mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
+      fi
+  parallel:
+    matrix:
+      - jobname: osx-clang
+        image: macos-13-xcode-14
+        CC: clang
+      - jobname: osx-reftable
+        image: macos-13-xcode-14
+        CC: clang
+  artifacts:
+    paths:
+      - t/failed-test-artifacts
+    when: on_failure
+
+static-analysis:
+  image: ubuntu:22.04
+  variables:
+    jobname: StaticAnalysis
+  before_script:
+    - ./ci/install-docker-dependencies.sh
+  script:
+    - ./ci/run-static-analysis.sh
+    - ./ci/check-directional-formatting.bash
index 578587a47155e929457e12862cd648c9fdf81acd..32e69f798ee7da4174c1f73910c899adf14ca63c 100644 (file)
@@ -446,12 +446,41 @@ For C programs:
    detail.
 
  - The first #include in C files, except in platform specific compat/
-   implementations and sha1dc/, must be either "git-compat-util.h" or
-   one of the approved headers that includes it first for you.  (The
-   approved headers currently include "builtin.h",
-   "t/helper/test-tool.h", "xdiff/xinclude.h", or
-   "reftable/system.h".)  You do not have to include more than one of
-   these.
+   implementations and sha1dc/, must be <git-compat-util.h>.  This
+   header file insulates other header files and source files from
+   platform differences, like which system header files must be
+   included in what order, and what C preprocessor feature macros must
+   be defined to trigger certain features we expect out of the system.
+   A collorary to this is that C files should not directly include
+   system header files themselves.
+
+   There are some exceptions, because certain group of files that
+   implement an API all have to include the same header file that
+   defines the API and it is convenient to include <git-compat-util.h>
+   there.  Namely:
+
+   - the implementation of the built-in commands in the "builtin/"
+     directory that include "builtin.h" for the cmd_foo() prototype
+     definition,
+
+   - the test helper programs in the "t/helper/" directory that include
+     "t/helper/test-tool.h" for the cmd__foo() prototype definition,
+
+   - the xdiff implementation in the "xdiff/" directory that includes
+     "xdiff/xinclude.h" for the xdiff machinery internals,
+
+   - the unit test programs in "t/unit-tests/" directory that include
+     "t/unit-tests/test-lib.h" that gives them the unit-tests
+     framework, and
+
+   - the source files that implement reftable in the "reftable/"
+     directory that include "reftable/system.h" for the reftable
+     internals,
+
+   are allowed to assume that they do not have to include
+   <git-compat-util.h> themselves, as it is included as the first
+   '#include' in these header files.  These headers must be the first
+   header file to be "#include"d in them, though.
 
  - A C file must directly include the header files that declare the
    functions and the types it uses, except for the functions and types
@@ -666,6 +695,11 @@ Writing Documentation:
    <new-branch-name>
    --template=<template-directory>
 
+ When a placeholder is cited in text paragraph, it is enclosed in angle
+ brackets to remind the reader the reference in the synopsis section.
+ For better visibility, the placeholder is typeset in italics:
+   The _<file>_ to be added.
+
  Possibility of multiple occurrences is indicated by three dots:
    <file>...
    (One or more of <file>.)
@@ -751,6 +785,8 @@ Writing Documentation:
    Incorrect:
       `\--pretty=oneline`
 
+A placeholder is not enclosed in backticks, as it is not a literal.
+
  If some place in the documentation needs to typeset a command usage
  example with inline substitutions, it is fine to use +monospaced and
  inline substituted text+ instead of `monospaced literal text`, and with
index b629176d7d2d6776e0a66fbda466915219f32bc2..3f2383a12c77d04f027c64a0b6aed5ad7305e271 100644 (file)
@@ -122,6 +122,7 @@ TECH_DOCS += technical/scalar
 TECH_DOCS += technical/send-pack-pipeline
 TECH_DOCS += technical/shallow
 TECH_DOCS += technical/trivial-merge
+TECH_DOCS += technical/unit-tests
 SP_ARTICLES += $(TECH_DOCS)
 SP_ARTICLES += technical/api-index
 
diff --git a/Documentation/RelNotes/2.44.0.txt b/Documentation/RelNotes/2.44.0.txt
new file mode 100644 (file)
index 0000000..14f9ce8
--- /dev/null
@@ -0,0 +1,334 @@
+Git v2.44 Release Notes
+=======================
+
+Backward Compatibility Notes
+
+ * "git checkout -B <branch>" used to allow switching to a branch that
+   is in use on another worktree, but this was by mistake.  The users
+   need to use "--ignore-other-worktrees" option.
+
+
+UI, Workflows & Features
+
+ * "git add" and "git stash" learned to support the ":(attr:...)"
+   magic pathspec.
+
+ * "git rebase --autosquash" is now enabled for non-interactive rebase,
+   but it is still incompatible with the apply backend.
+
+ * Introduce "git replay", a tool meant on the server side without
+   working tree to recreate a history.
+
+ * "git merge-file" learned to take the "--diff-algorithm" option to
+   use algorithm different from the default "myers" diff.
+
+ * Command line completion (in contrib/) learned to complete path
+   arguments to the "add/set" subcommands of "git sparse-checkout"
+   better.
+
+ * "git checkout -B <branch> [<start-point>]" allowed a branch that is
+   in use in another worktree to be updated and checked out, which
+   might be a bit unexpected.  The rule has been tightened, which is a
+   breaking change.  "--ignore-other-worktrees" option is required to
+   unbreak you, if you are used to the current behaviour that "-B"
+   overrides the safety.
+
+ * The builtin_objectmode attribute is populated for each path
+   without adding anything in .gitattributes files, which would be
+   useful in magic pathspec, e.g., ":(attr:builtin_objectmode=100755)"
+   to limit to executables.
+
+ * "git fetch" learned to pay attention to "fetch.all" configuration
+   variable, which pretends as if "--all" was passed from the command
+   line when no remote parameter was given.
+
+ * In addition to (rather cryptic) Security Identifiers, show username
+   and domain in the error message when we barf on mismatch between
+   the Git directory and the current user on Windows.
+
+ * The error message given when "git branch -d branch" fails due to
+   commits unique to the branch has been split into an error and a new
+   conditional advice message.
+
+ * When given an existing but unreadable file as a configuration file,
+   gitweb behaved as if the file did not exist at all, but now it
+   errors out.  This is a change that may break backward compatibility.
+
+ * When $HOME/.gitconfig is missing but XDG config file is available, we
+   should write into the latter, not former.  "git gc" and "git
+   maintenance" wrote into a wrong "global config" file, which have
+   been corrected.
+
+ * Define "special ref" as a very narrow set that consists of
+   FETCH_HEAD and MERGE_HEAD, and clarify everything else that used to
+   be classified as such are actually just pseudorefs.
+
+ * All conditional "advice" messages show how to turn them off, which
+   becomes repetitive.  Setting advice.* configuration explicitly on
+   now omits the instruction part.
+
+ * The "disable repository discovery of a bare repository" check,
+   triggered by setting safe.bareRepository configuration variable to
+   'explicit', has been loosened to exclude the ".git/" directory inside
+   a non-bare repository from the check.  So you can do "cd .git &&
+   git cmd" to run a Git command that works on a bare repository without
+   explicitly specifying $GIT_DIR now.
+
+ * The completion script (in contrib/) learned more options that can
+   be used with "git log".
+
+ * The labels on conflict markers for the common ancestor, our version,
+   and the other version are available to custom 3-way merge driver
+   via %S, %X, and %Y placeholders.
+
+ * The write codepath for the reftable data learned to honor
+   core.fsync configuration.
+
+ * The "--fsck-objects" option of "git index-pack" now can take the
+   optional parameter to tweak severity of different fsck errors.
+
+ * The wincred credential backend has been taught to support oauth
+   refresh token the same way as credential-cache and
+   credential-libsecret backends.
+
+ * Command line completion support (in contrib/) has been
+   updated for "git bisect".
+
+ * "git branch" and friends learned to use the formatted text as
+   sorting key, not the underlying timestamp value, when the --sort
+   option is used with author or committer timestamp with a format
+   specifier (e.g., "--sort=creatordate:format:%H:%M:%S").
+
+ * The command line completion script (in contrib/) learned to
+   complete configuration variable names better.
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ * Process to add some form of low-level unit tests has started.
+
+ * Add support for GitLab CI.
+
+ * "git for-each-ref --no-sort" still sorted the refs alphabetically
+   which paid non-trivial cost.  It has been redefined to show output
+   in an unspecified order, to allow certain optimizations to take
+   advantage of.
+
+ * Simplify API implementation to delete references by eliminating
+   duplication.
+
+ * Subject approxidate() and show_date() machinery to OSS-Fuzz.
+
+ * A new helper to let us pretend that we called lstat() when we know
+   our cache_entry is up-to-date via fsmonitor.
+
+ * The optimization based on fsmonitor in the "diff --cached"
+   codepath is resurrected with the "fake-lstat" introduced earlier.
+
+ * Test balloon to use C99 "bool" type from <stdbool.h> has been
+   added.
+
+ * "git clone" has been prepared to allow cloning a repository with
+   non-default hash function into a repository that uses the reftable
+   backend.
+
+ * Streaming spans of packfile data used to be done only from a
+   single, primary, pack in a repository with multiple packfiles.  It
+   has been extended to allow reuse from other packfiles, too.
+
+ * Comment updates to help developers not to attempt to modify
+   messages from plumbing commands that must stay constant.
+
+   It might make sense to reassess the plumbing needs every few years,
+   but that should be done as a separate effort.
+
+ * Move test-ctype helper to the unit-test framework.
+
+ * Instead of manually creating refs/ hierarchy on disk upon a
+   creation of a secondary worktree, which is only usable via the
+   files backend, use the refs API to populate it.
+
+ * CI for GitLab learned to drive macOS jobs.
+
+ * A few tests to "git commit -o <pathspec>" and "git commit -i
+   <pathspec>" has been added.
+
+ * Tests on ref API are moved around to prepare for reftable.
+
+ * The Makefile often had to say "-L$(path) -R$(path)" that repeats
+   the path to the same library directory for link time and runtime.
+   A Makefile template is used to reduce such repetition.
+
+ * The priority queue test has been migrated to the unit testing
+   framework.
+
+ * Setting `feature.experimental` opts the user into multi-pack reuse
+   experiment
+
+ * Squelch node.js 16 deprecation warnings from GitHub Actions CI
+   by updating actions/github-script and actions/checkout that use
+   node.js 20.
+
+ * The mechanism to report the filename in the source code, used by
+   the unit-test machinery, assumed that the compiler expanded __FILE__
+   to the path to the source given to the $(CC), but some compilers
+   give full path, breaking the output.  This has been corrected.
+
+
+Fixes since v2.43
+-----------------
+
+ * The way CI testing used "prove" could lead to running the test
+   suite twice needlessly, which has been corrected.
+
+ * Update ref-related tests.
+
+ * "git format-patch --encode-email-headers" ignored the option when
+   preparing the cover letter, which has been corrected.
+
+ * Newer versions of Getopt::Long started giving warnings against our
+   (ab)use of it in "git send-email".  Bump the minimum version
+   requirement for Perl to 5.8.1 (from September 2002) to allow
+   simplifying our implementation.
+
+ * Earlier we stopped relying on commit-graph that (still) records
+   information about commits that are lost from the object store,
+   which has negative performance implications.  The default has been
+   flipped to disable this pessimization.
+
+ * Stale URLs have been updated to their current counterparts (or
+   archive.org) and HTTP links are replaced with working HTTPS links.
+
+ * trace2 streams used to record the URLs that potentially embed
+   authentication material, which has been corrected.
+
+ * The sample pre-commit hook that tries to catch introduction of new
+   paths that use potentially non-portable characters did not notice
+   an existing path getting renamed to such a problematic path, when
+   rename detection was enabled.
+
+ * The command line parser for the "log" family of commands was too
+   loose when parsing certain numbers, e.g., silently ignoring the
+   extra 'q' in "git log -n 1q" without complaining, which has been
+   tightened up.
+
+ * "git $cmd --end-of-options --rev -- --path" for some $cmd failed
+   to interpret "--rev" as a rev, and "--path" as a path.  This was
+   fixed for many programs like "reset" and "checkout".
+
+ * "git bisect reset" has been taught to clean up state files and refs
+   even when BISECT_START file is gone.
+
+ * Some codepaths did not correctly parse configuration variables
+   specified with valueless "true", which has been corrected.
+
+ * Code clean-up for sanity checking of command line options for "git
+   show-ref".
+
+ * The code to parse the From e-mail header has been updated to avoid
+   recursion.
+
+ * "git fetch --atomic" issued an unnecessary empty error message,
+   which has been corrected.
+
+ * Command line completion script (in contrib/) learned to work better
+   with the reftable backend.
+
+ * "git status" is taught to show both the branch being bisected and
+   being rebased when both are in effect at the same time.
+
+ * "git archive --list extra garbage" silently ignored excess command
+   line parameters, which has been corrected.
+
+ * "git sparse-checkout set" added default patterns even when the
+   patterns are being fed from the standard input, which has been
+   corrected.
+
+ * "git sparse-checkout (add|set) --[no-]cone --end-of-options" did
+   not handle "--end-of-options" correctly after a recent update.
+
+ * Unlike other environment variables that took the usual
+   true/false/yes/no as well as 0/1, GIT_FLUSH only understood 0/1,
+   which has been corrected.
+
+ * Clearing in-core repository (happens during e.g., "git fetch
+   --recurse-submodules" with commit graph enabled) made in-core
+   commit object in an inconsistent state by discarding the necessary
+   data from commit-graph too early, which has been corrected.
+
+ * Update to a new feature recently added, "git show-ref --exists".
+
+ * oss-fuzz tests are built and run in CI.
+   (merge c4a9cf1df3 js/oss-fuzz-build-in-ci later to maint).
+
+ * Rename detection logic ignored the final line of a file if it is an
+   incomplete line.
+
+ * GitHub CI update.
+   (merge 0188b2c8e0 pb/ci-github-skip-logs-for-broken-tests later to maint).
+
+ * "git diff --no-rename A B" did not disable rename detection but did
+   not trigger an error from the command line parser.
+
+ * "git archive --remote=<remote>" learned to talk over the smart
+   http (aka stateless) transport.
+   (merge 176cd68634 jx/remote-archive-over-smart-http later to maint).
+
+ * Fetching via protocol v0 over Smart HTTP transport sometimes failed
+   to correctly auto-follow tags.
+   (merge fba732c462 jk/fetch-auto-tag-following-fix later to maint).
+
+ * The documentation for the --exclude-per-directory option marked it
+   as deprecated, which confused readers into thinking there may be a
+   plan to remove it in the future, which was not our intention.
+   (merge 0009542cab jc/ls-files-doc-update later to maint).
+
+ * "git diff --no-index file1 file2" segfaulted while invoking the
+   external diff driver, which has been corrected.
+
+ * Rewrite //-comments to /* comments */ in files whose comments
+   prevalently use the latter.
+
+ * Cirrus CI jobs started breaking because we specified version of
+   FreeBSD that is no longer available, which has been corrected.
+   (merge 81fffb66d3 cb/use-freebsd-13-2-at-cirrus-ci later to maint).
+
+ * A caller called index_file_exists() that takes a string expressed
+   as <ptr, length> with a wrong length, which has been corrected.
+   (merge 156e28b36d jh/sparse-index-expand-to-path-fix later to maint).
+
+ * A failed "git tag -s" did not necessarily result in an error
+   depending on the crypto backend, which has been corrected.
+
+ * "git stash" sometimes was silent even when it failed due to
+   unwritable index file, which has been corrected.
+
+ * "git show-ref --verify" did not show things like "CHERRY_PICK_HEAD",
+   which has been corrected.
+
+ * Recent conversion to allow more than 0/1 in GIT_FLUSH broke the
+   mechanism by flipping what yes/no means by mistake, which has been
+   corrected.
+
+ * The sequencer machinery does not use the ref API and instead
+   records names of certain objects it needs for its correct operation
+   in temporary files, which makes these objects susceptible to loss
+   by garbage collection.  These temporary files have been added as
+   starting points for reachability analysis to fix this.
+   (merge bc7f5db896 pw/gc-during-rebase later to maint).
+
+ * "git cherry-pick" invoked during "git rebase -i" session lost
+   the authorship information, which has been corrected.
+   (merge e4301f73ff vn/rebase-with-cherry-pick-authorship later to maint).
+
+ * The code paths that call repo_read_object_file() have been
+   tightened to react to errors.
+   (merge 568459bf5e js/check-null-from-read-object-file later to maint).
+
+ * Other code cleanup, docfix, build fix, etc.
+   (merge 5aea3955bc rj/clarify-branch-doc-m later to maint).
+   (merge 9cce3be2df bk/bisect-doc-fix later to maint).
+   (merge 8430b438f6 vd/fsck-submodule-url-test later to maint).
+   (merge 3cb4384683 jc/t0091-with-unknown-git later to maint).
+   (merge 020456cb74 rs/receive-pack-remove-find-header later to maint).
+   (merge bc47139f4f la/trailer-cleanups later to maint).
diff --git a/Documentation/RelNotes/2.45.0.txt b/Documentation/RelNotes/2.45.0.txt
new file mode 100644 (file)
index 0000000..fe8832b
--- /dev/null
@@ -0,0 +1,110 @@
+Git v2.45 Release Notes
+=======================
+
+Backward Compatibility Notes
+
+UI, Workflows & Features
+
+ * Integrate the reftable code into the refs framework as a backend.
+   With "git init --ref-format=reftable", hopefully it would be a lot
+   more efficient to manage a repository with many references.
+
+ * "git checkout -p" and friends learned that that "@" is a synonym
+   for "HEAD".
+
+ * Variants of vimdiff learned to honor mergetool.<variant>.layout
+   settings.
+
+ * "git reflog" learned a "list" subcommand that enumerates known reflogs.
+
+ * When a merge conflicted at a submodule, merge-ort backend used to
+   unconditionally give a lengthy message to suggest how to resolve
+   it.  Now the message can be squelched as an advice message.
+
+ * "git for-each-ref" learned "--include-root-refs" option to show
+   even the stuff outside the 'refs/' hierarchy.
+
+
+Performance, Internal Implementation, Development Support etc.
+
+ * The code to iterate over refs with the reftable backend has seen
+   some optimization.
+
+ * More tests that are marked as "ref-files only" have been updated to
+   improve test coverage of reftable backend.
+
+ * Some parts of command line completion script (in contrib/) have
+   been micro-optimized.
+
+ * The way placeholders are to be marked-up in documentation have been
+   specified; use "_<placeholder>_" to typeset the word inside a pair
+   of <angle-brakets> emphasized.
+
+
+Fixes since v2.44
+-----------------
+
+ * "git apply" on a filesystem without filemode support have learned
+   to take a hint from what is in the index for the path, even when
+   not working with the "--index" or "--cached" option, when checking
+   the executable bit match what is required by the preimage in the
+   patch.
+   (merge 45b625142d cp/apply-core-filemode later to maint).
+
+ * "git column" has been taught to reject negative padding value, as
+   it would lead to nonsense behaviour including division by zero.
+   (merge 76fb807faa kh/column-reject-negative-padding later to maint).
+
+ * "git am --help" now tells readers what actions are available in
+   "git am --whitespace=<action>", in addition to saying that the
+   option is passed through to the underlying "git apply".
+   (merge a171dac734 jc/am-whitespace-doc later to maint).
+
+ * "git tag --column" failed to check the exit status of its "git
+   column" invocation, which has been corrected.
+   (merge 92e66478fc rj/tag-column-fix later to maint).
+
+ * Credential helper based on libsecret (in contrib/) has been updated
+   to handle an empty password correctly.
+   (merge 8f1f2023b7 mh/libsecret-empty-password-fix later to maint).
+
+ * "git difftool --dir-diff" learned to honor the "--trust-exit-code"
+   option; it used to always exit with 0 and signalled success.
+   (merge eb84c8b6ce ps/difftool-dir-diff-exit-code later to maint).
+
+ * The code incorrectly attempted to use textconv cache when asked,
+   even when we are not running in a repository, which has been
+   corrected.
+   (merge affe355fe7 jk/textconv-cache-outside-repo-fix later to maint).
+
+ * Remove an empty file that shouldn't have been added in the first
+   place.
+   (merge 4f66942215 js/remove-cruft-files later to maint).
+
+ * The logic to access reflog entries by date and number had ugly
+   corner cases at the boundaries, which have been cleaned up.
+   (merge 5edd126720 jk/reflog-special-cases-fix later to maint).
+
+ * An error message from "git upload-pack", which responds to "git
+   fetch" requests, had a trialing NUL in it, which has been
+   corrected.
+   (merge 3f4c7a0805 sg/upload-pack-error-message-fix later to maint).
+
+ * Clarify wording in the CodingGuidelines that requires <git-compat-util.h>
+   to be the first header file.
+   (merge 4e89f0e07c jc/doc-compat-util later to maint).
+
+ * Other code cleanup, docfix, build fix, etc.
+   (merge f0e578c69c rs/use-xstrncmpz later to maint).
+   (merge 83e6eb7d7a ba/credential-test-clean-fix later to maint).
+   (merge 64562d784d jb/doc-interactive-singlekey-do-not-need-perl later to maint).
+   (merge c431a235e2 cp/t9146-use-test-path-helpers later to maint).
+   (merge 82d75402d5 ds/doc-send-email-capitalization later to maint).
+   (merge 41bff66e35 jc/doc-add-placeholder-fix later to maint).
+   (merge 6835f0efe9 jw/remote-doc-typofix later to maint).
+   (merge 244001aa20 hs/rebase-not-in-progress later to maint).
+   (merge 2ca6c07db2 jc/no-include-of-compat-util-from-headers later to maint).
+   (merge 87bd7fbb9c rs/fetch-simplify-with-starts-with later to maint).
+   (merge f39addd0d9 rs/name-rev-with-mempool later to maint).
+   (merge 9a97b43e03 rs/submodule-prefix-simplify later to maint).
+   (merge 40b8076462 ak/rebase-autosquash later to maint).
index 4d7e5d875998fe1c3aa20c0bb5efdcf9fb6fad91..dde8e7840ef38225995549411fbcf9305b160c37 100644 (file)
@@ -1,30 +1,63 @@
 advice.*::
        These variables control various optional help messages designed to
-       aid new users. All 'advice.*' variables default to 'true', and you
-       can tell Git that you do not need help by setting these to 'false':
+       aid new users.  When left unconfigured, Git will give the message
+       alongside instructions on how to squelch it.  You can tell Git
+       that you do not need the help message by setting these to 'false':
 +
 --
+       addEmbeddedRepo::
+               Advice on what to do when you've accidentally added one
+               git repo inside of another.
+       addEmptyPathspec::
+               Advice shown if a user runs the add command without providing
+               the pathspec parameter.
+       addIgnoredFile::
+               Advice shown if a user attempts to add an ignored file to
+               the index.
+       amWorkDir::
+               Advice that shows the location of the patch file when
+               linkgit:git-am[1] fails to apply it.
        ambiguousFetchRefspec::
                Advice shown when a fetch refspec for multiple remotes maps to
                the same remote-tracking branch namespace and causes branch
                tracking set-up to fail.
+       checkoutAmbiguousRemoteBranchName::
+               Advice shown when the argument to
+               linkgit:git-checkout[1] and linkgit:git-switch[1]
+               ambiguously resolves to a
+               remote tracking branch on more than one remote in
+               situations where an unambiguous argument would have
+               otherwise caused a remote-tracking branch to be
+               checked out. See the `checkout.defaultRemote`
+               configuration variable for how to set a given remote
+               to be used by default in some situations where this
+               advice would be printed.
+       commitBeforeMerge::
+               Advice shown when linkgit:git-merge[1] refuses to
+               merge to avoid overwriting local changes.
+       detachedHead::
+               Advice shown when you used
+               linkgit:git-switch[1] or linkgit:git-checkout[1]
+               to move to the detached HEAD state, to instruct how to
+               create a local branch after the fact.
+       diverging::
+               Advice shown when a fast-forward is not possible.
        fetchShowForcedUpdates::
                Advice shown when linkgit:git-fetch[1] takes a long time
                to calculate forced updates after ref updates, or to warn
                that the check is disabled.
-       pushUpdateRejected::
-               Set this variable to 'false' if you want to disable
-               'pushNonFFCurrent', 'pushNonFFMatching', 'pushAlreadyExists',
-               'pushFetchFirst', 'pushNeedsForce', and 'pushRefNeedsUpdate'
-               simultaneously.
-       pushNonFFCurrent::
-               Advice shown when linkgit:git-push[1] fails due to a
-               non-fast-forward update to the current branch.
-       pushNonFFMatching::
-               Advice shown when you ran linkgit:git-push[1] and pushed
-               'matching refs' explicitly (i.e. you used ':', or
-               specified a refspec that isn't your current branch) and
-               it resulted in a non-fast-forward error.
+       forceDeleteBranch::
+               Advice shown when a user tries to delete a not fully merged
+               branch without the force option set.
+       ignoredHook::
+               Advice shown if a hook is ignored because the hook is not
+               set as executable.
+       implicitIdentity::
+               Advice on how to set your identity configuration when
+               your information is guessed from the system username and
+               domain name.
+       nestedTag::
+               Advice shown if a user attempts to recursively tag a tag object.
        pushAlreadyExists::
                Shown when linkgit:git-push[1] rejects an update that
                does not qualify for fast-forwarding (e.g., a tag.)
@@ -37,6 +70,18 @@ advice.*::
                tries to overwrite a remote ref that points at an
                object that is not a commit-ish, or make the remote
                ref point at an object that is not a commit-ish.
+       pushNonFFCurrent::
+               Advice shown when linkgit:git-push[1] fails due to a
+               non-fast-forward update to the current branch.
+       pushNonFFMatching::
+               Advice shown when you ran linkgit:git-push[1] and pushed
+               'matching refs' explicitly (i.e. you used ':', or
+               specified a refspec that isn't your current branch) and
+               it resulted in a non-fast-forward error.
+       pushRefNeedsUpdate::
+               Shown when linkgit:git-push[1] rejects a forced update of
+               a branch when its remote-tracking ref has updates that we
+               do not have locally.
        pushUnqualifiedRefname::
                Shown when linkgit:git-push[1] gives up trying to
                guess based on the source and destination refs what
@@ -44,10 +89,23 @@ advice.*::
                we can still suggest that the user push to either
                refs/heads/* or refs/tags/* based on the type of the
                source object.
-       pushRefNeedsUpdate::
-               Shown when linkgit:git-push[1] rejects a forced update of
-               a branch when its remote-tracking ref has updates that we
-               do not have locally.
+       pushUpdateRejected::
+               Set this variable to 'false' if you want to disable
+               'pushNonFFCurrent', 'pushNonFFMatching', 'pushAlreadyExists',
+               'pushFetchFirst', 'pushNeedsForce', and 'pushRefNeedsUpdate'
+               simultaneously.
+       resetNoRefresh::
+               Advice to consider using the `--no-refresh` option to
+               linkgit:git-reset[1] when the command takes more than 2 seconds
+               to refresh the index after reset.
+       resolveConflict::
+               Advice shown by various commands when conflicts
+               prevent the operation from being performed.
+       rmHints::
+               In case of failure in the output of linkgit:git-rm[1],
+               show directions on how to proceed from the current state.
+       sequencerInUse::
+               Advice shown when a sequencer command is already in progress.
        skippedCherryPicks::
                Shown when linkgit:git-rebase[1] skips a commit that has already
                been cherry-picked onto the upstream branch.
@@ -68,76 +126,25 @@ advice.*::
                Advise to consider using the `-u` option to linkgit:git-status[1]
                when the command takes more than 2 seconds to enumerate untracked
                files.
-       commitBeforeMerge::
-               Advice shown when linkgit:git-merge[1] refuses to
-               merge to avoid overwriting local changes.
-       resetNoRefresh::
-               Advice to consider using the `--no-refresh` option to
-               linkgit:git-reset[1] when the command takes more than 2 seconds
-               to refresh the index after reset.
-       resolveConflict::
-               Advice shown by various commands when conflicts
-               prevent the operation from being performed.
-       sequencerInUse::
-               Advice shown when a sequencer command is already in progress.
-       implicitIdentity::
-               Advice on how to set your identity configuration when
-               your information is guessed from the system username and
-               domain name.
-       detachedHead::
-               Advice shown when you used
-               linkgit:git-switch[1] or linkgit:git-checkout[1]
-               to move to the detached HEAD state, to instruct how to
-               create a local branch after the fact.
-       suggestDetachingHead::
-               Advice shown when linkgit:git-switch[1] refuses to detach HEAD
-               without the explicit `--detach` option.
-       checkoutAmbiguousRemoteBranchName::
-               Advice shown when the argument to
-               linkgit:git-checkout[1] and linkgit:git-switch[1]
-               ambiguously resolves to a
-               remote tracking branch on more than one remote in
-               situations where an unambiguous argument would have
-               otherwise caused a remote-tracking branch to be
-               checked out. See the `checkout.defaultRemote`
-               configuration variable for how to set a given remote
-               to be used by default in some situations where this
-               advice would be printed.
-       amWorkDir::
-               Advice that shows the location of the patch file when
-               linkgit:git-am[1] fails to apply it.
-       rmHints::
-               In case of failure in the output of linkgit:git-rm[1],
-               show directions on how to proceed from the current state.
-       addEmbeddedRepo::
-               Advice on what to do when you've accidentally added one
-               git repo inside of another.
-       ignoredHook::
-               Advice shown if a hook is ignored because the hook is not
-               set as executable.
-       waitingForEditor::
-               Print a message to the terminal whenever Git is waiting for
-               editor input from the user.
-       nestedTag::
-               Advice shown if a user attempts to recursively tag a tag object.
        submoduleAlternateErrorStrategyDie::
                Advice shown when a submodule.alternateErrorStrategy option
                configured to "die" causes a fatal error.
+       submoduleMergeConflict::
+               Advice shown when a non-trivial submodule merge conflict is
+               encountered.
        submodulesNotUpdated::
                Advice shown when a user runs a submodule command that fails
                because `git submodule update --init` was not run.
-       addIgnoredFile::
-               Advice shown if a user attempts to add an ignored file to
-               the index.
-       addEmptyPathspec::
-               Advice shown if a user runs the add command without providing
-               the pathspec parameter.
+       suggestDetachingHead::
+               Advice shown when linkgit:git-switch[1] refuses to detach HEAD
+               without the explicit `--detach` option.
        updateSparsePath::
                Advice shown when either linkgit:git-add[1] or linkgit:git-rm[1]
                is asked to update index entries outside the current sparse
                checkout.
-       diverging::
-               Advice shown when a fast-forward is not possible.
+       waitingForEditor::
+               Print a message to the terminal whenever Git is waiting for
+               editor input from the user.
        worktreeAddOrphan::
                Advice shown when a user tries to create a worktree from an
                invalid reference, to instruct how to create a new unborn
index bd5ae0c3378adbd5661a202dc1f8fcfbf27ac4a1..6c7e09a1ef5eb481b2abb26abd93edf38806cf76 100644 (file)
@@ -223,5 +223,5 @@ diff.colorMoved::
 
 diff.colorMovedWS::
        When moved lines are colored using e.g. the `diff.colorMoved` setting,
-       this option controls the `<mode>` how spaces are treated
-       for details of valid modes see '--color-moved-ws' in linkgit:git-diff[1].
+       this option controls the `<mode>` how spaces are treated.
+       For details of valid modes see '--color-moved-ws' in linkgit:git-diff[1].
index bccaec7a963679f8262d7c8d056fa4429b9586d1..66db0e15da7db82819de941626b7abc5983862c5 100644 (file)
@@ -7,6 +7,17 @@ Note that this setting should only be set by linkgit:git-init[1] or
 linkgit:git-clone[1].  Trying to change it after initialization will not
 work and will produce hard-to-diagnose issues.
 
+extensions.refStorage::
+       Specify the ref storage format to use. The acceptable values are:
++
+include::../ref-storage-format.txt[]
++
+It is an error to specify this key unless `core.repositoryFormatVersion` is 1.
++
+Note that this setting should only be set by linkgit:git-init[1] or
+linkgit:git-clone[1]. Trying to change it after initialization will not
+work and will produce hard-to-diagnose issues.
+
 extensions.worktreeConfig::
        If enabled, then worktrees will load config settings from the
        `$GIT_DIR/config.worktree` file in addition to the
index bf9546fca4f693f01b39252d12def7df9b51a52f..f061b64b7484497a43fba7aaac67c7f84b012582 100644 (file)
@@ -17,6 +17,9 @@ skipping more commits at a time, reducing the number of round trips.
 +
 * `pack.useBitmapBoundaryTraversal=true` may improve bitmap traversal times by
 walking fewer objects.
++
+* `pack.allowPackReuse=multi` may improve the time it takes to create a pack by
+reusing objects from multiple packs instead of just one.
 
 feature.manyFiles::
        Enable config options that optimize for repos with many files in the
index aea5b97477b64ef664b6b35faad78b2eb618db9a..d7dc461bd16ad782933a40e060c523b063cb1aca 100644 (file)
@@ -50,6 +50,12 @@ fetch.pruneTags::
        refs. See also `remote.<name>.pruneTags` and the PRUNING
        section of linkgit:git-fetch[1].
 
+fetch.all::
+       If true, fetch will attempt to update all available remotes.
+       This behavior can be overridden by passing `--no-all` or by
+       explicitly specifying one or more remote(s) to fetch from.
+       Defaults to false.
+
 fetch.output::
        Control how ref update status is printed. Valid values are
        `full` and `compact`. Default value is `full`. See the
index a2d3c7ec449e9b943a71f21891c2fd733a695dfc..5cc26555f19a4ff8f8a290a5316bfdd07b506e77 100644 (file)
@@ -4,9 +4,7 @@ interactive.singleKey::
        Currently this is used by the `--patch` mode of
        linkgit:git-add[1], linkgit:git-checkout[1],
        linkgit:git-restore[1], linkgit:git-commit[1],
-       linkgit:git-reset[1], and linkgit:git-stash[1]. Note that this
-       setting is silently ignored if portable keystroke input
-       is not available; requires the Perl module Term::ReadKey.
+       linkgit:git-reset[1], and linkgit:git-stash[1].
 
 interactive.diffFilter::
        When an interactive command (such as `git add --patch`) shows
index 294f61efd12fdf863e648b076462f4a9a1aa75b7..00bf665aa09bf353dd2c81220d2c83a31086e5b7 100644 (file)
@@ -45,14 +45,21 @@ mergetool.meld.useAutoMerge::
        value of `false` avoids using `--auto-merge` altogether, and is the
        default value.
 
-mergetool.vimdiff.layout::
-       The vimdiff backend uses this variable to control how its split
-       windows appear. Applies even if you are using Neovim (`nvim`) or
-       gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section
+mergetool.<vimdiff variant>.layout::
+       Configure the split window layout for vimdiff's `<variant>`, which is any of `vimdiff`,
+       `nvimdiff`, `gvimdiff`.
+       Upon launching `git mergetool` with `--tool=<variant>` (or without `--tool`
+       if `merge.tool` is configured as `<variant>`), Git will consult
+       `mergetool.<variant>.layout` to determine the tool's layout. If the
+       variant-specific configuration is not available, `vimdiff`'s is used as
+       fallback.  If that too is not available, a default layout with 4 windows
+       will be used.  To configure the layout, see the `BACKEND SPECIFIC HINTS`
+ifdef::git-mergetool[]
+       section.
+endif::[]
 ifndef::git-mergetool[]
-       in linkgit:git-mergetool[1].
+       section in linkgit:git-mergetool[1].
 endif::[]
-       for details.
 
 mergetool.hideResolved::
        During a merge, Git will automatically resolve as many conflicts as
index f50df9dbce89891f0c6d4a5563c5ab73be4325df..da527377fafcb629108676ed0becc489ed25095a 100644 (file)
@@ -28,11 +28,16 @@ all existing objects. You can force recompression by passing the -F option
 to linkgit:git-repack[1].
 
 pack.allowPackReuse::
-       When true, and when reachability bitmaps are enabled,
-       pack-objects will try to send parts of the bitmapped packfile
-       verbatim. This can reduce memory and CPU usage to serve fetches,
-       but might result in sending a slightly larger pack. Defaults to
-       true.
+       When true or "single", and when reachability bitmaps are
+       enabled, pack-objects will try to send parts of the bitmapped
+       packfile verbatim. When "multi", and when a multi-pack
+       reachability bitmap is available, pack-objects will try to send
+       parts of all packs in the MIDX.
++
+If only a single pack bitmap is available, and `pack.allowPackReuse`
+is set to "multi", reuse parts of just the bitmapped packfile. This
+can reduce memory and CPU usage to serve fetches, but might result in
+sending a slightly larger pack. Defaults to true.
 
 pack.island::
        An extended regular expression configuring a set of delta
index 7c57c5ee80fbe0770c2847371a2b1dd649d35ab8..c6187ab28b2fb731fad341c7d3c193872558645d 100644 (file)
@@ -9,7 +9,9 @@ rebase.stat::
        rebase. False by default.
 
 rebase.autoSquash::
-       If set to true enable `--autosquash` option by default.
+       If set to true, enable the `--autosquash` option of
+       linkgit:git-rebase[1] by default for interactive mode.
+       This can be overridden with the `--no-autosquash` option.
 
 rebase.autoStash::
        When set to true, automatically create a temporary stash entry
index 7fc770ee9e69d77b3743c8bff1b8bef35bb96f36..6a869d67eb90c9992a1cbcf3efb372d3a6fb2f40 100644 (file)
@@ -8,7 +8,7 @@ sendemail.smtpEncryption::
        See linkgit:git-send-email[1] for description.  Note that this
        setting is not subject to the 'identity' mechanism.
 
-sendemail.smtpsslcertpath::
+sendemail.smtpSSLCertPath::
        Path to ca-certificates (either a directory or a single file).
        Set it to an empty string to disable certificate verification.
 
@@ -62,12 +62,12 @@ sendemail.chainReplyTo::
 sendemail.envelopeSender::
 sendemail.from::
 sendemail.headerCmd::
-sendemail.signedoffbycc::
+sendemail.signedOffByCc::
 sendemail.smtpPass::
-sendemail.suppresscc::
+sendemail.suppressCc::
 sendemail.suppressFrom::
 sendemail.to::
-sendemail.tocmd::
+sendemail.toCmd::
 sendemail.smtpDomain::
 sendemail.smtpServer::
 sendemail.smtpServerPort::
@@ -81,8 +81,8 @@ sendemail.xmailer::
        linkgit:git-send-email[1] command-line options. See its
        documentation for details.
 
-sendemail.signedoffcc (deprecated)::
-       Deprecated alias for `sendemail.signedoffbycc`.
+sendemail.signedOffCc (deprecated)::
+       Deprecated alias for `sendemail.signedOffByCc`.
 
 sendemail.smtpBatchSize::
        Number of messages to be sent per connection, after that a relogin
index 53ec3c9a3476bd12b8a8f4b6c31552b2767d8366..aaaff0d46f0c6f04ca4e3182872b47d2bd2f07b6 100644 (file)
@@ -299,7 +299,7 @@ and accumulating child directory counts in the parent directories:
        Synonym for --dirstat=cumulative
 
 --dirstat-by-file[=<param1,param2>...]::
-       Synonym for --dirstat=files,param1,param2...
+       Synonym for --dirstat=files,<param1>,<param2>...
 
 --summary::
        Output a condensed summary of extended header information
index a1d6633a4f15b719a33615ca0ce2805ec2fa0b3e..54ebb4452e997f8c62c9dd2421948086249102bd 100644 (file)
@@ -1,5 +1,6 @@
---all::
-       Fetch all remotes.
+--[no-]all::
+       Fetch all remotes. This overrides the configuration variable
+       `fetch.all`.
 
 -a::
 --append::
index 3d2e6707168b69d591e3bf2a50abe3a62fc2ee23..14a371fff3569eac4fd633ebc945b1d8793b1237 100644 (file)
@@ -63,7 +63,7 @@ OPTIONS
        to ignore removed files; use `--no-all` option if you want
        to add modified or new files but ignore removed ones.
 +
-For more details about the <pathspec> syntax, see the 'pathspec' entry
+For more details about the _<pathspec>_ syntax, see the 'pathspec' entry
 in linkgit:gitglossary[7].
 
 -n::
@@ -119,10 +119,10 @@ apply to the index. See EDITING PATCHES below.
 -u::
 --update::
        Update the index just where it already has an entry matching
-       <pathspec>.  This removes as well as modifies index entries to
+       _<pathspec>_.  This removes as well as modifies index entries to
        match the working tree, but adds no new files.
 +
-If no <pathspec> is given when `-u` option is used, all
+If no _<pathspec>_ is given when `-u` option is used, all
 tracked files in the entire working tree are updated (old versions
 of Git used to limit the update to the current directory and its
 subdirectories).
@@ -131,11 +131,11 @@ subdirectories).
 --all::
 --no-ignore-removal::
        Update the index not only where the working tree has a file
-       matching <pathspec> but also where the index already has an
+       matching _<pathspec>_ but also where the index already has an
        entry. This adds, modifies, and removes index entries to
        match the working tree.
 +
-If no <pathspec> is given when `-A` option is used, all
+If no _<pathspec>_ is given when `-A` option is used, all
 files in the entire working tree are updated (old versions
 of Git used to limit the update to the current directory and its
 subdirectories).
@@ -145,11 +145,11 @@ subdirectories).
        Update the index by adding new files that are unknown to the
        index and files modified in the working tree, but ignore
        files that have been removed from the working tree.  This
-       option is a no-op when no <pathspec> is used.
+       option is a no-op when no _<pathspec>_ is used.
 +
 This option is primarily to help users who are used to older
-versions of Git, whose "git add <pathspec>..." was a synonym
-for "git add --no-all <pathspec>...", i.e. ignored removed files.
+versions of Git, whose "git add _<pathspec>_..." was a synonym
+for "git add --no-all _<pathspec>_...", i.e. ignored removed files.
 
 -N::
 --intent-to-add::
@@ -198,8 +198,8 @@ for "git add --no-all <pathspec>...", i.e. ignored removed files.
        unchanged.
 
 --pathspec-from-file=<file>::
-       Pathspec is passed in `<file>` instead of commandline args. If
-       `<file>` is exactly `-` then standard input is used. Pathspec
+       Pathspec is passed in _<file>_ instead of commandline args. If
+       _<file>_ is exactly `-` then standard input is used. Pathspec
        elements are separated by LF or CR/LF. Pathspec elements can be
        quoted as explained for the configuration variable `core.quotePath`
        (see linkgit:git-config[1]). See also `--pathspec-file-nul` and
index e080458d6c45891ec1db74b9df155aeab111e79f..463a3c660024e08b494caa3e22b4d4c417f46e0c 100644 (file)
@@ -128,6 +128,9 @@ include::rerere-options.txt[]
        These flags are passed to the 'git apply' (see linkgit:git-apply[1])
        program that applies
        the patch.
++
+Valid <action> for the `--whitespace` option are:
+`nowarn`, `warn`, `fix`, `error`, and `error-all`.
 
 --patch-format::
        By default the command will try to detect the patch format
index a0e75a62393d141b69c7dc2dbf2f417f795ed2fd..82f944dc03dffccae2425cb3a250d681ad3ed134 100644 (file)
@@ -17,7 +17,7 @@ The command takes various subcommands, and different options depending
 on the subcommand:
 
  git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]
-                 [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]
+                 [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]
  git bisect (bad|new|<term-new>) [<rev>]
  git bisect (good|old|<term-old>) [<rev>...]
  git bisect terms [--term-(good|old) | --term-(bad|new)]
@@ -301,7 +301,7 @@ Cutting down bisection by giving more parameters to bisect start
 
 You can further cut down the number of trials, if you know what part of
 the tree is involved in the problem you are tracking down, by specifying
-path parameters when issuing the `bisect start` command:
+pathspec parameters when issuing the `bisect start` command:
 
 ------------
 $ git bisect start -- arch/i386 include/asm-i386
index 5720d04ffe4e7434c1798cad4833e233fc71f534..b1d7fb539d021664111276e33ed16dfcd2a91f3c 100644 (file)
@@ -210,7 +210,7 @@ annotated.
 
 . Each blame entry always starts with a line of:
 
-       <40-byte hex sha1> <sourceline> <resultline> <num_lines>
+       <40-byte-hex-sha1> <sourceline> <resultline> <num-lines>
 +
 Line numbers count from 1.
 
index 4395aa935438aaac47cfe41f5db7a1eadafe8a25..0b08442932354fcdcbb321f0c45b80a3a5bc4fdf 100644 (file)
@@ -312,7 +312,8 @@ superproject's "origin/main", but tracks the submodule's "origin/main".
        option is omitted, the current HEAD will be used instead.
 
 <oldbranch>::
-       The name of an existing branch to rename.
+       The name of an existing branch.  If this option is omitted,
+       the name of the current branch will be used instead.
 
 <newbranch>::
        The new name for an existing branch. The same restrictions as for
index 392d9eb6aec6b0d43930c93a322f415dc75b4c5c..ca626f7fc68611de05319d78ddcc16e94b3375e1 100644 (file)
@@ -52,7 +52,7 @@ OPTIONS
 -s <format>::
 --suffix <format>::
        Specify an alternate suffix for the bugreport name, to create a file
-       named 'git-bugreport-<formatted suffix>'. This should take the form of a
+       named 'git-bugreport-<formatted-suffix>'. This should take the form of a
        strftime(3) format string; the current local time will be used.
 
 --no-diagnose::
@@ -60,7 +60,7 @@ OPTIONS
        Create a zip archive of supplemental information about the user's
        machine, Git client, and repository state. The archive is written to the
        same output directory as the bug report and is named
-       'git-diagnostics-<formatted suffix>'.
+       'git-diagnostics-<formatted-suffix>'.
 +
 Without `mode` specified, the diagnostic archive will contain the default set of
 statistics reported by `git diagnose`. An optional `mode` value may be specified
index 26ad1a5e27cc5af3334b49908ef1814ed315e180..8bdfa54ab09b4c4e8e4cb61767527e2ec06900b2 100644 (file)
@@ -63,7 +63,9 @@ $ git checkout <branch>
 ------------
 +
 that is to say, the branch is not reset/created unless "git checkout" is
-successful.
+successful (e.g., when the branch is in use in another worktree, not
+just the current branch stays the same, but the branch is not reset to
+the start-point, either).
 
 'git checkout' --detach [<branch>]::
 'git checkout' [--detach] <commit>::
index c37c4a37f7412c0b712d14067c2d7c7d975933c5..0c07720c6f4e4a53a20a9db8c210143e881a2347 100644 (file)
@@ -311,6 +311,12 @@ or `--mirror` is given)
        The result is Git repository can be separated from working
        tree.
 
+--ref-format=<ref-format>::
+
+Specify the given ref storage format for the repository. The valid values are:
++
+include::ref-storage-format.txt[]
+
 -j <n>::
 --jobs <n>::
        The number of submodules fetched at the same time.
index c8dbceba014639524ccf2b7b1897190a9fc3c0a0..903b16830ea22529f476f9fadbe0c7aac4b31c12 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
 'git commit-graph write' [--object-dir <dir>] [--append]
                        [--split[=<strategy>]] [--reachable | --stdin-packs | --stdin-commits]
                        [--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress]
-                       <split options>
+                       <split-options>
 
 
 DESCRIPTION
index b1caac887ae2dc5ce683ab4c6d91eed849403afe..dff39093b5ef322ce115afc8f4bee0c728b6173a 100644 (file)
@@ -103,11 +103,11 @@ OPTIONS
        names are not.
 
 --get-urlmatch <name> <URL>::
-       When given a two-part name section.key, the value for
-       section.<URL>.key whose <URL> part matches the best to the
+       When given a two-part <name> as <section>.<key>, the value for
+       <section>.<URL>.<key> whose <URL> part matches the best to the
        given URL is returned (if no such key exists, the value for
-       section.key is used as a fallback).  When given just the
-       section as name, do so for all the keys in the section and
+       <section>.<key> is used as a fallback).  When given just the
+       <section> as name, do so for all the keys in the section and
        list them.  Returns error code 1 if no value is found.
 
 --global::
index cf4a5a283ecd68f49fb3051b2f27007074eac4ef..4c475efeab976aefafa3dc64d41d3dcf303f63b6 100644 (file)
@@ -197,7 +197,7 @@ allowing access over SSH.
 5. Clients should now be able to check out the project. Use the CVS 'module'
    name to indicate what Git 'head' you want to check out.  This also sets the
    name of your newly checked-out directory, unless you tell it otherwise with
-   `-d <dir_name>`.  For example, this checks out 'master' branch to the
+   `-d <dir-name>`.  For example, this checks out 'master' branch to the
    `project-master` directory:
 +
 ------
@@ -224,7 +224,7 @@ the database to work reliably (otherwise you need to make sure
 that the database is up to date any time 'git-cvsserver' is executed).
 
 By default it uses SQLite databases in the Git directory, named
-`gitcvs.<module_name>.sqlite`. Note that the SQLite backend creates
+`gitcvs.<module-name>.sqlite`. Note that the SQLite backend creates
 temporary files in the same directory as the database file on
 write so it might not be enough to grant the users using
 'git-cvsserver' write access to the database file without granting
index e064f91c9e35899abd70f78a6f37158a0794f113..ede7b935d649472534dcc1bd9258c1d12231ca32 100644 (file)
@@ -18,7 +18,7 @@ SYNOPSIS
             [--allow-override=<service>] [--forbid-override=<service>]
             [--access-hook=<path>] [--[no-]informative-errors]
             [--inetd |
-             [--listen=<host_or_ipaddr>] [--port=<n>]
+             [--listen=<host-or-ipaddr>] [--port=<n>]
              [--user=<user> [--group=<group>]]]
             [--log-destination=(stderr|syslog|none)]
             [<directory>...]
@@ -86,10 +86,10 @@ OPTIONS
        Incompatible with --detach, --port, --listen, --user and --group
        options.
 
---listen=<host_or_ipaddr>::
+--listen=<host-or-ipaddr>::
        Listen on a specific IP address or hostname.  IP addresses can
        be either an IPv4 address or an IPv6 address if supported.  If IPv6
-       is not supported, then --listen=hostname is also not supported and
+       is not supported, then --listen=<hostname> is also not supported and
        --listen must be given an IPv4 address.
        Can be given more than once.
        Incompatible with `--inetd` option.
@@ -141,8 +141,8 @@ otherwise `stderr`.
        specified with no parameter, a request to
        git://host/{tilde}alice/foo is taken as a request to access
        'foo' repository in the home directory of user `alice`.
-       If `--user-path=path` is specified, the same request is
-       taken as a request to access `path/foo` repository in
+       If `--user-path=<path>` is specified, the same request is
+       taken as a request to access `<path>/foo` repository in
        the home directory of user `alice`.
 
 --verbose::
index 3ec8cc7ad72374b9c82db916b95ac0f6d56d5f32..0711959e6f6eaa6af5b8931058760b47189e6ba5 100644 (file)
@@ -45,7 +45,7 @@ OPTIONS
 -s <format>::
 --suffix <format>::
        Specify an alternate suffix for the diagnostics archive name, to create
-       a file named 'git-diagnostics-<formatted suffix>'. This should take the
+       a file named 'git-diagnostics-<formatted-suffix>'. This should take the
        form of a strftime(3) format string; the current local time will be
        used.
 
index 50cb080085e7708eb117e58fc42920c710452b31..a616f8b2e6f349d4fa8f7454c5ba48a219719842 100644 (file)
@@ -90,7 +90,7 @@ instead.  `--no-symlinks` is the default on Windows.
 --extcmd=<command>::
        Specify a custom command for viewing diffs.
        'git-difftool' ignores the configured defaults and runs
-       `$command $LOCAL $REMOTE` when this option is specified.
+       `<command> $LOCAL $REMOTE` when this option is specified.
        Additionally, `$BASE` is set in the environment.
 
 -g::
@@ -105,7 +105,6 @@ instead.  `--no-symlinks` is the default on Windows.
        `merge.tool` until a tool is found.
 
 --[no-]trust-exit-code::
-       'git-difftool' invokes a diff tool individually on each file.
        Errors reported by the diff tool are ignored by default.
        Use `--trust-exit-code` to make 'git-difftool' exit when an
        invoked diff tool returns a non-zero exit code.
index 4643ddbe68fd0c0eeb541df356ca3fc2bd2ee9d4..752e4b9b01d7d8a5527d1fe9a615ad8493e3f4bf 100644 (file)
@@ -48,7 +48,7 @@ When asking to 'abort' (which is the default), this program will die
 when encountering such a tag.  With 'drop' it will omit such tags from
 the output.  With 'rewrite', if the tagged object is a commit, it will
 rewrite the tag to tag an ancestor commit (via parent rewriting; see
-linkgit:git-rev-list[1])
+linkgit:git-rev-list[1]).
 
 -M::
 -C::
index bd7b1e0a2eaf3ebf595475580d81d6771b8b4166..b2607366b91458aabefc5f2e4814959a5ba9555c 100644 (file)
@@ -745,11 +745,11 @@ paths for a commit are encouraged to do so.
 
 `notemodify`
 ^^^^^^^^^^^^
-Included in a `commit` `<notes_ref>` command to add a new note
+Included in a `commit` `<notes-ref>` command to add a new note
 annotating a `<commit-ish>` or change this annotation contents.
 Internally it is similar to filemodify 100644 on `<commit-ish>`
 path (maybe split into subdirectories). It's not advised to
-use any other commands to write to the `<notes_ref>` tree except
+use any other commands to write to the `<notes-ref>` tree except
 `filedeleteall` to delete all existing notes in this tree.
 This command has two different means of specifying the content
 of the note.
index f123139c581001d2bcbd94dcc187775e58e8fd6c..50900a50dabce9cd5fcee479461c42466359cad5 100644 (file)
@@ -186,8 +186,8 @@ origin:
 ------------------------------------------------
 $ git fetch origin --prune --prune-tags
 $ git fetch origin --prune 'refs/tags/*:refs/tags/*'
-$ git fetch <url of origin> --prune --prune-tags
-$ git fetch <url of origin> --prune 'refs/tags/*:refs/tags/*'
+$ git fetch <url-of-origin> --prune --prune-tags
+$ git fetch <url-of-origin> --prune 'refs/tags/*:refs/tags/*'
 ------------------------------------------------
 
 OUTPUT
index 62e482a95e23fd87aa0bc5496a0584a7a7285f85..5a4f853785d119884c41de7f51b4057510f1ccf3 100644 (file)
@@ -14,7 +14,7 @@ SYNOPSIS
        [--msg-filter <command>] [--commit-filter <command>]
        [--tag-name-filter <command>] [--prune-empty]
        [--original <namespace>] [-d <directory>] [-f | --force]
-       [--state-branch <branch>] [--] [<rev-list options>...]
+       [--state-branch <branch>] [--] [<rev-list-options>...]
 
 WARNING
 -------
@@ -32,7 +32,7 @@ listed there as reasonably possible.
 DESCRIPTION
 -----------
 Lets you rewrite Git revision history by rewriting the branches mentioned
-in the <rev-list options>, applying custom filters on each revision.
+in the <rev-list-options>, applying custom filters on each revision.
 Those filters can modify each tree (e.g. removing a file or running
 a perl rewrite on all files) or information about each commit.
 Otherwise, all information (including original commit times or merge
@@ -624,7 +624,7 @@ with:
      real backup; it dereferences tags first.)
 
   ** Running git-filter-branch with either --tags or --all in your
-     <rev-list options>.  In order to retain annotated tags as
+     <rev-list-options>.  In order to retain annotated tags as
      annotated, you must use --tag-name-filter (and must not have
      restored from refs/original/ in a previously botched rewrite).
 
index e86d5700ddfe02e72e1cad809f29c555b15b6495..c1dd12b93cfd5c44a8d3d97c78c5f2f330f7fe3f 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 [verse]
 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]
                   [(--sort=<key>)...] [--format=<format>]
-                  [ --stdin | <pattern>... ]
+                  [--include-root-refs] [ --stdin | <pattern>... ]
                   [--points-at=<object>]
                   [--merged[=<object>]] [--no-merged[=<object>]]
                   [--contains[=<object>]] [--no-contains[=<object>]]
@@ -51,17 +51,14 @@ OPTIONS
        key.
 
 --format=<format>::
-       A string that interpolates `%(fieldname)` from a ref being shown
-       and the object it points at.  If `fieldname`
-       is prefixed with an asterisk (`*`) and the ref points
-       at a tag object, use the value for the field in the object
-       which the tag object refers to (instead of the field in the tag object).
-       When unspecified, `<format>` defaults to
-       `%(objectname) SPC %(objecttype) TAB %(refname)`.
-       It also interpolates `%%` to `%`, and `%xx` where `xx`
-       are hex digits interpolates to character with hex code
-       `xx`; for example `%00` interpolates to `\0` (NUL),
-       `%09` to `\t` (TAB) and `%0a` to `\n` (LF).
+       A string that interpolates `%(fieldname)` from a ref being shown and
+       the object it points at. In addition, the string literal `%%`
+       renders as `%` and `%xx` - where `xx` are hex digits - renders as
+       the character with hex code `xx`. For example, `%00` interpolates to
+       `\0` (NUL), `%09` to `\t` (TAB), and `%0a` to `\n` (LF).
++
+When unspecified, `<format>` defaults to `%(objectname) SPC %(objecttype)
+TAB %(refname)`.
 
 --color[=<when>]::
        Respect any colors specified in the `--format` option. The
@@ -108,6 +105,9 @@ OPTIONS
        any excluded pattern(s) are shown. Matching is done using the
        same rules as `<pattern>` above.
 
+--include-root-refs::
+       List root refs (HEAD and pseudorefs) apart from regular refs.
+
 FIELD NAMES
 -----------
 
@@ -298,6 +298,10 @@ fields will correspond to the appropriate date or name-email-date tuple
 from the `committer` or `tagger` fields depending on the object type.
 These are intended for working on a mix of annotated and lightweight tags.
 
+For tag objects, a `fieldname` prefixed with an asterisk (`*`) expands to
+the `fieldname` value of the peeled object, rather than that of the tag
+object itself.
+
 Fields that have name-email-date tuple as its value (`author`,
 `committer`, and `tagger`) can be suffixed with `name`, `email`,
 and `date` to extract the named component.  For email fields (`authoremail`,
@@ -358,9 +362,11 @@ In any case, a field name that refers to a field inapplicable to
 the object referred by the ref does not cause an error.  It
 returns an empty string instead.
 
-As a special case for the date-type fields, you may specify a format for
-the date by adding `:` followed by date format name (see the
-values the `--date` option to linkgit:git-rev-list[1] takes).
+As a special case for the date-type fields, you may specify a format for the
+date by adding `:` followed by date format name (see the values the `--date`
+option to linkgit:git-rev-list[1] takes). If this formatting is provided in
+a `--sort` key, references will be sorted according to the byte-value of the
+formatted string rather than the numeric value of the underlying timestamp.
 
 Some atoms like %(align) and %(if) always require a matching %(end).
 We call them "opening atoms" and sometimes denote them as %($open).
index 414da6b73e7dc9bee177cd91227acb36c6ed070a..728bb3821c1729dffe7565fa812570c315d0f878 100644 (file)
@@ -17,10 +17,10 @@ SYNOPSIS
                   [--signature-file=<file>]
                   [-n | --numbered | -N | --no-numbered]
                   [--start-number <n>] [--numbered-files]
-                  [--in-reply-to=<message id>] [--suffix=.<sfx>]
+                  [--in-reply-to=<message-id>] [--suffix=.<sfx>]
                   [--ignore-if-in-upstream] [--always]
                   [--cover-from-description=<mode>]
-                  [--rfc] [--subject-prefix=<subject prefix>]
+                  [--rfc] [--subject-prefix=<subject-prefix>]
                   [(--reroll-count|-v) <n>]
                   [--to=<email>] [--cc=<email>]
                   [--[no-]cover-letter] [--quiet]
@@ -30,8 +30,8 @@ SYNOPSIS
                   [--range-diff=<previous> [--creation-factor=<percent>]]
                   [--filename-max-length=<n>]
                   [--progress]
-                  [<common diff options>]
-                  [ <since> | <revision range> ]
+                  [<common-diff-options>]
+                  [ <since> | <revision-range> ]
 
 DESCRIPTION
 -----------
@@ -64,7 +64,7 @@ There are two ways to specify which commits to operate on.
    to the tip of the current branch that are not in the history
    that leads to the <since> to be output.
 
-2. Generic <revision range> expression (see "SPECIFYING
+2. Generic <revision-range> expression (see "SPECIFYING
    REVISIONS" section in linkgit:gitrevisions[7]) means the
    commits in the specified range.
 
@@ -179,9 +179,9 @@ Beware that the default for 'git send-email' is to thread emails
 itself.  If you want `git format-patch` to take care of threading, you
 will want to ensure that threading is disabled for `git send-email`.
 
---in-reply-to=<message id>::
+--in-reply-to=<message-id>::
        Make the first mail (or all the mails with `--no-thread`) appear as a
-       reply to the given <message id>, which avoids breaking threads to
+       reply to the given <message-id>, which avoids breaking threads to
        provide a new patch series.
 
 --ignore-if-in-upstream::
@@ -219,9 +219,9 @@ populated with placeholder text.
        Use the contents of <file> instead of the branch's description
        for generating the cover letter.
 
---subject-prefix=<subject prefix>::
+--subject-prefix=<subject-prefix>::
        Instead of the standard '[PATCH]' prefix in the subject
-       line, instead use '[<subject prefix>]'. This can be used
+       line, instead use '[<subject-prefix>]'. This can be used
        to name a patch series, and can be combined with the
        `--numbered` option.
 +
@@ -403,7 +403,7 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
        `format.useAutoBase` configuration.
 
 --root::
-       Treat the revision argument as a <revision range>, even if it
+       Treat the revision argument as a <revision-range>, even if it
        is just a single commit (that would normally be treated as a
        <since>).  Note that root commits included in the specified
        range are always formatted as creation patches, independently
index 6486620c3d8f2a2d7a9bb623c362d02465b06be4..5a20deefd5f5dae5fb4cfbb3ccfaef4ab723f44f 100644 (file)
@@ -79,8 +79,13 @@ OPTIONS
        to force the version for the generated pack index, and to force
        64-bit index entries on objects located above the given offset.
 
---strict::
-       Die, if the pack contains broken objects or links.
+--strict[=<msg-id>=<severity>...]::
+       Die, if the pack contains broken objects or links. An optional
+       comma-separated list of `<msg-id>=<severity>` can be passed to change
+       the severity of some possible issues, e.g.,
+        `--strict="missingEmail=ignore,badTagName=error"`. See the entry for the
+       `fsck.<msg-id>` configuration options in linkgit:git-fsck[1] for more
+       information on the possible values of `<msg-id>` and `<severity>`.
 
 --progress-title::
        For internal use only.
@@ -91,13 +96,18 @@ default and "Indexing objects" when `--stdin` is specified.
 --check-self-contained-and-connected::
        Die if the pack contains broken links. For internal use only.
 
---fsck-objects::
-       For internal use only.
+--fsck-objects[=<msg-id>=<severity>...]::
+       Die if the pack contains broken objects, but unlike `--strict`, don't
+       choke on broken links. If the pack contains a tree pointing to a
+       .gitmodules blob that does not exist, prints the hash of that blob
+       (for the caller to check) after the hash that goes into the name of the
+       pack/idx file (see "Notes").
 +
-Die if the pack contains broken objects. If the pack contains a tree
-pointing to a .gitmodules blob that does not exist, prints the hash of
-that blob (for the caller to check) after the hash that goes into the
-name of the pack/idx file (see "Notes").
+An optional comma-separated list of `<msg-id>=<severity>` can be passed to
+change the severity of some possible issues, e.g.,
+`--fsck-objects="missingEmail=ignore,badTagName=ignore"`. See the entry for the
+`fsck.<msg-id>` configuration options in linkgit:git-fsck[1] for more
+information on the possible values of `<msg-id>` and `<severity>`.
 
 --threads=<n>::
        Specifies the number of threads to spawn when resolving
index 6f0d2973bf444a510ae4989dee9aa1e360eee247..e8dc645bb59a8664865c9eed00698ee4374ea4a3 100644 (file)
@@ -11,6 +11,7 @@ SYNOPSIS
 [verse]
 'git init' [-q | --quiet] [--bare] [--template=<template-directory>]
          [--separate-git-dir <git-dir>] [--object-format=<format>]
+         [--ref-format=<format>]
          [-b <branch-name> | --initial-branch=<branch-name>]
          [--shared[=<permissions>]] [<directory>]
 
@@ -57,6 +58,12 @@ values are 'sha1' and (if enabled) 'sha256'.  'sha1' is the default.
 +
 include::object-format-disclaimer.txt[]
 
+--ref-format=<format>::
+
+Specify the given ref storage format for the repository. The valid values are:
++
+include::ref-storage-format.txt[]
+
 --template=<template-directory>::
 
 Specify the directory from which templates will be used.  (See the "TEMPLATE
index f65a8cd91d4bb40e986c3610b6f1c2b89c719ace..d08c7da8f495b3e19fb763535ff742585da9ce3e 100644 (file)
@@ -119,8 +119,10 @@ OPTIONS
 
 --exclude-per-directory=<file>::
        Read additional exclude patterns that apply only to the
-       directory and its subdirectories in <file>.  Deprecated; use
-       --exclude-standard instead.
+       directory and its subdirectories in <file>.  If you are
+       trying to emulate the way Porcelain commands work, using
+       the `--exclude-standard` option instead is easier and more
+       thorough.
 
 --exclude-standard::
        Add the standard Git exclusions: .git/info/exclude, .gitignore
@@ -298,9 +300,8 @@ traversing the directory tree and finding files to show when the
 flags --others or --ignored are specified.  linkgit:gitignore[5]
 specifies the format of exclude patterns.
 
-Generally, you should just use --exclude-standard, but for historical
-reasons the exclude patterns can be specified from the following
-places, in order:
+These exclude patterns can be specified from the following places,
+in order:
 
   1. The command-line flag --exclude=<pattern> specifies a
      single pattern.  Patterns are ordered in the same order
@@ -322,6 +323,18 @@ top of the directory tree.  A pattern read from a file specified
 by --exclude-per-directory is relative to the directory that the
 pattern file appears in.
 
+Generally, you should be able to use `--exclude-standard` when you
+want the exclude rules applied the same way as what Porcelain
+commands do.  To emulate what `--exclude-standard` specifies, you
+can give `--exclude-per-directory=.gitignore`, and then specify:
+
+  1. The file specified by the `core.excludesfile` configuration
+     variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file.
+
+  2. The `$GIT_DIR/info/exclude` file.
+
+via the `--exclude-from=` option.
+
 SEE ALSO
 --------
 linkgit:git-read-tree[1], linkgit:gitignore[5]
index 6a081eacb72372e332850118ab9df7280fa6f08d..71915a00fa472e73f5fadd2205f964919d3262db 100644 (file)
@@ -92,6 +92,12 @@ object store and the object ID of its blob is written to standard output.
        Instead of leaving conflicts in the file, resolve conflicts
        favouring our (or their or both) side of the lines.
 
+--diff-algorithm={patience|minimal|histogram|myers}::
+       Use a different diff algorithm while merging. The current default is "myers",
+       but selecting more recent algorithm such as "histogram" can help
+       avoid mismerges that occur due to unimportant matching lines
+       (such as braces from distinct functions). See also
+       linkgit:git-diff[1] `--diff-algorithm`.
 
 EXAMPLES
 --------
index b50acace3bc367ad7b73d2da10252e6b5f2e0d07..dd388fa21d5a51d1b6c3aca1b1d18b98f69a4f88 100644 (file)
@@ -64,10 +64,13 @@ OPTIONS
        share no common history.  This flag can be given to override that
        check and make the merge proceed anyway.
 
---merge-base=<commit>::
+--merge-base=<tree-ish>::
        Instead of finding the merge-bases for <branch1> and <branch2>,
        specify a merge-base for the merge, and specifying multiple bases is
        currently not supported. This option is incompatible with `--stdin`.
++
+As the merge-base is provided directly, <branch1> and <branch2> do not need
+to specify commits; trees are enough.
 
 [[OUTPUT]]
 OUTPUT
index 7f991a3380201fe4c9f66e9c99604dc16b467f73..dc1bf61534106ac8c9e916ba47bb7fb0f1bf97f0 100644 (file)
@@ -16,7 +16,7 @@ DESCRIPTION
 Move or rename a file, directory, or symlink.
 
  git mv [-v] [-f] [-n] [-k] <source> <destination>
- git mv [-v] [-f] [-n] [-k] <source> ... <destination directory>
+ git mv [-v] [-f] [-n] [-k] <source> ... <destination-directory>
 
 In the first form, it renames <source>, which must exist and be either
 a file, symlink or directory, to <destination>.
index f8310e56a85ab0f6f211d68b1886ec68ae126b9f..c9221a68ccedc828672917576d317c42f9e3647c 100644 (file)
@@ -56,7 +56,7 @@ SUBCOMMANDS
 list::
        List the notes object for a given object. If no object is
        given, show a list of all note objects and the objects they
-       annotate (in the format "<note object> <annotated object>").
+       annotate (in the format "<note-object> <annotated-object>").
        This is the default subcommand if no subcommand is given.
 
 add::
index af05708be71f356d4928ef80fa59151805700efd..e7e725044db418845cd8ee53aed60fba2374634f 100644 (file)
@@ -589,21 +589,27 @@ See also INCOMPATIBLE OPTIONS below.
 
 --autosquash::
 --no-autosquash::
-       When the commit log message begins with "squash! ..." or "fixup! ..."
-       or "amend! ...", and there is already a commit in the todo list that
-       matches the same `...`, automatically modify the todo list of
-       `rebase -i`, so that the commit marked for squashing comes right after
-       the commit to be modified, and change the action of the moved commit
-       from `pick` to `squash` or `fixup` or `fixup -C` respectively. A commit
-       matches the `...` if the commit subject matches, or if the `...` refers
-       to the commit's hash. As a fall-back, partial matches of the commit
-       subject work, too. The recommended way to create fixup/amend/squash
-       commits is by using the `--fixup`, `--fixup=amend:` or `--fixup=reword:`
-       and `--squash` options respectively of linkgit:git-commit[1].
+       Automatically squash commits with specially formatted messages into
+       previous commits being rebased.  If a commit message starts with
+       "squash! ", "fixup! " or "amend! ", the remainder of the subject line
+       is taken as a commit specifier, which matches a previous commit if it
+       matches the subject line or the hash of that commit.  If no commit
+       matches fully, matches of the specifier with the start of commit
+       subjects are considered.
 +
-If the `--autosquash` option is enabled by default using the
-configuration variable `rebase.autoSquash`, this option can be
-used to override and disable this setting.
+In the rebase todo list, the actions of squash, fixup and amend commits are
+changed from `pick` to `squash`, `fixup` or `fixup -C`, respectively, and they
+are moved right after the commit they modify.  The `--interactive` option can
+be used to review and edit the todo list before proceeding.
++
+The recommended way to create commits with squash markers is by using the
+`--squash`, `--fixup`, `--fixup=amend:` or `--fixup=reword:` options of
+linkgit:git-commit[1], which take the target commit as an argument and
+automatically fill in the subject line of the new commit from that.
++
+Setting configuration variable `rebase.autoSquash` to true enables
+auto-squashing by default for interactive rebase.  The `--no-autosquash`
+option can be used to override that setting.
 +
 See also INCOMPATIBLE OPTIONS below.
 
index ec64cbff4c6529d23fcf885ed5fa6f018404952f..a929c52982ff7629fdd32df1d008a0fb824847d0 100644 (file)
@@ -10,6 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git reflog' [show] [<log-options>] [<ref>]
+'git reflog list'
 'git reflog expire' [--expire=<time>] [--expire-unreachable=<time>]
        [--rewrite] [--updateref] [--stale-fix]
        [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]
@@ -39,6 +40,8 @@ actions, and in addition the `HEAD` reflog records branch switching.
 `git reflog show` is an alias for `git log -g --abbrev-commit
 --pretty=oneline`; see linkgit:git-log[1] for more information.
 
+The "list" subcommand lists all refs which have a corresponding reflog.
+
 The "expire" subcommand prunes older reflog entries. Entries older
 than `expire` time, or entries older than `expire-unreachable` time
 and not reachable from the current tip, are removed from the reflog.
index 1dec3148348350bc6f26a53ca2add524d3f8b9bf..932a5c3ea4741c2abbfab9b7070a51fcf0b58a37 100644 (file)
@@ -35,7 +35,7 @@ OPTIONS
 -v::
 --verbose::
        Be a little more verbose and show remote url after name.
-       For promisor remotes, also show which filter (`blob:none` etc.)
+       For promisor remotes, also show which filters (`blob:none` etc.)
        are configured.
        NOTE: This must be placed between `remote` and subcommand.
 
index 4f257126e33cc779d1f407ce61cdfbde3cf9ffad..0a65460adbded52c7d699228a7b3247c5fdf7fad 100644 (file)
@@ -114,11 +114,11 @@ FORMATS
 The following formats are available:
 
 * 'short':
-       <replaced sha1>
+       <replaced-sha1>
 * 'medium':
-       <replaced sha1> -> <replacement sha1>
+       <replaced-sha1> -> <replacement-sha1>
 * 'long':
-       <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>)
+       <replaced-sha1> (<replaced-type>) -> <replacement-sha1> (<replacement-type>)
 
 CREATING REPLACEMENT OBJECTS
 ----------------------------
diff --git a/Documentation/git-replay.txt b/Documentation/git-replay.txt
new file mode 100644 (file)
index 0000000..f6c269c
--- /dev/null
@@ -0,0 +1,127 @@
+git-replay(1)
+=============
+
+NAME
+----
+git-replay - EXPERIMENTAL: Replay commits on a new base, works with bare repos too
+
+
+SYNOPSIS
+--------
+[verse]
+(EXPERIMENTAL!) 'git replay' ([--contained] --onto <newbase> | --advance <branch>) <revision-range>...
+
+DESCRIPTION
+-----------
+
+Takes ranges of commits and replays them onto a new location. Leaves
+the working tree and the index untouched, and updates no references.
+The output of this command is meant to be used as input to
+`git update-ref --stdin`, which would update the relevant branches
+(see the OUTPUT section below).
+
+THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
+
+OPTIONS
+-------
+
+--onto <newbase>::
+       Starting point at which to create the new commits.  May be any
+       valid commit, and not just an existing branch name.
++
+When `--onto` is specified, the update-ref command(s) in the output will
+update the branch(es) in the revision range to point at the new
+commits, similar to the way how `git rebase --update-refs` updates
+multiple branches in the affected range.
+
+--advance <branch>::
+       Starting point at which to create the new commits; must be a
+       branch name.
++
+When `--advance` is specified, the update-ref command(s) in the output
+will update the branch passed as an argument to `--advance` to point at
+the new commits (in other words, this mimics a cherry-pick operation).
+
+<revision-range>::
+       Range of commits to replay. More than one <revision-range> can
+       be passed, but in `--advance <branch>` mode, they should have
+       a single tip, so that it's clear where <branch> should point
+       to. See "Specifying Ranges" in linkgit:git-rev-parse and the
+       "Commit Limiting" options below.
+
+include::rev-list-options.txt[]
+
+OUTPUT
+------
+
+When there are no conflicts, the output of this command is usable as
+input to `git update-ref --stdin`.  It is of the form:
+
+       update refs/heads/branch1 ${NEW_branch1_HASH} ${OLD_branch1_HASH}
+       update refs/heads/branch2 ${NEW_branch2_HASH} ${OLD_branch2_HASH}
+       update refs/heads/branch3 ${NEW_branch3_HASH} ${OLD_branch3_HASH}
+
+where the number of refs updated depends on the arguments passed and
+the shape of the history being replayed.  When using `--advance`, the
+number of refs updated is always one, but for `--onto`, it can be one
+or more (rebasing multiple branches simultaneously is supported).
+
+EXIT STATUS
+-----------
+
+For a successful, non-conflicted replay, the exit status is 0.  When
+the replay has conflicts, the exit status is 1.  If the replay is not
+able to complete (or start) due to some kind of error, the exit status
+is something other than 0 or 1.
+
+EXAMPLES
+--------
+
+To simply rebase `mybranch` onto `target`:
+
+------------
+$ git replay --onto target origin/main..mybranch
+update refs/heads/mybranch ${NEW_mybranch_HASH} ${OLD_mybranch_HASH}
+------------
+
+To cherry-pick the commits from mybranch onto target:
+
+------------
+$ git replay --advance target origin/main..mybranch
+update refs/heads/target ${NEW_target_HASH} ${OLD_target_HASH}
+------------
+
+Note that the first two examples replay the exact same commits and on
+top of the exact same new base, they only differ in that the first
+provides instructions to make mybranch point at the new commits and
+the second provides instructions to make target point at them.
+
+What if you have a stack of branches, one depending upon another, and
+you'd really like to rebase the whole set?
+
+------------
+$ git replay --contained --onto origin/main origin/main..tipbranch
+update refs/heads/branch1 ${NEW_branch1_HASH} ${OLD_branch1_HASH}
+update refs/heads/branch2 ${NEW_branch2_HASH} ${OLD_branch2_HASH}
+update refs/heads/tipbranch ${NEW_tipbranch_HASH} ${OLD_tipbranch_HASH}
+------------
+
+When calling `git replay`, one does not need to specify a range of
+commits to replay using the syntax `A..B`; any range expression will
+do:
+
+------------
+$ git replay --onto origin/main ^base branch1 branch2 branch3
+update refs/heads/branch1 ${NEW_branch1_HASH} ${OLD_branch1_HASH}
+update refs/heads/branch2 ${NEW_branch2_HASH} ${OLD_branch2_HASH}
+update refs/heads/branch3 ${NEW_branch3_HASH} ${OLD_branch3_HASH}
+------------
+
+This will simultaneously rebase `branch1`, `branch2`, and `branch3`,
+all commits they have since `base`, playing them on top of
+`origin/main`. These three branches may have commits on top of `base`
+that they have in common, but that does not need to be the case.
+
+GIT
+---
+Part of the linkgit:git[1] suite
index 912fab9f5e00b6e286b1d80a8164d76224408682..5d83dd36da11f3a7e5294bc5825e131c81d17633 100644 (file)
@@ -9,7 +9,7 @@ git-rev-parse - Pick out and massage parameters
 SYNOPSIS
 --------
 [verse]
-'git rev-parse' [<options>] <args>...
+'git rev-parse' [<options>] <arg>...
 
 DESCRIPTION
 -----------
@@ -130,7 +130,7 @@ for another option.
        'git diff-{asterisk}'). In contrast to the `--sq-quote` option,
        the command input is still interpreted as usual.
 
---short[=length]::
+--short[=<length>]::
        Same as `--verify` but shortens the object name to a unique
        prefix with at least `length` characters. The minimum length
        is 4, the default is the effective value of the `core.abbrev`
@@ -165,9 +165,9 @@ Options for Objects
 --all::
        Show all refs found in `refs/`.
 
---branches[=pattern]::
---tags[=pattern]::
---remotes[=pattern]::
+--branches[=<pattern>]::
+--tags[=<pattern>]::
+--remotes[=<pattern>]::
        Show all branches, tags, or remote-tracking branches,
        respectively (i.e., refs found in `refs/heads`,
        `refs/tags`, or `refs/remotes`, respectively).
@@ -176,7 +176,7 @@ If a `pattern` is given, only refs matching the given shell glob are
 shown.  If the pattern does not contain a globbing character (`?`,
 `*`, or `[`), it is turned into a prefix match by appending `/*`.
 
---glob=pattern::
+--glob=<pattern>::
        Show all refs matching the shell glob pattern `pattern`. If
        the pattern does not start with `refs/`, this is automatically
        prepended.  If the pattern does not contain a globbing
@@ -197,7 +197,7 @@ respectively, and they must begin with `refs/` when applied to `--glob`
 or `--all`. If a trailing '/{asterisk}' is intended, it must be given
 explicitly.
 
---exclude-hidden=[fetch|receive|uploadpack]::
+--exclude-hidden=(fetch|receive|uploadpack)::
        Do not include refs that would be hidden by `git-fetch`,
        `git-receive-pack` or `git-upload-pack` by consulting the appropriate
        `fetch.hideRefs`, `receive.hideRefs` or `uploadpack.hideRefs`
@@ -307,21 +307,24 @@ The following options are unaffected by `--path-format`:
        input, multiple algorithms may be printed, space-separated.
        If not specified, the default is "storage".
 
+--show-ref-format::
+       Show the reference storage format used for the repository.
+
 
 Other Options
 ~~~~~~~~~~~~~
 
---since=datestring::
---after=datestring::
+--since=<datestring>::
+--after=<datestring>::
        Parse the date string, and output the corresponding
        --max-age= parameter for 'git rev-list'.
 
---until=datestring::
---before=datestring::
+--until=<datestring>::
+--before=<datestring>::
        Parse the date string, and output the corresponding
        --min-age= parameter for 'git rev-list'.
 
-<args>...::
+<arg>...::
        Flags and parameters to be parsed.
 
 
index cbe0208834d51f89cf9020bdf55ce96be4221ae5..568925db533879697304459d6e47fe5f48861cf1 100644 (file)
@@ -116,7 +116,7 @@ include::rerere-options.txt[]
 
 --reference::
        Instead of starting the body of the log message with "This
-       reverts <full object name of the commit being reverted>.",
+       reverts <full-object-name-of-the-commit-being-reverted>.",
        refer to the commit using "--pretty=reference" format
        (cf. linkgit:git-log[1]).  The `revert.reference`
        configuration variable can be used to enable this option by
@@ -149,7 +149,7 @@ While git creates a basic commit message automatically, it is
 _strongly_ recommended to explain why the original commit is being
 reverted.
 In addition, repeatedly reverting reverts will result in increasingly
-unwieldy subject lines, for example 'Reapply "Reapply "<original subject>""'.
+unwieldy subject lines, for example 'Reapply "Reapply "<original-subject>""'.
 Please consider rewording these to be shorter and more unique.
 
 CONFIGURATION
index 30deb7fe2a4f5506745a938b76d8bbcfb504e34b..8264f8738093cf64b7e32201826fb170dd512c73 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git send-email' [<options>] <file|directory>...
-'git send-email' [<options>] <format-patch options>
+'git send-email' [<options>] <format-patch-options>
 'git send-email' --dump-aliases
 
 
@@ -138,7 +138,7 @@ Note that no attempts whatsoever are made to validate the encoding.
 
 --compose-encoding=<encoding>::
        Specify encoding of compose message. Default is the value of the
-       'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed.
+       'sendemail.composeEncoding'; if that is unspecified, UTF-8 is assumed.
 
 --transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)::
        Specify the transfer encoding to be used to send the message over SMTP.
@@ -174,7 +174,7 @@ Sending
        Specify a command to run to send the email. The command should
        be sendmail-like; specifically, it must support the `-i` option.
        The command will be executed in the shell if necessary.  Default
-       is the value of `sendemail.sendmailcmd`.  If unspecified, and if
+       is the value of `sendemail.sendmailCmd`.  If unspecified, and if
        --smtp-server is also unspecified, git-send-email will search
        for `sendmail` in `/usr/sbin`, `/usr/lib` and $PATH.
 
@@ -269,7 +269,7 @@ must be used for each option.
        certificates concatenated together: see verify(1) -CAfile and
        -CApath for more information on these). Set it to an empty string
        to disable certificate verification. Defaults to the value of the
-       `sendemail.smtpsslcertpath` configuration variable, if set, or the
+       `sendemail.smtpSSLCertPath` configuration variable, if set, or the
        backing SSL library's compiled-in default otherwise (which should
        be the best choice on most platforms).
 
@@ -313,7 +313,7 @@ Automating
        Specify a command to execute once per patch file which
        should generate patch file specific "To:" entries.
        Output of this command must be single email address per line.
-       Default is the value of 'sendemail.tocmd' configuration value.
+       Default is the value of 'sendemail.toCmd' configuration value.
 
 --cc-cmd=<command>::
        Specify a command to execute once per patch file which
@@ -348,19 +348,19 @@ Automating
 
 --[no-]signed-off-by-cc::
        If this is set, add emails found in the `Signed-off-by` trailer or Cc: lines to the
-       cc list. Default is the value of `sendemail.signedoffbycc` configuration
+       cc list. Default is the value of `sendemail.signedOffByCc` configuration
        value; if that is unspecified, default to --signed-off-by-cc.
 
 --[no-]cc-cover::
        If this is set, emails found in Cc: headers in the first patch of
        the series (typically the cover letter) are added to the cc list
-       for each email set. Default is the value of 'sendemail.cccover'
+       for each email set. Default is the value of 'sendemail.ccCover'
        configuration value; if that is unspecified, default to --no-cc-cover.
 
 --[no-]to-cover::
        If this is set, emails found in To: headers in the first patch of
        the series (typically the cover letter) are added to the to list
-       for each email set. Default is the value of 'sendemail.tocover'
+       for each email set. Default is the value of 'sendemail.toCover'
        configuration value; if that is unspecified, default to --no-to-cover.
 
 --suppress-cc=<category>::
@@ -384,7 +384,7 @@ Automating
 - 'all' will suppress all auto cc values.
 --
 +
-Default is the value of `sendemail.suppresscc` configuration value; if
+Default is the value of `sendemail.suppressCc` configuration value; if
 that is unspecified, default to 'self' if --suppress-from is
 specified, as well as 'body' if --no-signed-off-cc is specified.
 
@@ -471,7 +471,7 @@ Information
        Instead of the normal operation, dump the shorthand alias names from
        the configured alias file(s), one per line in alphabetical order. Note
        that this only includes the alias name and not its expanded email addresses.
-       See 'sendemail.aliasesfile' for more information about aliases.
+       See 'sendemail.aliasesFile' for more information about aliases.
 
 
 CONFIGURATION
index 10fecc51a75d4783c68565d25302c50480d626ce..4dbb88373bcddadde2560e8159ef31d1f3580c58 100644 (file)
@@ -309,7 +309,7 @@ Line                                     Notes
 ------------------------------------------------------------
 # branch.oid <commit> | (initial)        Current commit.
 # branch.head <branch> | (detached)      Current branch.
-# branch.upstream <upstream_branch>      If upstream is set.
+# branch.upstream <upstream-branch>      If upstream is set.
 # branch.ab +<ahead> -<behind>           If upstream is set and
                                         the commit is present.
 ------------------------------------------------------------
@@ -502,7 +502,7 @@ results, so it could be faster on subsequent runs.
        usually worth the additional size.
 
 * `core.untrackedCache=true` and `core.fsmonitor=true` or
-       `core.fsmonitor=<hook_command_pathname>` (see
+       `core.fsmonitor=<hook-command-pathname>` (see
        linkgit:git-update-index[1]): enable both the untracked cache
        and FSMonitor features and only search directories that have
        been modified since the previous `git status` command.  This
index 695730609aa3ab5a18d45cbff6aba5d1499dfdce..ca0347a37b554d168c918c7144a28e2b0c922c1c 100644 (file)
@@ -136,7 +136,7 @@ If you really want to remove a submodule from the repository and commit
 that use linkgit:git-rm[1] instead. See linkgit:gitsubmodules[7] for removal
 options.
 
-update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter spec>] [--] [<path>...]::
+update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter-spec>] [--] [<path>...]::
 +
 --
 Update the registered submodules to match what the superproject
@@ -185,7 +185,7 @@ submodule with the `--init` option.
 If `--recursive` is specified, this command will recurse into the
 registered submodules, and update any nested submodules within.
 
-If `--filter <filter spec>` is specified, the given partial clone filter will be
+If `--filter <filter-spec>` is specified, the given partial clone filter will be
 applied to the submodule. See linkgit:git-rev-list[1] for details on filter
 specifications.
 --
index 4e92308e85db5aab3b3e7f591e0ddb1f21afe724..43c68c2ec44f6a055ade52f15c29e36dfed42b45 100644 (file)
@@ -37,12 +37,12 @@ COMMANDS
        argument.  Normally this command initializes the current
        directory.
 
--T<trunk_subdir>;;
---trunk=<trunk_subdir>;;
--t<tags_subdir>;;
---tags=<tags_subdir>;;
--b<branches_subdir>;;
---branches=<branches_subdir>;;
+-T<trunk-subdir>;;
+--trunk=<trunk-subdir>;;
+-t<tags-subdir>;;
+--tags=<tags-subdir>;;
+-b<branches-subdir>;;
+--branches=<branches-subdir>;;
 -s;;
 --stdlayout;;
        These are optional command-line options for init.  Each of
@@ -726,9 +726,9 @@ ADVANCED OPTIONS
        when tracking a single URL.  The 'log' and 'dcommit' commands
        no longer require this switch as an argument.
 
--R<remote name>::
---svn-remote <remote name>::
-       Specify the [svn-remote "<remote name>"] section to use,
+-R<remote-name>::
+--svn-remote <remote-name>::
+       Specify the [svn-remote "<remote-name>"] section to use,
        this allows SVN multiple repositories to be tracked.
        Default: "svn"
 
index 3e23a82cf2627acf551274ab014b6410df35b80b..f38e4c8afa1bcbcfba7bd8b3e1da0bbad9703f77 100644 (file)
@@ -59,13 +59,18 @@ out at most one of `A` and `B`, in which case it defaults to `HEAD`.
 -c <new-branch>::
 --create <new-branch>::
        Create a new branch named `<new-branch>` starting at
-       `<start-point>` before switching to the branch. This is a
-       convenient shortcut for:
+       `<start-point>` before switching to the branch. This is the
+       transactional equivalent of
 +
 ------------
 $ git branch <new-branch>
 $ git switch <new-branch>
 ------------
++
+that is to say, the branch is not reset/created unless "git switch" is
+successful (e.g., when the branch is in use in another worktree, not
+just the current branch stays the same, but the branch is not reset to
+the start-point, either).
 
 -C <new-branch>::
 --force-create <new-branch>::
index d42efb3112787f943559723b9b19915df8181d5e..5fe519c31ec478e205223dbed919254a7ed4c610 100644 (file)
@@ -224,7 +224,7 @@ it in the repository configuration as follows:
 
 -------------------------------------
 [user]
-    signingKey = <gpg-key_id>
+    signingKey = <gpg-key-id>
 -------------------------------------
 
 `pager.tag` is only respected when listing tags, i.e., when `-l` is
index 962887f1907d1c18ce74bf36adb2d31abd76a940..e6b766d5c3ab54e6fc97d3cf31f9093a6eac5a41 100644 (file)
@@ -174,8 +174,17 @@ If you just want to run git as if it was started in `<path>` then use
        directory.
 
 --no-replace-objects::
-       Do not use replacement refs to replace Git objects. See
-       linkgit:git-replace[1] for more information.
+       Do not use replacement refs to replace Git objects.
+       This is equivalent to exporting the `GIT_NO_REPLACE_OBJECTS`
+       environment variable with any value.
+       See linkgit:git-replace[1] for more information.
+
+--no-lazy-fetch::
+       Do not fetch missing objects from the promisor remote on
+       demand.  Useful together with `git cat-file -e <object>` to
+       see if the object is locally available.
+       This is equivalent to setting the `GIT_NO_LAZY_FETCH`
+       environment variable to `1`.
 
 --literal-pathspecs::
        Treat pathspecs literally (i.e. no globbing, no pathspec magic).
@@ -202,7 +211,7 @@ If you just want to run git as if it was started in `<path>` then use
        Do not perform optional operations that require locks. This is
        equivalent to setting the `GIT_OPTIONAL_LOCKS` to `0`.
 
---list-cmds=group[,group...]::
+--list-cmds=<group>[,<group>...]::
        List commands by group. This is an internal/experimental
        option and may change or be removed in the future. Supported
        groups are: builtins, parseopt (builtin commands that use
@@ -556,6 +565,11 @@ double-quotes and respecting backslash escapes. E.g., the value
        is always used. The default is "sha1".
        See `--object-format` in linkgit:git-init[1].
 
+`GIT_DEFAULT_REF_FORMAT`::
+       If this variable is set, the default reference backend format for new
+       repositories will be set to this value. The default is "files".
+       See `--ref-format` in linkgit:git-init[1].
+
 Git Commits
 ~~~~~~~~~~~
 `GIT_AUTHOR_NAME`::
@@ -837,7 +851,7 @@ of the SID and an optional counter (to avoid filename
 collisions).
 +
 In addition, if the variable is set to
-`af_unix:[<socket_type>:]<absolute-pathname>`, Git will try
+`af_unix:[<socket-type>:]<absolute-pathname>`, Git will try
 to open the path as a Unix Domain Socket.  The socket type
 can be either `stream` or `dgram`.
 +
@@ -867,6 +881,10 @@ for full details.
        header and packfile URIs. Set this Boolean environment variable to false to prevent this
        redaction.
 
+`GIT_NO_REPLACE_OBJECTS`::
+       Setting and exporting this environment variable tells Git to
+       ignore replacement refs and do not replace Git objects.
+
 `GIT_LITERAL_PATHSPECS`::
        Setting this Boolean environment variable to true will cause Git to treat all
        pathspecs literally, rather than as glob patterns. For example,
@@ -888,6 +906,11 @@ for full details.
        Setting this Boolean environment variable to true will cause Git to treat all
        pathspecs as case-insensitive.
 
+`GIT_NO_LAZY_FETCH`::
+       Setting this Boolean environment variable to true tells Git
+       not to lazily fetch missing objects from the promisor remote
+       on demand.
+
 `GIT_REFLOG_ACTION`::
        When a ref is updated, reflog entries are created to keep
        track of the reason why the ref was updated (which is
index 8c1793c14880439da7103bc07f0f89a11137fc86..4338d023d9a313edae0bae8b2ac8087a3d15a003 100644 (file)
@@ -100,6 +100,21 @@ for a path to `Unspecified` state.  This can be done by listing
 the name of the attribute prefixed with an exclamation point `!`.
 
 
+RESERVED BUILTIN_* ATTRIBUTES
+-----------------------------
+
+builtin_* is a reserved namespace for builtin attribute values. Any
+user defined attributes under this namespace will be ignored and
+trigger a warning.
+
+`builtin_objectmode`
+~~~~~~~~~~~~~~~~~~~~
+This attribute is for filtering files by their file bit modes (40000,
+120000, 160000, 100755, 100644). e.g. ':(attr:builtin_objectmode=160000)'.
+You may also check these values with `git check-attr builtin_objectmode -- <file>`.
+If the object is not in the index `git check-attr --cached` will return unspecified.
+
+
 EFFECTS
 -------
 
@@ -1122,11 +1137,11 @@ The `merge.*.name` variable gives the driver a human-readable
 name.
 
 The `merge.*.driver` variable's value is used to construct a
-command to run to merge ancestor's version (`%O`), current
+command to run to common ancestor's version (`%O`), current
 version (`%A`) and the other branches' version (`%B`).  These
 three tokens are replaced with the names of temporary files that
 hold the contents of these versions when the command line is
-built. Additionally, %L will be replaced with the conflict marker
+built. Additionally, `%L` will be replaced with the conflict marker
 size (see below).
 
 The merge driver is expected to leave the result of the merge in
@@ -1144,8 +1159,9 @@ When left unspecified, the driver itself is used for both
 internal merge and the final merge.
 
 The merge driver can learn the pathname in which the merged result
-will be stored via placeholder `%P`.
-
+will be stored via placeholder `%P`. The conflict labels to be used
+for the common ancestor, local head and other head can be passed by
+using '%S', '%X' and '%Y` respectively.
 
 `conflict-marker-size`
 ^^^^^^^^^^^^^^^^^^^^^^
index 3cda2e07c24a96af8ff1c08c46780b5fdb490f4f..642c51227b5a0b1990c374bac4f815dac0b04c22 100644 (file)
@@ -245,20 +245,20 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
 
 This transformation limits the set of filepairs to those that change
 specified strings between the preimage and the postimage in a certain
-way.  -S<block of text> and -G<regular expression> options are used to
+way.  -S<block-of-text> and -G<regular-expression> options are used to
 specify different ways these strings are sought.
 
-"-S<block of text>" detects filepairs whose preimage and postimage
+"-S<block-of-text>" detects filepairs whose preimage and postimage
 have different number of occurrences of the specified block of text.
 By definition, it will not detect in-file moves.  Also, when a
 changeset moves a file wholesale without affecting the interesting
 string, diffcore-rename kicks in as usual, and `-S` omits the filepair
 (since the number of occurrences of that string didn't change in that
 rename-detected filepair).  When used with `--pickaxe-regex`, treat
-the <block of text> as an extended POSIX regular expression to match,
+the <block-of-text> as an extended POSIX regular expression to match,
 instead of a literal string.
 
-"-G<regular expression>" (mnemonic: grep) detects filepairs whose
+"-G<regular-expression>" (mnemonic: grep) detects filepairs whose
 textual diff has an added or a deleted line that matches the given
 regular expression.  This means that it will detect in-file (or what
 rename-detection considers the same file) moves, which is noise.  The
index 0773e5c3800392b8d4a548519b70379501207054..145cace1fe9fd3a583aaa7c0f605b64b78ef7554 100644 (file)
@@ -386,8 +386,8 @@ The remaining data of each directory block is grouped by type:
        long, "REUC" extension that is M-bytes long, followed by "EOIE",
        then the hash would be:
 
-       Hash("TREE" + <binary representation of N> +
-               "REUC" + <binary representation of M>)
+       Hash("TREE" + <binary-representation-of-N> +
+               "REUC" + <binary-representation-of-M>)
 
 == Index Entry Offset Table
 
index 9fcb29a9c844cc2c2efb1cb1767bd8f146270352..d6ae229be5685950da9a8cff4bbe215c62e0c17c 100644 (file)
@@ -396,6 +396,15 @@ CHUNK DATA:
            is padded at the end with between 0 and 3 NUL bytes to make the
            chunk size a multiple of 4 bytes.
 
+       Bitmapped Packfiles (ID: {'B', 'T', 'M', 'P'})
+           Stores a table of two 4-byte unsigned integers in network order.
+           Each table entry corresponds to a single pack (in the order that
+           they appear above in the `PNAM` chunk). The values for each table
+           entry are as follows:
+           - The first bit position (in pseudo-pack order, see below) to
+             contain an object from that pack.
+           - The number of bits whose objects are selected from that pack.
+
        OID Fanout (ID: {'O', 'I', 'D', 'F'})
            The ith entry, F[i], stores the number of OIDs with first
            byte at most i. Thus F[255] stores the total
@@ -509,6 +518,73 @@ packs arranged in MIDX order (with the preferred pack coming first).
 The MIDX's reverse index is stored in the optional 'RIDX' chunk within
 the MIDX itself.
 
+=== `BTMP` chunk
+
+The Bitmapped Packfiles (`BTMP`) chunk encodes additional information
+about the objects in the multi-pack index's reachability bitmap. Recall
+that objects from the MIDX are arranged in "pseudo-pack" order (see
+above) for reachability bitmaps.
+
+From the example above, suppose we have packs "a", "b", and "c", with
+10, 15, and 20 objects, respectively. In pseudo-pack order, those would
+be arranged as follows:
+
+    |a,0|a,1|...|a,9|b,0|b,1|...|b,14|c,0|c,1|...|c,19|
+
+When working with single-pack bitmaps (or, equivalently, multi-pack
+reachability bitmaps with a preferred pack), linkgit:git-pack-objects[1]
+performs ``verbatim'' reuse, attempting to reuse chunks of the bitmapped
+or preferred packfile instead of adding objects to the packing list.
+
+When a chunk of bytes is reused from an existing pack, any objects
+contained therein do not need to be added to the packing list, saving
+memory and CPU time. But a chunk from an existing packfile can only be
+reused when the following conditions are met:
+
+  - The chunk contains only objects which were requested by the caller
+    (i.e. does not contain any objects which the caller didn't ask for
+    explicitly or implicitly).
+
+  - All objects stored in non-thin packs as offset- or reference-deltas
+    also include their base object in the resulting pack.
+
+The `BTMP` chunk encodes the necessary information in order to implement
+multi-pack reuse over a set of packfiles as described above.
+Specifically, the `BTMP` chunk encodes three pieces of information (all
+32-bit unsigned integers in network byte-order) for each packfile `p`
+that is stored in the MIDX, as follows:
+
+`bitmap_pos`:: The first bit position (in pseudo-pack order) in the
+  multi-pack index's reachability bitmap occupied by an object from `p`.
+
+`bitmap_nr`:: The number of bit positions (including the one at
+  `bitmap_pos`) that encode objects from that pack `p`.
+
+For example, the `BTMP` chunk corresponding to the above example (with
+packs ``a'', ``b'', and ``c'') would look like:
+
+[cols="1,2,2"]
+|===
+| |`bitmap_pos` |`bitmap_nr`
+
+|packfile ``a''
+|`0`
+|`10`
+
+|packfile ``b''
+|`10`
+|`15`
+
+|packfile ``c''
+|`25`
+|`20`
+|===
+
+With this information in place, we can treat each packfile as
+individually reusable in the same fashion as verbatim pack reuse is
+performed on individual packs prior to the implementation of the `BTMP`
+chunk.
+
 == cruft packs
 
 The cruft packs feature offer an alternative to Git's traditional mechanism of
index 883982e7a0516204ddd2f2f9e14775fa17e2a810..37f91d5b50ca3ac9053bd687ee540ca87de21083 100644 (file)
@@ -243,7 +243,7 @@ named remote is not being used both values will be the same.
 Information about what is to be pushed is provided on the hook's standard
 input with lines of the form:
 
-  <local ref> SP <local object name> SP <remote ref> SP <remote object name> LF
+  <local-ref> SP <local-object-name> SP <remote-ref> SP <remote-object-name> LF
 
 For instance, if the command +git push origin master:foreign+ were run the
 hook would receive a line like the following:
@@ -251,9 +251,9 @@ hook would receive a line like the following:
   refs/heads/master 67890 refs/heads/foreign 12345
 
 although the full object name would be supplied.  If the foreign ref does not
-yet exist the `<remote object name>` will be the all-zeroes object name.  If a
-ref is to be deleted, the `<local ref>` will be supplied as `(delete)` and the
-`<local object name>` will be the all-zeroes object name.  If the local commit
+yet exist the `<remote-object-name>` will be the all-zeroes object name.  If a
+ref is to be deleted, the `<local-ref>` will be supplied as `(delete)` and the
+`<local-object-name>` will be the all-zeroes object name.  If the local commit
 was specified by something other than a name which could be expanded (such as
 `HEAD~`, or an object name) it will be supplied as it was originally given.
 
index c2213bb77b380a213c1d4a8f6230790b9d8ecb57..35b39960296b69531fff972b6f55c39ed066a655 100644 (file)
@@ -8,7 +8,7 @@ gitk - The Git repository browser
 SYNOPSIS
 --------
 [verse]
-'gitk' [<options>] [<revision range>] [--] [<path>...]
+'gitk' [<options>] [<revision-range>] [--] [<path>...]
 
 DESCRIPTION
 -----------
@@ -124,7 +124,7 @@ gitk-specific options
        range to show.  The command is expected to print on its
        standard output a list of additional revisions to be shown,
        one per line.  Use this instead of explicitly specifying a
-       '<revision range>' if the set of commits to show may vary
+       '<revision-range>' if the set of commits to show may vary
        between refreshes.
 
 --select-commit=<ref>::
index d6c6effc2151ffa136f0f2e36a07b659e25c43e4..2cf7735be479e6863f4e373bd7cf7794624e0094 100644 (file)
@@ -378,7 +378,7 @@ fetch-pack may send "filter" commands to request a partial clone
 or partial fetch and request that the server omit various objects
 from the packfile.
 
-session-id=<session id>
+session-id=<session-id>
 -----------------------
 
 The server may advertise a session ID that can be used to identify this process
index 836b3490ccda97f6fb8356b25244365198a8f681..ec40a550ccab88b35f826e9133635e15c0f6c5ff 100644 (file)
@@ -391,14 +391,14 @@ C: Start a queue, `c_pending`, ordered by commit time (popping newest
 
 C: Send one `$GIT_URL/git-upload-pack` request:
 
-   C: 0032want <want #1>...............................
-   C: 0032want <want #2>...............................
+   C: 0032want <want-#1>...............................
+   C: 0032want <want-#2>...............................
    ....
-   C: 0032have <common #1>.............................
-   C: 0032have <common #2>.............................
+   C: 0032have <common-#1>.............................
+   C: 0032have <common-#2>.............................
    ....
-   C: 0032have <have #1>...............................
-   C: 0032have <have #2>...............................
+   C: 0032have <have-#1>...............................
+   C: 0032have <have-#2>...............................
    ....
    C: 0000
 
@@ -512,7 +512,7 @@ Within the command portion of the request body clients SHOULD send
 the id obtained through ref discovery as old_id.
 
   update_request  =  command_list
-                    "PACK" <binary data>
+                    "PACK" <binary-data>
 
   command_list    =  PKT-LINE(command NUL cap_list LF)
                     *(command_pkt)
index 8c1e7c61eac751d352b9268ff2d57b357ce62ed4..0b800abd567a49b24be7c9feade0596ff758df92 100644 (file)
@@ -199,7 +199,7 @@ which can be used to limit the refs sent from the server.
 
 Additional features not supported in the base command will be advertised
 as the value of the command in the capability advertisement in the form
-of a space separated list of features: "<command>=<feature 1> <feature 2>"
+of a space separated list of features: "<command>=<feature-1> <feature-2>"
 
 ls-refs takes in the following arguments:
 
@@ -245,7 +245,7 @@ addition of future extensions.
 
 Additional features not supported in the base command will be advertised
 as the value of the command in the capability advertisement in the form
-of a space separated list of features: "<command>=<feature 1> <feature 2>"
+of a space separated list of features: "<command>=<feature-1> <feature-2>"
 
 A `fetch` request can take the following arguments:
 
@@ -363,7 +363,7 @@ can be included in the client's request as well as the potential
 addition of the 'packfile-uris' section in the server's response as
 explained below.
 
-    packfile-uris <comma-separated list of protocols>
+    packfile-uris <comma-separated-list-of-protocols>
        Indicates to the server that the client is willing to receive
        URIs of any of the given protocols in place of objects in the
        sent packfile. Before performing the connectivity check, the
@@ -534,7 +534,7 @@ with objects using hash algorithm X.  If not specified, the server is assumed to
 only handle SHA-1.  If the client would like to use a hash algorithm other than
 SHA-1, it should specify its object-format string.
 
-session-id=<session id>
+session-id=<session-id>
 ~~~~~~~~~~~~~~~~~~~~~~~
 
 The server may advertise a session ID that can be used to identify this process
index 8400d591da0e8a93035d72a947b07728055eeebd..f7b5a25a0caa91c7eec2612d56300af08718c2a6 100644 (file)
@@ -151,7 +151,7 @@ the superproject's `$GIT_DIR/config` file, so the superproject's history
 is not affected. This can be undone using `git submodule init`.
 
  * Deleted submodule: A submodule can be deleted by running
-`git rm <submodule path> && git commit`. This can be undone
+`git rm <submodule-path> && git commit`. This can be undone
 using `git revert`.
 +
 The deletion removes the superproject's tracking data, which are
@@ -229,7 +229,7 @@ Workflow for a third party library
   git submodule add <URL> <path>
 
   # Occasionally update the submodule to a new version:
-  git -C <path> checkout <new version>
+  git -C <path> checkout <new-version>
   git add <path>
   git commit -m "update submodule to new version"
 
index 59fc1d27419f534edd42968c41ec83f00ff3647e..85983587fcffa8a07daf452adc3967d85804a9d4 100644 (file)
@@ -343,7 +343,7 @@ $home_link_str::
        Label for the "home link" at the top of all pages, leading to `$home_link`
        (usually the main gitweb page, which contains the projects list).  It is
        used as the first component of gitweb's "breadcrumb trail":
-       `<home link> / <project> / <action>`.  Can be set at build time using
+       `<home-link> / <project> / <action>`.  Can be set at build time using
        the `GITWEB_HOME_LINK_STR` variable.  By default it is set to "projects",
        as this link leads to the list of projects.  Another popular choice is to
        set it to the name of site.  Note that it is treated as raw HTML so it
@@ -604,9 +604,9 @@ Many gitweb features can be enabled (or disabled) and configured using the
 Each `%feature` hash element is a hash reference and has the following
 structure:
 ----------------------------------------------------------------------
-"<feature_name>" => {
-       "sub" => <feature-sub (subroutine)>,
-       "override" => <allow-override (boolean)>,
+"<feature-name>" => {
+       "sub" => <feature-sub-(subroutine)>,
+       "override" => <allow-override-(boolean)>,
        "default" => [ <options>... ]
 },
 ----------------------------------------------------------------------
@@ -614,7 +614,7 @@ Some features cannot be overridden per project.  For those
 features the structure of appropriate `%feature` hash element has a simpler
 form:
 ----------------------------------------------------------------------
-"<feature_name>" => {
+"<feature-name>" => {
        "override" => 0,
        "default" => [ <options>... ]
 },
index ddd4a0fc70571b83ab6c00bbfc4fd94cabfd4464..56d24a30a3f7b9ccd7046a1d66abd1cee2525ba6 100644 (file)
@@ -305,7 +305,7 @@ pathnames.  In most general form such path_info (component) based gitweb URL
 looks like this:
 
 -----------------------------------------------------------------------
-.../gitweb.cgi/<repo>/<action>/<revision_from>:/<path_from>..<revision_to>:/<path_to>?<arguments>
+.../gitweb.cgi/<repo>/<action>/<revision-from>:/<path-from>..<revision-to>:/<path-to>?<arguments>
 -----------------------------------------------------------------------
 
 
index f7d98c11e3dd0821094ae82cb488606a0de14732..d71b199955e15578c1392448cc5db0ce01240766 100644 (file)
@@ -638,6 +638,20 @@ The most notable example is `HEAD`.
        An <<def_object,object>> used to temporarily store the contents of a
        <<def_dirty,dirty>> working directory and the index for future reuse.
 
+[[def_special_ref]]special ref::
+       A ref that has different semantics than normal refs. These refs can be
+       accessed via normal Git commands but may not behave the same as a
+       normal ref in some cases.
++
+The following special refs are known to Git:
+
+ - "`FETCH_HEAD`" is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It
+   may refer to multiple object IDs. Each object ID is annotated with metadata
+   indicating where it was fetched from and its fetch status.
+
+ - "`MERGE_HEAD`" is written by linkgit:git-merge[1] when resolving merge
+   conflicts. It contains all commit IDs which are being merged.
+
 [[def_submodule]]submodule::
        A <<def_repository,repository>> that holds the history of a
        separate project inside another repository (the latter of
index d1a4c468e6354e47f52579d6e44f2387b51ba811..befa86d69278b480610c6d0472c005ad6093cf83 100644 (file)
@@ -177,7 +177,8 @@ Instead of `--tool=vimdiff`, you can also use one of these other variants:
 
 When using these variants, in order to specify a custom layout you will have to
 set configuration variables `mergetool.gvimdiff.layout` and
-`mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout`
+`mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout` (though the
+latter will be used as fallback if the variant-specific one is not set).
 
 In addition, for backwards compatibility with previous Git versions, you can
 also append `1`, `2` or `3` to either `vimdiff` or any of the variants (ex:
diff --git a/Documentation/ref-storage-format.txt b/Documentation/ref-storage-format.txt
new file mode 100644 (file)
index 0000000..14fff8a
--- /dev/null
@@ -0,0 +1,3 @@
+* `files` for loose files with packed-refs. This is the default.
+* `reftable` for the reftable format. This format is experimental and its
+  internals are subject to change.
index a583b52c612aece1f7d1fd24086c0f7961eecceb..bb753b62929c10f5ccc9fc70034ab63a3b6bb7a1 100644 (file)
@@ -1019,6 +1019,10 @@ Unexpected missing objects will raise an error.
 +
 The form '--missing=print' is like 'allow-any', but will also print a
 list of the missing objects.  Object IDs are prefixed with a ``?'' character.
++
+If some tips passed to the traversal are missing, they will be
+considered as missing too, and the traversal will ignore them. In case
+we cannot get their Object ID though, an error will be raised.
 
 --exclude-promisor-objects::
        (For internal use only.)  Prefilter object traversal at
index 045a76756fcf47401dc61cb55f37df1deff480d7..47281420fc4a0c901d60b2854a8f0a6e8f70587a 100644 (file)
@@ -100,3 +100,9 @@ If set, by default "git config" reads from both "config" and
 multiple working directory mode, "config" file is shared while
 "config.worktree" is per-working directory (i.e., it's in
 GIT_COMMON_DIR/worktrees/<id>/config.worktree)
+
+==== `refStorage`
+
+Specifies the file format for the ref database. The valid values are
+`files` (loose references with a packed-refs file) and `reftable` (see
+Documentation/technical/reftable.txt).
diff --git a/Documentation/technical/unit-tests.txt b/Documentation/technical/unit-tests.txt
new file mode 100644 (file)
index 0000000..206037f
--- /dev/null
@@ -0,0 +1,240 @@
+= Unit Testing
+
+In our current testing environment, we spend a significant amount of effort
+crafting end-to-end tests for error conditions that could easily be captured by
+unit tests (or we simply forgo some hard-to-setup and rare error conditions).
+Unit tests additionally provide stability to the codebase and can simplify
+debugging through isolation. Writing unit tests in pure C, rather than with our
+current shell/test-tool helper setup, simplifies test setup, simplifies passing
+data around (no shell-isms required), and reduces testing runtime by not
+spawning a separate process for every test invocation.
+
+We believe that a large body of unit tests, living alongside the existing test
+suite, will improve code quality for the Git project.
+
+== Definitions
+
+For the purposes of this document, we'll use *test framework* to refer to
+projects that support writing test cases and running tests within the context
+of a single executable. *Test harness* will refer to projects that manage
+running multiple executables (each of which may contain multiple test cases) and
+aggregating their results.
+
+In reality, these terms are not strictly defined, and many of the projects
+discussed below contain features from both categories.
+
+For now, we will evaluate projects solely on their framework features. Since we
+are relying on having TAP output (see below), we can assume that any framework
+can be made to work with a harness that we can choose later.
+
+
+== Summary
+
+We believe the best way forward is to implement a custom TAP framework for the
+Git project. We use a version of the framework originally proposed in
+https://lore.kernel.org/git/c902a166-98ce-afba-93f2-ea6027557176@gmail.com/[1].
+
+See the <<framework-selection,Framework Selection>> section below for the
+rationale behind this decision.
+
+
+== Choosing a test harness
+
+During upstream discussion, it was occasionally noted that `prove` provides many
+convenient features, such as scheduling slower tests first, or re-running
+previously failed tests.
+
+While we already support the use of `prove` as a test harness for the shell
+tests, it is not strictly required. The t/Makefile allows running shell tests
+directly (though with interleaved output if parallelism is enabled). Git
+developers who wish to use `prove` as a more advanced harness can do so by
+setting DEFAULT_TEST_TARGET=prove in their config.mak.
+
+We will follow a similar approach for unit tests: by default the test
+executables will be run directly from the t/Makefile, but `prove` can be
+configured with DEFAULT_UNIT_TEST_TARGET=prove.
+
+
+[[framework-selection]]
+== Framework selection
+
+There are a variety of features we can use to rank the candidate frameworks, and
+those features have different priorities:
+
+* Critical features: we probably won't consider a framework without these
+** Can we legally / easily use the project?
+*** <<license,License>>
+*** <<vendorable-or-ubiquitous,Vendorable or ubiquitous>>
+*** <<maintainable-extensible,Maintainable / extensible>>
+*** <<major-platform-support,Major platform support>>
+** Does the project support our bare-minimum needs?
+*** <<tap-support,TAP support>>
+*** <<diagnostic-output,Diagnostic output>>
+*** <<runtime-skippable-tests,Runtime-skippable tests>>
+* Nice-to-have features:
+** <<parallel-execution,Parallel execution>>
+** <<mock-support,Mock support>>
+** <<signal-error-handling,Signal & error-handling>>
+* Tie-breaker stats
+** <<project-kloc,Project KLOC>>
+** <<adoption,Adoption>>
+
+[[license]]
+=== License
+
+We must be able to legally use the framework in connection with Git. As Git is
+licensed only under GPLv2, we must eliminate any LGPLv3, GPLv3, or Apache 2.0
+projects.
+
+[[vendorable-or-ubiquitous]]
+=== Vendorable or ubiquitous
+
+We want to avoid forcing Git developers to install new tools just to run unit
+tests. Any prospective frameworks and harnesses must either be vendorable
+(meaning, we can copy their source directly into Git's repository), or so
+ubiquitous that it is reasonable to expect that most developers will have the
+tools installed already.
+
+[[maintainable-extensible]]
+=== Maintainable / extensible
+
+It is unlikely that any pre-existing project perfectly fits our needs, so any
+project we select will need to be actively maintained and open to accepting
+changes. Alternatively, assuming we are vendoring the source into our repo, it
+must be simple enough that Git developers can feel comfortable making changes as
+needed to our version.
+
+In the comparison table below, "True" means that the framework seems to have
+active developers, that it is simple enough that Git developers can make changes
+to it, and that the project seems open to accepting external contributions (or
+that it is vendorable). "Partial" means that at least one of the above
+conditions holds.
+
+[[major-platform-support]]
+=== Major platform support
+
+At a bare minimum, unit-testing must work on Linux, MacOS, and Windows.
+
+In the comparison table below, "True" means that it works on all three major
+platforms with no issues. "Partial" means that there may be annoyances on one or
+more platforms, but it is still usable in principle.
+
+[[tap-support]]
+=== TAP support
+
+The https://testanything.org/[Test Anything Protocol] is a text-based interface
+that allows tests to communicate with a test harness. It is already used by
+Git's integration test suite. Supporting TAP output is a mandatory feature for
+any prospective test framework.
+
+In the comparison table below, "True" means this is natively supported.
+"Partial" means TAP output must be generated by post-processing the native
+output.
+
+Frameworks that do not have at least Partial support will not be evaluated
+further.
+
+[[diagnostic-output]]
+=== Diagnostic output
+
+When a test case fails, the framework must generate enough diagnostic output to
+help developers find the appropriate test case in source code in order to debug
+the failure.
+
+[[runtime-skippable-tests]]
+=== Runtime-skippable tests
+
+Test authors may wish to skip certain test cases based on runtime circumstances,
+so the framework should support this.
+
+[[parallel-execution]]
+=== Parallel execution
+
+Ideally, we will build up a significant collection of unit test cases, most
+likely split across multiple executables. It will be necessary to run these
+tests in parallel to enable fast develop-test-debug cycles.
+
+In the comparison table below, "True" means that individual test cases within a
+single test executable can be run in parallel. We assume that executable-level
+parallelism can be handled by the test harness.
+
+[[mock-support]]
+=== Mock support
+
+Unit test authors may wish to test code that interacts with objects that may be
+inconvenient to handle in a test (e.g. interacting with a network service).
+Mocking allows test authors to provide a fake implementation of these objects
+for more convenient tests.
+
+[[signal-error-handling]]
+=== Signal & error handling
+
+The test framework should fail gracefully when test cases are themselves buggy
+or when they are interrupted by signals during runtime.
+
+[[project-kloc]]
+=== Project KLOC
+
+The size of the project, in thousands of lines of code as measured by
+https://dwheeler.com/sloccount/[sloccount] (rounded up to the next multiple of
+1,000). As a tie-breaker, we probably prefer a project with fewer LOC.
+
+[[adoption]]
+=== Adoption
+
+As a tie-breaker, we prefer a more widely-used project. We use the number of
+GitHub / GitLab stars to estimate this.
+
+
+=== Comparison
+
+:true: [lime-background]#True#
+:false: [red-background]#False#
+:partial: [yellow-background]#Partial#
+
+:gpl: [lime-background]#GPL v2#
+:isc: [lime-background]#ISC#
+:mit: [lime-background]#MIT#
+:expat: [lime-background]#Expat#
+:lgpl: [lime-background]#LGPL v2.1#
+
+:custom-impl: https://lore.kernel.org/git/c902a166-98ce-afba-93f2-ea6027557176@gmail.com/[Custom Git impl.]
+:greatest: https://github.com/silentbicycle/greatest[Greatest]
+:criterion: https://github.com/Snaipe/Criterion[Criterion]
+:c-tap: https://github.com/rra/c-tap-harness/[C TAP]
+:check: https://libcheck.github.io/check/[Check]
+
+[format="csv",options="header",width="33%",subs="specialcharacters,attributes,quotes,macros"]
+|=====
+Framework,"<<license,License>>","<<vendorable-or-ubiquitous,Vendorable or ubiquitous>>","<<maintainable-extensible,Maintainable / extensible>>","<<major-platform-support,Major platform support>>","<<tap-support,TAP support>>","<<diagnostic-output,Diagnostic output>>","<<runtime--skippable-tests,Runtime- skippable tests>>","<<parallel-execution,Parallel execution>>","<<mock-support,Mock support>>","<<signal-error-handling,Signal & error handling>>","<<project-kloc,Project KLOC>>","<<adoption,Adoption>>"
+{custom-impl},{gpl},{true},{true},{true},{true},{true},{true},{false},{false},{false},1,0
+{greatest},{isc},{true},{partial},{true},{partial},{true},{true},{false},{false},{false},3,1400
+{criterion},{mit},{false},{partial},{true},{true},{true},{true},{true},{false},{true},19,1800
+{c-tap},{expat},{true},{partial},{partial},{true},{false},{true},{false},{false},{false},4,33
+{check},{lgpl},{false},{partial},{true},{true},{true},{false},{false},{false},{true},17,973
+|=====
+
+=== Additional framework candidates
+
+Several suggested frameworks have been eliminated from consideration:
+
+* Incompatible licenses:
+** https://github.com/zorgnax/libtap[libtap] (LGPL v3)
+** https://cmocka.org/[cmocka] (Apache 2.0)
+* Missing source: https://www.kindahl.net/mytap/doc/index.html[MyTap]
+* No TAP support:
+** https://nemequ.github.io/munit/[µnit]
+** https://github.com/google/cmockery[cmockery]
+** https://github.com/lpabon/cmockery2[cmockery2]
+** https://github.com/ThrowTheSwitch/Unity[Unity]
+** https://github.com/siu/minunit[minunit]
+** https://cunit.sourceforge.net/[CUnit]
+
+
+== Milestones
+
+* Add useful tests of library-like code
+* Integrate with
+  https://lore.kernel.org/git/20230502211454.1673000-1-calvinwan@google.com/[stdlib
+  work]
+* Run alongside regular `make test` target
index 3985b6d3c2956f7d0b2c5d16d262a5203afe680e..06f19533134f9d8018b1b1ae924370660ec36d73 100644 (file)
@@ -5,7 +5,7 @@
 * `<absolute-pathname>` - Writes to the file in append mode. If the target
 already exists and is a directory, the traces will be written to files (one
 per process) underneath the given directory.
-* `af_unix:[<socket_type>:]<absolute-pathname>` - Write to a
+* `af_unix:[<socket-type>:]<absolute-pathname>` - Write to a
 Unix DomainSocket (on platforms that support them).  Socket
 type can be either `stream` or `dgram`; if omitted Git will
 try both.
index 4e79c1589ece05ff21a144e5b48829a5dc39b50f..ce671f812d4ce32b156361333155f459c9521647 100644 (file)
@@ -73,8 +73,8 @@ use will be rewritten into URLs that work), you can create a
 configuration section of the form:
 
 ------------
-       [url "<actual url base>"]
-               insteadOf = <other url base>
+       [url "<actual-url-base>"]
+               insteadOf = <other-url-base>
 ------------
 
 For example, with this:
@@ -92,8 +92,8 @@ If you want to rewrite URLs for push only, you can create a
 configuration section of the form:
 
 ------------
-       [url "<actual url base>"]
-               pushInsteadOf = <other url base>
+       [url "<actual-url-base>"]
+               pushInsteadOf = <other-url-base>
 ------------
 
 For example, with this:
index 5d32ff23844108f5a388ecd35f7a38d5286310eb..6433903491054874c826880ea46e0fbc1fdb02bd 100644 (file)
@@ -4100,8 +4100,8 @@ independently of the contents or the type of the object: all objects can
 be validated by verifying that (a) their hashes match the content of the
 file and (b) the object successfully inflates to a stream of bytes that
 forms a sequence of
-`<ascii type without space> + <space> + <ascii decimal size> +
-<byte\0> + <binary object data>`.
+`<ascii-type-without-space> + <space> + <ascii-decimal-size> +
+<byte\0> + <binary-object-data>`.
 
 The structured objects can further have their structure and
 connectivity to other objects verified. This is generally done with
index 698e8dc37dbe5c2e5a0c9a3c8b1b6e6bb8cfe820..df788c764b7bb4cd61a1b2a6da277bfce82cdfca 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v2.43.3
+DEF_VER=v2.44.GIT
 
 LF='
 '
@@ -11,7 +11,7 @@ LF='
 if test -f version
 then
        VN=$(cat version) || VN="$DEF_VER"
-elif test -d ${GIT_DIR:-.git} -o -f .git &&
+elif { test -d "${GIT_DIR:-.git}" || test -f .git; } &&
        VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
        case "$VN" in
        *$LF*) (exit 1) ;;
index 1618ee27d287d1b67a904d58908b1ba86f75dc44..4e255c81f22386389c7460d8f5e59426673b5a5a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -682,6 +682,9 @@ TEST_BUILTINS_OBJS =
 TEST_OBJS =
 TEST_PROGRAMS_NEED_X =
 THIRD_PARTY_SOURCES =
+UNIT_TEST_PROGRAMS =
+UNIT_TEST_DIR = t/unit-tests
+UNIT_TEST_BIN = $(UNIT_TEST_DIR)/bin
 
 # Having this variable in your environment would break pipelines because
 # you cause "cd" to echo its destination to stdout.  It can also take
@@ -749,7 +752,12 @@ SCRIPTS = $(SCRIPT_SH_GEN) \
 
 ETAGS_TARGET = TAGS
 
+# If you add a new fuzzer, please also make sure to run it in
+# ci/run-build-and-minimal-fuzzers.sh so that we make sure it still links and
+# runs in the future.
+FUZZ_OBJS += oss-fuzz/dummy-cmd-main.o
 FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
+FUZZ_OBJS += oss-fuzz/fuzz-date.o
 FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
 FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
 .PHONY: fuzz-objs
@@ -758,7 +766,7 @@ fuzz-objs: $(FUZZ_OBJS)
 # Always build fuzz objects even if not testing, to prevent bit-rot.
 all:: $(FUZZ_OBJS)
 
-FUZZ_PROGRAMS += $(patsubst %.o,%,$(FUZZ_OBJS))
+FUZZ_PROGRAMS += $(patsubst %.o,%,$(filter-out %dummy-cmd-main.o,$(FUZZ_OBJS)))
 
 # Empty...
 EXTRA_PROGRAMS =
@@ -788,7 +796,6 @@ TEST_BUILTINS_OBJS += test-chmtime.o
 TEST_BUILTINS_OBJS += test-config.o
 TEST_BUILTINS_OBJS += test-crontab.o
 TEST_BUILTINS_OBJS += test-csprng.o
-TEST_BUILTINS_OBJS += test-ctype.o
 TEST_BUILTINS_OBJS += test-date.o
 TEST_BUILTINS_OBJS += test-delta.o
 TEST_BUILTINS_OBJS += test-dir-iterator.o
@@ -799,7 +806,6 @@ TEST_BUILTINS_OBJS += test-dump-split-index.o
 TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
 TEST_BUILTINS_OBJS += test-env-helper.o
 TEST_BUILTINS_OBJS += test-example-decorate.o
-TEST_BUILTINS_OBJS += test-fast-rebase.o
 TEST_BUILTINS_OBJS += test-find-pack.o
 TEST_BUILTINS_OBJS += test-fsmonitor-client.o
 TEST_BUILTINS_OBJS += test-genrandom.o
@@ -825,7 +831,6 @@ TEST_BUILTINS_OBJS += test-partial-clone.o
 TEST_BUILTINS_OBJS += test-path-utils.o
 TEST_BUILTINS_OBJS += test-pcre2-config.o
 TEST_BUILTINS_OBJS += test-pkt-line.o
-TEST_BUILTINS_OBJS += test-prio-queue.o
 TEST_BUILTINS_OBJS += test-proc-receive.o
 TEST_BUILTINS_OBJS += test-progress.o
 TEST_BUILTINS_OBJS += test-reach.o
@@ -1121,6 +1126,7 @@ LIB_OBJS += reflog.o
 LIB_OBJS += refs.o
 LIB_OBJS += refs/debug.o
 LIB_OBJS += refs/files-backend.o
+LIB_OBJS += refs/reftable-backend.o
 LIB_OBJS += refs/iterator.o
 LIB_OBJS += refs/packed-backend.o
 LIB_OBJS += refs/ref-cache.o
@@ -1290,6 +1296,7 @@ BUILTIN_OBJS += builtin/remote-fd.o
 BUILTIN_OBJS += builtin/remote.o
 BUILTIN_OBJS += builtin/repack.o
 BUILTIN_OBJS += builtin/replace.o
+BUILTIN_OBJS += builtin/replay.o
 BUILTIN_OBJS += builtin/rerere.o
 BUILTIN_OBJS += builtin/reset.o
 BUILTIN_OBJS += builtin/rev-list.o
@@ -1335,6 +1342,15 @@ THIRD_PARTY_SOURCES += compat/regex/%
 THIRD_PARTY_SOURCES += sha1collisiondetection/%
 THIRD_PARTY_SOURCES += sha1dc/%
 
+UNIT_TEST_PROGRAMS += t-basic
+UNIT_TEST_PROGRAMS += t-mem-pool
+UNIT_TEST_PROGRAMS += t-strbuf
+UNIT_TEST_PROGRAMS += t-ctype
+UNIT_TEST_PROGRAMS += t-prio-queue
+UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
+UNIT_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(UNIT_TEST_PROGRAMS))
+UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
+
 # xdiff and reftable libs may in turn depend on what is in libgit.a
 GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
 EXTLIBS =
@@ -1575,7 +1591,7 @@ endif
 
 ifdef LIBPCREDIR
        BASIC_CFLAGS += -I$(LIBPCREDIR)/include
-       EXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)
+       EXTLIBS += $(call libpath_template,$(LIBPCREDIR)/$(lib))
 endif
 
 ifdef HAVE_ALLOCA_H
@@ -1595,7 +1611,7 @@ else
        ifdef CURLDIR
                # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
                CURL_CFLAGS = -I$(CURLDIR)/include
-               CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib)
+               CURL_LIBCURL = $(call libpath_template,$(CURLDIR)/$(lib))
        else
                CURL_CFLAGS =
                CURL_LIBCURL =
@@ -1631,7 +1647,7 @@ else
        ifndef NO_EXPAT
                ifdef EXPATDIR
                        BASIC_CFLAGS += -I$(EXPATDIR)/include
-                       EXPAT_LIBEXPAT = -L$(EXPATDIR)/$(lib) $(CC_LD_DYNPATH)$(EXPATDIR)/$(lib) -lexpat
+                       EXPAT_LIBEXPAT = $(call libpath_template,$(EXPATDIR)/$(lib)) -lexpat
                else
                        EXPAT_LIBEXPAT = -lexpat
                endif
@@ -1644,7 +1660,7 @@ IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
 
 ifdef ZLIB_PATH
        BASIC_CFLAGS += -I$(ZLIB_PATH)/include
-       EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
+       EXTLIBS += $(call libpath_template,$(ZLIB_PATH)/$(lib))
 endif
 EXTLIBS += -lz
 
@@ -1652,7 +1668,7 @@ ifndef NO_OPENSSL
        OPENSSL_LIBSSL = -lssl
        ifdef OPENSSLDIR
                BASIC_CFLAGS += -I$(OPENSSLDIR)/include
-               OPENSSL_LINK = -L$(OPENSSLDIR)/$(lib) $(CC_LD_DYNPATH)$(OPENSSLDIR)/$(lib)
+               OPENSSL_LINK = $(call libpath_template,$(OPENSSLDIR)/$(lib))
        else
                OPENSSL_LINK =
        endif
@@ -1679,7 +1695,7 @@ ifndef NO_ICONV
        ifdef NEEDS_LIBICONV
                ifdef ICONVDIR
                        BASIC_CFLAGS += -I$(ICONVDIR)/include
-                       ICONV_LINK = -L$(ICONVDIR)/$(lib) $(CC_LD_DYNPATH)$(ICONVDIR)/$(lib)
+                       ICONV_LINK = $(call libpath_template,$(ICONVDIR)/$(lib))
                else
                        ICONV_LINK =
                endif
@@ -2342,7 +2358,7 @@ profile-fast: profile-clean
 
 all:: $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
 ifneq (,$X)
-       $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) $(OTHER_PROGRAMS))), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
+       $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) $(OTHER_PROGRAMS))), if test ! -d '$p' && test ! '$p' -ef '$p$X'; then $(RM) '$p'; fi;)
 endif
 
 all::
@@ -2676,6 +2692,7 @@ OBJECTS += $(TEST_OBJS)
 OBJECTS += $(XDIFF_OBJS)
 OBJECTS += $(FUZZ_OBJS)
 OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
+OBJECTS += $(UNIT_TEST_OBJS)
 
 ifndef NO_CURL
        OBJECTS += http.o http-walker.o remote-curl.o
@@ -3178,7 +3195,7 @@ endif
 
 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
 
-all:: $(TEST_PROGRAMS) $(test_bindir_programs)
+all:: $(TEST_PROGRAMS) $(test_bindir_programs) $(UNIT_TEST_PROGS)
 
 bin-wrappers/%: wrap-for-bin.sh
        $(call mkdir_p_parent_template)
@@ -3604,12 +3621,12 @@ rpm::
 .PHONY: rpm
 
 ifneq ($(INCLUDE_DLLS_IN_ARTIFACTS),)
-OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll)
+OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll t/unit-tests/bin/*.dll)
 endif
 
 artifacts-tar:: $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB) $(OTHER_PROGRAMS) \
                GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
-               $(MOFILES)
+               $(UNIT_TEST_PROGS) $(MOFILES)
        $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) \
                SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
        test -n "$(ARTIFACTS_DIRECTORY)"
@@ -3664,7 +3681,7 @@ cocciclean:
        $(RM) contrib/coccinelle/*.cocci.patch
 
 clean: profile-clean coverage-clean cocciclean
-       $(RM) -r .build
+       $(RM) -r .build $(UNIT_TEST_BIN)
        $(RM) po/git.pot po/git-core.pot
        $(RM) git.res
        $(RM) $(OBJECTS)
@@ -3838,15 +3855,26 @@ cover_db_html: cover_db
 #
 # make CC=clang CXX=clang++ \
 #      CFLAGS="-fsanitize=fuzzer-no-link,address" \
-#      LIB_FUZZING_ENGINE="-fsanitize=fuzzer" \
+#      LIB_FUZZING_ENGINE="-fsanitize=fuzzer,address" \
 #      fuzz-all
 #
-FUZZ_CXXFLAGS ?= $(CFLAGS)
+FUZZ_CXXFLAGS ?= $(ALL_CFLAGS)
 
 .PHONY: fuzz-all
 
-$(FUZZ_PROGRAMS): all
-       $(QUIET_LINK)$(CXX) $(FUZZ_CXXFLAGS) $(LIB_OBJS) $(BUILTIN_OBJS) \
-               $(XDIFF_OBJS) $(EXTLIBS) git.o $@.o $(LIB_FUZZING_ENGINE) -o $@
+$(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
+       $(QUIET_LINK)$(CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
+               -Wl,--allow-multiple-definition \
+               $(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
 
 fuzz-all: $(FUZZ_PROGRAMS)
+
+$(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_DIR)/test-lib.o $(GITLIBS) GIT-LDFLAGS
+       $(call mkdir_p_parent_template)
+       $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
+               $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
+
+.PHONY: build-unit-tests unit-tests
+build-unit-tests: $(UNIT_TEST_PROGS)
+unit-tests: $(UNIT_TEST_PROGS)
+       $(MAKE) -C t/ unit-tests
index 9879230ec4af3cd948e35b4778a07761f5365f2b..ae702771094d287a5dd6b4e183de5d80f46c2686 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.43.3.txt
\ No newline at end of file
+Documentation/RelNotes/2.45.0.txt
\ No newline at end of file
index 79eda168ebb7cdb739720c2c0d16a44484522822..68f525b35cfe650ebf440a1d879a761d55aa02e6 100644 (file)
@@ -1729,14 +1729,6 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
        if (mode == ADD_P_STASH)
                s.mode = &patch_mode_stash;
        else if (mode == ADD_P_RESET) {
-               /*
-                * NEEDSWORK: Instead of comparing to the literal "HEAD",
-                * compare the commit objects instead so that other ways of
-                * saying the same thing (such as "@") are also handled
-                * appropriately.
-                *
-                * This applies to the cases below too.
-                */
                if (!revision || !strcmp(revision, "HEAD"))
                        s.mode = &patch_mode_reset_head;
                else
index 50c79443ba749fc56437806c21a20755c1988714..4ba64ee5b2d315eeeaa6143f5c8c2053d066a830 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -33,52 +33,57 @@ static const char *advise_get_color(enum color_advice ix)
        return "";
 }
 
+enum advice_level {
+       ADVICE_LEVEL_NONE = 0,
+       ADVICE_LEVEL_DISABLED,
+       ADVICE_LEVEL_ENABLED,
+};
+
 static struct {
        const char *key;
-       int enabled;
+       enum advice_level level;
 } advice_setting[] = {
-       [ADVICE_ADD_EMBEDDED_REPO]                      = { "addEmbeddedRepo", 1 },
-       [ADVICE_ADD_EMPTY_PATHSPEC]                     = { "addEmptyPathspec", 1 },
-       [ADVICE_ADD_IGNORED_FILE]                       = { "addIgnoredFile", 1 },
-       [ADVICE_AM_WORK_DIR]                            = { "amWorkDir", 1 },
-       [ADVICE_AMBIGUOUS_FETCH_REFSPEC]                = { "ambiguousFetchRefspec", 1 },
-       [ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME]  = { "checkoutAmbiguousRemoteBranchName", 1 },
-       [ADVICE_COMMIT_BEFORE_MERGE]                    = { "commitBeforeMerge", 1 },
-       [ADVICE_DETACHED_HEAD]                          = { "detachedHead", 1 },
-       [ADVICE_SUGGEST_DETACHING_HEAD]                 = { "suggestDetachingHead", 1 },
-       [ADVICE_DIVERGING]                              = { "diverging", 1 },
-       [ADVICE_FETCH_SHOW_FORCED_UPDATES]              = { "fetchShowForcedUpdates", 1 },
-       [ADVICE_GRAFT_FILE_DEPRECATED]                  = { "graftFileDeprecated", 1 },
-       [ADVICE_IGNORED_HOOK]                           = { "ignoredHook", 1 },
-       [ADVICE_IMPLICIT_IDENTITY]                      = { "implicitIdentity", 1 },
-       [ADVICE_NESTED_TAG]                             = { "nestedTag", 1 },
-       [ADVICE_OBJECT_NAME_WARNING]                    = { "objectNameWarning", 1 },
-       [ADVICE_PUSH_ALREADY_EXISTS]                    = { "pushAlreadyExists", 1 },
-       [ADVICE_PUSH_FETCH_FIRST]                       = { "pushFetchFirst", 1 },
-       [ADVICE_PUSH_NEEDS_FORCE]                       = { "pushNeedsForce", 1 },
-       [ADVICE_PUSH_REF_NEEDS_UPDATE]                  = { "pushRefNeedsUpdate", 1 },
-
-       /* make this an alias for backward compatibility */
-       [ADVICE_PUSH_UPDATE_REJECTED_ALIAS]             = { "pushNonFastForward", 1 },
-
-       [ADVICE_PUSH_NON_FF_CURRENT]                    = { "pushNonFFCurrent", 1 },
-       [ADVICE_PUSH_NON_FF_MATCHING]                   = { "pushNonFFMatching", 1 },
-       [ADVICE_PUSH_UNQUALIFIED_REF_NAME]              = { "pushUnqualifiedRefName", 1 },
-       [ADVICE_PUSH_UPDATE_REJECTED]                   = { "pushUpdateRejected", 1 },
-       [ADVICE_RESET_NO_REFRESH_WARNING]               = { "resetNoRefresh", 1 },
-       [ADVICE_RESOLVE_CONFLICT]                       = { "resolveConflict", 1 },
-       [ADVICE_RM_HINTS]                               = { "rmHints", 1 },
-       [ADVICE_SEQUENCER_IN_USE]                       = { "sequencerInUse", 1 },
-       [ADVICE_SET_UPSTREAM_FAILURE]                   = { "setUpstreamFailure", 1 },
-       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { "skippedCherryPicks", 1 },
-       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { "statusAheadBehindWarning", 1 },
-       [ADVICE_STATUS_HINTS]                           = { "statusHints", 1 },
-       [ADVICE_STATUS_U_OPTION]                        = { "statusUoption", 1 },
-       [ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie", 1 },
-       [ADVICE_SUBMODULES_NOT_UPDATED]                 = { "submodulesNotUpdated", 1 },
-       [ADVICE_UPDATE_SPARSE_PATH]                     = { "updateSparsePath", 1 },
-       [ADVICE_WAITING_FOR_EDITOR]                     = { "waitingForEditor", 1 },
-       [ADVICE_WORKTREE_ADD_ORPHAN]                    = { "worktreeAddOrphan", 1 },
+       [ADVICE_ADD_EMBEDDED_REPO]                      = { "addEmbeddedRepo" },
+       [ADVICE_ADD_EMPTY_PATHSPEC]                     = { "addEmptyPathspec" },
+       [ADVICE_ADD_IGNORED_FILE]                       = { "addIgnoredFile" },
+       [ADVICE_AMBIGUOUS_FETCH_REFSPEC]                = { "ambiguousFetchRefspec" },
+       [ADVICE_AM_WORK_DIR]                            = { "amWorkDir" },
+       [ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME]  = { "checkoutAmbiguousRemoteBranchName" },
+       [ADVICE_COMMIT_BEFORE_MERGE]                    = { "commitBeforeMerge" },
+       [ADVICE_DETACHED_HEAD]                          = { "detachedHead" },
+       [ADVICE_DIVERGING]                              = { "diverging" },
+       [ADVICE_FETCH_SHOW_FORCED_UPDATES]              = { "fetchShowForcedUpdates" },
+       [ADVICE_FORCE_DELETE_BRANCH]                    = { "forceDeleteBranch" },
+       [ADVICE_GRAFT_FILE_DEPRECATED]                  = { "graftFileDeprecated" },
+       [ADVICE_IGNORED_HOOK]                           = { "ignoredHook" },
+       [ADVICE_IMPLICIT_IDENTITY]                      = { "implicitIdentity" },
+       [ADVICE_NESTED_TAG]                             = { "nestedTag" },
+       [ADVICE_OBJECT_NAME_WARNING]                    = { "objectNameWarning" },
+       [ADVICE_PUSH_ALREADY_EXISTS]                    = { "pushAlreadyExists" },
+       [ADVICE_PUSH_FETCH_FIRST]                       = { "pushFetchFirst" },
+       [ADVICE_PUSH_NEEDS_FORCE]                       = { "pushNeedsForce" },
+       [ADVICE_PUSH_NON_FF_CURRENT]                    = { "pushNonFFCurrent" },
+       [ADVICE_PUSH_NON_FF_MATCHING]                   = { "pushNonFFMatching" },
+       [ADVICE_PUSH_REF_NEEDS_UPDATE]                  = { "pushRefNeedsUpdate" },
+       [ADVICE_PUSH_UNQUALIFIED_REF_NAME]              = { "pushUnqualifiedRefName" },
+       [ADVICE_PUSH_UPDATE_REJECTED]                   = { "pushUpdateRejected" },
+       [ADVICE_PUSH_UPDATE_REJECTED_ALIAS]             = { "pushNonFastForward" }, /* backwards compatibility */
+       [ADVICE_RESET_NO_REFRESH_WARNING]               = { "resetNoRefresh" },
+       [ADVICE_RESOLVE_CONFLICT]                       = { "resolveConflict" },
+       [ADVICE_RM_HINTS]                               = { "rmHints" },
+       [ADVICE_SEQUENCER_IN_USE]                       = { "sequencerInUse" },
+       [ADVICE_SET_UPSTREAM_FAILURE]                   = { "setUpstreamFailure" },
+       [ADVICE_SKIPPED_CHERRY_PICKS]                   = { "skippedCherryPicks" },
+       [ADVICE_STATUS_AHEAD_BEHIND_WARNING]            = { "statusAheadBehindWarning" },
+       [ADVICE_STATUS_HINTS]                           = { "statusHints" },
+       [ADVICE_STATUS_U_OPTION]                        = { "statusUoption" },
+       [ADVICE_SUBMODULES_NOT_UPDATED]                 = { "submodulesNotUpdated" },
+       [ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie" },
+       [ADVICE_SUBMODULE_MERGE_CONFLICT]               = { "submoduleMergeConflict" },
+       [ADVICE_SUGGEST_DETACHING_HEAD]                 = { "suggestDetachingHead" },
+       [ADVICE_UPDATE_SPARSE_PATH]                     = { "updateSparsePath" },
+       [ADVICE_WAITING_FOR_EDITOR]                     = { "waitingForEditor" },
+       [ADVICE_WORKTREE_ADD_ORPHAN]                    = { "worktreeAddOrphan" },
 };
 
 static const char turn_off_instructions[] =
@@ -118,13 +123,13 @@ void advise(const char *advice, ...)
 
 int advice_enabled(enum advice_type type)
 {
-       switch(type) {
-       case ADVICE_PUSH_UPDATE_REJECTED:
-               return advice_setting[ADVICE_PUSH_UPDATE_REJECTED].enabled &&
-                      advice_setting[ADVICE_PUSH_UPDATE_REJECTED_ALIAS].enabled;
-       default:
-               return advice_setting[type].enabled;
-       }
+       int enabled = advice_setting[type].level != ADVICE_LEVEL_DISABLED;
+
+       if (type == ADVICE_PUSH_UPDATE_REJECTED)
+               return enabled &&
+                      advice_enabled(ADVICE_PUSH_UPDATE_REJECTED_ALIAS);
+
+       return enabled;
 }
 
 void advise_if_enabled(enum advice_type type, const char *advice, ...)
@@ -135,7 +140,8 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)
                return;
 
        va_start(params, advice);
-       vadvise(advice, 1, advice_setting[type].key, params);
+       vadvise(advice, !advice_setting[type].level, advice_setting[type].key,
+               params);
        va_end(params);
 }
 
@@ -164,7 +170,9 @@ int git_default_advice_config(const char *var, const char *value)
        for (i = 0; i < ARRAY_SIZE(advice_setting); i++) {
                if (strcasecmp(k, advice_setting[i].key))
                        continue;
-               advice_setting[i].enabled = git_config_bool(var, value);
+               advice_setting[i].level = git_config_bool(var, value)
+                                         ? ADVICE_LEVEL_ENABLED
+                                         : ADVICE_LEVEL_DISABLED;
                return 0;
        }
 
index 2affbe142616de0d329c9aaaaee9ca355fb73adf..7d0a821f5cb8a1818154852bbb76d7e15d4fe97b 100644 (file)
--- a/advice.h
+++ b/advice.h
@@ -10,18 +10,18 @@ struct string_list;
  * Add the new config variable to Documentation/config/advice.txt.
  * Call advise_if_enabled to print your advice.
  */
- enum advice_type {
+enum advice_type {
        ADVICE_ADD_EMBEDDED_REPO,
        ADVICE_ADD_EMPTY_PATHSPEC,
        ADVICE_ADD_IGNORED_FILE,
-       ADVICE_AM_WORK_DIR,
        ADVICE_AMBIGUOUS_FETCH_REFSPEC,
+       ADVICE_AM_WORK_DIR,
        ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME,
        ADVICE_COMMIT_BEFORE_MERGE,
        ADVICE_DETACHED_HEAD,
        ADVICE_DIVERGING,
-       ADVICE_SUGGEST_DETACHING_HEAD,
        ADVICE_FETCH_SHOW_FORCED_UPDATES,
+       ADVICE_FORCE_DELETE_BRANCH,
        ADVICE_GRAFT_FILE_DEPRECATED,
        ADVICE_IGNORED_HOOK,
        ADVICE_IMPLICIT_IDENTITY,
@@ -32,23 +32,25 @@ struct string_list;
        ADVICE_PUSH_NEEDS_FORCE,
        ADVICE_PUSH_NON_FF_CURRENT,
        ADVICE_PUSH_NON_FF_MATCHING,
+       ADVICE_PUSH_REF_NEEDS_UPDATE,
        ADVICE_PUSH_UNQUALIFIED_REF_NAME,
-       ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
        ADVICE_PUSH_UPDATE_REJECTED,
-       ADVICE_PUSH_REF_NEEDS_UPDATE,
+       ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
        ADVICE_RESET_NO_REFRESH_WARNING,
        ADVICE_RESOLVE_CONFLICT,
        ADVICE_RM_HINTS,
        ADVICE_SEQUENCER_IN_USE,
        ADVICE_SET_UPSTREAM_FAILURE,
+       ADVICE_SKIPPED_CHERRY_PICKS,
        ADVICE_STATUS_AHEAD_BEHIND_WARNING,
        ADVICE_STATUS_HINTS,
        ADVICE_STATUS_U_OPTION,
-       ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
        ADVICE_SUBMODULES_NOT_UPDATED,
+       ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
+       ADVICE_SUBMODULE_MERGE_CONFLICT,
+       ADVICE_SUGGEST_DETACHING_HEAD,
        ADVICE_UPDATE_SPARSE_PATH,
        ADVICE_WAITING_FOR_EDITOR,
-       ADVICE_SKIPPED_CHERRY_PICKS,
        ADVICE_WORKTREE_ADD_ORPHAN,
 };
 
diff --git a/apply.c b/apply.c
index 7608e3301ca0727dcfec0a579ed46390afa41ab0..432837a674c3cc559f762aa4b7766bd8f43177e0 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -77,7 +77,8 @@ static int parse_whitespace_option(struct apply_state *state, const char *option
                return 0;
        }
        /*
-        * Please update $__git_whitespacelist in git-completion.bash
+        * Please update $__git_whitespacelist in git-completion.bash,
+        * Documentation/git-apply.txt, and Documentation/git-am.txt
         * when you add new options.
         */
        return error(_("unrecognized whitespace option '%s'"), option);
@@ -2219,7 +2220,8 @@ static void reverse_patches(struct patch *p)
                struct fragment *frag = p->fragments;
 
                SWAP(p->new_name, p->old_name);
-               SWAP(p->new_mode, p->old_mode);
+               if (p->new_mode)
+                       SWAP(p->new_mode, p->old_mode);
                SWAP(p->is_new, p->is_delete);
                SWAP(p->lines_added, p->lines_deleted);
                SWAP(p->old_oid_prefix, p->new_oid_prefix);
@@ -3777,8 +3779,17 @@ static int check_preimage(struct apply_state *state,
                return error_errno("%s", old_name);
        }
 
-       if (!state->cached && !previous)
-               st_mode = ce_mode_from_stat(*ce, st->st_mode);
+       if (!state->cached && !previous) {
+               if (*ce && !(*ce)->ce_mode)
+                       BUG("ce_mode == 0 for path '%s'", old_name);
+
+               if (trust_executable_bit)
+                       st_mode = ce_mode_from_stat(*ce, st->st_mode);
+               else if (*ce)
+                       st_mode = (*ce)->ce_mode;
+               else
+                       st_mode = patch->old_mode;
+       }
 
        if (patch->is_new < 0)
                patch->is_new = 0;
index f2a0ed77523b457fa17497498d3ffb4499773a1f..8ae30125f84c463118d70b69eae88d4d21d31905 100644 (file)
@@ -365,7 +365,7 @@ static struct archiver *find_tar_filter(const char *name, size_t len)
        int i;
        for (i = 0; i < nr_tar_filters; i++) {
                struct archiver *ar = tar_filters[i];
-               if (!strncmp(ar->name, name, len) && !ar->name[len])
+               if (!xstrncmpz(ar->name, name, len))
                        return ar;
        }
        return NULL;
diff --git a/attr.c b/attr.c
index e62876dfd3e9beae50d18da63f15285d5974b8ec..679e42258c2b205bfceb9d065295c47c375442d4 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -17,6 +17,7 @@
 #include "utf8.h"
 #include "quote.h"
 #include "read-cache-ll.h"
+#include "refs.h"
 #include "revision.h"
 #include "object-store-ll.h"
 #include "setup.h"
@@ -183,6 +184,15 @@ static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check)
        }
 }
 
+/*
+ * Atribute name cannot begin with "builtin_" which
+ * is a reserved namespace for built in attributes values.
+ */
+static int attr_name_reserved(const char *name)
+{
+       return starts_with(name, "builtin_");
+}
+
 static int attr_name_valid(const char *name, size_t namelen)
 {
        /*
@@ -315,7 +325,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
                        cp++;
                        len--;
                }
-               if (!attr_name_valid(cp, len)) {
+               if (!attr_name_valid(cp, len) || attr_name_reserved(cp)) {
                        report_invalid_attr(cp, len, src, lineno);
                        return NULL;
                }
@@ -379,7 +389,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
                name += strlen(ATTRIBUTE_MACRO_PREFIX);
                name += strspn(name, blank);
                namelen = strcspn(name, blank);
-               if (!attr_name_valid(name, namelen)) {
+               if (!attr_name_valid(name, namelen) || attr_name_reserved(name)) {
                        report_invalid_attr(name, namelen, src, lineno);
                        goto fail_return;
                }
@@ -1240,6 +1250,85 @@ static struct object_id *default_attr_source(void)
        return &attr_source;
 }
 
+static const char *interned_mode_string(unsigned int mode)
+{
+       static struct {
+               unsigned int val;
+               char str[7];
+       } mode_string[] = {
+               { .val = 0040000 },
+               { .val = 0100644 },
+               { .val = 0100755 },
+               { .val = 0120000 },
+               { .val = 0160000 },
+       };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(mode_string); i++) {
+               if (mode_string[i].val != mode)
+                       continue;
+               if (!*mode_string[i].str)
+                       snprintf(mode_string[i].str, sizeof(mode_string[i].str),
+                                "%06o", mode);
+               return mode_string[i].str;
+       }
+       BUG("Unsupported mode 0%o", mode);
+}
+
+static const char *builtin_object_mode_attr(struct index_state *istate, const char *path)
+{
+       unsigned int mode;
+
+       if (direction == GIT_ATTR_CHECKIN) {
+               struct object_id oid;
+               struct stat st;
+               if (lstat(path, &st))
+                       die_errno(_("unable to stat '%s'"), path);
+               mode = canon_mode(st.st_mode);
+               if (S_ISDIR(mode)) {
+                       /*
+                        *`path` is either a directory or it is a submodule,
+                        * in which case it is already indexed as submodule
+                        * or it does not exist in the index yet and we need to
+                        * check if we can resolve to a ref.
+                       */
+                       int pos = index_name_pos(istate, path, strlen(path));
+                       if (pos >= 0) {
+                                if (S_ISGITLINK(istate->cache[pos]->ce_mode))
+                                        mode = istate->cache[pos]->ce_mode;
+                       } else if (resolve_gitlink_ref(path, "HEAD", &oid) == 0) {
+                               mode = S_IFGITLINK;
+                       }
+               }
+       } else {
+               /*
+                * For GIT_ATTR_CHECKOUT and GIT_ATTR_INDEX we only check
+                * for mode in the index.
+                */
+               int pos = index_name_pos(istate, path, strlen(path));
+               if (pos >= 0)
+                       mode = istate->cache[pos]->ce_mode;
+               else
+                       return ATTR__UNSET;
+       }
+
+       return interned_mode_string(mode);
+}
+
+
+static const char *compute_builtin_attr(struct index_state *istate,
+                                         const char *path,
+                                         const struct git_attr *attr) {
+       static const struct git_attr *object_mode_attr;
+
+       if (!object_mode_attr)
+               object_mode_attr = git_attr("builtin_objectmode");
+
+       if (attr == object_mode_attr)
+               return builtin_object_mode_attr(istate, path);
+       return ATTR__UNSET;
+}
+
 void git_check_attr(struct index_state *istate,
                    const char *path,
                    struct attr_check *check)
@@ -1253,7 +1342,7 @@ void git_check_attr(struct index_state *istate,
                unsigned int n = check->items[i].attr->attr_nr;
                const char *value = check->all_attrs[n].value;
                if (value == ATTR__UNKNOWN)
-                       value = ATTR__UNSET;
+                       value = compute_builtin_attr(istate, path, check->all_attrs[n].attr);
                check->items[i].value = value;
        }
 }
index 8487f8cd1bd740df2bd9f5af342f9373debf84da..f75e50c339764db8a6b9f2266281541203d4e76f 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -158,6 +158,9 @@ static void show_list(const char *debug, int counted, int nr,
                const char *subject_start;
                int subject_len;
 
+               if (!buf)
+                       die(_("unable to read %s"), oid_to_hex(&commit->object.oid));
+
                fprintf(stderr, "%c%c%c ",
                        (commit_flags & TREESAME) ? ' ' : 'T',
                        (commit_flags & UNINTERESTING) ? 'U' : ' ',
@@ -470,7 +473,6 @@ static int read_bisect_refs(void)
 }
 
 static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
-static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
 static GIT_PATH_FUNC(git_path_bisect_ancestors_ok, "BISECT_ANCESTORS_OK")
 static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
 static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START")
@@ -706,26 +708,10 @@ static enum bisect_error error_if_skipped_commits(struct commit_list *tried,
 
 static int is_expected_rev(const struct object_id *oid)
 {
-       const char *filename = git_path_bisect_expected_rev();
-       struct stat st;
-       struct strbuf str = STRBUF_INIT;
-       FILE *fp;
-       int res = 0;
-
-       if (stat(filename, &st) || !S_ISREG(st.st_mode))
-               return 0;
-
-       fp = fopen_or_warn(filename, "r");
-       if (!fp)
+       struct object_id expected_oid;
+       if (read_ref("BISECT_EXPECTED_REV", &expected_oid))
                return 0;
-
-       if (strbuf_getline_lf(&str, fp) != EOF)
-               res = !strcmp(str.buf, oid_to_hex(oid));
-
-       strbuf_release(&str);
-       fclose(fp);
-
-       return res;
+       return oideq(oid, &expected_oid);
 }
 
 enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
@@ -1184,10 +1170,10 @@ int bisect_clean_state(void)
        struct string_list refs_for_removal = STRING_LIST_INIT_NODUP;
        for_each_ref_in("refs/bisect", mark_for_removal, (void *) &refs_for_removal);
        string_list_append(&refs_for_removal, xstrdup("BISECT_HEAD"));
+       string_list_append(&refs_for_removal, xstrdup("BISECT_EXPECTED_REV"));
        result = delete_refs("bisect: remove", &refs_for_removal, REF_NO_DEREF);
        refs_for_removal.strdup_strings = 1;
        string_list_clear(&refs_for_removal, 0);
-       unlink_or_warn(git_path_bisect_expected_rev());
        unlink_or_warn(git_path_bisect_ancestors_ok());
        unlink_or_warn(git_path_bisect_log());
        unlink_or_warn(git_path_bisect_names());
index 534594f7f8006d11ebb9b8d10712b6fc6191a043..6719a181bd1f03af21b92d8be71a93142ef700e7 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -817,8 +817,9 @@ void remove_merge_branch_state(struct repository *r)
        unlink(git_path_merge_rr(r));
        unlink(git_path_merge_msg(r));
        unlink(git_path_merge_mode(r));
-       unlink(git_path_auto_merge(r));
-       save_autostash(git_path_merge_autostash(r));
+       refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
+                       NULL, REF_NO_DEREF);
+       save_autostash_ref(r, "MERGE_AUTOSTASH");
 }
 
 void remove_branch_state(struct repository *r, int verbose)
index d560baa6618ac9e021dc7f957b942466ac6e35b3..28280636da8f52deabea4472d52f574ecb3a4945 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -211,6 +211,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix);
 int cmd_remote_ext(int argc, const char **argv, const char *prefix);
 int cmd_remote_fd(int argc, const char **argv, const char *prefix);
 int cmd_repack(int argc, const char **argv, const char *prefix);
+int cmd_replay(int argc, const char **argv, const char *prefix);
 int cmd_rerere(int argc, const char **argv, const char *prefix);
 int cmd_reset(int argc, const char **argv, const char *prefix);
 int cmd_restore(int argc, const char **argv, const char *prefix);
index 2151c45fbf097253af1b56d34622f69f06921456..ada7719561f0ec324238e613a9788a5f5a2981eb 100644 (file)
@@ -421,7 +421,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
         * Check the "pathspec '%s' did not match any files" block
         * below before enabling new magic.
         */
-       parse_pathspec(&pathspec, PATHSPEC_ATTR,
+       parse_pathspec(&pathspec, 0,
                       PATHSPEC_PREFER_FULL |
                       PATHSPEC_SYMLINK_LEADING_PATH,
                       prefix, argv);
@@ -430,7 +430,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                if (pathspec.nr)
                        die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
 
-               parse_pathspec_file(&pathspec, PATHSPEC_ATTR,
+               parse_pathspec_file(&pathspec, 0,
                                    PATHSPEC_PREFER_FULL |
                                    PATHSPEC_SYMLINK_LEADING_PATH,
                                    prefix, pathspec_from_file, pathspec_file_nul);
@@ -501,7 +501,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                               PATHSPEC_LITERAL |
                               PATHSPEC_GLOB |
                               PATHSPEC_ICASE |
-                              PATHSPEC_EXCLUDE);
+                              PATHSPEC_EXCLUDE |
+                              PATHSPEC_ATTR);
 
                for (i = 0; i < pathspec.nr; i++) {
                        const char *path = pathspec.items[i].match;
index 032beaa635339a81d55bbcf8ce4345438d79f4c9..f69c3f7e43df4623be83509b7c9070d69072dc2a 100644 (file)
@@ -16,7 +16,6 @@
 #include "revision.h"
 
 static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
-static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
 static GIT_PATH_FUNC(git_path_bisect_ancestors_ok, "BISECT_ANCESTORS_OK")
 static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START")
 static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
@@ -919,7 +918,6 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
        const char *state;
        int i, verify_expected = 1;
        struct object_id oid, expected;
-       struct strbuf buf = STRBUF_INIT;
        struct oid_array revs = OID_ARRAY_INIT;
 
        if (!argc)
@@ -974,10 +972,8 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
                oid_array_append(&revs, &commit->object.oid);
        }
 
-       if (strbuf_read_file(&buf, git_path_bisect_expected_rev(), 0) < the_hash_algo->hexsz ||
-           get_oid_hex(buf.buf, &expected) < 0)
+       if (read_ref("BISECT_EXPECTED_REV", &expected))
                verify_expected = 0; /* Ignore invalid file contents */
-       strbuf_release(&buf);
 
        for (i = 0; i < revs.nr; i++) {
                if (bisect_write(state, oid_to_hex(&revs.oid[i]), terms, 0)) {
@@ -986,7 +982,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
                }
                if (verify_expected && !oideq(&revs.oid[i], &expected)) {
                        unlink_or_warn(git_path_bisect_ancestors_ok());
-                       unlink_or_warn(git_path_bisect_expected_rev());
+                       delete_ref(NULL, "BISECT_EXPECTED_REV", NULL, REF_NO_DEREF);
                        verify_expected = 0;
                }
        }
index 6e30d5eac53d66199425f360801d5a90780050c8..cfb63cce5fb9dff64106907947d0df25a2c25489 100644 (file)
@@ -24,6 +24,7 @@
 #include "ref-filter.h"
 #include "worktree.h"
 #include "help.h"
+#include "advice.h"
 #include "commit-reach.h"
 
 static const char * const builtin_branch_usage[] = {
@@ -42,7 +43,6 @@ static const char *head;
 static struct object_id head_oid;
 static int recurse_submodules = 0;
 static int submodule_propagate_branches = 0;
-static int omit_empty = 0;
 
 static int branch_use_color = -1;
 static char branch_colors[][COLOR_MAXLEN] = {
@@ -191,9 +191,10 @@ static int check_branch_commit(const char *branchname, const char *refname,
                return -1;
        }
        if (!force && !branch_merged(kinds, branchname, rev, head_rev)) {
-               error(_("the branch '%s' is not fully merged.\n"
-                     "If you are sure you want to delete it, "
-                     "run 'git branch -D %s'"), branchname, branchname);
+               error(_("the branch '%s' is not fully merged"), branchname);
+               advise_if_enabled(ADVICE_FORCE_DELETE_BRANCH,
+                                 _("If you are sure you want to delete it, "
+                                 "run 'git branch -D %s'"), branchname);
                return -1;
        }
        return 0;
@@ -435,8 +436,6 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
 {
        int i;
        struct ref_array array;
-       struct strbuf out = STRBUF_INIT;
-       struct strbuf err = STRBUF_INIT;
        int maxwidth = 0;
        const char *remote_prefix = "";
        char *to_free = NULL;
@@ -466,24 +465,27 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortin
        filter_ahead_behind(the_repository, format, &array);
        ref_array_sort(sorting, &array);
 
-       for (i = 0; i < array.nr; i++) {
-               strbuf_reset(&err);
-               strbuf_reset(&out);
-               if (format_ref_array_item(array.items[i], format, &out, &err))
-                       die("%s", err.buf);
-               if (column_active(colopts)) {
-                       assert(!filter->verbose && "--column and --verbose are incompatible");
-                        /* format to a string_list to let print_columns() do its job */
+       if (column_active(colopts)) {
+               struct strbuf out = STRBUF_INIT, err = STRBUF_INIT;
+
+               assert(!filter->verbose && "--column and --verbose are incompatible");
+
+               for (i = 0; i < array.nr; i++) {
+                       strbuf_reset(&err);
+                       strbuf_reset(&out);
+                       if (format_ref_array_item(array.items[i], format, &out, &err))
+                               die("%s", err.buf);
+
+                       /* format to a string_list to let print_columns() do its job */
                        string_list_append(output, out.buf);
-               } else {
-                       fwrite(out.buf, 1, out.len, stdout);
-                       if (out.len || !omit_empty)
-                               putchar('\n');
                }
+
+               strbuf_release(&err);
+               strbuf_release(&out);
+       } else {
+               print_formatted_ref_array(&array, format);
        }
 
-       strbuf_release(&err);
-       strbuf_release(&out);
        ref_array_clear(&array);
        free(to_free);
 }
@@ -734,7 +736,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                OPT_BIT('D', NULL, &delete, N_("delete branch (even if not merged)"), 2),
                OPT_BIT('m', "move", &rename, N_("move/rename a branch and its reflog"), 1),
                OPT_BIT('M', NULL, &rename, N_("move/rename a branch, even if target exists"), 2),
-               OPT_BOOL(0, "omit-empty",  &omit_empty,
+               OPT_BOOL(0, "omit-empty",  &format.array_opts.omit_empty,
                        N_("do not output a newline after empty formatted refs")),
                OPT_BIT('c', "copy", &copy, N_("copy a branch and its reflog"), 1),
                OPT_BIT('C', NULL, &copy, N_("copy a branch, even if target exists"), 2),
@@ -764,7 +766,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_branch_usage, options);
 
+       /*
+        * Try to set sort keys from config. If config does not set any,
+        * fall back on default (refname) sorting.
+        */
        git_config(git_branch_config, &sorting_options);
+       if (!sorting_options.nr)
+               string_list_append(&sorting_options, "refname");
 
        track = git_branch_track;
 
index 7d4899348a387b1a07377c2d968d7574a74d219d..bbf851138ec40875367aba94bc5b5de29b8dbe77 100644 (file)
@@ -221,6 +221,10 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
                                                                     &type,
                                                                     &size);
                                const char *target;
+
+                               if (!buffer)
+                                       die(_("unable to read %s"), oid_to_hex(&oid));
+
                                if (!skip_prefix(buffer, "object ", &target) ||
                                    get_oid_hex(target, &blob_oid))
                                        die("%s not a valid tag", oid_to_hex(&oid));
@@ -416,6 +420,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
 
                contents = repo_read_object_file(the_repository, oid, &type,
                                                 &size);
+               if (!contents)
+                       die("object %s disappeared", oid_to_hex(oid));
 
                if (use_mailmap) {
                        size_t s = size;
@@ -423,8 +429,6 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
                        size = cast_size_t_to_ulong(s);
                }
 
-               if (!contents)
-                       die("object %s disappeared", oid_to_hex(oid));
                if (type != data->type)
                        die("object %s changed type!?", oid_to_hex(oid));
                if (data->info.sizep && size != data->size && !use_mailmap)
@@ -481,6 +485,8 @@ static void batch_object_write(const char *obj_name,
 
                        buf = repo_read_object_file(the_repository, &data->oid, &data->type,
                                                    &data->size);
+                       if (!buf)
+                               die(_("unable to read %s"), oid_to_hex(&data->oid));
                        buf = replace_idents_using_mailmap(buf, &s);
                        data->size = cast_size_t_to_ulong(s);
 
index 3a7bfde158801653932f4769927dd4ce717d9457..15293a30134094f699d15035232bbc644277910c 100644 (file)
@@ -704,7 +704,8 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
        init_checkout_metadata(&opts.meta, info->refname,
                               info->commit ? &info->commit->object.oid : null_oid(),
                               NULL);
-       parse_tree(tree);
+       if (parse_tree(tree) < 0)
+               return 128;
        init_tree_desc(&tree_desc, tree->buffer, tree->size);
        switch (unpack_trees(1, &tree_desc, &opts)) {
        case -2:
@@ -783,9 +784,15 @@ static int merge_working_tree(const struct checkout_opts *opts,
                if (new_branch_info->commit)
                        BUG("'switch --orphan' should never accept a commit as starting point");
                new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
-       } else
+               if (!new_tree)
+                       BUG("unable to read empty tree");
+       } else {
                new_tree = repo_get_commit_tree(the_repository,
                                                new_branch_info->commit);
+               if (!new_tree)
+                       return error(_("unable to read tree (%s)"),
+                                    oid_to_hex(&new_branch_info->commit->object.oid));
+       }
        if (opts->discard_changes) {
                ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
                if (ret)
@@ -820,7 +827,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
                                oid_to_hex(old_commit_oid));
 
                init_tree_desc(&trees[0], tree->buffer, tree->size);
-               parse_tree(new_tree);
+               if (parse_tree(new_tree) < 0)
+                       exit(128);
                tree = new_tree;
                init_tree_desc(&trees[1], tree->buffer, tree->size);
 
@@ -1224,7 +1232,9 @@ static void setup_new_branch_info_and_source_tree(
        struct tree **source_tree = &opts->source_tree;
        struct object_id branch_rev;
 
-       new_branch_info->name = xstrdup(arg);
+       /* treat '@' as a shortcut for 'HEAD' */
+       new_branch_info->name = !strcmp(arg, "@") ? xstrdup("HEAD") :
+                                                   xstrdup(arg);
        setup_branch_path(new_branch_info);
 
        if (!check_refname_format(new_branch_info->path, 0) &&
@@ -1238,10 +1248,15 @@ static void setup_new_branch_info_and_source_tree(
        if (!new_branch_info->commit) {
                /* not a commit */
                *source_tree = parse_tree_indirect(rev);
+               if (!*source_tree)
+                       die(_("unable to read tree (%s)"), oid_to_hex(rev));
        } else {
                parse_commit_or_die(new_branch_info->commit);
                *source_tree = repo_get_commit_tree(the_repository,
                                                    new_branch_info->commit);
+               if (!*source_tree)
+                       die(_("unable to read tree (%s)"),
+                           oid_to_hex(&new_branch_info->commit->object.oid));
        }
 }
 
@@ -1515,6 +1530,26 @@ static void die_if_some_operation_in_progress(void)
        wt_status_state_free_buffers(&state);
 }
 
+/*
+ * die if attempting to checkout an existing branch that is in use
+ * in another worktree, unless ignore-other-wortrees option is given.
+ * The check is bypassed when the branch is already the current one,
+ * as it will not make things any worse.
+ */
+static void die_if_switching_to_a_branch_in_use(struct checkout_opts *opts,
+                                               const char *full_ref)
+{
+       int flags;
+       char *head_ref;
+
+       if (opts->ignore_other_worktrees)
+               return;
+       head_ref = resolve_refdup("HEAD", 0, NULL, &flags);
+       if (head_ref && (!(flags & REF_ISSYMREF) || strcmp(head_ref, full_ref)))
+               die_if_checked_out(full_ref, 1);
+       free(head_ref);
+}
+
 static int checkout_branch(struct checkout_opts *opts,
                           struct branch_info *new_branch_info)
 {
@@ -1575,14 +1610,15 @@ static int checkout_branch(struct checkout_opts *opts,
        if (!opts->can_switch_when_in_progress)
                die_if_some_operation_in_progress();
 
-       if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
-           !opts->ignore_other_worktrees) {
-               int flag;
-               char *head_ref = resolve_refdup("HEAD", 0, NULL, &flag);
-               if (head_ref &&
-                   (!(flag & REF_ISSYMREF) || strcmp(head_ref, new_branch_info->path)))
-                       die_if_checked_out(new_branch_info->path, 1);
-               free(head_ref);
+       /* "git checkout <branch>" */
+       if (new_branch_info->path && !opts->force_detach && !opts->new_branch)
+               die_if_switching_to_a_branch_in_use(opts, new_branch_info->path);
+
+       /* "git checkout -B <branch>" */
+       if (opts->new_branch_force) {
+               char *full_ref = xstrfmt("refs/heads/%s", opts->new_branch);
+               die_if_switching_to_a_branch_in_use(opts, full_ref);
+               free(full_ref);
        }
 
        if (!new_branch_info->commit && opts->new_branch) {
index 315befa13356029f918dbcb99248c474a6677eeb..10e98af95002118e9e9978009264db195bd2d770 100644 (file)
@@ -71,6 +71,7 @@ static char *remote_name = NULL;
 static char *option_branch = NULL;
 static struct string_list option_not = STRING_LIST_INIT_NODUP;
 static const char *real_git_dir;
+static const char *ref_format;
 static char *option_upload_pack = "git-upload-pack";
 static int option_verbosity;
 static int option_progress = -1;
@@ -156,6 +157,8 @@ static struct option builtin_clone_options[] = {
                    N_("any cloned submodules will be shallow")),
        OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
                   N_("separate git dir from working tree")),
+       OPT_STRING(0, "ref-format", &ref_format, N_("format"),
+                  N_("specify the reference format to use")),
        OPT_STRING_LIST('c', "config", &option_config, N_("key=value"),
                        N_("set config inside the new repository")),
        OPT_STRING_LIST(0, "server-option", &server_options,
@@ -735,7 +738,8 @@ static int checkout(int submodule_progress, int filter_submodules)
        tree = parse_tree_indirect(&oid);
        if (!tree)
                die(_("unable to parse commit %s"), oid_to_hex(&oid));
-       parse_tree(tree);
+       if (parse_tree(tree) < 0)
+               exit(128);
        init_tree_desc(&t, tree->buffer, tree->size);
        if (unpack_trees(1, &t, &opts) < 0)
                die(_("unable to checkout working tree"));
@@ -931,6 +935,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        int submodule_progress;
        int filter_submodules = 0;
        int hash_algo;
+       unsigned int ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
        const int do_not_override_repo_unix_permissions = -1;
 
        struct transport_ls_refs_options transport_ls_refs_options =
@@ -956,6 +961,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (option_single_branch == -1)
                option_single_branch = deepen ? 1 : 0;
 
+       if (ref_format) {
+               ref_storage_format = ref_storage_format_by_name(ref_format);
+               if (ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)
+                       die(_("unknown ref storage format '%s'"), ref_format);
+       }
+
        if (option_mirror)
                option_bare = 1;
 
@@ -1100,8 +1111,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                }
        }
 
-       init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
-               do_not_override_repo_unix_permissions, INIT_DB_QUIET);
+       /*
+        * Initialize the repository, but skip initializing the reference
+        * database. We do not yet know about the object format of the
+        * repository, and reference backends may persist that information into
+        * their on-disk data structures.
+        */
+       init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN,
+               ref_storage_format, NULL,
+               do_not_override_repo_unix_permissions, INIT_DB_QUIET | INIT_DB_SKIP_REFDB);
 
        if (real_git_dir) {
                free((char *)git_dir);
@@ -1188,10 +1206,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (option_required_reference.nr || option_optional_reference.nr)
                setup_reference();
 
-       if (option_sparse_checkout && git_sparse_checkout_init(dir))
-               return 1;
-
-       remote = remote_get(remote_name);
+       remote = remote_get_early(remote_name);
 
        refspec_appendf(&remote->fetch, "+%s*:%s*", src_ref_prefix,
                        branch_top.buf);
@@ -1269,6 +1284,27 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (transport->smart_options && !deepen && !filter_options.choice)
                transport->smart_options->check_self_contained_and_connected = 1;
 
+       strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+       refspec_ref_prefixes(&remote->fetch,
+                            &transport_ls_refs_options.ref_prefixes);
+       if (option_branch)
+               expand_ref_prefix(&transport_ls_refs_options.ref_prefixes,
+                                 option_branch);
+       if (!option_no_tags)
+               strvec_push(&transport_ls_refs_options.ref_prefixes,
+                           "refs/tags/");
+
+       refs = transport_get_remote_refs(transport, &transport_ls_refs_options);
+
+       /*
+        * Now that we know what algorithm the remote side is using, let's set
+        * ours to the same thing.
+        */
+       hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
+       initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1);
+       repo_set_hash_algo(the_repository, hash_algo);
+       create_reference_database(the_repository->ref_storage_format, NULL, 1);
+
        /*
         * Before fetching from the remote, download and install bundle
         * data from the --bundle-uri option.
@@ -1284,24 +1320,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                                bundle_uri);
                else if (has_heuristic)
                        git_config_set_gently("fetch.bundleuri", bundle_uri);
-       }
-
-       strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
-       refspec_ref_prefixes(&remote->fetch,
-                            &transport_ls_refs_options.ref_prefixes);
-       if (option_branch)
-               expand_ref_prefix(&transport_ls_refs_options.ref_prefixes,
-                                 option_branch);
-       if (!option_no_tags)
-               strvec_push(&transport_ls_refs_options.ref_prefixes,
-                           "refs/tags/");
-
-       refs = transport_get_remote_refs(transport, &transport_ls_refs_options);
-
-       if (refs)
-               mapped_refs = wanted_peer_refs(refs, &remote->fetch);
-
-       if (!bundle_uri) {
+       } else {
                /*
                * Populate transport->got_remote_bundle_uri and
                * transport->bundle_uri. We might get nothing.
@@ -1322,13 +1341,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                }
        }
 
-               /*
-                * Now that we know what algorithm the remote side is using,
-                * let's set ours to the same thing.
-                */
-       hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
-       initialize_repository_version(hash_algo, 1);
-       repo_set_hash_algo(the_repository, hash_algo);
+       if (refs)
+               mapped_refs = wanted_peer_refs(refs, &remote->fetch);
 
        if (mapped_refs) {
                /*
@@ -1431,6 +1445,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                dissociate_from_references();
        }
 
+       if (option_sparse_checkout && git_sparse_checkout_init(dir))
+               return 1;
+
        junk_mode = JUNK_LEAVE_REPO;
        err = checkout(submodule_progress, filter_submodules);
 
index e80218f81f94b5fc7a3e4605527556da336bb6ff..10ff7e01668203ce1b9233a90056abb65bc75e73 100644 (file)
@@ -45,6 +45,8 @@ int cmd_column(int argc, const char **argv, const char *prefix)
        memset(&copts, 0, sizeof(copts));
        copts.padding = 1;
        argc = parse_options(argc, argv, prefix, options, builtin_column_usage, 0);
+       if (copts.padding < 0)
+               die(_("%s must be non-negative"), "--padding");
        if (argc)
                usage_with_options(builtin_column_usage, options);
        if (real_command || command) {
index 666ad574a46b1218def7201e581e969f90e57d48..7102ee90a0094b12560108eebe38f2637f83e701 100644 (file)
@@ -21,7 +21,7 @@
        N_("git commit-graph write [--object-dir <dir>] [--append]\n" \
           "                       [--split[=<strategy>]] [--reachable | --stdin-packs | --stdin-commits]\n" \
           "                       [--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress]\n" \
-          "                       <split options>")
+          "                       <split-options>")
 
 static const char * builtin_commit_graph_verify_usage[] = {
        BUILTIN_COMMIT_GRAPH_VERIFY_USAGE,
index ef4cb92fc7e0ee2eb0482ec595a02a9b5ea6f30f..a91197245f18ed7b73eee64d3d5d930ca164bb06 100644 (file)
@@ -331,7 +331,8 @@ static void create_base_index(const struct commit *current_head)
        tree = parse_tree_indirect(&current_head->object.oid);
        if (!tree)
                die(_("failed to unpack HEAD tree object"));
-       parse_tree(tree);
+       if (parse_tree(tree) < 0)
+               exit(128);
        init_tree_desc(&t, tree->buffer, tree->size);
        if (unpack_trees(1, &t, &opts))
                exit(128); /* We've already reported the error, finish dying */
@@ -1875,7 +1876,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                                     &oid, flags);
        }
 
-       apply_autostash(git_path_merge_autostash(the_repository));
+       apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
 
 cleanup:
        strbuf_release(&author_ident);
index 11a4d4ef1411222f3750c760b68efd10180148c0..b55bfae7d66df0cea54313f677e1a924a4a579b3 100644 (file)
@@ -708,10 +708,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
        }
 
        if (use_global_config) {
-               char *user_config, *xdg_config;
-
-               git_global_config(&user_config, &xdg_config);
-               if (!user_config)
+               given_config_source.file = git_global_config();
+               if (!given_config_source.file)
                        /*
                         * It is unknown if HOME/.gitconfig exists, so
                         * we do not know if we should write to XDG
@@ -719,19 +717,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                         * is set and points at a sane location.
                         */
                        die(_("$HOME not set"));
-
                given_config_source.scope = CONFIG_SCOPE_GLOBAL;
-
-               if (access_or_warn(user_config, R_OK, 0) &&
-                   xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
-                       given_config_source.file = xdg_config;
-                       free(user_config);
-               } else {
-                       given_config_source.file = user_config;
-                       free(xdg_config);
-               }
-       }
-       else if (use_system_config) {
+       } else if (use_system_config) {
                given_config_source.file = git_system_config();
                given_config_source.scope = CONFIG_SCOPE_SYSTEM;
        } else if (use_local_config) {
@@ -760,7 +747,6 @@ int cmd_config(int argc, const char **argv, const char *prefix)
                given_config_source.scope = CONFIG_SCOPE_COMMAND;
        }
 
-
        if (respect_includes_opt == -1)
                config_options.respect_includes = !given_config_source.file;
        else
index f18f0809f9c7f78874eaddfd869c5fc5d11831e0..4693d18cc94f09ecf760c4662753583052ebc4c6 100644 (file)
@@ -136,8 +136,7 @@ static int anonymized_entry_cmp(const void *cmp_data UNUSED,
        a = container_of(eptr, const struct anonymized_entry, hash);
        if (keydata) {
                const struct anonymized_entry_key *key = keydata;
-               int equal = !strncmp(a->orig, key->orig, key->orig_len) &&
-                           !a->orig[key->orig_len];
+               int equal = !xstrncmpz(a->orig, key->orig, key->orig_len);
                return !equal;
        }
 
index 119f1a72ac6605b65937af3b7cbc651b4c695c0d..0a7a1a34765483e9f207ec26c5ca408df88c9dfc 100644 (file)
@@ -100,6 +100,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
 
 struct fetch_config {
        enum display_format display_format;
+       int all;
        int prune;
        int prune_tags;
        int show_forced_updates;
@@ -113,6 +114,11 @@ static int git_fetch_config(const char *k, const char *v,
 {
        struct fetch_config *fetch_config = cb;
 
+       if (!strcmp(k, "fetch.all")) {
+               fetch_config->all = git_config_bool(k, v);
+               return 0;
+       }
+
        if (!strcmp(k, "fetch.prune")) {
                fetch_config->prune = git_config_bool(k, v);
                return 0;
@@ -442,9 +448,8 @@ static void filter_prefetch_refspec(struct refspec *rs)
                        continue;
                if (!rs->items[i].dst ||
                    (rs->items[i].src &&
-                    !strncmp(rs->items[i].src,
-                             ref_namespace[NAMESPACE_TAGS].ref,
-                             strlen(ref_namespace[NAMESPACE_TAGS].ref)))) {
+                    starts_with(rs->items[i].src,
+                                ref_namespace[NAMESPACE_TAGS].ref))) {
                        int j;
 
                        free(rs->items[i].src);
@@ -2130,7 +2135,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        const char *bundle_uri;
        struct string_list list = STRING_LIST_INIT_DUP;
        struct remote *remote = NULL;
-       int all = 0, multiple = 0;
+       int all = -1, multiple = 0;
        int result = 0;
        int prune_tags_ok = 1;
        int enable_auto_gc = 1;
@@ -2335,11 +2340,20 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
            fetch_bundle_uri(the_repository, bundle_uri, NULL))
                warning(_("failed to fetch bundles from '%s'"), bundle_uri);
 
+       if (all < 0) {
+               /*
+                * no --[no-]all given;
+                * only use config option if no remote was explicitly specified
+                */
+               all = (!argc) ? config.all : 0;
+       }
+
        if (all) {
                if (argc == 1)
                        die(_("fetch --all does not take a repository argument"));
                else if (argc > 1)
                        die(_("fetch --all does not make sense with refspecs"));
+
                (void) for_each_remote(get_one_remote_for_fetch, &list);
 
                /* do not do fetch_multiple() of one */
index b5bc700d13ce78e6cf47c3e6a499e8129c830241..919282e12a335a5a7491b905f27dcfface0120a3 100644 (file)
@@ -18,16 +18,12 @@ static char const * const for_each_ref_usage[] = {
 
 int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
 {
-       int i;
        struct ref_sorting *sorting;
        struct string_list sorting_options = STRING_LIST_INIT_DUP;
-       int maxcount = 0, icase = 0, omit_empty = 0;
-       struct ref_array array;
+       int icase = 0, include_root_refs = 0, from_stdin = 0;
        struct ref_filter filter = REF_FILTER_INIT;
        struct ref_format format = REF_FORMAT_INIT;
-       struct strbuf output = STRBUF_INIT;
-       struct strbuf err = STRBUF_INIT;
-       int from_stdin = 0;
+       unsigned int flags = FILTER_REFS_REGULAR;
        struct strvec vec = STRVEC_INIT;
 
        struct option opts[] = {
@@ -39,11 +35,11 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                        N_("quote placeholders suitably for python"), QUOTE_PYTHON),
                OPT_BIT(0 , "tcl",  &format.quote_style,
                        N_("quote placeholders suitably for Tcl"), QUOTE_TCL),
-               OPT_BOOL(0, "omit-empty",  &omit_empty,
+               OPT_BOOL(0, "omit-empty",  &format.array_opts.omit_empty,
                        N_("do not output a newline after empty formatted refs")),
 
                OPT_GROUP(""),
-               OPT_INTEGER( 0 , "count", &maxcount, N_("show only <n> matched refs")),
+               OPT_INTEGER( 0 , "count", &format.array_opts.max_count, N_("show only <n> matched refs")),
                OPT_STRING(  0 , "format", &format.format, N_("format"), N_("format to use for the output")),
                OPT__COLOR(&format.use_color, N_("respect format colors")),
                OPT_REF_FILTER_EXCLUDE(&filter),
@@ -57,18 +53,20 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                OPT_NO_CONTAINS(&filter.no_commit, N_("print only refs which don't contain the commit")),
                OPT_BOOL(0, "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
                OPT_BOOL(0, "stdin", &from_stdin, N_("read reference patterns from stdin")),
+               OPT_BOOL(0, "include-root-refs", &include_root_refs, N_("also include HEAD ref and pseudorefs")),
                OPT_END(),
        };
 
-       memset(&array, 0, sizeof(array));
-
        format.format = "%(objectname) %(objecttype)\t%(refname)";
 
        git_config(git_default_config, NULL);
 
+       /* Set default (refname) sorting */
+       string_list_append(&sorting_options, "refname");
+
        parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0);
-       if (maxcount < 0) {
-               error("invalid --count argument: `%d'", maxcount);
+       if (format.array_opts.max_count < 0) {
+               error("invalid --count argument: `%d'", format.array_opts.max_count);
                usage_with_options(for_each_ref_usage, opts);
        }
        if (HAS_MULTI_BITS(format.quote_style)) {
@@ -99,27 +97,12 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
                filter.name_patterns = argv;
        }
 
+       if (include_root_refs)
+               flags |= FILTER_REFS_ROOT_REFS;
+
        filter.match_as_path = 1;
-       filter_refs(&array, &filter, FILTER_REFS_ALL);
-       filter_ahead_behind(the_repository, &format, &array);
-
-       ref_array_sort(sorting, &array);
-
-       if (!maxcount || array.nr < maxcount)
-               maxcount = array.nr;
-       for (i = 0; i < maxcount; i++) {
-               strbuf_reset(&err);
-               strbuf_reset(&output);
-               if (format_ref_array_item(array.items[i], &format, &output, &err))
-                       die("%s", err.buf);
-               fwrite(output.buf, 1, output.len, stdout);
-               if (output.len || !omit_empty)
-                       putchar('\n');
-       }
+       filter_and_format_refs(&filter, flags, sorting, &format);
 
-       strbuf_release(&err);
-       strbuf_release(&output);
-       ref_array_clear(&array);
        ref_filter_clear(&filter);
        ref_sorting_release(sorting);
        strvec_clear(&vec);
index a7cf94f67edf3aaace9fdbbca29778d6857d28af..f892487c9b975dd5079b86143e635c6539770981 100644 (file)
@@ -509,9 +509,7 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
        return 0;
 }
 
-static int fsck_handle_reflog(const char *logname,
-                             const struct object_id *oid UNUSED,
-                             int flag UNUSED, void *cb_data)
+static int fsck_handle_reflog(const char *logname, void *cb_data)
 {
        struct strbuf refname = STRBUF_INIT;
 
index 7c11d5ebef052a46cd06b411960fb1c2b3d6ac08..cb80ced6cb5c65d70859a3a6f57cff3d886084b3 100644 (file)
@@ -1543,19 +1543,18 @@ static int maintenance_register(int argc, const char **argv, const char *prefix)
 
        if (!found) {
                int rc;
-               char *user_config = NULL, *xdg_config = NULL;
+               char *global_config_file = NULL;
 
                if (!config_file) {
-                       git_global_config(&user_config, &xdg_config);
-                       config_file = user_config;
-                       if (!user_config)
-                               die(_("$HOME not set"));
+                       global_config_file = git_global_config();
+                       config_file = global_config_file;
                }
+               if (!config_file)
+                       die(_("$HOME not set"));
                rc = git_config_set_multivar_in_file_gently(
                        config_file, "maintenance.repo", maintpath,
                        CONFIG_REGEX_NONE, 0);
-               free(user_config);
-               free(xdg_config);
+               free(global_config_file);
 
                if (rc)
                        die(_("unable to add '%s' value of '%s'"),
@@ -1612,18 +1611,18 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi
 
        if (found) {
                int rc;
-               char *user_config = NULL, *xdg_config = NULL;
+               char *global_config_file = NULL;
+
                if (!config_file) {
-                       git_global_config(&user_config, &xdg_config);
-                       config_file = user_config;
-                       if (!user_config)
-                               die(_("$HOME not set"));
+                       global_config_file = git_global_config();
+                       config_file = global_config_file;
                }
+               if (!config_file)
+                       die(_("$HOME not set"));
                rc = git_config_set_multivar_in_file_gently(
                        config_file, key, NULL, maintpath,
                        CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE);
-               free(user_config);
-               free(xdg_config);
+               free(global_config_file);
 
                if (rc &&
                    (!force || rc == CONFIG_NOTHING_SET))
index c8e33f977552081fcde8afc12d0aa92bfc4b5e62..982bcfc4b1dfb81d35c2af2bf6118f289ec376ef 100644 (file)
@@ -571,6 +571,8 @@ static int grep_cache(struct grep_opt *opt,
 
                        data = repo_read_object_file(the_repository, &ce->oid,
                                                     &type, &size);
+                       if (!data)
+                               die(_("unable to read tree %s"), oid_to_hex(&ce->oid));
                        init_tree_desc(&tree, data, size);
 
                        hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
index 1ea87e01f2905ed70e3a17a847278ec2b7b68ec3..a3a37bd215d844806814d677d2c7dfa71c8f31c6 100644 (file)
@@ -24,7 +24,7 @@
 #include "setup.h"
 
 static const char index_pack_usage[] =
-"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
+"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict[=<msg-id>=<severity>...]] [--fsck-objects[=<msg-id>=<severity>...]] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
 
 struct object_entry {
        struct pack_idx_entry idx;
@@ -1785,8 +1785,9 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
                        } else if (!strcmp(arg, "--check-self-contained-and-connected")) {
                                strict = 1;
                                check_self_contained_and_connected = 1;
-                       } else if (!strcmp(arg, "--fsck-objects")) {
+                       } else if (skip_to_optional_arg(arg, "--fsck-objects", &arg)) {
                                do_fsck_object = 1;
+                               fsck_set_msg_types(&fsck_options, arg);
                        } else if (!strcmp(arg, "--verify")) {
                                verify = 1;
                        } else if (!strcmp(arg, "--verify-stat")) {
index b89814a6f87da30fc1721ecef02637f61600cd32..0170469b849e5e5ad52cf8586f4540088b0edd61 100644 (file)
@@ -10,6 +10,8 @@
 #include "object-file.h"
 #include "parse-options.h"
 #include "path.h"
+#include "refs.h"
+#include "repository.h"
 #include "setup.h"
 #include "strbuf.h"
 
@@ -56,6 +58,7 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)
 static const char *const init_db_usage[] = {
        N_("git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
           "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+          "         [--ref-format=<format>]\n"
           "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
           "         [--shared[=<permissions>]] [<directory>]"),
        NULL
@@ -75,8 +78,10 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
        const char *template_dir = NULL;
        unsigned int flags = 0;
        const char *object_format = NULL;
+       const char *ref_format = NULL;
        const char *initial_branch = NULL;
        int hash_algo = GIT_HASH_UNKNOWN;
+       unsigned int ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
        int init_shared_repository = -1;
        const struct option init_db_options[] = {
                OPT_STRING(0, "template", &template_dir, N_("template-directory"),
@@ -94,6 +99,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                           N_("override the name of the initial branch")),
                OPT_STRING(0, "object-format", &object_format, N_("hash"),
                           N_("specify the hash algorithm to use")),
+               OPT_STRING(0, "ref-format", &ref_format, N_("format"),
+                          N_("specify the reference format to use")),
                OPT_END()
        };
 
@@ -157,6 +164,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                        die(_("unknown hash algorithm '%s'"), object_format);
        }
 
+       if (ref_format) {
+               ref_storage_format = ref_storage_format_by_name(ref_format);
+               if (ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN)
+                       die(_("unknown ref storage format '%s'"), ref_format);
+       }
+
        if (init_shared_repository != -1)
                set_shared_repository(init_shared_repository);
 
@@ -235,5 +248,6 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 
        flags |= INIT_DB_EXIST_OK;
        return init_db(git_dir, real_git_dir, template_dir, hash_algo,
-                      initial_branch, init_shared_repository, flags);
+                      ref_storage_format, initial_branch,
+                      init_shared_repository, flags);
 }
index af6403cb71a6b87af1b95399b809720c4e38a367..db1808d7c13dfd523e31d1da395122b52b6579ab 100644 (file)
@@ -1365,6 +1365,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
        pp.date_mode.type = DATE_RFC2822;
        pp.rev = rev;
        pp.print_email_subject = 1;
+       pp.encode_email_headers = rev->encode_email_headers;
        pp_user_info(&pp, NULL, &sb, committer, encoding);
        prepare_cover_text(&pp, description_file, branch_name, &sb,
                           encoding, need_8bit_cte);
index 2975ea4082f8830fd94f0493841ed4ca3bff906d..e8d65ebbdc0afc864826d722a7da7514a4f382ea 100644 (file)
@@ -57,6 +57,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        struct transport *transport;
        const struct ref *ref;
        struct ref_array ref_array;
+       struct ref_sorting *sorting;
        struct string_list sorting_options = STRING_LIST_INIT_DUP;
 
        struct option options[] = {
@@ -140,13 +141,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                item->symref = xstrdup_or_null(ref->symref);
        }
 
-       if (sorting_options.nr) {
-               struct ref_sorting *sorting;
-
-               sorting = ref_sorting_options(&sorting_options);
-               ref_array_sort(sorting, &ref_array);
-               ref_sorting_release(sorting);
-       }
+       sorting = ref_sorting_options(&sorting_options);
+       ref_array_sort(sorting, &ref_array);
 
        for (i = 0; i < ref_array.nr; i++) {
                const struct ref_array_item *ref = ref_array.items[i];
@@ -156,6 +152,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
                status = 0; /* we found something */
        }
 
+       ref_sorting_release(sorting);
        ref_array_clear(&ref_array);
        if (transport_disconnect(transport))
                status = 1;
index 832c93d8d54cc50b8581102be4db7c92d80e738a..1f987334a31b0e19904825297c1bb0d37a1fc2fe 100644 (file)
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "abspath.h"
+#include "diff.h"
 #include "hex.h"
 #include "object-name.h"
 #include "object-store.h"
@@ -28,6 +29,30 @@ static int label_cb(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
+static int set_diff_algorithm(xpparam_t *xpp,
+                             const char *alg)
+{
+       long diff_algorithm = parse_algorithm_value(alg);
+       if (diff_algorithm < 0)
+               return -1;
+       xpp->flags = (xpp->flags & ~XDF_DIFF_ALGORITHM_MASK) | diff_algorithm;
+       return 0;
+}
+
+static int diff_algorithm_cb(const struct option *opt,
+                               const char *arg, int unset)
+{
+       xpparam_t *xpp = opt->value;
+
+       BUG_ON_OPT_NEG(unset);
+
+       if (set_diff_algorithm(xpp, arg))
+               return error(_("option diff-algorithm accepts \"myers\", "
+                              "\"minimal\", \"patience\" and \"histogram\""));
+
+       return 0;
+}
+
 int cmd_merge_file(int argc, const char **argv, const char *prefix)
 {
        const char *names[3] = { 0 };
@@ -48,6 +73,9 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
                            XDL_MERGE_FAVOR_THEIRS),
                OPT_SET_INT(0, "union", &xmp.favor, N_("for conflicts, use a union version"),
                            XDL_MERGE_FAVOR_UNION),
+               OPT_CALLBACK_F(0, "diff-algorithm", &xmp.xpp, N_("<algorithm>"),
+                            N_("choose a diff algorithm"),
+                            PARSE_OPT_NONEG, diff_algorithm_cb),
                OPT_INTEGER(0, "marker-size", &xmp.marker_size,
                            N_("for conflicts, use this marker size")),
                OPT__QUIET(&quiet, N_("do not warn about conflicts")),
index 3bdec53fbe58bb5edef6e4d425829a58ce87bffe..b57246da0c58c61f314cf11315a7358559650f81 100644 (file)
@@ -429,35 +429,49 @@ static int real_merge(struct merge_tree_options *o,
        struct merge_options opt;
 
        copy_merge_options(&opt, &o->merge_options);
-       parent1 = get_merge_parent(branch1);
-       if (!parent1)
-               help_unknown_ref(branch1, "merge-tree",
-                                _("not something we can merge"));
-
-       parent2 = get_merge_parent(branch2);
-       if (!parent2)
-               help_unknown_ref(branch2, "merge-tree",
-                                _("not something we can merge"));
-
        opt.show_rename_progress = 0;
 
        opt.branch1 = branch1;
        opt.branch2 = branch2;
 
        if (merge_base) {
-               struct commit *base_commit;
                struct tree *base_tree, *parent1_tree, *parent2_tree;
 
-               base_commit = lookup_commit_reference_by_name(merge_base);
-               if (!base_commit)
-                       die(_("could not lookup commit '%s'"), merge_base);
+               /*
+                * We actually only need the trees because we already
+                * have a merge base.
+                */
+               struct object_id base_oid, head_oid, merge_oid;
+
+               if (repo_get_oid_treeish(the_repository, merge_base, &base_oid))
+                       die(_("could not parse as tree '%s'"), merge_base);
+               base_tree = parse_tree_indirect(&base_oid);
+               if (!base_tree)
+                       die(_("unable to read tree (%s)"), oid_to_hex(&base_oid));
+               if (repo_get_oid_treeish(the_repository, branch1, &head_oid))
+                       die(_("could not parse as tree '%s'"), branch1);
+               parent1_tree = parse_tree_indirect(&head_oid);
+               if (!parent1_tree)
+                       die(_("unable to read tree (%s)"), oid_to_hex(&head_oid));
+               if (repo_get_oid_treeish(the_repository, branch2, &merge_oid))
+                       die(_("could not parse as tree '%s'"), branch2);
+               parent2_tree = parse_tree_indirect(&merge_oid);
+               if (!parent2_tree)
+                       die(_("unable to read tree (%s)"), oid_to_hex(&merge_oid));
 
                opt.ancestor = merge_base;
-               base_tree = repo_get_commit_tree(the_repository, base_commit);
-               parent1_tree = repo_get_commit_tree(the_repository, parent1);
-               parent2_tree = repo_get_commit_tree(the_repository, parent2);
                merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result);
        } else {
+               parent1 = get_merge_parent(branch1);
+               if (!parent1)
+                       help_unknown_ref(branch1, "merge-tree",
+                                        _("not something we can merge"));
+
+               parent2 = get_merge_parent(branch2);
+               if (!parent2)
+                       help_unknown_ref(branch2, "merge-tree",
+                                        _("not something we can merge"));
+
                /*
                 * Get the merge bases, in reverse order; see comment above
                 * merge_incore_recursive in merge-ort.h
index ebbe05033e98bc796ceeb6c70e6259b8c76c18f2..935c8a57ddbcaa3b396bdcf633f34eb29d8860c1 100644 (file)
@@ -192,8 +192,7 @@ static struct strategy *get_strategy(const char *name)
                        int j, found = 0;
                        struct cmdname *ent = main_cmds.names[i];
                        for (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)
-                               if (!strncmp(ent->name, all_strategy[j].name, ent->len)
-                                               && !all_strategy[j].name[ent->len])
+                               if (!xstrncmpz(all_strategy[j].name, ent->name, ent->len))
                                        found = 1;
                        if (!found)
                                add_cmdname(&not_strategies, ent->name, ent->len);
@@ -476,7 +475,7 @@ static void finish(struct commit *head_commit,
        run_hooks_l("post-merge", squash ? "1" : "0", NULL);
 
        if (new_head)
-               apply_autostash(git_path_merge_autostash(the_repository));
+               apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
        strbuf_release(&reflog_message);
 }
 
@@ -1315,7 +1314,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        if (abort_current_merge) {
                int nargc = 2;
                const char *nargv[] = {"reset", "--merge", NULL};
-               struct strbuf stash_oid = STRBUF_INIT;
+               char stash_oid_hex[GIT_MAX_HEXSZ + 1];
+               struct object_id stash_oid = {0};
 
                if (orig_argc != 2)
                        usage_msg_opt(_("--abort expects no arguments"),
@@ -1324,17 +1324,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                if (!file_exists(git_path_merge_head(the_repository)))
                        die(_("There is no merge to abort (MERGE_HEAD missing)."));
 
-               if (read_oneliner(&stash_oid, git_path_merge_autostash(the_repository),
-                   READ_ONELINER_SKIP_IF_EMPTY))
-                       unlink(git_path_merge_autostash(the_repository));
+               if (!read_ref("MERGE_AUTOSTASH", &stash_oid))
+                       delete_ref("", "MERGE_AUTOSTASH", &stash_oid, REF_NO_DEREF);
 
                /* Invoke 'git reset --merge' */
                ret = cmd_reset(nargc, nargv, prefix);
 
-               if (stash_oid.len)
-                       apply_autostash_oid(stash_oid.buf);
+               if (!is_null_oid(&stash_oid)) {
+                       oid_to_hex_r(stash_oid_hex, &stash_oid);
+                       apply_autostash_oid(stash_oid_hex);
+               }
 
-               strbuf_release(&stash_oid);
                goto done;
        }
 
@@ -1563,13 +1563,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                }
 
                if (autostash)
-                       create_autostash(the_repository,
-                                        git_path_merge_autostash(the_repository));
+                       create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
                if (checkout_fast_forward(the_repository,
                                          &head_commit->object.oid,
                                          &commit->object.oid,
                                          overwrite_ignore)) {
-                       apply_autostash(git_path_merge_autostash(the_repository));
+                       apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
                        ret = 1;
                        goto done;
                }
@@ -1655,8 +1654,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                die_ff_impossible();
 
        if (autostash)
-               create_autostash(the_repository,
-                                git_path_merge_autostash(the_repository));
+               create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
 
        /* We are going to make a new commit. */
        git_committer_info(IDENT_STRICT);
@@ -1741,7 +1739,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                else
                        fprintf(stderr, _("Merge with strategy %s failed.\n"),
                                use_strategies[0]->name);
-               apply_autostash(git_path_merge_autostash(the_repository));
+               apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
                ret = 2;
                goto done;
        } else if (best_strategy == wt_strategy)
index 2dd1807c4e09f8dc7ff557c628fdd850dc653361..ad9930c83112585f72a49883c4c8035529363fd5 100644 (file)
@@ -15,6 +15,7 @@
 #include "commit-slab.h"
 #include "commit-graph.h"
 #include "wildmatch.h"
+#include "mem-pool.h"
 
 /*
  * One day.  See the 'name a rev shortly after epoch' test in t6120 when
@@ -155,30 +156,25 @@ static struct rev_name *create_or_update_name(struct commit *commit,
        return name;
 }
 
-static char *get_parent_name(const struct rev_name *name, int parent_number)
+static char *get_parent_name(const struct rev_name *name, int parent_number,
+                            struct mem_pool *string_pool)
 {
-       struct strbuf sb = STRBUF_INIT;
        size_t len;
 
        strip_suffix(name->tip_name, "^0", &len);
        if (name->generation > 0) {
-               strbuf_grow(&sb, len +
-                           1 + decimal_width(name->generation) +
-                           1 + decimal_width(parent_number));
-               strbuf_addf(&sb, "%.*s~%d^%d", (int)len, name->tip_name,
-                           name->generation, parent_number);
+               return mem_pool_strfmt(string_pool, "%.*s~%d^%d",
+                                      (int)len, name->tip_name,
+                                      name->generation, parent_number);
        } else {
-               strbuf_grow(&sb, len +
-                           1 + decimal_width(parent_number));
-               strbuf_addf(&sb, "%.*s^%d", (int)len, name->tip_name,
-                           parent_number);
+               return mem_pool_strfmt(string_pool, "%.*s^%d",
+                                      (int)len, name->tip_name, parent_number);
        }
-       return strbuf_detach(&sb, NULL);
 }
 
 static void name_rev(struct commit *start_commit,
                const char *tip_name, timestamp_t taggerdate,
-               int from_tag, int deref)
+               int from_tag, int deref, struct mem_pool *string_pool)
 {
        struct prio_queue queue;
        struct commit *commit;
@@ -195,9 +191,10 @@ static void name_rev(struct commit *start_commit,
        if (!start_name)
                return;
        if (deref)
-               start_name->tip_name = xstrfmt("%s^0", tip_name);
+               start_name->tip_name = mem_pool_strfmt(string_pool, "%s^0",
+                                                      tip_name);
        else
-               start_name->tip_name = xstrdup(tip_name);
+               start_name->tip_name = mem_pool_strdup(string_pool, tip_name);
 
        memset(&queue, 0, sizeof(queue)); /* Use the prio_queue as LIFO */
        prio_queue_put(&queue, start_commit);
@@ -235,7 +232,8 @@ static void name_rev(struct commit *start_commit,
                                if (parent_number > 1)
                                        parent_name->tip_name =
                                                get_parent_name(name,
-                                                               parent_number);
+                                                               parent_number,
+                                                               string_pool);
                                else
                                        parent_name->tip_name = name->tip_name;
                                ALLOC_GROW(parents_to_queue,
@@ -415,7 +413,7 @@ static int name_ref(const char *path, const struct object_id *oid,
        return 0;
 }
 
-static void name_tips(void)
+static void name_tips(struct mem_pool *string_pool)
 {
        int i;
 
@@ -428,7 +426,7 @@ static void name_tips(void)
                struct tip_table_entry *e = &tip_table.table[i];
                if (e->commit) {
                        name_rev(e->commit, e->refname, e->taggerdate,
-                                e->from_tag, e->deref);
+                                e->from_tag, e->deref, string_pool);
                }
        }
 }
@@ -561,6 +559,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
 
 int cmd_name_rev(int argc, const char **argv, const char *prefix)
 {
+       struct mem_pool string_pool;
        struct object_array revs = OBJECT_ARRAY_INIT;
        int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;
        struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };
@@ -587,6 +586,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                OPT_END(),
        };
 
+       mem_pool_init(&string_pool, 0);
        init_commit_rev_name(&rev_names);
        git_config(git_default_config, NULL);
        argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);
@@ -648,7 +648,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
        adjust_cutoff_timestamp_for_slop();
 
        for_each_ref(name_ref, &data);
-       name_tips();
+       name_tips(&string_pool);
 
        if (annotate_stdin) {
                struct strbuf sb = STRBUF_INIT;
@@ -676,6 +676,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                                  always, allow_undefined, data.name_only);
        }
 
+       UNLEAK(string_pool);
        UNLEAK(revs);
        return 0;
 }
index e65cae0bcf702bf939dcd3ddfb2af5793e73fda0..caf20fd5bdd4b7c1cb44191d58ecbb389643b748 100644 (file)
@@ -716,9 +716,11 @@ static int append_edit(int argc, const char **argv, const char *prefix)
                struct strbuf buf = STRBUF_INIT;
                char *prev_buf = repo_read_object_file(the_repository, note, &type, &size);
 
-               if (prev_buf && size)
+               if (!prev_buf)
+                       die(_("unable to read %s"), oid_to_hex(note));
+               if (size)
                        strbuf_add(&buf, prev_buf, size);
-               if (d.buf.len && prev_buf && size)
+               if (d.buf.len && size)
                        append_separator(&buf);
                strbuf_insert(&d.buf, 0, buf.buf, buf.len);
 
index 5c8bfe1035feca3518d2ab6b2515c03adf9d75eb..329aeac80437502a49b48fe5383aa40e90cd16c3 100644 (file)
@@ -218,13 +218,19 @@ static int thin;
 static int num_preferred_base;
 static struct progress *progress_state;
 
-static struct packed_git *reuse_packfile;
+static struct bitmapped_pack *reuse_packfiles;
+static size_t reuse_packfiles_nr;
+static size_t reuse_packfiles_used_nr;
 static uint32_t reuse_packfile_objects;
 static struct bitmap *reuse_packfile_bitmap;
 
 static int use_bitmap_index_default = 1;
 static int use_bitmap_index = -1;
-static int allow_pack_reuse = 1;
+static enum {
+       NO_PACK_REUSE = 0,
+       SINGLE_PACK_REUSE,
+       MULTI_PACK_REUSE,
+} allow_pack_reuse = SINGLE_PACK_REUSE;
 static enum {
        WRITE_BITMAP_FALSE = 0,
        WRITE_BITMAP_QUIET,
@@ -1010,7 +1016,9 @@ static off_t find_reused_offset(off_t where)
        return reused_chunks[lo-1].difference;
 }
 
-static void write_reused_pack_one(size_t pos, struct hashfile *out,
+static void write_reused_pack_one(struct packed_git *reuse_packfile,
+                                 size_t pos, struct hashfile *out,
+                                 off_t pack_start,
                                  struct pack_window **w_curs)
 {
        off_t offset, next, cur;
@@ -1020,7 +1028,8 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
        offset = pack_pos_to_offset(reuse_packfile, pos);
        next = pack_pos_to_offset(reuse_packfile, pos + 1);
 
-       record_reused_object(offset, offset - hashfile_total(out));
+       record_reused_object(offset,
+                            offset - (hashfile_total(out) - pack_start));
 
        cur = offset;
        type = unpack_object_header(reuse_packfile, w_curs, &cur, &size);
@@ -1088,41 +1097,93 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
        copy_pack_data(out, reuse_packfile, w_curs, offset, next - offset);
 }
 
-static size_t write_reused_pack_verbatim(struct hashfile *out,
+static size_t write_reused_pack_verbatim(struct bitmapped_pack *reuse_packfile,
+                                        struct hashfile *out,
+                                        off_t pack_start,
                                         struct pack_window **w_curs)
 {
-       size_t pos = 0;
+       size_t pos = reuse_packfile->bitmap_pos;
+       size_t end;
+
+       if (pos % BITS_IN_EWORD) {
+               size_t word_pos = (pos / BITS_IN_EWORD);
+               size_t offset = pos % BITS_IN_EWORD;
+               size_t last;
+               eword_t word = reuse_packfile_bitmap->words[word_pos];
+
+               if (offset + reuse_packfile->bitmap_nr < BITS_IN_EWORD)
+                       last = offset + reuse_packfile->bitmap_nr;
+               else
+                       last = BITS_IN_EWORD;
+
+               for (; offset < last; offset++) {
+                       if (word >> offset == 0)
+                               return word_pos;
+                       if (!bitmap_get(reuse_packfile_bitmap,
+                                       word_pos * BITS_IN_EWORD + offset))
+                               return word_pos;
+               }
 
-       while (pos < reuse_packfile_bitmap->word_alloc &&
-                       reuse_packfile_bitmap->words[pos] == (eword_t)~0)
-               pos++;
+               pos += BITS_IN_EWORD - (pos % BITS_IN_EWORD);
+       }
+
+       /*
+        * Now we're going to copy as many whole eword_t's as possible.
+        * "end" is the index of the last whole eword_t we copy, but
+        * there may be additional bits to process. Those are handled
+        * individually by write_reused_pack().
+        *
+        * Begin by advancing to the first word boundary in range of the
+        * bit positions occupied by objects in "reuse_packfile". Then
+        * pick the last word boundary in the same range. If we have at
+        * least one word's worth of bits to process, continue on.
+        */
+       end = reuse_packfile->bitmap_pos + reuse_packfile->bitmap_nr;
+       if (end % BITS_IN_EWORD)
+               end -= end % BITS_IN_EWORD;
+       if (pos >= end)
+               return reuse_packfile->bitmap_pos / BITS_IN_EWORD;
 
-       if (pos) {
-               off_t to_write;
+       while (pos < end &&
+              reuse_packfile_bitmap->words[pos / BITS_IN_EWORD] == (eword_t)~0)
+               pos += BITS_IN_EWORD;
 
-               written = (pos * BITS_IN_EWORD);
-               to_write = pack_pos_to_offset(reuse_packfile, written)
-                       - sizeof(struct pack_header);
+       if (pos > end)
+               pos = end;
+
+       if (reuse_packfile->bitmap_pos < pos) {
+               off_t pack_start_off = pack_pos_to_offset(reuse_packfile->p, 0);
+               off_t pack_end_off = pack_pos_to_offset(reuse_packfile->p,
+                                                       pos - reuse_packfile->bitmap_pos);
+
+               written += pos - reuse_packfile->bitmap_pos;
 
                /* We're recording one chunk, not one object. */
-               record_reused_object(sizeof(struct pack_header), 0);
+               record_reused_object(pack_start_off,
+                                    pack_start_off - (hashfile_total(out) - pack_start));
                hashflush(out);
-               copy_pack_data(out, reuse_packfile, w_curs,
-                       sizeof(struct pack_header), to_write);
+               copy_pack_data(out, reuse_packfile->p, w_curs,
+                       pack_start_off, pack_end_off - pack_start_off);
 
                display_progress(progress_state, written);
        }
-       return pos;
+       if (pos % BITS_IN_EWORD)
+               BUG("attempted to jump past a word boundary to %"PRIuMAX,
+                   (uintmax_t)pos);
+       return pos / BITS_IN_EWORD;
 }
 
-static void write_reused_pack(struct hashfile *f)
+static void write_reused_pack(struct bitmapped_pack *reuse_packfile,
+                             struct hashfile *f)
 {
-       size_t i = 0;
+       size_t i = reuse_packfile->bitmap_pos / BITS_IN_EWORD;
        uint32_t offset;
+       off_t pack_start = hashfile_total(f) - sizeof(struct pack_header);
        struct pack_window *w_curs = NULL;
 
        if (allow_ofs_delta)
-               i = write_reused_pack_verbatim(f, &w_curs);
+               i = write_reused_pack_verbatim(reuse_packfile, f, pack_start,
+                                              &w_curs);
 
        for (; i < reuse_packfile_bitmap->word_alloc; ++i) {
                eword_t word = reuse_packfile_bitmap->words[i];
@@ -1133,16 +1194,23 @@ static void write_reused_pack(struct hashfile *f)
                                break;
 
                        offset += ewah_bit_ctz64(word >> offset);
+                       if (pos + offset < reuse_packfile->bitmap_pos)
+                               continue;
+                       if (pos + offset >= reuse_packfile->bitmap_pos + reuse_packfile->bitmap_nr)
+                               goto done;
                        /*
                         * Can use bit positions directly, even for MIDX
                         * bitmaps. See comment in try_partial_reuse()
                         * for why.
                         */
-                       write_reused_pack_one(pos + offset, f, &w_curs);
+                       write_reused_pack_one(reuse_packfile->p,
+                                             pos + offset - reuse_packfile->bitmap_pos,
+                                             f, pack_start, &w_curs);
                        display_progress(progress_state, ++written);
                }
        }
 
+done:
        unuse_pack(&w_curs);
 }
 
@@ -1194,9 +1262,14 @@ static void write_pack_file(void)
 
                offset = write_pack_header(f, nr_remaining);
 
-               if (reuse_packfile) {
+               if (reuse_packfiles_nr) {
                        assert(pack_to_stdout);
-                       write_reused_pack(f);
+                       for (j = 0; j < reuse_packfiles_nr; j++) {
+                               reused_chunks_nr = 0;
+                               write_reused_pack(&reuse_packfiles[j], f);
+                               if (reused_chunks_nr)
+                                       reuse_packfiles_used_nr++;
+                       }
                        offset = hashfile_total(f);
                }
 
@@ -3172,7 +3245,19 @@ static int git_pack_config(const char *k, const char *v,
                return 0;
        }
        if (!strcmp(k, "pack.allowpackreuse")) {
-               allow_pack_reuse = git_config_bool(k, v);
+               int res = git_parse_maybe_bool_text(v);
+               if (res < 0) {
+                       if (!strcasecmp(v, "single"))
+                               allow_pack_reuse = SINGLE_PACK_REUSE;
+                       else if (!strcasecmp(v, "multi"))
+                               allow_pack_reuse = MULTI_PACK_REUSE;
+                       else
+                               die(_("invalid pack.allowPackReuse value: '%s'"), v);
+               } else if (res) {
+                       allow_pack_reuse = SINGLE_PACK_REUSE;
+               } else {
+                       allow_pack_reuse = NO_PACK_REUSE;
+               }
                return 0;
        }
        if (!strcmp(k, "pack.threads")) {
@@ -3931,7 +4016,7 @@ static void loosen_unused_packed_objects(void)
  */
 static int pack_options_allow_reuse(void)
 {
-       return allow_pack_reuse &&
+       return allow_pack_reuse != NO_PACK_REUSE &&
               pack_to_stdout &&
               !ignore_packed_keep_on_disk &&
               !ignore_packed_keep_in_core &&
@@ -3944,13 +4029,18 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
        if (!(bitmap_git = prepare_bitmap_walk(revs, 0)))
                return -1;
 
-       if (pack_options_allow_reuse() &&
-           !reuse_partial_packfile_from_bitmap(
-                       bitmap_git,
-                       &reuse_packfile,
-                       &reuse_packfile_objects,
-                       &reuse_packfile_bitmap)) {
-               assert(reuse_packfile_objects);
+       if (pack_options_allow_reuse())
+               reuse_partial_packfile_from_bitmap(bitmap_git,
+                                                  &reuse_packfiles,
+                                                  &reuse_packfiles_nr,
+                                                  &reuse_packfile_bitmap,
+                                                  allow_pack_reuse == MULTI_PACK_REUSE);
+
+       if (reuse_packfiles) {
+               reuse_packfile_objects = bitmap_popcount(reuse_packfile_bitmap);
+               if (!reuse_packfile_objects)
+                       BUG("expected non-empty reuse bitmap");
+
                nr_result += reuse_packfile_objects;
                nr_seen += reuse_packfile_objects;
                display_progress(progress_state, nr_seen);
@@ -4306,6 +4396,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                prepare_repo_settings(the_repository);
                if (sparse < 0)
                        sparse = the_repository->settings.pack_use_sparse;
+               if (the_repository->settings.pack_use_multi_pack_reuse)
+                       allow_pack_reuse = MULTI_PACK_REUSE;
        }
 
        reset_pack_idx_option(&pack_idx_opts);
@@ -4518,11 +4610,20 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                fprintf_ln(stderr,
                           _("Total %"PRIu32" (delta %"PRIu32"),"
                             " reused %"PRIu32" (delta %"PRIu32"),"
-                            " pack-reused %"PRIu32),
+                            " pack-reused %"PRIu32" (from %"PRIuMAX")"),
                           written, written_delta, reused, reused_delta,
-                          reuse_packfile_objects);
+                          reuse_packfile_objects,
+                          (uintmax_t)reuse_packfiles_used_nr);
+
+       trace2_data_intmax("pack-objects", the_repository, "written", written);
+       trace2_data_intmax("pack-objects", the_repository, "written/delta", written_delta);
+       trace2_data_intmax("pack-objects", the_repository, "reused", reused);
+       trace2_data_intmax("pack-objects", the_repository, "reused/delta", reused_delta);
+       trace2_data_intmax("pack-objects", the_repository, "pack-reused", reuse_packfile_objects);
+       trace2_data_intmax("pack-objects", the_repository, "packs-reused", reuse_packfiles_used_nr);
 
 cleanup:
+       clear_packing_data(&to_pack);
        list_objects_filter_release(&filter_options);
        strvec_clear(&rp);
 
index 20e7db19737d5a5070068a131797042d37a936a5..1ffd863cff6701af8013130d2e2801366f4e7228 100644 (file)
@@ -261,7 +261,8 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
        cache_tree_free(&the_index.cache_tree);
        for (i = 0; i < nr_trees; i++) {
                struct tree *tree = trees[i];
-               parse_tree(tree);
+               if (parse_tree(tree) < 0)
+                       return 128;
                init_tree_desc(t+i, tree->buffer, tree->size);
        }
        if (unpack_trees(nr_trees, t, &opts))
index 4084a6abb8bf2d7eb87b64f3af792d8a7892292d..6ead9465a42c6d3c6ff7a547bb42ed9dd919dd90 100644 (file)
@@ -145,7 +145,6 @@ struct rebase_options {
                .reapply_cherry_picks = -1,             \
                .allow_empty_message = 1,               \
                .autosquash = -1,                       \
-               .config_autosquash = -1,                \
                .rebase_merges = -1,                    \
                .config_rebase_merges = -1,             \
                .update_refs = -1,                      \
@@ -516,7 +515,7 @@ static int finish_rebase(struct rebase_options *opts)
        int ret = 0;
 
        delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
-       unlink(git_path_auto_merge(the_repository));
+       delete_ref(NULL, "AUTO_MERGE", NULL, REF_NO_DEREF);
        apply_autostash(state_dir_path("autostash", opts));
        /*
         * We ignore errors in 'git maintenance run --auto', since the
@@ -702,10 +701,8 @@ static int run_specific_rebase(struct rebase_options *opts)
        if (opts->type == REBASE_MERGE) {
                /* Run sequencer-based rebase */
                setenv("GIT_CHERRY_PICK_HELP", resolvemsg, 1);
-               if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
+               if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT))
                        setenv("GIT_SEQUENCE_EDITOR", ":", 1);
-                       opts->autosquash = 0;
-               }
                if (opts->gpg_sign_opt) {
                        /* remove the leading "-S" */
                        char *tmp = xstrdup(opts->gpg_sign_opt + 2);
@@ -1257,7 +1254,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                die(_("options '%s' and '%s' cannot be used together"), "--root", "--fork-point");
 
        if (options.action != ACTION_NONE && !in_progress)
-               die(_("No rebase in progress?"));
+               die(_("no rebase in progress"));
 
        if (options.action == ACTION_EDIT_TODO && !is_merge(&options))
                die(_("The --edit-todo action can only be used during "
@@ -1396,7 +1393,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
        if ((options.flags & REBASE_INTERACTIVE_EXPLICIT) ||
            (options.action != ACTION_NONE) ||
            (options.exec.nr > 0) ||
-           (options.autosquash == -1 && options.config_autosquash == 1) ||
            options.autosquash == 1) {
                allow_preemptive_ff = 0;
        }
@@ -1499,8 +1495,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                        if (is_merge(&options))
                                die(_("apply options and merge options "
                                          "cannot be used together"));
-                       else if (options.autosquash == -1 && options.config_autosquash == 1)
-                               die(_("apply options are incompatible with rebase.autoSquash.  Consider adding --no-autosquash"));
                        else if (options.rebase_merges == -1 && options.config_rebase_merges == 1)
                                die(_("apply options are incompatible with rebase.rebaseMerges.  Consider adding --no-rebase-merges"));
                        else if (options.update_refs == -1 && options.config_update_refs == 1)
@@ -1520,10 +1514,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
        options.rebase_merges = (options.rebase_merges >= 0) ? options.rebase_merges :
                                ((options.config_rebase_merges >= 0) ? options.config_rebase_merges : 0);
 
-       if (options.autosquash == 1)
+       if (options.autosquash == 1) {
                imply_merge(&options, "--autosquash");
-       options.autosquash = (options.autosquash >= 0) ? options.autosquash :
-                            ((options.config_autosquash >= 0) ? options.config_autosquash : 0);
+       } else if (options.autosquash == -1) {
+               options.autosquash =
+                       options.config_autosquash &&
+                       (options.flags & REBASE_INTERACTIVE_EXPLICIT);
+       }
 
        if (options.type == REBASE_UNSPECIFIED) {
                if (!strcmp(options.default_backend, "merge"))
index e36b1d619f5c075fc26617fb26972dc21d561e75..db656074857e765c8b5d5c91ab1b872de0bad66d 100644 (file)
@@ -593,21 +593,6 @@ static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
        return strbuf_detach(&buf, NULL);
 }
 
-static char *find_header(const char *msg, size_t len, const char *key,
-                        const char **next_line)
-{
-       size_t out_len;
-       const char *val = find_header_mem(msg, len, key, &out_len);
-
-       if (!val)
-               return NULL;
-
-       if (next_line)
-               *next_line = val + out_len + 1;
-
-       return xmemdupz(val, out_len);
-}
-
 /*
  * Return zero if a and b are equal up to n bytes and nonzero if they are not.
  * This operation is guaranteed to run in constant time to avoid leaking data.
@@ -622,13 +607,14 @@ static int constant_memequal(const char *a, const char *b, size_t n)
        return res;
 }
 
-static const char *check_nonce(const char *buf, size_t len)
+static const char *check_nonce(const char *buf)
 {
-       char *nonce = find_header(buf, len, "nonce", NULL);
+       size_t noncelen;
+       const char *found = find_commit_header(buf, "nonce", &noncelen);
+       char *nonce = found ? xmemdupz(found, noncelen) : NULL;
        timestamp_t stamp, ostamp;
        char *bohmac, *expect = NULL;
        const char *retval = NONCE_BAD;
-       size_t noncelen;
 
        if (!nonce) {
                retval = NONCE_MISSING;
@@ -670,7 +656,6 @@ static const char *check_nonce(const char *buf, size_t len)
                goto leave;
        }
 
-       noncelen = strlen(nonce);
        expect = prepare_push_cert_nonce(service_dir, stamp);
        if (noncelen != strlen(expect)) {
                /* This is not even the right size. */
@@ -718,35 +703,28 @@ leave:
 static int check_cert_push_options(const struct string_list *push_options)
 {
        const char *buf = push_cert.buf;
-       int len = push_cert.len;
 
-       char *option;
-       const char *next_line;
+       const char *option;
+       size_t optionlen;
        int options_seen = 0;
 
        int retval = 1;
 
-       if (!len)
+       if (!*buf)
                return 1;
 
-       while ((option = find_header(buf, len, "push-option", &next_line))) {
-               len -= (next_line - buf);
-               buf = next_line;
+       while ((option = find_commit_header(buf, "push-option", &optionlen))) {
+               buf = option + optionlen + 1;
                options_seen++;
                if (options_seen > push_options->nr
-                   || strcmp(option,
-                             push_options->items[options_seen - 1].string)) {
-                       retval = 0;
-                       goto leave;
-               }
-               free(option);
+                   || xstrncmpz(push_options->items[options_seen - 1].string,
+                                option, optionlen))
+                       return 0;
        }
 
        if (options_seen != push_options->nr)
                retval = 0;
 
-leave:
-       free(option);
        return retval;
 }
 
@@ -773,7 +751,7 @@ static void prepare_push_cert_sha1(struct child_process *proc)
                check_signature(&sigcheck, push_cert.buf + bogs,
                                push_cert.len - bogs);
 
-               nonce_status = check_nonce(push_cert.buf, bogs);
+               nonce_status = check_nonce(sigcheck.payload);
        }
        if (!is_null_oid(&push_cert_oid)) {
                strvec_pushf(&proc->env, "GIT_PUSH_CERT=%s",
index a5a4099f61a5f825d6e622572c9ee85ae563de7b..060eb3377e5d5b2e8af213aa1eec2b2decb33af4 100644 (file)
@@ -7,11 +7,15 @@
 #include "wildmatch.h"
 #include "worktree.h"
 #include "reflog.h"
+#include "refs.h"
 #include "parse-options.h"
 
 #define BUILTIN_REFLOG_SHOW_USAGE \
        N_("git reflog [show] [<log-options>] [<ref>]")
 
+#define BUILTIN_REFLOG_LIST_USAGE \
+       N_("git reflog list")
+
 #define BUILTIN_REFLOG_EXPIRE_USAGE \
        N_("git reflog expire [--expire=<time>] [--expire-unreachable=<time>]\n" \
           "                  [--rewrite] [--updateref] [--stale-fix]\n" \
@@ -29,6 +33,11 @@ static const char *const reflog_show_usage[] = {
        NULL,
 };
 
+static const char *const reflog_list_usage[] = {
+       BUILTIN_REFLOG_LIST_USAGE,
+       NULL,
+};
+
 static const char *const reflog_expire_usage[] = {
        BUILTIN_REFLOG_EXPIRE_USAGE,
        NULL
@@ -46,6 +55,7 @@ static const char *const reflog_exists_usage[] = {
 
 static const char *const reflog_usage[] = {
        BUILTIN_REFLOG_SHOW_USAGE,
+       BUILTIN_REFLOG_LIST_USAGE,
        BUILTIN_REFLOG_EXPIRE_USAGE,
        BUILTIN_REFLOG_DELETE_USAGE,
        BUILTIN_REFLOG_EXISTS_USAGE,
@@ -60,8 +70,7 @@ struct worktree_reflogs {
        struct string_list reflogs;
 };
 
-static int collect_reflog(const char *ref, const struct object_id *oid UNUSED,
-                         int flags UNUSED, void *cb_data)
+static int collect_reflog(const char *ref, void *cb_data)
 {
        struct worktree_reflogs *cb = cb_data;
        struct worktree *worktree = cb->worktree;
@@ -96,8 +105,7 @@ static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)
                reflog_expire_cfg_tail = &reflog_expire_cfg;
 
        for (ent = reflog_expire_cfg; ent; ent = ent->next)
-               if (!strncmp(ent->pattern, pattern, len) &&
-                   ent->pattern[len] == '\0')
+               if (!xstrncmpz(ent->pattern, pattern, len))
                        return ent;
 
        FLEX_ALLOC_MEM(ent, pattern, pattern, len);
@@ -239,6 +247,29 @@ static int cmd_reflog_show(int argc, const char **argv, const char *prefix)
        return cmd_log_reflog(argc, argv, prefix);
 }
 
+static int show_reflog(const char *refname, void *cb_data UNUSED)
+{
+       printf("%s\n", refname);
+       return 0;
+}
+
+static int cmd_reflog_list(int argc, const char **argv, const char *prefix)
+{
+       struct option options[] = {
+               OPT_END()
+       };
+       struct ref_store *ref_store;
+
+       argc = parse_options(argc, argv, prefix, options, reflog_list_usage, 0);
+       if (argc)
+               return error(_("%s does not accept arguments: '%s'"),
+                            "list", argv[0]);
+
+       ref_store = get_main_ref_store(the_repository);
+
+       return refs_for_each_reflog(ref_store, show_reflog, NULL);
+}
+
 static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 {
        struct cmd_reflog_expire_cb cmd = { 0 };
@@ -418,6 +449,7 @@ int cmd_reflog(int argc, const char **argv, const char *prefix)
        parse_opt_subcommand_fn *fn = NULL;
        struct option options[] = {
                OPT_SUBCOMMAND("show", &fn, cmd_reflog_show),
+               OPT_SUBCOMMAND("list", &fn, cmd_reflog_list),
                OPT_SUBCOMMAND("expire", &fn, cmd_reflog_expire),
                OPT_SUBCOMMAND("delete", &fn, cmd_reflog_delete),
                OPT_SUBCOMMAND("exists", &fn, cmd_reflog_exists),
diff --git a/builtin/replay.c b/builtin/replay.c
new file mode 100644 (file)
index 0000000..6bc4b47
--- /dev/null
@@ -0,0 +1,446 @@
+/*
+ * "git replay" builtin command
+ */
+
+#define USE_THE_INDEX_VARIABLE
+#include "git-compat-util.h"
+
+#include "builtin.h"
+#include "environment.h"
+#include "hex.h"
+#include "lockfile.h"
+#include "merge-ort.h"
+#include "object-name.h"
+#include "parse-options.h"
+#include "refs.h"
+#include "revision.h"
+#include "strmap.h"
+#include <oidset.h>
+#include <tree.h>
+
+static const char *short_commit_name(struct commit *commit)
+{
+       return repo_find_unique_abbrev(the_repository, &commit->object.oid,
+                                      DEFAULT_ABBREV);
+}
+
+static struct commit *peel_committish(const char *name)
+{
+       struct object *obj;
+       struct object_id oid;
+
+       if (repo_get_oid(the_repository, name, &oid))
+               return NULL;
+       obj = parse_object(the_repository, &oid);
+       return (struct commit *)repo_peel_to_type(the_repository, name, 0, obj,
+                                                 OBJ_COMMIT);
+}
+
+static char *get_author(const char *message)
+{
+       size_t len;
+       const char *a;
+
+       a = find_commit_header(message, "author", &len);
+       if (a)
+               return xmemdupz(a, len);
+
+       return NULL;
+}
+
+static struct commit *create_commit(struct tree *tree,
+                                   struct commit *based_on,
+                                   struct commit *parent)
+{
+       struct object_id ret;
+       struct object *obj;
+       struct commit_list *parents = NULL;
+       char *author;
+       char *sign_commit = NULL; /* FIXME: cli users might want to sign again */
+       struct commit_extra_header *extra;
+       struct strbuf msg = STRBUF_INIT;
+       const char *out_enc = get_commit_output_encoding();
+       const char *message = repo_logmsg_reencode(the_repository, based_on,
+                                                  NULL, out_enc);
+       const char *orig_message = NULL;
+       const char *exclude_gpgsig[] = { "gpgsig", NULL };
+
+       commit_list_insert(parent, &parents);
+       extra = read_commit_extra_headers(based_on, exclude_gpgsig);
+       find_commit_subject(message, &orig_message);
+       strbuf_addstr(&msg, orig_message);
+       author = get_author(message);
+       reset_ident_date();
+       if (commit_tree_extended(msg.buf, msg.len, &tree->object.oid, parents,
+                                &ret, author, NULL, sign_commit, extra)) {
+               error(_("failed to write commit object"));
+               return NULL;
+       }
+       free(author);
+       strbuf_release(&msg);
+
+       obj = parse_object(the_repository, &ret);
+       return (struct commit *)obj;
+}
+
+struct ref_info {
+       struct commit *onto;
+       struct strset positive_refs;
+       struct strset negative_refs;
+       int positive_refexprs;
+       int negative_refexprs;
+};
+
+static void get_ref_information(struct rev_cmdline_info *cmd_info,
+                               struct ref_info *ref_info)
+{
+       int i;
+
+       ref_info->onto = NULL;
+       strset_init(&ref_info->positive_refs);
+       strset_init(&ref_info->negative_refs);
+       ref_info->positive_refexprs = 0;
+       ref_info->negative_refexprs = 0;
+
+       /*
+        * When the user specifies e.g.
+        *   git replay origin/main..mybranch
+        *   git replay ^origin/next mybranch1 mybranch2
+        * we want to be able to determine where to replay the commits.  In
+        * these examples, the branches are probably based on an old version
+        * of either origin/main or origin/next, so we want to replay on the
+        * newest version of that branch.  In contrast we would want to error
+        * out if they ran
+        *   git replay ^origin/master ^origin/next mybranch
+        *   git replay mybranch~2..mybranch
+        * the first of those because there's no unique base to choose, and
+        * the second because they'd likely just be replaying commits on top
+        * of the same commit and not making any difference.
+        */
+       for (i = 0; i < cmd_info->nr; i++) {
+               struct rev_cmdline_entry *e = cmd_info->rev + i;
+               struct object_id oid;
+               const char *refexpr = e->name;
+               char *fullname = NULL;
+               int can_uniquely_dwim = 1;
+
+               if (*refexpr == '^')
+                       refexpr++;
+               if (repo_dwim_ref(the_repository, refexpr, strlen(refexpr), &oid, &fullname, 0) != 1)
+                       can_uniquely_dwim = 0;
+
+               if (e->flags & BOTTOM) {
+                       if (can_uniquely_dwim)
+                               strset_add(&ref_info->negative_refs, fullname);
+                       if (!ref_info->negative_refexprs)
+                               ref_info->onto = lookup_commit_reference_gently(the_repository,
+                                                                               &e->item->oid, 1);
+                       ref_info->negative_refexprs++;
+               } else {
+                       if (can_uniquely_dwim)
+                               strset_add(&ref_info->positive_refs, fullname);
+                       ref_info->positive_refexprs++;
+               }
+
+               free(fullname);
+       }
+}
+
+static void determine_replay_mode(struct rev_cmdline_info *cmd_info,
+                                 const char *onto_name,
+                                 const char **advance_name,
+                                 struct commit **onto,
+                                 struct strset **update_refs)
+{
+       struct ref_info rinfo;
+
+       get_ref_information(cmd_info, &rinfo);
+       if (!rinfo.positive_refexprs)
+               die(_("need some commits to replay"));
+       if (onto_name && *advance_name)
+               die(_("--onto and --advance are incompatible"));
+       else if (onto_name) {
+               *onto = peel_committish(onto_name);
+               if (rinfo.positive_refexprs <
+                   strset_get_size(&rinfo.positive_refs))
+                       die(_("all positive revisions given must be references"));
+       } else if (*advance_name) {
+               struct object_id oid;
+               char *fullname = NULL;
+
+               *onto = peel_committish(*advance_name);
+               if (repo_dwim_ref(the_repository, *advance_name, strlen(*advance_name),
+                            &oid, &fullname, 0) == 1) {
+                       *advance_name = fullname;
+               } else {
+                       die(_("argument to --advance must be a reference"));
+               }
+               if (rinfo.positive_refexprs > 1)
+                       die(_("cannot advance target with multiple sources because ordering would be ill-defined"));
+       } else {
+               int positive_refs_complete = (
+                       rinfo.positive_refexprs ==
+                       strset_get_size(&rinfo.positive_refs));
+               int negative_refs_complete = (
+                       rinfo.negative_refexprs ==
+                       strset_get_size(&rinfo.negative_refs));
+               /*
+                * We need either positive_refs_complete or
+                * negative_refs_complete, but not both.
+                */
+               if (rinfo.negative_refexprs > 0 &&
+                   positive_refs_complete == negative_refs_complete)
+                       die(_("cannot implicitly determine whether this is an --advance or --onto operation"));
+               if (negative_refs_complete) {
+                       struct hashmap_iter iter;
+                       struct strmap_entry *entry;
+
+                       if (rinfo.negative_refexprs == 0)
+                               die(_("all positive revisions given must be references"));
+                       else if (rinfo.negative_refexprs > 1)
+                               die(_("cannot implicitly determine whether this is an --advance or --onto operation"));
+                       else if (rinfo.positive_refexprs > 1)
+                               die(_("cannot advance target with multiple source branches because ordering would be ill-defined"));
+
+                       /* Only one entry, but we have to loop to get it */
+                       strset_for_each_entry(&rinfo.negative_refs,
+                                             &iter, entry) {
+                               *advance_name = entry->key;
+                       }
+               } else { /* positive_refs_complete */
+                       if (rinfo.negative_refexprs > 1)
+                               die(_("cannot implicitly determine correct base for --onto"));
+                       if (rinfo.negative_refexprs == 1)
+                               *onto = rinfo.onto;
+               }
+       }
+       if (!*advance_name) {
+               *update_refs = xcalloc(1, sizeof(**update_refs));
+               **update_refs = rinfo.positive_refs;
+               memset(&rinfo.positive_refs, 0, sizeof(**update_refs));
+       }
+       strset_clear(&rinfo.negative_refs);
+       strset_clear(&rinfo.positive_refs);
+}
+
+static struct commit *mapped_commit(kh_oid_map_t *replayed_commits,
+                                   struct commit *commit,
+                                   struct commit *fallback)
+{
+       khint_t pos = kh_get_oid_map(replayed_commits, commit->object.oid);
+       if (pos == kh_end(replayed_commits))
+               return fallback;
+       return kh_value(replayed_commits, pos);
+}
+
+static struct commit *pick_regular_commit(struct commit *pickme,
+                                         kh_oid_map_t *replayed_commits,
+                                         struct commit *onto,
+                                         struct merge_options *merge_opt,
+                                         struct merge_result *result)
+{
+       struct commit *base, *replayed_base;
+       struct tree *pickme_tree, *base_tree;
+
+       base = pickme->parents->item;
+       replayed_base = mapped_commit(replayed_commits, base, onto);
+
+       result->tree = repo_get_commit_tree(the_repository, replayed_base);
+       pickme_tree = repo_get_commit_tree(the_repository, pickme);
+       base_tree = repo_get_commit_tree(the_repository, base);
+
+       merge_opt->branch1 = short_commit_name(replayed_base);
+       merge_opt->branch2 = short_commit_name(pickme);
+       merge_opt->ancestor = xstrfmt("parent of %s", merge_opt->branch2);
+
+       merge_incore_nonrecursive(merge_opt,
+                                 base_tree,
+                                 result->tree,
+                                 pickme_tree,
+                                 result);
+
+       free((char*)merge_opt->ancestor);
+       merge_opt->ancestor = NULL;
+       if (!result->clean)
+               return NULL;
+       return create_commit(result->tree, pickme, replayed_base);
+}
+
+int cmd_replay(int argc, const char **argv, const char *prefix)
+{
+       const char *advance_name = NULL;
+       struct commit *onto = NULL;
+       const char *onto_name = NULL;
+       int contained = 0;
+
+       struct rev_info revs;
+       struct commit *last_commit = NULL;
+       struct commit *commit;
+       struct merge_options merge_opt;
+       struct merge_result result;
+       struct strset *update_refs = NULL;
+       kh_oid_map_t *replayed_commits;
+       int ret = 0;
+
+       const char * const replay_usage[] = {
+               N_("(EXPERIMENTAL!) git replay "
+                  "([--contained] --onto <newbase> | --advance <branch>) "
+                  "<revision-range>..."),
+               NULL
+       };
+       struct option replay_options[] = {
+               OPT_STRING(0, "advance", &advance_name,
+                          N_("branch"),
+                          N_("make replay advance given branch")),
+               OPT_STRING(0, "onto", &onto_name,
+                          N_("revision"),
+                          N_("replay onto given commit")),
+               OPT_BOOL(0, "contained", &contained,
+                        N_("advance all branches contained in revision-range")),
+               OPT_END()
+       };
+
+       argc = parse_options(argc, argv, prefix, replay_options, replay_usage,
+                            PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT);
+
+       if (!onto_name && !advance_name) {
+               error(_("option --onto or --advance is mandatory"));
+               usage_with_options(replay_usage, replay_options);
+       }
+
+       if (advance_name && contained)
+               die(_("options '%s' and '%s' cannot be used together"),
+                   "--advance", "--contained");
+
+       repo_init_revisions(the_repository, &revs, prefix);
+
+       /*
+        * Set desired values for rev walking options here. If they
+        * are changed by some user specified option in setup_revisions()
+        * below, we will detect that below and then warn.
+        *
+        * TODO: In the future we might want to either die(), or allow
+        * some options changing these values if we think they could
+        * be useful.
+        */
+       revs.reverse = 1;
+       revs.sort_order = REV_SORT_IN_GRAPH_ORDER;
+       revs.topo_order = 1;
+       revs.simplify_history = 0;
+
+       argc = setup_revisions(argc, argv, &revs, NULL);
+       if (argc > 1) {
+               ret = error(_("unrecognized argument: %s"), argv[1]);
+               goto cleanup;
+       }
+
+       /*
+        * Detect and warn if we override some user specified rev
+        * walking options.
+        */
+       if (revs.reverse != 1) {
+               warning(_("some rev walking options will be overridden as "
+                         "'%s' bit in 'struct rev_info' will be forced"),
+                       "reverse");
+               revs.reverse = 1;
+       }
+       if (revs.sort_order != REV_SORT_IN_GRAPH_ORDER) {
+               warning(_("some rev walking options will be overridden as "
+                         "'%s' bit in 'struct rev_info' will be forced"),
+                       "sort_order");
+               revs.sort_order = REV_SORT_IN_GRAPH_ORDER;
+       }
+       if (revs.topo_order != 1) {
+               warning(_("some rev walking options will be overridden as "
+                         "'%s' bit in 'struct rev_info' will be forced"),
+                       "topo_order");
+               revs.topo_order = 1;
+       }
+       if (revs.simplify_history != 0) {
+               warning(_("some rev walking options will be overridden as "
+                         "'%s' bit in 'struct rev_info' will be forced"),
+                       "simplify_history");
+               revs.simplify_history = 0;
+       }
+
+       determine_replay_mode(&revs.cmdline, onto_name, &advance_name,
+                             &onto, &update_refs);
+
+       if (!onto) /* FIXME: Should handle replaying down to root commit */
+               die("Replaying down to root commit is not supported yet!");
+
+       if (prepare_revision_walk(&revs) < 0) {
+               ret = error(_("error preparing revisions"));
+               goto cleanup;
+       }
+
+       init_merge_options(&merge_opt, the_repository);
+       memset(&result, 0, sizeof(result));
+       merge_opt.show_rename_progress = 0;
+       last_commit = onto;
+       replayed_commits = kh_init_oid_map();
+       while ((commit = get_revision(&revs))) {
+               const struct name_decoration *decoration;
+               khint_t pos;
+               int hr;
+
+               if (!commit->parents)
+                       die(_("replaying down to root commit is not supported yet!"));
+               if (commit->parents->next)
+                       die(_("replaying merge commits is not supported yet!"));
+
+               last_commit = pick_regular_commit(commit, replayed_commits, onto,
+                                                 &merge_opt, &result);
+               if (!last_commit)
+                       break;
+
+               /* Record commit -> last_commit mapping */
+               pos = kh_put_oid_map(replayed_commits, commit->object.oid, &hr);
+               if (hr == 0)
+                       BUG("Duplicate rewritten commit: %s\n",
+                           oid_to_hex(&commit->object.oid));
+               kh_value(replayed_commits, pos) = last_commit;
+
+               /* Update any necessary branches */
+               if (advance_name)
+                       continue;
+               decoration = get_name_decoration(&commit->object);
+               if (!decoration)
+                       continue;
+               while (decoration) {
+                       if (decoration->type == DECORATION_REF_LOCAL &&
+                           (contained || strset_contains(update_refs,
+                                                         decoration->name))) {
+                               printf("update %s %s %s\n",
+                                      decoration->name,
+                                      oid_to_hex(&last_commit->object.oid),
+                                      oid_to_hex(&commit->object.oid));
+                       }
+                       decoration = decoration->next;
+               }
+       }
+
+       /* In --advance mode, advance the target ref */
+       if (result.clean == 1 && advance_name) {
+               printf("update %s %s %s\n",
+                      advance_name,
+                      oid_to_hex(&last_commit->object.oid),
+                      oid_to_hex(&onto->object.oid));
+       }
+
+       merge_finalize(&merge_opt, &result);
+       kh_destroy_oid_map(replayed_commits);
+       if (update_refs) {
+               strset_clear(update_refs);
+               free(update_refs);
+       }
+       ret = result.clean;
+
+cleanup:
+       release_revisions(&revs);
+
+       /* Return */
+       if (ret < 0)
+               exit(128);
+       return ret ? 0 : 1;
+}
index 8390bfe4c487b0c3170045f0601234c1e8278122..1d62ff6332737c6449c76f66d2ebcbadb36bfb11 100644 (file)
@@ -116,6 +116,10 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t
 
        if (reset_type == MIXED || reset_type == HARD) {
                tree = parse_tree_indirect(oid);
+               if (!tree) {
+                       error(_("unable to read tree (%s)"), oid_to_hex(oid));
+                       goto out;
+               }
                prime_cache_tree(the_repository, the_repository->index, tree);
        }
 
@@ -281,7 +285,9 @@ static void parse_args(struct pathspec *pathspec,
                        verify_filename(prefix, argv[0], 1);
                }
        }
-       *rev_ret = rev;
+
+       /* treat '@' as a shortcut for 'HEAD' */
+       *rev_ret = !strcmp("@", rev) ? "HEAD" : rev;
 
        parse_pathspec(pathspec, 0,
                       PATHSPEC_PREFER_FULL |
index b3f47838580c9dd0ed233a3ac34c19aac6b7fa0f..ec455aa97277dd58d106c10623ad36aa923bcd10 100644 (file)
@@ -545,6 +545,18 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
         *
         * Let "--missing" to conditionally set fetch_if_missing.
         */
+       /*
+        * NEEDSWORK: These loops that attempt to find presence of
+        * options without understanding that the options they are
+        * skipping are broken (e.g., it would not know "--grep
+        * --exclude-promisor-objects" is not triggering
+        * "--exclude-promisor-objects" option).  We really need
+        * setup_revisions() to have a mechanism to allow and disallow
+        * some sets of options for different commands (like rev-list,
+        * replay, etc). Such a mechanism should do an early parsing
+        * of options and be able to manage the `--missing=...` and
+        * `--exclude-promisor-objects` options below.
+        */
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
                if (!strcmp(arg, "--exclude-promisor-objects")) {
@@ -753,8 +765,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 
        if (arg_print_omitted)
                oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE);
-       if (arg_missing_action == MA_PRINT)
+       if (arg_missing_action == MA_PRINT) {
                oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
+               /* Add missing tips */
+               oidset_insert_from_set(&missing_objects, &revs.missing_commits);
+               oidset_clear(&revs.missing_commits);
+       }
 
        traverse_commit_list_filtered(
                &revs, show_commit, show_object, &info,
index 917f12244059a67b74b43c80ec59b8503b61700f..d08987646a0a533ad81480ae4667b577a335f9f7 100644 (file)
@@ -1062,6 +1062,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                puts(the_hash_algo->name);
                                continue;
                        }
+                       if (!strcmp(arg, "--show-ref-format")) {
+                               puts(ref_storage_format_to_name(the_repository->ref_storage_format));
+                               continue;
+                       }
                        if (!strcmp(arg, "--end-of-options")) {
                                seen_end_of_options = 1;
                                if (filter & (DO_FLAGS | DO_REVS))
index b7183be9709fd40a54162685825166945935e522..3df9eaad092babdbbfc47f1c5441fc43a4ccd182 100644 (file)
@@ -333,6 +333,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        }
 
        if (!ret && !transport_refs_pushed(remote_refs))
+               /* stable plumbing output; do not modify or localize */
                fprintf(stderr, "Everything up-to-date\n");
 
        return ret;
index 79955c2856eacea0398a7fd9e90f34c790bbd8cd..1c15421e6008e80b1983c168592998f17667bf58 100644 (file)
@@ -172,7 +172,7 @@ static int cmd_show_ref__verify(const struct show_one_options *show_one_opts,
        while (*refs) {
                struct object_id oid;
 
-               if ((starts_with(*refs, "refs/") || !strcmp(*refs, "HEAD")) &&
+               if ((starts_with(*refs, "refs/") || refname_is_safe(*refs)) &&
                    !read_ref(*refs, &oid)) {
                        show_one(show_one_opts, *refs, &oid);
                }
index 288a832c8da7aa2c5da4f57967ec9d0f2cea4ca4..0f52e252493d0d56fd0bcf5a7b9f92a416e86348 100644 (file)
@@ -773,8 +773,7 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix)
 
        argc = parse_options(argc, argv, prefix,
                             builtin_sparse_checkout_add_options,
-                            builtin_sparse_checkout_add_usage,
-                            PARSE_OPT_KEEP_UNKNOWN_OPT);
+                            builtin_sparse_checkout_add_usage, 0);
 
        sanitize_paths(argc, argv, prefix, add_opts.skip_checks);
 
@@ -820,8 +819,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
 
        argc = parse_options(argc, argv, prefix,
                             builtin_sparse_checkout_set_options,
-                            builtin_sparse_checkout_set_usage,
-                            PARSE_OPT_KEEP_UNKNOWN_OPT);
+                            builtin_sparse_checkout_set_usage, 0);
 
        if (update_modes(&set_opts.cone_mode, &set_opts.sparse_index))
                return 1;
@@ -992,8 +990,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
 
        argc = parse_options(argc, argv, prefix,
                             builtin_sparse_checkout_check_rules_options,
-                            builtin_sparse_checkout_check_rules_usage,
-                            PARSE_OPT_KEEP_UNKNOWN_OPT);
+                            builtin_sparse_checkout_check_rules_usage, 0);
 
        if (check_rules_opts.rules_file && check_rules_opts.cone_mode < 0)
                check_rules_opts.cone_mode = 1;
index 79ca53c149c1360cc7e7a8ab903c7bf1c3e92ca8..19a7e06bf414ccf811c93f0ac941a142a7fabef2 100644 (file)
@@ -43,18 +43,11 @@ static const char * const git_tag_usage[] = {
 static unsigned int colopts;
 static int force_sign_annotate;
 static int config_sign_tag = -1; /* unspecified */
-static int omit_empty = 0;
 
 static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,
                     struct ref_format *format)
 {
-       struct ref_array array;
-       struct strbuf output = STRBUF_INIT;
-       struct strbuf err = STRBUF_INIT;
        char *to_free = NULL;
-       int i;
-
-       memset(&array, 0, sizeof(array));
 
        if (filter->lines == -1)
                filter->lines = 0;
@@ -72,23 +65,8 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,
        if (verify_ref_format(format))
                die(_("unable to parse format string"));
        filter->with_commit_tag_algo = 1;
-       filter_refs(&array, filter, FILTER_REFS_TAGS);
-       filter_ahead_behind(the_repository, format, &array);
-       ref_array_sort(sorting, &array);
-
-       for (i = 0; i < array.nr; i++) {
-               strbuf_reset(&output);
-               strbuf_reset(&err);
-               if (format_ref_array_item(array.items[i], format, &output, &err))
-                       die("%s", err.buf);
-               fwrite(output.buf, 1, output.len, stdout);
-               if (output.len || !omit_empty)
-                       putchar('\n');
-       }
+       filter_and_format_refs(filter, FILTER_REFS_TAGS, sorting, format);
 
-       strbuf_release(&err);
-       strbuf_release(&output);
-       ref_array_clear(&array);
        free(to_free);
 
        return 0;
@@ -480,7 +458,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                OPT_WITHOUT(&filter.no_commit, N_("print only tags that don't contain the commit")),
                OPT_MERGED(&filter, N_("print only tags that are merged")),
                OPT_NO_MERGED(&filter, N_("print only tags that are not merged")),
-               OPT_BOOL(0, "omit-empty",  &omit_empty,
+               OPT_BOOL(0, "omit-empty",  &format.array_opts.omit_empty,
                        N_("do not output a newline after empty formatted refs")),
                OPT_REF_SORT(&sorting_options),
                {
@@ -500,7 +478,13 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
        setup_ref_filter_porcelain_msg();
 
+       /*
+        * Try to set sort keys from config. If config does not set any,
+        * fall back on default (refname) sorting.
+        */
        git_config(git_tag_config, &sorting_options);
+       if (!sorting_options.nr)
+               string_list_append(&sorting_options, "refname");
 
        memset(&opt, 0, sizeof(opt));
        filter.lines = -1;
@@ -546,7 +530,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                        struct column_options copts;
                        memset(&copts, 0, sizeof(copts));
                        copts.padding = 2;
-                       run_column_filter(colopts, &copts);
+                       if (run_column_filter(colopts, &copts))
+                               die(_("could not start 'git column'"));
                }
                filter.name_patterns = argv;
                ret = list_tags(&filter, sorting, &format);
index 8cf7dd9e2e5cef1d9238c22ed64ea07440d31528..cf5567208a277a62b872a1846919060fb6e276c3 100644 (file)
@@ -90,7 +90,7 @@ static char *git_config_val_global(int ident_flag UNUSED)
        char *user, *xdg;
        size_t unused;
 
-       git_global_config(&user, &xdg);
+       git_global_config_paths(&user, &xdg);
        if (xdg && *xdg) {
                normalize_path_copy(xdg, xdg);
                strbuf_addf(&buf, "%s\n", xdg);
index e1033c294f930ea8a1dbea23de6c92a0f3687bb7..9c76b62b02da037db84ef633100cc6d9136eb0cf 100644 (file)
@@ -416,7 +416,6 @@ static int add_worktree(const char *path, const char *refname,
        struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT;
        struct strbuf sb = STRBUF_INIT, realpath = STRBUF_INIT;
        const char *name;
-       struct child_process cp = CHILD_PROCESS_INIT;
        struct strvec child_env = STRVEC_INIT;
        unsigned int counter = 0;
        int len, ret;
@@ -424,7 +423,8 @@ static int add_worktree(const char *path, const char *refname,
        struct commit *commit = NULL;
        int is_branch = 0;
        struct strbuf sb_name = STRBUF_INIT;
-       struct worktree **worktrees;
+       struct worktree **worktrees, *wt = NULL;
+       struct ref_store *wt_refs;
 
        worktrees = get_worktrees();
        check_candidate_path(path, opts->force, worktrees, "add");
@@ -495,20 +495,32 @@ static int add_worktree(const char *path, const char *refname,
        strbuf_realpath(&realpath, get_git_common_dir(), 1);
        write_file(sb_git.buf, "gitdir: %s/worktrees/%s",
                   realpath.buf, name);
-       /*
-        * This is to keep resolve_ref() happy. We need a valid HEAD
-        * or is_git_directory() will reject the directory. Any value which
-        * looks like an object ID will do since it will be immediately
-        * replaced by the symbolic-ref or update-ref invocation in the new
-        * worktree.
-        */
-       strbuf_reset(&sb);
-       strbuf_addf(&sb, "%s/HEAD", sb_repo.buf);
-       write_file(sb.buf, "%s", oid_to_hex(null_oid()));
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
        write_file(sb.buf, "../..");
 
+       /*
+        * Set up the ref store of the worktree and create the HEAD reference.
+        */
+       wt = get_linked_worktree(name, 1);
+       if (!wt) {
+               ret = error(_("could not find created worktree '%s'"), name);
+               goto done;
+       }
+       wt_refs = get_worktree_ref_store(wt);
+
+       ret = refs_init_db(wt_refs, REFS_INIT_DB_IS_WORKTREE, &sb);
+       if (ret)
+               goto done;
+
+       if (!is_branch && commit)
+               ret = refs_update_ref(wt_refs, NULL, "HEAD", &commit->object.oid,
+                                     NULL, 0, UPDATE_REFS_MSG_ON_ERR);
+       else
+               ret = refs_create_symref(wt_refs, "HEAD", symref.buf, NULL);
+       if (ret)
+               goto done;
+
        /*
         * If the current worktree has sparse-checkout enabled, then copy
         * the sparse-checkout patterns from the current worktree.
@@ -526,22 +538,6 @@ static int add_worktree(const char *path, const char *refname,
 
        strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
        strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
-       cp.git_cmd = 1;
-
-       if (!is_branch && commit) {
-               strvec_pushl(&cp.args, "update-ref", "HEAD",
-                            oid_to_hex(&commit->object.oid), NULL);
-       } else {
-               strvec_pushl(&cp.args, "symbolic-ref", "HEAD",
-                            symref.buf, NULL);
-               if (opts->quiet)
-                       strvec_push(&cp.args, "--quiet");
-       }
-
-       strvec_pushv(&cp.env, child_env.v);
-       ret = run_command(&cp);
-       if (ret)
-               goto done;
 
        if (opts->orphan &&
            (ret = make_worktree_orphan(refname, opts, &child_env)))
@@ -587,6 +583,7 @@ done:
        strbuf_release(&sb_git);
        strbuf_release(&sb_name);
        strbuf_release(&realpath);
+       free_worktree(wt);
        return ret;
 }
 
index 64678fe19930402b8400cb05d3ccaad5bb5b00a6..80ca8324773d2dc352bf4d47cfc4d0036316180e 100644 (file)
@@ -778,8 +778,8 @@ static void prime_cache_tree_rec(struct repository *r,
                        struct cache_tree_sub *sub;
                        struct tree *subtree = lookup_tree(r, &entry.oid);
 
-                       if (!subtree->object.parsed)
-                               parse_tree(subtree);
+                       if (parse_tree(subtree) < 0)
+                               exit(128);
                        sub = cache_tree_sub(it, entry.path);
                        sub->cache_tree = cache_tree();
 
index 4f407530d3057552177883ad6b088f0a65b37b9a..b4e22de3cb9c351098cc57105c12e6242d1a4384 100755 (executable)
@@ -37,15 +37,13 @@ macos-*)
        test -z "$BREW_INSTALL_PACKAGES" ||
        brew install $BREW_INSTALL_PACKAGES
        brew link --force gettext
-       mkdir -p $HOME/bin
-       (
-               cd $HOME/bin
+
+       mkdir -p "$P4_PATH"
+       pushd "$P4_PATH"
                wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
                tar -xf helix-core-server.tgz &&
                sudo xattr -d com.apple.quarantine p4 p4d 2>/dev/null || true
-       )
-       PATH="$PATH:${HOME}/bin"
-       export PATH
+       popd
 
        if test -n "$CC_PACKAGE"
        then
index 48c43f0f90774e65fcc8b388c6a52444fde50506..eb2c9e1eca73d3beb19ad0d20087f50af13fc62a 100755 (executable)
@@ -21,7 +21,7 @@ linux-musl)
                apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
                bash cvs gnupg perl-cgi perl-dbd-sqlite >/dev/null
        ;;
-linux-*)
+linux-*|StaticAnalysis)
        # Required so that apt doesn't wait for user input on certain packages.
        export DEBIAN_FRONTEND=noninteractive
 
@@ -31,6 +31,11 @@ linux-*)
                perl-modules liberror-perl libauthen-sasl-perl libemail-valid-perl \
                libdbd-sqlite3-perl libio-socket-ssl-perl libnet-smtp-ssl-perl ${CC_PACKAGE:-${CC:-gcc}} \
                apache2 cvs cvsps gnupg libcgi-pm-perl subversion
+
+       if test "$jobname" = StaticAnalysis
+       then
+               apt install -q -y coccinelle
+       fi
        ;;
 pedantic)
        dnf -yq update >/dev/null &&
index c749b21366b95092b144611dd9182b30bf3cb4a8..0a73fc7bd1c2036afc3b7b9df169746133a8b537 100755 (executable)
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -252,7 +252,14 @@ then
        CI_COMMIT="$CI_COMMIT_SHA"
        case "$CI_JOB_IMAGE" in
        macos-*)
-               CI_OS_NAME=osx;;
+               # GitLab CI has Python installed via multiple package managers,
+               # most notably via asdf and Homebrew. Ensure that our builds
+               # pick up the Homebrew one by prepending it to our PATH as the
+               # asdf one breaks tests.
+               export PATH="$(brew --prefix)/bin:$PATH"
+
+               CI_OS_NAME=osx
+               ;;
        alpine:*|fedora:*|ubuntu:*)
                CI_OS_NAME=linux;;
        *)
@@ -344,6 +351,9 @@ macos-*)
        then
                MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes"
        fi
+
+       P4_PATH="$HOME/custom/p4"
+       export PATH="$P4_PATH:$PATH"
        ;;
 esac
 
@@ -357,7 +367,7 @@ linux-musl)
        MAKEFLAGS="$MAKEFLAGS NO_REGEX=Yes ICONV_OMITS_BOM=Yes"
        MAKEFLAGS="$MAKEFLAGS GIT_TEST_UTF8_LOCALE=C.UTF-8"
        ;;
-linux-leaks)
+linux-leaks|linux-reftable-leaks)
        export SANITIZE=leak
        export GIT_TEST_PASSING_SANITIZE_LEAK=true
        export GIT_TEST_SANITIZE_LEAK_LOG=true
index c33ad4e3a2220a97f6e0708afe915010f4f44561..b1f80aeac345dd70746b02b6ca1b5282a0c2a4aa 100755 (executable)
@@ -8,7 +8,7 @@
 # Tracing executed commands would produce too much noise in the loop below.
 set +x
 
-cd t/
+cd "${TEST_OUTPUT_DIRECTORY:-t/}"
 
 if ! ls test-results/*.exit >/dev/null 2>/dev/null
 then
diff --git a/ci/run-build-and-minimal-fuzzers.sh b/ci/run-build-and-minimal-fuzzers.sh
new file mode 100755 (executable)
index 0000000..8ba486f
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Build and test Git's fuzzers
+#
+
+. ${0%/*}/lib.sh
+
+group "Build fuzzers" make \
+       CC=clang \
+       CXX=clang++ \
+       CFLAGS="-fsanitize=fuzzer-no-link,address" \
+       LIB_FUZZING_ENGINE="-fsanitize=fuzzer,address" \
+       fuzz-all
+
+for fuzzer in commit-graph date pack-headers pack-idx ; do
+       begin_group "fuzz-$fuzzer"
+       ./oss-fuzz/fuzz-$fuzzer -verbosity=0 -runs=1 || exit 1
+       end_group "fuzz-$fuzzer"
+done
index 2528f25e31d3c860d1f2dc435af320a4f1b4973c..c192bd613c03dd5faa69dba835014d54bfdf16ae 100755 (executable)
@@ -37,6 +37,9 @@ linux-clang)
 linux-sha256)
        export GIT_TEST_DEFAULT_HASH=sha256
        ;;
+linux-reftable|linux-reftable-leaks|osx-reftable)
+       export GIT_TEST_DEFAULT_REF_FORMAT=reftable
+       ;;
 pedantic)
        # Don't run the tests; we only care about whether Git can be
        # built.
@@ -50,6 +53,8 @@ if test -n "$run_tests"
 then
        group "Run tests" make test ||
        handle_failed_tests
+       group "Run unit tests" \
+               make DEFAULT_UNIT_TEST_TARGET=unit-tests-prove unit-tests
 fi
 check_unignored_build_artifacts
 
index a3c67956a8df8f803bc81eee1b86a8f5559db57b..ae8094382fe418dbd807dbc2156e16b814aa2adc 100755 (executable)
@@ -15,4 +15,9 @@ group "Run tests" make --quiet -C t T="$(cd t &&
        tr '\n' ' ')" ||
 handle_failed_tests
 
+# We only have one unit test at the moment, so run it in the first slice
+if [ "$1" == "0" ] ; then
+       group "Run unit tests" make --quiet -C t unit-tests-prove
+fi
+
 check_unignored_build_artifacts
index ff2f0abf39930c85a515283625a98152d85bc492..50bbccc92ee86cf754a6b3250e52338a1870c990 100644 (file)
--- a/column.c
+++ b/column.c
@@ -182,6 +182,8 @@ void print_columns(const struct string_list *list, unsigned int colopts,
 {
        struct column_options nopts;
 
+       if (opts && (0 > opts->padding))
+               BUG("padding must be non-negative");
        if (!list->nr)
                return;
        assert((colopts & COL_ENABLE_MASK) != COL_AUTO);
@@ -361,6 +363,8 @@ int run_column_filter(int colopts, const struct column_options *opts)
 {
        struct strvec *argv;
 
+       if (opts && (0 > opts->padding))
+               BUG("padding must be non-negative");
        if (fd_out != -1)
                return -1;
 
index db94581f72443c28fd47535db78e39b5ad021a86..d6d6fa168942053e756317d8b490435e4d1280b6 100644 (file)
@@ -337,6 +337,8 @@ static char *grab_blob(struct repository *r,
                free_filespec(df);
        } else {
                blob = repo_read_object_file(r, oid, &type, size);
+               if (!blob)
+                       die(_("unable to read %s"), oid_to_hex(oid));
                if (type != OBJ_BLOB)
                        die("object '%s' is not a blob!", oid_to_hex(oid));
        }
index 54b2a50f5f1dfeb2121f73a43417a7855d6fe1f4..c4cd0f352b8833bc7362a5f685f220ec5dd888b0 100644 (file)
@@ -160,6 +160,7 @@ git-reflog                              ancillarymanipulators           complete
 git-remote                              ancillarymanipulators           complete
 git-repack                              ancillarymanipulators           complete
 git-replace                             ancillarymanipulators           complete
+git-replay                              plumbingmanipulators
 git-request-pull                        foreignscminterface             complete
 git-rerere                              ancillaryinterrogators
 git-reset                               mainporcelain           history
index 37bd10eca8bb5619d8735756285c2a3b010e8fcb..45417d7412202e54d21de0ae49941536eb2c82b4 100644 (file)
@@ -274,68 +274,37 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
        return ret;
 }
 
-static int verify_commit_graph_lite(struct commit_graph *g)
+static int graph_read_oid_fanout(const unsigned char *chunk_start,
+                                size_t chunk_size, void *data)
 {
+       struct commit_graph *g = data;
        int i;
 
-       /*
-        * Basic validation shared between parse_commit_graph()
-        * which'll be called every time the graph is used, and the
-        * much more expensive verify_commit_graph() used by
-        * "commit-graph verify".
-        *
-        * There should only be very basic checks here to ensure that
-        * we don't e.g. segfault in fill_commit_in_graph(), but
-        * because this is a very hot codepath nothing that e.g. loops
-        * over g->num_commits, or runs a checksum on the commit-graph
-        * itself.
-        */
-       if (!g->chunk_oid_fanout) {
-               error("commit-graph is missing the OID Fanout chunk");
-               return 1;
-       }
-       if (!g->chunk_oid_lookup) {
-               error("commit-graph is missing the OID Lookup chunk");
-               return 1;
-       }
-       if (!g->chunk_commit_data) {
-               error("commit-graph is missing the Commit Data chunk");
-               return 1;
-       }
+       if (chunk_size != 256 * sizeof(uint32_t))
+               return error(_("commit-graph oid fanout chunk is wrong size"));
+       g->chunk_oid_fanout = (const uint32_t *)chunk_start;
+       g->num_commits = ntohl(g->chunk_oid_fanout[255]);
 
        for (i = 0; i < 255; i++) {
                uint32_t oid_fanout1 = ntohl(g->chunk_oid_fanout[i]);
                uint32_t oid_fanout2 = ntohl(g->chunk_oid_fanout[i + 1]);
 
                if (oid_fanout1 > oid_fanout2) {
-                       error("commit-graph fanout values out of order");
+                       error(_("commit-graph fanout values out of order"));
                        return 1;
                }
        }
-       if (ntohl(g->chunk_oid_fanout[255]) != g->num_commits) {
-               error("commit-graph oid table and fanout disagree on size");
-               return 1;
-       }
 
        return 0;
 }
 
-static int graph_read_oid_fanout(const unsigned char *chunk_start,
-                                size_t chunk_size, void *data)
-{
-       struct commit_graph *g = data;
-       if (chunk_size != 256 * sizeof(uint32_t))
-               return error("commit-graph oid fanout chunk is wrong size");
-       g->chunk_oid_fanout = (const uint32_t *)chunk_start;
-       return 0;
-}
-
 static int graph_read_oid_lookup(const unsigned char *chunk_start,
                                 size_t chunk_size, void *data)
 {
        struct commit_graph *g = data;
        g->chunk_oid_lookup = chunk_start;
-       g->num_commits = chunk_size / g->hash_len;
+       if (chunk_size / g->hash_len != g->num_commits)
+               return error(_("commit-graph OID lookup chunk is the wrong size"));
        return 0;
 }
 
@@ -343,8 +312,8 @@ static int graph_read_commit_data(const unsigned char *chunk_start,
                                  size_t chunk_size, void *data)
 {
        struct commit_graph *g = data;
-       if (chunk_size != g->num_commits * GRAPH_DATA_WIDTH)
-               return error("commit-graph commit data chunk is wrong size");
+       if (chunk_size / GRAPH_DATA_WIDTH != g->num_commits)
+               return error(_("commit-graph commit data chunk is wrong size"));
        g->chunk_commit_data = chunk_start;
        return 0;
 }
@@ -353,8 +322,8 @@ static int graph_read_generation_data(const unsigned char *chunk_start,
                                      size_t chunk_size, void *data)
 {
        struct commit_graph *g = data;
-       if (chunk_size != g->num_commits * sizeof(uint32_t))
-               return error("commit-graph generations chunk is wrong size");
+       if (chunk_size / sizeof(uint32_t) != g->num_commits)
+               return error(_("commit-graph generations chunk is wrong size"));
        g->chunk_generation_data = chunk_start;
        return 0;
 }
@@ -363,8 +332,8 @@ static int graph_read_bloom_index(const unsigned char *chunk_start,
                                  size_t chunk_size, void *data)
 {
        struct commit_graph *g = data;
-       if (chunk_size != g->num_commits * 4) {
-               warning("commit-graph changed-path index chunk is too small");
+       if (chunk_size / 4 != g->num_commits) {
+               warning(_("commit-graph changed-path index chunk is too small"));
                return -1;
        }
        g->chunk_bloom_indexes = chunk_start;
@@ -378,8 +347,8 @@ static int graph_read_bloom_data(const unsigned char *chunk_start,
        uint32_t hash_version;
 
        if (chunk_size < BLOOMDATA_CHUNK_HEADER_SIZE) {
-               warning("ignoring too-small changed-path chunk"
-                       " (%"PRIuMAX" < %"PRIuMAX") in commit-graph file",
+               warning(_("ignoring too-small changed-path chunk"
+                       " (%"PRIuMAX" < %"PRIuMAX") in commit-graph file"),
                        (uintmax_t)chunk_size,
                        (uintmax_t)BLOOMDATA_CHUNK_HEADER_SIZE);
                return -1;
@@ -461,9 +430,19 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,
                                   GRAPH_HEADER_SIZE, graph->num_chunks, 1))
                goto free_and_return;
 
-       read_chunk(cf, GRAPH_CHUNKID_OIDFANOUT, graph_read_oid_fanout, graph);
-       read_chunk(cf, GRAPH_CHUNKID_OIDLOOKUP, graph_read_oid_lookup, graph);
-       read_chunk(cf, GRAPH_CHUNKID_DATA, graph_read_commit_data, graph);
+       if (read_chunk(cf, GRAPH_CHUNKID_OIDFANOUT, graph_read_oid_fanout, graph)) {
+               error(_("commit-graph required OID fanout chunk missing or corrupted"));
+               goto free_and_return;
+       }
+       if (read_chunk(cf, GRAPH_CHUNKID_OIDLOOKUP, graph_read_oid_lookup, graph)) {
+               error(_("commit-graph required OID lookup chunk missing or corrupted"));
+               goto free_and_return;
+       }
+       if (read_chunk(cf, GRAPH_CHUNKID_DATA, graph_read_commit_data, graph)) {
+               error(_("commit-graph required commit data chunk missing or corrupted"));
+               goto free_and_return;
+       }
+
        pair_chunk(cf, GRAPH_CHUNKID_EXTRAEDGES, &graph->chunk_extra_edges,
                   &graph->chunk_extra_edges_size);
        pair_chunk(cf, GRAPH_CHUNKID_BASE, &graph->chunk_base_graphs,
@@ -498,9 +477,6 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s,
 
        oidread(&graph->oid, graph->data + graph->data_len - graph->hash_len);
 
-       if (verify_commit_graph_lite(graph))
-               goto free_and_return;
-
        free_chunkfile(cf);
        return graph;
 
@@ -628,7 +604,7 @@ int open_commit_graph_chain(const char *chain_file,
                        /* treat empty files the same as missing */
                        errno = ENOENT;
                } else {
-                       warning("commit-graph chain file too small");
+                       warning(_("commit-graph chain file too small"));
                        errno = EINVAL;
                }
                return 0;
@@ -972,7 +948,7 @@ static int fill_commit_in_graph(struct repository *r,
        parent_data_pos = edge_value & GRAPH_EDGE_LAST_MASK;
        do {
                if (g->chunk_extra_edges_size / sizeof(uint32_t) <= parent_data_pos) {
-                       error("commit-graph extra-edges pointer out of bounds");
+                       error(_("commit-graph extra-edges pointer out of bounds"));
                        free_commit_list(item->parents);
                        item->parents = NULL;
                        item->object.parsed = 0;
@@ -2643,19 +2619,16 @@ cleanup:
        oid_array_clear(&ctx->oids);
        clear_topo_level_slab(&topo_levels);
 
-       if (ctx->commit_graph_filenames_after) {
-               for (i = 0; i < ctx->num_commit_graphs_after; i++) {
-                       free(ctx->commit_graph_filenames_after[i]);
-                       free(ctx->commit_graph_hash_after[i]);
-               }
-
-               for (i = 0; i < ctx->num_commit_graphs_before; i++)
-                       free(ctx->commit_graph_filenames_before[i]);
+       for (i = 0; i < ctx->num_commit_graphs_before; i++)
+               free(ctx->commit_graph_filenames_before[i]);
+       free(ctx->commit_graph_filenames_before);
 
-               free(ctx->commit_graph_filenames_after);
-               free(ctx->commit_graph_filenames_before);
-               free(ctx->commit_graph_hash_after);
+       for (i = 0; i < ctx->num_commit_graphs_after; i++) {
+               free(ctx->commit_graph_filenames_after[i]);
+               free(ctx->commit_graph_hash_after[i]);
        }
+       free(ctx->commit_graph_filenames_after);
+       free(ctx->commit_graph_hash_after);
 
        free(ctx);
 
@@ -2692,10 +2665,6 @@ static int verify_one_commit_graph(struct repository *r,
        struct commit *seen_gen_zero = NULL;
        struct commit *seen_gen_non_zero = NULL;
 
-       verify_commit_graph_error = verify_commit_graph_lite(g);
-       if (verify_commit_graph_error)
-               return verify_commit_graph_error;
-
        if (!commit_graph_checksum_valid(g)) {
                graph_report(_("the commit-graph file has incorrect checksum and is likely corrupt"));
                verify_commit_graph_error = VERIFY_COMMIT_GRAPH_ERROR_HASH;
index 10dbb65937d17cab381bc1bfab1dff099157a625..e9ad9db84f22797e745d7a6c4e77021c3cf1814c 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef COMPILER_H
 #define COMPILER_H
 
-#include "git-compat-util.h"
 #include "strbuf.h"
 
 #ifdef __GLIBC__
index 6c979c27d89ec858b849f87e64505c2554cb121b..23bc1bef86c87a0853b87d75e0fc35ea1932f99d 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef COMPAT_DISK_H
 #define COMPAT_DISK_H
 
-#include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
 
index 4bcbccf01a021481e31ae7f5ccd7e51cc6f4a92d..320fb99a90e1db6006135e9798f7300f6fa29798 100644 (file)
@@ -2695,6 +2695,30 @@ static PSID get_current_user_sid(void)
        return result;
 }
 
+static BOOL user_sid_to_user_name(PSID sid, LPSTR *str)
+{
+       SID_NAME_USE pe_use;
+       DWORD len_user = 0, len_domain = 0;
+       BOOL translate_sid_to_user;
+
+       /*
+        * returns only FALSE, because the string pointers are NULL
+        */
+       LookupAccountSidA(NULL, sid, NULL, &len_user, NULL, &len_domain,
+                         &pe_use);
+       /*
+        * Alloc needed space of the strings
+        */
+       ALLOC_ARRAY((*str), (size_t)len_domain + (size_t)len_user);
+       translate_sid_to_user = LookupAccountSidA(NULL, sid,
+           (*str) + len_domain, &len_user, *str, &len_domain, &pe_use);
+       if (!translate_sid_to_user)
+               FREE_AND_NULL(*str);
+       else
+               (*str)[len_domain] = '/';
+       return translate_sid_to_user;
+}
+
 static int acls_supported(const char *path)
 {
        size_t offset = offset_1st_component(path);
@@ -2776,27 +2800,47 @@ int is_path_owned_by_current_sid(const char *path, struct strbuf *report)
                        strbuf_addf(report, "'%s' is on a file system that does "
                                    "not record ownership\n", path);
                } else if (report) {
-                       LPSTR str1, str2, to_free1 = NULL, to_free2 = NULL;
+                       LPSTR str1, str2, str3, str4, to_free1 = NULL,
+                           to_free3 = NULL, to_local_free2 = NULL,
+                           to_local_free4 = NULL;
 
-                       if (ConvertSidToStringSidA(sid, &str1))
+                       if (user_sid_to_user_name(sid, &str1))
                                to_free1 = str1;
                        else
                                str1 = "(inconvertible)";
-
-                       if (!current_user_sid)
-                               str2 = "(none)";
-                       else if (!IsValidSid(current_user_sid))
-                               str2 = "(invalid)";
-                       else if (ConvertSidToStringSidA(current_user_sid, &str2))
-                               to_free2 = str2;
+                       if (ConvertSidToStringSidA(sid, &str2))
+                               to_local_free2 = str2;
                        else
                                str2 = "(inconvertible)";
+
+                       if (!current_user_sid) {
+                               str3 = "(none)";
+                               str4 = "(none)";
+                       }
+                       else if (!IsValidSid(current_user_sid)) {
+                               str3 = "(invalid)";
+                               str4 = "(invalid)";
+                       } else {
+                               if (user_sid_to_user_name(current_user_sid,
+                                                         &str3))
+                                       to_free3 = str3;
+                               else
+                                       str3 = "(inconvertible)";
+                               if (ConvertSidToStringSidA(current_user_sid,
+                                                          &str4))
+                                       to_local_free4 = str4;
+                               else
+                                       str4 = "(inconvertible)";
+                       }
                        strbuf_addf(report,
                                    "'%s' is owned by:\n"
-                                   "\t'%s'\nbut the current user is:\n"
-                                   "\t'%s'\n", path, str1, str2);
-                       LocalFree(to_free1);
-                       LocalFree(to_free2);
+                                   "\t%s (%s)\nbut the current user is:\n"
+                                   "\t%s (%s)\n",
+                                   path, str1, str2, str3, str4);
+                       free(to_free1);
+                       LocalFree(to_local_free2);
+                       free(to_free3);
+                       LocalFree(to_local_free4);
                }
        }
 
index 9ff6ae1cb903a0690295a7d5bb452ef5f35c12e1..3cfeb3d8bd99f4ca15d0f3a06cd4b1fe932f7f47 100644 (file)
--- a/config.c
+++ b/config.c
@@ -95,7 +95,6 @@ static long config_file_ftell(struct config_source *conf)
        return ftell(conf->u.file);
 }
 
-
 static int config_buf_fgetc(struct config_source *conf)
 {
        if (conf->u.buf.pos < conf->u.buf.len)
@@ -1988,7 +1987,27 @@ char *git_system_config(void)
        return system_config;
 }
 
-void git_global_config(char **user_out, char **xdg_out)
+char *git_global_config(void)
+{
+       char *user_config, *xdg_config;
+
+       git_global_config_paths(&user_config, &xdg_config);
+       if (!user_config) {
+               free(xdg_config);
+               return NULL;
+       }
+
+       if (access_or_warn(user_config, R_OK, 0) && xdg_config &&
+           !access_or_warn(xdg_config, R_OK, 0)) {
+               free(user_config);
+               return xdg_config;
+       } else {
+               free(xdg_config);
+               return user_config;
+       }
+}
+
+void git_global_config_paths(char **user_out, char **xdg_out)
 {
        char *user_config = xstrdup_or_null(getenv("GIT_CONFIG_GLOBAL"));
        char *xdg_config = NULL;
@@ -2041,7 +2060,7 @@ static int do_git_config_sequence(const struct config_options *opts,
                                                         data, CONFIG_SCOPE_SYSTEM,
                                                         NULL);
 
-       git_global_config(&user_config, &xdg_config);
+       git_global_config_paths(&user_config, &xdg_config);
 
        if (xdg_config && !access_or_die(xdg_config, R_OK, ACCESS_EACCES_OK))
                ret += git_config_from_file_with_options(fn, xdg_config, data,
@@ -3418,7 +3437,6 @@ out_free:
 write_err_out:
        ret = write_error(get_lock_file_path(&lock));
        goto out_free;
-
 }
 
 void git_config_set_multivar_in_file(const char *config_filename,
index 14f881ecfaf6b264b6d120205ab509f2ee5930f2..5dba984f770e4e96d322874351a70d0f7d0ee8ba 100644 (file)
--- a/config.h
+++ b/config.h
@@ -382,7 +382,8 @@ int config_error_nonbool(const char *);
 #endif
 
 char *git_system_config(void);
-void git_global_config(char **user, char **xdg);
+char *git_global_config(void);
+void git_global_config_paths(char **user, char **xdg);
 
 int git_config_parse_parameter(const char *, config_fn_t fn, void *data);
 
index 3bb03f423a08102f837c52dcbe7a3b581104e0cb..dacc95172dcdcbd85086d9dacf57d2be588c90e1 100644 (file)
@@ -158,6 +158,19 @@ ifeq ($(uname_S),Darwin)
                ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
                        MSGFMT = /usr/local/opt/gettext/bin/msgfmt
                endif
+       # On newer ARM-based machines the default installation path has changed to
+       # /opt/homebrew. Include it in our search paths so that the user does not
+       # have to configure this manually.
+       #
+       # Note that we do not employ the same workaround as above where we manually
+       # add gettext. The issue was fixed more than three years ago by now, and at
+       # that point there haven't been any ARM-based Macs yet.
+       else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
+               BASIC_CFLAGS += -I/opt/homebrew/include
+               BASIC_LDFLAGS += -L/opt/homebrew/lib
+               ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
+                       MSGFMT = /opt/homebrew/bin/msgfmt
+               endif
        endif
 
        # The builtin FSMonitor on MacOS builds upon Simple-IPC.  Both require
index 276593cd9dd935a283620f3b9d25b09987c04bf2..d1a96da14eb56766e1538da80ab97ed8a99b24f6 100644 (file)
@@ -94,7 +94,7 @@ AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
 [AC_ARG_WITH([$1],
  [AS_HELP_STRING([--with-$1=VALUE], $3)],
  if test -n "$withval"; then
-  if test "$withval" = "yes" -o "$withval" = "no"; then
+  if test "$withval" = "yes" || test "$withval" = "no"; then
     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
                     [a value for $1 ($2).  Maybe you do...?])
   fi
index 6b819e2fbdf357f8401a29b5f8daa29e43284cfe..804629c525b1b1978512c9d15b710bfebeef185e 100644 (file)
@@ -974,6 +974,35 @@ target_link_libraries(test-fake-ssh common-main)
 parse_makefile_for_sources(test-reftable_SOURCES "REFTABLE_TEST_OBJS")
 list(TRANSFORM test-reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 
+#unit-tests
+add_library(unit-test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
+
+parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "")
+foreach(unit_test ${unit_test_PROGRAMS})
+       add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c")
+       target_link_libraries("${unit_test}" unit-test-lib common-main)
+       set_target_properties("${unit_test}"
+               PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
+       if(MSVC)
+               set_target_properties("${unit_test}"
+                       PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
+               set_target_properties("${unit_test}"
+                       PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/unit-tests/bin)
+       endif()
+       list(APPEND PROGRAMS_BUILT "${unit_test}")
+
+       # t-basic intentionally fails tests, to validate the unit-test infrastructure.
+       # Therefore, it should only be run as part of t0080, which verifies that it
+       # fails only in the expected ways.
+       #
+       # All other unit tests should be run.
+       if(NOT ${unit_test} STREQUAL "t-basic")
+               add_test(NAME "t.unit-tests.${unit_test}"
+                       COMMAND "./${unit_test}"
+                       WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t/unit-tests/bin)
+       endif()
+endforeach()
+
 #test-tool
 parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
 
@@ -1093,17 +1122,18 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
        file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
 endif()
 
-file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+file(GLOB test_scripts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
-foreach(tsh ${test_scipts})
-       add_test(NAME ${tsh}
+foreach(tsh ${test_scripts})
+       string(REGEX REPLACE ".*/(.*)\\.sh" "\\1" test_name ${tsh})
+       add_test(NAME "t.suite.${test_name}"
                COMMAND ${SH_EXE} ${tsh} --no-bin-wrappers --no-chain-lint -vx
                WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
 endforeach()
 
 # This test script takes an extremely long time and is known to time out even
 # on fast machines because it requires in excess of one hour to run
-set_tests_properties("${CMAKE_SOURCE_DIR}/t/t7112-reset-submodule.sh" PROPERTIES TIMEOUT 4000)
+set_tests_properties("t.suite.t7112-reset-submodule" PROPERTIES TIMEOUT 4000)
 
 endif()#BUILD_TESTING
diff --git a/contrib/coccinelle/xstrncmpz.cocci b/contrib/coccinelle/xstrncmpz.cocci
new file mode 100644 (file)
index 0000000..ccb39e2
--- /dev/null
@@ -0,0 +1,28 @@
+@@
+expression S, T, L;
+@@
+(
+- strncmp(S, T, L) || S[L]
++ !!xstrncmpz(S, T, L)
+|
+- strncmp(S, T, L) || S[L] != '\0'
++ !!xstrncmpz(S, T, L)
+|
+- strncmp(S, T, L) || T[L]
++ !!xstrncmpz(T, S, L)
+|
+- strncmp(S, T, L) || T[L] != '\0'
++ !!xstrncmpz(T, S, L)
+|
+- !strncmp(S, T, L) && !S[L]
++ !xstrncmpz(S, T, L)
+|
+- !strncmp(S, T, L) && S[L] == '\0'
++ !xstrncmpz(S, T, L)
+|
+- !strncmp(S, T, L) && !T[L]
++ !xstrncmpz(T, S, L)
+|
+- !strncmp(S, T, L) && T[L] == '\0'
++ !xstrncmpz(T, S, L)
+)
index e21a39b406fb2e262a5277807385e4c14d17063f..fcf1afd75de4eb14a0123a2a75692298f2c39a0b 100644 (file)
@@ -137,6 +137,9 @@ __git_eread ()
 __git_pseudoref_exists ()
 {
        local ref=$1
+       local head
+
+       __git_find_repo_path
 
        # If the reftable is in use, we have to shell out to 'git rev-parse'
        # to determine whether the ref exists instead of looking directly in
@@ -144,9 +147,8 @@ __git_pseudoref_exists ()
        # Bash builtins since executing Git commands are expensive on some
        # platforms.
        if __git_eread "$__git_repo_path/HEAD" head; then
-               b="${head#ref: }"
-               if [ "$b" == "refs/heads/.invalid" ]; then
-                       __git -C "$__git_repo_path" rev-parse --verify --quiet "$ref" 2>/dev/null
+               if [ "$head" == "ref: refs/heads/.invalid" ]; then
+                       __git show-ref --exists "$ref"
                        return $?
                fi
        fi
@@ -1481,12 +1483,32 @@ _git_bisect ()
 {
        __git_has_doubledash && return
 
-       local subcommands="start bad good skip reset visualize replay log run"
-       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       __git_find_repo_path
+
+       # If a bisection is in progress get the terms being used.
+       local term_bad term_good
+       if [ -f "$__git_repo_path"/BISECT_TERMS ]; then
+               term_bad=$(__git bisect terms --term-bad)
+               term_good=$(__git bisect terms --term-good)
+       fi
+
+       # We will complete any custom terms, but still always complete the
+       # more usual bad/new/good/old because git bisect gives a good error
+       # message if these are given when not in use, and that's better than
+       # silent refusal to complete if the user is confused.
+       #
+       # We want to recognize 'view' but not complete it, because it overlaps
+       # with 'visualize' too much and is just an alias for it.
+       #
+       local completable_subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help"
+       local all_subcommands="$completable_subcommands view"
+
+       local subcommand="$(__git_find_on_cmdline "$all_subcommands")"
+
        if [ -z "$subcommand" ]; then
                __git_find_repo_path
                if [ -f "$__git_repo_path"/BISECT_START ]; then
-                       __gitcomp "$subcommands"
+                       __gitcomp "$completable_subcommands"
                else
                        __gitcomp "replay start"
                fi
@@ -1494,7 +1516,26 @@ _git_bisect ()
        fi
 
        case "$subcommand" in
-       bad|good|reset|skip|start)
+       start)
+               case "$cur" in
+               --*)
+                       __gitcomp "--first-parent --no-checkout --term-new --term-bad --term-old --term-good"
+                       return
+                       ;;
+               *)
+                       __git_complete_refs
+                       ;;
+               esac
+               ;;
+       terms)
+               __gitcomp "--term-good --term-old --term-bad --term-new"
+               return
+               ;;
+       visualize|view)
+               __git_complete_log_opts
+               return
+               ;;
+       bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
                __git_complete_refs
                ;;
        *)
@@ -1656,7 +1697,6 @@ __git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
 
 _git_cherry_pick ()
 {
-       __git_find_repo_path
        if __git_pseudoref_exists CHERRY_PICK_HEAD; then
                __gitcomp "$__git_cherry_pick_inprogress_options"
                return
@@ -1807,7 +1847,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
                        --output= --output-indicator-context=
                        --output-indicator-new= --output-indicator-old=
                        --ws-error-highlight=
-                       --pickaxe-all --pickaxe-regex
+                       --pickaxe-all --pickaxe-regex --patch-with-raw
 "
 
 # Options for diff/difftool
@@ -2071,6 +2111,16 @@ __git_log_common_options="
        --min-age= --until= --before=
        --min-parents= --max-parents=
        --no-min-parents --no-max-parents
+       --alternate-refs --ancestry-path
+       --author-date-order --basic-regexp
+       --bisect --boundary --exclude-first-parent-only
+       --exclude-hidden --extended-regexp
+       --fixed-strings --grep-reflog
+       --ignore-missing --left-only --perl-regexp
+       --reflog --regexp-ignore-case --remove-empty
+       --right-only --show-linear-break
+       --show-notes-by-default --show-pulls
+       --since-as-filter --single-worktree
 "
 # Options that go well for log and gitk (not shortlog)
 __git_log_gitk_options="
@@ -2086,6 +2136,7 @@ __git_log_shortlog_options="
 # Options accepted by log and show
 __git_log_show_options="
        --diff-merges --diff-merges= --no-diff-merges --dd --remerge-diff
+       --encoding=
 "
 
 __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-combined cc remerge r"
@@ -2093,10 +2144,12 @@ __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-c
 __git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
 __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:"
 
-_git_log ()
+# Complete porcelain (i.e. not git-rev-list) options and at least some
+# option arguments accepted by git-log.  Note that this same set of options
+# are also accepted by some other git commands besides git-log.
+__git_complete_log_opts ()
 {
-       __git_has_doubledash && return
-       __git_find_repo_path
+       COMPREPLY=()
 
        local merge=""
        if __git_pseudoref_exists MERGE_HEAD; then
@@ -2169,6 +2222,8 @@ _git_log ()
                        --no-walk --no-walk= --do-walk
                        --parents --children
                        --expand-tabs --expand-tabs= --no-expand-tabs
+                       --clear-decorations --decorate-refs=
+                       --decorate-refs-exclude=
                        $merge
                        $__git_diff_common_options
                        "
@@ -2190,6 +2245,16 @@ _git_log ()
                return
                ;;
        esac
+}
+
+_git_log ()
+{
+       __git_has_doubledash && return
+       __git_find_repo_path
+
+       __git_complete_log_opts
+        [ ${#COMPREPLY[@]} -eq 0 ] || return
+
        __git_complete_revlist
 }
 
@@ -2595,6 +2660,33 @@ __git_compute_config_vars ()
        __git_config_vars="$(git help --config-for-completion)"
 }
 
+__git_config_vars_all=
+__git_compute_config_vars_all ()
+{
+       test -n "$__git_config_vars_all" ||
+       __git_config_vars_all="$(git --no-pager help --config)"
+}
+
+__git_compute_first_level_config_vars_for_section ()
+{
+       local section="$1"
+       __git_compute_config_vars
+       local this_section="__git_first_level_config_vars_for_section_${section}"
+       test -n "${!this_section}" ||
+       printf -v "__git_first_level_config_vars_for_section_${section}" %s \
+               "$(echo "$__git_config_vars" | awk -F. "/^${section}\.[a-z]/ { print \$2 }")"
+}
+
+__git_compute_second_level_config_vars_for_section ()
+{
+       local section="$1"
+       __git_compute_config_vars_all
+       local this_section="__git_second_level_config_vars_for_section_${section}"
+       test -n "${!this_section}" ||
+       printf -v "__git_second_level_config_vars_for_section_${section}" %s \
+               "$(echo "$__git_config_vars_all" | awk -F. "/^${section}\.</ { print \$3 }")"
+}
+
 __git_config_sections=
 __git_compute_config_sections ()
 {
@@ -2739,73 +2831,50 @@ __git_complete_config_variable_name ()
        done
 
        case "$cur_" in
-       branch.*.*)
+       branch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*)
                local pfx="${cur_%.*}."
                cur_="${cur_##*.}"
-               __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" "$sfx"
+               local section="${pfx%.*.}"
+               __git_compute_second_level_config_vars_for_section "${section}"
+               local this_section="__git_second_level_config_vars_for_section_${section}"
+               __gitcomp "${!this_section}" "$pfx" "$cur_" "$sfx"
                return
                ;;
        branch.*)
                local pfx="${cur_%.*}."
                cur_="${cur_#*.}"
+               local section="${pfx%.}"
                __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
-               __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
-               return
-               ;;
-       guitool.*.*)
-               local pfx="${cur_%.*}."
-               cur_="${cur_##*.}"
-               __gitcomp "
-                       argPrompt cmd confirm needsFile noConsole noRescan
-                       prompt revPrompt revUnmerged title
-                       " "$pfx" "$cur_" "$sfx"
-               return
-               ;;
-       difftool.*.*)
-               local pfx="${cur_%.*}."
-               cur_="${cur_##*.}"
-               __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
-               return
-               ;;
-       man.*.*)
-               local pfx="${cur_%.*}."
-               cur_="${cur_##*.}"
-               __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
-               return
-               ;;
-       mergetool.*.*)
-               local pfx="${cur_%.*}."
-               cur_="${cur_##*.}"
-               __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" "$sfx"
+               __git_compute_first_level_config_vars_for_section "${section}"
+               local this_section="__git_first_level_config_vars_for_section_${section}"
+               __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }"
                return
                ;;
        pager.*)
                local pfx="${cur_%.*}."
                cur_="${cur_#*.}"
                __git_compute_all_commands
-               __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }"
-               return
-               ;;
-       remote.*.*)
-               local pfx="${cur_%.*}."
-               cur_="${cur_##*.}"
-               __gitcomp "
-                       url proxy fetch push mirror skipDefaultUpdate
-                       receivepack uploadpack tagOpt pushurl
-                       " "$pfx" "$cur_" "$sfx"
+               __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
                return
                ;;
        remote.*)
                local pfx="${cur_%.*}."
                cur_="${cur_#*.}"
+               local section="${pfx%.}"
                __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
-               __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }"
+               __git_compute_first_level_config_vars_for_section "${section}"
+               local this_section="__git_first_level_config_vars_for_section_${section}"
+               __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }"
                return
                ;;
-       url.*.*)
+       submodule.*)
                local pfx="${cur_%.*}."
-               cur_="${cur_##*.}"
-               __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" "$sfx"
+               cur_="${cur_#*.}"
+               local section="${pfx%.}"
+               __gitcomp_nl "$(__git config -f "$(__git rev-parse --show-toplevel)/.gitmodules" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')" "$pfx" "$cur_" "."
+               __git_compute_first_level_config_vars_for_section "${section}"
+               local this_section="__git_first_level_config_vars_for_section_${section}"
+               __gitcomp_nl_append "${!this_section}" "$pfx" "$cur_" "${sfx:- }"
                return
                ;;
        *.*)
@@ -2966,7 +3035,6 @@ _git_reset ()
 
 _git_restore ()
 {
-       __git_find_repo_path
        case "$prev" in
        -s)
                __git_complete_refs
@@ -2995,7 +3063,6 @@ __git_revert_inprogress_options=$__git_sequencer_inprogress_options
 
 _git_revert ()
 {
-       __git_find_repo_path
        if __git_pseudoref_exists REVERT_HEAD; then
                __gitcomp "$__git_revert_inprogress_options"
                return
@@ -3117,12 +3184,119 @@ __gitcomp_directories ()
                        COMPREPLY+=("$c/")
                        _found=1
                fi
-       done < <(git ls-tree -z -d --name-only HEAD $_tmp_dir)
+       done < <(__git ls-tree -z -d --name-only HEAD $_tmp_dir)
 
        if [[ $_found == 0 ]] && [[ "$cur" =~ /$ ]]; then
                # No possible further completions any deeper, so assume we're at
                # a leaf directory and just consider it complete
                __gitcomp_direct_append "$cur "
+       elif [[ $_found == 0 ]]; then
+               # No possible completions found.  Avoid falling back to
+               # bash's default file and directory completion, because all
+               # valid completions have already been searched and the
+               # fallbacks can do nothing but mislead.  In fact, they can
+               # mislead in three different ways:
+               #    1) Fallback file completion makes no sense when asking
+               #       for directory completions, as this function does.
+               #    2) Fallback directory completion is bad because
+               #       e.g. "/pro" is invalid and should NOT complete to
+               #       "/proc".
+               #    3) Fallback file/directory completion only completes
+               #       on paths that exist in the current working tree,
+               #       i.e. which are *already* part of their
+               #       sparse-checkout.  Thus, normal file and directory
+               #       completion is always useless for "git
+               #       sparse-checkout add" and is also probelmatic for
+               #       "git sparse-checkout set" unless using it to
+               #       strictly narrow the checkout.
+               COMPREPLY=( "" )
+       fi
+}
+
+# In non-cone mode, the arguments to {set,add} are supposed to be
+# patterns, relative to the toplevel directory.  These can be any kind
+# of general pattern, like 'subdir/*.c' and we can't complete on all
+# of those.  However, if the user presses Tab to get tab completion, we
+# presume that they are trying to provide a pattern that names a specific
+# path.
+__gitcomp_slash_leading_paths ()
+{
+       local dequoted_word pfx="" cur_ toplevel
+
+       # Since we are dealing with a sparse-checkout, subdirectories may not
+       # exist in the local working copy.  Therefore, we want to run all
+       # ls-files commands relative to the repository toplevel.
+       toplevel="$(git rev-parse --show-toplevel)/"
+
+       __git_dequote "$cur"
+
+       # If the paths provided by the user already start with '/', then
+       # they are considered relative to the toplevel of the repository
+       # already.  If they do not start with /, then we need to adjust
+       # them to start with the appropriate prefix.
+       case "$cur" in
+       /*)
+               cur="${cur:1}"
+               ;;
+       *)
+               pfx="$(__git rev-parse --show-prefix)"
+       esac
+
+       # Since sparse-index is limited to cone-mode, in non-cone-mode the
+       # list of valid paths is precisely the cached files in the index.
+       #
+       # NEEDSWORK:
+       #   1) We probably need to take care of cases where ls-files
+       #      responds with special quoting.
+       #   2) We probably need to take care of cases where ${cur} has
+       #      some kind of special quoting.
+       #   3) On top of any quoting from 1 & 2, we have to provide an extra
+       #      level of quoting for any paths that contain a '*', '?', '\',
+       #      '[', ']', or leading '#' or '!' since those will be
+       #      interpreted by sparse-checkout as something other than a
+       #      literal path character.
+       # Since there are two types of quoting here, this might get really
+       # complex.  For now, just punt on all of this...
+       completions="$(__git -C "${toplevel}" -c core.quotePath=false \
+                        ls-files --cached -- "${pfx}${cur}*" \
+                        | sed -e s%^%/% -e 's%$% %')"
+       # Note, above, though that we needed all of the completions to be
+       # prefixed with a '/', and we want to add a space so that bash
+       # completion will actually complete an entry and let us move on to
+       # the next one.
+
+       # Return what we've found.
+       if test -n "$completions"; then
+               # We found some completions; return them
+               local IFS=$'\n'
+               COMPREPLY=($completions)
+       else
+               # Do NOT fall back to bash-style all-local-files-and-dirs
+               # when we find no match.  Such options are worse than
+               # useless:
+               #     1. "git sparse-checkout add" needs paths that are NOT
+               #        currently in the working copy.  "git
+               #        sparse-checkout set" does as well, except in the
+               #        special cases when users are only trying to narrow
+               #        their sparse checkout to a subset of what they
+               #        already have.
+               #
+               #     2. A path like '.config' is ambiguous as to whether
+               #        the user wants all '.config' files throughout the
+               #        tree, or just the one under the current directory.
+               #        It would result in a warning from the
+               #        sparse-checkout command due to this.  As such, all
+               #        completions of paths should be prefixed with a
+               #        '/'.
+               #
+               #     3. We don't want paths prefixed with a '/' to
+               #        complete files in the system root directory, we
+               #        want it to complete on files relative to the
+               #        repository root.
+               #
+               # As such, make sure that NO completions are offered rather
+               # than falling back to bash's default completions.
+               COMPREPLY=( "" )
        fi
 }
 
@@ -3130,6 +3304,7 @@ _git_sparse_checkout ()
 {
        local subcommands="list init set disable add reapply"
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       local using_cone=true
        if [ -z "$subcommand" ]; then
                __gitcomp "$subcommands"
                return
@@ -3140,9 +3315,18 @@ _git_sparse_checkout ()
                __gitcomp_builtin sparse-checkout_$subcommand "" "--"
                ;;
        set,*|add,*)
-               if [ "$(__git config core.sparseCheckoutCone)" == "true" ] ||
-               [ -n "$(__git_find_on_cmdline --cone)" ]; then
+               if [[ "$(__git config core.sparseCheckout)" == "true" &&
+                     "$(__git config core.sparseCheckoutCone)" == "false" &&
+                     -z "$(__git_find_on_cmdline --cone)" ]]; then
+                       using_cone=false
+               fi
+               if [[ -n "$(__git_find_on_cmdline --no-cone)" ]]; then
+                       using_cone=false
+               fi
+               if [[ "$using_cone" == "true" ]]; then
                        __gitcomp_directories
+               else
+                        __gitcomp_slash_leading_paths
                fi
        esac
 }
index 2c030050aea1c67472570a9d86d69d55e31e7714..71f179cba3fbda3bc93de461649cf75bb08c6653 100644 (file)
@@ -408,7 +408,7 @@ __git_ps1 ()
 
        local repo_info rev_parse_exit_code
        repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
-               --is-bare-repository --is-inside-work-tree \
+               --is-bare-repository --is-inside-work-tree --show-ref-format \
                --short HEAD 2>/dev/null)"
        rev_parse_exit_code="$?"
 
@@ -421,6 +421,8 @@ __git_ps1 ()
                short_sha="${repo_info##*$'\n'}"
                repo_info="${repo_info%$'\n'*}"
        fi
+       local ref_format="${repo_info##*$'\n'}"
+       repo_info="${repo_info%$'\n'*}"
        local inside_worktree="${repo_info##*$'\n'}"
        repo_info="${repo_info%$'\n'*}"
        local bare_repo="${repo_info##*$'\n'}"
@@ -479,12 +481,25 @@ __git_ps1 ()
                        b="$(git symbolic-ref HEAD 2>/dev/null)"
                else
                        local head=""
-                       if ! __git_eread "$g/HEAD" head; then
-                               return $exit
-                       fi
-                       # is it a symbolic ref?
-                       b="${head#ref: }"
-                       if [ "$head" = "$b" ]; then
+
+                       case "$ref_format" in
+                       files)
+                               if ! __git_eread "$g/HEAD" head; then
+                                       return $exit
+                               fi
+
+                               if [[ $head == "ref: "* ]]; then
+                                       head="${head#ref: }"
+                               else
+                                       head=""
+                               fi
+                               ;;
+                       *)
+                               head="$(git symbolic-ref HEAD 2>/dev/null)"
+                               ;;
+                       esac
+
+                       if test -z "$head"; then
                                detached=yes
                                b="$(
                                case "${GIT_PS1_DESCRIBE_STYLE-}" in
@@ -502,6 +517,8 @@ __git_ps1 ()
 
                                b="$short_sha..."
                                b="($b)"
+                       else
+                               b="$head"
                        fi
                fi
        fi
index 215a81d8bae59ca2364eb762c72089ff8b6b51d7..90034d0cf1eb3d04c04872f38f2c8ba3a25fd904 100644 (file)
@@ -164,6 +164,9 @@ static int keyring_get(struct credential *c)
                        if (g_strv_length(parts) >= 1) {
                                g_free(c->password);
                                c->password = g_strdup(parts[0]);
+                       } else {
+                               g_free(c->password);
+                               c->password = g_strdup("");
                        }
                        for (int i = 1; i < g_strv_length(parts); i++) {
                                if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {
index 4cd56c42e24469a48a40e7b02de4b4921ff8662c..4be0d58cd89ad7bfbbf8c8fc0b2268cee9052f9e 100644 (file)
@@ -35,7 +35,7 @@ static void *xmalloc(size_t size)
 }
 
 static WCHAR *wusername, *password, *protocol, *host, *path, target[1024],
-       *password_expiry_utc;
+       *password_expiry_utc, *oauth_refresh_token;
 
 static void write_item(const char *what, LPCWSTR wbuf, int wlen)
 {
@@ -140,6 +140,11 @@ static void get_credential(void)
        DWORD num_creds;
        int i;
        CREDENTIAL_ATTRIBUTEW *attr;
+       WCHAR *secret;
+       WCHAR *line;
+       WCHAR *remaining_lines;
+       WCHAR *part;
+       WCHAR *remaining_parts;
 
        if (!CredEnumerateW(L"git:*", 0, &num_creds, &creds))
                return;
@@ -149,9 +154,24 @@ static void get_credential(void)
                if (match_cred(creds[i], 0)) {
                        write_item("username", creds[i]->UserName,
                                creds[i]->UserName ? wcslen(creds[i]->UserName) : 0);
-                       write_item("password",
-                               (LPCWSTR)creds[i]->CredentialBlob,
-                               creds[i]->CredentialBlobSize / sizeof(WCHAR));
+                       if (creds[i]->CredentialBlobSize > 0) {
+                               secret = xmalloc(creds[i]->CredentialBlobSize);
+                               wcsncpy_s(secret, creds[i]->CredentialBlobSize, (LPCWSTR)creds[i]->CredentialBlob, creds[i]->CredentialBlobSize / sizeof(WCHAR));
+                               line = wcstok_s(secret, L"\r\n", &remaining_lines);
+                               write_item("password", line, line ? wcslen(line) : 0);
+                               while(line != NULL) {
+                                       part = wcstok_s(line, L"=", &remaining_parts);
+                                       if (!wcscmp(part, L"oauth_refresh_token")) {
+                                               write_item("oauth_refresh_token", remaining_parts, remaining_parts ? wcslen(remaining_parts) : 0);
+                                       }
+                                       line = wcstok_s(NULL, L"\r\n", &remaining_lines);
+                               }
+                               free(secret);
+                       } else {
+                               write_item("password",
+                                               (LPCWSTR)creds[i]->CredentialBlob,
+                                               creds[i]->CredentialBlobSize / sizeof(WCHAR));
+                       }
                        for (int j = 0; j < creds[i]->AttributeCount; j++) {
                                attr = creds[i]->Attributes + j;
                                if (!wcscmp(attr->Keyword, L"git_password_expiry_utc")) {
@@ -170,16 +190,26 @@ static void store_credential(void)
 {
        CREDENTIALW cred;
        CREDENTIAL_ATTRIBUTEW expiry_attr;
+       WCHAR *secret;
+       int wlen;
 
        if (!wusername || !password)
                return;
 
+       if (oauth_refresh_token) {
+               wlen = _scwprintf(L"%s\r\noauth_refresh_token=%s", password, oauth_refresh_token);
+               secret = xmalloc(sizeof(WCHAR) * wlen);
+               _snwprintf_s(secret, sizeof(WCHAR) * wlen, wlen, L"%s\r\noauth_refresh_token=%s", password, oauth_refresh_token);
+       } else {
+               secret = _wcsdup(password);
+       }
+
        cred.Flags = 0;
        cred.Type = CRED_TYPE_GENERIC;
        cred.TargetName = target;
        cred.Comment = L"saved by git-credential-wincred";
-       cred.CredentialBlobSize = (wcslen(password)) * sizeof(WCHAR);
-       cred.CredentialBlob = (LPVOID)password;
+       cred.CredentialBlobSize = wcslen(secret) * sizeof(WCHAR);
+       cred.CredentialBlob = (LPVOID)_wcsdup(secret);
        cred.Persist = CRED_PERSIST_LOCAL_MACHINE;
        cred.AttributeCount = 0;
        cred.Attributes = NULL;
@@ -194,6 +224,8 @@ static void store_credential(void)
        cred.TargetAlias = NULL;
        cred.UserName = wusername;
 
+       free(secret);
+
        if (!CredWriteW(&cred, 0))
                die("CredWrite failed");
 }
@@ -265,6 +297,8 @@ static void read_credential(void)
                        password = utf8_to_utf16_dup(v);
                else if (!strcmp(buf, "password_expiry_utc"))
                        password_expiry_utc = utf8_to_utf16_dup(v);
+               else if (!strcmp(buf, "oauth_refresh_token"))
+                       oauth_refresh_token = utf8_to_utf16_dup(v);
                /*
                 * Ignore other lines; we don't know what they mean, but
                 * this future-proofs us when later versions of git do
index e0c5d3b0de63483113edbcc09003e70aaa0a3d2d..5dab3f506c6e0877740f7d3990388b3975e877c5 100755 (executable)
@@ -373,7 +373,8 @@ try_remove_previous () {
 
 # Usage: process_subtree_split_trailer SPLIT_HASH MAIN_HASH [REPOSITORY]
 process_subtree_split_trailer () {
-       assert test $# = 2 -o $# = 3
+       assert test $# -ge 2
+       assert test $# -le 3
        b="$1"
        sq="$2"
        repository=""
@@ -402,7 +403,8 @@ process_subtree_split_trailer () {
 
 # Usage: find_latest_squash DIR [REPOSITORY]
 find_latest_squash () {
-       assert test $# = 1 -o $# = 2
+       assert test $# -ge 1
+       assert test $# -le 2
        dir="$1"
        repository=""
        if test "$#" = 2
@@ -455,7 +457,8 @@ find_latest_squash () {
 
 # Usage: find_existing_splits DIR REV [REPOSITORY]
 find_existing_splits () {
-       assert test $# = 2 -o $# = 3
+       assert test $# -ge 2
+       assert test $# -le 3
        debug "Looking for prior splits..."
        local indent=$(($indent + 1))
 
@@ -489,13 +492,13 @@ find_existing_splits () {
                        ;;
                END)
                        debug "Main is: '$main'"
-                       if test -z "$main" -a -n "$sub"
+                       if test -z "$main" && test -n "$sub"
                        then
                                # squash commits refer to a subtree
                                debug "  Squash: $sq from $sub"
                                cache_set "$sq" "$sub"
                        fi
-                       if test -n "$main" -a -n "$sub"
+                       if test -n "$main" && test -n "$sub"
                        then
                                debug "  Prior: $main -> $sub"
                                cache_set $main $sub
@@ -638,10 +641,16 @@ subtree_for_commit () {
        while read mode type tree name
        do
                assert test "$name" = "$dir"
-               assert test "$type" = "tree" -o "$type" = "commit"
-               test "$type" = "commit" && continue  # ignore submodules
-               echo $tree
-               break
+
+               case "$type" in
+               commit)
+                       continue;; # ignore submodules
+               tree)
+                       echo $tree
+                       break;;
+               *)
+                       die "fatal: tree entry is of type ${type}, expected tree or commit";;
+               esac
        done || exit $?
 }
 
@@ -778,6 +787,22 @@ ensure_valid_ref_format () {
                die "fatal: '$1' does not look like a ref"
 }
 
+# Usage: check if a commit from another subtree should be
+# ignored from processing for splits
+should_ignore_subtree_split_commit () {
+       assert test $# = 1
+       local rev="$1"
+       if test -n "$(git log -1 --grep="git-subtree-dir:" $rev)"
+       then
+               if test -z "$(git log -1 --grep="git-subtree-mainline:" $rev)" &&
+                       test -z "$(git log -1 --grep="git-subtree-dir: $arg_prefix$" $rev)"
+               then
+                       return 0
+               fi
+       fi
+       return 1
+}
+
 # Usage: process_split_commit REV PARENTS
 process_split_commit () {
        assert test $# = 2
@@ -916,7 +941,7 @@ cmd_split () {
        if test $# -eq 0
        then
                rev=$(git rev-parse HEAD)
-       elif test $# -eq 1 -o $# -eq 2
+       elif test $# -eq 1 || test $# -eq 2
        then
                rev=$(git rev-parse -q --verify "$1^{commit}") ||
                        die "fatal: '$1' does not refer to a commit"
@@ -963,7 +988,19 @@ cmd_split () {
        eval "$grl" |
        while read rev parents
        do
-               process_split_commit "$rev" "$parents"
+               if should_ignore_subtree_split_commit "$rev"
+               then
+                       continue
+               fi
+               parsedparents=''
+               for parent in $parents
+               do
+                       if ! should_ignore_subtree_split_commit "$parent"
+                       then
+                               parsedparents="$parsedparents$parent "
+                       fi
+               done
+               process_split_commit "$rev" "$parsedparents"
        done || exit $?
 
        latest_new=$(cache_get latest_new) || exit $?
@@ -1006,8 +1043,11 @@ cmd_split () {
 
 # Usage: cmd_merge REV [REPOSITORY]
 cmd_merge () {
-       test $# -eq 1 -o $# -eq 2 ||
+       if test $# -lt 1 || test $# -gt 2
+       then
                die "fatal: you must provide exactly one revision, and optionally a repository. Got: '$*'"
+       fi
+
        rev=$(git rev-parse -q --verify "$1^{commit}") ||
                die "fatal: '$1' does not refer to a commit"
        repository=""
index 49a21dd7c9c553f80a905ca8333b93fbe05fcc67..ca4df5be83245fe9a37a0b46737b61071f3b78b0 100755 (executable)
@@ -385,6 +385,46 @@ test_expect_success 'split sub dir/ with --rejoin' '
        )
 '
 
+# Tests that commits from other subtrees are not processed as
+# part of a split.
+#
+# This test performs the following:
+# - Creates Repo with subtrees 'subA' and 'subB'
+# - Creates commits in the repo including changes to subtrees
+# - Runs the following 'split' and commit' commands in order:
+#      - Perform 'split' on subtree A
+#      - Perform 'split' on subtree B
+#      - Create new commits with changes to subtree A and B
+#      - Perform split on subtree A
+#      - Check that the commits in subtree B are not processed
+#                      as part of the subtree A split
+test_expect_success 'split with multiple subtrees' '
+       subtree_test_create_repo "$test_count" &&
+       subtree_test_create_repo "$test_count/subA" &&
+       subtree_test_create_repo "$test_count/subB" &&
+       test_create_commit "$test_count" main1 &&
+       test_create_commit "$test_count/subA" subA1 &&
+       test_create_commit "$test_count/subA" subA2 &&
+       test_create_commit "$test_count/subA" subA3 &&
+       test_create_commit "$test_count/subB" subB1 &&
+       git -C "$test_count" fetch ./subA HEAD &&
+       git -C "$test_count" subtree add --prefix=subADir FETCH_HEAD &&
+       git -C "$test_count" fetch ./subB HEAD &&
+       git -C "$test_count" subtree add --prefix=subBDir FETCH_HEAD &&
+       test_create_commit "$test_count" subADir/main-subA1 &&
+       test_create_commit "$test_count" subBDir/main-subB1 &&
+       git -C "$test_count" subtree split --prefix=subADir \
+               --squash --rejoin -m "Sub A Split 1" &&
+       git -C "$test_count" subtree split --prefix=subBDir \
+               --squash --rejoin -m "Sub B Split 1" &&
+       test_create_commit "$test_count" subADir/main-subA2 &&
+       test_create_commit "$test_count" subBDir/main-subB2 &&
+       git -C "$test_count" subtree split --prefix=subADir \
+               --squash --rejoin -m "Sub A Split 2" &&
+       test "$(git -C "$test_count" subtree split --prefix=subBDir \
+               --squash --rejoin -d -m "Sub B Split 1" 2>&1 | grep -w "\[1\]")" = ""
+'
+
 test_expect_success 'split sub dir/ with --rejoin from scratch' '
        subtree_test_create_repo "$test_count" &&
        test_create_commit "$test_count" main1 &&
index 888c34a5215258ad7d5715771f92ab58f3efd363..989197aace0bc03ecae6d5f94af86e6e91968562 100755 (executable)
@@ -79,7 +79,7 @@ trap cleanup $siglist
 # create the links to the original repo.  explicitly exclude index, HEAD and
 # logs/HEAD from the list since they are purely related to the current working
 # directory, and should not be shared.
-for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn
+for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn reftable
 do
        # create a containing directory if needed
        case $x in
index a8870baff36a4a3042baf31c730793b45f6b6442..35b25eb3cb9212f92dd918d0f247e49ecd620c41 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1028,7 +1028,7 @@ static int read_convert_config(const char *var, const char *value,
        if (parse_config_key(var, "filter", &name, &namelen, &key) < 0 || !name)
                return 0;
        for (drv = user_convert; drv; drv = drv->next)
-               if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
+               if (!xstrncmpz(drv->name, name, namelen))
                        break;
        if (!drv) {
                CALLOC_ARRAY(drv, 1);
index 8fde93d7cac78d9fee3f3326ae4fff2e36a6c009..6c8df04273702fa47215dffa263477df347900ee 100644 (file)
  */
 static int check_removed(const struct cache_entry *ce, struct stat *st)
 {
-       if (lstat(ce->name, st) < 0) {
+       int stat_err;
+
+       if (!(ce->ce_flags & CE_FSMONITOR_VALID))
+               stat_err = lstat(ce->name, st);
+       else
+               stat_err = fake_lstat(ce, st);
+       if (stat_err < 0) {
                if (!is_missing_file_error(errno))
                        return -1;
                return 1;
diff --git a/diff.c b/diff.c
index ccfa1fca0d05fa0148a53e05497efaf21cc4d916..e50def45383eba4af74300802a161bdeeb6c4e8f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5590,7 +5590,7 @@ struct option *add_diff_options(const struct option *opts,
                OPT_BITOP(0, "shortstat", &options->output_format,
                          N_("output only the last line of --stat"),
                          DIFF_FORMAT_SHORTSTAT, DIFF_FORMAT_NO_OUTPUT),
-               OPT_CALLBACK_F('X', "dirstat", options, N_("<param1,param2>..."),
+               OPT_CALLBACK_F('X', "dirstat", options, N_("<param1>,<param2>..."),
                               N_("output the distribution of relative amount of changes for each sub-directory"),
                               PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
                               diff_opt_dirstat),
@@ -5598,8 +5598,8 @@ struct option *add_diff_options(const struct option *opts,
                               N_("synonym for --dirstat=cumulative"),
                               PARSE_OPT_NONEG | PARSE_OPT_NOARG,
                               diff_opt_dirstat),
-               OPT_CALLBACK_F(0, "dirstat-by-file", options, N_("<param1,param2>..."),
-                              N_("synonym for --dirstat=files,param1,param2..."),
+               OPT_CALLBACK_F(0, "dirstat-by-file", options, N_("<param1>,<param2>..."),
+                              N_("synonym for --dirstat=files,<param1>,<param2>..."),
                               PARSE_OPT_NONEG | PARSE_OPT_OPTARG,
                               diff_opt_dirstat),
                OPT_BIT_F(0, "check", &options->output_format,
index 278b04243a3f40e63df433eea9549f90aed1c34d..de619846f29ad9c51d42b538d12c1b62e3958b5d 100644 (file)
@@ -2,10 +2,19 @@
 #include "dir.h"
 #include "iterator.h"
 #include "dir-iterator.h"
+#include "string-list.h"
 
 struct dir_iterator_level {
        DIR *dir;
 
+       /*
+        * The directory entries of the current level. This list will only be
+        * populated when the iterator is ordered. In that case, `dir` will be
+        * set to `NULL`.
+        */
+       struct string_list entries;
+       size_t entries_idx;
+
        /*
         * The length of the directory part of path at this level
         * (including a trailing '/'):
@@ -43,6 +52,31 @@ struct dir_iterator_int {
        unsigned int flags;
 };
 
+static int next_directory_entry(DIR *dir, const char *path,
+                               struct dirent **out)
+{
+       struct dirent *de;
+
+repeat:
+       errno = 0;
+       de = readdir(dir);
+       if (!de) {
+               if (errno) {
+                       warning_errno("error reading directory '%s'",
+                                     path);
+                       return -1;
+               }
+
+               return 1;
+       }
+
+       if (is_dot_or_dotdot(de->d_name))
+               goto repeat;
+
+       *out = de;
+       return 0;
+}
+
 /*
  * Push a level in the iter stack and initialize it with information from
  * the directory pointed by iter->base->path. It is assumed that this
@@ -72,6 +106,35 @@ static int push_level(struct dir_iterator_int *iter)
                return -1;
        }
 
+       string_list_init_dup(&level->entries);
+       level->entries_idx = 0;
+
+       /*
+        * When the iterator is sorted we read and sort all directory entries
+        * directly.
+        */
+       if (iter->flags & DIR_ITERATOR_SORTED) {
+               struct dirent *de;
+
+               while (1) {
+                       int ret = next_directory_entry(level->dir, iter->base.path.buf, &de);
+                       if (ret < 0) {
+                               if (errno != ENOENT &&
+                                   iter->flags & DIR_ITERATOR_PEDANTIC)
+                                       return -1;
+                               continue;
+                       } else if (ret > 0) {
+                               break;
+                       }
+
+                       string_list_append(&level->entries, de->d_name);
+               }
+               string_list_sort(&level->entries);
+
+               closedir(level->dir);
+               level->dir = NULL;
+       }
+
        return 0;
 }
 
@@ -88,21 +151,22 @@ static int pop_level(struct dir_iterator_int *iter)
                warning_errno("error closing directory '%s'",
                              iter->base.path.buf);
        level->dir = NULL;
+       string_list_clear(&level->entries, 0);
 
        return --iter->levels_nr;
 }
 
 /*
  * Populate iter->base with the necessary information on the next iteration
- * entry, represented by the given dirent de. Return 0 on success and -1
+ * entry, represented by the given name. Return 0 on success and -1
  * otherwise, setting errno accordingly.
  */
 static int prepare_next_entry_data(struct dir_iterator_int *iter,
-                                  struct dirent *de)
+                                  const char *name)
 {
        int err, saved_errno;
 
-       strbuf_addstr(&iter->base.path, de->d_name);
+       strbuf_addstr(&iter->base.path, name);
        /*
         * We have to reset these because the path strbuf might have
         * been realloc()ed at the previous strbuf_addstr().
@@ -139,27 +203,34 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator)
                struct dirent *de;
                struct dir_iterator_level *level =
                        &iter->levels[iter->levels_nr - 1];
+               const char *name;
 
                strbuf_setlen(&iter->base.path, level->prefix_len);
-               errno = 0;
-               de = readdir(level->dir);
 
-               if (!de) {
-                       if (errno) {
-                               warning_errno("error reading directory '%s'",
-                                             iter->base.path.buf);
+               if (level->dir) {
+                       int ret = next_directory_entry(level->dir, iter->base.path.buf, &de);
+                       if (ret < 0) {
                                if (iter->flags & DIR_ITERATOR_PEDANTIC)
                                        goto error_out;
-                       } else if (pop_level(iter) == 0) {
-                               return dir_iterator_abort(dir_iterator);
+                               continue;
+                       } else if (ret > 0) {
+                               if (pop_level(iter) == 0)
+                                       return dir_iterator_abort(dir_iterator);
+                               continue;
                        }
-                       continue;
-               }
 
-               if (is_dot_or_dotdot(de->d_name))
-                       continue;
+                       name = de->d_name;
+               } else {
+                       if (level->entries_idx >= level->entries.nr) {
+                               if (pop_level(iter) == 0)
+                                       return dir_iterator_abort(dir_iterator);
+                               continue;
+                       }
 
-               if (prepare_next_entry_data(iter, de)) {
+                       name = level->entries.items[level->entries_idx++].string;
+               }
+
+               if (prepare_next_entry_data(iter, name)) {
                        if (errno != ENOENT && iter->flags & DIR_ITERATOR_PEDANTIC)
                                goto error_out;
                        continue;
@@ -188,6 +259,8 @@ int dir_iterator_abort(struct dir_iterator *dir_iterator)
                        warning_errno("error closing directory '%s'",
                                      iter->base.path.buf);
                }
+
+               string_list_clear(&level->entries, 0);
        }
 
        free(iter->levels);
index 479e1ec784dfa4081430ea5a104302e79d10eae3..6d438809b6ed51b5735080f878c08aa2302b7552 100644 (file)
  *   and ITER_ERROR is returned immediately. In both cases, a meaningful
  *   warning is emitted. Note: ENOENT errors are always ignored so that
  *   the API users may remove files during iteration.
+ *
+ * - DIR_ITERATOR_SORTED: sort directory entries alphabetically.
  */
 #define DIR_ITERATOR_PEDANTIC (1 << 0)
+#define DIR_ITERATOR_SORTED   (1 << 1)
 
 struct dir_iterator {
        /* The current path: */
diff --git a/dir.c b/dir.c
index 3e75c126edf3fbe6d18b719f68538c648189fbfb..ac699542302cece1d1aea426cd4cc37940e6fead 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -2178,7 +2178,8 @@ static int exclude_matches_pathspec(const char *path, int pathlen,
                       PATHSPEC_LITERAL |
                       PATHSPEC_GLOB |
                       PATHSPEC_ICASE |
-                      PATHSPEC_EXCLUDE);
+                      PATHSPEC_EXCLUDE |
+                      PATHSPEC_ATTR);
 
        for (i = 0; i < pathspec->nr; i++) {
                const struct pathspec_item *item = &pathspec->items[i];
index 90632a39bc995af8bf56166b4d89bba5d6dd5272..60706ea3987f2c4d11e5e2e2d21aa5cd5e9196e1 100644 (file)
@@ -207,6 +207,9 @@ void setup_git_env(const char *git_dir)
        shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
        if (shallow_file)
                set_alternate_shallow_file(the_repository, shallow_file, 0);
+
+       if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0))
+               fetch_if_missing = 0;
 }
 
 int is_bare_repository(void)
index e5351c9dd95ea6e7afe77b1db466d6ab30310491..5cec19cecc1a5a2c057f807f3b96dd2b29f0b355 100644 (file)
@@ -36,6 +36,7 @@ const char *getenv_safe(struct strvec *argv, const char *name);
 #define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
 #define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
 #define GIT_REPLACE_REF_BASE_ENVIRONMENT "GIT_REPLACE_REF_BASE"
+#define NO_LAZY_FETCH_ENVIRONMENT "GIT_NO_LAZY_FETCH"
 #define GITATTRIBUTES_FILE ".gitattributes"
 #define INFOATTRIBUTES_FILE "info/attributes"
 #define ATTRIBUTE_MACRO_PREFIX "[attr]"
index 7b525b1ecd896e02dfa71cdf3aab75496d998fac..ac7e0af622a8fc74b678b57f464698d1bc9a45e7 100644 (file)
@@ -169,6 +169,15 @@ size_t bitmap_popcount(struct bitmap *self)
        return count;
 }
 
+int bitmap_is_empty(struct bitmap *self)
+{
+       size_t i;
+       for (i = 0; i < self->word_alloc; i++)
+               if (self->words[i])
+                       return 0;
+       return 1;
+}
+
 int bitmap_equals(struct bitmap *self, struct bitmap *other)
 {
        struct bitmap *big, *small;
index 7eb8b9b63013daa70c91687108307d38a9eb1e09..c11d76c6f336930e0ea540a5b40c594bdb9f5be2 100644 (file)
@@ -189,5 +189,6 @@ void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other);
 void bitmap_or(struct bitmap *self, const struct bitmap *other);
 
 size_t bitmap_popcount(struct bitmap *self);
+int bitmap_is_empty(struct bitmap *self);
 
 #endif
diff --git a/fsck.c b/fsck.c
index 1ad02fcdfabea74dc7f3d1c214400516d327a421..8ded0a473a47fb45c223d8736f58c599b66cbb93 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -20,7 +20,6 @@
 #include "packfile.h"
 #include "submodule-config.h"
 #include "config.h"
-#include "credential.h"
 #include "help.h"
 
 static ssize_t max_tree_entry_len = 4096;
@@ -1047,138 +1046,6 @@ done:
        return ret;
 }
 
-static int starts_with_dot_slash(const char *const path)
-{
-       return path_match_flags(path, PATH_MATCH_STARTS_WITH_DOT_SLASH |
-                               PATH_MATCH_XPLATFORM);
-}
-
-static int starts_with_dot_dot_slash(const char *const path)
-{
-       return path_match_flags(path, PATH_MATCH_STARTS_WITH_DOT_DOT_SLASH |
-                               PATH_MATCH_XPLATFORM);
-}
-
-static int submodule_url_is_relative(const char *url)
-{
-       return starts_with_dot_slash(url) || starts_with_dot_dot_slash(url);
-}
-
-/*
- * Count directory components that a relative submodule URL should chop
- * from the remote_url it is to be resolved against.
- *
- * In other words, this counts "../" components at the start of a
- * submodule URL.
- *
- * Returns the number of directory components to chop and writes a
- * pointer to the next character of url after all leading "./" and
- * "../" components to out.
- */
-static int count_leading_dotdots(const char *url, const char **out)
-{
-       int result = 0;
-       while (1) {
-               if (starts_with_dot_dot_slash(url)) {
-                       result++;
-                       url += strlen("../");
-                       continue;
-               }
-               if (starts_with_dot_slash(url)) {
-                       url += strlen("./");
-                       continue;
-               }
-               *out = url;
-               return result;
-       }
-}
-/*
- * Check whether a transport is implemented by git-remote-curl.
- *
- * If it is, returns 1 and writes the URL that would be passed to
- * git-remote-curl to the "out" parameter.
- *
- * Otherwise, returns 0 and leaves "out" untouched.
- *
- * Examples:
- *   http::https://example.com/repo.git -> 1, https://example.com/repo.git
- *   https://example.com/repo.git -> 1, https://example.com/repo.git
- *   git://example.com/repo.git -> 0
- *
- * This is for use in checking for previously exploitable bugs that
- * required a submodule URL to be passed to git-remote-curl.
- */
-static int url_to_curl_url(const char *url, const char **out)
-{
-       /*
-        * We don't need to check for case-aliases, "http.exe", and so
-        * on because in the default configuration, is_transport_allowed
-        * prevents URLs with those schemes from being cloned
-        * automatically.
-        */
-       if (skip_prefix(url, "http::", out) ||
-           skip_prefix(url, "https::", out) ||
-           skip_prefix(url, "ftp::", out) ||
-           skip_prefix(url, "ftps::", out))
-               return 1;
-       if (starts_with(url, "http://") ||
-           starts_with(url, "https://") ||
-           starts_with(url, "ftp://") ||
-           starts_with(url, "ftps://")) {
-               *out = url;
-               return 1;
-       }
-       return 0;
-}
-
-static int check_submodule_url(const char *url)
-{
-       const char *curl_url;
-
-       if (looks_like_command_line_option(url))
-               return -1;
-
-       if (submodule_url_is_relative(url) || starts_with(url, "git://")) {
-               char *decoded;
-               const char *next;
-               int has_nl;
-
-               /*
-                * This could be appended to an http URL and url-decoded;
-                * check for malicious characters.
-                */
-               decoded = url_decode(url);
-               has_nl = !!strchr(decoded, '\n');
-
-               free(decoded);
-               if (has_nl)
-                       return -1;
-
-               /*
-                * URLs which escape their root via "../" can overwrite
-                * the host field and previous components, resolving to
-                * URLs like https::example.com/submodule.git and
-                * https:///example.com/submodule.git that were
-                * susceptible to CVE-2020-11008.
-                */
-               if (count_leading_dotdots(url, &next) > 0 &&
-                   (*next == ':' || *next == '/'))
-                       return -1;
-       }
-
-       else if (url_to_curl_url(url, &curl_url)) {
-               struct credential c = CREDENTIAL_INIT;
-               int ret = 0;
-               if (credential_from_url_gently(&c, curl_url, 1) ||
-                   !*c.host)
-                       ret = -1;
-               credential_clear(&c);
-               return ret;
-       }
-
-       return 0;
-}
-
 struct fsck_gitmodules_data {
        const struct object_id *oid;
        struct fsck_options *options;
index 3e7a59b5ff108dddce111cb372b6c846c093b4be..7c2a6538e5afea607f3d9a1c09cc6aea5539d8de 100644 (file)
@@ -225,6 +225,7 @@ struct strbuf;
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <string.h>
 #ifdef HAVE_STRINGS_H
 #include <strings.h> /* for strcasecmp() */
@@ -684,11 +685,11 @@ report_fn get_warn_routine(void);
 void set_die_is_recursing_routine(int (*routine)(void));
 
 /*
- * If the string "str" begins with the string found in "prefix", return 1.
+ * If the string "str" begins with the string found in "prefix", return true.
  * The "out" parameter is set to "str + strlen(prefix)" (i.e., to the point in
  * the string right after the prefix).
  *
- * Otherwise, return 0 and leave "out" untouched.
+ * Otherwise, return false and leave "out" untouched.
  *
  * Examples:
  *
@@ -699,57 +700,58 @@ void set_die_is_recursing_routine(int (*routine)(void));
  *   [skip prefix if present, otherwise use whole string]
  *   skip_prefix(name, "refs/heads/", &name);
  */
-static inline int skip_prefix(const char *str, const char *prefix,
-                             const char **out)
+static inline bool skip_prefix(const char *str, const char *prefix,
+                              const char **out)
 {
        do {
                if (!*prefix) {
                        *out = str;
-                       return 1;
+                       return true;
                }
        } while (*str++ == *prefix++);
-       return 0;
+       return false;
 }
 
 /*
  * Like skip_prefix, but promises never to read past "len" bytes of the input
  * buffer, and returns the remaining number of bytes in "out" via "outlen".
  */
-static inline int skip_prefix_mem(const char *buf, size_t len,
-                                 const char *prefix,
-                                 const char **out, size_t *outlen)
+static inline bool skip_prefix_mem(const char *buf, size_t len,
+                                  const char *prefix,
+                                  const char **out, size_t *outlen)
 {
        size_t prefix_len = strlen(prefix);
        if (prefix_len <= len && !memcmp(buf, prefix, prefix_len)) {
                *out = buf + prefix_len;
                *outlen = len - prefix_len;
-               return 1;
+               return true;
        }
-       return 0;
+       return false;
 }
 
 /*
- * If buf ends with suffix, return 1 and subtract the length of the suffix
- * from *len. Otherwise, return 0 and leave *len untouched.
+ * If buf ends with suffix, return true and subtract the length of the suffix
+ * from *len. Otherwise, return false and leave *len untouched.
  */
-static inline int strip_suffix_mem(const char *buf, size_t *len,
-                                  const char *suffix)
+static inline bool strip_suffix_mem(const char *buf, size_t *len,
+                                   const char *suffix)
 {
        size_t suflen = strlen(suffix);
        if (*len < suflen || memcmp(buf + (*len - suflen), suffix, suflen))
-               return 0;
+               return false;
        *len -= suflen;
-       return 1;
+       return true;
 }
 
 /*
- * If str ends with suffix, return 1 and set *len to the size of the string
- * without the suffix. Otherwise, return 0 and set *len to the size of the
+ * If str ends with suffix, return true and set *len to the size of the string
+ * without the suffix. Otherwise, return false and set *len to the size of the
  * string.
  *
  * Note that we do _not_ NUL-terminate str to the new length.
  */
-static inline int strip_suffix(const char *str, const char *suffix, size_t *len)
+static inline bool strip_suffix(const char *str, const char *suffix,
+                               size_t *len)
 {
        *len = strlen(str);
        return strip_suffix_mem(str, len, suffix);
@@ -1013,6 +1015,15 @@ static inline unsigned long cast_size_t_to_ulong(size_t a)
        return (unsigned long)a;
 }
 
+static inline uint32_t cast_size_t_to_uint32_t(size_t a)
+{
+       if (a != (uint32_t)a)
+               die("object too large to read on this platform: %"
+                   PRIuMAX" is cut off to %u",
+                   (uintmax_t)a, (uint32_t)a);
+       return (uint32_t)a;
+}
+
 static inline int cast_size_t_to_int(size_t a)
 {
        if (a > INT_MAX)
index e4e820e68095928765940be51fba0cdb8e5d609c..dd0c9a5b7f2b078205000f3051df0bade8b0cfab 100755 (executable)
@@ -91,6 +91,19 @@ then
        # ignore the error from the above --- run_merge_tool
        # will diagnose unusable tool by itself
        run_merge_tool "$merge_tool" false
+
+       status=$?
+       if test $status -ge 126
+       then
+               # Command not found (127), not executable (126) or
+               # exited via a signal (>= 128).
+               exit $status
+       fi
+
+       if test "$GIT_DIFFTOOL_TRUST_EXIT_CODE" = true
+       then
+               exit $status
+       fi
 else
        # Launch the merge tool on each path provided by 'git diff'
        while test $# -gt 6
index 156597adb59f33d049b9ef81f10b7fda283eca3d..28ab12c72b6561bf6f583391acf8daa300a6211b 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -4251,7 +4251,8 @@ class P4Sync(Command, P4UserMap):
         if self.tempBranches != []:
             for branch in self.tempBranches:
                 read_pipe(["git", "update-ref", "-d", branch])
-            os.rmdir(os.path.join(os.environ.get("GIT_DIR", ".git"), self.tempBranchLocation))
+            if len(read_pipe(["git", "for-each-ref", self.tempBranchLocation])) > 0:
+                   die("There are unexpected temporary branches")
 
         # Create a symbolic ref p4/HEAD pointing to p4/<branch> to allow
         # a convenient shortcut refname "p4".
diff --git a/git.c b/git.c
index c67e44dd82d2e4fc01fb841c8f863282607f6ac7..5265f920f165d99f01584eed54554dd51563acca 100644 (file)
--- a/git.c
+++ b/git.c
@@ -4,6 +4,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
+#include "object-file.h"
 #include "pager.h"
 #include "read-cache-ll.h"
 #include "run-command.h"
@@ -186,6 +187,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                        use_pager = 0;
                        if (envchanged)
                                *envchanged = 1;
+               } else if (!strcmp(cmd, "--no-lazy-fetch")) {
+                       fetch_if_missing = 0;
+                       setenv(NO_LAZY_FETCH_ENVIRONMENT, "1", 1);
+                       if (envchanged)
+                               *envchanged = 1;
                } else if (!strcmp(cmd, "--no-replace-objects")) {
                        disable_replace_refs();
                        setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
@@ -594,6 +600,7 @@ static struct cmd_struct commands[] = {
        { "remote-fd", cmd_remote_fd, NO_PARSEOPT },
        { "repack", cmd_repack, RUN_SETUP },
        { "replace", cmd_replace, RUN_SETUP },
+       { "replay", cmd_replay, RUN_SETUP },
        { "rerere", cmd_rerere, RUN_SETUP },
        { "reset", cmd_reset, RUN_SETUP },
        { "restore", cmd_restore, RUN_SETUP | NEED_WORK_TREE },
index fc6d5dd522bf4f4c9869e4e14ea5a07409155784..ccd14e0e30c14ef1da31d09cf6949e70b75cf5e0 100755 (executable)
@@ -728,9 +728,11 @@ our $per_request_config = 1;
 sub read_config_file {
        my $filename = shift;
        return unless defined $filename;
-       # die if there are errors parsing config file
        if (-e $filename) {
                do $filename;
+               # die if there is a problem accessing the file
+               die $! if $!;
+               # die if there are errors parsing config file
                die $@ if $@;
                return 1;
        }
index ff07b87e6461446610c35708a39f22a5e5b36aff..1ed1e29d0706bfe51e2074cabe393e0ed6eba7c7 100644 (file)
@@ -38,6 +38,7 @@ struct rpc_service {
 static struct rpc_service rpc_service[] = {
        { "upload-pack", "uploadpack", 1, 1 },
        { "receive-pack", "receivepack", 0, -1 },
+       { "upload-archive", "uploadarchive", 0, -1 },
 };
 
 static struct string_list *get_parameters(void)
@@ -639,10 +640,15 @@ static void check_content_type(struct strbuf *hdr, const char *accepted_type)
 
 static void service_rpc(struct strbuf *hdr, char *service_name)
 {
-       const char *argv[] = {NULL, "--stateless-rpc", ".", NULL};
+       struct strvec argv = STRVEC_INIT;
        struct rpc_service *svc = select_service(hdr, service_name);
        struct strbuf buf = STRBUF_INIT;
 
+       strvec_push(&argv, svc->name);
+       if (strcmp(service_name, "git-upload-archive"))
+               strvec_push(&argv, "--stateless-rpc");
+       strvec_push(&argv, ".");
+
        strbuf_reset(&buf);
        strbuf_addf(&buf, "application/x-git-%s-request", svc->name);
        check_content_type(hdr, buf.buf);
@@ -655,9 +661,9 @@ static void service_rpc(struct strbuf *hdr, char *service_name)
 
        end_headers(hdr);
 
-       argv[0] = svc->name;
-       run_service(argv, svc->buffer_input);
+       run_service(argv.v, svc->buffer_input);
        strbuf_release(&buf);
+       strvec_clear(&argv);
 }
 
 static int dead;
@@ -723,6 +729,7 @@ static struct service_cmd {
        {"GET", "/objects/pack/pack-[0-9a-f]{64}\\.idx$", get_idx_file},
 
        {"POST", "/git-upload-pack$", service_rpc},
+       {"POST", "/git-upload-archive$", service_rpc},
        {"POST", "/git-receive-pack$", service_rpc}
 };
 
index b4d0b2a6aa381f4edb1bd890de4a4be1d10ab8fb..12d111374107a7a071ac90d035c5172af2b63c79 100644 (file)
@@ -1851,6 +1851,7 @@ int cmd_main(int argc, const char **argv)
 
                if (oideq(&ref->old_oid, &ref->peer_ref->new_oid)) {
                        if (push_verbosely)
+                               /* stable plumbing output; do not modify or localize */
                                fprintf(stderr, "'%s': up-to-date\n", ref->name);
                        if (helper_status)
                                printf("ok %s up to date\n", ref->name);
@@ -1871,6 +1872,7 @@ int cmd_main(int argc, const char **argv)
                                 * commits at the remote end and likely
                                 * we were not up to date to begin with.
                                 */
+                               /* stable plumbing output; do not modify or localize */
                                error("remote '%s' is not an ancestor of\n"
                                      "local '%s'.\n"
                                      "Maybe you are not up-to-date and "
index da287cc8e0dd2935cb230dd256d5f268495ed40f..4346f8da4560fd518d73db7969faa9127e302090 100644 (file)
@@ -711,15 +711,6 @@ static void filter_combine__free(void *filter_data)
        free(d);
 }
 
-static void add_all(struct oidset *dest, struct oidset *src) {
-       struct oidset_iter iter;
-       struct object_id *src_oid;
-
-       oidset_iter_init(src, &iter);
-       while ((src_oid = oidset_iter_next(&iter)) != NULL)
-               oidset_insert(dest, src_oid);
-}
-
 static void filter_combine__finalize_omits(
        struct oidset *omits,
        void *filter_data)
@@ -728,7 +719,7 @@ static void filter_combine__finalize_omits(
        size_t sub;
 
        for (sub = 0; sub < d->nr; sub++) {
-               add_all(omits, &d->sub[sub].omits);
+               oidset_insert_from_set(omits, &d->sub[sub].omits);
                oidset_clear(&d->sub[sub].omits);
        }
 }
index c34846d176c886ecb9f028ec48bb847402d242f9..2078c22b097a61c97faddb6689a75e6c10ccb9ee 100644 (file)
@@ -89,9 +89,7 @@ void *mem_pool_alloc(struct mem_pool *pool, size_t len)
        struct mp_block *p = NULL;
        void *r;
 
-       /* round up to a 'GIT_MAX_ALIGNMENT' alignment */
-       if (len & (GIT_MAX_ALIGNMENT - 1))
-               len += GIT_MAX_ALIGNMENT - (len & (GIT_MAX_ALIGNMENT - 1));
+       len = DIV_ROUND_UP(len, GIT_MAX_ALIGNMENT) * GIT_MAX_ALIGNMENT;
 
        if (pool->mp_block &&
            pool->mp_block->end - pool->mp_block->next_free >= len)
@@ -99,9 +97,9 @@ void *mem_pool_alloc(struct mem_pool *pool, size_t len)
 
        if (!p) {
                if (len >= (pool->block_alloc / 2))
-                       return mem_pool_alloc_block(pool, len, pool->mp_block);
-
-               p = mem_pool_alloc_block(pool, pool->block_alloc, NULL);
+                       p = mem_pool_alloc_block(pool, len, pool->mp_block);
+               else
+                       p = mem_pool_alloc_block(pool, pool->block_alloc, NULL);
        }
 
        r = p->next_free;
@@ -109,6 +107,45 @@ void *mem_pool_alloc(struct mem_pool *pool, size_t len)
        return r;
 }
 
+static char *mem_pool_strvfmt(struct mem_pool *pool, const char *fmt,
+                             va_list ap)
+{
+       struct mp_block *block = pool->mp_block;
+       char *next_free = block ? block->next_free : NULL;
+       size_t available = block ? block->end - block->next_free : 0;
+       va_list cp;
+       int len, len2;
+       char *ret;
+
+       va_copy(cp, ap);
+       len = vsnprintf(next_free, available, fmt, cp);
+       va_end(cp);
+       if (len < 0)
+               BUG("your vsnprintf is broken (returned %d)", len);
+
+       ret = mem_pool_alloc(pool, len + 1);  /* 1 for NUL */
+
+       /* Shortcut; relies on mem_pool_alloc() not touching buffer contents. */
+       if (ret == next_free)
+               return ret;
+
+       len2 = vsnprintf(ret, len + 1, fmt, ap);
+       if (len2 != len)
+               BUG("your vsnprintf is broken (returns inconsistent lengths)");
+       return ret;
+}
+
+char *mem_pool_strfmt(struct mem_pool *pool, const char *fmt, ...)
+{
+       va_list ap;
+       char *ret;
+
+       va_start(ap, fmt);
+       ret = mem_pool_strvfmt(pool, fmt, ap);
+       va_end(ap);
+       return ret;
+}
+
 void *mem_pool_calloc(struct mem_pool *pool, size_t count, size_t size)
 {
        size_t len = st_mult(count, size);
index fe7507f022bba40d74aab341e99269ead7171695..d1c66413ec322104f6199cc2248466c734cee868 100644 (file)
@@ -47,6 +47,11 @@ void *mem_pool_calloc(struct mem_pool *pool, size_t count, size_t size);
 char *mem_pool_strdup(struct mem_pool *pool, const char *str);
 char *mem_pool_strndup(struct mem_pool *pool, const char *str, size_t len);
 
+/*
+ * Allocate memory from the memory pool and format a string into it.
+ */
+char *mem_pool_strfmt(struct mem_pool *pool, const char *fmt, ...);
+
 /*
  * Move the memory associated with the 'src' pool to the 'dst' pool. The 'src'
  * pool will be empty and not contain any memory. It still needs to be free'd
index 1df58ebaac08582d042268f5a07cf5cbd9d7b1c3..61e0ae53981dbc786061a1b8ed7689ca5fee3912 100644 (file)
@@ -185,9 +185,9 @@ static void create_temp(mmfile_t *src, char *path, size_t len)
 static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,
                        mmbuffer_t *result,
                        const char *path,
-                       mmfile_t *orig, const char *orig_name UNUSED,
-                       mmfile_t *src1, const char *name1 UNUSED,
-                       mmfile_t *src2, const char *name2 UNUSED,
+                       mmfile_t *orig, const char *orig_name,
+                       mmfile_t *src1, const char *name1,
+                       mmfile_t *src2, const char *name2,
                        const struct ll_merge_options *opts,
                        int marker_size)
 {
@@ -222,6 +222,12 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,
                        strbuf_addf(&cmd, "%d", marker_size);
                else if (skip_prefix(format, "P", &format))
                        sq_quote_buf(&cmd, path);
+               else if (skip_prefix(format, "S", &format))
+                       sq_quote_buf(&cmd, orig_name ? orig_name : "");
+               else if (skip_prefix(format, "X", &format))
+                       sq_quote_buf(&cmd, name1 ? name1 : "");
+               else if (skip_prefix(format, "Y", &format))
+                       sq_quote_buf(&cmd, name2 ? name2 : "");
                else
                        strbuf_addch(&cmd, '%');
        }
@@ -286,7 +292,7 @@ static int read_merge_config(const char *var, const char *value,
         * after seeing merge.<name>.var1.
         */
        for (fn = ll_user_merge; fn; fn = fn->next)
-               if (!strncmp(fn->name, name, namelen) && !fn->name[namelen])
+               if (!xstrncmpz(fn->name, name, namelen))
                        break;
        if (!fn) {
                CALLOC_ARRAY(fn, 1);
@@ -315,7 +321,12 @@ static int read_merge_config(const char *var, const char *value,
                 *    %B - temporary file name for the other branches' version.
                 *    %L - conflict marker length
                 *    %P - the original path (safely quoted for the shell)
+                *    %S - the revision for the merge base
+                *    %X - the revision for our version
+                *    %Y - the revision for their version
                 *
+                * If the file is not named indentically in all versions, then each
+                * revision is joined with the corresponding path, separated by a colon.
                 * The external merge driver should write the results in the
                 * file named by %A, and signal that it has done with zero exit
                 * status.
index cb83449d7f7340eaf5969256fe4fdc9d09911c64..817f7b57c7bee9db817b5c9c77532615aef3d160 100644 (file)
@@ -18,6 +18,7 @@
 #include "merge-ort.h"
 
 #include "alloc.h"
+#include "advice.h"
 #include "attr.h"
 #include "cache-tree.h"
 #include "commit.h"
@@ -38,6 +39,7 @@
 #include "path.h"
 #include "promisor-remote.h"
 #include "read-cache-ll.h"
+#include "refs.h"
 #include "revision.h"
 #include "sparse-index.h"
 #include "strmap.h"
@@ -1656,9 +1658,10 @@ static int collect_merge_info(struct merge_options *opt,
        info.data = opt;
        info.show_all_errors = 1;
 
-       parse_tree(merge_base);
-       parse_tree(side1);
-       parse_tree(side2);
+       if (parse_tree(merge_base) < 0 ||
+           parse_tree(side1) < 0 ||
+           parse_tree(side2) < 0)
+               return -1;
        init_tree_desc(t + 0, merge_base->buffer, merge_base->size);
        init_tree_desc(t + 1, side1->buffer, side1->size);
        init_tree_desc(t + 2, side2->buffer, side2->size);
@@ -4375,9 +4378,11 @@ static int checkout(struct merge_options *opt,
        unpack_opts.verbose_update = (opt->verbosity > 2);
        unpack_opts.fn = twoway_merge;
        unpack_opts.preserve_ignored = 0; /* FIXME: !opts->overwrite_ignore */
-       parse_tree(prev);
+       if (parse_tree(prev) < 0)
+               return -1;
        init_tree_desc(&trees[0], prev->buffer, prev->size);
-       parse_tree(next);
+       if (parse_tree(next) < 0)
+               return -1;
        init_tree_desc(&trees[1], next->buffer, next->size);
 
        ret = unpack_trees(2, trees, &unpack_opts);
@@ -4555,7 +4560,7 @@ static void print_submodule_conflict_suggestion(struct string_list *csub) {
                      " - commit the resulting index in the superproject\n"),
                    tmp.buf, subs.buf);
 
-       printf("%s", msg.buf);
+       advise_if_enabled(ADVICE_SUBMODULE_MERGE_CONFLICT, "%s", msg.buf);
 
        strbuf_release(&subs);
        strbuf_release(&tmp);
@@ -4659,9 +4664,6 @@ void merge_switch_to_result(struct merge_options *opt,
 {
        assert(opt->priv == NULL);
        if (result->clean >= 0 && update_worktree_and_index) {
-               const char *filename;
-               FILE *fp;
-
                trace2_region_enter("merge", "checkout", opt->repo);
                if (checkout(opt, head, result->tree)) {
                        /* failure to function */
@@ -4687,10 +4689,17 @@ void merge_switch_to_result(struct merge_options *opt,
                trace2_region_leave("merge", "record_conflicted", opt->repo);
 
                trace2_region_enter("merge", "write_auto_merge", opt->repo);
-               filename = git_path_auto_merge(opt->repo);
-               fp = xfopen(filename, "w");
-               fprintf(fp, "%s\n", oid_to_hex(&result->tree->object.oid));
-               fclose(fp);
+               if (refs_update_ref(get_main_ref_store(opt->repo), "", "AUTO_MERGE",
+                                   &result->tree->object.oid, NULL, REF_NO_DEREF,
+                                   UPDATE_REFS_MSG_ON_ERR)) {
+                       /* failure to function */
+                       opt->priv = NULL;
+                       result->clean = -1;
+                       merge_finalize(opt, result);
+                       trace2_region_leave("merge", "write_auto_merge",
+                                           opt->repo);
+                       return;
+               }
                trace2_region_leave("merge", "write_auto_merge", opt->repo);
        }
        if (display_update_msgs)
@@ -4977,6 +4986,9 @@ redo:
 
        if (result->clean >= 0) {
                result->tree = parse_tree_indirect(&working_tree_oid);
+               if (!result->tree)
+                       die(_("unable to read tree (%s)"),
+                           oid_to_hex(&working_tree_oid));
                /* existence of conflicted entries implies unclean */
                result->clean &= strmap_empty(&opt->priv->conflicted);
        }
index a0c3e7a2d9105dd895f0ae2613d0f87f00b8d794..d58c05ad2ce847b9d41fecc01c42d8af4a90b9e1 100644 (file)
@@ -405,7 +405,8 @@ static inline int merge_detect_rename(struct merge_options *opt)
 
 static void init_tree_desc_from_tree(struct tree_desc *desc, struct tree *tree)
 {
-       parse_tree(tree);
+       if (parse_tree(tree) < 0)
+               exit(128);
        init_tree_desc(desc, tree->buffer, tree->size);
 }
 
diff --git a/merge.c b/merge.c
index ca89b312d173530f8c8a1e5d07470b9d2404e9d4..563281b10f1d04bd6b51a79f2852a61aa49552fd 100644 (file)
--- a/merge.c
+++ b/merge.c
@@ -77,7 +77,10 @@ int checkout_fast_forward(struct repository *r,
                return -1;
        }
        for (i = 0; i < nr_trees; i++) {
-               parse_tree(trees[i]);
+               if (parse_tree(trees[i]) < 0) {
+                       rollback_lock_file(&lock_file);
+                       return -1;
+               }
                init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
        }
 
index 06937acbf5497115c9ba4d9a2377634b1885db7e..97e376329bf510fce8c70c89a6de7a5465190d2b 100644 (file)
@@ -371,9 +371,17 @@ diff_cmd_help () {
 
 
 merge_cmd () {
-       layout=$(git config mergetool.vimdiff.layout)
+       TOOL=$1
 
-       case "$1" in
+       layout=$(git config "mergetool.$TOOL.layout")
+
+       # backward compatibility:
+       if test -z "$layout"
+       then
+               layout=$(git config mergetool.vimdiff.layout)
+       fi
+
+       case "$TOOL" in
        *vimdiff)
                if test -z "$layout"
                then
diff --git a/midx.c b/midx.c
index 2f3863c936a4c1c9035f90ae28b73887cf8f24b2..85e1c2cd1287b34e91d9dcccc74d330c93ff809c 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -21,6 +21,7 @@
 #include "refs.h"
 #include "revision.h"
 #include "list-objects.h"
+#include "pack-revindex.h"
 
 #define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
 #define MIDX_VERSION 1
@@ -33,6 +34,7 @@
 
 #define MIDX_CHUNK_ALIGNMENT 4
 #define MIDX_CHUNKID_PACKNAMES 0x504e414d /* "PNAM" */
+#define MIDX_CHUNKID_BITMAPPEDPACKS 0x42544d50 /* "BTMP" */
 #define MIDX_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */
 #define MIDX_CHUNKID_OIDLOOKUP 0x4f49444c /* "OIDL" */
 #define MIDX_CHUNKID_OBJECTOFFSETS 0x4f4f4646 /* "OOFF" */
@@ -41,6 +43,7 @@
 #define MIDX_CHUNK_FANOUT_SIZE (sizeof(uint32_t) * 256)
 #define MIDX_CHUNK_OFFSET_WIDTH (2 * sizeof(uint32_t))
 #define MIDX_CHUNK_LARGE_OFFSET_WIDTH (sizeof(uint64_t))
+#define MIDX_CHUNK_BITMAPPED_PACKS_WIDTH (2 * sizeof(uint32_t))
 #define MIDX_LARGE_OFFSET_NEEDED 0x80000000
 
 #define PACK_EXPIRED UINT_MAX
@@ -64,6 +67,7 @@ void get_midx_rev_filename(struct strbuf *out, struct multi_pack_index *m)
 static int midx_read_oid_fanout(const unsigned char *chunk_start,
                                size_t chunk_size, void *data)
 {
+       int i;
        struct multi_pack_index *m = data;
        m->chunk_oid_fanout = (uint32_t *)chunk_start;
 
@@ -71,6 +75,16 @@ static int midx_read_oid_fanout(const unsigned char *chunk_start,
                error(_("multi-pack-index OID fanout is of the wrong size"));
                return 1;
        }
+       for (i = 0; i < 255; i++) {
+               uint32_t oid_fanout1 = ntohl(m->chunk_oid_fanout[i]);
+               uint32_t oid_fanout2 = ntohl(m->chunk_oid_fanout[i+1]);
+
+               if (oid_fanout1 > oid_fanout2) {
+                       error(_("oid fanout out of order: fanout[%d] = %"PRIx32" > %"PRIx32" = fanout[%d]"),
+                             i, oid_fanout1, oid_fanout2, i + 1);
+                       return 1;
+               }
+       }
        m->num_objects = ntohl(m->chunk_oid_fanout[255]);
        return 0;
 }
@@ -164,6 +178,8 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
 
        m->num_packs = get_be32(m->data + MIDX_BYTE_NUM_PACKS);
 
+       m->preferred_pack_idx = -1;
+
        cf = init_chunkfile(NULL);
 
        if (read_table_of_contents(cf, m->data, midx_size,
@@ -182,6 +198,9 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
 
        pair_chunk(cf, MIDX_CHUNKID_LARGEOFFSETS, &m->chunk_large_offsets,
                   &m->chunk_large_offsets_len);
+       pair_chunk(cf, MIDX_CHUNKID_BITMAPPEDPACKS,
+                  (const unsigned char **)&m->chunk_bitmapped_packs,
+                  &m->chunk_bitmapped_packs_len);
 
        if (git_env_bool("GIT_TEST_MIDX_READ_RIDX", 1))
                pair_chunk(cf, MIDX_CHUNKID_REVINDEX, &m->chunk_revindex,
@@ -275,6 +294,26 @@ int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t
        return 0;
 }
 
+int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
+                      struct bitmapped_pack *bp, uint32_t pack_int_id)
+{
+       if (!m->chunk_bitmapped_packs)
+               return error(_("MIDX does not contain the BTMP chunk"));
+
+       if (prepare_midx_pack(r, m, pack_int_id))
+               return error(_("could not load bitmapped pack %"PRIu32), pack_int_id);
+
+       bp->p = m->packs[pack_int_id];
+       bp->bitmap_pos = get_be32((char *)m->chunk_bitmapped_packs +
+                                 MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * pack_int_id);
+       bp->bitmap_nr = get_be32((char *)m->chunk_bitmapped_packs +
+                                MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * pack_int_id +
+                                sizeof(uint32_t));
+       bp->pack_int_id = pack_int_id;
+
+       return 0;
+}
+
 int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result)
 {
        return bsearch_hash(oid->hash, m->chunk_oid_fanout, m->chunk_oid_lookup,
@@ -392,7 +431,8 @@ static int cmp_idx_or_pack_name(const char *idx_or_pack_name,
        return strcmp(idx_or_pack_name, idx_name);
 }
 
-int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
+int midx_locate_pack(struct multi_pack_index *m, const char *idx_or_pack_name,
+                    uint32_t *pos)
 {
        uint32_t first = 0, last = m->num_packs;
 
@@ -403,8 +443,11 @@ int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
 
                current = m->pack_names[mid];
                cmp = cmp_idx_or_pack_name(idx_or_pack_name, current);
-               if (!cmp)
+               if (!cmp) {
+                       if (pos)
+                               *pos = mid;
                        return 1;
+               }
                if (cmp > 0) {
                        first = mid + 1;
                        continue;
@@ -415,6 +458,28 @@ int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
        return 0;
 }
 
+int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
+{
+       return midx_locate_pack(m, idx_or_pack_name, NULL);
+}
+
+int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id)
+{
+       if (m->preferred_pack_idx == -1) {
+               if (load_midx_revindex(m) < 0) {
+                       m->preferred_pack_idx = -2;
+                       return -1;
+               }
+
+               m->preferred_pack_idx =
+                       nth_midxed_pack_int_id(m, pack_pos_to_midx(m, 0));
+       } else if (m->preferred_pack_idx == -2)
+               return -1; /* no revindex */
+
+       *pack_int_id = m->preferred_pack_idx;
+       return 0;
+}
+
 int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local)
 {
        struct multi_pack_index *m;
@@ -457,13 +522,31 @@ static size_t write_midx_header(struct hashfile *f,
        return MIDX_HEADER_SIZE;
 }
 
+#define BITMAP_POS_UNKNOWN (~((uint32_t)0))
+
 struct pack_info {
        uint32_t orig_pack_int_id;
        char *pack_name;
        struct packed_git *p;
+
+       uint32_t bitmap_pos;
+       uint32_t bitmap_nr;
+
        unsigned expired : 1;
 };
 
+static void fill_pack_info(struct pack_info *info,
+                          struct packed_git *p, const char *pack_name,
+                          uint32_t orig_pack_int_id)
+{
+       memset(info, 0, sizeof(struct pack_info));
+
+       info->orig_pack_int_id = orig_pack_int_id;
+       info->pack_name = xstrdup(pack_name);
+       info->p = p;
+       info->bitmap_pos = BITMAP_POS_UNKNOWN;
+}
+
 static int pack_info_compare(const void *_a, const void *_b)
 {
        struct pack_info *a = (struct pack_info *)_a;
@@ -504,6 +587,7 @@ static void add_pack_to_midx(const char *full_path, size_t full_path_len,
                             const char *file_name, void *data)
 {
        struct write_midx_context *ctx = data;
+       struct packed_git *p;
 
        if (ends_with(file_name, ".idx")) {
                display_progress(ctx->progress, ++ctx->pack_paths_checked);
@@ -530,27 +614,22 @@ static void add_pack_to_midx(const char *full_path, size_t full_path_len,
 
                ALLOC_GROW(ctx->info, ctx->nr + 1, ctx->alloc);
 
-               ctx->info[ctx->nr].p = add_packed_git(full_path,
-                                                     full_path_len,
-                                                     0);
-
-               if (!ctx->info[ctx->nr].p) {
+               p = add_packed_git(full_path, full_path_len, 0);
+               if (!p) {
                        warning(_("failed to add packfile '%s'"),
                                full_path);
                        return;
                }
 
-               if (open_pack_index(ctx->info[ctx->nr].p)) {
+               if (open_pack_index(p)) {
                        warning(_("failed to open pack-index '%s'"),
                                full_path);
-                       close_pack(ctx->info[ctx->nr].p);
-                       FREE_AND_NULL(ctx->info[ctx->nr].p);
+                       close_pack(p);
+                       free(p);
                        return;
                }
 
-               ctx->info[ctx->nr].pack_name = xstrdup(file_name);
-               ctx->info[ctx->nr].orig_pack_int_id = ctx->nr;
-               ctx->info[ctx->nr].expired = 0;
+               fill_pack_info(&ctx->info[ctx->nr], p, file_name, ctx->nr);
                ctx->nr++;
        }
 }
@@ -806,6 +885,26 @@ static int write_midx_pack_names(struct hashfile *f, void *data)
        return 0;
 }
 
+static int write_midx_bitmapped_packs(struct hashfile *f, void *data)
+{
+       struct write_midx_context *ctx = data;
+       size_t i;
+
+       for (i = 0; i < ctx->nr; i++) {
+               struct pack_info *pack = &ctx->info[i];
+               if (pack->expired)
+                       continue;
+
+               if (pack->bitmap_pos == BITMAP_POS_UNKNOWN && pack->bitmap_nr)
+                       BUG("pack '%s' has no bitmap position, but has %d bitmapped object(s)",
+                           pack->pack_name, pack->bitmap_nr);
+
+               hashwrite_be32(f, pack->bitmap_pos);
+               hashwrite_be32(f, pack->bitmap_nr);
+       }
+       return 0;
+}
+
 static int write_midx_oid_fanout(struct hashfile *f,
                                 void *data)
 {
@@ -973,8 +1072,19 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
        QSORT(data, ctx->entries_nr, midx_pack_order_cmp);
 
        ALLOC_ARRAY(pack_order, ctx->entries_nr);
-       for (i = 0; i < ctx->entries_nr; i++)
+       for (i = 0; i < ctx->entries_nr; i++) {
+               struct pack_midx_entry *e = &ctx->entries[data[i].nr];
+               struct pack_info *pack = &ctx->info[ctx->pack_perm[e->pack_int_id]];
+               if (pack->bitmap_pos == BITMAP_POS_UNKNOWN)
+                       pack->bitmap_pos = i;
+               pack->bitmap_nr++;
                pack_order[i] = data[i].nr;
+       }
+       for (i = 0; i < ctx->nr; i++) {
+               struct pack_info *pack = &ctx->info[ctx->pack_perm[i]];
+               if (pack->bitmap_pos == BITMAP_POS_UNKNOWN)
+                       pack->bitmap_pos = 0;
+       }
        free(data);
 
        trace2_region_leave("midx", "midx_pack_order", the_repository);
@@ -1275,6 +1385,7 @@ static int write_midx_internal(const char *object_dir,
        struct hashfile *f = NULL;
        struct lock_file lk;
        struct write_midx_context ctx = { 0 };
+       int bitmapped_packs_concat_len = 0;
        int pack_name_concat_len = 0;
        int dropped_packs = 0;
        int result = 0;
@@ -1310,11 +1421,6 @@ static int write_midx_internal(const char *object_dir,
                for (i = 0; i < ctx.m->num_packs; i++) {
                        ALLOC_GROW(ctx.info, ctx.nr + 1, ctx.alloc);
 
-                       ctx.info[ctx.nr].orig_pack_int_id = i;
-                       ctx.info[ctx.nr].pack_name = xstrdup(ctx.m->pack_names[i]);
-                       ctx.info[ctx.nr].p = ctx.m->packs[i];
-                       ctx.info[ctx.nr].expired = 0;
-
                        if (flags & MIDX_WRITE_REV_INDEX) {
                                /*
                                 * If generating a reverse index, need to have
@@ -1330,10 +1436,10 @@ static int write_midx_internal(const char *object_dir,
                                if (open_pack_index(ctx.m->packs[i]))
                                        die(_("could not open index for %s"),
                                            ctx.m->packs[i]->pack_name);
-                               ctx.info[ctx.nr].p = ctx.m->packs[i];
                        }
 
-                       ctx.nr++;
+                       fill_pack_info(&ctx.info[ctx.nr++], ctx.m->packs[i],
+                                      ctx.m->pack_names[i], i);
                }
        }
 
@@ -1492,8 +1598,10 @@ static int write_midx_internal(const char *object_dir,
        }
 
        for (i = 0; i < ctx.nr; i++) {
-               if (!ctx.info[i].expired)
-                       pack_name_concat_len += strlen(ctx.info[i].pack_name) + 1;
+               if (ctx.info[i].expired)
+                       continue;
+               pack_name_concat_len += strlen(ctx.info[i].pack_name) + 1;
+               bitmapped_packs_concat_len += 2 * sizeof(uint32_t);
        }
 
        /* Check that the preferred pack wasn't expired (if given). */
@@ -1553,6 +1661,9 @@ static int write_midx_internal(const char *object_dir,
                add_chunk(cf, MIDX_CHUNKID_REVINDEX,
                          st_mult(ctx.entries_nr, sizeof(uint32_t)),
                          write_midx_revindex);
+               add_chunk(cf, MIDX_CHUNKID_BITMAPPEDPACKS,
+                         bitmapped_packs_concat_len,
+                         write_midx_bitmapped_packs);
        }
 
        write_midx_header(f, get_num_chunks(cf), ctx.nr - dropped_packs);
@@ -1592,8 +1703,13 @@ static int write_midx_internal(const char *object_dir,
                                      flags) < 0) {
                        error(_("could not write multi-pack bitmap"));
                        result = 1;
+                       clear_packing_data(&pdata);
+                       free(commits);
                        goto cleanup;
                }
+
+               clear_packing_data(&pdata);
+               free(commits);
        }
        /*
         * NOTE: Do not use ctx.entries beyond this point, since it might
@@ -1782,15 +1898,6 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
        }
        stop_progress(&progress);
 
-       for (i = 0; i < 255; i++) {
-               uint32_t oid_fanout1 = ntohl(m->chunk_oid_fanout[i]);
-               uint32_t oid_fanout2 = ntohl(m->chunk_oid_fanout[i + 1]);
-
-               if (oid_fanout1 > oid_fanout2)
-                       midx_report(_("oid fanout out of order: fanout[%d] = %"PRIx32" > %"PRIx32" = fanout[%d]"),
-                                   i, oid_fanout1, oid_fanout2, i + 1);
-       }
-
        if (m->num_objects == 0) {
                midx_report(_("the midx contains no oid"));
                /*
diff --git a/midx.h b/midx.h
index eb57a37519ce018fdd7aa9ba0d9d6c11003d5452..b374a7afafb867a9ef9f0fd9913ec2552914859c 100644 (file)
--- a/midx.h
+++ b/midx.h
@@ -6,6 +6,7 @@
 struct object_id;
 struct pack_entry;
 struct repository;
+struct bitmapped_pack;
 
 #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
 #define GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP \
@@ -27,11 +28,14 @@ struct multi_pack_index {
        unsigned char num_chunks;
        uint32_t num_packs;
        uint32_t num_objects;
+       int preferred_pack_idx;
 
        int local;
 
        const unsigned char *chunk_pack_names;
        size_t chunk_pack_names_len;
+       const uint32_t *chunk_bitmapped_packs;
+       size_t chunk_bitmapped_packs_len;
        const uint32_t *chunk_oid_fanout;
        const unsigned char *chunk_oid_lookup;
        const unsigned char *chunk_object_offsets;
@@ -57,6 +61,8 @@ void get_midx_rev_filename(struct strbuf *out, struct multi_pack_index *m);
 
 struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
 int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
+int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
+                      struct bitmapped_pack *bp, uint32_t pack_int_id);
 int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result);
 off_t nth_midxed_offset(struct multi_pack_index *m, uint32_t pos);
 uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos);
@@ -64,7 +70,11 @@ struct object_id *nth_midxed_object_oid(struct object_id *oid,
                                        struct multi_pack_index *m,
                                        uint32_t n);
 int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
-int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name);
+int midx_contains_pack(struct multi_pack_index *m,
+                      const char *idx_or_pack_name);
+int midx_locate_pack(struct multi_pack_index *m, const char *idx_or_pack_name,
+                    uint32_t *pos);
+int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id);
 int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);
 
 /*
index 3a2ef5d6800173fa669bdfcb2612bf21a7c6417a..511f09bc0fea75301433fe888efbe10d5227fdc0 100644 (file)
@@ -1034,6 +1034,15 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
                                                len, str,
                                                show_date(co_time, co_tz, DATE_MODE(RFC2822)));
                                }
+                       } else if (nth == co_cnt && !is_null_oid(oid)) {
+                               /*
+                                * We were asked for the Nth reflog (counting
+                                * from 0), but there were only N entries.
+                                * read_ref_at() will have returned "1" to tell
+                                * us it did not find an entry, but it did
+                                * still fill in the oid with the "old" value,
+                                * which we can use.
+                                */
                        } else {
                                if (flags & GET_OID_QUIETLY) {
                                        exit(128);
index 2c61e4c86217e633d2e28acd0b3ae654584ede7d..e6a1c4d9059ab398f06f042a7b7cdd953ff6a943 100644 (file)
--- a/object.c
+++ b/object.c
@@ -47,8 +47,7 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
                len = strlen(str);
 
        for (i = 1; i < ARRAY_SIZE(object_type_strings); i++)
-               if (!strncmp(str, object_type_strings[i], len) &&
-                   object_type_strings[i][len] == '\0')
+               if (!xstrncmpz(object_type_strings[i], str, len))
                        return i;
 
        if (gentle)
index d1e5376316ecd5f9dcf549e1067697283bdc712c..91d13859106a1bc56632aeedd4030a007608a359 100644 (file)
--- a/oidset.c
+++ b/oidset.c
@@ -23,6 +23,16 @@ int oidset_insert(struct oidset *set, const struct object_id *oid)
        return !added;
 }
 
+void oidset_insert_from_set(struct oidset *dest, struct oidset *src)
+{
+       struct oidset_iter iter;
+       struct object_id *src_oid;
+
+       oidset_iter_init(src, &iter);
+       while ((src_oid = oidset_iter_next(&iter)))
+               oidset_insert(dest, src_oid);
+}
+
 int oidset_remove(struct oidset *set, const struct object_id *oid)
 {
        khiter_t pos = kh_get_oid_set(&set->set, *oid);
index ba4a5a2cd3a7a233bc9ca2cb7cf4a58a1e5a122c..262f4256d6ac5ad39e1cef4a39e36716e817d651 100644 (file)
--- a/oidset.h
+++ b/oidset.h
@@ -47,6 +47,12 @@ int oidset_contains(const struct oidset *set, const struct object_id *oid);
  */
 int oidset_insert(struct oidset *set, const struct object_id *oid);
 
+/**
+ * Insert all the oids that are in set 'src' into set 'dest'; a copy
+ * is made of each oid inserted into set 'dest'.
+ */
+void oidset_insert_from_set(struct oidset *dest, struct oidset *src);
+
 /**
  * Remove the oid from the set.
  *
index 9acb74412ef0fc28589262b392c9d56c7d381137..5b954088254b21a6cbc90b41d0dac415a552d6b7 100644 (file)
@@ -1,3 +1,4 @@
 fuzz-commit-graph
+fuzz-date
 fuzz-pack-headers
 fuzz-pack-idx
diff --git a/oss-fuzz/dummy-cmd-main.c b/oss-fuzz/dummy-cmd-main.c
new file mode 100644 (file)
index 0000000..071cb23
--- /dev/null
@@ -0,0 +1,14 @@
+#include "git-compat-util.h"
+
+/*
+ * When linking the fuzzers, we link against common-main.o to pick up some
+ * symbols. However, even though we ignore common-main:main(), we still need to
+ * provide all the symbols it references. In the fuzzers' case, we need to
+ * provide a dummy cmd_main() for the linker to be happy. It will never be
+ * executed.
+ */
+
+int cmd_main(int argc, const char **argv) {
+       BUG("We should not execute cmd_main() from a fuzz target");
+       return 1;
+}
diff --git a/oss-fuzz/fuzz-date.c b/oss-fuzz/fuzz-date.c
new file mode 100644 (file)
index 0000000..036378b
--- /dev/null
@@ -0,0 +1,49 @@
+#include "git-compat-util.h"
+#include "date.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+       int local;
+       int num;
+       char *str;
+       int16_t tz;
+       timestamp_t ts;
+       enum date_mode_type dmtype;
+       struct date_mode *dm;
+
+       if (size <= 4)
+               /*
+                * we use the first byte to fuzz dmtype and the
+                * second byte to fuzz local, then the next two
+                * bytes to fuzz tz offset. The remainder
+                * (at least one byte) is fed as input to
+                * approxidate_careful().
+                */
+               return 0;
+
+       local = !!(*data++ & 0x10);
+       num = *data++ % DATE_UNIX;
+       if (num >= DATE_STRFTIME)
+               num++;
+       dmtype = (enum date_mode_type)num;
+       size -= 2;
+
+       tz = *data++;
+       tz = (tz << 8) | *data++;
+       size -= 2;
+
+       str = xmemdupz(data, size);
+
+       ts = approxidate_careful(str, &num);
+       free(str);
+
+       dm = date_mode_from_type(dmtype);
+       dm->local = local;
+       show_date(ts, (int)tz, dm);
+
+       date_mode_release(dm);
+
+       return 0;
+}
index be4733e3bdcff59c135569d696b72e1451e53898..990a9498d731942bf2b01580a8ac77d08ba04d5f 100644 (file)
@@ -195,6 +195,13 @@ struct bb_commit {
        unsigned idx; /* within selected array */
 };
 
+static void clear_bb_commit(struct bb_commit *commit)
+{
+       free_commit_list(commit->reverse_edges);
+       bitmap_free(commit->commit_mask);
+       bitmap_free(commit->bitmap);
+}
+
 define_commit_slab(bb_data, struct bb_commit);
 
 struct bitmap_builder {
@@ -336,7 +343,7 @@ next:
 
 static void bitmap_builder_clear(struct bitmap_builder *bb)
 {
-       clear_bb_data(&bb->data);
+       deep_clear_bb_data(&bb->data, clear_bb_commit);
        free(bb->commits);
        bb->commits_nr = bb->commits_alloc = 0;
 }
index c88dd35bdc57f7cb2dcda13f14849b4c15e159c2..2baeabacee13d4ec5311261499fe10d8f0a882e5 100644 (file)
@@ -331,7 +331,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
        struct stat st;
        char *bitmap_name = midx_bitmap_filename(midx);
        int fd = git_open(bitmap_name);
-       uint32_t i;
+       uint32_t i, preferred_pack;
        struct packed_git *preferred;
 
        if (fd < 0) {
@@ -386,7 +386,12 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
                }
        }
 
-       preferred = bitmap_git->midx->packs[midx_preferred_pack(bitmap_git)];
+       if (midx_preferred_pack(bitmap_git->midx, &preferred_pack) < 0) {
+               warning(_("could not determine MIDX preferred pack"));
+               goto cleanup;
+       }
+
+       preferred = bitmap_git->midx->packs[preferred_pack];
        if (!is_pack_valid(preferred)) {
                warning(_("preferred pack (%s) is invalid"),
                        preferred->pack_name);
@@ -1273,6 +1278,8 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
                base = fill_in_bitmap(bitmap_git, revs, base, seen);
        }
 
+       object_list_free(&not_mapped);
+
        return base;
 }
 
@@ -1827,8 +1834,10 @@ cleanup:
  * -1 means "stop trying further objects"; 0 means we may or may not have
  * reused, but you can keep feeding bits.
  */
-static int try_partial_reuse(struct packed_git *pack,
-                            size_t pos,
+static int try_partial_reuse(struct bitmap_index *bitmap_git,
+                            struct bitmapped_pack *pack,
+                            size_t bitmap_pos,
+                            uint32_t pack_pos,
                             struct bitmap *reuse,
                             struct pack_window **w_curs)
 {
@@ -1836,40 +1845,18 @@ static int try_partial_reuse(struct packed_git *pack,
        enum object_type type;
        unsigned long size;
 
-       /*
-        * try_partial_reuse() is called either on (a) objects in the
-        * bitmapped pack (in the case of a single-pack bitmap) or (b)
-        * objects in the preferred pack of a multi-pack bitmap.
-        * Importantly, the latter can pretend as if only a single pack
-        * exists because:
-        *
-        *   - The first pack->num_objects bits of a MIDX bitmap are
-        *     reserved for the preferred pack, and
-        *
-        *   - Ties due to duplicate objects are always resolved in
-        *     favor of the preferred pack.
-        *
-        * Therefore we do not need to ever ask the MIDX for its copy of
-        * an object by OID, since it will always select it from the
-        * preferred pack. Likewise, the selected copy of the base
-        * object for any deltas will reside in the same pack.
-        *
-        * This means that we can reuse pos when looking up the bit in
-        * the reuse bitmap, too, since bits corresponding to the
-        * preferred pack precede all bits from other packs.
-        */
-
-       if (pos >= pack->num_objects)
-               return -1; /* not actually in the pack or MIDX preferred pack */
+       if (pack_pos >= pack->p->num_objects)
+               return -1; /* not actually in the pack */
 
-       offset = delta_obj_offset = pack_pos_to_offset(packpos);
-       type = unpack_object_header(pack, w_curs, &offset, &size);
+       offset = delta_obj_offset = pack_pos_to_offset(pack->p, pack_pos);
+       type = unpack_object_header(pack->p, w_curs, &offset, &size);
        if (type < 0)
                return -1; /* broken packfile, punt */
 
        if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA) {
                off_t base_offset;
                uint32_t base_pos;
+               uint32_t base_bitmap_pos;
 
                /*
                 * Find the position of the base object so we can look it up
@@ -1879,24 +1866,48 @@ static int try_partial_reuse(struct packed_git *pack,
                 * and the normal slow path will complain about it in
                 * more detail.
                 */
-               base_offset = get_delta_base(pack, w_curs, &offset, type,
+               base_offset = get_delta_base(pack->p, w_curs, &offset, type,
                                             delta_obj_offset);
                if (!base_offset)
                        return 0;
-               if (offset_to_pack_pos(pack, base_offset, &base_pos) < 0)
-                       return 0;
 
-               /*
-                * We assume delta dependencies always point backwards. This
-                * lets us do a single pass, and is basically always true
-                * due to the way OFS_DELTAs work. You would not typically
-                * find REF_DELTA in a bitmapped pack, since we only bitmap
-                * packs we write fresh, and OFS_DELTA is the default). But
-                * let's double check to make sure the pack wasn't written with
-                * odd parameters.
-                */
-               if (base_pos >= pos)
-                       return 0;
+               offset_to_pack_pos(pack->p, base_offset, &base_pos);
+
+               if (bitmap_is_midx(bitmap_git)) {
+                       /*
+                        * Cross-pack deltas are rejected for now, but could
+                        * theoretically be supported in the future.
+                        *
+                        * We would need to ensure that we're sending both
+                        * halves of the delta/base pair, regardless of whether
+                        * or not the two cross a pack boundary. If they do,
+                        * then we must convert the delta to an REF_DELTA to
+                        * refer back to the base in the other pack.
+                        * */
+                       if (midx_pair_to_pack_pos(bitmap_git->midx,
+                                                 pack->pack_int_id,
+                                                 base_offset,
+                                                 &base_bitmap_pos) < 0) {
+                               return 0;
+                       }
+               } else {
+                       if (offset_to_pack_pos(pack->p, base_offset,
+                                              &base_pos) < 0)
+                               return 0;
+                       /*
+                        * We assume delta dependencies always point backwards.
+                        * This lets us do a single pass, and is basically
+                        * always true due to the way OFS_DELTAs work. You would
+                        * not typically find REF_DELTA in a bitmapped pack,
+                        * since we only bitmap packs we write fresh, and
+                        * OFS_DELTA is the default). But let's double check to
+                        * make sure the pack wasn't written with odd
+                        * parameters.
+                        */
+                       if (base_pos >= pack_pos)
+                               return 0;
+                       base_bitmap_pos = pack->bitmap_pos + base_pos;
+               }
 
                /*
                 * And finally, if we're not sending the base as part of our
@@ -1906,77 +1917,89 @@ static int try_partial_reuse(struct packed_git *pack,
                 * to REF_DELTA on the fly. Better to just let the normal
                 * object_entry code path handle it.
                 */
-               if (!bitmap_get(reuse, base_pos))
+               if (!bitmap_get(reuse, base_bitmap_pos))
                        return 0;
        }
 
        /*
         * If we got here, then the object is OK to reuse. Mark it.
         */
-       bitmap_set(reuse, pos);
+       bitmap_set(reuse, bitmap_pos);
        return 0;
 }
 
-uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git)
+static void reuse_partial_packfile_from_bitmap_1(struct bitmap_index *bitmap_git,
+                                                struct bitmapped_pack *pack,
+                                                struct bitmap *reuse)
 {
-       struct multi_pack_index *m = bitmap_git->midx;
-       if (!m)
-               BUG("midx_preferred_pack: requires non-empty MIDX");
-       return nth_midxed_pack_int_id(m, pack_pos_to_midx(bitmap_git->midx, 0));
-}
-
-int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
-                                      struct packed_git **packfile_out,
-                                      uint32_t *entries,
-                                      struct bitmap **reuse_out)
-{
-       struct repository *r = the_repository;
-       struct packed_git *pack;
        struct bitmap *result = bitmap_git->result;
-       struct bitmap *reuse;
        struct pack_window *w_curs = NULL;
-       size_t i = 0;
-       uint32_t offset;
-       uint32_t objects_nr;
+       size_t pos = pack->bitmap_pos / BITS_IN_EWORD;
 
-       assert(result);
+       if (!pack->bitmap_pos) {
+               /*
+                * If we're processing the first (in the case of a MIDX, the
+                * preferred pack) or the only (in the case of single-pack
+                * bitmaps) pack, then we can reuse whole words at a time.
+                *
+                * This is because we know that any deltas in this range *must*
+                * have their bases chosen from the same pack, since:
+                *
+                * - In the single pack case, there is no other pack to choose
+                *   them from.
+                *
+                * - In the MIDX case, the first pack is the preferred pack, so
+                *   all ties are broken in favor of that pack (i.e. the one
+                *   we're currently processing). So any duplicate bases will be
+                *   resolved in favor of the pack we're processing.
+                */
+               while (pos < result->word_alloc &&
+                      pos < pack->bitmap_nr / BITS_IN_EWORD &&
+                      result->words[pos] == (eword_t)~0)
+                       pos++;
+               memset(reuse->words, 0xFF, pos * sizeof(eword_t));
+       }
 
-       load_reverse_index(r, bitmap_git);
+       for (; pos < result->word_alloc; pos++) {
+               eword_t word = result->words[pos];
+               size_t offset;
 
-       if (bitmap_is_midx(bitmap_git))
-               pack = bitmap_git->midx->packs[midx_preferred_pack(bitmap_git)];
-       else
-               pack = bitmap_git->pack;
-       objects_nr = pack->num_objects;
+               for (offset = 0; offset < BITS_IN_EWORD; offset++) {
+                       size_t bit_pos;
+                       uint32_t pack_pos;
 
-       while (i < result->word_alloc && result->words[i] == (eword_t)~0)
-               i++;
+                       if (word >> offset == 0)
+                               break;
 
-       /*
-        * Don't mark objects not in the packfile or preferred pack. This bitmap
-        * marks objects eligible for reuse, but the pack-reuse code only
-        * understands how to reuse a single pack. Since the preferred pack is
-        * guaranteed to have all bases for its deltas (in a multi-pack bitmap),
-        * we use it instead of another pack. In single-pack bitmaps, the choice
-        * is made for us.
-        */
-       if (i > objects_nr / BITS_IN_EWORD)
-               i = objects_nr / BITS_IN_EWORD;
+                       offset += ewah_bit_ctz64(word >> offset);
 
-       reuse = bitmap_word_alloc(i);
-       memset(reuse->words, 0xFF, i * sizeof(eword_t));
+                       bit_pos = pos * BITS_IN_EWORD + offset;
+                       if (bit_pos < pack->bitmap_pos)
+                               continue;
+                       if (bit_pos >= pack->bitmap_pos + pack->bitmap_nr)
+                               goto done;
 
-       for (; i < result->word_alloc; ++i) {
-               eword_t word = result->words[i];
-               size_t pos = (i * BITS_IN_EWORD);
+                       if (bitmap_is_midx(bitmap_git)) {
+                               uint32_t midx_pos;
+                               off_t ofs;
 
-               for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
-                       if ((word >> offset) == 0)
-                               break;
+                               midx_pos = pack_pos_to_midx(bitmap_git->midx, bit_pos);
+                               ofs = nth_midxed_offset(bitmap_git->midx, midx_pos);
 
-                       offset += ewah_bit_ctz64(word >> offset);
-                       if (try_partial_reuse(pack, pos + offset,
-                                             reuse, &w_curs) < 0) {
+                               if (offset_to_pack_pos(pack->p, ofs, &pack_pos) < 0)
+                                       BUG("could not find object in pack %s "
+                                           "at offset %"PRIuMAX" in MIDX",
+                                           pack_basename(pack->p), (uintmax_t)ofs);
+                       } else {
+                               pack_pos = cast_size_t_to_uint32_t(st_sub(bit_pos, pack->bitmap_pos));
+                               if (pack_pos >= pack->p->num_objects)
+                                       BUG("advanced beyond the end of pack %s (%"PRIuMAX" > %"PRIu32")",
+                                           pack_basename(pack->p), (uintmax_t)pack_pos,
+                                           pack->p->num_objects);
+                       }
+
+                       if (try_partial_reuse(bitmap_git, pack, bit_pos,
+                                             pack_pos, reuse, &w_curs) < 0) {
                                /*
                                 * try_partial_reuse indicated we couldn't reuse
                                 * any bits, so there is no point in trying more
@@ -1993,11 +2016,97 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
 
 done:
        unuse_pack(&w_curs);
+}
 
-       *entries = bitmap_popcount(reuse);
-       if (!*entries) {
-               bitmap_free(reuse);
+static int bitmapped_pack_cmp(const void *va, const void *vb)
+{
+       const struct bitmapped_pack *a = va;
+       const struct bitmapped_pack *b = vb;
+
+       if (a->bitmap_pos < b->bitmap_pos)
                return -1;
+       if (a->bitmap_pos > b->bitmap_pos)
+               return 1;
+       return 0;
+}
+
+void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
+                                       struct bitmapped_pack **packs_out,
+                                       size_t *packs_nr_out,
+                                       struct bitmap **reuse_out,
+                                       int multi_pack_reuse)
+{
+       struct repository *r = the_repository;
+       struct bitmapped_pack *packs = NULL;
+       struct bitmap *result = bitmap_git->result;
+       struct bitmap *reuse;
+       size_t i;
+       size_t packs_nr = 0, packs_alloc = 0;
+       size_t word_alloc;
+       uint32_t objects_nr = 0;
+
+       assert(result);
+
+       load_reverse_index(r, bitmap_git);
+
+       if (bitmap_is_midx(bitmap_git)) {
+               for (i = 0; i < bitmap_git->midx->num_packs; i++) {
+                       struct bitmapped_pack pack;
+                       if (nth_bitmapped_pack(r, bitmap_git->midx, &pack, i) < 0) {
+                               warning(_("unable to load pack: '%s', disabling pack-reuse"),
+                                       bitmap_git->midx->pack_names[i]);
+                               free(packs);
+                               return;
+                       }
+
+                       if (!pack.bitmap_nr)
+                               continue;
+
+                       if (!multi_pack_reuse && pack.bitmap_pos) {
+                               /*
+                                * If we're only reusing a single pack, skip
+                                * over any packs which are not positioned at
+                                * the beginning of the MIDX bitmap.
+                                *
+                                * This is consistent with the existing
+                                * single-pack reuse behavior, which only reuses
+                                * parts of the MIDX's preferred pack.
+                                */
+                               continue;
+                       }
+
+                       ALLOC_GROW(packs, packs_nr + 1, packs_alloc);
+                       memcpy(&packs[packs_nr++], &pack, sizeof(pack));
+
+                       objects_nr += pack.p->num_objects;
+
+                       if (!multi_pack_reuse)
+                               break;
+               }
+
+               QSORT(packs, packs_nr, bitmapped_pack_cmp);
+       } else {
+               ALLOC_GROW(packs, packs_nr + 1, packs_alloc);
+
+               packs[packs_nr].p = bitmap_git->pack;
+               packs[packs_nr].bitmap_nr = bitmap_git->pack->num_objects;
+               packs[packs_nr].bitmap_pos = 0;
+
+               objects_nr = packs[packs_nr++].bitmap_nr;
+       }
+
+       word_alloc = objects_nr / BITS_IN_EWORD;
+       if (objects_nr % BITS_IN_EWORD)
+               word_alloc++;
+       reuse = bitmap_word_alloc(word_alloc);
+
+       for (i = 0; i < packs_nr; i++)
+               reuse_partial_packfile_from_bitmap_1(bitmap_git, &packs[i], reuse);
+
+       if (bitmap_is_empty(reuse)) {
+               free(packs);
+               bitmap_free(reuse);
+               return;
        }
 
        /*
@@ -2005,9 +2114,9 @@ done:
         * need to be handled separately.
         */
        bitmap_and_not(result, reuse);
-       *packfile_out = pack;
+       *packs_out = packs;
+       *packs_nr_out = packs_nr;
        *reuse_out = reuse;
-       return 0;
 }
 
 int bitmap_walk_contains(struct bitmap_index *bitmap_git,
index 5273a6a019708c8295be8e4fa5ca11db342f3a40..c7dea13217a00ef544d16a45d0f78de8f0e8ebc0 100644 (file)
@@ -52,6 +52,15 @@ typedef int (*show_reachable_fn)(
 
 struct bitmap_index;
 
+struct bitmapped_pack {
+       struct packed_git *p;
+
+       uint32_t bitmap_pos;
+       uint32_t bitmap_nr;
+
+       uint32_t pack_int_id; /* MIDX only */
+};
+
 struct bitmap_index *prepare_bitmap_git(struct repository *r);
 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
@@ -68,11 +77,11 @@ int test_bitmap_hashes(struct repository *r);
 
 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
                                         int filter_provided_objects);
-uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git);
-int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
-                                      struct packed_git **packfile,
-                                      uint32_t *entries,
-                                      struct bitmap **reuse_out);
+void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
+                                       struct bitmapped_pack **packs_out,
+                                       size_t *packs_nr_out,
+                                       struct bitmap **reuse_out,
+                                       int multi_pack_reuse);
 int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
                             kh_oid_map_t *reused_bitmaps, int show_progress);
 void free_bitmap_index(struct bitmap_index *);
index f403ca6986a9d4c68715c1e1b24462d462fb8aa9..a9d9855063aea85f4b1b8f70f301c644c5d5e225 100644 (file)
@@ -151,6 +151,21 @@ void prepare_packing_data(struct repository *r, struct packing_data *pdata)
        init_recursive_mutex(&pdata->odb_lock);
 }
 
+void clear_packing_data(struct packing_data *pdata)
+{
+       if (!pdata)
+               return;
+
+       free(pdata->cruft_mtime);
+       free(pdata->in_pack);
+       free(pdata->in_pack_by_idx);
+       free(pdata->in_pack_pos);
+       free(pdata->index);
+       free(pdata->layer);
+       free(pdata->objects);
+       free(pdata->tree_depth);
+}
+
 struct object_entry *packlist_alloc(struct packing_data *pdata,
                                    const struct object_id *oid)
 {
index 0d78db40cb2f11fcbc4b3c2bbb2d23624ef3f22e..b9898a4e64b8b4d53b21ea776c16f79d9794efef 100644 (file)
@@ -169,6 +169,7 @@ struct packing_data {
 };
 
 void prepare_packing_data(struct repository *r, struct packing_data *pdata);
+void clear_packing_data(struct packing_data *pdata);
 
 /* Protect access to object database */
 static inline void packing_data_lock(struct packing_data *pdata)
index acf1dd9786cd3c2a0cb410804721488b6d1d92b4..a7624d8be8e58e0807cf0b2dc5e3bae52ac53af9 100644 (file)
@@ -520,19 +520,12 @@ static int midx_pack_order_cmp(const void *va, const void *vb)
        return 0;
 }
 
-int midx_to_pack_pos(struct multi_pack_index *m, uint32_t at, uint32_t *pos)
+static int midx_key_to_pack_pos(struct multi_pack_index *m,
+                               struct midx_pack_key *key,
+                               uint32_t *pos)
 {
-       struct midx_pack_key key;
        uint32_t *found;
 
-       if (!m->revindex_data)
-               BUG("midx_to_pack_pos: reverse index not yet loaded");
-       if (m->num_objects <= at)
-               BUG("midx_to_pack_pos: out-of-bounds object at %"PRIu32, at);
-
-       key.pack = nth_midxed_pack_int_id(m, at);
-       key.offset = nth_midxed_offset(m, at);
-       key.midx = m;
        /*
         * The preferred pack sorts first, so determine its identifier by
         * looking at the first object in pseudo-pack order.
@@ -542,14 +535,43 @@ int midx_to_pack_pos(struct multi_pack_index *m, uint32_t at, uint32_t *pos)
         * implicitly is preferred (and includes all its objects, since ties are
         * broken first by pack identifier).
         */
-       key.preferred_pack = nth_midxed_pack_int_id(m, pack_pos_to_midx(m, 0));
+       if (midx_preferred_pack(key->midx, &key->preferred_pack) < 0)
+               return error(_("could not determine preferred pack"));
 
-       found = bsearch(&key, m->revindex_data, m->num_objects,
-                       sizeof(*m->revindex_data), midx_pack_order_cmp);
+       found = bsearch(key, m->revindex_data, m->num_objects,
+                       sizeof(*m->revindex_data),
+                       midx_pack_order_cmp);
 
        if (!found)
-               return error("bad offset for revindex");
+               return -1;
 
        *pos = found - m->revindex_data;
        return 0;
 }
+
+int midx_to_pack_pos(struct multi_pack_index *m, uint32_t at, uint32_t *pos)
+{
+       struct midx_pack_key key;
+
+       if (!m->revindex_data)
+               BUG("midx_to_pack_pos: reverse index not yet loaded");
+       if (m->num_objects <= at)
+               BUG("midx_to_pack_pos: out-of-bounds object at %"PRIu32, at);
+
+       key.pack = nth_midxed_pack_int_id(m, at);
+       key.offset = nth_midxed_offset(m, at);
+       key.midx = m;
+
+       return midx_key_to_pack_pos(m, &key, pos);
+}
+
+int midx_pair_to_pack_pos(struct multi_pack_index *m, uint32_t pack_int_id,
+                         off_t ofs, uint32_t *pos)
+{
+       struct midx_pack_key key = {
+               .pack = pack_int_id,
+               .offset = ofs,
+               .midx = m,
+       };
+       return midx_key_to_pack_pos(m, &key, pos);
+}
index 6dd47efea10ec69a3438f0a804a71bf13cd91c37..422c2487ae32d8a4500f4a151ca673364fed96a0 100644 (file)
@@ -142,4 +142,7 @@ uint32_t pack_pos_to_midx(struct multi_pack_index *m, uint32_t pos);
  */
 int midx_to_pack_pos(struct multi_pack_index *midx, uint32_t at, uint32_t *pos);
 
+int midx_pair_to_pack_pos(struct multi_pack_index *midx, uint32_t pack_id,
+                         off_t ofs, uint32_t *pos);
+
 #endif
diff --git a/path.c b/path.c
index 67e2690efef897b406d46eab6202b52fc65a55d0..8bb223c92c91c2d963ab4fefa9efb0ac7c3b026c 100644 (file)
--- a/path.c
+++ b/path.c
@@ -871,7 +871,7 @@ const char *enter_repo(const char *path, int strict)
        return NULL;
 }
 
-static int calc_shared_perm(int mode)
+int calc_shared_perm(int mode)
 {
        int tweak;
 
@@ -1588,7 +1588,5 @@ REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")
 REPO_GIT_PATH_FUNC(merge_rr, "MERGE_RR")
 REPO_GIT_PATH_FUNC(merge_mode, "MERGE_MODE")
 REPO_GIT_PATH_FUNC(merge_head, "MERGE_HEAD")
-REPO_GIT_PATH_FUNC(merge_autostash, "MERGE_AUTOSTASH")
-REPO_GIT_PATH_FUNC(auto_merge, "AUTO_MERGE")
 REPO_GIT_PATH_FUNC(fetch_head, "FETCH_HEAD")
 REPO_GIT_PATH_FUNC(shallow, "shallow")
diff --git a/path.h b/path.h
index 639372edd9ee36127e3b89084f89ee59d12ff60f..e053effef20cbad3115095d54989cb9d4d91cfff 100644 (file)
--- a/path.h
+++ b/path.h
@@ -175,14 +175,13 @@ const char *git_path_merge_msg(struct repository *r);
 const char *git_path_merge_rr(struct repository *r);
 const char *git_path_merge_mode(struct repository *r);
 const char *git_path_merge_head(struct repository *r);
-const char *git_path_merge_autostash(struct repository *r);
-const char *git_path_auto_merge(struct repository *r);
 const char *git_path_fetch_head(struct repository *r);
 const char *git_path_shallow(struct repository *r);
 
 int ends_with_path_components(const char *path, const char *components);
 int validate_headref(const char *ref);
 
+int calc_shared_perm(int mode);
 int adjust_shared_perm(const char *path);
 
 char *interpolate_path(const char *path, int real_home);
index bb1efe1f3929f116a216de5cae6fa6b83227569e..2133b9fe60a87c201186dc3f1840276104903f7f 100644 (file)
@@ -109,16 +109,37 @@ static struct pathspec_magic {
        { PATHSPEC_ATTR,    '\0', "attr" },
 };
 
-static void prefix_magic(struct strbuf *sb, int prefixlen, unsigned magic)
+static void prefix_magic(struct strbuf *sb, int prefixlen,
+                        unsigned magic, const char *element)
 {
-       int i;
-       strbuf_addstr(sb, ":(");
-       for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)
-               if (magic & pathspec_magic[i].bit) {
-                       if (sb->buf[sb->len - 1] != '(')
-                               strbuf_addch(sb, ',');
-                       strbuf_addstr(sb, pathspec_magic[i].name);
+       /* No magic was found in element, just add prefix magic */
+       if (!magic) {
+               strbuf_addf(sb, ":(prefix:%d)", prefixlen);
+               return;
+       }
+
+       /*
+        * At this point, we know that parse_element_magic() was able
+        * to extract some pathspec magic from element. So we know
+        * element is correctly formatted in either shorthand or
+        * longhand form
+        */
+       if (element[1] != '(') {
+               /* Process an element in shorthand form (e.g. ":!/<match>") */
+               strbuf_addstr(sb, ":(");
+               for (int i = 0; i < ARRAY_SIZE(pathspec_magic); i++) {
+                       if ((magic & pathspec_magic[i].bit) &&
+                           pathspec_magic[i].mnemonic) {
+                               if (sb->buf[sb->len - 1] != '(')
+                                       strbuf_addch(sb, ',');
+                               strbuf_addstr(sb, pathspec_magic[i].name);
+                       }
                }
+       } else {
+               /* For the longhand form, we copy everything up to the final ')' */
+               size_t len = strchr(element, ')') - element;
+               strbuf_add(sb, element, len);
+       }
        strbuf_addf(sb, ",prefix:%d)", prefixlen);
 }
 
@@ -493,7 +514,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
                struct strbuf sb = STRBUF_INIT;
 
                /* Preserve the actual prefix length of each pattern */
-               prefix_magic(&sb, prefixlen, element_magic);
+               prefix_magic(&sb, prefixlen, element_magic, elt);
 
                strbuf_addstr(&sb, match);
                item->original = strbuf_detach(&sb, NULL);
index a3fc5b74d8afc62550681297e4aaa66881fd6f1f..6b95addef41e21943dbe0f72eb03ccb5683e68a1 100644 (file)
--- a/po/bg.po
+++ b/po/bg.po
@@ -1,7 +1,7 @@
 # Bulgarian translation of git po-file.
-# Copyright (C) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Alexander Shopov <ash@kambanaria.org>.
+# Copyright (C) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Alexander Shopov <ash@kambanaria.org>.
 # This file is distributed under the same license as the git package.
-# Alexander Shopov <ash@kambanaria.org>, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023.
+# Alexander Shopov <ash@kambanaria.org>, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024.
 # ========================
 # DICTIONARY TO MERGE IN GIT GUI
 # ------------------------
 # midx, multi-pack index - файл с индекса за множество пакети
 # overlay mode - припокриващ режим (при изтеглянe)
 # incremental file нарастващ файл
+# commit-graph граф с подавания
+# commit-graph chain верига на гра̀фа с подавания
 # split (commit-graphr) раздробен (граф с подавания)
 # clobber (a tag) презаписвам (етикет)
 # blame извеждане на авторство
 # master/main branch основен клон
 # unborn/orphan branch неродѐн клон (а не несъздаден) - клон без никакви подавания, включително и началното
 # parse анализ, анализирам
+# reinitialize repository зануляване на хранилището и инициализиране
+# replay изпълняване/прилагане наново
+# BTMP chunk откъс за побитова маска
+# OID fanout chunk откъс за разпределянето
+# OID lookup chunk  откъс за търсенето
+# autostash автоматично скатано
+# symref файл с указател (regular file that stores a string that begins with ref: refs/)
+#
+#
 #
 # ------------------------
 # „$var“ - може да не сработва за shell има gettext и eval_gettext - проверка - намират се лесно по „$
 # for i in `sort -u FILES`; do cnt=`grep $i FILES | wc -l`; echo $cnt $i ;done | sort -n
 msgid ""
 msgstr ""
-"Project-Id-Version: git 2.43\n"
+"Project-Id-Version: git 2.44\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-17 15:49+0100\n"
-"PO-Revision-Date: 2023-11-18 13:23+0100\n"
+"POT-Creation-Date: 2024-02-16 09:33+0100\n"
+"PO-Revision-Date: 2024-02-16 09:38+0100\n"
 "Last-Translator: Alexander Shopov <ash@kambanaria.org>\n"
 "Language-Team: Bulgarian <dict@fsa-bg.org>\n"
 "Language: bg\n"
@@ -1690,6 +1701,10 @@ msgstr "опцията „%s“ изисква „%s“"
 msgid "Unexpected option --output"
 msgstr "Неочаквана опция „--output“"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "излишна опция или стойност на командния ред: „%s“"
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Непознат формат на архив: „%s“"
@@ -1737,6 +1752,14 @@ msgstr ""
 "неправилна стойност за опцията „--attr-source“ или променливата "
 "„GIT_ATTR_SOURCE“"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "„stat“ не може да се изпълни върху „%s“"
+
+#, c-format
+msgid "unable to read %s"
+msgstr "обектът „%s“ не може да бъде прочетен"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "Неправилно цитирано съдържание във файла „%s“: %s"
@@ -3074,12 +3097,13 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "обектът-подаване за „%s“ не може да се открие"
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
+msgid "the branch '%s' is not fully merged"
+msgstr "клонът „%s“ не е слят напълно"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
 msgstr ""
-"клонът „%s“ не е слят напълно.  Ако сте сигурни, че искате\n"
-"да го изтриете, изпълнете:\n"
+"Ако сте сигурни, че искате да го изтриете, изпълнете:\n"
 "\n"
 "    git branch -D %s"
 
@@ -3126,7 +3150,7 @@ msgstr "подаването, сочено от указателя „HEAD“, 
 
 #, c-format
 msgid "HEAD (%s) points outside of refs/heads/"
-msgstr "„HEAD“ (%s) сочи извън директорията „refs/heads“"
+msgstr "„HEAD“ (%s) сочи извън директорията „refs/heads/“"
 
 #, c-format
 msgid "branch %s is being rebased at %s"
@@ -4138,8 +4162,8 @@ msgstr "принудително изтегляне (вашите промѐн
 msgid "new-branch"
 msgstr "НОВ_КЛОН"
 
-msgid "new unparented branch"
-msgstr "нов ÐºÐ»Ð¾Ð½ Ð±ÐµÐ· Ñ\80одиÑ\82ел"
+msgid "new unborn branch"
+msgstr "нов Ð½ÐµÑ\80одеÌ\80н ÐºÐ»Ð¾Ð½"
 
 msgid "update ignored files (default)"
 msgstr "обновяване на игнорираните файлове (стандартно)"
@@ -4392,9 +4416,6 @@ msgstr ""
 "което изисква някоя от опциите „-i“, „-n“ или „-f“.  Няма да се извърши "
 "изчистване"
 
-msgid "-x and -X cannot be used together"
-msgstr "опциите „-x“ и „-X“ са несъвместими"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [ОПЦИЯ…] [--] ХРАНИЛИЩЕ [ДИРЕКТОРИЯ]"
 
@@ -4486,6 +4507,9 @@ msgstr "СЛУЖЕБНА_ДИРЕКТОРИЯ"
 msgid "separate git dir from working tree"
 msgstr "отделна СЛУЖЕБНА_ДИРЕКТОРИЯ за git извън работното дърво"
 
+msgid "specify the reference format to use"
+msgstr "указване на форма̀та за указател"
+
 msgid "key=value"
 msgstr "КЛЮЧ=СТОЙНОСТ"
 
@@ -4613,12 +4637,9 @@ msgstr "Прекалено много аргументи."
 msgid "You must specify a repository to clone."
 msgstr "Трябва да укажете кое хранилище искате да клонирате."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"опцията „--bundle-uri“ е несъвместима с „--depth“, „--shallow-since“ и „--"
-"shallow-exclude“"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "непознат формат на съхранение: „%s“"
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4756,7 +4777,7 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir ДИРЕКТОРИЯ] [--append]\n"
 "                       [--split[=СТРАТЕГИЯ]] [--reachable|--stdin-packs|--"
@@ -7144,6 +7165,10 @@ msgstr "липсва поддръжка за нишки.  „%s“ ще се п
 msgid "unable to read tree (%s)"
 msgstr "дървото не може да бъде прочетено (%s)"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "дървото не може да бъде прочетено: %s"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "не може да се изпълни „grep“ от обект от вида %s"
@@ -7565,10 +7590,6 @@ msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr ""
 "СЪВПАДЕНИЕ НА СТОЙНОСТИТЕ ЗА СУМИТЕ ЗА SHA1: „%s“ НА ДВА РАЗЛИЧНИ ОБЕКТА!"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "обектът „%s“ не може да бъде прочетен"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "съществуващият обект в „%s“ не може да бъде прочетен"
@@ -7711,6 +7732,7 @@ msgstr "грешка при проверка с „fsck“ на пакетнит
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
@@ -8449,6 +8471,14 @@ msgstr ""
 "git merge-file [ОПЦИЯ…] [-L ИМЕ_1 [-L ОРИГИНАЛ [-L ИМЕ_2]]] ФАЙЛ_1 ОРИГ_ФАЙЛ "
 "ФАЙЛ_2"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"опцията приема следните варианти за алгоритъм за разлики: „myers“ (по "
+"Майерс), „minimal“ (минимизиране на разликите), „patience“ (пасианс) и "
+"„histogram“ (хистограмен)"
+
 msgid "send results to standard output"
 msgstr "извеждане на резултатите на стандартния изход"
 
@@ -8470,6 +8500,12 @@ msgstr "при конфликти да се ползва чуждата верс
 msgid "for conflicts, use a union version"
 msgstr "при конфликти да се ползва обединена версия"
 
+msgid "<algorithm>"
+msgstr "АЛГОРИТЪМ"
+
+msgid "choose a diff algorithm"
+msgstr "избор на АЛГОРИТЪМа за разлики"
+
 msgid "for conflicts, use this marker size"
 msgstr "при конфликти да се ползва маркер с такъв БРОЙ знаци"
 
@@ -8561,9 +8597,6 @@ msgstr "„--trivial-merge“ е несъвместима с другите оп
 msgid "unknown strategy option: -X%s"
 msgstr "непозната опция за стратегия: -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "опциите „--merge-base“ и „--stdin“ са несъвместими"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "входен ред с неправилен формат: „%s“."
@@ -8606,7 +8639,7 @@ msgstr "(псевдоним на „--stat“)"
 msgid "add (at most <n>) entries from shortlog to merge commit message"
 msgstr ""
 "добавяне (на максимум такъв БРОЙ) записи от съкратения журнал в съобщението "
-"за подаване"
+"за подаване със сливане"
 
 msgid "create a single commit instead of doing a merge"
 msgstr "създаване на едно подаване вместо извършване на сливане"
@@ -9522,6 +9555,11 @@ msgstr "Компресиране на обектите"
 msgid "inconsistency with delta count"
 msgstr "неправилен брой разлики"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr ""
+"неправилна стойност за преизползването на пакети „pack.allowPackReuse“: „%s“"
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9795,10 +9833,10 @@ msgstr "Изброяване на обектите"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Общо: %<PRIu32> (разлики: %<PRIu32>), преизползвани: %<PRIu32> (разлики: "
-"%<PRIu32>), преизползвани при пакетиране: %<PRIu32>"
+"%<PRIu32>), преизползвани при пакетиране: %<PRIu32> (от %<PRIuMAX>)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10791,13 +10829,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "опцията „C“ очаква число за аргумент"
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"опциите за прилагане са несъвместими с „rebase.autoSquash“.  Пробвайте да "
-"добавите опцията „--no-autosquash“"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -11823,6 +11854,76 @@ msgstr "опцията „--convert-graft-file“ не приема аргуме
 msgid "only one pattern can be given with -l"
 msgstr "опцията „-l“ приема точно един шаблон"
 
+msgid "need some commits to replay"
+msgstr "необходимо е да има подавания за прилагане отново"
+
+msgid "--onto and --advance are incompatible"
+msgstr "опциите „--onto“ и „--advance“ са несъвместими"
+
+msgid "all positive revisions given must be references"
+msgstr "всички зададени положителни версии трябва да са указатели"
+
+msgid "argument to --advance must be a reference"
+msgstr "аргументът към „--advance“ трябва да е указател"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"цели с множество източници не може да се придвижат напред, защото подредбата "
+"не е добре дефинирана"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"не може да се определи дали това действие е за „--advance“ или „--onto“"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"цели с множество клони-източници не може да се придвижат напред, защото "
+"подредбата не е добре дефинирана"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "правилната база за „--onto“ не може да се определи"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(ЕКСПЕРИМЕНТАЛНО!) git replay ([--contained] --onto НОВА_БАЗА | --advance "
+"КЛОН) ДИАПАЗОН_ПОДАВАНИЯ…"
+
+msgid "make replay advance given branch"
+msgstr "прилагането наново придвижва дадения КЛОН напред"
+
+msgid "replay onto given commit"
+msgstr "прилагането наново върху даденото ПОДАВАНЕ"
+
+msgid "advance all branches contained in revision-range"
+msgstr "придвижване на всички КЛОНи в ДИАПАЗОНа_ПОДАВАНИЯ"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "изисква се някоя от опциите „--onto“ или „--advance“"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"някои опции за проследяване на указатели ще бъдат променени, защото битът "
+"„%s“ в структурата „struct rev_info“ има превес"
+
+msgid "error preparing revisions"
+msgstr "грешка при подготовката на версии"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "не се поддържа прилагане наново и на началното подаване!"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "не се поддържа прилагане наново и на подавания със сливане!"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr "git rerere [clear|forget ПЪТ…|diff|status|remaining|gc]"
@@ -12030,15 +12131,6 @@ msgstr "опцията „--prefix“ изисква аргумент"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "непознат режим за „--abbrev-ref“: „%s“"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "опциите „--exclude-hidden“ и „--branches“ са несъвместими"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "опциите „--exclude-hidden“ и „--tags“ са несъвместими"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "опциите „--exclude-hidden“ и „--remotes“ са несъвместими"
-
 msgid "this operation must be run in a work tree"
 msgstr "тази команда трябва да се изпълни в работно дърво"
 
@@ -12242,7 +12334,7 @@ msgid "git shortlog [<options>] [<revision-range>] [[--] <path>...]"
 msgstr "git shortlog [ОПЦИЯ…] [ДИАПАЗОН_НА_ВЕРСИИТЕ] [[--] [ПЪТ…]]"
 
 msgid "git log --pretty=short | git shortlog [<options>]"
-msgstr "git log --pretty=short|git shortlog [ОПЦИЯ…]"
+msgstr "git log --pretty=short | git shortlog [ОПЦИЯ…]"
 
 msgid "using multiple --group options with stdin is not supported"
 msgstr "повече от една опции „--group“ са несъвместими със стандартния вход"
@@ -12455,10 +12547,6 @@ msgstr ""
 "извеждане на указателите приети от стандартния вход, които липсват в "
 "локалното хранилище"
 
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "опциите „%s“, „%s“ и „%s“ са несъвместими"
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -13951,7 +14039,7 @@ msgstr "Липсва клон-източник, затова се приема 
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
@@ -13965,7 +14053,7 @@ msgstr ""
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
@@ -14034,6 +14122,10 @@ msgstr "директорията „%s“ не може да бъде създа
 msgid "initializing"
 msgstr "инициализация"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "създаденото в „%s“ работно дърво липсва"
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "Приготвяне на работното дърво (нов клон „%s“)"
@@ -14076,10 +14168,6 @@ msgstr ""
 "доставете\n"
 "обектите от отдалеченото хранилище"
 
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "опциите „%s“ и „%s“ са несъвместими"
-
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr "Изтегляне КЛОНа, дори и да е изтеглен в друго работно дърво"
 
@@ -14089,7 +14177,7 @@ msgstr "създаване на нов клон"
 msgid "create or reset a branch"
 msgstr "създаване или зануляване на клони"
 
-msgid "create unborn/orphaned branch"
+msgid "create unborn branch"
 msgstr "създаване на неродѐн клон"
 
 msgid "populate the new working tree"
@@ -14112,11 +14200,8 @@ msgid "options '%s', '%s', and '%s' cannot be used together"
 msgstr "опциите „%s“, „%s“ и „%s“ са несъвместими"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "опциите „%s“ и „%s“ са несъвместими"
-
-msgid "<commit-ish>"
-msgstr "ПОДАВАНЕ"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "опциите „%s“ и указателите към подавания са несъвместими"
 
 msgid "added with --lock"
 msgstr "добавена с „--lock“"
@@ -14753,6 +14838,11 @@ msgstr "Пакетиране на непакетираните обекти в 
 msgid "Create, list, delete refs to replace objects"
 msgstr "Създаване, извеждане, изтриване на указатели за замяна на обекти"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"ЕКСПЕРИМЕНТАЛНО: прилагане на подавания върху нова база, работи и с голи "
+"хранилища"
+
 msgid "Generates a summary of pending changes"
 msgstr "Обобщение на предстоящите промѐни"
 
@@ -14991,6 +15081,36 @@ msgstr "Инструмент за управление на големи хра
 msgid "commit-graph file is too small"
 msgstr "файлът за гра̀фа с подаванията е твърде малък"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "откъсът за разпределянето в гра̀фа с подаванията е прекалено малък"
+
+msgid "commit-graph fanout values out of order"
+msgstr ""
+"стойностите за откъс за разпределяне в гра̀фа с подаванията не са подредени"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "откъсът за търсенето в гра̀фа с подаванията е прекалено малък"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr ""
+"откъсът за данните за подаванията в гра̀фа с подаванията е с неправилен размер"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr "откъсът за поколенията в гра̀фа с подаванията е с неправилен размер"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr ""
+"откъсът за индекса с промѐни в пътищата в гра̀фа с подаванията е прекалено "
+"малък"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"прескачане на прекалено малък откъс за индекса с промѐни (%<PRIuMAX> < "
+"%<PRIuMAX>) в пътищата в гра̀фа с подаванията"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr "отпечатъкът на гра̀фа с подаванията %X не съвпада с %X"
@@ -15007,6 +15127,19 @@ msgstr "версията на контролната сума на гра̀фа
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "файлът с гра̀фа на подаванията е твърде малък, за да съдържа %u откъси"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr ""
+"откъсът за разпределянето необходимо на гра̀фа с подаванията липсва или е "
+"повреден"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr ""
+"откъсът за търсенето необходимо на гра̀фа с подаванията липсва или е повреден"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr ""
+"откъсът за данните необходими на гра̀фа с подаванията липсва или е повреден"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "базовият откъс липсва в гра̀фа с подаванията"
 
@@ -15020,6 +15153,9 @@ msgstr "веригата на гра̀фа с подаванията не съв
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "броят подавания в основния граф е прекалено голям: %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "веригата на гра̀фа с подаванията е твърде малка"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr ""
@@ -15038,12 +15174,16 @@ msgstr "подаването „%s“ не може да бъде открито
 
 msgid "commit-graph requires overflow generation data but has none"
 msgstr ""
-"графът с подаванията изисква генериране на данни за отместването, но такива "
-"липсват"
+"графът с подаванията изисква данни за прелелите поколения, но такива липсват"
 
 msgid "commit-graph overflow generation data is too small"
 msgstr "прекалено малко данни за прелелите поколения в гра̀фа с подаванията"
 
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr ""
+"указателят за допълнителните ребра в гра̀фа с подаванията е извън позволения "
+"диапазон"
+
 msgid "Loading known commits in commit graph"
 msgstr "Зареждане на познатите подавания в гра̀фа с подаванията"
 
@@ -16244,6 +16384,10 @@ msgstr ""
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "Непозната стойност „%s“ за настройката „diff.submodule“"
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "непозната стойност за настройката „%s“: „%s“"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -16323,14 +16467,6 @@ msgstr "неправилен аргумент за „--color-moved“: „%s“
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "неправилен режим „%s“ за „ --color-moved-ws“"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"опцията приема следните варианти за алгоритъм за разлики: „myers“ (по "
-"Майерс), „minimal“ (минимизиране на разликите), „patience“ (пасианс) и "
-"„histogram“ (хистограмен)"
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "неправилен аргумент към „%s“"
@@ -16374,8 +16510,8 @@ msgstr "„--stat“ във формат за четене от програма
 msgid "output only the last line of --stat"
 msgstr "извеждане само на последния ред на „--stat“"
 
-msgid "<param1,param2>..."
-msgstr "ПАРАМЕТЪР_1, ПАРАМЕТЪР_2, …"
+msgid "<param1>,<param2>..."
+msgstr "ПАРАМЕТЪР_1,ПАРАМЕТЪР_2,…"
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -16384,8 +16520,8 @@ msgstr "извеждане на разпределението на промѐ
 msgid "synonym for --dirstat=cumulative"
 msgstr "псевдоним на „--dirstat=cumulative“"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "псевдоним на „--dirstat=ФАЙЛ…,ПАРАМЕТЪР_1,ПАРАМЕТЪР_2,…“"
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "псевдоним на „--dirstat=files,ПАРАМЕТЪР_1,ПАРАМЕТЪР_2,…“"
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr ""
@@ -16569,12 +16705,6 @@ msgstr "разлика чрез алгоритъм за подредба кат
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "разлика по хистограмния алгоритъм"
 
-msgid "<algorithm>"
-msgstr "АЛГОРИТЪМ"
-
-msgid "choose a diff algorithm"
-msgstr "избор на АЛГОРИТЪМа за разлики"
-
 msgid "<text>"
 msgstr "ТЕКСТ"
 
@@ -18093,6 +18223,13 @@ msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr ""
 "неправилен размер на откъса за разпределянето в индекса за множество пакети"
 
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"неправилна подредба на откъси (OID fanout): fanout[%d] = %<PRIx32> > "
+"%<PRIx32> = fanout[%d]"
+
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "неправилен размер на откъса за търсенето в индекса за множество пакети"
 
@@ -18149,6 +18286,14 @@ msgid "bad pack-int-id: %u (%u total packs)"
 msgstr ""
 "неправилен идентификатор на пакет (pack-int-id): %u (от общо %u пакети)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr ""
+"липсва откъс за побитова маска във файла за индекса за множество пакети"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "пакетът за битови маски %<PRIu32> не може да се отвори"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr ""
 "индексът за множество пакети съдържа 64-битови отмествания, но размерът на "
@@ -18241,13 +18386,6 @@ msgstr "неправилна сума за проверка"
 msgid "Looking for referenced packfiles"
 msgstr "Търсене на указаните пакетни файлове"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr ""
-"неправилна подредба на откъси (OID fanout): fanout[%d] = %<PRIx32> > "
-"%<PRIx32> = fanout[%d]"
-
 msgid "the midx contains no oid"
 msgstr "във файла с индекса за множество пакети няма идентификатори на обекти"
 
@@ -18792,6 +18930,11 @@ msgstr "задължителният обратен индекс липсва в
 msgid "could not open pack %s"
 msgstr "пакетът „%s“ не може да се отвори"
 
+msgid "could not determine MIDX preferred pack"
+msgstr ""
+"предпочитаният пакет за файла с индекса за множество пакети не може да се "
+"определи"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
 msgstr "предпочитаният пакет „%s“ е неправилен"
@@ -18818,6 +18961,11 @@ msgstr ""
 "повредена битова маска във формат EWAH: отрязана заглавна част за битовата "
 "маска на подаване „%s“"
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr ""
+"пакетът не може да се зареди: „%s“, преизползването на пакети се изключва"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "обектът „%s“ липсва в битовата маска на видовете"
@@ -18917,6 +19065,9 @@ msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr ""
 "неправилен размер на откъс за обратен индекс в индекса за множество пакети"
 
+msgid "could not determine preferred pack"
+msgstr "предпочитаният пакет не може да се определи"
+
 msgid "cannot both write and verify reverse index"
 msgstr "обратният индекс не може едновременно да се записва и да се проверява"
 
@@ -18987,10 +19138,6 @@ msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr ""
 "„%s“ очаква неотрицателно цяло число, евентуално със суфикс „k“/„m“/„g“"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "опциите „%s“ и „%s“ са несъвместими"
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "нееднозначна опция: „%s“ (може да е „--%s%s“ или „--%s%s“)"
@@ -19315,10 +19462,6 @@ msgstr "файлът „%s“ не може да бъде индексиран"
 msgid "unable to add '%s' to index"
 msgstr "„%s“ не може да се добави в индекса"
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "„stat“ не може да се изпълни върху „%s“"
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "„%s“ съществува и като файл, и като директория"
@@ -19864,7 +20007,7 @@ msgstr "неправилно име на клон: „%s = %s“"
 
 #, c-format
 msgid "ignoring dangling symref %s"
-msgstr "игнориране на указател на обект извън клон „%s“"
+msgstr "игноÑ\80иÑ\80ане Ð½Ð° Ñ\84айл Ñ\81 Ñ\83казаÑ\82ел Ð½Ð° Ð¾Ð±ÐµÐºÑ\82 Ð¸Ð·Ð²Ñ\8aн ÐºÐ»Ð¾Ð½ â\80\9e%sâ\80\9c"
 
 #, c-format
 msgid "log for ref %s has gap after %s"
@@ -19904,10 +20047,6 @@ msgstr "„%s“ съществува, не може да се създаде 
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "невъзможно е едновременно да се обработват „%s“ и „%s“"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "Указателят „%s“ не може да бъде изтрит"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "Указателят „%s“ не може да бъде изтрит: %s"
@@ -21333,6 +21472,9 @@ msgstr "Конфликти при прилагането на автоматич
 msgid "Autostash exists; creating a new stash entry."
 msgstr "Вече има запис за автоматично скатано, затова се създава нов запис."
 
+msgid "autostash reference is a symref"
+msgstr "указателят за автоматично скатано e файл с указател"
+
 msgid "could not detach HEAD"
 msgstr "указателят „HEAD“ не може да се отдели"
 
@@ -21656,6 +21798,10 @@ msgstr "шаблоните няма да бъдат копирани от „%s
 msgid "invalid initial branch name: '%s'"
 msgstr "неправилно име на първоначалния клон: „%s“"
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init: „--initial-branch=%s“ се пропуска"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "файлове от вид %d не се поддържат"
@@ -21666,17 +21812,18 @@ msgstr "„%s“ не може да се премести в „%s“"
 
 msgid "attempt to reinitialize repository with different hash"
 msgstr ""
-"опит за повторно задаване на първото подаване в хранилището с различна "
-"контролна сума"
+"опит за зануляване на хранилището и инициализиране с различна контролна сума"
+
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr ""
+"опит за зануляване на хранилището и инициализиране с различен формат на "
+"съхраняване"
 
 #, c-format
 msgid "%s already exists"
 msgstr "Директорията „%s“ вече съществува"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init: „--initial-branch=%s“ се пропуска"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr ""
@@ -21948,12 +22095,6 @@ msgstr ""
 "какъв брой записи в кеша на обектите-дървета да се отбележат като невалидни "
 "(стандартно е 0)"
 
-msgid "unhandled options"
-msgstr "неподдържани опции"
-
-msgid "error preparing revisions"
-msgstr "грешка при подготовката на версии"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "подаването „%s“ не е отбелязано като достижимо"
@@ -22110,9 +22251,6 @@ msgstr "протоколът не поддържа задаването на п
 msgid "invalid remote service path"
 msgstr "неправилен път на отдалечената услуга"
 
-msgid "operation not supported by protocol"
-msgstr "опцията не се поддържа от протокола"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "неуспешно свързване към подуслугата „%s“"
@@ -22247,10 +22385,6 @@ msgstr "стойността на настройката „transport.color.*“
 msgid "support for protocol v2 not implemented yet"
 msgstr "протокол версия 2 все още не се поддържа"
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "непозната стойност за настройката „%s“: „%s“"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "преносът по „%s“ не е позволен"
@@ -22304,6 +22438,9 @@ msgstr ""
 "спъсъкът с адреси на пратки обявени за налични от сървъра не може да се "
 "получи "
 
+msgid "operation not supported by protocol"
+msgstr "опцията не се поддържа от протокола"
+
 msgid "too-short tree object"
 msgstr "прекалено кратък обект-дърво"
 
@@ -23147,6 +23284,10 @@ msgstr "освен това в индекса има неподадени про
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "не може да извършите „%s“, защото в индекса има неподадени промѐни."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "непознат стил „%s“ за „%s“"
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
index d1a4e56c3a59f200b66d46a26bb93474297f7866..bcb4da80fb9afe7ad62f65326ff6e0564c236550 100644 (file)
--- a/po/ca.po
+++ b/po/ca.po
@@ -1,7 +1,7 @@
 # Catalan translations for Git.
 # This file is distributed under the same license as the Git package.
 # Alex Henrie <alexhenrie24@gmail.com>, 2014-2016.
-# Jordi Mas i Hernàndez <jmas@softcatala.org>, 2016-2023
+# Jordi Mas i Hernàndez <jmas@softcatala.org>, 2016-2024
 #
 # Terminologia
 #
@@ -56,6 +56,7 @@
 #   Anglès           |  Català
 #   -----------------+---------------------------------
 #   blame            |  «blame»
+#   fanout           |  «fanout»
 #   HEAD             |  HEAD (f, la branca actual) - (no s'apostrofa)
 #   cherry pick      |  «cherry pick»
 #   promisor         |  «promisor»
 #
 # Criteris
 #   - Mantingueu en anglès les referències a seccions de la documentació, ja que no està traduïda.
-#   - Usem la convenció valenciana per a «per / per a», que inclou l'ús de «per a» davant d'infintiu
+#   - Usem la convenció valenciana per a «per / per a», que inclou l'ús de «per a» davant d'infinitiu
 #
 msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-13 18:55+0100\n"
-"PO-Revision-Date: 2023-11-13 19:00-0600\n"
+"POT-Creation-Date: 2024-02-16 07:14+0100\n"
+"PO-Revision-Date: 2024-02-16 07:16+0100\n"
 "Last-Translator: Jordi Mas i Hernàndez <jmas@softcatala.org>\n"
 "Language-Team: Catalan\n"
 "Language: ca\n"
@@ -592,6 +593,7 @@ msgstr "«git apply --cached» ha fallat"
 #. Consider translating (saying "no" discards!) as
 #. (saying "n" for "no" discards!) if the translation
 #. of the word "no" does not start with n.
+#.
 msgid ""
 "Your edited hunk does not apply. Edit again (saying \"no\" discards!) [y/n]? "
 msgstr ""
@@ -1502,6 +1504,10 @@ msgstr "l'opció «%s» requereix «%s»"
 msgid "Unexpected option --output"
 msgstr "Opció inesperada --output"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "paràmetre extra de la línia d'ordres «%s»"
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Format d'arxiu desconegut «%s»"
@@ -1547,6 +1553,14 @@ msgstr "s'ignorarà el blob «%s» gitattributes per a ser massa gran"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "--attr-source incorrecte o GIT_ATTR_SOURCE"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "no s'ha pogut fer «stat» a «%s»"
+
+#, c-format
+msgid "unable to read %s"
+msgstr "no s'ha pogut llegir %s"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "Comentari amb cometes errònies en el fitxer «%s»: %s"
@@ -1643,6 +1657,7 @@ msgstr[1] "(aproximadament %d passos)"
 
 #. TRANSLATORS: the last %s will be replaced with "(roughly %d
 #. steps)" translation.
+#.
 #, c-format
 msgid "Bisecting: %d revision left to test after this %s\n"
 msgid_plural "Bisecting: %d revisions left to test after this %s\n"
@@ -1728,17 +1743,20 @@ msgstr "no s'està seguint: informació ambigua per a la referència «%s»"
 #. TRANSLATORS: This is a line listing a remote with duplicate
 #. refspecs in the advice message below. For RTL languages you'll
 #. probably want to swap the "%s" and leading "  " space around.
+#.
 #. #-#-#-#-#  object-name.c.po  #-#-#-#-#
 #. TRANSLATORS: This is line item of ambiguous object output
 #. from describe_ambiguous_object() above. For RTL languages
 #. you'll probably want to swap the "%s" and leading " " space
 #. around.
+#.
 #, c-format
 msgid "  %s\n"
 msgstr "  %s\n"
 
 #. TRANSLATORS: The second argument is a \n-delimited list of
 #. duplicate refspecs, composed above.
+#.
 #, c-format
 msgid ""
 "There are multiple remotes whose fetch refspecs map to the remote\n"
@@ -2143,6 +2161,7 @@ msgstr "El cos de la comissió és:"
 #. TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a]
 #. in your translation. The program will only accept English
 #. input at this point.
+#.
 #, c-format
 msgid "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: "
 msgstr ""
@@ -2480,6 +2499,7 @@ msgstr "bisecant amb només una comissió %s"
 #. TRANSLATORS: Make sure to include [Y] and [n] in your
 #. translation. The program will only accept English input
 #. at this point.
+#.
 msgid "Are you sure [Y/n]? "
 msgstr "N'esteu segur [Y/n]? "
 
@@ -2557,6 +2577,7 @@ msgstr "Cal començar per «git bisect start»\n"
 #. TRANSLATORS: Make sure to include [Y] and [n] in your
 #. translation. The program will only accept English input
 #. at this point.
+#.
 msgid "Do you want me to do it for you [Y/n]? "
 msgstr "Voleu que ho faci per vostè [Y/n]? "
 
@@ -2777,6 +2798,7 @@ msgstr ""
 #. among various forms of relative timestamps, but
 #. your language may need more or fewer display
 #. columns.
+#.
 msgid "4 years, 11 months ago"
 msgstr "fa 4 anys i 11 mesos"
 
@@ -2838,12 +2860,12 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "no s'ha pogut cercar l'objecte de comissió per a «%s»"
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"la branca «%s» no està completament fusionada.\n"
-"Si esteu segur que voleu suprimir-la, executeu «git branch -D %s»"
+msgid "the branch '%s' is not fully merged"
+msgstr "la branca «%s» no està completament fusionada"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "Si esteu segur que voleu suprimir-la, executeu «git branch -D %s»"
 
 msgid "update of config-file failed"
 msgstr "ha fallat l'actualització del fitxer de configuració"
@@ -3884,8 +3906,8 @@ msgstr "agafa a la força (descarta qualsevol modificació local)"
 msgid "new-branch"
 msgstr "branca-nova"
 
-msgid "new unparented branch"
-msgstr "branca òrfena nova"
+msgid "new unborn branch"
+msgstr "branca no nascuda nova"
 
 msgid "update ignored files (default)"
 msgstr "actualitza els fitxers ignorats (per defecte)"
@@ -4137,9 +4159,6 @@ msgstr ""
 "clean.requireForce és per defecte cert i ni -i, -n ni -f s'han indicat; "
 "refusant netejar"
 
-msgid "-x and -X cannot be used together"
-msgstr "-x i -X no es poden usar junts"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<opcions>] [--] <repositori> [<directori>]"
 
@@ -4228,6 +4247,9 @@ msgstr "directori de git"
 msgid "separate git dir from working tree"
 msgstr "separa el directori de git de l'arbre de treball"
 
+msgid "specify the reference format to use"
+msgstr "especifiqueu el format de referència a usar"
+
 msgid "key=value"
 msgstr "clau=valor"
 
@@ -4347,11 +4369,9 @@ msgstr "Hi ha massa arguments."
 msgid "You must specify a repository to clone."
 msgstr "Heu d'especificar un repositori per a clonar."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri és incompatible amb --depth, --shallow-since i --shallow-exclude"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "el format d'emmagatzematge de referència «%s» és desconegut"
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4481,14 +4501,14 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <dir>] [--append]\n"
 "                       [--split[=<strategy>]] [--reachable | --stdin-packs | "
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 
 msgid "dir"
 msgstr "directori"
@@ -5007,6 +5027,7 @@ msgstr "reusa el missatge de la comissió especificada"
 
 #. TRANSLATORS: Leave "[(amend|reword):]" as-is,
 #. and only translate <commit>.
+#.
 msgid "[(amend|reword):]commit"
 msgstr "[(amend|reword):]commit"
 
@@ -5544,7 +5565,7 @@ msgstr "No s'ha trobat cap nom, no es pot descriure res."
 
 #, c-format
 msgid "option '%s' and commit-ishes cannot be used together"
-msgstr "les opcions «%s» i de comissió no es poden usar juntes"
+msgstr "opció «%s» i les de comissió no es poden usar juntes"
 
 msgid ""
 "git diagnose [(-o | --output-directory) <path>] [(-s | --suffix) <format>]\n"
@@ -6820,6 +6841,7 @@ msgstr "s'ha especificat un nombre de fils no vàlid (%d) per a %s"
 #. TRANSLATORS: %s is the configuration
 #. variable for tweaking threads, currently
 #. grep.threads
+#.
 #, c-format
 msgid "no threads support, ignoring %s"
 msgstr "no s'admeten fils, s'ignorarà %s"
@@ -6828,6 +6850,10 @@ msgstr "no s'admeten fils, s'ignorarà %s"
 msgid "unable to read tree (%s)"
 msgstr "no s'ha pogut llegir l'arbre (%s)"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "no s'ha pogut llegir l'arbre %s"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "no es pot fer grep des d'un objecte de tipus %s"
@@ -7246,10 +7272,6 @@ msgstr "hi ha una inconsistència seriosa d'inflació"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "S'HA TROBAT UNA COL·LISIÓ SHA1 AMB %s !"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "no s'ha pogut llegir %s"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "no es pot llegir la informació d'objecte existent %s"
@@ -7390,11 +7412,13 @@ msgstr "error fsck als objectes del paquet"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 
@@ -8110,6 +8134,12 @@ msgstr ""
 "git merge-file [<opcions>] [-L <nom1> [-L <original> [-L <nom2>]]] <fitxer1> "
 "<fitxer-original> <fitxer2>"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"l'opció diff-algorithm accepta «myers», «minimal», «patience» i «histogram»"
+
 msgid "send results to standard output"
 msgstr "envia els resultats a la sortida estàndard"
 
@@ -8131,6 +8161,12 @@ msgstr "en conflictes, usa la seva versió"
 msgid "for conflicts, use a union version"
 msgstr "en conflictes, usa una versió d'unió"
 
+msgid "<algorithm>"
+msgstr "<algorisme>"
+
+msgid "choose a diff algorithm"
+msgstr "trieu un algorisme per al diff"
+
 msgid "for conflicts, use this marker size"
 msgstr "en conflictes, usa aquesta mida de marcador"
 
@@ -8221,9 +8257,6 @@ msgstr "--trivial-merge és incompatible amb totes les altres opcions"
 msgid "unknown strategy option: -X%s"
 msgstr "opció d'estratègia desconeguda: -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base és incompatible amb --stdin"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "línia d'entrada mal formada: «%s»."
@@ -8856,6 +8889,7 @@ msgstr "s'ha produït un error en copiar les notes de «%s» a «%s»"
 
 #. TRANSLATORS: the first %s will be replaced by a git
 #. notes command: 'add', 'merge', 'remove', etc.
+#.
 #, c-format
 msgid "refusing to %s notes in %s (outside of refs/notes/)"
 msgstr "s'està refusant %s les notes en %s (fora de refs/notes/)"
@@ -9165,6 +9199,10 @@ msgstr "S'estan comprimint els objectes"
 msgid "inconsistency with delta count"
 msgstr "inconsistència amb el comptador de diferències"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "valor pack.allowPackReuse value no vàlid: «%s»"
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9430,10 +9468,10 @@ msgstr "S'estan enumerant els objectes"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Total %<PRIu32> (%<PRIu32> diferències), reusats %<PRIu32> (%<PRIu32> "
-"diferències), paquets reusats %<PRIu32>"
+"diferències), paquets reusats %<PRIu32> (de %<PRIuMAX>)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10397,13 +10435,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "«switch» «c» espera un valor numèric"
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"les opcions «apply» són incompatibles amb rebase.autoSquash. Considereu "
-"afegir-hi --no-autosquash"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -10922,6 +10953,7 @@ msgstr "(sense URL)"
 #. TRANSLATORS: the colon ':' should align
 #. with the one in " Fetch URL: %s"
 #. translation.
+#.
 #, c-format
 msgid "  Push  URL: %s"
 msgstr "  URL de pujada: %s"
@@ -11414,6 +11446,77 @@ msgstr "--convert-graft-file arguments"
 msgid "only one pattern can be given with -l"
 msgstr "només es pot especificar un patró amb -l"
 
+msgid "need some commits to replay"
+msgstr "calen algunes comissions per tornar a reproduir"
+
+msgid "--onto and --advance are incompatible"
+msgstr "--onto i --advance són incompatibles"
+
+msgid "all positive revisions given must be references"
+msgstr "totes les revisions positives que s'han donat han de ser referències"
+
+msgid "argument to --advance must be a reference"
+msgstr "l'argument per a --advance ha de ser una referència"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"no es pot avançar l'objectiu amb múltiples fonts perquè l'ordenació no "
+"estaria definida correctament"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"no es pot determinar implícitament si aquesta és una operació --advance o --"
+"onto"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"no es pot avançar l'objectiu amb múltiples branques d'origen perquè "
+"l'ordenació no estaria definida correctament"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "no es pot determinar implícitament la base correcta per a --onto"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+
+msgid "make replay advance given branch"
+msgstr "fes avançar la repetició de la branca donada"
+
+msgid "replay onto given commit"
+msgstr "torna a reproduir a la comissió donada"
+
+msgid "advance all branches contained in revision-range"
+msgstr "avança totes les branques contingudes a l'interval de revisions"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "l'opció --onto o --advance és obligatòria"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"algunes opcions de referència se sobreescriuran de forma forçada com a «%s» "
+"bits a «struct rev_info»"
+
+msgid "error preparing revisions"
+msgstr "s'ha produït un error en preparar les revisions"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "encara no s'admet la reproducció cap avall en una comissió arrel"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "encara no s'admet la repetició de les comissió de fusió"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr ""
@@ -11622,15 +11725,6 @@ msgstr "--prefix requereix un argument"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "mode desconegut per a --abbrev-ref: %s"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden no es pot utilitzar juntament amb --branches"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden no es pot utilitzar juntament amb --tags"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden no es pot utilitzar juntament amb --remotes"
-
 msgid "this operation must be run in a work tree"
 msgstr "aquesta operació s'ha d'executar en un arbre de treball"
 
@@ -12040,10 +12134,6 @@ msgstr "no imprimeixis els resultats a stdout (útil amb --verify)"
 msgid "show refs from stdin that aren't in local repository"
 msgstr "mostra les referències de stdin que no siguin en el repositori local"
 
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "només es poden donar les opcions «%s», «%s», o «%s»"
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -13519,28 +13609,28 @@ msgstr "No hi ha cap branca d'origen possible, inferint «--orphan»"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
-"Si voleu crear un arbre de treball que contingui una branca orfe nova\n"
-"(branca sense comissions) per a aquest repositori, podeu fer-ho\n"
+"Si voleu crear un arbre de treball que contingui una branca no nascuda\n"
+"nova (branca sense comissions) per a aquest repositori, podeu fer-ho\n"
 "utilitzant l'argument --orphan:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
-"Si voleu crear un arbre de treball que contingui una branca orfe nova\n"
-"(branca sense comissions) per a aquest repositori, podeu fer-ho\n"
+"Si voleu crear un arbre de treball que contingui una branca no nascuda\n"
+"nova (branca sense comissions) per a aquest repositori, podeu fer-ho\n"
 "utilitzant l'argument --orphan:\n"
 "\n"
 "    git worktree add --orphan %s\n"
@@ -13602,6 +13692,10 @@ msgstr "no s'ha pogut crear directori de «%s»"
 msgid "initializing"
 msgstr "s'està inicialitzant"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "no s'ha pogut trobar l'arbre de treball creat «%s»"
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "S'està preparant l'arbre de treball (branca nova «%s»)"
@@ -13641,10 +13735,6 @@ msgstr ""
 "No hi ha referències locals o remotes malgrat hi existeix almenys un\n"
 "remot, aturada; useu «add -f» per a anul·lar o obtenir primer un remot"
 
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "les opcions «%s» i «%s» no es poden usar juntes"
-
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr "agafa <branca> encara que sigui agafada en altre arbre de treball"
 
@@ -13654,8 +13744,8 @@ msgstr "crea una branca nova"
 msgid "create or reset a branch"
 msgstr "crea o restableix una branca"
 
-msgid "create unborn/orphaned branch"
-msgstr "crea una branca no nascuda/òrfena"
+msgid "create unborn branch"
+msgstr "crea una branca no nascuda"
 
 msgid "populate the new working tree"
 msgstr "emplena l'arbre de treball nou"
@@ -13679,11 +13769,8 @@ msgid "options '%s', '%s', and '%s' cannot be used together"
 msgstr "les opcions «%s», «%s», i «%s» no es poden usar juntes"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "les opcions «%s» i «%s» no es poden usar juntes"
-
-msgid "<commit-ish>"
-msgstr "<commit-ish>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "opció «%s» i les de comissió no es poden usar juntes"
 
 msgid "added with --lock"
 msgstr "afegit amb --lock"
@@ -14313,6 +14400,11 @@ msgstr "Empaqueta els objectes desempaquetats en un repositori"
 msgid "Create, list, delete refs to replace objects"
 msgstr "Crea, llista i esborra referències per a substituir objectes"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"EXPERIMENTAL: torna a reproduir comissions sobre una nova base, també "
+"funciona amb repositoris nus"
+
 msgid "Generates a summary of pending changes"
 msgstr "Genera un resum dels canvis pendents"
 
@@ -14554,6 +14646,35 @@ msgstr "Una eina per a gestionar dipòsits Git grans"
 msgid "commit-graph file is too small"
 msgstr "el fitxer del graf de comissions és massa petit"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr ""
+"el fragment de «fanout» de l'oid del graf de comissions és de mida incorrecta"
+
+msgid "commit-graph fanout values out of order"
+msgstr "valors de graf de comissions de «fanout» estan fora d'ordre"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "el fragment de cerca OID és de mida incorrecta"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "el fragment de dades del graf de comissions és de mida incorrecta"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr ""
+"el fragment de les generacions del graf de comissions és de mida incorrecta"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr ""
+"el fragment d'índex del canvi del camí del graf de comissions és massa petit"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"s'ignorarà un fragment massa petit de camí canviat (%<PRIuMAX> < %<PRIuMAX>) "
+"al fitxer del graf de comissions"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr ""
@@ -14573,6 +14694,20 @@ msgid "commit-graph file is too small to hold %u chunks"
 msgstr ""
 "el fitxer del graf de comissions és massa petit per a guardar %u fragments"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr ""
+"manca o està malmès el fragment del «fanout» OID requerit al graf de "
+"comissions"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr ""
+"manca o està malmès el fragment de cerca d'OID requerit al graf de comissions"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr ""
+"manca o està corromput el fragment de dades de publicació requerit al graf "
+"de comissions"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "el fragment del graf de comissions no té grafs de base"
 
@@ -14586,6 +14721,9 @@ msgstr "la cadena del graf de comissions no coincideix"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "el nombre de comissions en el graf base és massa alt: %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "el fitxer de cadena del graf de comissions és massa petit"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr ""
@@ -14613,6 +14751,9 @@ msgstr ""
 "les dades de generació de desbordament del graf de comissions són massa "
 "petites"
 
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "punter de vores extra del graf de comissió està fora dels límits"
+
 msgid "Loading known commits in commit graph"
 msgstr "S'estan carregant comissions conegudes al graf de comissions"
 
@@ -15785,6 +15926,10 @@ msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr ""
 "Valor desconegut de la variable de configuració de «diff.submodule»: «%s»"
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "valor desconegut per al config «%s»': %s"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -15862,12 +16007,6 @@ msgstr "argument --color-moved incorrecte: %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "mode «%s» no vàlid en --color-moved-ws"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"l'opció diff-algorithm accepta «myers», «minimal», «patience» i «histogram»"
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "argument no vàlid a %s"
@@ -15912,8 +16051,8 @@ msgstr "llegible per una màquina --stat"
 msgid "output only the last line of --stat"
 msgstr "mostra només l'última línia de --stat"
 
-msgid "<param1,param2>..."
-msgstr "<param1,param2>..."
+msgid "<param1>,<param2>..."
+msgstr "<param1>,<param2>..."
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -15924,8 +16063,8 @@ msgstr ""
 msgid "synonym for --dirstat=cumulative"
 msgstr "sinònim de --dirstat=cumulative"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "sinònim de --dirstat=files,param1,param2..."
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "sinònim de --dirstat=files,<param1>,<param2>..."
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr ""
@@ -16108,12 +16247,6 @@ msgstr "genera diff usant l'algorisme «patience diff»"
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "genera diff usant l'algorisme «histogram diff»"
 
-msgid "<algorithm>"
-msgstr "<algorisme>"
-
-msgid "choose a diff algorithm"
-msgstr "trieu un algorisme per al diff"
-
 msgid "<text>"
 msgstr "<text>"
 
@@ -16499,12 +16632,14 @@ msgstr "s'ha produït un error en processar els acks: %d"
 
 #. TRANSLATORS: The parameter will be 'ready', a protocol
 #. keyword.
+#.
 #, c-format
 msgid "expected packfile to be sent after '%s'"
 msgstr "s'esperava que el fitxer de paquet s'enviés després de «%s»"
 
 #. TRANSLATORS: The parameter will be 'ready', a protocol
 #. keyword.
+#.
 #, c-format
 msgid "expected no other sections to be sent after no '%s'"
 msgstr "no s'esperava que cap altra secció s'enviés després de «%s»"
@@ -17322,6 +17457,7 @@ msgstr ""
 #. name, and the second argument is the abbreviated id of the
 #. commit that needs to be merged.  For example:
 #.  - go to submodule (mysubmodule), and either merge commit abc1234"
+#.
 #, c-format
 msgid ""
 " - go to submodule (%s), and either merge commit %s\n"
@@ -17356,6 +17492,7 @@ msgstr ""
 
 #. TRANSLATORS: The %s arguments are: 1) tree hash of a merge
 #. base, and 2-3) the trees for the two trees we're merging.
+#.
 #, c-format
 msgid "collecting merge info failed for trees %s, %s, %s"
 msgstr ""
@@ -17616,6 +17753,12 @@ msgstr "s'ha produït un error en llegir la memòria cau"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "l'OID «fanout» de l'índex multipaquet és d'una mida incorrecta"
 
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"oid «fanout» desordenat: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "El fragment de cerca OID índex multipaquet és de mida incorrecta"
 
@@ -17676,6 +17819,13 @@ msgstr ""
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "pack-int-id: %u incorrecte (%u paquets en total)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX no conté el fragment BTMP"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "no s'ha pogut carregar el paquet amb bits %<PRIu32>"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr ""
 "l'índex multipaquet emmagatzema un desplaçament de 64 bits, però off_t és "
@@ -17764,11 +17914,6 @@ msgstr "suma de verificació incorrecta"
 msgid "Looking for referenced packfiles"
 msgstr "S'estan cercant fitxers empaquetats referenciats"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr "oid fanout desordenat: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-
 msgid "the midx contains no oid"
 msgstr "el midx no conté cap oid"
 
@@ -17851,6 +17996,7 @@ msgstr "S'està refusant reescriure les notes en %s (fora de refs/notes/)"
 #. TRANSLATORS: The first %s is the name of
 #. the environment variable, the second %s is
 #. its value.
+#.
 #, c-format
 msgid "Bad %s value: '%s'"
 msgstr "Valor erroni de %s: «%s»"
@@ -18069,6 +18215,7 @@ msgstr "no s'han pogut desempaquetar els continguts de %s"
 #. TRANSLATORS: This is a line of ambiguous object
 #. output shown when we cannot look up or parse the
 #. object in question. E.g. "deadbeef [bad object]".
+#.
 #, c-format
 msgid "%s [bad object]"
 msgstr "%s [objecte incorrecte]"
@@ -18077,6 +18224,7 @@ msgstr "%s [objecte incorrecte]"
 #. object output. E.g.:
 #. *
 #.    "deadbeef commit 2021-01-01 - Some Commit Message"
+#.
 #, c-format
 msgid "%s commit %s - %s"
 msgstr "%s comissió %s - %s"
@@ -18091,6 +18239,7 @@ msgstr "%s comissió %s - %s"
 #. *
 #. The third argument is the "tag" string
 #. from object.c.
+#.
 #, c-format
 msgid "%s tag %s - %s"
 msgstr "%s etiqueta %s - %s"
@@ -18100,18 +18249,21 @@ msgstr "%s etiqueta %s - %s"
 #. the tag itself. E.g.:
 #. *
 #.    "deadbeef [bad tag, could not parse it]"
+#.
 #, c-format
 msgid "%s [bad tag, could not parse it]"
 msgstr "%s [etiqueta malmesa, no s'ha pogut analitzar]"
 
 #. TRANSLATORS: This is a line of ambiguous <type>
 #. object output. E.g. "deadbeef tree".
+#.
 #, c-format
 msgid "%s tree"
 msgstr "arbre %s"
 
 #. TRANSLATORS: This is a line of ambiguous <type>
 #. object output. E.g. "deadbeef blob".
+#.
 #, c-format
 msgid "%s blob"
 msgstr "blob %s"
@@ -18123,6 +18275,7 @@ msgstr "l'id d'objecte curt %s és ambigu"
 #. TRANSLATORS: The argument is the list of ambiguous
 #. objects composed in show_ambiguous_object(). See
 #. its "TRANSLATORS" comments for details.
+#.
 #, c-format
 msgid ""
 "The candidates are:\n"
@@ -18292,6 +18445,9 @@ msgstr "falta l'índex invers necessari al mapa de bits multipaquet"
 msgid "could not open pack %s"
 msgstr "no s'ha pogut obrir el paquet %s"
 
+msgid "could not determine MIDX preferred pack"
+msgstr "no s'ha pogut determinar el paquet preferit MIDX"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
 msgstr "el paquet preferit (%s) no és vàlid"
@@ -18317,6 +18473,12 @@ msgstr ""
 "mapa de bits ewah malmès: capçalera truncada per al mapa de bits de la "
 "comissió «%s»"
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr ""
+"no s'ha pogut carregar el paquet: «%s», s'està inhabilitant lareutilització "
+"de paquets"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "no s'ha trobat l'objecte «%s» als tipus de mapes de bits"
@@ -18410,6 +18572,9 @@ msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr ""
 "el fragment de l'index invers de l'índex multipaquet és de mida incorrecta"
 
+msgid "could not determine preferred pack"
+msgstr "no s'ha pogut determinar el paquet preferit"
+
 msgid "cannot both write and verify reverse index"
 msgstr "no es pot escriure i verificar l'índex invers"
 
@@ -18474,10 +18639,6 @@ msgstr "%s no és disponible"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s espera un valor enter no negatiu amb un sufix opcional k/m/g"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s és incompatible amb %s"
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "opció ambigua: %s (pot ser --%s%s o --%s%s)"
@@ -18514,6 +18675,7 @@ msgstr "ús: %s"
 
 #. TRANSLATORS: the colon here should align with the
 #. one in "usage: %s" translation.
+#.
 #, c-format
 msgid "   or: %s"
 msgstr "   o: %s"
@@ -18536,6 +18698,7 @@ msgstr "   o: %s"
 #. function. The "%s" is a line in the (hopefully already
 #. translated) N_() usage string, which contained embedded
 #. newlines before we split it up.
+#.
 #, c-format
 msgid "%*s%s"
 msgstr "%*s%s"
@@ -18798,10 +18961,6 @@ msgstr "no es pot llegir indexar el fitxer «%s»"
 msgid "unable to add '%s' to index"
 msgstr "no s'ha pogut afegir «%s» a l'índex"
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "no s'ha pogut fer «stat» a «%s»"
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "«%s» apareix com a fitxer i com a directori"
@@ -19383,10 +19542,6 @@ msgstr "«%s» existeix; no es pot crear «%s»"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "no es poden processar «%s» i «%s» a la vegada"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "no s'ha pogut eliminar la referència %s"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "no s'ha pogut suprimir la referència %s: %s"
@@ -19570,6 +19725,7 @@ msgstr ""
 #. TRANSLATORS: "matches '%s'%" is the <dst> part of "git push
 #. <remote> <src>:<dst>" push, and "being pushed ('%s')" is
 #. the <src>.
+#.
 #, c-format
 msgid ""
 "The destination you provided is not a full refname (i.e.,\n"
@@ -19610,7 +19766,7 @@ msgid ""
 "'%s:refs/tags/%s'?"
 msgstr ""
 "La part <src> de l'especificació de la referència és un objecte d'etiqueta.\n"
-"Voleu crear una etiqueta pujant-la a «%srefs/tags/%s»?"
+"Voleu crear una etiqueta pujant-la a «%s:refs/tags/%s»?"
 
 #, c-format
 msgid ""
@@ -19619,7 +19775,7 @@ msgid ""
 "'%s:refs/tags/%s'?"
 msgstr ""
 "La part <src> de l'especificació de la referència és un objecte d'arbre.\n"
-"Voleu crear una etiqueta pujant-la a «%srefs/tags/%s»?"
+"Voleu crear una etiqueta pujant-la a «%s:refs/tags/%s»?"
 
 #, c-format
 msgid ""
@@ -20203,6 +20359,7 @@ msgstr "cometeu els vostres canvis o feu un «stash» per a procedir."
 
 #. TRANSLATORS: %s will be "revert", "cherry-pick" or
 #. "rebase".
+#.
 #, c-format
 msgid "%s: Unable to write new index file"
 msgstr "%s: No s'ha pogut escriure un fitxer d'índex nou"
@@ -20762,6 +20919,9 @@ msgid "Autostash exists; creating a new stash entry."
 msgstr ""
 "El «stash» automàtic ja existeix; s'està creant una entrada «stash» nova."
 
+msgid "autostash reference is a symref"
+msgstr "la referència d'autostash és un symref"
+
 msgid "could not detach HEAD"
 msgstr "no s'ha pogut separar HEAD"
 
@@ -21005,7 +21165,8 @@ msgid ""
 "not a git repository (or any parent up to mount point %s)\n"
 "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."
 msgstr ""
-"no és un repositori de git (ni cap pare fins al punt de muntatge %s)\n"
+"no és un repositori de git (ni existeix cap pare fins al punt de muntatge "
+"%s)\n"
 "S'atura a la frontera de sistema de fitxers (GIT_DISCOVERY_ACROSS_FILESYSTEM "
 "no està establert)."
 
@@ -21077,6 +21238,10 @@ msgstr "no s'estan copiant plantilles de «%s»: %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "nom de branca inicial no vàlid: «%s»"
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "reinicialització: s'ha ignorat --initial-branch=%s"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "no s'ha pogut gestionar el tipus de fitxer %d"
@@ -21088,14 +21253,16 @@ msgstr "no s'ha pogut moure %s a %s"
 msgid "attempt to reinitialize repository with different hash"
 msgstr "s'ha intentat reinicialitzar el repositori amb un resum diferent"
 
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr ""
+"s'ha intentat reactivar el repositori amb un format d'emmagatzematge de "
+"referència diferent"
+
 #, c-format
 msgid "%s already exists"
 msgstr "%s ja existeix"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "reinicialització: s'ha ignorat --initial-branch=%s"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr "S'ha reinicialitzat el repositori compartit existent del Git en %s%s\n"
@@ -21365,12 +21532,6 @@ msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr ""
 "nombre d'entrades a l'arbre de la memòria cau a invalidar (per defecte 0)"
 
-msgid "unhandled options"
-msgstr "opcions no gestionades"
-
-msgid "error preparing revisions"
-msgstr "s'ha produït un error en preparar les revisions"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "la comissió %s no està marcada com abastable"
@@ -21523,9 +21684,6 @@ msgstr "el protocol no permet establir el camí del servei remot"
 msgid "invalid remote service path"
 msgstr "el camí del servei remot no és vàlid"
 
-msgid "operation not supported by protocol"
-msgstr "opció no admesa pel protocol"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "no es pot connectar al subservei %s"
@@ -21657,10 +21815,6 @@ msgid "support for protocol v2 not implemented yet"
 msgstr ""
 "encara no s'ha implementat la compatibilitat amb la versió v2 del protocol"
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "valor desconegut per al config «%s»': %s"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "no es permet el transport «%s»"
@@ -21714,6 +21868,9 @@ msgid "could not retrieve server-advertised bundle-uri list"
 msgstr ""
 "no s'ha pogut recuperar la llista de paquets d'URI anunciats pel servidor"
 
+msgid "operation not supported by protocol"
+msgstr "opció no admesa pel protocol"
+
 msgid "too-short tree object"
 msgstr "objecte d'arbre massa curt"
 
@@ -22555,6 +22712,10 @@ msgstr "addicionalment, el vostre índex conté canvis sense cometre."
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "no es pot %s: El vostre índex conté canvis sense cometre."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "estil desconegut «%s» donat per a «%s»"
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
@@ -22950,64 +23111,3 @@ msgstr "S'està ometent %s amb el sufix de còpia de seguretat «%s».\n"
 #, perl-format
 msgid "Do you really want to send %s? [y|N]: "
 msgstr "Esteu segur que voleu enviar %s? [y|N]: "
-
-#, c-format
-#~ msgid "options '%s=%s' and '%s=%s' cannot be used together"
-#~ msgstr "les opcions «%s=%s» i «%s=%s» no es poden usar juntes"
-
-#, c-format
-#~ msgid "%s : incompatible with something else"
-#~ msgstr "%s: és incompatible amb alguna altra cosa"
-
-#~ msgid "Could not write patch"
-#~ msgstr "No s'ha pogut escriure el pedaç"
-
-#, c-format
-#~ msgid "Could not stat '%s'"
-#~ msgstr "No s'ha pogut fer stat a «%s»"
-
-#, c-format
-#~ msgid "Cannot delete branch '%s' checked out at '%s'"
-#~ msgstr "No es pot suprimir la branca «%s» agafada a «%s»"
-
-#~ msgid "unable to write new_index file"
-#~ msgstr "no s'ha pogut escriure el fitxer new_index"
-
-#~ msgid "do not apply config rules"
-#~ msgstr "no apliquis les regles de configuració"
-
-#~ msgid "join whitespace-continued values"
-#~ msgstr "uneix els valors continus amb espais en blanc"
-
-#~ msgid "set parsing options"
-#~ msgstr "estableix les opcions d'anàlisi"
-
-#~ msgid "cannot move directory over file"
-#~ msgstr "no es pot moure un directori sobre un fitxer"
-
-#~ msgid "cannot use --filter without --stdout"
-#~ msgstr "no es pot utilitzar --filter sense --stdout"
-
-#~ msgid "cannot use --max-pack-size with --cruft"
-#~ msgstr "no es pot usar --max-pack-size amb --cruft"
-
-#~ msgid "--strategy requires --merge or --interactive"
-#~ msgstr "--strategy requereix --merge o --interactive"
-
-#, c-format
-#~ msgid ""
-#~ "commit-graph has generation number zero for commit %s, but non-zero "
-#~ "elsewhere"
-#~ msgstr ""
-#~ "el graf de comissions té nombre de generació zero per a la comissió %s, "
-#~ "però té no zero en altres llocs"
-
-#~ msgid "--merge-base only works with commits"
-#~ msgstr "--merge-base només funciona amb comissions"
-
-#~ msgid "scalar clone [<options>] [--] <repo> [<dir>]"
-#~ msgstr "scalar clone [<opcions>] [--] <repositori> [<dir>]"
-
-#, c-format
-#~ msgid "could not rename '%s' to '%s'"
-#~ msgstr "no s'ha pogut canviar el nom «%s» a «%s»"
index 95a185afd2b211ecdeaf70132cadc7f999a8df68..37d6c8099836c5f335f8007d363e170af75ad540 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -8,8 +8,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-09 11:29+0100\n"
-"PO-Revision-Date: 2023-11-10 14:28+0100\n"
+"POT-Creation-Date: 2024-02-17 18:07+0100\n"
+"PO-Revision-Date: 2024-02-17 18:14+0100\n"
 "Last-Translator: Ralf Thielow <ralf.thielow@gmail.com>\n"
 "Language-Team: German\n"
 "Language: de\n"
@@ -1473,6 +1473,10 @@ msgstr "die Option '%s' erfordert '%s'"
 msgid "Unexpected option --output"
 msgstr "Unerwartete Option --output"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "zusätzlicher Befehlszeilenparameter '%s'"
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Unbekanntes Archivformat '%s'"
@@ -1518,6 +1522,14 @@ msgstr "ignoriere übermäßig großen gitattribute-Blob '%s'"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "ungültiges --attr-source oder GIT_ATTR_SOURCE"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "konnte '%s' nicht lesen"
+
+#, c-format
+msgid "unable to read %s"
+msgstr "kann %s nicht lesen"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "Ungültiger Inhalt bzgl. Anführungszeichen in Datei '%s': %s"
@@ -1698,12 +1710,10 @@ msgstr ""
 msgid "not tracking: ambiguous information for ref '%s'"
 msgstr "kein Tracking: mehrdeutige Informationen für Referenz '%s'"
 
-#. #-#-#-#-#  branch.c.po  #-#-#-#-#
 #. TRANSLATORS: This is a line listing a remote with duplicate
 #. refspecs in the advice message below. For RTL languages you'll
 #. probably want to swap the "%s" and leading "  " space around.
 #.
-#. #-#-#-#-#  object-name.c.po  #-#-#-#-#
 #. TRANSLATORS: This is line item of ambiguous object output
 #. from describe_ambiguous_object() above. For RTL languages
 #. you'll probably want to swap the "%s" and leading " " space
@@ -2830,13 +2840,14 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "konnte Commit-Objekt für '%s' nicht nachschlagen"
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
+msgid "the branch '%s' is not fully merged"
+msgstr "der Branch '%s' ist nicht vollständig zusammengeführt"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
 msgstr ""
-"Der Branch '%s' ist nicht vollständig zusammengeführt.\n"
-"Wenn Sie sicher sind diesen Branch zu entfernen, führen Sie 'git branch -D "
-"%s' aus."
+"Wenn Sie sicher sind, dass Sie den Branch löschen wollen, führen Sie 'git "
+"branch -D %s' aus."
 
 msgid "update of config-file failed"
 msgstr "Aktualisierung der Konfigurationsdatei fehlgeschlagen."
@@ -3905,8 +3916,8 @@ msgstr "Auschecken erzwingen (verwirft lokale Änderungen)"
 msgid "new-branch"
 msgstr "neuer Branch"
 
-msgid "new unparented branch"
-msgstr "neuer Branch ohne Eltern-Commit"
+msgid "new unborn branch"
+msgstr "neuer ungeborener Branch"
 
 msgid "update ignored files (default)"
 msgstr "ignorierte Dateien aktualisieren (Standard)"
@@ -4160,9 +4171,6 @@ msgstr ""
 "clean.requireForce standardmäßig auf \"true\" gesetzt und weder -i, -n noch -"
 "f gegeben; \"clean\" verweigert"
 
-msgid "-x and -X cannot be used together"
-msgstr "-x und -X können nicht gemeinsam verwendet werden"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<Optionen>] [--] <Repository> [<Verzeichnis>]"
 
@@ -4256,6 +4264,9 @@ msgstr ".git-Verzeichnis"
 msgid "separate git dir from working tree"
 msgstr "Git-Verzeichnis vom Arbeitsverzeichnis separieren"
 
+msgid "specify the reference format to use"
+msgstr "das zu verwendende Referenzformat angeben"
+
 msgid "key=value"
 msgstr "Schlüssel=Wert"
 
@@ -4379,12 +4390,9 @@ msgstr "Zu viele Argumente."
 msgid "You must specify a repository to clone."
 msgstr "Sie müssen ein Repository zum Klonen angeben."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri ist inkompatibel mit --depth, --shallow-since und --shallow-"
-"exclude"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "unbekanntes Speicherformat für Referenzen '%s'"
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4526,7 +4534,7 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <Verzeichnis>] [--append]\n"
 "                       [--split[=<Strategie>]] [--reachable | --stdin-packs "
@@ -6892,7 +6900,6 @@ msgstr "grep: Fehler beim Erzeugen eines Thread: %s"
 msgid "invalid number of threads specified (%d) for %s"
 msgstr "ungültige Anzahl von Threads (%d) für %s angegeben"
 
-#. #-#-#-#-#  grep.c.po  #-#-#-#-#
 #. TRANSLATORS: %s is the configuration
 #. variable for tweaking threads, currently
 #. grep.threads
@@ -6905,6 +6912,10 @@ msgstr "keine Unterstützung von Threads, '%s' wird ignoriert"
 msgid "unable to read tree (%s)"
 msgstr "konnte \"Tree\"-Objekt (%s) nicht lesen"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "konnte \"Tree\"-Objekt (%s) nicht lesen"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "kann \"grep\" nicht mit Objekten des Typs %s durchführen"
@@ -7326,10 +7337,6 @@ msgstr "ernsthafte Inkonsistenz nach Dekomprimierung"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "SHA1 KOLLISION MIT %s GEFUNDEN !"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "kann %s nicht lesen"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "Kann existierende Informationen zu Objekt %s nicht lesen."
@@ -7470,11 +7477,13 @@ msgstr "fsck Fehler beim Packen von Objekten"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<Vorlagenverzeichnis>]\n"
 "         [--separate-git-dir <Git-Verzeichnis>] [--object-format=<Format>]\n"
+"         [--ref-format=<Format>]\n"
 "         [-b <Branchname> | --initial-branch=<Branchname>]\n"
 "         [--shared[=<Berechtigungen>]] [<Verzeichnis>]"
 
@@ -8195,6 +8204,13 @@ msgstr ""
 "git merge-file [<Optionen>] [-L <Name1> [-L <orig> [-L <Name2>]]] <Datei1> "
 "<orig-Datei> <Datei2>"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"Option diff-algorithm akzeptiert: \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+
 msgid "send results to standard output"
 msgstr "Ergebnisse zur Standard-Ausgabe senden"
 
@@ -8216,6 +8232,12 @@ msgstr "bei Konflikten ihre Variante verwenden"
 msgid "for conflicts, use a union version"
 msgstr "bei Konflikten eine gemeinsame Variante verwenden"
 
+msgid "<algorithm>"
+msgstr "<Algorithmus>"
+
+msgid "choose a diff algorithm"
+msgstr "einen Algorithmus für Änderungen wählen"
+
 msgid "for conflicts, use this marker size"
 msgstr "bei Konflikten diese Kennzeichnungslänge verwenden"
 
@@ -8307,9 +8329,6 @@ msgstr "--trivial-merge ist mit allen anderen Optionen inkompatibel"
 msgid "unknown strategy option: -X%s"
 msgstr "unbekannte Strategie-Option: -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base ist inkompatibel mit --stdin"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "Fehlerhafte Eingabezeile: '%s'."
@@ -9264,6 +9283,10 @@ msgstr "Komprimiere Objekte"
 msgid "inconsistency with delta count"
 msgstr "Inkonsistenz mit der Anzahl von Deltas"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "ungültiger Wert für pack.allowPackReuse: '%s'"
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9533,10 +9556,10 @@ msgstr "Objekte aufzählen"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Gesamt %<PRIu32> (Delta %<PRIu32>), Wiederverwendet %<PRIu32> (Delta "
-"%<PRIu32>), Pack wiederverwendet %<PRIu32>"
+"%<PRIu32>), Paket wiederverwendet %<PRIu32> (von %<PRIuMAX>)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10547,13 +10570,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "Schalter `C' erwartet einen numerischen Wert."
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"apply-Optionen sind mit rebase.autoSquash nicht kompatibel. Erwägen Sie das "
-"Hinzufügen von --no-autosquash"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -11567,6 +11583,77 @@ msgstr "--convert-graft-file erwartet keine Argumente"
 msgid "only one pattern can be given with -l"
 msgstr "Mit -l kann nur ein Muster angegeben werden"
 
+msgid "need some commits to replay"
+msgstr "zum erneuten Abspielen werden Commits benötigt"
+
+msgid "--onto and --advance are incompatible"
+msgstr "--onto und --advance sind inkompatibel"
+
+msgid "all positive revisions given must be references"
+msgstr "alle angegebenen positiven Commits müssen Referenzen sein"
+
+msgid "argument to --advance must be a reference"
+msgstr "Argument für --advance muss eine Referenz sein"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"kann Ziel nicht mit mehreren Quellen erweitern, da die Reihenfolge unklar "
+"wäre"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"kann nicht implizit bestimmen, ob es sich um eine --advance oder --onto "
+"Operation handelt"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"kann Ziel nicht mit mehreren Quell-Branches erweitern, da die Reihenfolge "
+"unklar wäre"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "kann nicht implizit die richtige Basis für --onto bestimmen"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(EXPERIMENTELL!) git replay ([--contained] --onto <neue-Basis> | --advance "
+"<Branch>) <Commitbereich>..."
+
+msgid "make replay advance given branch"
+msgstr "angegebenen Branch durch neues Abspielen erweitern"
+
+msgid "replay onto given commit"
+msgstr "auf angegebenen Commit neu abspielen"
+
+msgid "advance all branches contained in revision-range"
+msgstr "alle Branches erweitern, die in Commitbereich liegen"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "Option --onto oder --advance erforderlich"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"einige Optionen für das Abgehen von Commits werden außer Kraft gesetzt, da "
+"das '%s' Bit in 'struct rev_info' erzwungen wird"
+
+msgid "error preparing revisions"
+msgstr "Fehler beim Vorbereiten der Commits"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "erneutes Abspielen bis zum Root-Commit wird noch nicht unterstützt!"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "erneutes Abspielen von Merge-Commits wird noch nicht unterstützt!"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr ""
@@ -11778,15 +11865,6 @@ msgstr "--prefix benötigt ein Argument"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "unbekannter Modus für --abbrev-ref: %s"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden kann nicht zusammen mit --branches verwendet werden"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden kann nicht zusammen mit --tags verwendet werden"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden kann nicht zusammen mit --remotes verwendet werden"
-
 msgid "this operation must be run in a work tree"
 msgstr "Diese Operation muss in einem Arbeitsverzeichnis ausgeführt werden."
 
@@ -12202,10 +12280,6 @@ msgstr ""
 "Referenzen von der Standard-Eingabe anzeigen, die sich nicht im lokalen "
 "Repository befinden"
 
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "es kann nur eines von '%s', '%s' oder '%s' angegeben werden"
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -13717,33 +13791,29 @@ msgstr "Kein möglicher Quell-Branch, der auf '--orphan' schließen lässt"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
-"Wenn Sie ein Arbeitsverzeichnis erstellen möchten, um einen neuen verwaisten "
-"Branch\n"
-"(Branch ohne Commits) für dieses Repository zu erstellen, können Sie dies "
-"mit\n"
-"der Option --orphan tun:\n"
+"Wenn Sie ein Arbeitsverzeichnis erstellen möchten, welches einen neuen\n"
+"ungeborenen Branch (Branch ohne Commits) für dieses Repository erzeugt,\n"
+"können Sie dies mit der Option --orphan tun:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
-"Wenn Sie ein Arbeitsverzeichnis erstellen möchten, um einen neuen verwaisten "
-"Branch\n"
-"(Branch ohne Commits) für dieses Repository zu erstellen, können Sie dies "
-"mit\n"
-"der Option --orphan tun:\n"
+"Wenn Sie ein Arbeitsverzeichnis erstellen möchten, welches einen neuen\n"
+"ungeborenen Branch (Branch ohne Commits) für dieses Repository erzeugt,\n"
+"können Sie dies mit der Option --orphan tun:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 
@@ -13805,6 +13875,10 @@ msgstr "Konnte Verzeichnis '%s' nicht erstellen."
 msgid "initializing"
 msgstr "initialisiere"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "konnte erstelltes Arbeitsverzeichnis '%s' nicht finden"
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "Bereite Arbeitsverzeichnis vor (neuer Branch '%s')"
@@ -13845,10 +13919,6 @@ msgstr ""
 "Referenz zu überschreiben\n"
 "oder rufen Sie diese zuerst ab"
 
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "'%s' und '%s' können nicht zusammen verwendet werden"
-
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr ""
 "<Branch> auschecken, auch wenn dieser bereits in einem anderen "
@@ -13860,8 +13930,8 @@ msgstr "neuen Branch erstellen"
 msgid "create or reset a branch"
 msgstr "Branch erstellen oder umsetzen"
 
-msgid "create unborn/orphaned branch"
-msgstr "ungeborenen/verwaisten Branch erstellen"
+msgid "create unborn branch"
+msgstr "ungeborenen Branch erzeugen"
 
 msgid "populate the new working tree"
 msgstr "das neue Arbeitsverzeichnis auschecken"
@@ -13886,11 +13956,8 @@ msgstr ""
 "die Optionen '%s', '%s' und '%s' können nicht gemeinsam verwendet werden"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "die Optionen '%s' und '%s' können nicht gemeinsam verwendet werden"
-
-msgid "<commit-ish>"
-msgstr "<Commit-Angabe>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "Option '%s' und commit-ish können nicht gemeinsam verwendet werden"
 
 msgid "added with --lock"
 msgstr "mit --lock hinzugefügt"
@@ -14541,6 +14608,11 @@ msgstr "ungepackte Objekte in einem Repository packen"
 msgid "Create, list, delete refs to replace objects"
 msgstr "Referenzen für ersetzende Objekte erstellen, auflisten, löschen"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"EXPERIMENTELL: Commits auf neuer Basis abspielen, funktioniert auch mit Bare-"
+"Repositories"
+
 msgid "Generates a summary of pending changes"
 msgstr "eine Übersicht über ausstehende Änderungen generieren"
 
@@ -14785,6 +14857,32 @@ msgstr "Ein Werkzeug zur Verwaltung großer Git-Repositories"
 msgid "commit-graph file is too small"
 msgstr "Commit-Graph-Datei ist zu klein"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "Commit-Graph OID fanout Chunk hat die falsche Größe"
+
+msgid "commit-graph fanout values out of order"
+msgstr "Commit-Graph fanout-Werte sind nicht in Ordnung"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "Commit-Graph OID Lookup Chunk hat die falsche Größe"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "Commit-Graph Commit Daten Chunk hat die falsche Größe"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr "Commit-Graph Generations Chunk hat die falsche Größe"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "Commit-Graph changed-path Index Chunk ist zu klein"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"ignoriere zu kleinen Chunk für geänderte Pfade (%<PRIuMAX> < %<PRIuMAX>) in "
+"Commit-Graph-Datei"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr "Commit-Graph-Signatur %X stimmt nicht mit Signatur %X überein"
@@ -14801,6 +14899,16 @@ msgstr "Hash-Version des Commit-Graph %X stimmt nicht mit Version %X überein"
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "Commit-Graph-Datei ist zu klein, um %u Chunks zu enthalten"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr "Commit-Graph benötigter OID fanout Chunk fehlt oder ist beschädigt"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr "Commit-Graph benötigter OID lookup Chunk fehlt oder ist beschädigt"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr ""
+"Commit-Graph erforderlicher Commit-Daten Chunk fehlt oder ist beschädigt"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "Commit-Graph hat keinen Basis-Graph-Chunk"
 
@@ -14814,6 +14922,9 @@ msgstr "Commit-Graph Verkettung stimmt nicht überein"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "Anzahl der Commits im Basisgraph zu hoch: %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "Commit-Graph Chain-Datei zu klein"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr "Ungültige Commit-Graph Verkettung: Zeile '%s' ist kein Hash"
@@ -14834,6 +14945,9 @@ msgstr "Commit-Graph erfordert Überlaufgenerierungsdaten, aber hat keine"
 msgid "commit-graph overflow generation data is too small"
 msgstr "Commit-Graph Überlaufgenerierungsdaten sind zu klein"
 
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "commit-graph extra-edges Zeiger außerhalb der Grenzen"
+
 msgid "Loading known commits in commit graph"
 msgstr "Lade bekannte Commits in Commit-Graph"
 
@@ -16000,6 +16114,10 @@ msgstr ""
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "Unbekannter Wert in Konfigurationsvariable 'diff.submodule': '%s'"
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "Unbekannter Wert für Konfiguration '%s': %s"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -16082,13 +16200,6 @@ msgstr "ungültiges --color-moved Argument: %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "ungültiger Modus '%s' in --color-moved-ws"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"Option diff-algorithm akzeptiert: \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "ungültiges Argument für %s"
@@ -16132,8 +16243,8 @@ msgstr "maschinenlesbare Ausgabe von --stat"
 msgid "output only the last line of --stat"
 msgstr "nur die letzte Zeile von --stat ausgeben"
 
-msgid "<param1,param2>..."
-msgstr "<Parameter1,Parameter2>..."
+msgid "<param1>,<param2>..."
+msgstr "<Parameter1>,<Parameter2>..."
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -16144,8 +16255,8 @@ msgstr ""
 msgid "synonym for --dirstat=cumulative"
 msgstr "Synonym für --dirstat=cumulative"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "Synonym für --dirstat=files,Parameter1,Parameter2..."
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "Synonym für --dirstat=files,<Parameter1>,<Parameter2>..."
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr ""
@@ -16328,12 +16439,6 @@ msgstr "Änderungen durch Nutzung des Algorithmus \"Patience Diff\" erzeugen"
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "Änderungen durch Nutzung des Algorithmus \"Histogram Diff\" erzeugen"
 
-msgid "<algorithm>"
-msgstr "<Algorithmus>"
-
-msgid "choose a diff algorithm"
-msgstr "einen Algorithmus für Änderungen wählen"
-
 msgid "<text>"
 msgstr "<Text>"
 
@@ -17547,7 +17652,7 @@ msgstr ""
 #. conflict in a submodule. The first argument is the submodule
 #. name, and the second argument is the abbreviated id of the
 #. commit that needs to be merged.  For example:
-#.  - go to submodule (mysubmodule), and either merge commit abc1234"
+#. - go to submodule (mysubmodule), and either merge commit abc1234"
 #.
 #, c-format
 msgid ""
@@ -17848,6 +17953,13 @@ msgstr "Lesen des Zwischenspeichers fehlgeschlagen"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "Multi-Pack-Index OID fanout hat die falsche Größe"
 
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"Ungültige oid fanout Reihenfolge: fanout[%d] = %<PRIx32> > %<PRIx32> = "
+"fanout[%d]"
+
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "multi-pack-index OID-Lookup-Chunk hat die falsche Größe"
 
@@ -17898,6 +18010,13 @@ msgstr "Falsche Reihenfolge bei Multi-Pack-Index Pack-Namen: '%s' vor '%s'"
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "Ungültige pack-int-id: %u (%u Pakete insgesamt)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX enthält keinen BTMP-Chunk"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "konnte Bitmap-Paket nicht laden %<PRIu32>"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr ""
 "Multi-Pack-Index speichert einen 64-Bit Offset, aber off_t ist zu klein"
@@ -17983,13 +18102,6 @@ msgstr "Prüfsumme nicht korrekt"
 msgid "Looking for referenced packfiles"
 msgstr "Suche nach referenzierten Pack-Dateien"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr ""
-"Ungültige oid fanout Reihenfolge: fanout[%d] = %<PRIx32> > %<PRIx32> = "
-"fanout[%d]"
-
 msgid "the midx contains no oid"
 msgstr "das midx enthält keine oid"
 
@@ -18304,7 +18416,7 @@ msgstr "%s [ungültiges Objekt]"
 #. TRANSLATORS: This is a line of ambiguous commit
 #. object output. E.g.:
 #. *
-#.    "deadbeef commit 2021-01-01 - Some Commit Message"
+#. "deadbeef commit 2021-01-01 - Some Commit Message"
 #.
 #, c-format
 msgid "%s commit %s - %s"
@@ -18313,7 +18425,7 @@ msgstr "%s Commit %s - %s"
 #. TRANSLATORS: This is a line of ambiguous
 #. tag object output. E.g.:
 #. *
-#.    "deadbeef tag 2022-01-01 - Some Tag Message"
+#. "deadbeef tag 2022-01-01 - Some Tag Message"
 #. *
 #. The second argument is the YYYY-MM-DD found
 #. in the tag.
@@ -18329,7 +18441,7 @@ msgstr "%s Tag %s - %s"
 #. tag object output where we couldn't parse
 #. the tag itself. E.g.:
 #. *
-#.    "deadbeef [bad tag, could not parse it]"
+#. "deadbeef [bad tag, could not parse it]"
 #.
 #, c-format
 msgid "%s [bad tag, could not parse it]"
@@ -18525,6 +18637,9 @@ msgstr "Multi-Pack-Bitmap fehlt erforderlicher Reverse-Index"
 msgid "could not open pack %s"
 msgstr "konnte Paket '%s' nicht öffnen"
 
+msgid "could not determine MIDX preferred pack"
+msgstr "konnte das von MIDX bevorzugte Paket nicht ermitteln"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
 msgstr "bevorzugtes Paket (%s) ist ungültig"
@@ -18547,6 +18662,12 @@ msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr ""
 "fehlerhafte ewah-Bitmap: abgeschnittener Header für Bitmap des Commits \"%s\""
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr ""
+"Paket kann nicht geladen werden: '%s', Deaktivierung der Paket-"
+"Wiederverwendung"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "Objekt '%s' nicht im Typ Bitmaps gefunden"
@@ -18638,6 +18759,9 @@ msgstr "ungültige rev-index Position bei %<PRIu64>: %<PRIu32> != %<PRIu32>"
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "multi-pack-index Reverse-Index Chunk hat die falsche Größe"
 
+msgid "could not determine preferred pack"
+msgstr "konnte das bevorzugte Paket nicht bestimmen"
+
 msgid "cannot both write and verify reverse index"
 msgstr ""
 "Reverse-Index kann nicht gleichzeitig geschrieben und verifiziert werden"
@@ -18703,10 +18827,6 @@ msgstr ""
 "%s erwartet einen nicht-negativen Integer-Wert mit einem optionalen k/m/g "
 "Suffix"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s ist inkompatibel mit %s."
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "Mehrdeutige Option: %s (kann --%s%s oder --%s%s sein)"
@@ -19030,10 +19150,6 @@ msgstr "Konnte Datei '%s' nicht indizieren."
 msgid "unable to add '%s' to index"
 msgstr "Konnte '%s' nicht dem Index hinzufügen."
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "konnte '%s' nicht lesen"
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "'%s' scheint eine Datei und ein Verzeichnis zu sein"
@@ -19612,10 +19728,6 @@ msgstr "'%s' existiert; kann '%s' nicht erstellen"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "kann '%s' und '%s' nicht zur selben Zeit verarbeiten"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "konnte Referenz %s nicht löschen"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "konnte Referenz %s nicht entfernen: %s"
@@ -19810,16 +19922,13 @@ msgid ""
 "\n"
 "Neither worked, so we gave up. You must fully qualify the ref."
 msgstr ""
-"Das angegebene Ziel ist kein vollständiger Referenzname (startet mit \"refs/"
-"\").\n"
-"Wir versuchten zu erraten, was Sie meinten, mit:\n"
+"Das angegebene Ziel ist kein vollständiger Referenzname (startet mit\n"
+"\"refs/\"). Wir versuchten zu erraten, was Sie meinten, mit:\n"
 "\n"
 "- Suche einer Referenz, die mit '%s' übereinstimmt, auf der Remote-Seite\n"
-"- Prüfung, ob die versendete <Quelle> ('%s') eine Referenz in \"refs/{heads,"
-"tags}\"\n"
-"  ist, in dessen Falle wir einen entsprechenden refs/{heads,tags} Präfix "
-"auf\n"
-"  der Remote-Seite hinzufügen würden.\n"
+"- Prüfung, ob die versendete <Quelle> ('%s') eine Referenz in\n"
+"  \"refs/{heads,tags}/\" ist, in dessen Falle wir einen entsprechenden\n"
+"  refs/{heads,tags}/ Präfix auf der Remote-Seite hinzufügen würden.\n"
 "\n"
 "Keines hat funktioniert, sodass wir aufgegeben haben. Sie müssen die\n"
 "Referenz mit vollqualifizierten Namen angeben."
@@ -21004,6 +21113,9 @@ msgstr "Beim Anwenden des automatischen Stash traten Konflikte auf."
 msgid "Autostash exists; creating a new stash entry."
 msgstr "Automatischer Stash existiert; ein neuer Stash-Eintrag wird erstellt."
 
+msgid "autostash reference is a symref"
+msgstr "Referenz für autostash ist eine symbolische Referenz"
+
 msgid "could not detach HEAD"
 msgstr "konnte HEAD nicht loslösen"
 
@@ -21323,6 +21435,10 @@ msgstr "kopiere keine Vorlagen von '%s': %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "ungültiger initialer Branchname: '%s'"
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "Neu-Initialisierung: --initial-branch=%s ignoriert"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "kann nicht mit Dateityp %d umgehen"
@@ -21334,14 +21450,16 @@ msgstr "konnte %s nicht nach %s verschieben"
 msgid "attempt to reinitialize repository with different hash"
 msgstr "Versuch, das Repository mit einem anderen Hash zu reinitialisieren"
 
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr ""
+"Versuch, das Repository mit einem anderen Referenzspeicherformat neu zu "
+"initialisieren"
+
 #, c-format
 msgid "%s already exists"
 msgstr "%s existiert bereits"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "Neu-Initialisierung: --initial-branch=%s ignoriert"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr "Bestehendes verteiltes Git-Repository in %s%s neuinitialisiert\n"
@@ -21611,12 +21729,6 @@ msgstr ""
 "Anzahl der Einträge im Cache-Verzeichnis, die ungültig gemacht werden sollen "
 "(Standardwert 0)"
 
-msgid "unhandled options"
-msgstr "unbehandelte Optionen"
-
-msgid "error preparing revisions"
-msgstr "Fehler beim Vorbereiten der Commits"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "Commit %s ist nicht als erreichbar gekennzeichnet."
@@ -21772,9 +21884,6 @@ msgstr ""
 msgid "invalid remote service path"
 msgstr "ungültiger Remote-Service Pfad."
 
-msgid "operation not supported by protocol"
-msgstr "die Operation wird von dem Protokoll nicht unterstützt"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "kann keine Verbindung zu Subservice %s herstellen"
@@ -21904,10 +22013,6 @@ msgstr "Konnte transport.color.* Konfiguration nicht parsen."
 msgid "support for protocol v2 not implemented yet"
 msgstr "Unterstützung für Protokoll v2 noch nicht implementiert."
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "Unbekannter Wert für Konfiguration '%s': %s"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "Übertragungsart '%s' nicht erlaubt."
@@ -21961,6 +22066,9 @@ msgstr "bundle-uri Operation wird vom Protokoll nicht unterstützt"
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "konnte die vom Server angekündigte bundle-uri-Liste nicht abrufen"
 
+msgid "operation not supported by protocol"
+msgstr "die Operation wird von dem Protokoll nicht unterstützt"
+
 msgid "too-short tree object"
 msgstr "zu kurzes Tree-Objekt"
 
@@ -22849,6 +22957,10 @@ msgid "cannot %s: Your index contains uncommitted changes."
 msgstr ""
 "%s nicht möglich: Die Staging-Area enthält nicht committete Änderungen."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "unbekannter Stil '%s' für '%s' angegeben"
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
index ee2e610ef1469c351f9d7825319bc68a71e73e9c..736a90f6bb68e1b25f3a666513e0b2de4930cb12 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -80,8 +80,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-08 04:57+0000\n"
-"PO-Revision-Date: 2023-11-11 10:00+0100\n"
+"POT-Creation-Date: 2024-02-16 19:18+0100\n"
+"PO-Revision-Date: 2024-02-16 19:19+0100\n"
 "Last-Translator: Cédric Malard <c.malard-git@valdun.net>\n"
 "Language-Team: Jean-Noël Avila <jn.avila@free.fr>\n"
 "Language: fr\n"
@@ -1525,6 +1525,10 @@ msgstr "l'option '%s' requiert '%s'"
 msgid "Unexpected option --output"
 msgstr "Option --output inattendue"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "paramètre de commande supplémentaire '%s'"
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Format d'archive inconnu '%s'"
@@ -1570,6 +1574,14 @@ msgstr "blob gitattributes trop gros ignoré '%s'"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "mauvais --attr-source ou GIT_ATTR_SOURCE"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "fstat de '%s' impossible"
+
+#, c-format
+msgid "unable to read %s"
+msgstr "impossible de lire %s"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "Contenu mal cité dans le fichier '%s' : %s"
@@ -2874,12 +2886,12 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "impossible de rechercher l'objet commit pour '%s'"
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"la branche '%s' n'est pas totalement fusionnée.\n"
-"Si vous souhaitez réellement la supprimer, lancez 'git branch -D %s'"
+msgid "the branch '%s' is not fully merged"
+msgstr "la branche '%s' n'est pas complètement fusionnée"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "Si vous souhaitez réellement la supprimer, lancez 'git branch -D %s'"
 
 msgid "update of config-file failed"
 msgstr "échec de la mise à jour du fichier de configuration"
@@ -3937,8 +3949,8 @@ msgstr "forcer l'extraction (laisser tomber les modifications locales)"
 msgid "new-branch"
 msgstr "nouvelle branche"
 
-msgid "new unparented branch"
-msgstr "nouvelle branche sans parent"
+msgid "new unborn branch"
+msgstr "nouvelle branche non née"
 
 msgid "update ignored files (default)"
 msgstr "mettre à jour les fichiers ignorés (par défaut)"
@@ -4192,9 +4204,6 @@ msgstr ""
 "clean.requireForce à true par défaut et ni -i, -n ou -f fourni ; refus de "
 "nettoyer"
 
-msgid "-x and -X cannot be used together"
-msgstr "-x et -X ne peuvent pas être utilisés ensemble"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<options>] [--] <dépôt> [<répertoire>]"
 
@@ -4285,6 +4294,9 @@ msgstr "gitdir"
 msgid "separate git dir from working tree"
 msgstr "séparer le répertoire git de la copie de travail"
 
+msgid "specify the reference format to use"
+msgstr "spécifier le format de réference à utiliser"
+
 msgid "key=value"
 msgstr "clé=valeur"
 
@@ -4407,12 +4419,9 @@ msgstr "Trop d'arguments."
 msgid "You must specify a repository to clone."
 msgstr "Vous devez spécifier un dépôt à cloner."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri est incompatible avec --depth, --shallow-since, et --shallow-"
-"exclude"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "Format de stockage de réf inconnu '%s'"
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4546,14 +4555,14 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <rép>] [--append]\n"
 "                       [--split[=<stratégie>]] [--reachable | --stdin-packs "
 "| --stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <options de division>"
+"                       <options-de-division>"
 
 msgid "dir"
 msgstr "répertoire"
@@ -6906,6 +6915,10 @@ msgstr "pas de support des fils, ignore %s"
 msgid "unable to read tree (%s)"
 msgstr "impossible de lire l'arbre (%s)"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "impossible de lire l'arbre %s"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "impossible de faire un grep sur un objet de type %s"
@@ -7324,10 +7337,6 @@ msgstr "grave incohérence dans la décompression (inflate)"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "COLLISION SHA1 TROUVÉE AVEC %s !"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "impossible de lire %s"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "impossible de lire l'information existante de l'objet %s"
@@ -7469,12 +7478,14 @@ msgstr "erreur de fsck dans les objets paquets"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
-"git init [-q | --quiet] [--bare] [--template=<répertoire-modèle>]\n"
-"         [--separate-git-dir <rép-git>] [--object-format=<format>]\\n\"\n"
-"         [-b <nom-de-branche> | --initial-branch=<nom-de-branche>]\\n\"\n"
+"git init [-q | --quiet] [--bare] [--template=<répertoire-de-modèles>]\n"
+"         [--separate-git-dir <rép-git>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
+"         [-b <nom-de-branch> | --initial-branch=<nom-de-branche>]\n"
 "         [--shared[=<permissions>]] [<répertoire>]"
 
 msgid "permissions"
@@ -8204,6 +8215,13 @@ msgstr ""
 "git merge-file [<options>] [-L <nom1> [-L <orig> [-L <nom2>]]] <fichier1> "
 "<fichier-orig> <fichier2>"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"l'option diff-algorithm accept \"myers\", \"minimal\", \"patience\" et "
+"\"histogram\""
+
 msgid "send results to standard output"
 msgstr "envoyer les résultats sur la sortie standard"
 
@@ -8225,6 +8243,12 @@ msgstr "pour les conflits, utiliser leur version (their)"
 msgid "for conflicts, use a union version"
 msgstr "pour les conflits, utiliser l'ensemble des versions"
 
+msgid "<algorithm>"
+msgstr "<algorithme>"
+
+msgid "choose a diff algorithm"
+msgstr "choisir un algorithme de différence"
+
 msgid "for conflicts, use this marker size"
 msgstr "pour les conflits, utiliser cette taille de marqueur"
 
@@ -8315,9 +8339,6 @@ msgstr "--trivial-merge est incompatible avec d'autres options"
 msgid "unknown strategy option: -X%s"
 msgstr "option de stratégie inconnue : -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base est incompatible avec --stdin"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "ligne en entrée malformée : '%s'."
@@ -9264,6 +9285,10 @@ msgstr "Compression des objets"
 msgid "inconsistency with delta count"
 msgstr "inconsistance dans le compte de delta"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "valeur invalide de pack.allowPackReuse : '%s'"
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9527,10 +9552,10 @@ msgstr "Énumération des objets"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Total %<PRIu32> (delta %<PRIu32>), réutilisés %<PRIu32> (delta %<PRIu32>), "
-"réutilisés du pack %<PRIu32>"
+"réutilisés du paquet %<PRIu32> (depuis %<PRIuMAX>)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10519,13 +10544,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "l'option `C' attend un valeur numérique"
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"les options d'application sont incompatibles avec rebase.autoSquash. "
-"Considérez l'ajout de --no-autosquash"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -11535,6 +11553,77 @@ msgstr "--convert-graft-file ne supporte aucun argument"
 msgid "only one pattern can be given with -l"
 msgstr "-l n'accepte qu'un motifs"
 
+msgid "need some commits to replay"
+msgstr "commits requis pour pouvoir rejouer"
+
+msgid "--onto and --advance are incompatible"
+msgstr "--onto et --advance sont incompatibles"
+
+msgid "all positive revisions given must be references"
+msgstr "toutes les révisions positives fournies doivent être des références"
+
+msgid "argument to --advance must be a reference"
+msgstr "l'argument de --advance doit être une référence"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"impossible d'avancer la cible avec des sources multiples parce l'ordre ne "
+"serait pas total"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"impossible de déterminer implicitement s'il y a une opération --advance ou --"
+"onto"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"impossible d'avancer la cible sur des branches sources multiples parce que "
+"l'ordre ne serait pas total"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "impossible de déterminer implicitement une base correcte pour --onto"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <nouvelle-base> | --advance "
+"<branche>) <plage-de-révision>..."
+
+msgid "make replay advance given branch"
+msgstr "faire rejouer en avançant la branche indiquée"
+
+msgid "replay onto given commit"
+msgstr "rejouer par-dessus le commit indiqué"
+
+msgid "advance all branches contained in revision-range"
+msgstr "avancer toutes les branches contenues dans la plage-de-révisions"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "une option --onto ou --advance est obligatoire"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"certaines options de parcours de révs seront surchargées car le bit '%s' "
+"dans 'struct rev_info' sera forcé"
+
+msgid "error preparing revisions"
+msgstr "erreur lors de la préparation des révisions"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "rejouer jusqu'au commit racine n'est pas encore géré !"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "rejouer des commits de fusion n'est pas encore géré !"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr ""
@@ -11746,15 +11835,6 @@ msgstr "--prefix exige un argument"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "mode inconnu pour --abbrev-ref : %s"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden ne peut être utilisé avec --branches"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden ne peut pas être utilisé avec --tags"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden ne peut pas être utilisé avec --remotes"
-
 msgid "this operation must be run in a work tree"
 msgstr "cette opération doit être effectuée dans un arbre de travail"
 
@@ -12171,10 +12251,6 @@ msgstr ""
 "afficher les références de l'entrée standard qui ne sont pas dans le dépôt "
 "local"
 
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "les options '%s', '%s' et '%s' sont mutuellement exclusives"
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -13673,28 +13749,28 @@ msgstr "Aucune branche source possible, activation de '--orphan'"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
 "Si vous vouliez créer un arbre-de-travail contenant une nouvelle branche\n"
-"orpheline (une branche sans commit) pour ce dépôt, vous pouvez le faire\n"
+"non-née (une branche sans commit) pour ce dépôt, vous pouvez le faire\n"
 "en utilisant le drapeau --orphan :\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
 "Si vous vouliez créer un arbre-de-travail contenant une nouvelle branche\n"
-"orpheline (une branche sans commit) pour ce dépôt, vous pouvez le faire\n"
+"non-née (une branche sans commit) pour ce dépôt, vous pouvez le faire\n"
 "en utilisant le drapeau --orphan :\n"
 "\n"
 "    git worktree add --orphan %s\n"
@@ -13756,6 +13832,10 @@ msgstr "impossible de créer le répertoire de '%s'"
 msgid "initializing"
 msgstr "initialisation"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "impossible de trouver l'arbre-de-travail créé '%s'"
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "Préparation de l'arbre de travail (nouvelle branche '%s')"
@@ -13797,10 +13877,6 @@ msgstr ""
 "on arrête ; utilisez 'add -f' pour passe outre ou récupérer le distant en "
 "premier"
 
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "'%s' et '%s' ne peuvent pas être utilisées ensemble"
-
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr ""
 "extraire la <branche> même si elle est déjà extraite dans une autre copie de "
@@ -13812,8 +13888,8 @@ msgstr "créer une nouvelle branche"
 msgid "create or reset a branch"
 msgstr "créer ou réinitialiser une branche"
 
-msgid "create unborn/orphaned branch"
-msgstr "créer une branche non née/orpheline"
+msgid "create unborn branch"
+msgstr "créer une branche non née"
 
 msgid "populate the new working tree"
 msgstr "remplissage de la nouvelle copie de travail"
@@ -13835,11 +13911,9 @@ msgid "options '%s', '%s', and '%s' cannot be used together"
 msgstr "les options '%s', '%s' et '%s' ne peuvent pas être utilisées ensemble"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "les options '%s' et '%s' ne peuvent pas être utilisées ensemble"
-
-msgid "<commit-ish>"
-msgstr "<commit-esque>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr ""
+"l'option '%s' et des commit-esques ne peuvent pas être utilisés ensemble"
 
 msgid "added with --lock"
 msgstr "ajouté avec --lock"
@@ -14480,6 +14554,11 @@ msgstr "Empaqueter les objets non-empaquetés d'un dépôt"
 msgid "Create, list, delete refs to replace objects"
 msgstr "Créer, lister, supprimer des référence pour remplacer des objets"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"EXPÉRIMENTAL ; rejoue des commits sur une nouvelle base, fonctionne aussi "
+"avec les dépôts nus"
+
 msgid "Generates a summary of pending changes"
 msgstr "Générer une résumé des modifications en attentes"
 
@@ -14722,6 +14801,35 @@ msgstr "Un outil pour gérer les grands dépôts Git"
 msgid "commit-graph file is too small"
 msgstr "le graphe de commit est trop petit"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr ""
+"le tronçon de distribution d'oid du graphe de commit n'a pas la bonne taille"
+
+msgid "commit-graph fanout values out of order"
+msgstr "les valeurs de distribution du graphe de commit sont désordonnées"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr ""
+"le tronçon de recherche de l'OID du graphe de commits n'a pas la bonne taille"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "le tronçon de données du graphe de commit n'a pas la bonne taille"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr "le tronçon des générations du graphe de commit n'a pas la bonne taille"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr ""
+"le tronçon d'index des chemins modifiés du graphe de commit est trop petit"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"tronçon de chemin modifié dans le fichier de graphe de commits trop petit "
+"((%<PRIuMAX> < %<PRIuMAX>)) ignoré"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr ""
@@ -14741,6 +14849,21 @@ msgstr ""
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "le graphe de commit est trop petit pour contenir %u tronçons"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr ""
+"le tronçon de distribution des OID requis du graphe de commits est manquant "
+"ou corrompu"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr ""
+"le tronçon de recherche OID requis par le graphe de commits est manquant ou "
+"corrompu"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr ""
+"le tronçon d'étalement OID requis par le graphe de commits est manquant ou "
+"corrompu"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "le graphe de commit n'a pas de tronçon de graphes de base"
 
@@ -14754,6 +14877,9 @@ msgstr "la chaîne de graphe de commit ne correspond pas"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "nombre de commits dans le graphe de base trop haut : %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "la chaine du graphe de commit est trop petite"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr ""
@@ -14781,6 +14907,9 @@ msgstr ""
 "les données de génération de débordement du graphe de commits sont trop "
 "petites"
 
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "pointeur hors-gamme d'arêtes supplémentaires du graphe de commits"
+
 msgid "Loading known commits in commit graph"
 msgstr "Lecture des commits connus dans un graphe de commit"
 
@@ -15960,6 +16089,10 @@ msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr ""
 "Valeur inconnue pour la variable de configuration 'diff.submodule' : '%s'"
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "valeur inconnue pour la config '%s' : %s"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -16042,13 +16175,6 @@ msgstr "mauvais argument --color-moved : %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "mode invalide '%s' dans --color-moved-ws"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"l'option diff-algorithm accept \"myers\", \"minimal\", \"patience\" et "
-"\"histogram\""
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "argument invalide pour %s"
@@ -16092,8 +16218,8 @@ msgstr "--stat pour traitement automatique"
 msgid "output only the last line of --stat"
 msgstr "afficher seulement la dernière ligne de --stat"
 
-msgid "<param1,param2>..."
-msgstr "<param1,param2>..."
+msgid "<param1>,<param2>..."
+msgstr "<param1>,<param2>..."
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -16104,8 +16230,8 @@ msgstr ""
 msgid "synonym for --dirstat=cumulative"
 msgstr "synonyme pour --dirstat=cumulative"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "synonyme pour --dirstat=files,param1,param2..."
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "synonyme pour --dirstat=files,<param1>,<param2>..."
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr ""
@@ -16293,12 +16419,6 @@ msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr ""
 "générer un diff en utilisant l'algorithme de différence \"histogramme\""
 
-msgid "<algorithm>"
-msgstr "<algorithme>"
-
-msgid "choose a diff algorithm"
-msgstr "choisir un algorithme de différence"
-
 msgid "<text>"
 msgstr "<texte>"
 
@@ -17808,6 +17928,13 @@ msgstr "impossible de lire le cache"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "l'étalement de l'OID d'index multi-paquet n'a pas la bonne taille"
 
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"étalement oid en désordre : étalement[%d] = %<PRIx32> > %<PRIx32> = "
+"étalement[%d]"
+
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr ""
 "le tronçon de recherche de l'OID d'index multi-paquet n'a pas la bonne taille"
@@ -17868,6 +17995,13 @@ msgstr ""
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "mauvais pack-int-id : %u (%u paquets au total)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "le MIDX ne contient pas de tronçon BTMP"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "impossible d'ouvrir le paquet bitmappé %<PRIu32>"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr ""
 "l'index multi-paquet stocke un décalage en 64-bit, mais off_t est trop petit"
@@ -17953,13 +18087,6 @@ msgstr "somme de contrôle incorrecte"
 msgid "Looking for referenced packfiles"
 msgstr "Recherche de fichiers paquets référencés"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr ""
-"étalement oid en désordre : étalement[%d] = %<PRIx32> > %<PRIx32> = "
-"étalement[%d]"
-
 msgid "the midx contains no oid"
 msgstr "le midx ne contient aucun oid"
 
@@ -18486,6 +18613,9 @@ msgstr "l'index inverse requis manque dans l'index multi-paquet"
 msgid "could not open pack %s"
 msgstr "impossible d'ouvrir le paquet '%s'"
 
+msgid "could not determine MIDX preferred pack"
+msgstr "impossible de déterminer le paquet préféré de MIDX"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
 msgstr "le paquet préféré (%s) est invalide"
@@ -18507,6 +18637,10 @@ msgstr "table de recherche en bitmap corrompue : index de commit %u hors plage"
 msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr "bitmap ewah corrompue : entête tronqué pour la bitmap du commit '%s'"
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr "impossible de charger le paquet : '%s', pack-reuse désactivé"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "objet '%s' non trouvé dans les bitmaps de type"
@@ -18599,6 +18733,9 @@ msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr ""
 "le tronçon d'index inversé de l'index multi-paquet n'a pas la bonne taille"
 
+msgid "could not determine preferred pack"
+msgstr "impossible de déterminer le paquet préféré"
+
 msgid "cannot both write and verify reverse index"
 msgstr "impossible de lire et vérifier à la fois l'index inverse"
 
@@ -18662,10 +18799,6 @@ msgstr "%s n'est pas disponible"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s attend une valeur entière non négative avec une suffixe k/m/g"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s est incompatible avec %s"
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "option ambigüe : %s (devrait être --%s%s ou --%s%s)"
@@ -18994,10 +19127,6 @@ msgstr "indexation du fichier '%s' impossible"
 msgid "unable to add '%s' to index"
 msgstr "impossible d'ajouter '%s' à l'index"
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "fstat de '%s' impossible"
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "'%s' existe à la fois comme un fichier et un répertoire"
@@ -19574,10 +19703,6 @@ msgstr "'%s' existe ; impossible de créer '%s'"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "impossible de traiter '%s' et '%s' en même temps"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "impossible de supprimer la référence %s"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "impossible de supprimer la référence %s : %s"
@@ -19773,7 +19898,7 @@ msgid ""
 "Neither worked, so we gave up. You must fully qualify the ref."
 msgstr ""
 "La destination que vous avez fournie n'est pas un nom de référence complète\n"
-"(c'est-à-dire commençant par \"ref/\"). Essai d'approximation par :\n"
+"(c'est-à-dire commençant par \"refs/\"). Essai d'approximation par :\n"
 "\n"
 "- Recherche d'une référence qui correspond à '%s' sur le serveur distant.\n"
 "- Vérification si la <source> en cours de poussée ('%s')\n"
@@ -20961,6 +21086,9 @@ msgid "Autostash exists; creating a new stash entry."
 msgstr ""
 "Un remisage automatique existe ; création d'une nouvelle entrée de remisage."
 
+msgid "autostash reference is a symref"
+msgstr "la référence d'auto-remisage est une symref"
+
 msgid "could not detach HEAD"
 msgstr "impossible de détacher HEAD"
 
@@ -21279,6 +21407,10 @@ msgstr "pas de copie des modèles depuis '%s' : %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "nom de branche initiale invalide : '%s'"
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-initialisation : --initial-branch=%s ignoré"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "impossible de traiter le fichier de type %d"
@@ -21290,14 +21422,16 @@ msgstr "impossible de déplacer %s vers %s"
 msgid "attempt to reinitialize repository with different hash"
 msgstr "essai de réinitialisation du dépôt avec une empreinte différente"
 
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr ""
+"essai de réinitialisation du dépôt avec un format de stockage de références "
+"différent"
+
 #, c-format
 msgid "%s already exists"
 msgstr "%s existe déjà"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-initialisation : --initial-branch=%s ignoré"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr "Dépôt Git existant partagé réinitialisé dans %s%s\n"
@@ -21567,12 +21701,6 @@ msgstr "effacer l'arbre de cache avant chaque itération"
 msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr "nombre d'entrées dans l'arbre de cache à invalider (par défaut, 0)"
 
-msgid "unhandled options"
-msgstr "options non gérées"
-
-msgid "error preparing revisions"
-msgstr "erreur lors de la préparation des révisions"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "le commit %s n'est pas marqué joignable"
@@ -21732,9 +21860,6 @@ msgstr ""
 msgid "invalid remote service path"
 msgstr "chemin de service distant invalide"
 
-msgid "operation not supported by protocol"
-msgstr "option non supportée par le protocole"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "impossible de se connecter au sous-service %s"
@@ -21866,10 +21991,6 @@ msgstr "impossible d'analyser la configuration transport.color.*"
 msgid "support for protocol v2 not implemented yet"
 msgstr "le support du protocole v2 n'est pas encore implanté"
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "valeur inconnue pour la config '%s' : %s"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "transport '%s' non permis"
@@ -21924,6 +22045,9 @@ msgid "could not retrieve server-advertised bundle-uri list"
 msgstr ""
 "impossible de récupérer la liste de bundle-uris annoncée par le serveur"
 
+msgid "operation not supported by protocol"
+msgstr "option non supportée par le protocole"
+
 msgid "too-short tree object"
 msgstr "objet arbre trop court"
 
@@ -22773,6 +22897,10 @@ msgstr "de plus, votre index contient des modifications non validées."
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "%s impossible : votre index contient des modifications non validées."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "style inconnu '%s' pour '%s'"
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
@@ -23174,6 +23302,61 @@ msgstr "%s sauté avec un suffix de sauvegarde '%s'.\n"
 msgid "Do you really want to send %s? [y|N]: "
 msgstr "Souhaitez-vous réellement envoyer %s ?[y|N] : "
 
+#~ msgid "-x and -X cannot be used together"
+#~ msgstr "-x et -X ne peuvent pas être utilisés ensemble"
+
+#~ msgid ""
+#~ "--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
+#~ "exclude"
+#~ msgstr ""
+#~ "--bundle-uri est incompatible avec --depth, --shallow-since, et --shallow-"
+#~ "exclude"
+
+#~ msgid "--merge-base is incompatible with --stdin"
+#~ msgstr "--merge-base est incompatible avec --stdin"
+
+#~ msgid ""
+#~ "apply options are incompatible with rebase.autoSquash.  Consider adding --"
+#~ "no-autosquash"
+#~ msgstr ""
+#~ "les options d'application sont incompatibles avec rebase.autoSquash. "
+#~ "Considérez l'ajout de --no-autosquash"
+
+#~ msgid "--exclude-hidden cannot be used together with --branches"
+#~ msgstr "--exclude-hidden ne peut être utilisé avec --branches"
+
+#~ msgid "--exclude-hidden cannot be used together with --tags"
+#~ msgstr "--exclude-hidden ne peut pas être utilisé avec --tags"
+
+#~ msgid "--exclude-hidden cannot be used together with --remotes"
+#~ msgstr "--exclude-hidden ne peut pas être utilisé avec --remotes"
+
+#, c-format
+#~ msgid "only one of '%s', '%s' or '%s' can be given"
+#~ msgstr "les options '%s', '%s' et '%s' sont mutuellement exclusives"
+
+#, c-format
+#~ msgid "'%s' and '%s' cannot be used together"
+#~ msgstr "'%s' et '%s' ne peuvent pas être utilisées ensemble"
+
+#, c-format
+#~ msgid "options '%s', and '%s' cannot be used together"
+#~ msgstr "les options '%s' et '%s' ne peuvent pas être utilisées ensemble"
+
+#~ msgid "<commit-ish>"
+#~ msgstr "<commit-esque>"
+
+#, c-format
+#~ msgid "%s is incompatible with %s"
+#~ msgstr "%s est incompatible avec %s"
+
+#, c-format
+#~ msgid "could not remove reference %s"
+#~ msgstr "impossible de supprimer la référence %s"
+
+#~ msgid "unhandled options"
+#~ msgstr "options non gérées"
+
 #, c-format
 #~ msgid "options '%s=%s' and '%s=%s' cannot be used together"
 #~ msgstr ""
index 9698367606beb8480d967e616eb8ac960d773807..3e8b212b6178f52813fd16b603653a447692da7a 100644 (file)
--- a/po/id.po
+++ b/po/id.po
@@ -7,8 +7,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-12 20:04+0700\n"
-"PO-Revision-Date: 2023-11-12 20:30+0700\n"
+"POT-Creation-Date: 2024-02-16 09:36+0700\n"
+"PO-Revision-Date: 2024-02-16 10:45+0700\n"
 "Last-Translator: Bagas Sanjaya <bagasdotme@gmail.com>\n"
 "Language-Team: Indonesian\n"
 "Language: id\n"
@@ -909,7 +909,7 @@ msgid "unclosed quote"
 msgstr "tanda kutip tak ditutup"
 
 #: alias.c builtin/cat-file.c builtin/notes.c builtin/prune-packed.c
-#: builtin/receive-pack.c builtin/tag.c
+#: builtin/receive-pack.c builtin/tag.c t/helper/test-pkt-line.c
 msgid "too many arguments"
 msgstr "terlalu banyak argumen"
 
@@ -924,12 +924,13 @@ msgid "unrecognized whitespace ignore option '%s'"
 msgstr "opsi abai spasi putih tidak dikenal '%s'"
 
 #: apply.c archive.c builtin/add.c builtin/branch.c builtin/checkout-index.c
-#: builtin/checkout.c builtin/clone.c builtin/commit.c builtin/describe.c
-#: builtin/diff-tree.c builtin/difftool.c builtin/fast-export.c builtin/fetch.c
-#: builtin/help.c builtin/index-pack.c builtin/init-db.c builtin/log.c
-#: builtin/ls-files.c builtin/merge-base.c builtin/merge.c
-#: builtin/pack-objects.c builtin/push.c builtin/rebase.c builtin/repack.c
-#: builtin/reset.c builtin/rev-list.c builtin/show-branch.c builtin/stash.c
+#: builtin/checkout.c builtin/clean.c builtin/clone.c builtin/commit.c
+#: builtin/describe.c builtin/diff-tree.c builtin/difftool.c
+#: builtin/fast-export.c builtin/fetch.c builtin/help.c builtin/index-pack.c
+#: builtin/init-db.c builtin/log.c builtin/ls-files.c builtin/merge-base.c
+#: builtin/merge-tree.c builtin/merge.c builtin/pack-objects.c builtin/rebase.c
+#: builtin/repack.c builtin/replay.c builtin/reset.c builtin/rev-list.c
+#: builtin/rev-parse.c builtin/show-branch.c builtin/stash.c
 #: builtin/submodule--helper.c builtin/tag.c builtin/worktree.c parse-options.c
 #: range-diff.c revision.c
 #, c-format
@@ -1752,6 +1753,11 @@ msgstr "opsi `%s' butuh '%s'"
 msgid "Unexpected option --output"
 msgstr "Opsi --output tak diharapkan"
 
+#: archive.c
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "parameter konfigurasi tambahan: '%s'"
+
 #: archive.c
 #, c-format
 msgid "Unknown archive format '%s'"
@@ -1808,6 +1814,17 @@ msgstr "mengabaikan blob gitattributes '%s' yang terlalu besar"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "--attr-source atau GIT_ATTR_SOURCE jelek"
 
+#: attr.c read-cache.c
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "tidak dapat men-stat '%s'"
+
+#: bisect.c builtin/cat-file.c builtin/index-pack.c builtin/notes.c
+#: builtin/pack-objects.c combine-diff.c rerere.c
+#, c-format
+msgid "unable to read %s"
+msgstr "tidak dapat membaca %s"
+
 #: bisect.c
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
@@ -2359,8 +2376,8 @@ msgid "bad action '%s' for '%s'"
 msgstr "tindakan jelek '%s' untuk '%s'"
 
 #: builtin/am.c builtin/blame.c builtin/fetch.c builtin/pack-objects.c
-#: builtin/pull.c diff-merges.c gpg-interface.c ls-refs.c parallel-checkout.c
-#: sequencer.c setup.c
+#: builtin/pull.c config.c diff-merges.c gpg-interface.c ls-refs.c
+#: parallel-checkout.c sequencer.c setup.c
 #, c-format
 msgid "invalid value for '%s': '%s'"
 msgstr "nilai tidak valid untuk '%s': '%s'"
@@ -2523,8 +2540,7 @@ msgstr "git write-tree gagal menulis sebuah pohon"
 msgid "applying to an empty history"
 msgstr "menerapkan ke sebuah riwayat kosong"
 
-#: builtin/am.c builtin/commit.c builtin/merge.c sequencer.c
-#: t/helper/test-fast-rebase.c
+#: builtin/am.c builtin/commit.c builtin/merge.c builtin/replay.c sequencer.c
 msgid "failed to write commit object"
 msgstr "gagal menulis objek komit"
 
@@ -2710,8 +2726,9 @@ msgid "n"
 msgstr "n"
 
 #: builtin/am.c builtin/branch.c builtin/bugreport.c builtin/cat-file.c
-#: builtin/diagnose.c builtin/for-each-ref.c builtin/ls-files.c
-#: builtin/ls-tree.c builtin/replace.c builtin/tag.c builtin/verify-tag.c
+#: builtin/clone.c builtin/diagnose.c builtin/for-each-ref.c builtin/init-db.c
+#: builtin/ls-files.c builtin/ls-tree.c builtin/replace.c builtin/tag.c
+#: builtin/verify-tag.c
 msgid "format"
 msgstr "format"
 
@@ -3406,12 +3423,13 @@ msgstr "tidak dapat mencari objek komit untuk '%s'"
 
 #: builtin/branch.c
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"cabang '%s' belum sepenuhnya tergabung.\n"
-"kalau Anda yakin ingin menghapusnya, jalankan 'git branch -D %s'"
+msgid "the branch '%s' is not fully merged"
+msgstr "cabang '%s' belum sepenuhnya digabungkan"
+
+#: builtin/branch.c
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "Jika anda yakin untuk menghapusnya, lakukan 'git branch -D %s'"
 
 #: builtin/branch.c
 msgid "update of config-file failed"
@@ -4443,7 +4461,7 @@ msgstr "Tidak dapat melakukan reflog untuk '%s': %s\n"
 msgid "HEAD is now at"
 msgstr "HEAD sekarang berada di"
 
-#: builtin/checkout.c builtin/clone.c t/helper/test-fast-rebase.c
+#: builtin/checkout.c builtin/clone.c
 msgid "unable to update HEAD"
 msgstr "tidak dapat memperbarui HEAD"
 
@@ -4714,8 +4732,8 @@ msgid "new-branch"
 msgstr "cabang baru"
 
 #: builtin/checkout.c
-msgid "new unparented branch"
-msgstr "cabang baru tanpa induk"
+msgid "new unborn branch"
+msgstr "cabang yatim baru"
 
 #: builtin/checkout.c builtin/merge.c
 msgid "update ignored files (default)"
@@ -4783,7 +4801,7 @@ msgstr ""
 msgid "you must specify path(s) to restore"
 msgstr "Anda harus sebutkan jalur untuk dipulihkan"
 
-#: builtin/checkout.c builtin/clone.c builtin/remote.c
+#: builtin/checkout.c builtin/clone.c builtin/remote.c builtin/replay.c
 #: builtin/submodule--helper.c builtin/worktree.c
 msgid "branch"
 msgstr "cabang"
@@ -5027,10 +5045,6 @@ msgstr ""
 "clean.requireForce asal ke true dan baik -i, -n, atau -f tidak diberikan; "
 "menolak membersihkan"
 
-#: builtin/clean.c
-msgid "-x and -X cannot be used together"
-msgstr "-x dan -X tidak dapat digunakan bersamaan"
-
 #: builtin/clone.c
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<opsi>] [--] <repo> [<direktori>]"
@@ -5122,6 +5136,7 @@ msgid "create a shallow clone since a specific time"
 msgstr "buat klon dangkal sejak waktu yang disebutkan"
 
 #: builtin/clone.c builtin/fetch.c builtin/pull.c builtin/rebase.c
+#: builtin/replay.c
 msgid "revision"
 msgstr "revisi"
 
@@ -5149,6 +5164,10 @@ msgstr "direktori git"
 msgid "separate git dir from working tree"
 msgstr "pisahkan direktori git dari pohon kerja"
 
+#: builtin/clone.c builtin/init-db.c
+msgid "specify the reference format to use"
+msgstr "sebutkan format referensi untuk digunakan"
+
 #: builtin/clone.c
 msgid "key=value"
 msgstr "kunci=nilai"
@@ -5299,13 +5318,10 @@ msgstr "Terlalu banyak argumen."
 msgid "You must specify a repository to clone."
 msgstr "Anda harus sebutkan repositori untuk diklon."
 
-#: builtin/clone.c
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri tidak kompatibel dengan --depth, --shallow-since, dan --shallow-"
-"exclude"
+#: builtin/clone.c builtin/init-db.c setup.c
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "format penyimpanan referensi tidak dikenal '%s'"
 
 #: builtin/clone.c
 #, c-format
@@ -5471,13 +5487,13 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <direktori>] [--append]\n"
 "                       [--split[=<strategi>]] [--reachable | --stdin-packs | "
 "--stdin-commits]\n"
-"                       [--changed-paths] [--[no-]max-new-filters <n>] [--[-"
-"no-]progress]\n"
+"                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
+"[no-]progress]\n"
 "                       <opsi pemisahan>"
 
 #: builtin/commit-graph.c builtin/fetch.c builtin/log.c builtin/repack.c
@@ -8400,6 +8416,11 @@ msgstr "tidak ada dukungan utas, abaikan %s"
 msgid "unable to read tree (%s)"
 msgstr "tidak dapat membaca pohon (%s)"
 
+#: builtin/grep.c
+#, c-format
+msgid "unable to read tree %s"
+msgstr "tidak dapat membaca pohon %s"
+
 #: builtin/grep.c
 #, c-format
 msgid "unable to grep from object of type %s"
@@ -8929,11 +8950,6 @@ msgstr "inkonsistensi inflate serius"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "TUMBUKAN SHA1 DITEMUKAN DENGAN %s !"
 
-#: builtin/index-pack.c builtin/pack-objects.c
-#, c-format
-msgid "unable to read %s"
-msgstr "tidak dapat membaca %s"
-
 #: builtin/index-pack.c
 #, c-format
 msgid "cannot read existing object info %s"
@@ -9111,11 +9127,13 @@ msgstr "kesalahan fsck dalam objek paket"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<direktori templat>]\n"
 "         [--separate-git-dir <direktori git>] [--object-format=<format>]\n"
+"\t  [--ref-format=<format>]\n"
 "         [-b <nama cabang> | --initial-branch=<nama cabang>]\n"
 "         [--shared[=<perizinan>]] [<direktori>]"
 
@@ -9280,7 +9298,7 @@ msgstr ""
 "lacak evolusi rentang baris <awal>,<akhir> atau fungsi :<nama fungsi> dalam "
 "<berkas>"
 
-#: builtin/log.c builtin/shortlog.c bundle.c
+#: builtin/log.c builtin/replay.c builtin/shortlog.c bundle.c
 #, c-format
 msgid "unrecognized argument: %s"
 msgstr "argumen tidak dikenal: %s"
@@ -10036,6 +10054,14 @@ msgstr ""
 "git merge-file [<opsi>] [-L <nama 1> [-L <asli> [-L <nama 2>]]] <berkas 1> "
 "<berkas asli> <berkas 2>"
 
+#: builtin/merge-file.c diff.c
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"opsi diff-algorithm terima \"myers\", \"minimal\", \"patience\" dan "
+"\"histogram\""
+
 #: builtin/merge-file.c
 msgid "send results to standard output"
 msgstr "kirim hasil ke keluaran standar"
@@ -10064,6 +10090,14 @@ msgstr "untuk konflik, gunakan versi mereka"
 msgid "for conflicts, use a union version"
 msgstr "untuk konflik, gunakan versi bersatu"
 
+#: builtin/merge-file.c diff.c
+msgid "<algorithm>"
+msgstr "<algoritma>"
+
+#: builtin/merge-file.c diff.c
+msgid "choose a diff algorithm"
+msgstr "pilih algoritma diff"
+
 #: builtin/merge-file.c
 msgid "for conflicts, use this marker size"
 msgstr "untuk konflik, gunakan ukuran penanda ini"
@@ -10181,10 +10215,6 @@ msgstr "--trivial-merge tidak kompatibel dengan semua opsi lainnya"
 msgid "unknown strategy option: -X%s"
 msgstr "opsi strategi tidak dikenal: -X%s"
 
-#: builtin/merge-tree.c
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base tidak kompatibel dengan --stdin"
-
 #: builtin/merge-tree.c builtin/notes.c
 #, c-format
 msgid "malformed input line: '%s'."
@@ -10342,7 +10372,7 @@ msgstr "'%s' tidak menunjuk pada sebuah komit"
 msgid "Bad branch.%s.mergeoptions string: %s"
 msgstr "Untai branch.%s.mergeoptions jelek: %s"
 
-#: builtin/merge.c builtin/stash.c merge-recursive.c
+#: builtin/merge.c merge-recursive.c
 msgid "Unable to write index."
 msgstr "Tidak dapat menulis indeks."
 
@@ -10350,7 +10380,7 @@ msgstr "Tidak dapat menulis indeks."
 msgid "Not handling anything other than two heads merge."
 msgstr "Tak tangani apapun selain penggabungan dua kepala."
 
-#: builtin/merge.c t/helper/test-fast-rebase.c
+#: builtin/merge.c
 #, c-format
 msgid "unable to write %s"
 msgstr "tidak dapat menulis %s"
@@ -11363,6 +11393,11 @@ msgstr "Memampatkan objek"
 msgid "inconsistency with delta count"
 msgstr "ketidakkonsistenan dengan hitungan delta"
 
+#: builtin/pack-objects.c
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "nilai pack.allowPackReuse tidak valid: '%s'"
+
 #: builtin/pack-objects.c
 #, c-format
 msgid ""
@@ -11694,10 +11729,10 @@ msgstr "Menghitung objek"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Total %<PRIu32> (delta %<PRIu32>), digunakan ulang %<PRIu32> (delta "
-"%<PRIu32>), pak yang digunakan ulang %<PRIu32>"
+"%<PRIu32>), pak yang digunakan ulang %<PRIu32> (dari %<PRIuMAX>)"
 
 #: builtin/pack-redundant.c
 msgid ""
@@ -12816,7 +12851,7 @@ msgid "The --edit-todo action can only be used during interactive rebase."
 msgstr ""
 "Aksi --edit-todo hanya dapat digunakan selama pendasaran ulang interaktif."
 
-#: builtin/rebase.c t/helper/test-fast-rebase.c
+#: builtin/rebase.c
 msgid "Cannot read HEAD"
 msgstr "Tidak dapat membaca HEAD"
 
@@ -12862,14 +12897,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "tombol `C' harap nilai numerik"
 
-#: builtin/rebase.c
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"opsi penerapan tidak kompatibel dengan rebase.autoSquash. "
-"Pertimbangkanmenambahkan --no-autosquash"
-
 #: builtin/rebase.c
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
@@ -13368,10 +13395,10 @@ msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
 msgstr[0] ""
-"Catatan: Sebuah cabang diluar hierarki refs/remotes tidak dihapus;\n"
+"Catatan: Sebuah cabang diluar hierarki refs/remotes/ tidak dihapus;\n"
 "untuk menghapusnya, gunakan:"
 msgstr[1] ""
-"Catatan: Beberapa cabang diluar hierarki refs/remotes tidak dihapus;\n"
+"Catatan: Beberapa cabang diluar hierarki refs/remotes/ tidak dihapus;\n"
 "untuk menghapusnya, gunakan:"
 
 #: builtin/remote.c
@@ -14108,6 +14135,94 @@ msgstr "--convert-graft-file tidak mengambil argumen"
 msgid "only one pattern can be given with -l"
 msgstr "hanya satu pola yang dapat diberikan dengan -l"
 
+#: builtin/replay.c
+msgid "need some commits to replay"
+msgstr "butuh beberapa komit untuk dimainkan ulang"
+
+#: builtin/replay.c
+msgid "--onto and --advance are incompatible"
+msgstr "--onto dan --advance tidak kompatibel"
+
+#: builtin/replay.c
+msgid "all positive revisions given must be references"
+msgstr "semua revisi positif yang diberikan haruslah referensi"
+
+#: builtin/replay.c
+msgid "argument to --advance must be a reference"
+msgstr "argumen pada --advance harus sebuah referensi"
+
+#: builtin/replay.c
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"tidak dapat memajukan target dengan banyak sumber karena pengurutannya akan "
+"menjadi tidak jelas"
+
+#: builtin/replay.c
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"tidak dapat menentukan secara tidak langsung apakah ini operasi --advance "
+"atau --onto"
+
+#: builtin/replay.c
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"tidak dapat memajukan target dengan banyak cabang sumber karena "
+"pengurutannya akan menjadi tidak jelas"
+
+#: builtin/replay.c
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "tidak dapat menentukan secara tidak langsung dasar untuk --onto"
+
+#: builtin/replay.c
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(EKSPERIMENTAL!) git replay ([--contained] --onto <dasar baru> | --advance "
+"<cabang>) <rentang revisi>..."
+
+#: builtin/replay.c
+msgid "make replay advance given branch"
+msgstr "buat pemainan ulang memajukan caban yang diberikan"
+
+#: builtin/replay.c
+msgid "replay onto given commit"
+msgstr "mainkan ulang pada komit yang diberikan"
+
+#: builtin/replay.c
+msgid "advance all branches contained in revision-range"
+msgstr "majukan semua cabang yang berada pada rentang komit"
+
+#: builtin/replay.c
+msgid "option --onto or --advance is mandatory"
+msgstr "opsi --onto atau --advance diwajibkan"
+
+#: builtin/replay.c
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"beberapa opsi jalan revisi akan ditimpa oleh karena bit '%s' di 'struct "
+"rev_info' akan dipaksakan"
+
+#: builtin/replay.c
+msgid "error preparing revisions"
+msgstr "kesalahan menyiapkan revisi"
+
+#: builtin/replay.c
+msgid "replaying down to root commit is not supported yet!"
+msgstr "memainkan ulang ke komit akar belum didukung!"
+
+#: builtin/replay.c
+msgid "replaying merge commits is not supported yet!"
+msgstr "memainkan ulang komit penggabungan belum didukung!"
+
 #: builtin/rerere.c
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
@@ -14370,18 +14485,6 @@ msgstr "--prefix butuh sebuah argumen"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "mode untuk --abbrev-ref tidak dikenal: %s"
 
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden tidak dapat digunakan bersamaan dengan --branches"
-
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden tidak dapat digunakan bersamaan dengan --tags"
-
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden tidak dapat digunakan dengan --remotes"
-
 #: builtin/rev-parse.c setup.c
 msgid "this operation must be run in a work tree"
 msgstr "operasi ini harus dijalankan di dalam pohon kerja"
@@ -14894,11 +14997,6 @@ msgstr ""
 "perlihatkan referensi dari masukan standar yang tidak ada dalam repositori "
 "lokal"
 
-#: builtin/show-ref.c
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "hanya salah satu dari '%s', '%s', dan '%s' dapat diberikan"
-
 #: builtin/sparse-checkout.c
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
@@ -16720,7 +16818,7 @@ msgstr "Tidak ada cabang sumber yang mungkin, menyimpulkan '--orphan'"
 #: builtin/worktree.c
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
@@ -16734,7 +16832,7 @@ msgstr ""
 #: builtin/worktree.c
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
@@ -16812,6 +16910,11 @@ msgstr "tidak dapat membuat direktori '%s'"
 msgid "initializing"
 msgstr "menginisialisasi"
 
+#: builtin/worktree.c
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "tidak dapat menemukan pohon kerja yang dibuat '%s'"
+
 #: builtin/worktree.c
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
@@ -16858,11 +16961,6 @@ msgstr ""
 "ada, berhenti; gunakan 'add -f' untuk menimpa atau mengambil remote\n"
 "terlebih dahulu"
 
-#: builtin/worktree.c
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "'%s' dan '%s' tidak dapat digunakan bersamaan"
-
 #: builtin/worktree.c
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr ""
@@ -16877,7 +16975,7 @@ msgid "create or reset a branch"
 msgstr "buat atau setel ulang sebuah cabang"
 
 #: builtin/worktree.c
-msgid "create unborn/orphaned branch"
+msgid "create unborn branch"
 msgstr "buat cabang belum lahir/yatim"
 
 #: builtin/worktree.c
@@ -16907,12 +17005,8 @@ msgstr "Opsi '%s', '%s', dan '%s' tidak dapat digunakan bersamaan"
 
 #: builtin/worktree.c
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "Opsi '%s', dan '%s' tidak dapat digunakan bersamaan"
-
-#: builtin/worktree.c
-msgid "<commit-ish>"
-msgstr "<mirip-komit>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "opsi '%s' dan mirip-komit tidak dapat digunakan bersamaan"
 
 #: builtin/worktree.c
 msgid "added with --lock"
@@ -17714,6 +17808,12 @@ msgstr "Pak objek tak terpak di dalam repositori"
 msgid "Create, list, delete refs to replace objects"
 msgstr "Buat, daftar, hapus referensi untuk mengganti objek"
 
+#: command-list.h
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"EKSPERIMENTAL: Mainkan ulang komit pada dasar baru, dan juga bekerja pada "
+"repositori bare"
+
 #: command-list.h
 msgid "Generates a summary of pending changes"
 msgstr "Buat ringkasan perubahan tertunda"
@@ -18031,6 +18131,39 @@ msgstr "Alat untuk mengelola repositori Git besar"
 msgid "commit-graph file is too small"
 msgstr "berkas grafik komit terlalu kecil"
 
+#: commit-graph.c
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "bingkah oid grafik komit kipas keluar salah ukuran"
+
+#: commit-graph.c
+msgid "commit-graph fanout values out of order"
+msgstr "nilai kipas keluar grafik komit tidak berurutan"
+
+#: commit-graph.c
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "bingkah OID pencarian grafik komit salah ukuran"
+
+#: commit-graph.c
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "bingkah data grafik komit salah ukuran"
+
+#: commit-graph.c
+msgid "commit-graph generations chunk is wrong size"
+msgstr "bingkah generasi grafik komit salah ukuran"
+
+#: commit-graph.c
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "bingkah indeks grafik komit jalur berubah terlalu kecil"
+
+#: commit-graph.c
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"mengabaikan bingkah jalur berubah yang terlalu kecil (%<PRIuMAX> < "
+"%<PRIuMAX>) di dalam berkas grafik komit"
+
 #: commit-graph.c
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
@@ -18051,6 +18184,19 @@ msgstr "versi hash grafik komit %X tidak cocok dengan versi %X"
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "berkas grafik komit terlalu kecil untuk menyimpan %u bingkah"
 
+#: commit-graph.c
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr ""
+"bingkah grafik komit OID kipas keluar yang diperlukan hilang atau rusak"
+
+#: commit-graph.c
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr "bingkah grafik komit OID pencarian yang diperlukan hilang atau rusak"
+
+#: commit-graph.c
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr "bingkah grafik komit data komit yang diperlukan hilang atau rusak"
+
 #: commit-graph.c
 msgid "commit-graph has no base graphs chunk"
 msgstr "grafik komit tidak punya bingkah grafik dasar"
@@ -18068,6 +18214,10 @@ msgstr "rantai grafik komit tidak cocok"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "jumlah komit pada grafik dasar terlalu tinggi: %<PRIuMAX>"
 
+#: commit-graph.c
+msgid "commit-graph chain file too small"
+msgstr "berkas rantai grafik komit terlalu kecil"
+
 #: commit-graph.c
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
@@ -18094,6 +18244,10 @@ msgstr "grafik komit memerlukan pembuatan data meluap tapi tidak punya"
 msgid "commit-graph overflow generation data is too small"
 msgstr "data generasi luapan grafik komit terlalu kecil"
 
+#: commit-graph.c
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "penunjuk tepi tambahan grafik komit di luar batas"
+
 #: commit-graph.c
 msgid "Loading known commits in commit graph"
 msgstr "Memuat komit yang dikenal di grafik komit"
@@ -19505,6 +19659,11 @@ msgstr ""
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "Nilai tidak dikenal untuk variabel konfigurasi 'diff.submodule': '%s'"
 
+#: diff.c transport.c
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "nilai tidak dikenal untuk konfigurasi '%s': %s"
+
 #: diff.c
 #, c-format
 msgid ""
@@ -19601,14 +19760,6 @@ msgstr "argumen --color-moved jelek: %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "mode tidak valid '%s' dalam --color-moved-ws"
 
-#: diff.c
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"opsi diff-algorithm terima \"myers\", \"minimal\", \"patience\" dan "
-"\"histogram\""
-
 #: diff.c
 #, c-format
 msgid "invalid argument to %s"
@@ -19666,8 +19817,8 @@ msgid "output only the last line of --stat"
 msgstr "keluarkan hanya baris terakhir --stat"
 
 #: diff.c
-msgid "<param1,param2>..."
-msgstr "<parameter 1,parameter 2>..."
+msgid "<param1>,<param2>..."
+msgstr "<parameter 1>,<parameter 2>..."
 
 #: diff.c
 msgid ""
@@ -19680,8 +19831,8 @@ msgid "synonym for --dirstat=cumulative"
 msgstr "sinonim untuk --dirstat=cumulative"
 
 #: diff.c
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "sinonim untuk --dirstat=files,param1,param2..."
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "sinonim untuk --dirstat=files,<parameter 1>,<parameter 2>..."
 
 #: diff.c
 msgid "warn if changes introduce conflict markers or whitespace errors"
@@ -19913,14 +20064,6 @@ msgstr "buat diff menggunakan algoritma \"diff sabar\""
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "buat diff menggunakan algoritma \"diff histogram\""
 
-#: diff.c
-msgid "<algorithm>"
-msgstr "<algoritma>"
-
-#: diff.c
-msgid "choose a diff algorithm"
-msgstr "pilih algoritma diff"
-
 #: diff.c
 msgid "<text>"
 msgstr "<teks>"
@@ -21729,6 +21872,14 @@ msgstr "gagal membaca tembolok"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "OID kipas-keluar indeks multipak salah ukuran"
 
+#: midx.c
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"kipas-keluar oid tidak berurutan: fanout[%d] =%<PRIx32> > %<PRIx32> = "
+"fanout[%d]"
+
 #: midx.c
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "bingkah pencarian OID kipas-keluar indeks multipak salah ukuran"
@@ -21790,6 +21941,15 @@ msgstr "nama pak indeks multipak tidak berurutan: '%s' sebelum '%s'"
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "pack-int-id jelek: %u (total pak %u)"
 
+#: midx.c
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX tidak berisi bingkah BTMP"
+
+#: midx.c
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "tidak dapat membuka pak terbitmap %<PRIu32>"
+
 #: midx.c
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr "indeks multipak simpan offset 64-bit, tapi off_t terlalu kecil"
@@ -21897,14 +22057,6 @@ msgstr "checksum salah"
 msgid "Looking for referenced packfiles"
 msgstr "Mencari berkas pak yang direferensikan"
 
-#: midx.c
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr ""
-"kipas-keluar oid tidak berurutan: fanout[%d] =%<PRIx32> > %<PRIx32> = "
-"fanout[%d]"
-
 #: midx.c
 msgid "the midx contains no oid"
 msgstr "midx tidak berisi oid"
@@ -22542,6 +22694,10 @@ msgstr "bitmap multipak kehilangan indeks balik yang diperlukan"
 msgid "could not open pack %s"
 msgstr "tidak dapat membuka '%s'"
 
+#: pack-bitmap.c t/helper/test-read-midx.c
+msgid "could not determine MIDX preferred pack"
+msgstr "tidak dapat menentukan pak MIDX terpilih"
+
 #: pack-bitmap.c
 #, c-format
 msgid "preferred pack (%s) is invalid"
@@ -22565,6 +22721,11 @@ msgstr "tabel pencarian bitmap rusak: indeks komit %u di luar jangkauan"
 msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr "bitmap ewah rusak: kepala terpotong untuk bitmap komit \"%s\""
 
+#: pack-bitmap.c
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr "tidak dapat memuat pak: '%s', mematikan penggunaan ulang pak"
+
 #: pack-bitmap.c
 #, c-format
 msgid "object '%s' not found in type bitmaps"
@@ -22680,6 +22841,10 @@ msgstr "posisi indeks balik tidak valid pada %<PRIu64>: %<PRIu32> != %<PRIu32>"
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "bingkah indeks balik multipak salah ukuran"
 
+#: pack-revindex.c
+msgid "could not determine preferred pack"
+msgstr "tidak dapat menentukan pak terpilih"
+
 #: pack-write.c
 msgid "cannot both write and verify reverse index"
 msgstr "tidak dapat kedua-duanya menulis dan memverifikasi indeks balik"
@@ -22760,11 +22925,6 @@ msgstr ""
 "%s mengharapkan nilai bilangan bulat non negatif dengan akhiran opsional k/m/"
 "g"
 
-#: parse-options.c
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s tidak kompatibel dengan %s"
-
 #: parse-options.c
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
@@ -23164,11 +23324,6 @@ msgstr "tidak dapat menulis berkas indeks '%s'"
 msgid "unable to add '%s' to index"
 msgstr "tidak dapat menambahkan '%s' ke indeks"
 
-#: read-cache.c
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "tidak dapat men-stat '%s'"
-
 #: read-cache.c
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
@@ -23855,17 +24010,12 @@ msgstr "'%s' ada; tidak dapat membuat '%s'"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "tidak dapat memproses '%s' dan '%s' pada waktu yang bersamaan"
 
-#: refs/files-backend.c
-#, c-format
-msgid "could not remove reference %s"
-msgstr "tidak dapat menghapus referensi %s"
-
-#: refs/files-backend.c refs/packed-backend.c
+#: refs.c
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "tidak dapat menghapus referensi %s: %s"
 
-#: refs/files-backend.c refs/packed-backend.c
+#: refs.c
 #, c-format
 msgid "could not delete references: %s"
 msgstr "tidak dapat menghapus referensi: %s"
@@ -24100,9 +24250,9 @@ msgid ""
 msgstr ""
 "Tujuan yang Anda berikan bukan nama referensi penuh (seperti \n"
 "dimulai dengan \"refs/\"). Kami mencoba menebak maksud Anda dengan:\n"
-"- Cari referensi yang cocok dengan '%s' pada sisi remote.\n"
-"- Perika apakah <src> yang sedang didorong ('%s') adalah \n"
-"  referensi pada \"refs/{heads,tags}\". Bila demikian kami \n"
+"- mencari referensi yang cocok dengan '%s' pada sisi remote.\n"
+"- memeriksa apakah <src> yang sedang didorong ('%s') adalah \n"
+"  referensi pada \"refs/{heads,tags}/\". Bila demikian kami \n"
 "  menambahkan awalan refs/{heads,tags}/ yang bersesuaian pada sisi \n"
 "  remote.\n"
 "\n"
@@ -25042,7 +25192,7 @@ msgstr "identitas pengarang tidak valid '%s'"
 msgid "corrupt author: missing date information"
 msgstr "pengarang rusak: informasi tanggal hilang"
 
-#: sequencer.c t/helper/test-fast-rebase.c
+#: sequencer.c
 #, c-format
 msgid "could not update %s"
 msgstr "tidak dapat memperbarui %s"
@@ -25536,6 +25686,10 @@ msgstr "Menerapkan stase otomatis menghasilkan konflik."
 msgid "Autostash exists; creating a new stash entry."
 msgstr "Stase otomatis sudah ada; membuat entri stase baru."
 
+#: sequencer.c
+msgid "autostash reference is a symref"
+msgstr "referensi autostase itu referensi simbolik"
+
 #: sequencer.c
 msgid "could not detach HEAD"
 msgstr "tidak dapat melepas HEAD"
@@ -25916,6 +26070,11 @@ msgstr "tidak menyalin templat dari '%s': %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "nama cabang asal salah: '%s'"
 
+#: setup.c
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init: --initial-branch=%s diabaikan"
+
 #: setup.c
 #, c-format
 msgid "unable to handle file type %d"
@@ -25931,14 +26090,16 @@ msgid "attempt to reinitialize repository with different hash"
 msgstr "mencoba menginisialisasi ulang repositori dengan hash yang berbeda"
 
 #: setup.c
-#, c-format
-msgid "%s already exists"
-msgstr "%s sudah ada"
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr ""
+"mencoba menginisialisasi ulang repositori dengan format penyimpanan "
+"referensi yang berbeda"
 
 #: setup.c
 #, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init: --initial-branch=%s diabaikan"
+msgid "%s already exists"
+msgstr "%s sudah ada"
 
 #: setup.c
 #, c-format
@@ -26264,14 +26425,6 @@ msgstr "bersihkan pohon tembolok sebelum setiap iterasi"
 msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr "jumlah entri di dalam pohon tembolok untuk dinirvalidasi (asali 0)"
 
-#: t/helper/test-fast-rebase.c
-msgid "unhandled options"
-msgstr "opsi tak tertangani"
-
-#: t/helper/test-fast-rebase.c
-msgid "error preparing revisions"
-msgstr "kesalahan menyiapkan revisi"
-
 #: t/helper/test-reach.c
 #, c-format
 msgid "commit %s is not marked reachable"
@@ -26469,10 +26622,6 @@ msgstr "menyetel jalur layanan remote tidak didukung oleh protokol"
 msgid "invalid remote service path"
 msgstr "jalur layanan remote tidak valid"
 
-#: transport-helper.c transport.c
-msgid "operation not supported by protocol"
-msgstr "operasi tidak didukung oleh protokol"
-
 #: transport-helper.c
 #, c-format
 msgid "can't connect to subservice %s"
@@ -26636,11 +26785,6 @@ msgstr "tidak dapat menguraikan konfigurasi transport.color.*"
 msgid "support for protocol v2 not implemented yet"
 msgstr "dukungan untuk protokol v2 belum diterapkan"
 
-#: transport.c
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "nilai tidak dikenal untuk konfigurasi '%s': %s"
-
 #: transport.c
 #, c-format
 msgid "transport '%s' not allowed"
@@ -26701,6 +26845,10 @@ msgstr "operasi bundle-uri tidak didukung oleh protokol"
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "tidak dapat menerima daftar bundle-uri teriklankan server"
 
+#: transport.c
+msgid "operation not supported by protocol"
+msgstr "operasi tidak didukung oleh protokol"
+
 #: tree-walk.c
 msgid "too-short tree object"
 msgstr "objek pohon terlalu pendek"
@@ -27722,6 +27870,11 @@ msgstr "juga indeks Anda berisi perubahan yang belum dikomit."
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "tidak dapat %s: indeks Anda berisi perubahan yang belum dikomit."
 
+#: xdiff-interface.c
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "nilai gaya tidak dikenal '%s' diberikan untuk '%s'"
+
 #: git-merge-octopus.sh git-merge-resolve.sh
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
index cd2a86a4a53eed36a7c4c079b18be9c1bfe13631..786c2f749e71b1973245e9d43e6f6ebaa619d637 100644 (file)
--- a/po/sv.po
+++ b/po/sv.po
@@ -1,14 +1,14 @@
 # Swedish translations for Git.
-# Copyright (C) 2010-2023 Peter Krefting <peter@softwolves.pp.se>
+# Copyright (C) 2010-2024 Peter Krefting <peter@softwolves.pp.se>
 # This file is distributed under the same license as the Git package.
-# Peter Krefting <peter@softwolves.pp.se>, 2010-2023.
+# Peter Krefting <peter@softwolves.pp.se>, 2010-2024.
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: git 2.43.0\n"
+"Project-Id-Version: git 2.44.0\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-09 14:12+0100\n"
-"PO-Revision-Date: 2023-11-09 14:28+0100\n"
+"POT-Creation-Date: 2024-02-16 07:58+0100\n"
+"PO-Revision-Date: 2024-02-16 07:59+0100\n"
 "Last-Translator: Peter Krefting <peter@softwolves.pp.se>\n"
 "Language-Team: Svenska <tp-sv@listor.tp-sv.se>\n"
 "Language: sv\n"
@@ -1417,6 +1417,10 @@ msgstr "flaggan ”%s” kräver ”%s”"
 msgid "Unexpected option --output"
 msgstr "Oväntad flagga --output"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "falsk konfigureringsparameter: ”%s”"
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Okänt arkivformat ”%s”"
@@ -1462,6 +1466,14 @@ msgstr "ignorerar allt för stor gitattributes-objekt ”%s”"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "felaktig --attr-source eller GIT_ATTR_SOURCE"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "kan inte ta status på ”%s”"
+
+#, c-format
+msgid "unable to read %s"
+msgstr "kunde inte läsa %s"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "Felaktigt citerat innehåll i filen ”%s”: %s"
@@ -2582,7 +2594,7 @@ msgid "do not show object names of boundary commits (Default: off)"
 msgstr "visa inte objektnamn för gränsincheckningar (Standard: av)"
 
 msgid "do not treat root commits as boundaries (Default: off)"
-msgstr "vehandla inte rotincheckningar som gränser (Standard: av)"
+msgstr "behandla inte rotincheckningar som gränser (Standard: av)"
 
 msgid "show work cost statistics"
 msgstr "visa statistik över arbetskostnad"
@@ -2734,12 +2746,12 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "kunde inte slå upp incheckningsobjekt för ”%s”"
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"grenen ”%s” har inte slagits samman i sin helhet.\n"
-"Om du är säker på att du vill ta bort den, kör ”git branch -D %s”"
+msgid "the branch '%s' is not fully merged"
+msgstr "grenen ”%s” har inte slagits samman i sin helhet"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "Om du är säker på att du vill ta bort den, kör ”git branch -D %s”"
 
 msgid "update of config-file failed"
 msgstr "misslyckades uppdatera konfigurationsfil"
@@ -3772,8 +3784,8 @@ msgstr "tvinga utcheckning (kasta bort lokala ändringar)"
 msgid "new-branch"
 msgstr "ny-gren"
 
-msgid "new unparented branch"
-msgstr "ny gren utan förälder"
+msgid "new unborn branch"
+msgstr "ny ofödd gren"
 
 msgid "update ignored files (default)"
 msgstr "uppdatera ignorerade filer (standard)"
@@ -4023,9 +4035,6 @@ msgstr ""
 "clean.requireForce har standardvärdet true och varken -i, -n eller -f "
 "angavs; vägrar städa"
 
-msgid "-x and -X cannot be used together"
-msgstr "-x och -X kan inte användas samtidigt"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<flaggor>] [--] <arkiv> [<kat>]"
 
@@ -4113,6 +4122,9 @@ msgstr "gitkat"
 msgid "separate git dir from working tree"
 msgstr "separera gitkatalogen från arbetskatalogen"
 
+msgid "specify the reference format to use"
+msgstr "använd referensformatet som ska användas"
+
 msgid "key=value"
 msgstr "nyckel=värde"
 
@@ -4228,12 +4240,9 @@ msgstr "För många argument."
 msgid "You must specify a repository to clone."
 msgstr "Du måste ange ett arkiv att klona."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri är inkompatibelt med --depth, --shallow-since och --shallow-"
-"exclude"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "okänt format för lagring av referenser ”%s”"
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4361,7 +4370,7 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <kat>] [--append]\n"
 "                       [--split[=<strategi>]] [--reachable | --stdin-packs | "
@@ -6674,6 +6683,10 @@ msgstr "trådstöd saknas, ignorerar %s"
 msgid "unable to read tree (%s)"
 msgstr "kunde inte läsa träd (%s)"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "kunde inte läsa trädet %s"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "kunde inte ”grep” från objekt av typen %s"
@@ -7080,10 +7093,6 @@ msgstr "allvarlig inflate-inkonsekvens"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "SHA1-KOLLISION UPPTÄCKT VID %s !"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "kunde inte läsa %s"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "kan inte läsa information om befintligt objekt %s"
@@ -7224,11 +7233,13 @@ msgstr "fsck-fel i packat objekt"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<mallkatalog>]\n"
 "         [--separate-git-dir <git-kat>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <grennamn> | --initial-branch=<grennamn>]\n"
 "         [--shared[=<behörigheter>]] [<katalog>]"
 
@@ -7927,6 +7938,12 @@ msgstr ""
 "git merge-file [<alternativ>] [-L <namn1> [-L <orig> [-L <namn2>]]] <fil1> "
 "<origfil> <fil2>"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"flaggan diff-algorithm godtar ”myers”, ”minimal”, ”patience” och ”histogram”"
+
 msgid "send results to standard output"
 msgstr "sänd resultat till standard ut"
 
@@ -7948,6 +7965,12 @@ msgstr "för konflikter, använd deras version"
 msgid "for conflicts, use a union version"
 msgstr "för konflikter, använd en förenad version"
 
+msgid "<algorithm>"
+msgstr "<algoritm>"
+
+msgid "choose a diff algorithm"
+msgstr "välj en diff-algoritm"
+
 msgid "for conflicts, use this marker size"
 msgstr "för konflikter, använd denna markörstorlek"
 
@@ -8038,9 +8061,6 @@ msgstr "--trivial-merge är inkompatibelt med andra flaggor"
 msgid "unknown strategy option: -X%s"
 msgstr "okänd strategiflagga: -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base är inkompatibel med --stdin"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "felaktig indatarad: ”%s”."
@@ -8966,6 +8986,10 @@ msgstr "Komprimerar objekt"
 msgid "inconsistency with delta count"
 msgstr "deltaräknaren är inkonsekvent"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "felaktigt värde för pack.allowPackReuse: ”%s”"
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9219,10 +9243,10 @@ msgstr "Räknar upp objekt"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Totalt %<PRIu32> (delta %<PRIu32>), återanvände %<PRIu32> (delta %<PRIu32>), "
-"paket-återanvända %<PRIu32>"
+"paket-återanvända %<PRIu32> (från %<PRIuMAX>)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10175,13 +10199,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "flaggan ”C” förväntar ett numeriskt värde"
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"argument för ”apply” är inkompatibla med rebase.autoSquash. Överväg att "
-"lägga till --no-autosquash"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -11167,6 +11184,76 @@ msgstr "--convert-graft-file tar inga argument"
 msgid "only one pattern can be given with -l"
 msgstr "endast ett mönster kan anges med -l"
 
+msgid "need some commits to replay"
+msgstr "behöver några incheckningar för omspelning"
+
+msgid "--onto and --advance are incompatible"
+msgstr "--onto och --advance kan inte kombineras"
+
+msgid "all positive revisions given must be references"
+msgstr "alla positiva revisioner som anges måste vara referenser"
+
+msgid "argument to --advance must be a reference"
+msgstr "argumentet till --advance måste vara en referens"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"kan inte flytta målet framåt när det finns flera källor eftersom ordningen "
+"inte kan fastställas"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"kan inte avgöra om den underförstådda processen är --advance eller --onto"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"kan inte flytta målet framåt när det finns flera källgrenar eftersom "
+"ordningen inte kan fastställas"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "kan inte avgöra den underförstådda basen för --onto"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(EXPERIMENTELLT!) git replay ([--contained] --onto <nybas> | --advance "
+"<gren>) <revisions-intervall>..."
+
+msgid "make replay advance given branch"
+msgstr "låt omspelningen flytta den givna grenen framåt"
+
+msgid "replay onto given commit"
+msgstr "spela om ovanpå en given incheckning"
+
+msgid "advance all branches contained in revision-range"
+msgstr "flytta alla grenar som finns i revisionsintervallet framåt"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "flaggan --onto eller --advance måste anges"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"några flaggor för revisionstraversering kommer överstyras eftersom ”%s”-"
+"biten i ”struct rev_info” kommer att tvingas"
+
+msgid "error preparing revisions"
+msgstr "fel när revisioner skulle förberedas"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "kan ännu inte spela om hela vägen ned till rotincheckningen!"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "kan ännu inte spela om sammanslagningsincheckningar!"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr ""
@@ -11373,15 +11460,6 @@ msgstr "--prefix kräver ett argument"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "okänt läge för --abbrev-ref: %s"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden kan endast användas tillsammans med --branches"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden kan  kan inte användas tillsammans med --tags"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden kan  kan inte användas tillsammans med --remotes"
-
 msgid "this operation must be run in a work tree"
 msgstr "funktionen måste köras i en arbetskatalog"
 
@@ -11784,10 +11862,6 @@ msgstr "visa inte resultat på standard ut (användbart med --verify)"
 msgid "show refs from stdin that aren't in local repository"
 msgstr "visa referenser från standard in som inte finns i lokalt arkiv"
 
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "endast en av ”%s”, ”%s” och ”%s” kan anges"
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -13232,13 +13306,13 @@ msgstr "Ingen möjlig källgren, använder ”--orphan”"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
-"Om meningen var att skapa en arbetskatalog från en ny föräldrals\n"
+"Om meningen var att skapa en arbetskatalog från en ny ofödd\n"
 "gren (gren utan incheckningar) för det här arkivet kan du göra\n"
 "det med flaggan --orphan:\n"
 "\n"
@@ -13246,13 +13320,13 @@ msgstr ""
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
-"Om meningen var att skapa en arbetskatalog från en ny föräldrals\n"
+"Om meningen var att skapa en arbetskatalog från en ny ofödd\n"
 "gren (gren utan incheckningar) för det här arkivet kan du göra\n"
 "det med flaggan --orphan:\n"
 "\n"
@@ -13314,6 +13388,10 @@ msgstr "kunde inte skapa katalogen ”%s”"
 msgid "initializing"
 msgstr "initierar"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "kunde inte hitta den skapade arbetskatalogen ”%s”"
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "Förbereder arbetskatalog (ny gren ”%s”)"
@@ -13352,10 +13430,6 @@ msgstr ""
 "finns, avslutar; använd ”add -f” för att överstyra eller hämta från en fjärr "
 "först"
 
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "”%s” och ”%s” kan inte användas samtidigt"
-
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr ""
 "checka ut <gren> även om den redan är utcheckad i en annan arbetskatalog"
@@ -13366,8 +13440,8 @@ msgstr "skapa en ny gren"
 msgid "create or reset a branch"
 msgstr "skapa eller återställ en gren"
 
-msgid "create unborn/orphaned branch"
-msgstr "skapa en ofödd/övergiven gren"
+msgid "create unborn branch"
+msgstr "skapa en ofödd gren"
 
 msgid "populate the new working tree"
 msgstr "befolka den nya arbetskatalogen"
@@ -13389,11 +13463,8 @@ msgid "options '%s', '%s', and '%s' cannot be used together"
 msgstr "flaggorna ”%s”, ”%s” och ”%s” kan inte användas samtidigt"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "flaggorna ”%s” och ”%s” kan inte användas samtidigt"
-
-msgid "<commit-ish>"
-msgstr "<incheckning-igt>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "flaggorna ”%s” och incheckning-igt kan inte användas samtidigt"
 
 msgid "added with --lock"
 msgstr "lagt till med --lock"
@@ -14006,6 +14077,11 @@ msgstr "Packa opackade objekt i ett arkiv"
 msgid "Create, list, delete refs to replace objects"
 msgstr "Skapa, visa, ta bort referenser för att ersätta objekt"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"EXPERIMENTELLT: Spela om incheckningar ovanpå en ny bas, fungerar även med "
+"nakna arkiv"
+
 msgid "Generates a summary of pending changes"
 msgstr "Skapar en sammanfattning av väntande ändringar"
 
@@ -14243,6 +14319,32 @@ msgstr "Verktyg för att hantera stora Git-arkiv"
 msgid "commit-graph file is too small"
 msgstr "incheckningsgraffilen %s är för liten"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "incheckningsgrafens oid-utbredningsstycke har fel storlek"
+
+msgid "commit-graph fanout values out of order"
+msgstr "incheckningsgrafens utbredningsvärden är i fel ordning"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "incheckningsgrafens OID-uppslagningsstycket har fel storlek"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "incheckningsgrafens incheckningsdatastycke har fel storlek"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr "incheckningsgrafens generationsstycke har fel storlek"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "incheckningsgrafens ändrade-sökvägar-indexstycke är förö litet"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"ignorerar för litet ändrade-sökvägar-stycke (%<PRIuMAX> < %<PRIuMAX>) i "
+"incheckningsgraffilen"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr "incheckningsgrafens signatur %X stämmer inte med signaturen %X"
@@ -14259,6 +14361,18 @@ msgstr "incheckningsgrafens hashversion %X stämmer inte med versionen %X"
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "incheckningsgraffilen är för liten för att innehålla %u stycken"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr ""
+"incheckningsgrafens nödvändiga OID-utbredningsstycke saknas eller är trasigt"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr ""
+"incheckningsgrafens nödvändiga OID-uppslagningsstycke saknas eller är trasigt"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr ""
+"incheckningsgrafens nödvändiga incheckningsdatastycke saknas eller är trasigt"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "incheckningsgrafen har inga bas-graf-stycken"
 
@@ -14272,6 +14386,9 @@ msgstr "incheckningsgrafens kedja stämmer inte"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "antalet incheckningar i basgrafen för högt: %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "incheckningsgrafens kedjefil är för liten"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr "ogiltig incheckingsgrafkedja: rad ”%s” är inte ett hash-värde"
@@ -14292,6 +14409,9 @@ msgstr "incheckningsgraf kräver spillgenerationsdata, men har ingen"
 msgid "commit-graph overflow generation data is too small"
 msgstr "incheckningsgrafens spillgenerationsdata är för liten"
 
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "incheckningsgrafens extra-kant-pekare är utanför intervallet"
+
 msgid "Loading known commits in commit graph"
 msgstr "Läser in kända incheckningar i incheckningsgraf"
 
@@ -15430,6 +15550,10 @@ msgstr ""
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "Okänt värde för konfigurationsvariabeln ”diff.submodule”: ”%s”"
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "okänt värde för inställningen ”%s”: %s"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -15509,12 +15633,6 @@ msgstr "felaktigt argument till --color-moved: %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "ogiltigt läge %s” i --color-moved-ws"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"flaggan diff-algorithm godtar ”myers”, ”minimal”, ”patience” och ”histogram”"
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "ogiltigt argument för %s"
@@ -15558,8 +15676,8 @@ msgstr "maskinläsbar --stat"
 msgid "output only the last line of --stat"
 msgstr "skriv bara ut den sista raden för --stat"
 
-msgid "<param1,param2>..."
-msgstr "<param1,param2>..."
+msgid "<param1>,<param2>..."
+msgstr "<param1>,<param2>..."
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -15569,8 +15687,8 @@ msgstr ""
 msgid "synonym for --dirstat=cumulative"
 msgstr "synonym för --dirstat=cumulative"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "synonym för --dirstat=filer,param1,param2..."
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "synonym för --dirstat=filer,<param1>,<param2>..."
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr "varna om ändringar introducerar konfliktmarkörer eller blankstegsfel"
@@ -15744,12 +15862,6 @@ msgstr "skapa diffar med algoritmen ”patience diff”"
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "skapa diffar med algoritmen ”histogram diff”"
 
-msgid "<algorithm>"
-msgstr "<algoritm>"
-
-msgid "choose a diff algorithm"
-msgstr "välj en diff-algoritm"
-
 msgid "<text>"
 msgstr "<text>"
 
@@ -17220,6 +17332,12 @@ msgstr "misslyckades läsa cachen"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "OID-utbredning för multi-pack-index har fel storlek"
 
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"oid-utbredning i fel ordning: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "OID-uppslagningsstycket för multi-pack-index har fel storlek"
 
@@ -17270,6 +17388,13 @@ msgstr "paketnamn för multi-pack-index i fel ordning: ”%s” före ”%s”"
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "bad pack-int-id: %u (%u paket totalt)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX innehåller inte BTMP-stycket"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "kunde inte läsa det bitmappade paketet %<PRIu32>"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr "multi-pack-index innehåller 64-bitars offset, men off_t är för liten"
 
@@ -17353,12 +17478,6 @@ msgstr "felaktig kontrollsumma"
 msgid "Looking for referenced packfiles"
 msgstr "Ser efter refererade packfiler"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr ""
-"oid-utbredning i fel ordning: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-
 msgid "the midx contains no oid"
 msgstr "midx saknar oid"
 
@@ -17875,6 +17994,9 @@ msgstr "flerpaketsbitkarta saknar nödvändigt omvänt index"
 msgid "could not open pack %s"
 msgstr "kunde inte öppna paketfilen %s"
 
+msgid "could not determine MIDX preferred pack"
+msgstr "kunde inte bestämma det föredragna MIDX-paketet"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
 msgstr "föredragen paketfil (%s) är ogiltig"
@@ -17894,6 +18016,10 @@ msgstr ""
 msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr "trasig ewah-bitkarta: avhugget huvud för bitkarta för incheckning ”%s”"
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr "kunde inte läsa paketet: ”%s”, inaktiverar återanvändning av paket"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "objektet ”%s” hittades inte i typbitkartor"
@@ -17985,6 +18111,9 @@ msgstr "ogiltig rev-indexposition vid %<PRIu64>: %<PRIu32> != %<PRIu32>"
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "baklängesindex-stycke för multi-pack-index har fel storlek"
 
+msgid "could not determine preferred pack"
+msgstr "kunde inte bestämma föredraget paket"
+
 msgid "cannot both write and verify reverse index"
 msgstr "kan inte både skriva och bekräfta reverse-index"
 
@@ -18047,10 +18176,6 @@ msgstr "%s är inte tillgängligt"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s förväntar ett icke-negativt heltalsvärde, med valfritt k/m/g-suffix"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s är inkompatibel med %s"
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "tvetydig flagga: %s (kan vara --%s%s eller --%s%s)"
@@ -18364,10 +18489,6 @@ msgstr "kan inte indexera filen ”%s”"
 msgid "unable to add '%s' to index"
 msgstr "kan inte lägga till ”%s” till indexet"
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "kan inte ta status på ”%s”"
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "”%s” finns både som en fil och en katalog"
@@ -18940,10 +19061,6 @@ msgstr "”%s” finns; kan inte skapa ”%s”"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "kan inte hantera ”%s” och ”%s” samtidigt"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "kunde inte ta bort referensen %s"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "kunde inte ta bort referensen %s: %s"
@@ -19138,7 +19255,7 @@ msgstr ""
 "- Se efter en referens som motsvarar ”%s” på fjärrsidan.\n"
 "- Se om <källan> som sänds (”%s”)\n"
 "  är en referens i ”refs/{heads,tags}/”. Om så lägger vi till\n"
-"  motsvarande refs/{heads,tags}/-prefix på fjärrsidan.\n"
+"  motsvarande ”refs/{heads,tags}/”-prefix på fjärrsidan.\n"
 "\n"
 "Inget av dem fungerade, så vi gav upp. Ange fullständig referens."
 
@@ -20299,6 +20416,9 @@ msgstr "Tillämpning av autostash gav konflikter."
 msgid "Autostash exists; creating a new stash entry."
 msgstr "Autostash finns; skapar ny stash-post."
 
+msgid "autostash reference is a symref"
+msgstr "autostash-referensen är en symbolisk referens"
+
 msgid "could not detach HEAD"
 msgstr "kunde inte koppla från HEAD"
 
@@ -20610,6 +20730,10 @@ msgstr "kopierade inte mallar från ”%s”: %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "ogiltigt namn på första gren: ”%s”"
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init: ignorerade --initial-branch=%s"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "kan inte hantera filtyp %d"
@@ -20621,14 +20745,14 @@ msgstr "kan inte flytta %s till %s"
 msgid "attempt to reinitialize repository with different hash"
 msgstr "försöker initiera arkivet på nytt med annan hash"
 
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr "försöker initiera arkivet på nytt med annat referenslagringsformat"
+
 #, c-format
 msgid "%s already exists"
 msgstr "%s finns redan"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init: ignorerade --initial-branch=%s"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr "Ominitierade befintligt delat Git-arkiv i %s%s\n"
@@ -20893,12 +21017,6 @@ msgstr "töm cacheträdet före varje iteration"
 msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr "antal poster i cacheträdet att ogiltigförklara (förval är 0)"
 
-msgid "unhandled options"
-msgstr "flaggor som inte hanterats"
-
-msgid "error preparing revisions"
-msgstr "fel när revisioner skulle förberedas"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "incheckning %s är inte märkt nåbar"
@@ -21054,9 +21172,6 @@ msgstr "protkollet stöder inte att sätta sökväg till fjärrtjänst"
 msgid "invalid remote service path"
 msgstr "felaktig sökväg till fjärrtjänst"
 
-msgid "operation not supported by protocol"
-msgstr "funktionen stöds inte av protokollet"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "kan inte ansluta till undertjänsten %s"
@@ -21186,10 +21301,6 @@ msgstr "kunde inte tolka inställningen för transport.color.*"
 msgid "support for protocol v2 not implemented yet"
 msgstr "stöd för protokoll v2 ännu ej implementerat"
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "okänt värde för inställningen ”%s”: %s"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "transporten ”%s” tillåts inte"
@@ -21243,6 +21354,9 @@ msgstr "bundle-uri-funktionen stöds inte av protokollet"
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "kunde inte hämta bundle-uri-listan som servern annonserade"
 
+msgid "operation not supported by protocol"
+msgstr "funktionen stöds inte av protokollet"
+
 msgid "too-short tree object"
 msgstr "trädobjekt för kort"
 
@@ -22066,6 +22180,10 @@ msgstr "dessutom innehåller dit index ändringar som inte har checkats in."
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "kan inte %s: Ditt index innehåller ändringar som inte checkats in."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "okänd stil ”%s” angavs för ”%s”"
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
index f01962d1dbdb40028e6c949e6d86e6f9cd322d55..19d6661bbe6d237d608e997bd2c22fe84d1e8ad8 100644 (file)
--- a/po/tr.po
+++ b/po/tr.po
@@ -1,8 +1,8 @@
 # Turkish translations for Git
 # Git Türkçe çevirileri
-# Copyright (C) 2020-2023 Emir SARI <emir_sari@icloud.com>
+# Copyright (C) 2020-2024 Emir SARI <emir_sari@icloud.com>
 # This file is distributed under the same license as the Git package.
-# Emir SARI <emir_sari@icloud.com>, 2020-2023
+# Emir SARI <emir_sari@icloud.com>, 2020-2024
 #
 # ######################################################### #
 #     Git Türkçe kavramlar dizini / Git Turkish Glossary    #
@@ -27,6 +27,7 @@
 # detached HEAD               | ayrık HEAD                  #
 # dirty                       | kirli                       #
 # evil merge                  | uğursuz birleştirme         #
+# fanout                      | çıkış sayısı                #
 # fast-forward                | ileri sarım/sarmak          #
 # fetch                       | getirme(k)                  #
 # fixup                       | düzeltmek                   #
 # pathspec                    | yol belirteci               #
 # pattern                     | dizgi                       #
 # porcelain                   | okunabilir                  #
-# prune                       | budamak                     #
+# prune                       | buda(mak)                     #
 # pseudoref                   | yalancıktan başvuru         #
-# pull                        | çekme(k)                    #
-# push                        | itme(k)                     #
+# pull                        | çek(mek)                    #
+# push                        | it(mek)                     #
 # rebase                      | yeniden temellendirme(k)    #
 # record                      | kayıt yaz(mak)              #
 # ref                         | başvuru                     #
@@ -85,6 +86,7 @@
 # trailer                     | artbilgi                    #
 # tree                        | ağaç                        #
 # treeish                     | ağacımsı                    #
+# unborn                      | henüz doğmamış (dal)        #
 # unstage                     | hazırlıktan çıkar(mak)      #
 # upstream                    | üstkaynak                   #
 # worktree/working tree       | çalışma ağacı               #
@@ -94,8 +96,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Git Turkish Localization Project\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-09 11:15+0300\n"
-"PO-Revision-Date: 2023-11 13:00+0300\n"
+"POT-Creation-Date: 2024-02-16 22:04+0300\n"
+"PO-Revision-Date: 2024-02-16 22:00+0300\n"
 "Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
 "Language-Team: Turkish (https://github.com/bitigchi/git-po/)\n"
 "Language: tr\n"
@@ -1499,6 +1501,10 @@ msgstr "'%s' seçeneği '%s' gerektiriyor"
 msgid "Unexpected option --output"
 msgstr "Beklenmedik seçenek --output"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "fazladan komut satırı parametresi '%s'"
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Bilinmeyen arşiv biçimi '%s'"
@@ -1544,6 +1550,14 @@ msgstr "pek büyük gitattributes ikili nesnesi '%s' yok sayılıyor"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "hatalı --attr-source veya GIT_ATTR_SOURCE"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "'%s' dosyasının bilgileri alınamıyor"
+
+#, c-format
+msgid "unable to read %s"
+msgstr "%s okunamıyor"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "'%s' dosyasında hatalı tırnağa alınmış içerik: %s"
@@ -2823,12 +2837,12 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "'%s' için işleme nesnesi aranamadı"
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"'%s' dalı tümüyle birleştirilmemiş.\n"
-"Eğer silmek istediğinizden eminseniz 'git branch -D %s' çalıştırın."
+msgid "the branch '%s' is not fully merged"
+msgstr "'%s' dalı tümüyle birleştirilmedi"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "Onu silmek istediğinizden eminseniz 'git branch -D %s' çalıştırın."
 
 msgid "update of config-file failed"
 msgstr "config-file güncellenemedi"
@@ -3863,8 +3877,8 @@ msgstr "zorla çıkış yap (yerel değişiklikleri çöpe at)"
 msgid "new-branch"
 msgstr "yeni dal"
 
-msgid "new unparented branch"
-msgstr "yeni üst ögesi olmayan dal"
+msgid "new unborn branch"
+msgstr "yeni henüz doğmamış dal"
 
 msgid "update ignored files (default)"
 msgstr "yok sayılan dosyaları güncelle (öntanımlı)"
@@ -4115,9 +4129,6 @@ msgstr ""
 "clean.requireForce öntanımlı olarak 'true' ve ne -i ne -n ne de -f verilmiş; "
 "temizleme reddediliyor"
 
-msgid "-x and -X cannot be used together"
-msgstr "-x ve -X birlikte kullanılamaz"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<seçenekler>] [--] <depo> [<dizin>]"
 
@@ -4205,6 +4216,9 @@ msgstr "git dizini"
 msgid "separate git dir from working tree"
 msgstr "git dizinini çalışma ağacından ayır"
 
+msgid "specify the reference format to use"
+msgstr "kullanılacak başvuru biçimini belirt"
+
 msgid "key=value"
 msgstr "anahtar=değer"
 
@@ -4322,11 +4336,9 @@ msgstr "Çok fazla argüman."
 msgid "You must specify a repository to clone."
 msgstr "Klonlamak için bir depo belirtmelisiniz."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri; --depth, --shallow-since ve --shallow-exclude ile uyumsuz"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "bilinmeyen başvuru depolama biçimi '%s'"
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4454,11 +4466,11 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <dizin>] [--append]\n"
-"                       [--split[=<<strateji>]] [--reachable | --stdin-packs "
-"--stdin-commits]\n"
+"                       [--split[=<strateji>]] [--reachable | --stdin-packs | "
+"--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
 "                       <bölme-seçenekleri>"
@@ -6777,6 +6789,10 @@ msgstr "iş parçacığı desteği yok, %s yok sayılıyor"
 msgid "unable to read tree (%s)"
 msgstr "ağaç okunamıyor (%s)"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "%s ağacı okunamıyor"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "%s türündeki bir nesneden grep yapılamıyor"
@@ -7189,10 +7205,6 @@ msgstr "ciddi şişirme programı tutarsızlığı"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "%s İLE SHA1 ÇARPIŞMASI BULUNDU!"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "%s okunamıyor"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "var olan nesne bilgisi %s okunamıyor"
@@ -7333,13 +7345,15 @@ msgstr "paket nesnelerinde fsck hatası"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<şablon-dizini>]\n"
 "         [--separate-git-dir <git-dizini>] [--object-format=<biçim>]\n"
+"         [--ref-format=<biçim>]\n"
 "         [-b <dal-adı> | --initial-branch=<dal-adı>]\n"
-"         [--shared[=<izinler>]] [<dizin>]"
+"         [--shared[=<izin>]] [<dizin>]"
 
 msgid "permissions"
 msgstr "izinler"
@@ -8039,6 +8053,13 @@ msgstr ""
 "git merge-file [<seçenekler>] [-L <ad1> [-L <orij> [-L <ad2>]]] <dosya1> "
 "<orij-dosya> <dosya2>"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"diff-algorithm seçeneği şunları kabul eder: \"myers\", \"minimal\", "
+"\"patience\" ve \"histogram\""
+
 msgid "send results to standard output"
 msgstr "sonuçları standart çıktıya gönder"
 
@@ -8060,6 +8081,12 @@ msgstr "çakışmalarda onların sürümünü kullan"
 msgid "for conflicts, use a union version"
 msgstr "çakışmalarda birlik olmuş bir sürüm kullan"
 
+msgid "<algorithm>"
+msgstr "<algoritma>"
+
+msgid "choose a diff algorithm"
+msgstr "bir diff algoritması seç"
+
 msgid "for conflicts, use this marker size"
 msgstr "çakışmalarda bu imleyici boyutunu kullan"
 
@@ -8150,9 +8177,6 @@ msgstr "--trivial-merge, tüm diğer seçeneklerle uyumsuz"
 msgid "unknown strategy option: -X%s"
 msgstr "bilinmeyen strateji seçeneği: -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base, --stdin ile uyumsuz"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "hatalı oluşturulmuş girdi satırı: '%s'."
@@ -9077,6 +9101,10 @@ msgstr "Nesneler sıkıştırılıyor"
 msgid "inconsistency with delta count"
 msgstr "delta sayımında tutarsızlık"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "geçersiz pack.allowPackReuse değeri: '%s'"
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9332,10 +9360,10 @@ msgstr "Nesneler ortaya dökülüyor"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Toplam %<PRIu32> (delta %<PRIu32>), yeniden kullanılan %<PRIu32> (delta "
-"%<PRIu32>), yeniden kullanılan paket %<PRIu32>"
+"%<PRIu32>), yeniden kullanılan paket %<PRIu32> (%<PRIuMAX> konumundan)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10298,13 +10326,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "'C' anahtarı sayısal bir değer bekliyor"
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"seçenekleri uygula, rebase.autoSquash ile uyumlu değil. --no-autosquash "
-"eklemeyi düşünün"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -10717,10 +10738,10 @@ msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
 msgstr[0] ""
-"Not: refs/remotes hiyerarşisi dışındaki bir dal kaldırılmadı;\n"
+"Not: refs/remotes/ hiyerarşisi dışındaki bir dal kaldırılmadı;\n"
 "onu silmek için şunu kullanın:"
 msgstr[1] ""
-"Not: refs/remotes hiyerarşisi dışındaki bazı dallar kaldırılmadı;\n"
+"Not: refs/remotes/ hiyerarşisi dışındaki bazı dallar kaldırılmadı;\n"
 "onları silmek için şunu kullanın:"
 
 #, c-format
@@ -11298,6 +11319,76 @@ msgstr "--convert-graft-file argüman almaz"
 msgid "only one pattern can be given with -l"
 msgstr "-l ile yalnızca bir dizgi verilebilir"
 
+msgid "need some commits to replay"
+msgstr "yeniden oynatmak için birkaç işleme gerekli"
+
+msgid "--onto and --advance are incompatible"
+msgstr "--onto ve --advance birbiriyle uyumsuz"
+
+msgid "all positive revisions given must be references"
+msgstr "verilen tüm pozitif revizyonlar, başvuru olmalı"
+
+msgid "argument to --advance must be a reference"
+msgstr "--advance'a olan argüman bir başvuru olmalı"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"birden çok kaynaklı hedef ilerletilemiyor; çünkü sıralama hatalı tanımlanmış "
+"olurdu"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr ""
+"bunun --advance veya --onto işlemi olup olmadığı örtük olarak algılanamıyor"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"birden çok kaynak dallı hedef ilerletilemiyor; çünkü sıralama hatalı "
+"tanımlanmış olurdu"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "--onto için olan doğru temel örtük olarak algılanamıyor"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(DENEYSEL!) git replay ([--contained] --onto <yeni-temel> | --advance <dal>) "
+"<revizyon-erimi>..."
+
+msgid "make replay advance given branch"
+msgstr "verilen dalı önceden yeniden oynat"
+
+msgid "replay onto given commit"
+msgstr "verilen işlemeye yeniden oynat"
+
+msgid "advance all branches contained in revision-range"
+msgstr "revizyon eriminde içerilen tüm dalları ilerlet"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "--onto veya --advance seçeneğinin kullanımı zorunlu"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"'struct rev_info' içindeki '%s' biti zorlanacağından kimi revizyon yürütme "
+"seçenekleri geçersiz kılınacak"
+
+msgid "error preparing revisions"
+msgstr "revizyonlar hazırlanırken hata"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "kök işlemeye kadar yeniden oynatma henüz desteklenmiyor!"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "birleştirme işlemelerini yeniden oynatma henüz desteklenmiyor!"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr ""
@@ -11506,15 +11597,6 @@ msgstr "--prefix bir argüman gerektiriyor"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "--abbrev-ref için bilinmeyen kip: %s"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden, --branches ile birlikte kullanılamıyor"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden, --tags ile birlikte kullanılamıyor"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden, --remotes ile birlikte kullanılamıyor"
-
 msgid "this operation must be run in a work tree"
 msgstr "bu işlem bir çalışma ağacı içinde çalıştırılmalı"
 
@@ -11920,9 +12002,6 @@ msgstr "sonuçları stdout'a yazdırma (--verify ile birlikte kullanışlı)"
 msgid "show refs from stdin that aren't in local repository"
 msgstr "stdin'den yerel bir depoda olmayan başvuruları göster"
 
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "yalnızca '%s', '%s' veya '%s' arasından biri verilebilir"
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -13366,29 +13445,29 @@ msgstr "Olası kaynak dal yok, '--orphan' anlamı çıkarılıyor"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
-"Bu depo için yeni bir yetim dal içeren (işlemesiz dal) bir\n"
-"çalışma ağacı oluşturmak istediyseniz bunu --orphan bayrağı\n"
-"ile yapabilirsiniz:\n"
+"Bu depo için henüz doğmamış bir dal (işleme içermeyen dal) içeren\n"
+"bir çalışma ağacı oluşturmak istediyseniz bunu --orphan bayrağını\n"
+"kullanarak yapabilirsiniz:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
-"Bu depo için yeni bir yetim dal içeren (işlemesiz dal) bir\n"
-"çalışma ağacı oluşturmak istediyseniz bunu --orphan bayrağı\n"
-"ile yapabilirsiniz:\n"
+"Bu depo için henüz doğmamış bir dal (işleme içermeyen dal) içeren\n"
+"bir çalışma ağacı oluşturmak istediyseniz bunu --orphan bayrağını\n"
+"kullanarak yapabilirsiniz:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 
@@ -13446,6 +13525,10 @@ msgstr "'%s' dizini oluşturulamadı"
 msgid "initializing"
 msgstr "ilklendiriliyor"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "oluşturulan '%s' çalışma ağacı bulunamadı"
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "Çalışma ağacı hazırlanıyor (yeni dal '%s')"
@@ -13483,10 +13566,6 @@ msgstr ""
 "Bir uzak konum olmasına rağmen hiçbir yerel/uzak başvuru yok, durduruluyor;\n"
 "geçersiz kılmak veya önce bir uzak konum getirmek için 'add -f' kullanın"
 
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "'%s' ve '%s' birlikte kullanılamaz"
-
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr "diğer çalışma ağacında çıkış yapılmış olsa bile <dal> çıkışını yap"
 
@@ -13496,8 +13575,8 @@ msgstr "yeni bir dal oluştur"
 msgid "create or reset a branch"
 msgstr "yeni bir dal oluştur veya sıfırla"
 
-msgid "create unborn/orphaned branch"
-msgstr "doğmamış/yetim bırakılmış dal oluştur"
+msgid "create unborn branch"
+msgstr "henüz doğmamış dal oluştur"
 
 msgid "populate the new working tree"
 msgstr "yeni çalışma ağacını doldur"
@@ -13519,11 +13598,8 @@ msgid "options '%s', '%s', and '%s' cannot be used together"
 msgstr "'%s', '%s' ve '%s' seçenekleri birlikte kullanılamaz"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "'%s' ve '%s' seçenekleri birlikte kullanılamaz"
-
-msgid "<commit-ish>"
-msgstr "<işlememsi>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "'%s' seçeneği ve işlememsiler birlikte kullanılamaz"
 
 msgid "added with --lock"
 msgstr "--lock ile eklendi"
@@ -14135,6 +14211,10 @@ msgstr "Bir depodaki paketlenmemiş nesneleri paketle"
 msgid "Create, list, delete refs to replace objects"
 msgstr "Nesne değiştirmek için başvurular oluştur, sil, listele"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"DENEYSEL: İşlemeleri yeni temelde yeniden oynat, çıplak depolarla da çalışır"
+
 msgid "Generates a summary of pending changes"
 msgstr "Bekleyen değişikliklerin bir özetini çıkart"
 
@@ -14373,6 +14453,32 @@ msgstr "Büyük Git depolarını yönetmek için bir araç"
 msgid "commit-graph file is too small"
 msgstr "commit-graph dosyası pek küçük"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "commit-graph OID çıkış sayısı iri parçası boyutu yanlış"
+
+msgid "commit-graph fanout values out of order"
+msgstr "commit-graph çıkış sayısı değerleri sırasız: fanout[%d] = %u != %u"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "commit-graph OID arama iri parçası boyutu yanlış"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "commit-graph işleme verisi iri parçası boyutu yanlış"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr "commit-graph kuşaklar iri parçası boyutu yanlış"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "commit-graph changed-path indeksi iri parçası boyutu pek küçük"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"commit-graph dosyasındaki pek küçük changed-path iri parçası (%<PRIuMAX> < "
+"%<PRIuMAX>) yok sayılıyor"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr "commit-graph imzası %X, %X ile eşleşmiyor"
@@ -14389,6 +14495,17 @@ msgstr "commit-graph sağlama sürümü %X, %X ile eşleşmiyor"
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "commit-graph dosyası %u iri parça tutmak için pek küçük"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr ""
+"commit-graph'ten gerekli OID çıkış sayısı iri parçası eksik veya hasarlı"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr "commit-graph'ten gerekli OID arama iri parçası eksik veya hasarlı"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr ""
+"commit-graph'ten gerekli OID çıkış sayısı iri parçası eksik veya hasarlı"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "commit-graph temel grafiği iri parçasına iye değil"
 
@@ -14402,6 +14519,9 @@ msgstr "commit-graph zinciri eşleşmiyor"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "temel grafikteki işleme sayısı pek yüksek: %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "commit-graph zincir dosyası pek küçük"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr "geçersiz commit-graph zinciri: '%s'. satır bir sağlama değil"
@@ -14422,6 +14542,9 @@ msgstr "commit-graph, taşım oluşturma verisi gerektiriyor; ancak hiç yok"
 msgid "commit-graph overflow generation data is too small"
 msgstr "commit-graph, taşım üretim verisi pek küçük"
 
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "commit-graph extra-edges işaretçisi sınırlar dışında"
+
 msgid "Loading known commits in commit graph"
 msgstr "İşleme grafiğindeki bilinen işlemeler yükleniyor"
 
@@ -15562,6 +15685,10 @@ msgstr ""
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "'diff.submodule' yapılandırma değişkeni için bilinmeyen değer: '%s'"
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "'%s' yapılandırması için bilinmeyen değer: %s"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -15642,13 +15769,6 @@ msgstr "hatalı --color-moved argümanı: %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "--color-moved-ws içinde geçersiz kip '%s'"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"diff-algorithm seçeneği şunları kabul eder: \"myers\", \"minimal\", "
-"\"patience\" ve \"histogram\""
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "%s için geçersiz argüman"
@@ -15692,8 +15812,8 @@ msgstr "makinede okunabilen --stat"
 msgid "output only the last line of --stat"
 msgstr "--stat'ın yalnızca son satırını çıktı ver"
 
-msgid "<param1,param2>..."
-msgstr "<param1,param2>..."
+msgid "<param1>,<param2>..."
+msgstr "<param1>,<param2>..."
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -15703,8 +15823,8 @@ msgstr ""
 msgid "synonym for --dirstat=cumulative"
 msgstr "--dirstat=cumulative eşanlamlısı"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "--dirstat=files,param1,param2... eşanlamlısı"
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "--dirstat=files,<param1>,<param2>... eşanlamlısı"
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr ""
@@ -15879,12 +15999,6 @@ msgstr "diff'i \"patience diff\" algoritmasını kullanarak oluştur"
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "diff'i \"histogram diff\" algoritmasını kullanarak oluştur"
 
-msgid "<algorithm>"
-msgstr "<algoritma>"
-
-msgid "choose a diff algorithm"
-msgstr "bir diff algoritması seç"
-
 msgid "<text>"
 msgstr "<metin>"
 
@@ -17367,7 +17481,13 @@ msgid "failed to read the cache"
 msgstr "önbellek okunamadı"
 
 msgid "multi-pack-index OID fanout is of the wrong size"
-msgstr "multi-pack-index OID ikiye bölümünün boyutu hatalı"
+msgstr "multi-pack-index OID çıkış sayısı boyutu yanlış"
+
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"oid çıkış sayısı sırasız: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
 
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "multi-pack-index OID arama iri parçası yanlış boyutlu"
@@ -17415,6 +17535,13 @@ msgstr "multi-pack-index paket adlarının sırasız: '%s' şundan önce: '%s'"
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "hatalı pack-int-id: %u (%u toplam paket)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX, BTMP iri parçasını içermiyor"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "biteşlemli %<PRIu32> paketi yüklenemedi"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr "multi-pack-index bir 64 bit ofset depoluyor; ancak off_t pek küçük"
 
@@ -17498,11 +17625,6 @@ msgstr "yanlış sağlama toplamı"
 msgid "Looking for referenced packfiles"
 msgstr "Başvurulmuş paket dosyaları aranıyor"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr "oid fanout sırasız: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-
 msgid "the midx contains no oid"
 msgstr "midx bir oid içermiyor"
 
@@ -18022,9 +18144,12 @@ msgstr "çoklu paket biteşlemi gereken ters indeksi içermiyor"
 msgid "could not open pack %s"
 msgstr "%s paketi açılamadı"
 
+msgid "could not determine MIDX preferred pack"
+msgstr "MIDX yeğlenen paketi algılanamadı"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
-msgstr "tercih edilen (%s) paket geçersiz"
+msgstr "yeğlenen paket (%s) geçersiz"
 
 msgid "corrupt bitmap lookup table: triplet position out of index"
 msgstr "hasarlı biteşlem arama tablosu: üçlü konum indeks dışında"
@@ -18041,6 +18166,10 @@ msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr ""
 "hasarlı ewah biteşlemi: \"%s\" işlemesinin biteşleminde kısaltılmış üstbilgi"
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr "paket yüklenemiyor: '%s', pack-reuse devre dışı bırakılıyor"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "'%s' nesnesi, tür biteşlemlerinde bulunamadı"
@@ -18132,6 +18261,9 @@ msgstr "%<PRIu64> konumunda geçersiz rev-index konumu: %<PRIu32> != %<PRIu32>"
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "multi-pack-index reverse-index iri parçası yanlış boyutlu"
 
+msgid "could not determine preferred pack"
+msgstr "yeğlenen paket algılanamadı"
+
 msgid "cannot both write and verify reverse index"
 msgstr "ters indeks dosyası hem yazılıp hem doğrulanamıyor"
 
@@ -18194,10 +18326,6 @@ msgstr "%s kullanılabilir değil"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s negatif olmayan bir tamsayı bekliyor, isteğe bağlı k/m/g eki ile"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s, %s ile uyumsuz"
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "belirsiz seçenek: %s (--%s%s veya --%s%s olabilir)"
@@ -18511,10 +18639,6 @@ msgstr "'%s' dosyası indekslenemiyor"
 msgid "unable to add '%s' to index"
 msgstr "'%s' indekse eklenemiyor"
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "'%s' dosyasının bilgileri alınamıyor"
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "'%s' hem bir dosya hem de bir dizin olarak görünüyor"
@@ -19086,10 +19210,6 @@ msgstr "'%s' mevcut; '%s' oluşturulamıyor"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "'%s' ve '%s' aynı anda işlenemiyor"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "%s başvurusu kaldırılamadı"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "%s başvurusu silinemedi: %s"
@@ -20446,6 +20566,9 @@ msgstr "Kendiliğinden zulalama çakışmalara neden oldu."
 msgid "Autostash exists; creating a new stash entry."
 msgstr "Kendiliğinden zulalama mevcut; yeni bir zula girdisi oluşturuluyor."
 
+msgid "autostash reference is a symref"
+msgstr "kendiliğinden zulalama başvurusu bir sembol başvurusu"
+
 msgid "could not detach HEAD"
 msgstr "HEAD ayrılamadı"
 
@@ -20756,6 +20879,10 @@ msgstr "şablonlar '%s' konumundan kopyalanmıyor: %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "geçersiz başlangıç dalı adı: '%s'"
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init: --initial-branch=%s yok sayıldı"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "%d dosya türü ele alınamıyor"
@@ -20767,14 +20894,15 @@ msgstr "%s şuraya taşınamıyor: %s"
 msgid "attempt to reinitialize repository with different hash"
 msgstr "depoyu başka bir sağlama ile yeniden ilklendirme deneniyor"
 
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr ""
+"depo başka bir başvuru depolama biçimiyle yeniden ilklendirilmeye çalışılıyor"
+
 #, c-format
 msgid "%s already exists"
 msgstr "%s halihazırda var"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init: --initial-branch=%s yok sayıldı"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr "%s%s içindeki var olan paylaşılan Git deposu yeniden ilklendirildi\n"
@@ -21039,12 +21167,6 @@ msgstr "her bir yinelemeden önce önbellek ağacını temizle"
 msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr "önbellek ağacındaki geçersizleştirilecek girdi sayısı (öntanımlı 0)"
 
-msgid "unhandled options"
-msgstr "beklenmeyen seçenekler"
-
-msgid "error preparing revisions"
-msgstr "revizyonlar hazırlanırken hata"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "%s işlemesi ulaşılabilir olarak imlenmedi"
@@ -21198,9 +21320,6 @@ msgstr "uzak servis yolu ayarlama protokol tarafından desteklenmiyor"
 msgid "invalid remote service path"
 msgstr "geçersiz uzak konum servis yolu"
 
-msgid "operation not supported by protocol"
-msgstr "işlem protokol tarafından desteklenmiyor"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "%s altservisine bağlanılamıyor"
@@ -21330,10 +21449,6 @@ msgstr "transport.color.* yapılandırması ayrıştırılamadı"
 msgid "support for protocol v2 not implemented yet"
 msgstr "protokol v2 desteği henüz yerine getirilmedi"
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "'%s' yapılandırması için bilinmeyen değer: %s"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "'%s' taşıyıcısına izin verilmiyor"
@@ -21387,6 +21502,9 @@ msgstr "bundle-uri işlemi protokol tarafından desteklenmiyor"
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "sunucu tarafından tanıtılan bundle-uri listesi alınamadı"
 
+msgid "operation not supported by protocol"
+msgstr "işlem protokol tarafından desteklenmiyor"
+
 msgid "too-short tree object"
 msgstr "ağaç nesnesi çok kısa"
 
@@ -22210,6 +22328,10 @@ msgstr "Ek olarak, indeksiniz işlenmemiş değişiklikler içeriyor."
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "%s yapılamıyor: İndeksiniz işlenmemiş değişiklikler içeriyor."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "'%s' bilinmeyen biçemi şunun için verildi: '%s'"
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
index 086890552a23c17f8721c9a364320be1a3ee3998..0507e387babbbd98578060270e3293ba84ccdda8 100644 (file)
--- a/po/uk.po
+++ b/po/uk.po
@@ -9,7 +9,7 @@ msgstr ""
 "Project-Id-Version: Git v2.43\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
 "POT-Creation-Date: 2023-11-09 14:26-0800\n"
-"PO-Revision-Date: 2023-11-09 14:34-0800\n"
+"PO-Revision-Date: 2024-02-11 09:26-0800\n"
 "Last-Translator: Arkadii Yakovets <ark@cho.red>\n"
 "Language-Team: Ukrainian <https://github.com/arkid15r/git-uk-l10n/>\n"
 "Language: uk\n"
@@ -18,7 +18,7 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
 "n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
-"X-Generator: Poedit 3.4.1\n"
+"X-Generator: Poedit 3.4.2\n"
 
 #, c-format
 msgid "Huh (%s)?"
@@ -1443,6 +1443,10 @@ msgstr "опція \"%s\" потребує \"%s\""
 msgid "Unexpected option --output"
 msgstr "Неочікувана опція --output"
 
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "зайвий параметр командного рядка: \"%s\""
+
 #, c-format
 msgid "Unknown archive format '%s'"
 msgstr "Невідомий формат архіву \"%s\""
@@ -1488,6 +1492,14 @@ msgstr "ігнорування надто великих gitattributes blob \"%s
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "невірний --attr-source або GIT_ATTR_SOURCE"
 
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "не вдалося виконати stat для \"%s\""
+
+#, c-format
+msgid "unable to read %s"
+msgstr "не вдалося прочитати %s"
+
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
 msgstr "Невірно процитований вміст у файлі \"%s\": %s"
@@ -1666,10 +1678,12 @@ msgstr ""
 msgid "not tracking: ambiguous information for ref '%s'"
 msgstr "не відстежується: неоднозначна інформація для посилання \"%s\""
 
+#. #-#-#-#-#  branch.c.po  #-#-#-#-#
 #. TRANSLATORS: This is a line listing a remote with duplicate
 #. refspecs in the advice message below. For RTL languages you'll
 #. probably want to swap the "%s" and leading "  " space around.
 #.
+#. #-#-#-#-#  object-name.c.po  #-#-#-#-#
 #. TRANSLATORS: This is line item of ambiguous object output
 #. from describe_ambiguous_object() above. For RTL languages
 #. you'll probably want to swap the "%s" and leading " " space
@@ -2325,7 +2339,7 @@ msgid ""
 "git bisect start [--term-(new|bad)=<term> --term-(old|good)=<term>]    [--no-"
 "checkout] [--first-parent] [<bad> [<good>...]] [--]    [<pathspec>...]"
 msgstr ""
-"git bisect start [--term-{new,bad}=<термін> --term-{old,good}=<термін>]    "
+"git bisect start [--term-(new,bad)=<термін> --term-(old,good)=<термін>]    "
 "[--no-checkout] [--first-parent] [<поганий> [<добрий>...]] [--]    "
 "[<визначник шляху>...]"
 
@@ -2785,11 +2799,12 @@ msgid "couldn't look up commit object for '%s'"
 msgstr "не вдалося знайти об’єкт коміту для \"%s\""
 
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
+msgid "the branch '%s' is not fully merged"
+msgstr "гілка \"%s\" злита не повністю"
+
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
 msgstr ""
-"гілка \"%s\" злита не повністю.\n"
 "Якщо ви впевнені, що хочете її видалити, виконайте \"git branch -D %s\""
 
 msgid "update of config-file failed"
@@ -2856,11 +2871,11 @@ msgstr "неприпустима назва гілки: \"%s\""
 
 #, c-format
 msgid "no commit on branch '%s' yet"
-msgstr "поки що немає комітів в гілці \"%s\""
+msgstr "поки що немає комітів у гілці \"%s\""
 
 #, c-format
 msgid "no branch named '%s'"
-msgstr "немає гілки з ім’ям \"%s\""
+msgstr "немає гілки з назвою \"%s\""
 
 msgid "branch rename failed"
 msgstr "не вдалося перейменувати гілку"
@@ -3078,7 +3093,7 @@ msgid ""
 "'--set-upstream-to' instead"
 msgstr ""
 "опція \"--set-upstream\" більше не підтримується. Будь ласка, використовуйте "
-"\"--track\" або \"--set-upstream-to\""
+"\"--track\" або \"--set-upstream-to\" замість неї"
 
 msgid "git version:\n"
 msgstr "версія git:\n"
@@ -3848,8 +3863,8 @@ msgstr "переключити примусово (викинути локаль
 msgid "new-branch"
 msgstr "нова-гілка"
 
-msgid "new unparented branch"
-msgstr "нова Ð³Ñ\96лка Ð±ÐµÐ· Ð´Ð¶ÐµÑ\80ела"
+msgid "new unborn branch"
+msgstr "нова Ð½ÐµÐ½Ð°Ñ\80оджена Ð³Ñ\96лка"
 
 msgid "update ignored files (default)"
 msgstr "оновити ігноровані файли (за замовчуванням)"
@@ -4100,9 +4115,6 @@ msgstr ""
 "clean.requireForce встановлено у true за замовчуванням і не задано ні -i, ні "
 "-n, ні -f; відмовлено в прибиранні"
 
-msgid "-x and -X cannot be used together"
-msgstr "-x та -X не можна використовувати разом"
-
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<опції>] [--] <сховище> [<директорія>]"
 
@@ -4193,6 +4205,9 @@ msgstr "git директорія"
 msgid "separate git dir from working tree"
 msgstr "відокремити git-директорію від робочого дерева"
 
+msgid "specify the reference format to use"
+msgstr "вкажіть формат посилання, який потрібно використовувати"
+
 msgid "key=value"
 msgstr "ключ=значення"
 
@@ -4311,11 +4326,9 @@ msgstr "Забагато аргументів."
 msgid "You must specify a repository to clone."
 msgstr "Треба вказати сховище для клонування."
 
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr ""
-"--bundle-uri несумісний з --depth, --shallow-since та --shallow-exclude"
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "невідомий формат зберігання посилань \"%s\""
 
 #, c-format
 msgid "repository '%s' does not exist"
@@ -4450,7 +4463,7 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <директорія>] [--append] [--object-dir "
 "<директорія>] [--append] [--object-dir <директорія>] [--append\n"
@@ -4458,7 +4471,7 @@ msgstr ""
 "| --stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <число>] [--"
 "[no-]progress]\n"
-"                       <опції розділення>"
+"                       <опції-розділення>"
 
 msgid "dir"
 msgstr "директорія"
@@ -6757,7 +6770,7 @@ msgid "scheduler to trigger git maintenance run"
 msgstr "планувальник для запуску обслуговування git"
 
 msgid "failed to set up maintenance schedule"
-msgstr "не вдалося встановити графік обслуговування"
+msgstr "не вдалося встановити розклад обслуговування"
 
 msgid "failed to add repo to global config"
 msgstr "не вдалося додати сховище до глобальної конфігурації"
@@ -6776,6 +6789,7 @@ msgstr "grep: не вдалося створити потік: %s"
 msgid "invalid number of threads specified (%d) for %s"
 msgstr "невірно вказана кількість потоків (%d) для %s"
 
+#. #-#-#-#-#  grep.c.po  #-#-#-#-#
 #. TRANSLATORS: %s is the configuration
 #. variable for tweaking threads, currently
 #. grep.threads
@@ -6788,6 +6802,10 @@ msgstr "немає підтримки потоків, ігнорування %s"
 msgid "unable to read tree (%s)"
 msgstr "не вдалося прочитати дерево (%s)"
 
+#, c-format
+msgid "unable to read tree %s"
+msgstr "не вдалося прочитати дерево %s"
+
 #, c-format
 msgid "unable to grep from object of type %s"
 msgstr "не вдалося виконати grep для об’єкта типу %s"
@@ -7200,10 +7218,6 @@ msgstr "серйозне неспівпадіння під час розпаку
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "ВИЯВЛЕНО SHA1 КОЛІЗІЮ З %s!"
 
-#, c-format
-msgid "unable to read %s"
-msgstr "не вдалося прочитати %s"
-
 #, c-format
 msgid "cannot read existing object info %s"
 msgstr "неможливо прочитати інформацію про існуючий об’єкт %s"
@@ -7348,11 +7362,13 @@ msgstr "помилка fsck в об’єктах пакунка"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<шаблон-директорія>]\n"
 "         [--separate-git-dir <git-директорія>] [--object-format=<формат>]\n"
+"         [--ref-format=<формат>]\n"
 "         [-b <назва-гілки> | --initial-branch=<назва-гілки>]\n"
 "         [--shared[=<дозволи>]] [<директорія>]"
 
@@ -7400,8 +7416,8 @@ msgid ""
 "                       [--parse] [<file>...]"
 msgstr ""
 "git interpret-trailers [--in-place] [--trim-empty]\n"
-"                       [(--trailer (<ключ>|<аліасКлюча>)"
-"[(=|:)<значення>])...]\n"
+"                       [(--trailer <ключ>|"
+"<аліасКлюча>[(=|:)<значення>])...]\n"
 "                       [--parse] [<файл>...]"
 
 msgid "edit files in place"
@@ -7411,7 +7427,7 @@ msgid "trim empty trailers"
 msgstr "обрізати порожні причепи"
 
 msgid "placement"
-msgstr "розташування"
+msgstr "розміщення"
 
 msgid "where to place the new trailer"
 msgstr "де розмістити новий причіп"
@@ -8065,11 +8081,18 @@ msgstr ""
 "git merge-file [<опції>] [-L <назва1> [-L <оріг> [-L <назва2>]]] <файл1> "
 "<оріг-файл> <файл2>"
 
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"опція diff-algorithm приймає значення \"myers\", \"minimal\", \"patience\" "
+"та \"histogram\""
+
 msgid "send results to standard output"
 msgstr "надсилати результати до стандартного виводу"
 
 msgid "use object IDs instead of filenames"
-msgstr "використовувати ID обʼєктів замість назв файлів"
+msgstr "використовувати ідентифікатори обʼєктів замість назв файлів"
 
 msgid "use a diff3 based merge"
 msgstr "використовувати злиття на основі diff3"
@@ -8086,6 +8109,12 @@ msgstr "у разі конфліктів використовувати їхню
 msgid "for conflicts, use a union version"
 msgstr "у разі конфліктів використовувати об’єднану версію"
 
+msgid "<algorithm>"
+msgstr "<алгоритм>"
+
+msgid "choose a diff algorithm"
+msgstr "вибрати алгоритм різниці"
+
 msgid "for conflicts, use this marker size"
 msgstr "у разі конфліктів використовувати цей розмір маркера"
 
@@ -8097,7 +8126,7 @@ msgstr "встановити мітки для файл1/оріг-файл/фа
 
 #, c-format
 msgid "object '%s' does not exist"
-msgstr "обʼєкт \"%s\" не існує"
+msgstr "обєкт \"%s\" не існує"
 
 msgid "Could not write object file"
 msgstr "Не вдалося записати файл обʼєкта"
@@ -8177,9 +8206,6 @@ msgstr "--trivial-merge несумісна з усіма іншими опція
 msgid "unknown strategy option: -X%s"
 msgstr "невідомий варіант стратегії: -X%s"
 
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base несумісна з --stdin"
-
 #, c-format
 msgid "malformed input line: '%s'."
 msgstr "невірно сформований рядок вводу: \"%s\"."
@@ -9112,6 +9138,10 @@ msgstr "Компресія обʼєктів"
 msgid "inconsistency with delta count"
 msgstr "неспівпадіння з підрахунком дельти"
 
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "неприпустиме значення pack.allowPackReuse: \"%s\""
+
 #, c-format
 msgid ""
 "value of uploadpack.blobpackfileuri must be of the form '<object-hash> <pack-"
@@ -9368,10 +9398,10 @@ msgstr "Перерахування обʼєктів"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "Всього %<PRIu32> (дельта %<PRIu32>), повторно використано %<PRIu32> (дельта "
-"%<PRIu32>), повторно використано пакунків %<PRIu32>"
+"%<PRIu32>), повторно використано пакунків %<PRIu32> (з %<PRIuMAX>)"
 
 msgid ""
 "'git pack-redundant' is nominated for removal.\n"
@@ -10360,13 +10390,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "перемикач \"C\" очікує числове значення"
 
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr ""
-"apply опції несумісні з rebase.autoSquash.  Розгляньте можливість додавання "
-"--no-autosquash"
-
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
 "no-rebase-merges"
@@ -11156,7 +11179,7 @@ msgid "write a multi-pack index of the resulting packs"
 msgstr "записати multi-pack-index результуючих пакунків"
 
 msgid "pack prefix to store a pack containing pruned objects"
-msgstr "пÑ\80еÑ\84Ñ\96кÑ\81 Ð¿Ð°ÐºÑ\83нка Ð´Ð»Ñ\8f Ð·Ð±ÐµÑ\80Ñ\96ганнÑ\8f Ð¿Ð°ÐºÑ\83нка Ð· Ð¾Ð±Ñ\80Ñ\96заними Ð¾Ð±Ê¼Ñ\94кÑ\82ами"
+msgstr "префікс для зберігання пакунка з обрізаними обʼєктами"
 
 msgid "pack prefix to store a pack containing filtered out objects"
 msgstr "префікс для зберігання пакунка з відфільтрованими  обʼєктами"
@@ -11166,7 +11189,7 @@ msgstr "неможливо видалити пакунки в precious-objects 
 
 #, c-format
 msgid "option '%s' can only be used along with '%s'"
-msgstr "опÑ\86Ñ\96Ñ\8e \"%s\" Ð¼Ð¾Ð¶Ð½Ð° Ð²Ð¸ÐºÐ¾Ñ\80иÑ\81Ñ\82овÑ\83ваÑ\82и тільки разом з \"%s\""
+msgstr "опÑ\86Ñ\96Ñ\8f \"%s\" Ð¼Ð¾Ð¶Ðµ Ð±Ñ\83Ñ\82и Ð²Ð¸ÐºÐ¾Ñ\80иÑ\81Ñ\82ана тільки разом з \"%s\""
 
 msgid "Nothing new to pack."
 msgstr "Немає нічого нового для пакування."
@@ -11371,6 +11394,75 @@ msgstr "--convert-graft-file не потребує аргументів"
 msgid "only one pattern can be given with -l"
 msgstr "тільки один шаблон може бути заданий з -l"
 
+msgid "need some commits to replay"
+msgstr "потрібні деякі комміти для відтворення"
+
+msgid "--onto and --advance are incompatible"
+msgstr "--onto та --advance несумісні"
+
+msgid "all positive revisions given must be references"
+msgstr "всі надані позитивні ревізії мають бути посиланнями"
+
+msgid "argument to --advance must be a reference"
+msgstr "аргумент до --advance має бути посиланням"
+
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr ""
+"неможливо просунути посилання з декількома джерелами, тому що впорядкування "
+"буде нечітко визначеним"
+
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr "неможливо неявно визначити, чи це операція --advance або --onto"
+
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr ""
+"неможливо просунути посилання з декількома джерельними гілками, тому що "
+"впорядкування буде нечітко визначеним"
+
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "неможливо неявно визначити вірну базу для --onto"
+
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(ЕКСПЕРИМЕНТАЛЬНО!) git replay ([--contained] --onto <нова-база> | --advance "
+"<гілка>) <діапазон-ревізій>..."
+
+msgid "make replay advance given branch"
+msgstr "зробити відтворення з просуванням даної гілки"
+
+msgid "replay onto given commit"
+msgstr "відтворити на заданий коміт"
+
+msgid "advance all branches contained in revision-range"
+msgstr "просунути всі гілки, що містяться в діапазоні ревізій"
+
+msgid "option --onto or --advance is mandatory"
+msgstr "опція --onto або --advance є обовʼязковою"
+
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr ""
+"деякі опції проходження по ревізіям будуть перевизначені, оскільки біт "
+"\"%s\" у \"struct rev_info\" буде примусово використано"
+
+msgid "error preparing revisions"
+msgstr "помилка при підготовці ревізій"
+
+msgid "replaying down to root commit is not supported yet!"
+msgstr "відтворення до кореневого коміту поки що не підтримується!"
+
+msgid "replaying merge commits is not supported yet!"
+msgstr "відтворення коммітів злиття поки що не підтримується!"
+
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
 msgstr ""
@@ -11583,15 +11675,6 @@ msgstr "--prefix потребує аргументу"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "невідомий режим для --abbrev-ref: %s"
 
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden не можна використовувати разом з --branches"
-
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden неможливо використовувати разом з --tags"
-
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden неможливо використовувати разом з --remotes"
-
 msgid "this operation must be run in a work tree"
 msgstr "цю операцію треба виконувати в робочому дереві"
 
@@ -12005,10 +12088,6 @@ msgstr "не виводити результати у stdout (корисно з
 msgid "show refs from stdin that aren't in local repository"
 msgstr "показати посилання з stdin, яких немає в локальному сховищі"
 
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "можна вказати тільки один з \"%s\", \"%s\" або \"%s\""
-
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
 "rules) [<options>]"
@@ -12820,7 +12899,7 @@ msgstr ""
 "branch] [--] [<шлях>...]"
 
 msgid "Failed to resolve HEAD as a valid ref."
-msgstr "Ð\9dе Ð²Ð´Ð°Ð»Ð¾Ñ\81Ñ\8f Ñ\80озпÑ\96знаÑ\82и HEAD Ñ\8fк дійсне посилання."
+msgstr "Ð\9dе Ð²Ð´Ð°Ð»Ð¾Ñ\81Ñ\8f Ñ\80озвʼÑ\8fзаÑ\82и HEAD Ð² дійсне посилання."
 
 msgid "git submodule absorbgitdirs [<options>] [<path>...]"
 msgstr "git submodule absorbgitdirs [<опції>] [<шлях>...]"
@@ -13325,7 +13404,7 @@ msgstr "%d\n"
 
 #, c-format
 msgid "index-version: was %d, set to %d"
-msgstr "index-version: було %d, стало %d"
+msgstr "версія індексу: була %d, стала %d"
 
 msgid ""
 "core.splitIndex is set to false; remove or change it, if you really want to "
@@ -13482,13 +13561,13 @@ msgstr "Немає можливої джерельної гілки, що озн
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
-"Якщо ви хочете створити робоче дерево, що містить нову сирітську гілку\n"
+"Якщо ви хочете створити робоче дерево, що містить нову ненароджену гілку\n"
 "(гілку без комітів) для цього сховища, ви можете зробити це\n"
 "за допомогою прапорця --orphan:\n"
 "\n"
@@ -13496,13 +13575,13 @@ msgstr ""
 
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
-"Якщо ви хочете створити робоче дерево, що містить нову сирітську гілку\n"
+"Якщо ви хочете створити робоче дерево, що містить нову ненароджену гілку\n"
 "(гілку без комітів) для цього сховища, ви можете зробити це\n"
 "за допомогою прапорця --orphan:\n"
 "\n"
@@ -13565,6 +13644,10 @@ msgstr "не вдалося створити директорію \"%s\""
 msgid "initializing"
 msgstr "ініціалізація"
 
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "не вдалося знайти створене робоче дерево \"%s\""
+
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
 msgstr "Підготовка робочого дерева (нова гілка \"%s\")"
@@ -13601,12 +13684,8 @@ msgid ""
 msgstr ""
 "Не існує локальних або віддалених посилань, незважаючи на наявність "
 "принаймні одного віддаленого\n"
-"призначення, зупинка; скористайтесь \"add -f\" для перевизначення або "
-"спочатку виконайте отримання віддаленого посилання"
-
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "\"%s\" і \"%s\" не можна використовувати разом"
+"призначення, зупинка; скористайтесь \"add -f\", щоб перевизначити, або "
+"спочатку виконайте отримання з віддаленного сховища"
 
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr ""
@@ -13618,8 +13697,8 @@ msgstr "створити нову гілку"
 msgid "create or reset a branch"
 msgstr "створити або скинути гілку"
 
-msgid "create unborn/orphaned branch"
-msgstr "створити ненароджену/сирітську гілку"
+msgid "create unborn branch"
+msgstr "створити ненароджену гілку"
 
 msgid "populate the new working tree"
 msgstr "заповнити нове робоче дерево"
@@ -13642,11 +13721,8 @@ msgid "options '%s', '%s', and '%s' cannot be used together"
 msgstr "опції \"%s\", \"%s\" та \"%s\" не можна використовувати разом"
 
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "опції \"%s\" і \"%s\" не можна використовувати разом"
-
-msgid "<commit-ish>"
-msgstr "<комітоподібне>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "опцію \"%s\" не можна використовувати разом з комітоподібними"
 
 msgid "added with --lock"
 msgstr "додано з --lock"
@@ -13926,7 +14002,7 @@ msgstr "ідентифікатор завершення фрагмента зʼ
 
 #, c-format
 msgid "chunk id %<PRIx32> not %d-byte aligned"
-msgstr "шматок в id %<PRIx32> не %d-byte впорядкований"
+msgstr "шматок id %<PRIx32> не є %d-byte впорядкованим"
 
 #, c-format
 msgid "improper chunk offset(s) %<PRIx64> and %<PRIx64>"
@@ -13981,7 +14057,7 @@ msgid "Move objects and refs by archive"
 msgstr "Перенести архів обʼєктів та посилань"
 
 msgid "Provide contents or details of repository objects"
-msgstr "Ð\9fоказаÑ\82и Ð²Ð¼Ñ\96Ñ\81Ñ\82 Ð°Ð±Ð¾ Ñ\96нÑ\84оÑ\80маÑ\86Ñ\96Ñ\8e Ð¿Ñ\80о Ð¾Ð±Ê¼Ñ\94кÑ\82и сховища"
+msgstr "Ð\9dадаваÑ\82и Ð²Ð¼Ñ\96Ñ\81Ñ\82 Ð°Ð±Ð¾ Ð´ÐµÑ\82алÑ\96 Ð¾Ð±Ê¼Ñ\94кÑ\82Ñ\96в сховища"
 
 msgid "Display gitattributes information"
 msgstr "Відобразити інформацію про gitattributes"
@@ -14269,6 +14345,11 @@ msgstr "Запакувати розпаковані обʼєкти у схови
 msgid "Create, list, delete refs to replace objects"
 msgstr "Створити, показати, видалити посилання для об’єктів заміни"
 
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr ""
+"ЕКСПЕРИМЕНТАЛЬНО: Відтворення коммітів на новій базі також працює з "
+"порожніми сховищами"
+
 msgid "Generates a summary of pending changes"
 msgstr "Створює підсумок змін для розгляду"
 
@@ -14391,7 +14472,7 @@ msgid "Display version information about Git"
 msgstr "Показати інформацію про версію Git"
 
 msgid "Show logs with differences each commit introduces"
-msgstr "Показати журнал з різницею, яку вносить кожен з комітів"
+msgstr "Показати журнал з різницями, які вносить кожен коміт"
 
 msgid "Manage multiple working trees"
 msgstr "Керувати кількома робочими деревами"
@@ -14507,6 +14588,32 @@ msgstr "Інструмент для керування великими схов
 msgid "commit-graph file is too small"
 msgstr "файл коміт-графа занадто малий"
 
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "шматок oid fanout коміт-графа має невірний розмір"
+
+msgid "commit-graph fanout values out of order"
+msgstr "значення fanout коміт-графа впорядковані невірно"
+
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "шматок OID lookup коміт-графа має невірний розмір"
+
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "шматок commit data коміт-графа має невірний розмір"
+
+msgid "commit-graph generations chunk is wrong size"
+msgstr "шматок generations коміт-графа має невірний розмір"
+
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "шматок changed-path index коміт-графа має невірний розмір"
+
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr ""
+"ігнорування занадто малого шматка changed-path (%<PRIuMAX> < %<PRIuMAX>) "
+"файла коміт-графа"
+
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
 msgstr "підпис коміт-графа %X не збігається з підписом %X"
@@ -14523,11 +14630,20 @@ msgstr "хеш версія коміт-графа %X не збігається 
 msgid "commit-graph file is too small to hold %u chunks"
 msgstr "файл коміт-графа занадто малий, щоб вмістити %u шматків"
 
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr "необхідний шматок OID fanout коміт-графа відсутній або пошкоджений"
+
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr "необхідний шматок OID lookup коміт-графа відсутній або пошкоджений"
+
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr "необхідний шматок commit data коміт-графа відсутній або пошкоджений"
+
 msgid "commit-graph has no base graphs chunk"
 msgstr "коміт-граф не має шматка базових графів"
 
 msgid "commit-graph base graphs chunk is too small"
-msgstr "занадто малий шматок базових графів коміт-графа"
+msgstr "шматок base graphs коміт-графа занадто малий"
 
 msgid "commit-graph chain does not match"
 msgstr "ланцюжок коміт-графа не співпадає"
@@ -14536,6 +14652,9 @@ msgstr "ланцюжок коміт-графа не співпадає"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "кількість комітів у базовому графі занадто велика: %<PRIuMAX>"
 
+msgid "commit-graph chain file too small"
+msgstr "файл ланцюжка коміт-графа занадто малий"
+
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
 msgstr "неприпустимий ланцюжок коміт-графа: рядок \"%s\" не є хешем"
@@ -14551,10 +14670,13 @@ msgid "could not find commit %s"
 msgstr "не вдалося знайти коміт %s"
 
 msgid "commit-graph requires overflow generation data but has none"
-msgstr "коміт-граф потребує даних генерації переповнення, але їх немаєданих"
+msgstr "коміт-граф потребує даних генерації переповнення, але не має їх"
 
 msgid "commit-graph overflow generation data is too small"
-msgstr "занадто мало даних про переповнення коміт-граф генерації"
+msgstr "занадто мало даних генерації переповнення коміт-графа"
+
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "extra-edges pointer коміт-графа виходить за межі"
 
 msgid "Loading known commits in commit graph"
 msgstr "Завантаження відомих комітів у коміт-графі"
@@ -14692,7 +14814,8 @@ msgid ""
 "commit-graph has both zero and non-zero generations (e.g., commits '%s' and "
 "'%s')"
 msgstr ""
-"коміт-граф має як нульові, так і ненульові генерації (коміти \"%s\" і \"%s\")"
+"коміт-граф має як нульові, так і ненульові генерації (наприклад, коміти "
+"\"%s\" і \"%s\")"
 
 msgid "Verifying commits in commit graph"
 msgstr "Перевірка комітів у коміт-графі"
@@ -15702,6 +15825,10 @@ msgstr ""
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "Невідоме значення конфігураційної змінної \"diff.submodule\": \"%s\""
 
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "невідоме значення для конфігурації \"%s\": %s"
+
 #, c-format
 msgid ""
 "Found errors in 'diff.dirstat' config variable:\n"
@@ -15782,13 +15909,6 @@ msgstr "невірний --color-moved аргумент: %s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "неприпустимий режим \"%s\" у --color-moved-ws"
 
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"опція diff-algorithm приймає значення \"myers\", \"minimal\", \"patience\" "
-"та \"histogram\""
-
 #, c-format
 msgid "invalid argument to %s"
 msgstr "неприпустимий аргумент до %s"
@@ -15832,8 +15952,8 @@ msgstr "машинний вивід --stat"
 msgid "output only the last line of --stat"
 msgstr "вивести лише останній рядок --stat"
 
-msgid "<param1,param2>..."
-msgstr "<параметр1,параметр2>..."
+msgid "<param1>,<param2>..."
+msgstr "<параметр1>,<параметр2>..."
 
 msgid ""
 "output the distribution of relative amount of changes for each sub-directory"
@@ -15842,8 +15962,8 @@ msgstr "вивести розподіл відносної кількості з
 msgid "synonym for --dirstat=cumulative"
 msgstr "синонім для --dirstat=cumulative"
 
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "синонім для --dirstat=files,параметр1,параметр2..."
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "синонім для --dirstat=files,<параметр1>,<параметр2>..."
 
 msgid "warn if changes introduce conflict markers or whitespace errors"
 msgstr ""
@@ -16019,12 +16139,6 @@ msgstr "згенерувати різницю за алгоритмом \"patien
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "згенерувати різницю за алгоритмом \"histogram diff\""
 
-msgid "<algorithm>"
-msgstr "<алгоритм>"
-
-msgid "choose a diff algorithm"
-msgstr "вибрати алгоритм різниці"
-
 msgid "<text>"
 msgstr "<текст>"
 
@@ -17224,7 +17338,7 @@ msgstr ""
 #. conflict in a submodule. The first argument is the submodule
 #. name, and the second argument is the abbreviated id of the
 #. commit that needs to be merged.  For example:
-#. - go to submodule (mysubmodule), and either merge commit abc1234"
+#.  - go to submodule (mysubmodule), and either merge commit abc1234"
 #.
 #, c-format
 msgid ""
@@ -17513,12 +17627,18 @@ msgstr "не вдалося прочитати кеш"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "multi-pack-index OID розсіювання має невірний розмір"
 
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr ""
+"невірна послідовність oid fanout: fanout[%d] = %<PRIx32> > %<PRIx32> = "
+"fanout[%d]"
+
 msgid "multi-pack-index OID lookup chunk is the wrong size"
-msgstr "multi-pack-index шматок пошуку OID має невірний розмір"
+msgstr "multi-pack-index OID lookup шматок має невірний розмір"
 
 msgid "multi-pack-index object offset chunk is the wrong size"
-msgstr ""
-"multi-pack-index необхідній шматок зміщення обʼєкта має невірний розмір"
+msgstr "multi-pack-index object offset шматок має невірний розмір"
 
 #, c-format
 msgid "multi-pack-index file %s is too small"
@@ -17537,24 +17657,22 @@ msgid "multi-pack-index hash version %u does not match version %u"
 msgstr "версія хешу multi-pack-index %u не збігається з версією %u"
 
 msgid "multi-pack-index required pack-name chunk missing or corrupted"
-msgstr ""
-"multi-pack-index необхідний шматок імені пакунка відсутній або пошкоджений"
+msgstr "необхідний шматок pack-name multi-pack-index відсутній або пошкоджений"
 
 msgid "multi-pack-index required OID fanout chunk missing or corrupted"
 msgstr ""
-"multi-pack-index необхідний шматок розсіювання OID відсутній або пошкоджений"
+"необхідний шматок OID fanout multi-pack-index відсутній або пошкоджений"
 
 msgid "multi-pack-index required OID lookup chunk missing or corrupted"
 msgstr ""
-"multi-pack-index необхідний шматок пошуку OID відсутній або пошкоджений"
+"необхідний шматок OID lookup multi-pack-index відсутній або пошкоджений"
 
 msgid "multi-pack-index required object offsets chunk missing or corrupted"
 msgstr ""
-"multi-pack-index необхідний шматок зміщення обʼєктів відсутній або "
-"пошкоджений"
+"необхідний шматок object offsets multi-pack-index відсутній або пошкоджений"
 
 msgid "multi-pack-index pack-name chunk is too short"
-msgstr "multi-pack-index  pack-name шматок занадто малий"
+msgstr "шматок pack-name multi-pack-index занадто малий"
 
 #, c-format
 msgid "multi-pack-index pack names out of order: '%s' before '%s'"
@@ -17566,12 +17684,19 @@ msgstr ""
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "невірний pack-int-id: %u (%u всього пакунків)"
 
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX не містить шматок BTMP"
+
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "не вдалося завантажити бітмаповий пакунок %<PRIu32>"
+
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr ""
 "multi-pack-index зберігає 64-бітне зміщення, але значення off_t занадто мале"
 
 msgid "multi-pack-index large offset out of bounds"
-msgstr "multi-pack-index large зсув виходить за межі"
+msgstr "large offset multi-pack-index виходить за межі"
 
 #, c-format
 msgid "failed to add packfile '%s'"
@@ -17651,13 +17776,6 @@ msgstr "невірна контрольна сума"
 msgid "Looking for referenced packfiles"
 msgstr "Пошук файлів пакунків, на які є посилання"
 
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr ""
-"невірна послідовність oid розсіювання: fanout[%d] = %<PRIx32> > %<PRIx32> = "
-"fanout[%d]"
-
 msgid "the midx contains no oid"
 msgstr "midx не містить oid"
 
@@ -17961,7 +18079,7 @@ msgstr "%s [невірний обʼект]"
 #. TRANSLATORS: This is a line of ambiguous commit
 #. object output. E.g.:
 #. *
-#. "deadbeef commit 2021-01-01 - Some Commit Message"
+#.    "deadbeef commit 2021-01-01 - Some Commit Message"
 #.
 #, c-format
 msgid "%s commit %s - %s"
@@ -17970,7 +18088,7 @@ msgstr "%s коміт %s - %s"
 #. TRANSLATORS: This is a line of ambiguous
 #. tag object output. E.g.:
 #. *
-#. "deadbeef tag 2022-01-01 - Some Tag Message"
+#.    "deadbeef tag 2022-01-01 - Some Tag Message"
 #. *
 #. The second argument is the YYYY-MM-DD found
 #. in the tag.
@@ -17986,7 +18104,7 @@ msgstr "%s тег %s - %s"
 #. tag object output where we couldn't parse
 #. the tag itself. E.g.:
 #. *
-#. "deadbeef [bad tag, could not parse it]"
+#.    "deadbeef [bad tag, could not parse it]"
 #.
 #, c-format
 msgid "%s [bad tag, could not parse it]"
@@ -18182,6 +18300,9 @@ msgstr "у мультіпакунковому bitmap відсутній необ
 msgid "could not open pack %s"
 msgstr "не вдалося відкрити пакунок %s"
 
+msgid "could not determine MIDX preferred pack"
+msgstr "не вдалося визначити бажаний пакунок MIDX"
+
 #, c-format
 msgid "preferred pack (%s) is invalid"
 msgstr "бажаний пакунок (%s) є неприпустимим"
@@ -18202,6 +18323,12 @@ msgstr ""
 msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr "пошкоджений ewah bitmap: урізаний заголовок для bitmap коміту \"%s\""
 
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr ""
+"не вдалося завантажити пакунок: \"%s\", вимкнення повторного використання "
+"пакунків"
+
 #, c-format
 msgid "object '%s' not found in type bitmaps"
 msgstr "обʼєкт \"%s\" не знайдено в типах bitmap"
@@ -18296,6 +18423,9 @@ msgstr ""
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "multi-pack-index reverse-index шматок має невірний розмір"
 
+msgid "could not determine preferred pack"
+msgstr "не вдалося визначити бажаний пакунок"
+
 msgid "cannot both write and verify reverse index"
 msgstr "неможливо одночасно записувати та звіряти зворотний індекс"
 
@@ -18358,10 +18488,6 @@ msgstr "%s недоступний"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s очікує невід'ємне ціле значення з опціональним суфіксом k/m/g"
 
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s несумісний з %s"
-
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
 msgstr "неоднозначна опція: %s (може бути --%s%s або --%s%s)"
@@ -18469,7 +18595,7 @@ msgstr ""
 
 #, c-format
 msgid "bad boolean environment value '%s' for '%s'"
-msgstr "невÑ\96Ñ\80не Ð±Ñ\83леве Ð·Ð½Ð°Ñ\87еннÑ\8f ÐºÐ¾Ð½Ñ\84Ñ\96гÑ\83Ñ\80аÑ\86Ñ\96Ñ\97 \"%s\" для \"%s\""
+msgstr "невÑ\96Ñ\80не Ð±Ñ\83леве Ð·Ð½Ð°Ñ\87еннÑ\8f Ð¾Ñ\82оÑ\87еннÑ\8f \"%s\" для \"%s\""
 
 #, c-format
 msgid "failed to parse %s"
@@ -18683,10 +18809,6 @@ msgstr "не вдалося проіндексувати файл \"%s\""
 msgid "unable to add '%s' to index"
 msgstr "не вдалося додати \"%s\" до індексу"
 
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "не вдалося виконати stat для \"%s\""
-
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
 msgstr "\"%s\" відображається як файл і як каталог"
@@ -19260,10 +19382,6 @@ msgstr "\"%s\" існує; неможливо створити \"%s\""
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "неможливо обробити \"%s\" і \"%s\" одночасно"
 
-#, c-format
-msgid "could not remove reference %s"
-msgstr "не вдалося видалити посилання %s"
-
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "не вдалося видалити посилання %s: %s"
@@ -20651,6 +20769,9 @@ msgstr "Застосування автосхову призвело до кон
 msgid "Autostash exists; creating a new stash entry."
 msgstr "Автосхов існує; створення нового запису схову."
 
+msgid "autostash reference is a symref"
+msgstr "посилання автосхову є символьним посиланням"
+
 msgid "could not detach HEAD"
 msgstr "не вдалося відʼєднати HEAD"
 
@@ -20971,6 +21092,10 @@ msgstr "не копіюються шаблони з \"%s\": %s"
 msgid "invalid initial branch name: '%s'"
 msgstr "неприпустиме початкове ім’я гілки: \"%s\""
 
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init: ігноровано --initial-branch=%s"
+
 #, c-format
 msgid "unable to handle file type %d"
 msgstr "не вдалося обробити тип файлу %d"
@@ -20982,14 +21107,14 @@ msgstr "не вдалося перемістити %s на %s"
 msgid "attempt to reinitialize repository with different hash"
 msgstr "спроба переініціалізувати репозиторій з іншим хеш-алгоритмом"
 
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr "спроба переініціалізувати сховище з іншим форматом зберігання"
+
 #, c-format
 msgid "%s already exists"
 msgstr "%s вже існує"
 
-#, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init: ігноровано --initial-branch=%s"
-
 #, c-format
 msgid "Reinitialized existing shared Git repository in %s%s\n"
 msgstr "Переініціалізовано існуюче спільне Git сховище в %s%s\n"
@@ -21261,12 +21386,6 @@ msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr ""
 "кількість записів у дереві кешу, які потрібно анулювати (за замовчуванням 0)"
 
-msgid "unhandled options"
-msgstr "необроблені опції"
-
-msgid "error preparing revisions"
-msgstr "помилка при підготовці ревізій"
-
 #, c-format
 msgid "commit %s is not marked reachable"
 msgstr "коміт %s не позначений як досяжний"
@@ -21423,9 +21542,6 @@ msgstr "встановлення шляху до віддаленого серв
 msgid "invalid remote service path"
 msgstr "неприпустимий шлях до віддаленої служби"
 
-msgid "operation not supported by protocol"
-msgstr "операція не підтримується протоколом"
-
 #, c-format
 msgid "can't connect to subservice %s"
 msgstr "неможливо підключитися до підсервісу %s"
@@ -21557,10 +21673,6 @@ msgstr "не вдалося розібрати конфігурацію transpor
 msgid "support for protocol v2 not implemented yet"
 msgstr "підтримка протоколу v2 ще не запроваджена"
 
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "невідоме значення для конфігурації \"%s\": %s"
-
 #, c-format
 msgid "transport '%s' not allowed"
 msgstr "засіб передачі \"%s\" не дозволений"
@@ -21613,6 +21725,9 @@ msgstr "bundle-uri операція не підтримується проток
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "не вдалося отримати список адрес пакетів, оголошений сервером"
 
+msgid "operation not supported by protocol"
+msgstr "операція не підтримується протоколом"
+
 msgid "too-short tree object"
 msgstr "занадто короткий обʼєкт дерева"
 
@@ -22014,7 +22129,7 @@ msgid "unable to get random bytes"
 msgstr "не вдалося отримати випадкові байти"
 
 msgid "Unmerged paths:"
-msgstr "не злиті шляхи:"
+msgstr "Ð\9dе злиті шляхи:"
 
 msgid "  (use \"git restore --staged <file>...\" to unstage)"
 msgstr ""
@@ -22466,6 +22581,10 @@ msgstr "крім того, ваш індекс містить незакоміч
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "неможливо виконати %s: Ваш індекс містить незакомічені зміни."
 
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "невідомий стиль \"%s\" наданий для \"%s\""
+
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
 "merge"
index 86402725b28399d5abc0e083bf17ba9b4d78e9de..39efaf1012a436a567112c7ea346d30456700e0b 100644 (file)
@@ -46,6 +46,7 @@
 #   commit                           |  提交
 #   commit message                   |  提交说明
 #   commit object                    |  提交对象
+#   commit-graph                     |  提交图
 #   commit-ish (also committish)     |  提交号
 #   cone                             |  锥形(稀疏检出模型);锥(稀疏检出)
 #   conflict                         |  冲突
 #   plumbing                         |  管件(Git 底层核心命令的别称)
 #   porcelain                        |  瓷件(Git 上层封装命令的别称)
 #   precious-objects repo            |  珍品仓库
+#   preferred pack                   |  首选包(多包索引中引入的首选包概念)
 #   promisor                         |  承诺者
 #   prune                            |  清除
 #   pull                             |  拉,拉取
@@ -151,8 +153,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-10 10:49+0800\n"
-"PO-Revision-Date: 2023-11-10 17:13+0800\n"
+"POT-Creation-Date: 2024-02-16 14:27+0800\n"
+"PO-Revision-Date: 2024-02-18 11:47+0800\n"
 "Last-Translator: Teng Long <dyroneteng@gmail.com>\n"
 "Language-Team: GitHub <https://github.com/dyrone/git/>\n"
 "Language: zh_CN\n"
@@ -1031,7 +1033,7 @@ msgid "unclosed quote"
 msgstr "未关闭的引号"
 
 #: alias.c builtin/cat-file.c builtin/notes.c builtin/prune-packed.c
-#: builtin/receive-pack.c builtin/tag.c
+#: builtin/receive-pack.c builtin/tag.c t/helper/test-pkt-line.c
 msgid "too many arguments"
 msgstr "太多参数"
 
@@ -1046,12 +1048,13 @@ msgid "unrecognized whitespace ignore option '%s'"
 msgstr "未能识别的空白字符忽略选项 '%s'"
 
 #: apply.c archive.c builtin/add.c builtin/branch.c builtin/checkout-index.c
-#: builtin/checkout.c builtin/clone.c builtin/commit.c builtin/describe.c
-#: builtin/diff-tree.c builtin/difftool.c builtin/fast-export.c builtin/fetch.c
-#: builtin/help.c builtin/index-pack.c builtin/init-db.c builtin/log.c
-#: builtin/ls-files.c builtin/merge-base.c builtin/merge.c
-#: builtin/pack-objects.c builtin/push.c builtin/rebase.c builtin/repack.c
-#: builtin/reset.c builtin/rev-list.c builtin/show-branch.c builtin/stash.c
+#: builtin/checkout.c builtin/clean.c builtin/clone.c builtin/commit.c
+#: builtin/describe.c builtin/diff-tree.c builtin/difftool.c
+#: builtin/fast-export.c builtin/fetch.c builtin/help.c builtin/index-pack.c
+#: builtin/init-db.c builtin/log.c builtin/ls-files.c builtin/merge-base.c
+#: builtin/merge-tree.c builtin/merge.c builtin/pack-objects.c builtin/rebase.c
+#: builtin/repack.c builtin/replay.c builtin/reset.c builtin/rev-list.c
+#: builtin/rev-parse.c builtin/show-branch.c builtin/stash.c
 #: builtin/submodule--helper.c builtin/tag.c builtin/worktree.c parse-options.c
 #: range-diff.c revision.c
 #, c-format
@@ -1859,6 +1862,11 @@ msgstr "选项 '%s' 需要 '%s'"
 msgid "Unexpected option --output"
 msgstr "未知参数 --output"
 
+#: archive.c
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "额外的命令行参数:'%s'"
+
 #: archive.c
 #, c-format
 msgid "Unknown archive format '%s'"
@@ -1915,6 +1923,17 @@ msgstr "忽略过大的 gitattributes 数据对象 '%s'"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "错误的 --attr-source 或 GIT_ATTR_SOURCE"
 
+#: attr.c read-cache.c
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "无法对 %s 执行 stat"
+
+#: bisect.c builtin/cat-file.c builtin/index-pack.c builtin/notes.c
+#: builtin/pack-objects.c combine-diff.c rerere.c
+#, c-format
+msgid "unable to read %s"
+msgstr "不能读 %s"
+
 #: bisect.c
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
@@ -2448,8 +2467,8 @@ msgid "bad action '%s' for '%s'"
 msgstr "'%2$s' 的错误动作 '%1$s'"
 
 #: builtin/am.c builtin/blame.c builtin/fetch.c builtin/pack-objects.c
-#: builtin/pull.c diff-merges.c gpg-interface.c ls-refs.c parallel-checkout.c
-#: sequencer.c setup.c
+#: builtin/pull.c config.c diff-merges.c gpg-interface.c ls-refs.c
+#: parallel-checkout.c sequencer.c setup.c
 #, c-format
 msgid "invalid value for '%s': '%s'"
 msgstr "'%s' 的值无效:'%s'"
@@ -2602,8 +2621,7 @@ msgstr "git write-tree 无法写入树对象"
 msgid "applying to an empty history"
 msgstr "正应用到一个空历史上"
 
-#: builtin/am.c builtin/commit.c builtin/merge.c sequencer.c
-#: t/helper/test-fast-rebase.c
+#: builtin/am.c builtin/commit.c builtin/merge.c builtin/replay.c sequencer.c
 msgid "failed to write commit object"
 msgstr "无法写提交对象"
 
@@ -2783,8 +2801,9 @@ msgid "n"
 msgstr "n"
 
 #: builtin/am.c builtin/branch.c builtin/bugreport.c builtin/cat-file.c
-#: builtin/diagnose.c builtin/for-each-ref.c builtin/ls-files.c
-#: builtin/ls-tree.c builtin/replace.c builtin/tag.c builtin/verify-tag.c
+#: builtin/clone.c builtin/diagnose.c builtin/for-each-ref.c builtin/init-db.c
+#: builtin/ls-files.c builtin/ls-tree.c builtin/replace.c builtin/tag.c
+#: builtin/verify-tag.c
 msgid "format"
 msgstr "格式"
 
@@ -2916,7 +2935,9 @@ msgstr "git archive:应有一个 flush 包"
 msgid ""
 "git bisect start [--term-(new|bad)=<term> --term-(old|good)=<term>]    [--no-"
 "checkout] [--first-parent] [<bad> [<good>...]] [--]    [<pathspec>...]"
-msgstr "git bisect start [--term-{new|bad}=<术语> --term-{old|good}=<术语>]    [--no-checkout] [--first-parent] [<坏> [<好>...]] [--]    [<路径规格>...]"
+msgstr ""
+"git bisect start [--term-{new|bad}=<术语> --term-{old|good}=<术语>]    [--no-"
+"checkout] [--first-parent] [<坏> [<好>...]] [--]    [<路径规格>...]"
 
 #: builtin/bisect.c
 msgid "git bisect (good|bad) [<rev>...]"
@@ -3473,12 +3494,13 @@ msgstr "无法查询 '%s' 指向的提交对象"
 
 #: builtin/branch.c
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"分支 '%s' 没有完全合并。\n"
-"如果您确认要删除它,执行 'git branch -D %s'"
+msgid "the branch '%s' is not fully merged"
+msgstr "分支 '%s' 没有完全合并"
+
+#: builtin/branch.c
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "如果您确认要删除它,执行 'git branch -D %s'"
 
 #: builtin/branch.c
 msgid "update of config-file failed"
@@ -4488,7 +4510,7 @@ msgstr "不能对 '%s' 执行 reflog 操作:%s\n"
 msgid "HEAD is now at"
 msgstr "HEAD 目前位于"
 
-#: builtin/checkout.c builtin/clone.c t/helper/test-fast-rebase.c
+#: builtin/checkout.c builtin/clone.c
 msgid "unable to update HEAD"
 msgstr "不能更新 HEAD"
 
@@ -4757,8 +4779,8 @@ msgid "new-branch"
 msgstr "新分支"
 
 #: builtin/checkout.c
-msgid "new unparented branch"
-msgstr "æ\96°ç\9a\84没æ\9c\89ç\88¶æ\8f\90交的分支"
+msgid "new unborn branch"
+msgstr "æ\96°ç\9a\84æ\9cªè¯\9eç\94\9f的分支"
 
 #: builtin/checkout.c builtin/merge.c
 msgid "update ignored files (default)"
@@ -4824,7 +4846,7 @@ msgstr ""
 msgid "you must specify path(s) to restore"
 msgstr "您必须指定要恢复的路径"
 
-#: builtin/checkout.c builtin/clone.c builtin/remote.c
+#: builtin/checkout.c builtin/clone.c builtin/remote.c builtin/replay.c
 #: builtin/submodule--helper.c builtin/worktree.c
 msgid "branch"
 msgstr "分支"
@@ -5065,10 +5087,6 @@ msgid ""
 msgstr ""
 "clean.requireForce 默认为 true 且未提供 -i、-n 或 -f 选项,拒绝执行清理动作"
 
-#: builtin/clean.c
-msgid "-x and -X cannot be used together"
-msgstr "-x 和 -X 不能同时使用"
-
 #: builtin/clone.c
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<选项>] [--] <仓库> [<路径>]"
@@ -5160,6 +5178,7 @@ msgid "create a shallow clone since a specific time"
 msgstr "从一个特定时间创建一个浅克隆"
 
 #: builtin/clone.c builtin/fetch.c builtin/pull.c builtin/rebase.c
+#: builtin/replay.c
 msgid "revision"
 msgstr "版本"
 
@@ -5187,6 +5206,10 @@ msgstr "git目录"
 msgid "separate git dir from working tree"
 msgstr "git目录和工作区分离"
 
+#: builtin/clone.c builtin/init-db.c
+msgid "specify the reference format to use"
+msgstr "指定要使用的引用格式"
+
 #: builtin/clone.c
 msgid "key=value"
 msgstr "key=value"
@@ -5336,11 +5359,10 @@ msgstr "太多参数。"
 msgid "You must specify a repository to clone."
 msgstr "您必须指定一个仓库来克隆。"
 
-#: builtin/clone.c
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr "--bundle-uri 与 --depth、--shallow-since 和 --shallow-exclude 不兼容"
+#: builtin/clone.c builtin/init-db.c setup.c
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "未知的引用存储格式 '%s'"
 
 #: builtin/clone.c
 #, c-format
@@ -5501,7 +5523,7 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <目录>] [--append]\n"
 "                       [--split[=<策略>]] [--reachable | --stdin-packs | --"
@@ -5520,17 +5542,17 @@ msgstr "保存图形的对象目录"
 
 #: builtin/commit-graph.c
 msgid "if the commit-graph is split, only verify the tip file"
-msgstr "如果提交图被拆分,只验证头一个文件"
+msgstr "如果提交图被拆分,只验证头一个文件"
 
 #: builtin/commit-graph.c
 #, c-format
 msgid "Could not open commit-graph '%s'"
-msgstr "无法打开提交图 '%s'"
+msgstr "无法打开提交图 '%s'"
 
 #: builtin/commit-graph.c
 #, c-format
 msgid "could not open commit-graph chain '%s'"
-msgstr "无法打开提交图链 '%s'"
+msgstr "无法打开提交图链 '%s'"
 
 #: builtin/commit-graph.c
 #, c-format
@@ -5574,15 +5596,15 @@ msgstr "启用变更路径的计算"
 
 #: builtin/commit-graph.c
 msgid "allow writing an incremental commit-graph file"
-msgstr "允许写一个增量提交图文件"
+msgstr "允许写一个增量提交图文件"
 
 #: builtin/commit-graph.c
 msgid "maximum number of commits in a non-base split commit-graph"
-msgstr "在非基本拆分提交图中的最大提交数"
+msgstr "在非基本拆分提交图中的最大提交数"
 
 #: builtin/commit-graph.c
 msgid "maximum ratio between two levels of a split commit-graph"
-msgstr "一个拆分提交图的两个级别之间的最大比率"
+msgstr "一个拆分提交图的两个级别之间的最大比率"
 
 #: builtin/commit-graph.c
 msgid "only expire files older than a given date-time"
@@ -8378,6 +8400,11 @@ msgstr "没有线程支持,忽略 %s"
 msgid "unable to read tree (%s)"
 msgstr "无法读取树(%s)"
 
+#: builtin/grep.c
+#, c-format
+msgid "unable to read tree %s"
+msgstr "无法读取树 %s"
+
 #: builtin/grep.c
 #, c-format
 msgid "unable to grep from object of type %s"
@@ -8901,11 +8928,6 @@ msgstr "解压缩严重的不一致"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "发现 %s 出现 SHA1 冲突!"
 
-#: builtin/index-pack.c builtin/pack-objects.c
-#, c-format
-msgid "unable to read %s"
-msgstr "不能读 %s"
-
 #: builtin/index-pack.c
 #, c-format
 msgid "cannot read existing object info %s"
@@ -9083,11 +9105,13 @@ msgstr "在打包对象中 fsck 检查出错"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<模板目录>]\n"
 "         [--separate-git-dir <git 目录>] [--object-format=<格式>]\n"
+"         [--ref-format=<格式>]\n"
 "         [-b <分支名> | --initial-branch=<分支名>]\n"
 "         [--shared[=<权限>]] [<目录>]"
 
@@ -9246,7 +9270,7 @@ msgid ""
 "<file>"
 msgstr "跟踪 <文件> 中 <开始>,<结束> 范围内的行或函数 :<函数名> 的演变"
 
-#: builtin/log.c builtin/shortlog.c bundle.c
+#: builtin/log.c builtin/replay.c builtin/shortlog.c bundle.c
 #, c-format
 msgid "unrecognized argument: %s"
 msgstr "未能识别的参数:%s"
@@ -9990,6 +10014,12 @@ msgstr ""
 "git merge-file [<选项>] [-L <名字1> [-L <初始名字> [-L <名字2>]]] <文件1> <初"
 "始文件> <文件2>"
 
+#: builtin/merge-file.c diff.c
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr "选项 diff-algorithm 接受参数 \"myers\"、\"minimal\"、\"patience\" 和 \"histogram\""
+
 #: builtin/merge-file.c
 msgid "send results to standard output"
 msgstr "将结果发送到标准输出"
@@ -10018,6 +10048,14 @@ msgstr "如果冲突,使用他们的版本"
 msgid "for conflicts, use a union version"
 msgstr "如果冲突,使用联合版本"
 
+#: builtin/merge-file.c diff.c
+msgid "<algorithm>"
+msgstr "<算法>"
+
+#: builtin/merge-file.c diff.c
+msgid "choose a diff algorithm"
+msgstr "选择一个差异算法"
+
 #: builtin/merge-file.c
 msgid "for conflicts, use this marker size"
 msgstr "如果冲突,使用指定长度的标记"
@@ -10135,10 +10173,6 @@ msgstr "--trivial-merge 与其他所有选项不兼容"
 msgid "unknown strategy option: -X%s"
 msgstr "未知的策略选项:-X%s"
 
-#: builtin/merge-tree.c
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base 与 --stdin 不兼容"
-
 #: builtin/merge-tree.c builtin/notes.c
 #, c-format
 msgid "malformed input line: '%s'."
@@ -10296,7 +10330,7 @@ msgstr "'%s' 没有指向一个提交"
 msgid "Bad branch.%s.mergeoptions string: %s"
 msgstr "坏的 branch.%s.mergeoptions 字符串:%s"
 
-#: builtin/merge.c builtin/stash.c merge-recursive.c
+#: builtin/merge.c merge-recursive.c
 msgid "Unable to write index."
 msgstr "不能写入索引。"
 
@@ -10304,7 +10338,7 @@ msgstr "不能写入索引。"
 msgid "Not handling anything other than two heads merge."
 msgstr "未处理两个头合并之外的任何操作。"
 
-#: builtin/merge.c t/helper/test-fast-rebase.c
+#: builtin/merge.c
 #, c-format
 msgid "unable to write %s"
 msgstr "不能写 %s"
@@ -11290,6 +11324,11 @@ msgstr "压缩对象中"
 msgid "inconsistency with delta count"
 msgstr "不一致的差异计数"
 
+#: builtin/pack-objects.c
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "无效的 pack.allowPackReuse 值:'%s'"
+
 #: builtin/pack-objects.c
 #, c-format
 msgid ""
@@ -11614,10 +11653,10 @@ msgstr "枚举对象中"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "总共 %<PRIu32>(差异 %<PRIu32>),复用 %<PRIu32>(差异 %<PRIu32>),包复用 "
-"%<PRIu32>"
+"%<PRIu32>(来自  %<PRIuMAX> 个包)"
 
 #: builtin/pack-redundant.c
 msgid ""
@@ -12691,7 +12730,7 @@ msgstr "没有正在进行的变基?"
 msgid "The --edit-todo action can only be used during interactive rebase."
 msgstr "动作 --edit-todo 只能用在交互式变基过程中。"
 
-#: builtin/rebase.c t/helper/test-fast-rebase.c
+#: builtin/rebase.c
 msgid "Cannot read HEAD"
 msgstr "不能读取 HEAD"
 
@@ -12735,12 +12774,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "开关 `C' 期望一个数字值"
 
-#: builtin/rebase.c
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr "应用的选项与 rebase.autoSquash 不兼容。考虑加上 --no-autosquash"
-
 #: builtin/rebase.c
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
@@ -13224,8 +13257,8 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 层级之外的一个分支未被移除。要删除它,使用:"
-msgstr[1] "注意:ref/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
+msgstr[0] "注意:refs/remotes/ 层级之外的一个分支未被移除。要删除它,使用:"
+msgstr[1] "注意:refs/remotes/ 层级之外的一些分支未被移除。要删除它们,使用:"
 
 #: builtin/remote.c
 #, c-format
@@ -13956,6 +13989,84 @@ msgstr "--convert-graft-file 不带参数"
 msgid "only one pattern can be given with -l"
 msgstr "只能为 -l 提供一个模式"
 
+#: builtin/replay.c
+msgid "need some commits to replay"
+msgstr "需要一些提交来重放"
+
+#: builtin/replay.c
+msgid "--onto and --advance are incompatible"
+msgstr "--onto 和 --advance 不兼容"
+
+#: builtin/replay.c
+msgid "all positive revisions given must be references"
+msgstr "提供的所有正向版本必须为引用"
+
+#: builtin/replay.c
+msgid "argument to --advance must be a reference"
+msgstr "--advance 的参数必须是引用"
+
+#: builtin/replay.c
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr "不能使用多个源推进目标,因为无法明确如何排序"
+
+#: builtin/replay.c
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr "不能隐式地确定这是 --advance 还是 --onto 的操作"
+
+#: builtin/replay.c
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr "不能使用多个源分支推进目标,因为无法明确如何排序"
+
+#: builtin/replay.c
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "不能隐式地确定 --onto 正确的基线"
+
+#: builtin/replay.c
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr "(试验中!)git replay ([--contained] --onto <新基线> | --advance <分支>) <版本范围>..."
+
+#: builtin/replay.c
+msgid "make replay advance given branch"
+msgstr "重放时演进给定的分支"
+
+#: builtin/replay.c
+msgid "replay onto given commit"
+msgstr "重放到给定提交"
+
+#: builtin/replay.c
+msgid "advance all branches contained in revision-range"
+msgstr "演进版本范围中包含的所有分支"
+
+#: builtin/replay.c
+msgid "option --onto or --advance is mandatory"
+msgstr "选项 --onto 或 --advance 必须指定其一"
+
+#: builtin/replay.c
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr "一些版本遍历选项将被覆盖,如 'struct rev_info' 中的 '%s' 位将被强制设定"
+
+#: builtin/replay.c
+msgid "error preparing revisions"
+msgstr "准备版本时错误"
+
+#: builtin/replay.c
+msgid "replaying down to root commit is not supported yet!"
+msgstr "目前还不支持重放到根提交!"
+
+#: builtin/replay.c
+msgid "replaying merge commits is not supported yet!"
+msgstr "目前还不支持重放到合并提交!"
+
 #: builtin/rerere.c
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
@@ -14215,18 +14326,6 @@ msgstr "--prefix 需要一个参数"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "未知的 --abbrev-ref 模式:%s"
 
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden 不能与 --branches 一起使用"
-
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden 不能与 --tags 一起使用"
-
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden 不能与 --remotes 一起使用"
-
 #: builtin/rev-parse.c setup.c
 msgid "this operation must be run in a work tree"
 msgstr "该操作必须在一个工作区中运行"
@@ -14730,11 +14829,6 @@ msgstr "不打印结果到标准输出(例如与 --verify 参数共用)"
 msgid "show refs from stdin that aren't in local repository"
 msgstr "显示从标准输入中读入的不在本地仓库中的引用"
 
-#: builtin/show-ref.c
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "选项 '%s'、'%s' 或 '%s' 只能使用其一"
-
 #: builtin/sparse-checkout.c
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
@@ -16509,30 +16603,30 @@ msgstr "没有可用的源分支,将基于 '--orphan' 选项进行推断"
 #: builtin/worktree.c
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
-"如果你打算为此仓库创建一个包含新的孤立分支\n"
-"(没有提交的分支)的工作区,你可以使用选项\n"
-"--orphan 来执行此操作:\n"
+"如果你打算为此仓库创建一个包含新的未诞生的\n"
+"分支(没有提交的分支)的工作区,你可以使用\n"
+"选项 --orphan 来执行此操作:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 
 #: builtin/worktree.c
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
-"如果你打算为此仓库创建一个包含新的孤立分支\n"
-"(没有提交的分支)的工作区,你可以使用选项\n"
-"--orphan 来执行此操作:\n"
+"如果你打算为此仓库创建一个包含新的未诞生的\n"
+"分支(没有提交的分支)的工作区,你可以使用\n"
+"选项 --orphan 来执行此操作:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 
@@ -16601,6 +16695,11 @@ msgstr "不能创建目录 '%s'"
 msgid "initializing"
 msgstr "初始化"
 
+#: builtin/worktree.c
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "无法找到已创建的工作树 '%s'"
+
 #: builtin/worktree.c
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
@@ -16645,11 +16744,6 @@ msgstr ""
 "尽管已配置远程仓库,但不存在任何本地的或远程的引用,操作终止。\n"
 "请先使用 'add -f' 来覆盖或拉取一个远程仓库"
 
-#: builtin/worktree.c
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "'%s' 和 '%s' 不能同时使用"
-
 #: builtin/worktree.c
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr "检出 <分支>,即使已经被检出到其它工作区"
@@ -16663,8 +16757,8 @@ msgid "create or reset a branch"
 msgstr "创建或重置一个分支"
 
 #: builtin/worktree.c
-msgid "create unborn/orphaned branch"
-msgstr "创建一个尚未诞生的/孤立的分支"
+msgid "create unborn branch"
+msgstr "创建一个尚未诞生的分支"
 
 #: builtin/worktree.c
 msgid "populate the new working tree"
@@ -16693,12 +16787,8 @@ msgstr "选项 '%s'、'%s' 和 '%s' 不能同时使用"
 
 #: builtin/worktree.c
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "选项 '%s' 与 '%s' 不能同时使用"
-
-#: builtin/worktree.c
-msgid "<commit-ish>"
-msgstr "<提交号>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "选项 '%s' 和提交号不能同时使用"
 
 #: builtin/worktree.c
 msgid "added with --lock"
@@ -17488,6 +17578,10 @@ msgstr "打包仓库中未打包对象"
 msgid "Create, list, delete refs to replace objects"
 msgstr "创建、列出、删除对象替换引用"
 
+#: command-list.h
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr "试验中:基于一个新基线重放提交,同样适用于纯仓库"
+
 #: command-list.h
 msgid "Generates a summary of pending changes"
 msgstr "生成待定更改的摘要"
@@ -17803,57 +17897,104 @@ msgstr "一个管理大型 Git 仓库的工具"
 
 #: commit-graph.c
 msgid "commit-graph file is too small"
-msgstr "提交图形文件太小"
+msgstr "提交图文件太小"
+
+#: commit-graph.c
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "提交图中对象 ID 的扇出块大小错误"
+
+#: commit-graph.c
+msgid "commit-graph fanout values out of order"
+msgstr "提交图的扇出值失序"
+
+#: commit-graph.c
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "提交图的对象 ID 查询块大小错误"
+
+#: commit-graph.c
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "提交图的提交数据块大小错误"
+
+#: commit-graph.c
+msgid "commit-graph generations chunk is wrong size"
+msgstr "提交图的世代块大小错误"
+
+#: commit-graph.c
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "提交图的变更路径的索引块太小"
+
+#: commit-graph.c
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr "忽略提交图文件中过小的更改路径块(%<PRIuMAX> < %<PRIuMAX>)"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
-msgstr "提交图签名 %X 和签名 %X 不匹配"
+msgstr "提交图签名 %X 和签名 %X 不匹配"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph version %X does not match version %X"
-msgstr "提交图版本 %X 和版本 %X 不匹配"
+msgstr "提交图版本 %X 和版本 %X 不匹配"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph hash version %X does not match version %X"
-msgstr "æ\8f\90交å\9b¾å½¢å\93\88å¸\8cç\89\88æ\9c¬ %X å\92\8cç\89\88æ\9c¬ %X ä¸\8då\8c¹é\85\8d"
+msgstr "提交图哈希版本 %X 和版本 %X 不匹配"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph file is too small to hold %u chunks"
-msgstr "提交图形文件太小,容不下 %u 个块"
+msgstr "提交图文件太小,容不下 %u 个块"
+
+#: commit-graph.c
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr "提交图所需的对象 ID 扇出块缺失或损坏"
+
+#: commit-graph.c
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr "提交图所需的对象 ID 查询块缺失或损坏"
+
+#: commit-graph.c
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr "提交图所需的提交数据块缺失或损坏"
 
 #: commit-graph.c
 msgid "commit-graph has no base graphs chunk"
-msgstr "提交图没有基础图形块"
+msgstr "提交图没有基础图形块"
 
 #: commit-graph.c
 msgid "commit-graph base graphs chunk is too small"
-msgstr "提交图的基础图形块过小"
+msgstr "提交图的基础图形块过小"
 
 #: commit-graph.c
 msgid "commit-graph chain does not match"
-msgstr "提交图链不匹配"
+msgstr "提交图链不匹配"
 
 #: commit-graph.c
 #, c-format
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "基础图形中的提交数量过高:%<PRIuMAX>"
 
+#: commit-graph.c
+msgid "commit-graph chain file too small"
+msgstr "提交图链文件太小"
+
 #: commit-graph.c
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
-msgstr "无效的提交图链:行 '%s' 不是一个哈希值"
+msgstr "无效的提交图链:行 '%s' 不是一个哈希值"
 
 #: commit-graph.c
 msgid "unable to find all commit-graph files"
-msgstr "无法找到所有提交图文件"
+msgstr "无法找到所有提交图文件"
 
 #: commit-graph.c
 msgid "invalid commit position. commit-graph is likely corrupt"
-msgstr "æ\97 æ\95\88ç\9a\84æ\8f\90交ä½\8dç½®ã\80\82æ\8f\90交å\9b¾å½¢å\8f¯è\83½å·²æ\8d\9få\9d\8f"
+msgstr "无效的提交位置。提交图可能已损坏"
 
 #: commit-graph.c
 #, c-format
@@ -17868,6 +18009,10 @@ msgstr "提交图需要溢出世代数据,但是没有"
 msgid "commit-graph overflow generation data is too small"
 msgstr "提交图溢出世代数据过小"
 
+#: commit-graph.c
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "提交图额外边的指针越界"
+
 #: commit-graph.c
 msgid "Loading known commits in commit graph"
 msgstr "正在加载提交图中的已知提交"
@@ -17943,26 +18088,25 @@ msgstr[1] "正在用 %d 步写出提交图"
 
 #: commit-graph.c
 msgid "unable to open commit-graph chain file"
-msgstr "无法打开提交图链文件"
+msgstr "无法打开提交图链文件"
 
 #: commit-graph.c
 msgid "failed to rename base commit-graph file"
-msgstr "无法重命名基础提交图文件"
+msgstr "无法重命名基础提交图文件"
 
 #: commit-graph.c
 msgid "failed to rename temporary commit-graph file"
-msgstr "无法重命名临时提交图文件"
+msgstr "无法重命名临时提交图文件"
 
 #: commit-graph.c
 #, c-format
 msgid "cannot merge graphs with %<PRIuMAX>, %<PRIuMAX> commits"
-msgstr ""
-"无法合并提交图形,总共已累加提交数:%<PRIuMAX>,当前待累加提交数:%<PRIuMAX>"
+msgstr "无法合并提交图,总共已累加提交数:%<PRIuMAX>,当前待累加提交数:%<PRIuMAX>"
 
 #: commit-graph.c
 #, c-format
 msgid "cannot merge graph %s, too many commits: %<PRIuMAX>"
-msgstr "无法合并提交图 %s, 提交过多:%<PRIuMAX>"
+msgstr "无法合并提交图 %s, 提交过多:%<PRIuMAX>"
 
 #: commit-graph.c
 msgid "Scanning merged commits"
@@ -17970,7 +18114,7 @@ msgstr "正在扫描合并提交"
 
 #: commit-graph.c
 msgid "Merging commit-graph"
-msgstr "正在合并提交图"
+msgstr "正在合并提交图"
 
 #: commit-graph.c
 msgid "attempting to write a commit-graph, but 'core.commitGraph' is disabled"
@@ -17987,59 +18131,59 @@ msgstr "提交图文件的校验码错误,可能已经损坏"
 #: commit-graph.c
 #, c-format
 msgid "commit-graph has incorrect OID order: %s then %s"
-msgstr "提交图的对象 ID 顺序不正确:%s 然后 %s"
+msgstr "提交图的对象 ID 顺序不正确:%s 然后 %s"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph has incorrect fanout value: fanout[%d] = %u != %u"
-msgstr "提交图有不正确的扇出值:fanout[%d] = %u != %u"
+msgstr "提交图有不正确的扇出值:fanout[%d] = %u != %u"
 
 #: commit-graph.c
 #, c-format
 msgid "failed to parse commit %s from commit-graph"
-msgstr "无法从提交图中解析提交 %s"
+msgstr "无法从提交图中解析提交 %s"
 
 #: commit-graph.c
 #, c-format
 msgid "failed to parse commit %s from object database for commit-graph"
-msgstr "无法从提交图的对象库中解析提交 %s"
+msgstr "无法从提交图的对象库中解析提交 %s"
 
 #: commit-graph.c
 #, c-format
 msgid "root tree OID for commit %s in commit-graph is %s != %s"
-msgstr "提交图中的提交 %s 的根树对象 ID 是 %s != %s"
+msgstr "提交图中的提交 %s 的根树对象 ID 是 %s != %s"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph parent list for commit %s is too long"
-msgstr "提交 %s 的提交图父提交列表太长了"
+msgstr "提交 %s 的提交图父提交列表太长了"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph parent for %s is %s != %s"
-msgstr "%s 的提交图父提交是 %s != %s"
+msgstr "%s 的提交图父提交是 %s != %s"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph parent list for commit %s terminates early"
-msgstr "提交 %s 的提交图父提交列表过早终止"
+msgstr "提交 %s 的提交图父提交列表过早终止"
 
 #: commit-graph.c
 #, c-format
 msgid "commit-graph generation for commit %s is %<PRIuMAX> < %<PRIuMAX>"
-msgstr "提交图中的提交 %s 的世代号是 %<PRIuMAX> < %<PRIuMAX>"
+msgstr "提交图中的提交 %s 的世代号是 %<PRIuMAX> < %<PRIuMAX>"
 
 #: commit-graph.c
 #, c-format
 msgid "commit date for commit %s in commit-graph is %<PRIuMAX> != %<PRIuMAX>"
-msgstr "提交图中提交 %s 的提交日期是 %<PRIuMAX> != %<PRIuMAX>"
+msgstr "提交图中提交 %s 的提交日期是 %<PRIuMAX> != %<PRIuMAX>"
 
 #: commit-graph.c
 #, c-format
 msgid ""
 "commit-graph has both zero and non-zero generations (e.g., commits '%s' and "
 "'%s')"
-msgstr "æ\8f\90交å\9b¾å½¢å\85·æ\9c\89é\9b¶å\92\8cé\9d\9eé\9b¶ç\9a\84ä¸\96代ï¼\88ä¾\8bå¦\82ï¼\9aæ\8f\90交 '%s' å\92\8c '%s'ï¼\89"
+msgstr "提交图具有零和非零的世代(例如:提交 '%s' 和 '%s')"
 
 #: commit-graph.c
 msgid "Verifying commits in commit graph"
@@ -18073,7 +18217,7 @@ msgstr ""
 #: commit.c
 #, c-format
 msgid "commit %s exists in commit-graph but not in the object database"
-msgstr "提交 %s 存在于提交图中,但不存在于对象数据库中"
+msgstr "提交 %s 存在于提交图中,但不存在于对象数据库中"
 
 #: commit.c
 #, c-format
@@ -19255,6 +19399,11 @@ msgstr "color-moved-ws:allow-indentation-change 不能与其它空白字符模
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "配置变量 'diff.submodule' 未知的取值:'%s'"
 
+#: diff.c transport.c
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "配置 '%s' 未知的取值:%s"
+
 #: diff.c
 #, c-format
 msgid ""
@@ -19348,13 +19497,6 @@ msgstr "坏的 --color-moved 参数:%s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "--color-moved-ws 中的无效模式 '%s' "
 
-#: diff.c
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"diff-algorithm 选项有 \"myers\"、\"minimal\"、\"patience\" 和 \"histogram\""
-
 #: diff.c
 #, c-format
 msgid "invalid argument to %s"
@@ -19412,8 +19554,8 @@ msgid "output only the last line of --stat"
 msgstr "只输出 --stat 的最后一行"
 
 #: diff.c
-msgid "<param1,param2>..."
-msgstr "<参数1,参数2>..."
+msgid "<param1>,<param2>..."
+msgstr "<参数1>,<参数2>..."
 
 #: diff.c
 msgid ""
@@ -19425,8 +19567,8 @@ msgid "synonym for --dirstat=cumulative"
 msgstr "和 --dirstat=cumulative 同义"
 
 #: diff.c
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "是 --dirstat=files,param1,param2... 的同义词"
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "是 --dirstat=files,<参数1>,<参数2>... 的同义词"
 
 #: diff.c
 msgid "warn if changes introduce conflict markers or whitespace errors"
@@ -19648,14 +19790,6 @@ msgstr "使用 \"patience diff\" 算法生成差异"
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "使用 \"histogram diff\" 算法生成差异"
 
-#: diff.c
-msgid "<algorithm>"
-msgstr "<算法>"
-
-#: diff.c
-msgid "choose a diff algorithm"
-msgstr "选择一个差异算法"
-
 #: diff.c
 msgid "<text>"
 msgstr "<文本>"
@@ -21411,6 +21545,12 @@ msgstr "无法读取缓存"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "多包索引的对象 ID 扇出表大小错误"
 
+#: midx.c
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr "对象 ID 扇出失序:fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+
 #: midx.c
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "多包索引的对象 ID 查询块大小错误"
@@ -21469,6 +21609,15 @@ msgstr "多包索引包名无序:'%s' 在 '%s' 之前"
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "错的 pack-int-id:%u(共有 %u 个包)"
 
+#: midx.c
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "多包索引中未包含 BTMP 块"
+
+#: midx.c
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "不能打开已被位图索引的包 %<PRIu32>"
+
 #: midx.c
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr "多包索引存储一个64位偏移,但是 off_t 太小"
@@ -21576,12 +21725,6 @@ msgstr "不正确的校验码"
 msgid "Looking for referenced packfiles"
 msgstr "正在查找引用的包文件"
 
-#: midx.c
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr "对象 ID 扇出无序:fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-
 #: midx.c
 msgid "the midx contains no oid"
 msgstr "midx 不包含 oid"
@@ -22211,6 +22354,10 @@ msgstr "多包位图缺少必需的反向索引"
 msgid "could not open pack %s"
 msgstr "不能打开包 %s"
 
+#: pack-bitmap.c t/helper/test-read-midx.c
+msgid "could not determine MIDX preferred pack"
+msgstr "不能确定多包索引的首选包"
+
 #: pack-bitmap.c
 #, c-format
 msgid "preferred pack (%s) is invalid"
@@ -22234,6 +22381,11 @@ msgstr "损坏的位图查询表:提交索引 %u 超出范围"
 msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr "损坏的 EWAH 位图:提交 \"%s\" 位图的文件头被截断"
 
+#: pack-bitmap.c
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr "无法打开包:'%s',禁用包重用"
+
 #: pack-bitmap.c
 #, c-format
 msgid "object '%s' not found in type bitmaps"
@@ -22349,6 +22501,10 @@ msgstr "位于 %<PRIu64> 的无效的反向索引:%<PRIu32> != %<PRIu32>"
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "多包索引的反向索引块大小错误"
 
+#: pack-revindex.c
+msgid "could not determine preferred pack"
+msgstr "无法确定首选包"
+
 #: pack-write.c
 msgid "cannot both write and verify reverse index"
 msgstr "无法同时写入和校验反向索引"
@@ -22427,11 +22583,6 @@ msgstr "%s 不可用"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s 期望一个非负整数和一个可选的 k/m/g 后缀"
 
-#: parse-options.c
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s 与 %s 不兼容"
-
 #: parse-options.c
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
@@ -22821,11 +22972,6 @@ msgstr "无法索引文件 '%s'"
 msgid "unable to add '%s' to index"
 msgstr "无法在索引中添加 '%s'"
 
-#: read-cache.c
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "无法对 %s 执行 stat"
-
 #: read-cache.c
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
@@ -23500,17 +23646,12 @@ msgstr "'%s' 已存在,无法创建 '%s'"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "无法同时处理 '%s' 和 '%s'"
 
-#: refs/files-backend.c
-#, c-format
-msgid "could not remove reference %s"
-msgstr "无法删除引用 %s"
-
-#: refs/files-backend.c refs/packed-backend.c
+#: refs.c
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "无法删除引用 %s:%s"
 
-#: refs/files-backend.c refs/packed-backend.c
+#: refs.c
 #, c-format
 msgid "could not delete references: %s"
 msgstr "无法删除引用:%s"
@@ -24665,7 +24806,7 @@ msgstr "无效的作者身份 '%s'"
 msgid "corrupt author: missing date information"
 msgstr "损坏的作者:缺失日期信息"
 
-#: sequencer.c t/helper/test-fast-rebase.c
+#: sequencer.c
 #, c-format
 msgid "could not update %s"
 msgstr "不能更新 %s"
@@ -25155,6 +25296,10 @@ msgstr "应用自动贮藏导致冲突。"
 msgid "Autostash exists; creating a new stash entry."
 msgstr "自动贮藏已经存在;正在创建一个新的贮藏条目。"
 
+#: sequencer.c
+msgid "autostash reference is a symref"
+msgstr "自动贮藏的引用是一个符号引用"
+
 #: sequencer.c
 msgid "could not detach HEAD"
 msgstr "不能分离头指针"
@@ -25529,6 +25674,11 @@ msgstr "没有从 '%s' 复制模版:%s"
 msgid "invalid initial branch name: '%s'"
 msgstr "无效的初始分支名:'%s'"
 
+#: setup.c
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init:已忽略 --initial-branch=%s"
+
 #: setup.c
 #, c-format
 msgid "unable to handle file type %d"
@@ -25544,14 +25694,14 @@ msgid "attempt to reinitialize repository with different hash"
 msgstr "尝试用不同的哈希算法重新初始化仓库"
 
 #: setup.c
-#, c-format
-msgid "%s already exists"
-msgstr "%s 已经存在"
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr "尝试使用不同的引用存储格式重新初始化仓库"
 
 #: setup.c
 #, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init:已忽略 --initial-branch=%s"
+msgid "%s already exists"
+msgstr "%s 已经存在"
 
 #: setup.c
 #, c-format
@@ -25869,14 +26019,6 @@ msgstr "在每次迭代前清除缓存树"
 msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr "缓存树中无效化的条目数量(默认 0)"
 
-#: t/helper/test-fast-rebase.c
-msgid "unhandled options"
-msgstr "未处理的选项"
-
-#: t/helper/test-fast-rebase.c
-msgid "error preparing revisions"
-msgstr "准备版本时错误"
-
 #: t/helper/test-reach.c
 #, c-format
 msgid "commit %s is not marked reachable"
@@ -26070,10 +26212,6 @@ msgstr "协议不支持设置远程服务路径"
 msgid "invalid remote service path"
 msgstr "无效的远程服务路径"
 
-#: transport-helper.c transport.c
-msgid "operation not supported by protocol"
-msgstr "协议不支持该操作"
-
 #: transport-helper.c
 #, c-format
 msgid "can't connect to subservice %s"
@@ -26237,11 +26375,6 @@ msgstr "不能解析 transport.color.* 配置"
 msgid "support for protocol v2 not implemented yet"
 msgstr "协议 v2 的支持尚未实现"
 
-#: transport.c
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "配置 '%s' 的取值未知:%s"
-
 #: transport.c
 #, c-format
 msgid "transport '%s' not allowed"
@@ -26301,6 +26434,10 @@ msgstr "协议不支持 bundle-uri 操作"
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "无法获取服务器公布的 bundle-uri 列表"
 
+#: transport.c
+msgid "operation not supported by protocol"
+msgstr "协议不支持该操作"
+
 #: tree-walk.c
 msgid "too-short tree object"
 msgstr "太短的树对象"
@@ -27329,6 +27466,11 @@ msgstr "另外,您的索引中包含未提交的变更。"
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "不能%s:您的索引中包含未提交的变更。"
 
+#: xdiff-interface.c
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "'%2$s' 的未知风格取值 '%1$s'"
+
 #: git-merge-octopus.sh git-merge-resolve.sh
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
index f777a0596f8caa04151ce928cf253090fcdd4557..312dd128a41163e63869696369138c93aefa43d9 100644 (file)
 # - Yichao Yu <yyc1992 AT gmail.com>
 # - Zhuang Ya <zhuangya AT me.com>
 #
-# Yi-Jyun Pan <pan93412@gmail.com>, 2021, 2022, 2023.
+# Yi-Jyun Pan <pan93412@gmail.com>, 2021, 2022, 2023, 2024.
 # Kaiyang Wu <self@origincode.me>, 2022.
-# lumynou5 <lumynou5.tw@gmail.com>, 2023.
+# lumynou5 <lumynou5.tw@gmail.com>, 2023, 2024.
 msgid ""
 msgstr ""
 "Project-Id-Version: Git\n"
 "Report-Msgid-Bugs-To: Git Mailing List <git@vger.kernel.org>\n"
-"POT-Creation-Date: 2023-11-19 22:29+0800\n"
-"PO-Revision-Date: 2023-11-19 23:34+0800\n"
+"POT-Creation-Date: 2024-02-18 20:48+0800\n"
+"PO-Revision-Date: 2024-02-18 20:50+0800\n"
 "Last-Translator: Yi-Jyun Pan <pan93412@gmail.com>\n"
 "Language-Team: Chinese (Traditional) <http://weblate.slat.org/projects/git-"
 "po/git-cli/zh_Hant/>\n"
@@ -36,7 +36,7 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Poedit 3.4.1\n"
+"X-Generator: Poedit 3.4.2\n"
 "X-ZhConverter: 繁化姬 dict-f4bc617e-r910 @ 2019/11/16 20:23:12 | https://"
 "zhconvert.org\n"
 
@@ -910,7 +910,7 @@ msgid "unclosed quote"
 msgstr "未閉合的引號"
 
 #: alias.c builtin/cat-file.c builtin/notes.c builtin/prune-packed.c
-#: builtin/receive-pack.c builtin/tag.c
+#: builtin/receive-pack.c builtin/tag.c t/helper/test-pkt-line.c
 msgid "too many arguments"
 msgstr "引數過多"
 
@@ -925,12 +925,13 @@ msgid "unrecognized whitespace ignore option '%s'"
 msgstr "空白字元忽略選項 “%s” 無法識別"
 
 #: apply.c archive.c builtin/add.c builtin/branch.c builtin/checkout-index.c
-#: builtin/checkout.c builtin/clone.c builtin/commit.c builtin/describe.c
-#: builtin/diff-tree.c builtin/difftool.c builtin/fast-export.c builtin/fetch.c
-#: builtin/help.c builtin/index-pack.c builtin/init-db.c builtin/log.c
-#: builtin/ls-files.c builtin/merge-base.c builtin/merge.c
-#: builtin/pack-objects.c builtin/push.c builtin/rebase.c builtin/repack.c
-#: builtin/reset.c builtin/rev-list.c builtin/show-branch.c builtin/stash.c
+#: builtin/checkout.c builtin/clean.c builtin/clone.c builtin/commit.c
+#: builtin/describe.c builtin/diff-tree.c builtin/difftool.c
+#: builtin/fast-export.c builtin/fetch.c builtin/help.c builtin/index-pack.c
+#: builtin/init-db.c builtin/log.c builtin/ls-files.c builtin/merge-base.c
+#: builtin/merge-tree.c builtin/merge.c builtin/pack-objects.c builtin/rebase.c
+#: builtin/repack.c builtin/replay.c builtin/reset.c builtin/rev-list.c
+#: builtin/rev-parse.c builtin/show-branch.c builtin/stash.c
 #: builtin/submodule--helper.c builtin/tag.c builtin/worktree.c parse-options.c
 #: range-diff.c revision.c
 #, c-format
@@ -1240,12 +1241,12 @@ msgstr "%s:已存在於工作區中"
 #: apply.c
 #, c-format
 msgid "new mode (%o) of %s does not match old mode (%o)"
-msgstr "%2$s 的新模式 (%1$o) 和舊模式 (%3$o) 不符"
+msgstr "%2$s 的新模式(%1$o)和舊模式(%3$o)不符"
 
 #: apply.c
 #, c-format
 msgid "new mode (%o) of %s does not match old mode (%o) of %s"
-msgstr "%2$s 的新模式 (%1$o) 和 %4$s 的舊模式 (%3$o) 不符"
+msgstr "%2$s 的新模式(%1$o)和 %4$s 的舊模式(%3$o)不符"
 
 #: apply.c
 #, c-format
@@ -1732,6 +1733,11 @@ msgstr "“%s” 選項需要 “%s”"
 msgid "Unexpected option --output"
 msgstr "非預期選項 --output"
 
+#: archive.c
+#, c-format
+msgid "extra command line parameter '%s'"
+msgstr "多出命令列參數 “%s”"
+
 #: archive.c
 #, c-format
 msgid "Unknown archive format '%s'"
@@ -1788,6 +1794,17 @@ msgstr "忽略過大的 gitattributes 資料物件 “%s”"
 msgid "bad --attr-source or GIT_ATTR_SOURCE"
 msgstr "無效的 --attr-source 或 GIT_ATTR_SOURCE"
 
+#: attr.c read-cache.c
+#, c-format
+msgid "unable to stat '%s'"
+msgstr "無法對 %s 執行 stat"
+
+#: bisect.c builtin/cat-file.c builtin/index-pack.c builtin/notes.c
+#: builtin/pack-objects.c combine-diff.c rerere.c
+#, c-format
+msgid "unable to read %s"
+msgstr "不能讀 %s"
+
 #: bisect.c
 #, c-format
 msgid "Badly quoted content in file '%s': %s"
@@ -2323,8 +2340,8 @@ msgid "bad action '%s' for '%s'"
 msgstr "“%s” 動作對 “%s” 無效"
 
 #: builtin/am.c builtin/blame.c builtin/fetch.c builtin/pack-objects.c
-#: builtin/pull.c diff-merges.c gpg-interface.c ls-refs.c parallel-checkout.c
-#: sequencer.c setup.c
+#: builtin/pull.c config.c diff-merges.c gpg-interface.c ls-refs.c
+#: parallel-checkout.c sequencer.c setup.c
 #, c-format
 msgid "invalid value for '%s': '%s'"
 msgstr "“%s” 的值無效:“%s”"
@@ -2477,8 +2494,7 @@ msgstr "git write-tree 無法寫入樹狀物件"
 msgid "applying to an empty history"
 msgstr "正在套用至空白歷史記錄上"
 
-#: builtin/am.c builtin/commit.c builtin/merge.c sequencer.c
-#: t/helper/test-fast-rebase.c
+#: builtin/am.c builtin/commit.c builtin/merge.c builtin/replay.c sequencer.c
 msgid "failed to write commit object"
 msgstr "無法寫入提交物件"
 
@@ -2661,8 +2677,9 @@ msgid "n"
 msgstr "n"
 
 #: builtin/am.c builtin/branch.c builtin/bugreport.c builtin/cat-file.c
-#: builtin/diagnose.c builtin/for-each-ref.c builtin/ls-files.c
-#: builtin/ls-tree.c builtin/replace.c builtin/tag.c builtin/verify-tag.c
+#: builtin/clone.c builtin/diagnose.c builtin/for-each-ref.c builtin/init-db.c
+#: builtin/ls-files.c builtin/ls-tree.c builtin/replace.c builtin/tag.c
+#: builtin/verify-tag.c
 msgid "format"
 msgstr "format"
 
@@ -3357,12 +3374,13 @@ msgstr "無法查詢 “%s” 指向的提交物件"
 
 #: builtin/branch.c
 #, c-format
-msgid ""
-"the branch '%s' is not fully merged.\n"
-"If you are sure you want to delete it, run 'git branch -D %s'"
-msgstr ""
-"分支 “%s” 沒有完全合併。\n"
-"如果確定要刪除它,請執行 “git branch -D %s”"
+msgid "the branch '%s' is not fully merged"
+msgstr "分支 “%s” 沒有完全合併"
+
+#: builtin/branch.c
+#, c-format
+msgid "If you are sure you want to delete it, run 'git branch -D %s'"
+msgstr "如果確定要刪除它,請執行 “git branch -D %s”"
 
 #: builtin/branch.c
 msgid "update of config-file failed"
@@ -4370,7 +4388,7 @@ msgstr "無法對 “%s” 執行 reflog 動作:%s\n"
 msgid "HEAD is now at"
 msgstr "HEAD 目前位於"
 
-#: builtin/checkout.c builtin/clone.c t/helper/test-fast-rebase.c
+#: builtin/checkout.c builtin/clone.c
 msgid "unable to update HEAD"
 msgstr "無法更新 HEAD"
 
@@ -4631,8 +4649,8 @@ msgid "new-branch"
 msgstr "new-branch"
 
 #: builtin/checkout.c
-msgid "new unparented branch"
-msgstr "新的,沒有父提交的分支"
+msgid "new unborn branch"
+msgstr "新的未誕生分支"
 
 #: builtin/checkout.c builtin/merge.c
 msgid "update ignored files (default)"
@@ -4699,7 +4717,7 @@ msgstr ""
 msgid "you must specify path(s) to restore"
 msgstr "您必須指定要還原的路徑"
 
-#: builtin/checkout.c builtin/clone.c builtin/remote.c
+#: builtin/checkout.c builtin/clone.c builtin/remote.c builtin/replay.c
 #: builtin/submodule--helper.c builtin/worktree.c
 msgid "branch"
 msgstr "branch"
@@ -4940,10 +4958,6 @@ msgid ""
 msgstr ""
 "clean.requireForce 預設為 true 且未提供 -i、-n 或 -f 選項,拒絕執行清理動作"
 
-#: builtin/clean.c
-msgid "-x and -X cannot be used together"
-msgstr "-x 和 -X 不能同時使用"
-
 #: builtin/clone.c
 msgid "git clone [<options>] [--] <repo> [<dir>]"
 msgstr "git clone [<options>] [--] <repo> [<dir>]"
@@ -5035,6 +5049,7 @@ msgid "create a shallow clone since a specific time"
 msgstr "建立從指定時間到現在的淺層複製"
 
 #: builtin/clone.c builtin/fetch.c builtin/pull.c builtin/rebase.c
+#: builtin/replay.c
 msgid "revision"
 msgstr "revision"
 
@@ -5062,6 +5077,10 @@ msgstr "gitdir"
 msgid "separate git dir from working tree"
 msgstr "git 目錄和工作區分離"
 
+#: builtin/clone.c builtin/init-db.c
+msgid "specify the reference format to use"
+msgstr "指定要使用的引用格式"
+
 #: builtin/clone.c
 msgid "key=value"
 msgstr "key=value"
@@ -5211,11 +5230,10 @@ msgstr "太多參數。"
 msgid "You must specify a repository to clone."
 msgstr "您必須指定要複製的版本庫。"
 
-#: builtin/clone.c
-msgid ""
-"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
-"exclude"
-msgstr "--bundle-uri 與 --depth、--shallow-since 和 --shallow-exclude 不相容"
+#: builtin/clone.c builtin/init-db.c setup.c
+#, c-format
+msgid "unknown ref storage format '%s'"
+msgstr "未知的引用儲存格式 “%s”"
 
 #: builtin/clone.c
 #, c-format
@@ -5376,14 +5394,14 @@ msgid ""
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 msgstr ""
 "git commit-graph write [--object-dir <dir>] [--append]\n"
 "                       [--split[=<strategy>]] [--reachable | --stdin-packs | "
 "--stdin-commits]\n"
 "                       [--changed-paths] [--[no-]max-new-filters <n>] [--"
 "[no-]progress]\n"
-"                       <split options>"
+"                       <split-options>"
 
 #: builtin/commit-graph.c builtin/fetch.c builtin/log.c builtin/repack.c
 msgid "dir"
@@ -8262,6 +8280,11 @@ msgstr "沒有執行緒支援,忽略 %s"
 msgid "unable to read tree (%s)"
 msgstr "無法讀取樹(%s)"
 
+#: builtin/grep.c
+#, c-format
+msgid "unable to read tree %s"
+msgstr "無法讀取 %s 樹狀物件"
+
 #: builtin/grep.c
 #, c-format
 msgid "unable to grep from object of type %s"
@@ -8784,11 +8807,6 @@ msgstr "解壓縮嚴重的不一致"
 msgid "SHA1 COLLISION FOUND WITH %s !"
 msgstr "發現 %s 出現 SHA1 衝突!"
 
-#: builtin/index-pack.c builtin/pack-objects.c
-#, c-format
-msgid "unable to read %s"
-msgstr "不能讀 %s"
-
 #: builtin/index-pack.c
 #, c-format
 msgid "cannot read existing object info %s"
@@ -8962,11 +8980,13 @@ msgstr "在打包物件中 fsck 檢查發生錯誤"
 msgid ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 msgstr ""
 "git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
 "         [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
+"         [--ref-format=<format>]\n"
 "         [-b <branch-name> | --initial-branch=<branch-name>]\n"
 "         [--shared[=<permissions>]] [<directory>]"
 
@@ -9125,7 +9145,7 @@ msgid ""
 "<file>"
 msgstr "追蹤 <開始>,<結束> 範圍中橫列或 <檔案> 中> :<函數名稱> 的變化史"
 
-#: builtin/log.c builtin/shortlog.c bundle.c
+#: builtin/log.c builtin/replay.c builtin/shortlog.c bundle.c
 #, c-format
 msgid "unrecognized argument: %s"
 msgstr "無法識別的參數:%s"
@@ -9868,6 +9888,13 @@ msgstr ""
 "git merge-file [<選項>] [-L <檔案1> [-L <初始> [-L <名字2>]]] <檔案1> <初始文"
 "件> <檔案2>"
 
+#: builtin/merge-file.c diff.c
+msgid ""
+"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
+"\"histogram\""
+msgstr ""
+"diff-algorithm 選項有 \"myers\"、\"minimal\"、\"patience\" 和 \"histogram\""
+
 #: builtin/merge-file.c
 msgid "send results to standard output"
 msgstr "將結果傳送到標準輸出"
@@ -9896,6 +9923,14 @@ msgstr "如果衝突,使用他們的版本"
 msgid "for conflicts, use a union version"
 msgstr "如果衝突,使用聯合版本"
 
+#: builtin/merge-file.c diff.c
+msgid "<algorithm>"
+msgstr "<演算法>"
+
+#: builtin/merge-file.c diff.c
+msgid "choose a diff algorithm"
+msgstr "選擇一個差異演算法"
+
 #: builtin/merge-file.c
 msgid "for conflicts, use this marker size"
 msgstr "如果衝突,使用指定長度的標記"
@@ -10012,10 +10047,6 @@ msgstr "--trivial-merge 和其他所有選項都不相容"
 msgid "unknown strategy option: -X%s"
 msgstr "未知的策略選項:-X%s"
 
-#: builtin/merge-tree.c
-msgid "--merge-base is incompatible with --stdin"
-msgstr "--merge-base 與 --stdin 不相容"
-
 #: builtin/merge-tree.c builtin/notes.c
 #, c-format
 msgid "malformed input line: '%s'."
@@ -10174,7 +10205,7 @@ msgstr "'%s' 沒有指向一個提交"
 msgid "Bad branch.%s.mergeoptions string: %s"
 msgstr "壞的 branch.%s.mergeoptions 字串:%s"
 
-#: builtin/merge.c builtin/stash.c merge-recursive.c
+#: builtin/merge.c merge-recursive.c
 msgid "Unable to write index."
 msgstr "不能寫入索引。"
 
@@ -10182,7 +10213,7 @@ msgstr "不能寫入索引。"
 msgid "Not handling anything other than two heads merge."
 msgstr "未處理兩個頭合併之外的任何動作。"
 
-#: builtin/merge.c t/helper/test-fast-rebase.c
+#: builtin/merge.c
 #, c-format
 msgid "unable to write %s"
 msgstr "不能寫 %s"
@@ -11168,6 +11199,11 @@ msgstr "壓縮物件中"
 msgid "inconsistency with delta count"
 msgstr "不一致的差異計數"
 
+#: builtin/pack-objects.c
+#, c-format
+msgid "invalid pack.allowPackReuse value: '%s'"
+msgstr "無效的 pack.allowPackReuse 值:“%s”"
+
 #: builtin/pack-objects.c
 #, c-format
 msgid ""
@@ -11492,10 +11528,10 @@ msgstr "枚舉物件"
 #, c-format
 msgid ""
 "Total %<PRIu32> (delta %<PRIu32>), reused %<PRIu32> (delta %<PRIu32>), pack-"
-"reused %<PRIu32>"
+"reused %<PRIu32> (from %<PRIuMAX>)"
 msgstr ""
 "總共 %<PRIu32> (差異 %<PRIu32>),復用 %<PRIu32> (差異 %<PRIu32>),重用包 "
-"%<PRIu32>"
+"%<PRIu32> (總共 %<PRIuMAX>)"
 
 #: builtin/pack-redundant.c
 msgid ""
@@ -12574,7 +12610,7 @@ msgstr "沒有正在進行的重定基底?"
 msgid "The --edit-todo action can only be used during interactive rebase."
 msgstr "動作 --edit-todo 只能用在互動式重定基底過程中。"
 
-#: builtin/rebase.c t/helper/test-fast-rebase.c
+#: builtin/rebase.c
 msgid "Cannot read HEAD"
 msgstr "不能讀取 HEAD"
 
@@ -12618,12 +12654,6 @@ msgstr ""
 msgid "switch `C' expects a numerical value"
 msgstr "開關 `C' 期望一個數字值"
 
-#: builtin/rebase.c
-msgid ""
-"apply options are incompatible with rebase.autoSquash.  Consider adding --no-"
-"autosquash"
-msgstr "apply 選項與 rebase.autoSquash 不相容。請考慮加上 --no-autosquash"
-
 #: builtin/rebase.c
 msgid ""
 "apply options are incompatible with rebase.rebaseMerges.  Consider adding --"
@@ -13109,7 +13139,7 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
+msgstr[0] "注意:refs/remotes/ 層級之外的一個分支未被移除。要刪除它,使用:"
 
 #: builtin/remote.c
 #, c-format
@@ -13838,6 +13868,86 @@ msgstr "--convert-graft-file 不帶參數"
 msgid "only one pattern can be given with -l"
 msgstr "只能為 -l 提供一個模式"
 
+#: builtin/replay.c
+msgid "need some commits to replay"
+msgstr "需要一些提交才能重放"
+
+#: builtin/replay.c
+msgid "--onto and --advance are incompatible"
+msgstr "--onto 和 --advance 不相容"
+
+#: builtin/replay.c
+msgid "all positive revisions given must be references"
+msgstr "提供的所有正向修訂集必須為引用"
+
+#: builtin/replay.c
+msgid "argument to --advance must be a reference"
+msgstr "傳入 --advance 的引數必須為引用"
+
+#: builtin/replay.c
+msgid ""
+"cannot advance target with multiple sources because ordering would be ill-"
+"defined"
+msgstr "無法用多個來源演進目的地,以免無法確定排序"
+
+#: builtin/replay.c
+msgid ""
+"cannot implicitly determine whether this is an --advance or --onto operation"
+msgstr "無法假設這是 --advance 還是 --onto 動作"
+
+#: builtin/replay.c
+msgid ""
+"cannot advance target with multiple source branches because ordering would "
+"be ill-defined"
+msgstr "無法由多個來源分支演進目的地,以免無法確定排序"
+
+#: builtin/replay.c
+msgid "cannot implicitly determine correct base for --onto"
+msgstr "無法假設 --onto 的正確基底"
+
+#: builtin/replay.c
+msgid ""
+"(EXPERIMENTAL!) git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+msgstr ""
+"(實驗性功能!)git replay ([--contained] --onto <newbase> | --advance "
+"<branch>) <revision-range>..."
+
+#: builtin/replay.c
+msgid "make replay advance given branch"
+msgstr "在指定分支上進行重放演進"
+
+#: builtin/replay.c
+msgid "replay onto given commit"
+msgstr "重放到指定提交"
+
+#: builtin/replay.c
+msgid "advance all branches contained in revision-range"
+msgstr "演進所有包含在 revision-range 中的分支"
+
+#: builtin/replay.c
+msgid "option --onto or --advance is mandatory"
+msgstr "必須傳入 --onto 或 --advance 選項"
+
+#: builtin/replay.c
+#, c-format
+msgid ""
+"some rev walking options will be overridden as '%s' bit in 'struct rev_info' "
+"will be forced"
+msgstr "將覆寫部分修訂版遍歷選項,強制使用 “struct rev_info” 的 “%s” 位元"
+
+#: builtin/replay.c
+msgid "error preparing revisions"
+msgstr "無法準備修訂集"
+
+#: builtin/replay.c
+msgid "replaying down to root commit is not supported yet!"
+msgstr "尚不支援重放到根提交!"
+
+#: builtin/replay.c
+msgid "replaying merge commits is not supported yet!"
+msgstr "尚不支援重放合併提交!"
+
 #: builtin/rerere.c
 msgid ""
 "git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"
@@ -14100,18 +14210,6 @@ msgstr "--prefix 需要 1 個引數"
 msgid "unknown mode for --abbrev-ref: %s"
 msgstr "--abbrev-ref 的模式未知:%s"
 
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --branches"
-msgstr "--exclude-hidden 無法與 --branches 同時使用"
-
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --tags"
-msgstr "--exclude-hidden 無法與 --tags 同時使用"
-
-#: builtin/rev-parse.c revision.c
-msgid "--exclude-hidden cannot be used together with --remotes"
-msgstr "--exclude-hidden 無法與 --remotes 同時使用"
-
 #: builtin/rev-parse.c setup.c
 msgid "this operation must be run in a work tree"
 msgstr "該動作必須在一個工作區中執行"
@@ -14610,11 +14708,6 @@ msgstr "不列印結果到標準輸出(例如與 --verify 參數共用)"
 msgid "show refs from stdin that aren't in local repository"
 msgstr "顯示從標準輸入中讀入的不在本機版本庫中的引用"
 
-#: builtin/show-ref.c
-#, c-format
-msgid "only one of '%s', '%s' or '%s' can be given"
-msgstr "只能傳入 “%s”、“%s” 或 “%s”"
-
 #: builtin/sparse-checkout.c
 msgid ""
 "git sparse-checkout (init | list | set | add | reapply | disable | check-"
@@ -16389,14 +16482,14 @@ msgstr "沒有可能的來源分支,推測為 “--orphan”"
 #: builtin/worktree.c
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
 msgstr ""
 "如果您是想要在這個版本庫建立一個工作區,裡面包含一個\n"
-"孤立分支(即沒有提交的分支),可以使用 --orphan 達到\n"
+"未誕生分支(即沒有提交的分支),可以使用 --orphan 達到\n"
 "這個效果:\n"
 "\n"
 "    git worktree add --orphan -b %s %s\n"
@@ -16404,14 +16497,14 @@ msgstr ""
 #: builtin/worktree.c
 #, c-format
 msgid ""
-"If you meant to create a worktree containing a new orphan branch\n"
+"If you meant to create a worktree containing a new unborn branch\n"
 "(branch with no commits) for this repository, you can do so\n"
 "using the --orphan flag:\n"
 "\n"
 "    git worktree add --orphan %s\n"
 msgstr ""
 "如果您是想要在這個版本庫建立一個工作區,裡面包含一個\n"
-"孤立分支(即沒有提交的分支),可以使用 --orphan 達到\n"
+"未誕生分支(即沒有提交的分支),可以使用 --orphan 達到\n"
 "這個效果:\n"
 "\n"
 "    git worktree add --orphan %s\n"
@@ -16481,6 +16574,11 @@ msgstr "不能建立目錄 '%s'"
 msgid "initializing"
 msgstr "正在初始化"
 
+#: builtin/worktree.c
+#, c-format
+msgid "could not find created worktree '%s'"
+msgstr "找不到建立的工作區「%s」"
+
 #: builtin/worktree.c
 #, c-format
 msgid "Preparing worktree (new branch '%s')"
@@ -16525,11 +16623,6 @@ msgstr ""
 "即使有提供一個遠端,卻不存在本機或遠端引用,\n"
 "故停止。使用 “add -f” 先覆蓋或抓取遠端"
 
-#: builtin/worktree.c
-#, c-format
-msgid "'%s' and '%s' cannot be used together"
-msgstr "無法同時使用 “%s” 和 “%s”"
-
 #: builtin/worktree.c
 msgid "checkout <branch> even if already checked out in other worktree"
 msgstr "簽出 <分支>,即使已經被簽出到其它工作區"
@@ -16543,8 +16636,8 @@ msgid "create or reset a branch"
 msgstr "建立或重設一個分支"
 
 #: builtin/worktree.c
-msgid "create unborn/orphaned branch"
-msgstr "建立尚無內容(孤立)的分支"
+msgid "create unborn branch"
+msgstr "建立未誕生分支"
 
 #: builtin/worktree.c
 msgid "populate the new working tree"
@@ -16573,12 +16666,8 @@ msgstr "「%s」、「%s」和「%s」選項不得同時使用"
 
 #: builtin/worktree.c
 #, c-format
-msgid "options '%s', and '%s' cannot be used together"
-msgstr "無法同時使用 “%s” 和 “%s” 選項"
-
-#: builtin/worktree.c
-msgid "<commit-ish>"
-msgstr "<提交指示元>"
+msgid "option '%s' and commit-ish cannot be used together"
+msgstr "“%s” 選項和提交號不得同時使用"
 
 #: builtin/worktree.c
 msgid "added with --lock"
@@ -17366,6 +17455,10 @@ msgstr "打包版本庫中未打包物件"
 msgid "Create, list, delete refs to replace objects"
 msgstr "建立、列出、刪除物件取代引用"
 
+#: command-list.h
+msgid "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
+msgstr "實驗性功能:在新的基底重放提交,亦支援裸版本庫"
+
 #: command-list.h
 msgid "Generates a summary of pending changes"
 msgstr "生成待定更改的摘要"
@@ -17683,6 +17776,37 @@ msgstr "用來管理大型 Git 版本庫的工具"
 msgid "commit-graph file is too small"
 msgstr "提交圖形檔案太小"
 
+#: commit-graph.c
+msgid "commit-graph oid fanout chunk is wrong size"
+msgstr "提交圖形 OID 扇出區塊大小有誤"
+
+#: commit-graph.c
+msgid "commit-graph fanout values out of order"
+msgstr "提交圖形扇出的數值失序"
+
+#: commit-graph.c
+msgid "commit-graph OID lookup chunk is the wrong size"
+msgstr "提交圖形 OID 查詢區塊的大小有誤"
+
+#: commit-graph.c
+msgid "commit-graph commit data chunk is wrong size"
+msgstr "提交圖形的提交資料區塊大小有誤"
+
+#: commit-graph.c
+msgid "commit-graph generations chunk is wrong size"
+msgstr "提交圖形的世代區塊大小有誤"
+
+#: commit-graph.c
+msgid "commit-graph changed-path index chunk is too small"
+msgstr "提交圖形的更動路徑索引區塊過小"
+
+#: commit-graph.c
+#, c-format
+msgid ""
+"ignoring too-small changed-path chunk (%<PRIuMAX> < %<PRIuMAX>) in commit-"
+"graph file"
+msgstr "忽略提交圖形檔案中過小的更動路徑區塊 (%<PRIuMAX> < %<PRIuMAX>)"
+
 #: commit-graph.c
 #, c-format
 msgid "commit-graph signature %X does not match signature %X"
@@ -17701,7 +17825,19 @@ msgstr "提交圖形雜湊版本 %X 和版本 %X 不符合"
 #: commit-graph.c
 #, c-format
 msgid "commit-graph file is too small to hold %u chunks"
-msgstr "commit-graph 檔案不夠放置 %u 個區塊"
+msgstr "提交圖形檔案不夠放置 %u 個區塊"
+
+#: commit-graph.c
+msgid "commit-graph required OID fanout chunk missing or corrupted"
+msgstr "提交圖形需要的 OID 扇出區塊遺失或損壞"
+
+#: commit-graph.c
+msgid "commit-graph required OID lookup chunk missing or corrupted"
+msgstr "提交圖形需要的 OID 查詢區塊遺失或損壞"
+
+#: commit-graph.c
+msgid "commit-graph required commit data chunk missing or corrupted"
+msgstr "提交圖形需要的提交資料區塊遺失或損壞"
 
 #: commit-graph.c
 msgid "commit-graph has no base graphs chunk"
@@ -17720,10 +17856,14 @@ msgstr "提交圖形鏈不符合"
 msgid "commit count in base graph too high: %<PRIuMAX>"
 msgstr "基礎圖 (base graph) 中的提交數過多:%<PRIuMAX>"
 
+#: commit-graph.c
+msgid "commit-graph chain file too small"
+msgstr "提交圖形鏈檔案過小"
+
 #: commit-graph.c
 #, c-format
 msgid "invalid commit-graph chain: line '%s' not a hash"
-msgstr "無效的提交圖形鏈:行 '%s' 不是一個雜湊值"
+msgstr "無效的提交圖形鏈:「%s」列不是雜湊值"
 
 #: commit-graph.c
 msgid "unable to find all commit-graph files"
@@ -17746,6 +17886,10 @@ msgstr "提交圖需要比目前更多的世代資料,但沒有相關資料"
 msgid "commit-graph overflow generation data is too small"
 msgstr "提交圖形的溢出世代資料過小"
 
+#: commit-graph.c
+msgid "commit-graph extra-edges pointer out of bounds"
+msgstr "提交圖形的延伸邊界指針超出範圍"
+
 #: commit-graph.c
 msgid "Loading known commits in commit graph"
 msgstr "正在載入提交圖中的已知提交"
@@ -19120,6 +19264,11 @@ msgstr "color-moved-ws:allow-indentation-change 不能與其它空白字元模
 msgid "Unknown value for 'diff.submodule' config variable: '%s'"
 msgstr "設定變數 'diff.submodule' 未知的取值:'%s'"
 
+#: diff.c transport.c
+#, c-format
+msgid "unknown value for config '%s': %s"
+msgstr "設定 '%s' 的取值未知:%s"
+
 #: diff.c
 #, c-format
 msgid ""
@@ -19213,13 +19362,6 @@ msgstr "壞的 --color-moved 參數:%s"
 msgid "invalid mode '%s' in --color-moved-ws"
 msgstr "--color-moved-ws 中的無效模式 '%s'"
 
-#: diff.c
-msgid ""
-"option diff-algorithm accepts \"myers\", \"minimal\", \"patience\" and "
-"\"histogram\""
-msgstr ""
-"diff-algorithm 選項有 \"myers\"、\"minimal\"、\"patience\" 和 \"histogram\""
-
 #: diff.c
 #, c-format
 msgid "invalid argument to %s"
@@ -19277,8 +19419,9 @@ msgid "output only the last line of --stat"
 msgstr "只輸出 --stat 的最後一行"
 
 #: diff.c
-msgid "<param1,param2>..."
-msgstr "<參數1,參數2>..."
+#| msgid "<param1,param2>..."
+msgid "<param1>,<param2>..."
+msgstr "<param1>,<param2>..."
 
 #: diff.c
 msgid ""
@@ -19290,8 +19433,8 @@ msgid "synonym for --dirstat=cumulative"
 msgstr "和 --dirstat=cumulative 同義"
 
 #: diff.c
-msgid "synonym for --dirstat=files,param1,param2..."
-msgstr "是 --dirstat=files,param1,param2... 的同義詞"
+msgid "synonym for --dirstat=files,<param1>,<param2>..."
+msgstr "是 --dirstat=files,<param1>,<param2>... 的同義詞"
 
 #: diff.c
 msgid "warn if changes introduce conflict markers or whitespace errors"
@@ -19513,14 +19656,6 @@ msgstr "使用 \"patience diff\" 演算法生成差異"
 msgid "generate diff using the \"histogram diff\" algorithm"
 msgstr "使用 \"histogram diff\" 演算法生成差異"
 
-#: diff.c
-msgid "<algorithm>"
-msgstr "<演算法>"
-
-#: diff.c
-msgid "choose a diff algorithm"
-msgstr "選擇一個差異演算法"
-
 #: diff.c
 msgid "<text>"
 msgstr "<文字>"
@@ -20940,7 +21075,7 @@ msgstr ""
 #. conflict in a submodule. The first argument is the submodule
 #. name, and the second argument is the abbreviated id of the
 #. commit that needs to be merged.  For example:
-#. - go to submodule (mysubmodule), and either merge commit abc1234"
+#.  - go to submodule (mysubmodule), and either merge commit abc1234"
 #.
 #: merge-ort.c
 #, c-format
@@ -21274,6 +21409,12 @@ msgstr "讀取快取失敗"
 msgid "multi-pack-index OID fanout is of the wrong size"
 msgstr "多包索引的物件 ID fanout 大小錯誤"
 
+#: midx.c
+#, c-format
+msgid ""
+"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+msgstr "物件 ID 扇出無序:fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
+
 #: midx.c
 msgid "multi-pack-index OID lookup chunk is the wrong size"
 msgstr "多包索引 OID 查詢區塊的大小有誤"
@@ -21332,6 +21473,15 @@ msgstr "多包索引包名無序:'%s' 在 '%s' 之前"
 msgid "bad pack-int-id: %u (%u total packs)"
 msgstr "錯的 pack-int-id:%u(共有 %u 個包)"
 
+#: midx.c
+msgid "MIDX does not contain the BTMP chunk"
+msgstr "MIDX 未包含 BTMP 區塊"
+
+#: midx.c
+#, c-format
+msgid "could not load bitmapped pack %<PRIu32>"
+msgstr "無法載入位圖化 (bitmapped) 的封裝 %<PRIu32>"
+
 #: midx.c
 msgid "multi-pack-index stores a 64-bit offset, but off_t is too small"
 msgstr "多包索引儲存一個64位位移,但是 off_t 太小"
@@ -21439,12 +21589,6 @@ msgstr "總和檢查碼不正確"
 msgid "Looking for referenced packfiles"
 msgstr "正在尋找引用的 packfile"
 
-#: midx.c
-#, c-format
-msgid ""
-"oid fanout out of order: fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-msgstr "物件 ID 扇出無序:fanout[%d] = %<PRIx32> > %<PRIx32> = fanout[%d]"
-
 #: midx.c
 msgid "the midx contains no oid"
 msgstr "midx 沒有 oid"
@@ -21820,7 +21964,7 @@ msgstr "%s [無效物件]"
 #. TRANSLATORS: This is a line of ambiguous commit
 #. object output. E.g.:
 #. *
-#. "deadbeef commit 2021-01-01 - Some Commit Message"
+#.    "deadbeef commit 2021-01-01 - Some Commit Message"
 #.
 #: object-name.c
 #, c-format
@@ -21830,7 +21974,7 @@ msgstr "%s 提交 %s - %s"
 #. TRANSLATORS: This is a line of ambiguous
 #. tag object output. E.g.:
 #. *
-#. "deadbeef tag 2022-01-01 - Some Tag Message"
+#.    "deadbeef tag 2022-01-01 - Some Tag Message"
 #. *
 #. The second argument is the YYYY-MM-DD found
 #. in the tag.
@@ -21847,7 +21991,7 @@ msgstr "%s 標籤 %s - %s"
 #. tag object output where we couldn't parse
 #. the tag itself. E.g.:
 #. *
-#. "deadbeef [bad tag, could not parse it]"
+#.    "deadbeef [bad tag, could not parse it]"
 #.
 #: object-name.c
 #, c-format
@@ -22075,6 +22219,10 @@ msgstr "多包位圖缺少需要的反向索引"
 msgid "could not open pack %s"
 msgstr "無法開啟封包 %s"
 
+#: pack-bitmap.c t/helper/test-read-midx.c
+msgid "could not determine MIDX preferred pack"
+msgstr "無法確定 MIDX 偏好的封裝"
+
 #: pack-bitmap.c
 #, c-format
 msgid "preferred pack (%s) is invalid"
@@ -22098,6 +22246,11 @@ msgstr "位圖查詢表損壞:提交索引 %u 超出範圍"
 msgid "corrupt ewah bitmap: truncated header for bitmap of commit \"%s\""
 msgstr "ewah 位圖損壞:提交 “%s” 之位圖的標頭遭截斷"
 
+#: pack-bitmap.c
+#, c-format
+msgid "unable to load pack: '%s', disabling pack-reuse"
+msgstr "無法載入「%s」封裝,停用 pack-reuse"
+
 #: pack-bitmap.c
 #, c-format
 msgid "object '%s' not found in type bitmaps"
@@ -22213,6 +22366,10 @@ msgstr "%<PRIu64> 位置的修訂版索引 (rev-index) 無效:%<PRIu32> != %<P
 msgid "multi-pack-index reverse-index chunk is the wrong size"
 msgstr "多包索引的反向索引區塊大小有誤"
 
+#: pack-revindex.c
+msgid "could not determine preferred pack"
+msgstr "無法確定偏好封裝"
+
 #: pack-write.c
 msgid "cannot both write and verify reverse index"
 msgstr "無法同時寫入和驗證倒排索引"
@@ -22291,11 +22448,6 @@ msgstr "%s 不可用"
 msgid "%s expects a non-negative integer value with an optional k/m/g suffix"
 msgstr "%s 期望一個非負整數和一個可選的 k/m/g 後綴"
 
-#: parse-options.c
-#, c-format
-msgid "%s is incompatible with %s"
-msgstr "%s 與 %s 不相容"
-
 #: parse-options.c
 #, c-format
 msgid "ambiguous option: %s (could be --%s%s or --%s%s)"
@@ -22685,11 +22837,6 @@ msgstr "無法索引檔案 '%s'"
 msgid "unable to add '%s' to index"
 msgstr "無法在索引中新增 '%s'"
 
-#: read-cache.c
-#, c-format
-msgid "unable to stat '%s'"
-msgstr "無法對 %s 執行 stat"
-
 #: read-cache.c
 #, c-format
 msgid "'%s' appears as both a file and as a directory"
@@ -23364,17 +23511,12 @@ msgstr "'%s' 已存在,無法建立 '%s'"
 msgid "cannot process '%s' and '%s' at the same time"
 msgstr "無法同時處理 '%s' 和 '%s'"
 
-#: refs/files-backend.c
-#, c-format
-msgid "could not remove reference %s"
-msgstr "無法刪除引用 %s"
-
-#: refs/files-backend.c refs/packed-backend.c
+#: refs.c
 #, c-format
 msgid "could not delete reference %s: %s"
 msgstr "無法刪除引用 %s:%s"
 
-#: refs/files-backend.c refs/packed-backend.c
+#: refs.c
 #, c-format
 msgid "could not delete references: %s"
 msgstr "無法刪除引用:%s"
@@ -24532,7 +24674,7 @@ msgstr "無效的作者身分 '%s'"
 msgid "corrupt author: missing date information"
 msgstr "作者資訊損壞:缺少日期資訊"
 
-#: sequencer.c t/helper/test-fast-rebase.c
+#: sequencer.c
 #, c-format
 msgid "could not update %s"
 msgstr "不能更新 %s"
@@ -25023,6 +25165,10 @@ msgstr "因套用自動貯存而導致衝突。"
 msgid "Autostash exists; creating a new stash entry."
 msgstr "已有自動貯存;建立新貯存項目。"
 
+#: sequencer.c
+msgid "autostash reference is a symref"
+msgstr "autostash 引用是符號引用"
+
 #: sequencer.c
 msgid "could not detach HEAD"
 msgstr "不能分離開頭指標"
@@ -25395,6 +25541,11 @@ msgstr "沒有從 '%s' 複製範本:%s"
 msgid "invalid initial branch name: '%s'"
 msgstr "無效的初始分支名稱:'%s'"
 
+#: setup.c
+#, c-format
+msgid "re-init: ignored --initial-branch=%s"
+msgstr "re-init: 忽略 --initial-branch=%s"
+
 #: setup.c
 #, c-format
 msgid "unable to handle file type %d"
@@ -25410,14 +25561,14 @@ msgid "attempt to reinitialize repository with different hash"
 msgstr "嘗試以不同的雜湊值重新初始化版本庫"
 
 #: setup.c
-#, c-format
-msgid "%s already exists"
-msgstr "%s 已經存在"
+msgid ""
+"attempt to reinitialize repository with different reference storage format"
+msgstr "嘗試以不同的引用儲存格式重新初始化版本庫"
 
 #: setup.c
 #, c-format
-msgid "re-init: ignored --initial-branch=%s"
-msgstr "re-init: 忽略 --initial-branch=%s"
+msgid "%s already exists"
+msgstr "%s 已經存在"
 
 #: setup.c
 #, c-format
@@ -25733,14 +25884,6 @@ msgstr "每次迭代前清除快取樹狀物件"
 msgid "number of entries in the cache tree to invalidate (default 0)"
 msgstr "在快取樹狀物件中,要使失效的項目數量(預設值為 0)"
 
-#: t/helper/test-fast-rebase.c
-msgid "unhandled options"
-msgstr "未處理選項"
-
-#: t/helper/test-fast-rebase.c
-msgid "error preparing revisions"
-msgstr "準備修訂版本時發生錯誤"
-
 #: t/helper/test-reach.c
 #, c-format
 msgid "commit %s is not marked reachable"
@@ -25934,10 +26077,6 @@ msgstr "協定不支援設定遠端服務路徑"
 msgid "invalid remote service path"
 msgstr "無效的遠端服務路徑"
 
-#: transport-helper.c transport.c
-msgid "operation not supported by protocol"
-msgstr "協定不支援該動作"
-
 #: transport-helper.c
 #, c-format
 msgid "can't connect to subservice %s"
@@ -26101,11 +26240,6 @@ msgstr "不能解析 transport.color.* 設定"
 msgid "support for protocol v2 not implemented yet"
 msgstr "協定 v2 的支援尚未實現"
 
-#: transport.c
-#, c-format
-msgid "unknown value for config '%s': %s"
-msgstr "設定 '%s' 的取值未知:%s"
-
 #: transport.c
 #, c-format
 msgid "transport '%s' not allowed"
@@ -26165,6 +26299,10 @@ msgstr "通訊協定不支援 bundle-uri 動作"
 msgid "could not retrieve server-advertised bundle-uri list"
 msgstr "無法取得伺服器公佈的 bundle-uri 清單"
 
+#: transport.c
+msgid "operation not supported by protocol"
+msgstr "協定不支援該動作"
+
 #: tree-walk.c
 msgid "too-short tree object"
 msgstr "太短的樹狀物件"
@@ -27193,6 +27331,11 @@ msgstr "另外,您的索引中包含未提交的變更。"
 msgid "cannot %s: Your index contains uncommitted changes."
 msgstr "不能%s:您的索引中包含未提交的變更。"
 
+#: xdiff-interface.c
+#, c-format
+msgid "unknown style '%s' given for '%s'"
+msgstr "給予「%2$s」的「%1$s」樣式未知"
+
 #: git-merge-octopus.sh git-merge-resolve.sh
 msgid ""
 "Error: Your local changes to the following files would be overwritten by "
@@ -27649,3 +27792,55 @@ msgstr "略過 %s 含備份後綴 '%s'。\n"
 #, perl-format
 msgid "Do you really want to send %s? [y|N]: "
 msgstr "您真的要傳送 %s?[y|N]: "
+
+#~ msgid "-x and -X cannot be used together"
+#~ msgstr "-x 和 -X 不能同時使用"
+
+#~ msgid ""
+#~ "--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-"
+#~ "exclude"
+#~ msgstr ""
+#~ "--bundle-uri 與 --depth、--shallow-since 和 --shallow-exclude 不相容"
+
+#~ msgid "--merge-base is incompatible with --stdin"
+#~ msgstr "--merge-base 與 --stdin 不相容"
+
+#~ msgid ""
+#~ "apply options are incompatible with rebase.autoSquash.  Consider adding --"
+#~ "no-autosquash"
+#~ msgstr "apply 選項與 rebase.autoSquash 不相容。請考慮加上 --no-autosquash"
+
+#~ msgid "--exclude-hidden cannot be used together with --branches"
+#~ msgstr "--exclude-hidden 無法與 --branches 同時使用"
+
+#~ msgid "--exclude-hidden cannot be used together with --tags"
+#~ msgstr "--exclude-hidden 無法與 --tags 同時使用"
+
+#~ msgid "--exclude-hidden cannot be used together with --remotes"
+#~ msgstr "--exclude-hidden 無法與 --remotes 同時使用"
+
+#, c-format
+#~ msgid "only one of '%s', '%s' or '%s' can be given"
+#~ msgstr "只能傳入 “%s”、“%s” 或 “%s”"
+
+#, c-format
+#~ msgid "'%s' and '%s' cannot be used together"
+#~ msgstr "無法同時使用 “%s” 和 “%s”"
+
+#, c-format
+#~ msgid "options '%s', and '%s' cannot be used together"
+#~ msgstr "無法同時使用 “%s” 和 “%s” 選項"
+
+#~ msgid "<commit-ish>"
+#~ msgstr "<提交指示元>"
+
+#, c-format
+#~ msgid "%s is incompatible with %s"
+#~ msgstr "%s 與 %s 不相容"
+
+#, c-format
+#~ msgid "could not remove reference %s"
+#~ msgstr "無法刪除引用 %s"
+
+#~ msgid "unhandled options"
+#~ msgstr "未處理選項"
index f29b06a5d059e23030333f26d5ba0667872251ab..3b85add243ba79a4ccc90c9faacbb9fee2742303 100644 (file)
@@ -17,6 +17,7 @@
 #include "pack-mtimes.h"
 #include "config.h"
 #include "run-command.h"
+#include "sequencer.h"
 
 struct connectivity_progress {
        struct progress *progress;
@@ -30,6 +31,52 @@ static void update_progress(struct connectivity_progress *cp)
                display_progress(cp->progress, cp->count);
 }
 
+static void add_one_file(const char *path, struct rev_info *revs)
+{
+       struct strbuf buf = STRBUF_INIT;
+       struct object_id oid;
+       struct object *object;
+
+       if (!read_oneliner(&buf, path, READ_ONELINER_SKIP_IF_EMPTY)) {
+               strbuf_release(&buf);
+               return;
+       }
+       strbuf_trim(&buf);
+       if (!get_oid_hex(buf.buf, &oid)) {
+               object = parse_object_or_die(&oid, buf.buf);
+               add_pending_object(revs, object, "");
+       }
+       strbuf_release(&buf);
+}
+
+/* Mark objects recorded in rebase state files as reachable. */
+static void add_rebase_files(struct rev_info *revs)
+{
+       struct strbuf buf = STRBUF_INIT;
+       size_t len;
+       const char *path[] = {
+               "rebase-apply/autostash",
+               "rebase-apply/orig-head",
+               "rebase-merge/autostash",
+               "rebase-merge/orig-head",
+       };
+       struct worktree **worktrees = get_worktrees();
+
+       for (struct worktree **wt = worktrees; *wt; wt++) {
+               strbuf_reset(&buf);
+               strbuf_addstr(&buf, get_worktree_git_dir(*wt));
+               strbuf_complete(&buf, '/');
+               len = buf.len;
+               for (size_t i = 0; i < ARRAY_SIZE(path); i++) {
+                       strbuf_setlen(&buf, len);
+                       strbuf_addstr(&buf, path[i]);
+                       add_one_file(buf.buf, revs);
+               }
+       }
+       strbuf_release(&buf);
+       free_worktrees(worktrees);
+}
+
 static int add_one_ref(const char *path, const struct object_id *oid,
                       int flag, void *cb_data)
 {
@@ -322,6 +369,9 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
        head_ref(add_one_ref, revs);
        other_head_refs(add_one_ref, revs);
 
+       /* rebase autostash and orig-head */
+       add_rebase_files(revs);
+
        /* Add all reflog info */
        if (mark_reflog)
                add_reflogs_to_pending(revs, 0);
index 9a1a7edc5a22cf0b0d91f7edd03225ea19607156..2a50a784f0ec6ae4da94fed41345e625c5bbce1c 100644 (file)
@@ -436,6 +436,14 @@ int match_stat_data_racy(const struct index_state *istate,
 
 void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, struct stat *st);
 
+/*
+ * Fill members of st by members of sd enough to convince match_stat()
+ * to consider that they match.  It should be usable as a replacement
+ * for lstat() for a tracked path that is known to be up-to-date via
+ * some out-of-line means (like fsmonitor).
+ */
+int fake_lstat(const struct cache_entry *ce, struct stat *st);
+
 #define REFRESH_REALLY                   (1 << 0) /* ignore_valid */
 #define REFRESH_UNMERGED                 (1 << 1) /* allow unmerged */
 #define REFRESH_QUIET                    (1 << 2) /* be quiet about it */
index 08970caff7cd08112db8838465e953d6c8380d1b..f546cf7875cbfefddbec2449e8303786e485a8dd 100644 (file)
@@ -195,6 +195,33 @@ void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, st
        }
 }
 
+static unsigned int st_mode_from_ce(const struct cache_entry *ce)
+{
+       extern int trust_executable_bit, has_symlinks;
+
+       switch (ce->ce_mode & S_IFMT) {
+       case S_IFLNK:
+               return has_symlinks ? S_IFLNK : (S_IFREG | 0644);
+       case S_IFREG:
+               return (ce->ce_mode & (trust_executable_bit ? 0755 : 0644)) | S_IFREG;
+       case S_IFGITLINK:
+               return S_IFDIR | 0755;
+       case S_IFDIR:
+               return ce->ce_mode;
+       default:
+               BUG("unsupported ce_mode: %o", ce->ce_mode);
+       }
+}
+
+int fake_lstat(const struct cache_entry *ce, struct stat *st)
+{
+       fake_lstat_data(&ce->ce_stat_data, st);
+       st->st_mode = st_mode_from_ce(ce);
+
+       /* always succeed as lstat() replacement */
+       return 0;
+}
+
 static int ce_compare_data(struct index_state *istate,
                           const struct cache_entry *ce,
                           struct stat *st)
index 0ac3fca67da00956896dffada6a2a37d4870800f..0ec29f7385480ad4ee71a6cc684307b2bf19c814 100644 (file)
@@ -1611,6 +1611,12 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
        if (formatp) {
                formatp++;
                parse_date_format(formatp, &date_mode);
+
+               /*
+                * If this is a sort field and a format was specified, we'll
+                * want to compare formatted date by string value.
+                */
+               v->atom->type = FIELD_STR;
        }
 
        if (!eoemail)
@@ -2505,17 +2511,12 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
                return 0;
 
        /*
-        * If it is a tag object, see if we use a value that derefs
-        * the object, and if we do grab the object it refers to.
+        * If it is a tag object, see if we use the peeled value. If we do,
+        * grab the peeled OID.
         */
-       oi_deref.oid = *get_tagged_oid((struct tag *)obj);
+       if (need_tagged && peel_iterated_oid(&obj->oid, &oi_deref.oid))
+               die("bad tag");
 
-       /*
-        * NEEDSWORK: This derefs tag only once, which
-        * is good to deal with chains of trust, but
-        * is not consistent with what deref_tag() does
-        * which peels the onion to the core.
-        */
        return get_object(ref, 1, &obj, &oi_deref, err);
 }
 
@@ -2627,6 +2628,12 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
                                       each_ref_fn cb,
                                       void *cb_data)
 {
+       if (filter->kind == FILTER_REFS_KIND_MASK) {
+               /* In this case, we want to print all refs including root refs. */
+               return refs_for_each_include_root_refs(get_main_ref_store(the_repository),
+                                                      cb, cb_data);
+       }
+
        if (!filter->match_as_path) {
                /*
                 * in this case, the patterns are applied after
@@ -2713,15 +2720,18 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
        return ref;
 }
 
+static void ref_array_append(struct ref_array *array, struct ref_array_item *ref)
+{
+       ALLOC_GROW(array->items, array->nr + 1, array->alloc);
+       array->items[array->nr++] = ref;
+}
+
 struct ref_array_item *ref_array_push(struct ref_array *array,
                                      const char *refname,
                                      const struct object_id *oid)
 {
        struct ref_array_item *ref = new_ref_array_item(refname, oid);
-
-       ALLOC_GROW(array->items, array->nr + 1, array->alloc);
-       array->items[array->nr++] = ref;
-
+       ref_array_append(array, ref);
        return ref;
 }
 
@@ -2746,6 +2756,9 @@ static int ref_kind_from_refname(const char *refname)
                        return ref_kind[i].kind;
        }
 
+       if (is_pseudoref(get_main_ref_store(the_repository), refname))
+               return FILTER_REFS_PSEUDOREFS;
+
        return FILTER_REFS_OTHERS;
 }
 
@@ -2758,48 +2771,45 @@ static int filter_ref_kind(struct ref_filter *filter, const char *refname)
        return ref_kind_from_refname(refname);
 }
 
-struct ref_filter_cbdata {
-       struct ref_array *array;
-       struct ref_filter *filter;
-       struct contains_cache contains_cache;
-       struct contains_cache no_contains_cache;
-};
-
-/*
- * A call-back given to for_each_ref().  Filter refs and keep them for
- * later object processing.
- */
-static int ref_filter_handler(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+static struct ref_array_item *apply_ref_filter(const char *refname, const struct object_id *oid,
+                           int flag, struct ref_filter *filter)
 {
-       struct ref_filter_cbdata *ref_cbdata = cb_data;
-       struct ref_filter *filter = ref_cbdata->filter;
        struct ref_array_item *ref;
        struct commit *commit = NULL;
        unsigned int kind;
 
        if (flag & REF_BAD_NAME) {
                warning(_("ignoring ref with broken name %s"), refname);
-               return 0;
+               return NULL;
        }
 
        if (flag & REF_ISBROKEN) {
                warning(_("ignoring broken ref %s"), refname);
-               return 0;
+               return NULL;
        }
 
        /* Obtain the current ref kind from filter_ref_kind() and ignore unwanted refs. */
        kind = filter_ref_kind(filter, refname);
-       if (!(kind & filter->kind))
-               return 0;
+
+       /*
+        * Generally HEAD refs are printed with special description denoting a rebase,
+        * detached state and so forth. This is useful when only printing the HEAD ref
+        * But when it is being printed along with other pseudorefs, it makes sense to
+        * keep the formatting consistent. So we mask the type to act like a pseudoref.
+        */
+       if (filter->kind == FILTER_REFS_KIND_MASK && kind == FILTER_REFS_DETACHED_HEAD)
+               kind = FILTER_REFS_PSEUDOREFS;
+       else if (!(kind & filter->kind))
+               return NULL;
 
        if (!filter_pattern_match(filter, refname))
-               return 0;
+               return NULL;
 
        if (filter_exclude_match(filter, refname))
-               return 0;
+               return NULL;
 
        if (filter->points_at.nr && !match_points_at(&filter->points_at, oid, refname))
-               return 0;
+               return NULL;
 
        /*
         * A merge filter is applied on refs pointing to commits. Hence
@@ -2810,15 +2820,15 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
            filter->with_commit || filter->no_commit || filter->verbose) {
                commit = lookup_commit_reference_gently(the_repository, oid, 1);
                if (!commit)
-                       return 0;
+                       return NULL;
                /* We perform the filtering for the '--contains' option... */
                if (filter->with_commit &&
-                   !commit_contains(filter, commit, filter->with_commit, &ref_cbdata->contains_cache))
-                       return 0;
+                   !commit_contains(filter, commit, filter->with_commit, &filter->internal.contains_cache))
+                       return NULL;
                /* ...or for the `--no-contains' option */
                if (filter->no_commit &&
-                   commit_contains(filter, commit, filter->no_commit, &ref_cbdata->no_contains_cache))
-                       return 0;
+                   commit_contains(filter, commit, filter->no_commit, &filter->internal.no_contains_cache))
+                       return NULL;
        }
 
        /*
@@ -2826,11 +2836,32 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
         * to do its job and the resulting list may yet to be pruned
         * by maxcount logic.
         */
-       ref = ref_array_push(ref_cbdata->array, refname, oid);
+       ref = new_ref_array_item(refname, oid);
        ref->commit = commit;
        ref->flag = flag;
        ref->kind = kind;
 
+       return ref;
+}
+
+struct ref_filter_cbdata {
+       struct ref_array *array;
+       struct ref_filter *filter;
+};
+
+/*
+ * A call-back given to for_each_ref().  Filter refs and keep them for
+ * later object processing.
+ */
+static int filter_one(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+{
+       struct ref_filter_cbdata *ref_cbdata = cb_data;
+       struct ref_array_item *ref;
+
+       ref = apply_ref_filter(refname, oid, flag, ref_cbdata->filter);
+       if (ref)
+               ref_array_append(ref_cbdata->array, ref);
+
        return 0;
 }
 
@@ -2848,6 +2879,49 @@ static void free_array_item(struct ref_array_item *item)
        free(item);
 }
 
+struct ref_filter_and_format_cbdata {
+       struct ref_filter *filter;
+       struct ref_format *format;
+
+       struct ref_filter_and_format_internal {
+               int count;
+       } internal;
+};
+
+static int filter_and_format_one(const char *refname, const struct object_id *oid, int flag, void *cb_data)
+{
+       struct ref_filter_and_format_cbdata *ref_cbdata = cb_data;
+       struct ref_array_item *ref;
+       struct strbuf output = STRBUF_INIT, err = STRBUF_INIT;
+
+       ref = apply_ref_filter(refname, oid, flag, ref_cbdata->filter);
+       if (!ref)
+               return 0;
+
+       if (format_ref_array_item(ref, ref_cbdata->format, &output, &err))
+               die("%s", err.buf);
+
+       if (output.len || !ref_cbdata->format->array_opts.omit_empty) {
+               fwrite(output.buf, 1, output.len, stdout);
+               putchar('\n');
+       }
+
+       strbuf_release(&output);
+       strbuf_release(&err);
+       free_array_item(ref);
+
+       /*
+        * Increment the running count of refs that match the filter. If
+        * max_count is set and we've reached the max, stop the ref
+        * iteration by returning a nonzero value.
+        */
+       if (ref_cbdata->format->array_opts.max_count &&
+           ++ref_cbdata->internal.count >= ref_cbdata->format->array_opts.max_count)
+               return 1;
+
+       return 0;
+}
+
 /* Free all memory allocated for ref_array */
 void ref_array_clear(struct ref_array *array)
 {
@@ -2966,28 +3040,14 @@ void filter_ahead_behind(struct repository *r,
        free(commits);
 }
 
-/*
- * API for filtering a set of refs. Based on the type of refs the user
- * has requested, we iterate through those refs and apply filters
- * as per the given ref_filter structure and finally store the
- * filtered refs in the ref_array structure.
- */
-int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type)
+static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref_fn fn, void *cb_data)
 {
-       struct ref_filter_cbdata ref_cbdata;
-       int save_commit_buffer_orig;
        int ret = 0;
 
-       ref_cbdata.array = array;
-       ref_cbdata.filter = filter;
-
        filter->kind = type & FILTER_REFS_KIND_MASK;
 
-       save_commit_buffer_orig = save_commit_buffer;
-       save_commit_buffer = 0;
-
-       init_contains_cache(&ref_cbdata.contains_cache);
-       init_contains_cache(&ref_cbdata.no_contains_cache);
+       init_contains_cache(&filter->internal.contains_cache);
+       init_contains_cache(&filter->internal.no_contains_cache);
 
        /*  Simple per-ref filtering */
        if (!filter->kind)
@@ -3000,19 +3060,48 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
                 * of filter_ref_kind().
                 */
                if (filter->kind == FILTER_REFS_BRANCHES)
-                       ret = for_each_fullref_in("refs/heads/", ref_filter_handler, &ref_cbdata);
+                       ret = for_each_fullref_in("refs/heads/", fn, cb_data);
                else if (filter->kind == FILTER_REFS_REMOTES)
-                       ret = for_each_fullref_in("refs/remotes/", ref_filter_handler, &ref_cbdata);
+                       ret = for_each_fullref_in("refs/remotes/", fn, cb_data);
                else if (filter->kind == FILTER_REFS_TAGS)
-                       ret = for_each_fullref_in("refs/tags/", ref_filter_handler, &ref_cbdata);
-               else if (filter->kind & FILTER_REFS_ALL)
-                       ret = for_each_fullref_in_pattern(filter, ref_filter_handler, &ref_cbdata);
-               if (!ret && (filter->kind & FILTER_REFS_DETACHED_HEAD))
-                       head_ref(ref_filter_handler, &ref_cbdata);
+                       ret = for_each_fullref_in("refs/tags/", fn, cb_data);
+               else if (filter->kind & FILTER_REFS_REGULAR)
+                       ret = for_each_fullref_in_pattern(filter, fn, cb_data);
+
+               /*
+                * When printing all ref types, HEAD is already included,
+                * so we don't want to print HEAD again.
+                */
+               if (!ret && (filter->kind != FILTER_REFS_KIND_MASK) &&
+                   (filter->kind & FILTER_REFS_DETACHED_HEAD))
+                       head_ref(fn, cb_data);
        }
 
-       clear_contains_cache(&ref_cbdata.contains_cache);
-       clear_contains_cache(&ref_cbdata.no_contains_cache);
+       clear_contains_cache(&filter->internal.contains_cache);
+       clear_contains_cache(&filter->internal.no_contains_cache);
+
+       return ret;
+}
+
+/*
+ * API for filtering a set of refs. Based on the type of refs the user
+ * has requested, we iterate through those refs and apply filters
+ * as per the given ref_filter structure and finally store the
+ * filtered refs in the ref_array structure.
+ */
+int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type)
+{
+       struct ref_filter_cbdata ref_cbdata;
+       int save_commit_buffer_orig;
+       int ret = 0;
+
+       ref_cbdata.array = array;
+       ref_cbdata.filter = filter;
+
+       save_commit_buffer_orig = save_commit_buffer;
+       save_commit_buffer = 0;
+
+       ret = do_filter_refs(filter, type, filter_one, &ref_cbdata);
 
        /*  Filters that need revision walking */
        reach_filter(array, &filter->reachable_from, INCLUDE_REACHED);
@@ -3022,6 +3111,51 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
        return ret;
 }
 
+static inline int can_do_iterative_format(struct ref_filter *filter,
+                                         struct ref_sorting *sorting,
+                                         struct ref_format *format)
+{
+       /*
+        * Filtering & formatting results within a single ref iteration
+        * callback is not compatible with options that require
+        * post-processing a filtered ref_array. These include:
+        * - filtering on reachability
+        * - sorting the filtered results
+        * - including ahead-behind information in the formatted output
+        */
+       return !(filter->reachable_from ||
+                filter->unreachable_from ||
+                sorting ||
+                format->bases.nr);
+}
+
+void filter_and_format_refs(struct ref_filter *filter, unsigned int type,
+                           struct ref_sorting *sorting,
+                           struct ref_format *format)
+{
+       if (can_do_iterative_format(filter, sorting, format)) {
+               int save_commit_buffer_orig;
+               struct ref_filter_and_format_cbdata ref_cbdata = {
+                       .filter = filter,
+                       .format = format,
+               };
+
+               save_commit_buffer_orig = save_commit_buffer;
+               save_commit_buffer = 0;
+
+               do_filter_refs(filter, type, filter_and_format_one, &ref_cbdata);
+
+               save_commit_buffer = save_commit_buffer_orig;
+       } else {
+               struct ref_array array = { 0 };
+               filter_refs(&array, filter, type);
+               filter_ahead_behind(the_repository, format, &array);
+               ref_array_sort(sorting, &array);
+               print_formatted_ref_array(&array, format);
+               ref_array_clear(&array);
+       }
+}
+
 static int compare_detached_head(struct ref_array_item *a, struct ref_array_item *b)
 {
        if (!(a->kind ^ b->kind))
@@ -3139,7 +3273,8 @@ void ref_sorting_set_sort_flags_all(struct ref_sorting *sorting,
 
 void ref_array_sort(struct ref_sorting *sorting, struct ref_array *array)
 {
-       QSORT_S(array->items, array->nr, compare_refs, sorting);
+       if (sorting)
+               QSORT_S(array->items, array->nr, compare_refs, sorting);
 }
 
 static void append_literal(const char *cp, const char *ep, struct ref_formatting_state *state)
@@ -3210,6 +3345,29 @@ int format_ref_array_item(struct ref_array_item *info,
        return 0;
 }
 
+void print_formatted_ref_array(struct ref_array *array, struct ref_format *format)
+{
+       int total;
+       struct strbuf output = STRBUF_INIT, err = STRBUF_INIT;
+
+       total = format->array_opts.max_count;
+       if (!total || array->nr < total)
+               total = array->nr;
+       for (int i = 0; i < total; i++) {
+               strbuf_reset(&err);
+               strbuf_reset(&output);
+               if (format_ref_array_item(array->items[i], format, &output, &err))
+                       die("%s", err.buf);
+               if (output.len || !format->array_opts.omit_empty) {
+                       fwrite(output.buf, 1, output.len, stdout);
+                       putchar('\n');
+               }
+       }
+
+       strbuf_release(&err);
+       strbuf_release(&output);
+}
+
 void pretty_print_ref(const char *name, const struct object_id *oid,
                      struct ref_format *format)
 {
@@ -3245,18 +3403,6 @@ static int parse_sorting_atom(const char *atom)
        return res;
 }
 
-/*  If no sorting option is given, use refname to sort as default */
-static struct ref_sorting *ref_default_sorting(void)
-{
-       static const char cstr_name[] = "refname";
-
-       struct ref_sorting *sorting = xcalloc(1, sizeof(*sorting));
-
-       sorting->next = NULL;
-       sorting->atom = parse_sorting_atom(cstr_name);
-       return sorting;
-}
-
 static void parse_ref_sorting(struct ref_sorting **sorting_tail, const char *arg)
 {
        struct ref_sorting *s;
@@ -3280,9 +3426,7 @@ struct ref_sorting *ref_sorting_options(struct string_list *options)
        struct string_list_item *item;
        struct ref_sorting *sorting = NULL, **tail = &sorting;
 
-       if (!options->nr) {
-               sorting = ref_default_sorting();
-       } else {
+       if (options->nr) {
                for_each_string_list_item(item, options)
                        parse_ref_sorting(tail, item->string);
        }
index 4ecb6ab1c6039ebca47ec6d7bfaee22a94d5e9f0..0ca28d2bba6f2aed4b8d084972739f3a88f44caa 100644 (file)
@@ -6,6 +6,7 @@
 #include "commit.h"
 #include "string-list.h"
 #include "strvec.h"
+#include "commit-reach.h"
 
 /* Quoting styles */
 #define QUOTE_NONE 0
 #define FILTER_REFS_BRANCHES       0x0004
 #define FILTER_REFS_REMOTES        0x0008
 #define FILTER_REFS_OTHERS         0x0010
-#define FILTER_REFS_ALL            (FILTER_REFS_TAGS | FILTER_REFS_BRANCHES | \
+#define FILTER_REFS_REGULAR        (FILTER_REFS_TAGS | FILTER_REFS_BRANCHES | \
                                    FILTER_REFS_REMOTES | FILTER_REFS_OTHERS)
 #define FILTER_REFS_DETACHED_HEAD  0x0020
-#define FILTER_REFS_KIND_MASK      (FILTER_REFS_ALL | FILTER_REFS_DETACHED_HEAD)
+#define FILTER_REFS_PSEUDOREFS     0x0040
+#define FILTER_REFS_ROOT_REFS      (FILTER_REFS_DETACHED_HEAD | FILTER_REFS_PSEUDOREFS)
+#define FILTER_REFS_KIND_MASK      (FILTER_REFS_REGULAR | FILTER_REFS_DETACHED_HEAD | \
+                                   FILTER_REFS_PSEUDOREFS)
 
 struct atom_value;
 struct ref_sorting;
@@ -74,6 +78,11 @@ struct ref_filter {
                lines;
        int abbrev,
                verbose;
+
+       struct {
+               struct contains_cache contains_cache;
+               struct contains_cache no_contains_cache;
+       } internal;
 };
 
 struct ref_format {
@@ -91,6 +100,11 @@ struct ref_format {
 
        /* List of bases for ahead-behind counts. */
        struct string_list bases;
+
+       struct {
+               int max_count;
+               int omit_empty;
+       } array_opts;
 };
 
 #define REF_FILTER_INIT { \
@@ -125,6 +139,14 @@ struct ref_format {
  * filtered refs in the ref_array structure.
  */
 int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int type);
+/*
+ * Filter refs using the given ref_filter and type, sort the contents
+ * according to the given ref_sorting, format the filtered refs with the
+ * given ref_format, and print them to stdout.
+ */
+void filter_and_format_refs(struct ref_filter *filter, unsigned int type,
+                           struct ref_sorting *sorting,
+                           struct ref_format *format);
 /*  Clear all memory allocated to ref_array */
 void ref_array_clear(struct ref_array *array);
 /*  Used to verify if the given format is correct and to parse out the used atoms */
@@ -149,6 +171,12 @@ char *get_head_description(void);
 /*  Set up translated strings in the output. */
 void setup_ref_filter_porcelain_msg(void);
 
+/*
+ * Print up to maxcount ref_array elements to stdout using the given
+ * ref_format.
+ */
+void print_formatted_ref_array(struct ref_array *array, struct ref_format *format);
+
 /*
  * Print a single ref, outside of any ref-filter. Note that the
  * name must be a fully qualified refname.
diff --git a/refs.c b/refs.c
index fcae5dddc6050627668048e966384b7f9fa70171..55d2e0b2cb9e959443e98eb329fdf97eff9073a9 100644 (file)
--- a/refs.c
+++ b/refs.c
 /*
  * List of all available backends
  */
-static struct ref_storage_be *refs_backends = &refs_be_files;
+static const struct ref_storage_be *refs_backends[] = {
+       [REF_STORAGE_FORMAT_FILES] = &refs_be_files,
+       [REF_STORAGE_FORMAT_REFTABLE] = &refs_be_reftable,
+};
 
-static struct ref_storage_be *find_ref_storage_backend(const char *name)
+static const struct ref_storage_be *find_ref_storage_backend(unsigned int ref_storage_format)
 {
-       struct ref_storage_be *be;
-       for (be = refs_backends; be; be = be->next)
-               if (!strcmp(be->name, name))
-                       return be;
+       if (ref_storage_format < ARRAY_SIZE(refs_backends))
+               return refs_backends[ref_storage_format];
        return NULL;
 }
 
+unsigned int ref_storage_format_by_name(const char *name)
+{
+       for (unsigned int i = 0; i < ARRAY_SIZE(refs_backends); i++)
+               if (refs_backends[i] && !strcmp(refs_backends[i]->name, name))
+                       return i;
+       return REF_STORAGE_FORMAT_UNKNOWN;
+}
+
+const char *ref_storage_format_to_name(unsigned int ref_storage_format)
+{
+       const struct ref_storage_be *be = find_ref_storage_backend(ref_storage_format);
+       if (!be)
+               return "unknown";
+       return be->name;
+}
+
 /*
  * How to handle various characters in refnames:
  * 0: An acceptable character for refs
@@ -843,6 +860,47 @@ static int is_pseudoref_syntax(const char *refname)
        return 1;
 }
 
+int is_pseudoref(struct ref_store *refs, const char *refname)
+{
+       static const char *const irregular_pseudorefs[] = {
+               "AUTO_MERGE",
+               "BISECT_EXPECTED_REV",
+               "NOTES_MERGE_PARTIAL",
+               "NOTES_MERGE_REF",
+               "MERGE_AUTOSTASH",
+       };
+       struct object_id oid;
+       size_t i;
+
+       if (!is_pseudoref_syntax(refname))
+               return 0;
+
+       if (ends_with(refname, "_HEAD")) {
+               refs_resolve_ref_unsafe(refs, refname,
+                                       RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
+                                       &oid, NULL);
+               return !is_null_oid(&oid);
+       }
+
+       for (i = 0; i < ARRAY_SIZE(irregular_pseudorefs); i++)
+               if (!strcmp(refname, irregular_pseudorefs[i])) {
+                       refs_resolve_ref_unsafe(refs, refname,
+                                               RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
+                                               &oid, NULL);
+                       return !is_null_oid(&oid);
+               }
+
+       return 0;
+}
+
+int is_headref(struct ref_store *refs, const char *refname)
+{
+       if (!strcmp(refname, "HEAD"))
+               return refs_ref_exists(refs, refname);
+
+       return 0;
+}
+
 static int is_current_worktree_ref(const char *ref) {
        return is_pseudoref_syntax(ref) || is_per_worktree_ref(ref);
 }
@@ -1022,55 +1080,40 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
                           const char *message, void *cb_data)
 {
        struct read_ref_at_cb *cb = cb_data;
-       int reached_count;
 
        cb->tz = tz;
        cb->date = timestamp;
 
-       /*
-        * It is not possible for cb->cnt == 0 on the first iteration because
-        * that special case is handled in read_ref_at().
-        */
-       if (cb->cnt > 0)
-               cb->cnt--;
-       reached_count = cb->cnt == 0 && !is_null_oid(ooid);
-       if (timestamp <= cb->at_time || reached_count) {
+       if (timestamp <= cb->at_time || cb->cnt == 0) {
                set_read_ref_cutoffs(cb, timestamp, tz, message);
                /*
                 * we have not yet updated cb->[n|o]oid so they still
                 * hold the values for the previous record.
                 */
-               if (!is_null_oid(&cb->ooid) && !oideq(&cb->ooid, noid))
-                       warning(_("log for ref %s has gap after %s"),
+               if (!is_null_oid(&cb->ooid)) {
+                       oidcpy(cb->oid, noid);
+                       if (!oideq(&cb->ooid, noid))
+                               warning(_("log for ref %s has gap after %s"),
                                        cb->refname, show_date(cb->date, cb->tz, DATE_MODE(RFC2822)));
-               if (reached_count)
-                       oidcpy(cb->oid, ooid);
-               else if (!is_null_oid(&cb->ooid) || cb->date == cb->at_time)
+               }
+               else if (cb->date == cb->at_time)
                        oidcpy(cb->oid, noid);
                else if (!oideq(noid, cb->oid))
                        warning(_("log for ref %s unexpectedly ended on %s"),
                                cb->refname, show_date(cb->date, cb->tz,
                                                       DATE_MODE(RFC2822)));
+               cb->reccnt++;
+               oidcpy(&cb->ooid, ooid);
+               oidcpy(&cb->noid, noid);
                cb->found_it = 1;
+               return 1;
        }
        cb->reccnt++;
        oidcpy(&cb->ooid, ooid);
        oidcpy(&cb->noid, noid);
-       return cb->found_it;
-}
-
-static int read_ref_at_ent_newest(struct object_id *ooid UNUSED,
-                                 struct object_id *noid,
-                                 const char *email UNUSED,
-                                 timestamp_t timestamp, int tz,
-                                 const char *message, void *cb_data)
-{
-       struct read_ref_at_cb *cb = cb_data;
-
-       set_read_ref_cutoffs(cb, timestamp, tz, message);
-       oidcpy(cb->oid, noid);
-       /* We just want the first entry */
-       return 1;
+       if (cb->cnt > 0)
+               cb->cnt--;
+       return 0;
 }
 
 static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid,
@@ -1082,7 +1125,7 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid
 
        set_read_ref_cutoffs(cb, timestamp, tz, message);
        oidcpy(cb->oid, ooid);
-       if (is_null_oid(cb->oid))
+       if (cb->at_time && is_null_oid(cb->oid))
                oidcpy(cb->oid, noid);
        /* We just want the first entry */
        return 1;
@@ -1105,14 +1148,24 @@ int read_ref_at(struct ref_store *refs, const char *refname,
        cb.cutoff_cnt = cutoff_cnt;
        cb.oid = oid;
 
-       if (cb.cnt == 0) {
-               refs_for_each_reflog_ent_reverse(refs, refname, read_ref_at_ent_newest, &cb);
-               return 0;
-       }
-
        refs_for_each_reflog_ent_reverse(refs, refname, read_ref_at_ent, &cb);
 
        if (!cb.reccnt) {
+               if (cnt == 0) {
+                       /*
+                        * The caller asked for ref@{0}, and we had no entries.
+                        * It's a bit subtle, but in practice all callers have
+                        * prepped the "oid" field with the current value of
+                        * the ref, which is the most reasonable fallback.
+                        *
+                        * We'll put dummy values into the out-parameters (so
+                        * they're not just uninitialized garbage), and the
+                        * caller can take our return value as a hint that
+                        * we did not find any such reflog.
+                        */
+                       set_read_ref_cutoffs(&cb, 0, 0, "empty reflog");
+                       return 1;
+               }
                if (flags & GET_OID_QUIETLY)
                        exit(128);
                else
@@ -1577,10 +1630,6 @@ struct ref_iterator *refs_ref_iterator_begin(
        if (trim)
                iter = prefix_ref_iterator_begin(iter, "", trim);
 
-       /* Sanity check for subclasses: */
-       if (!iter->ordered)
-               BUG("reference iterator is not ordered");
-
        return iter;
 }
 
@@ -1707,6 +1756,13 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
        return refs_for_each_rawref(get_main_ref_store(the_repository), fn, cb_data);
 }
 
+int refs_for_each_include_root_refs(struct ref_store *refs, each_ref_fn fn,
+                                   void *cb_data)
+{
+       return do_for_each_ref(refs, "", NULL, fn, 0,
+                              DO_FOR_EACH_INCLUDE_ROOT_REFS, cb_data);
+}
+
 static int qsort_strcmp(const void *va, const void *vb)
 {
        const char *a = *(const char **)va;
@@ -1806,8 +1862,10 @@ static int refs_read_special_head(struct ref_store *ref_store,
        int result = -1;
        strbuf_addf(&full_path, "%s/%s", ref_store->gitdir, refname);
 
-       if (strbuf_read_file(&content, full_path.buf, 0) < 0)
+       if (strbuf_read_file(&content, full_path.buf, 0) < 0) {
+               *failure_errno = errno;
                goto done;
+       }
 
        result = parse_loose_ref_contents(content.buf, oid, referent, type,
                                          failure_errno);
@@ -1818,15 +1876,45 @@ done:
        return result;
 }
 
+static int is_special_ref(const char *refname)
+{
+       /*
+        * Special references are refs that have different semantics compared
+        * to "normal" refs. These refs can thus not be stored in the ref
+        * backend, but must always be accessed via the filesystem. The
+        * following refs are special:
+        *
+        * - FETCH_HEAD may contain multiple object IDs, and each one of them
+        *   carries additional metadata like where it came from.
+        *
+        * - MERGE_HEAD may contain multiple object IDs when merging multiple
+        *   heads.
+        *
+        * Reading, writing or deleting references must consistently go either
+        * through the filesystem (special refs) or through the reference
+        * backend (normal ones).
+        */
+       static const char * const special_refs[] = {
+               "FETCH_HEAD",
+               "MERGE_HEAD",
+       };
+       size_t i;
+
+       for (i = 0; i < ARRAY_SIZE(special_refs); i++)
+               if (!strcmp(refname, special_refs[i]))
+                       return 1;
+
+       return 0;
+}
+
 int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
                      struct object_id *oid, struct strbuf *referent,
                      unsigned int *type, int *failure_errno)
 {
        assert(failure_errno);
-       if (!strcmp(refname, "FETCH_HEAD") || !strcmp(refname, "MERGE_HEAD")) {
+       if (is_special_ref(refname))
                return refs_read_special_head(ref_store, refname, oid, referent,
                                              type, failure_errno);
-       }
 
        return ref_store->be->read_raw_ref(ref_store, refname, oid, referent,
                                           type, failure_errno);
@@ -1928,11 +2016,9 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
 }
 
 /* backend functions */
-int refs_init_db(struct strbuf *err)
+int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err)
 {
-       struct ref_store *refs = get_main_ref_store(the_repository);
-
-       return refs->be->init_db(refs, err);
+       return refs->be->init_db(refs, flags, err);
 }
 
 const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
@@ -2029,12 +2115,12 @@ static struct ref_store *ref_store_init(struct repository *repo,
                                        const char *gitdir,
                                        unsigned int flags)
 {
-       const char *be_name = "files";
-       struct ref_storage_be *be = find_ref_storage_backend(be_name);
+       const struct ref_storage_be *be;
        struct ref_store *refs;
 
+       be = find_ref_storage_backend(repo->ref_storage_format);
        if (!be)
-               BUG("reference backend %s is unknown", be_name);
+               BUG("reference backend is unknown");
 
        refs = be->init(repo, gitdir, flags);
        return refs;
@@ -2469,18 +2555,33 @@ cleanup:
        return ret;
 }
 
-int refs_for_each_reflog(struct ref_store *refs, each_ref_fn fn, void *cb_data)
+struct do_for_each_reflog_help {
+       each_reflog_fn *fn;
+       void *cb_data;
+};
+
+static int do_for_each_reflog_helper(struct repository *r UNUSED,
+                                    const char *refname,
+                                    const struct object_id *oid UNUSED,
+                                    int flags,
+                                    void *cb_data)
+{
+       struct do_for_each_reflog_help *hp = cb_data;
+       return hp->fn(refname, hp->cb_data);
+}
+
+int refs_for_each_reflog(struct ref_store *refs, each_reflog_fn fn, void *cb_data)
 {
        struct ref_iterator *iter;
-       struct do_for_each_ref_help hp = { fn, cb_data };
+       struct do_for_each_reflog_help hp = { fn, cb_data };
 
        iter = refs->be->reflog_iterator_begin(refs);
 
        return do_for_each_repo_ref_iterator(the_repository, iter,
-                                            do_for_each_ref_helper, &hp);
+                                            do_for_each_reflog_helper, &hp);
 }
 
-int for_each_reflog(each_ref_fn fn, void *cb_data)
+int for_each_reflog(each_reflog_fn fn, void *cb_data)
 {
        return refs_for_each_reflog(get_main_ref_store(the_repository), fn, cb_data);
 }
@@ -2599,13 +2700,55 @@ void ref_transaction_for_each_queued_update(struct ref_transaction *transaction,
 int refs_delete_refs(struct ref_store *refs, const char *logmsg,
                     struct string_list *refnames, unsigned int flags)
 {
+       struct ref_transaction *transaction;
+       struct strbuf err = STRBUF_INIT;
+       struct string_list_item *item;
+       int ret = 0, failures = 0;
        char *msg;
-       int retval;
+
+       if (!refnames->nr)
+               return 0;
 
        msg = normalize_reflog_message(logmsg);
-       retval = refs->be->delete_refs(refs, msg, refnames, flags);
+
+       /*
+        * Since we don't check the references' old_oids, the
+        * individual updates can't fail, so we can pack all of the
+        * updates into a single transaction.
+        */
+       transaction = ref_store_transaction_begin(refs, &err);
+       if (!transaction) {
+               ret = error("%s", err.buf);
+               goto out;
+       }
+
+       for_each_string_list_item(item, refnames) {
+               ret = ref_transaction_delete(transaction, item->string,
+                                            NULL, flags, msg, &err);
+               if (ret) {
+                       warning(_("could not delete reference %s: %s"),
+                               item->string, err.buf);
+                       strbuf_reset(&err);
+                       failures = 1;
+               }
+       }
+
+       ret = ref_transaction_commit(transaction, &err);
+       if (ret) {
+               if (refnames->nr == 1)
+                       error(_("could not delete reference %s: %s"),
+                             refnames->items[0].string, err.buf);
+               else
+                       error(_("could not delete references: %s"), err.buf);
+       }
+
+out:
+       if (!ret && failures)
+               ret = -1;
+       ref_transaction_free(transaction);
+       strbuf_release(&err);
        free(msg);
-       return retval;
+       return ret;
 }
 
 int delete_refs(const char *msg, struct string_list *refnames,
diff --git a/refs.h b/refs.h
index ff113bb12a2512c8f2caf9f0bd8e1e471490a5c0..298caf6c6184cc3a23acf78d1a0e3dc8c7d8614c 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -11,6 +11,9 @@ struct string_list;
 struct string_list_item;
 struct worktree;
 
+unsigned int ref_storage_format_by_name(const char *name);
+const char *ref_storage_format_to_name(unsigned int ref_storage_format);
+
 /*
  * Resolve a reference, recursively following symbolic refererences.
  *
@@ -123,7 +126,9 @@ int should_autocreate_reflog(const char *refname);
 
 int is_branch(const char *refname);
 
-int refs_init_db(struct strbuf *err);
+#define REFS_INIT_DB_IS_WORKTREE (1 << 0)
+
+int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err);
 
 /*
  * Return the peeled value of the oid currently being iterated via
@@ -393,6 +398,12 @@ int for_each_namespaced_ref(const char **exclude_patterns,
 int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data);
 int for_each_rawref(each_ref_fn fn, void *cb_data);
 
+/*
+ * Iterates over all refs including root refs, i.e. pseudorefs and HEAD.
+ */
+int refs_for_each_include_root_refs(struct ref_store *refs, each_ref_fn fn,
+                                   void *cb_data);
+
 /*
  * Normalizes partial refs to their fully qualified form.
  * Will prepend <prefix> to the <pattern> if it doesn't start with 'refs/'.
@@ -435,7 +446,20 @@ int refs_create_reflog(struct ref_store *refs, const char *refname,
                       struct strbuf *err);
 int safe_create_reflog(const char *refname, struct strbuf *err);
 
-/** Reads log for the value of ref during at_time. **/
+/**
+ * Reads log for the value of ref during at_time (in which case "cnt" should be
+ * negative) or the reflog "cnt" entries from the top (in which case "at_time"
+ * should be 0).
+ *
+ * If we found the reflog entry in question, returns 0 (and details of the
+ * entry can be found in the out-parameters).
+ *
+ * If we ran out of reflog entries, the out-parameters are filled with the
+ * details of the oldest entry we did find, and the function returns 1. Note
+ * that there is one important special case here! If the reflog was empty
+ * and the caller asked for the 0-th cnt, we will return "1" but leave the
+ * "oid" field untouched.
+ **/
 int read_ref_at(struct ref_store *refs,
                const char *refname, unsigned int flags,
                timestamp_t at_time, int cnt,
@@ -529,12 +553,19 @@ int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_dat
 /* youngest entry first */
 int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void *cb_data);
 
+/*
+ * The signature for the callback function for the {refs_,}for_each_reflog()
+ * functions below. The memory pointed to by the refname argument is only
+ * guaranteed to be valid for the duration of a single callback invocation.
+ */
+typedef int each_reflog_fn(const char *refname, void *cb_data);
+
 /*
  * Calls the specified function for each reflog file until it returns nonzero,
  * and returns the value. Reflog file order is unspecified.
  */
-int refs_for_each_reflog(struct ref_store *refs, each_ref_fn fn, void *cb_data);
-int for_each_reflog(each_ref_fn fn, void *cb_data);
+int refs_for_each_reflog(struct ref_store *refs, each_reflog_fn fn, void *cb_data);
+int for_each_reflog(each_reflog_fn fn, void *cb_data);
 
 #define REFNAME_ALLOW_ONELEVEL 1
 #define REFNAME_REFSPEC_PATTERN 2
@@ -1018,4 +1049,7 @@ extern struct ref_namespace_info ref_namespace[NAMESPACE__COUNT];
  */
 void update_ref_namespace(enum ref_namespace namespace, char *ref);
 
+int is_pseudoref(struct ref_store *refs, const char *refname);
+int is_headref(struct ref_store *refs, const char *refname);
+
 #endif /* REFS_H */
index b7ffc4ce67e333321036592b7e53efa30f8871d8..c7531b17f096c329353caf1fd456c726cded5ab8 100644 (file)
@@ -33,10 +33,10 @@ struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_stor
        return (struct ref_store *)res;
 }
 
-static int debug_init_db(struct ref_store *refs, struct strbuf *err)
+static int debug_init_db(struct ref_store *refs, int flags, struct strbuf *err)
 {
        struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
-       int res = drefs->refs->be->init_db(drefs->refs, err);
+       int res = drefs->refs->be->init_db(drefs->refs, flags, err);
        trace_printf_key(&trace_refs, "init_db: %d\n", res);
        return res;
 }
@@ -143,20 +143,6 @@ static int debug_create_symref(struct ref_store *ref_store,
        return res;
 }
 
-static int debug_delete_refs(struct ref_store *ref_store, const char *msg,
-                            struct string_list *refnames, unsigned int flags)
-{
-       struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
-       int res =
-               drefs->refs->be->delete_refs(drefs->refs, msg, refnames, flags);
-       int i;
-       trace_printf_key(&trace_refs, "delete_refs {\n");
-       for (i = 0; i < refnames->nr; i++)
-               trace_printf_key(&trace_refs, "%s\n", refnames->items[i].string);
-       trace_printf_key(&trace_refs, "}: %d\n", res);
-       return res;
-}
-
 static int debug_rename_ref(struct ref_store *ref_store, const char *oldref,
                            const char *newref, const char *logmsg)
 {
@@ -195,7 +181,6 @@ static int debug_ref_iterator_advance(struct ref_iterator *ref_iterator)
                trace_printf_key(&trace_refs, "iterator_advance: %s (0)\n",
                        diter->iter->refname);
 
-       diter->base.ordered = diter->iter->ordered;
        diter->base.refname = diter->iter->refname;
        diter->base.oid = diter->iter->oid;
        diter->base.flags = diter->iter->flags;
@@ -236,7 +221,7 @@ debug_ref_iterator_begin(struct ref_store *ref_store, const char *prefix,
                drefs->refs->be->iterator_begin(drefs->refs, prefix,
                                                exclude_patterns, flags);
        struct debug_ref_iterator *diter = xcalloc(1, sizeof(*diter));
-       base_ref_iterator_init(&diter->base, &debug_ref_iterator_vtable, 1);
+       base_ref_iterator_init(&diter->base, &debug_ref_iterator_vtable);
        diter->iter = res;
        trace_printf_key(&trace_refs, "ref_iterator_begin: \"%s\" (0x%x)\n",
                         prefix, flags);
@@ -440,7 +425,6 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
 }
 
 struct ref_storage_be refs_be_debug = {
-       .next = NULL,
        .name = "debug",
        .init = NULL,
        .init_db = debug_init_db,
@@ -458,7 +442,6 @@ struct ref_storage_be refs_be_debug = {
 
        .pack_refs = debug_pack_refs,
        .create_symref = debug_create_symref,
-       .delete_refs = debug_delete_refs,
        .rename_ref = debug_rename_ref,
        .copy_ref = debug_copy_ref,
 
index 922e65e0d9c7228ba584899229c1cced1f69766f..a098d14ea00ed6db449e5d3cc8dff28594228977 100644 (file)
@@ -229,6 +229,38 @@ static void add_per_worktree_entries_to_dir(struct ref_dir *dir, const char *dir
        }
 }
 
+static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs,
+                                           const char *refname,
+                                           struct ref_dir *dir)
+{
+       struct object_id oid;
+       int flag;
+
+       if (!refs_resolve_ref_unsafe(&refs->base, refname, RESOLVE_REF_READING,
+                                    &oid, &flag)) {
+               oidclr(&oid);
+               flag |= REF_ISBROKEN;
+       } else if (is_null_oid(&oid)) {
+               /*
+                * It is so astronomically unlikely
+                * that null_oid is the OID of an
+                * actual object that we consider its
+                * appearance in a loose reference
+                * file to be repo corruption
+                * (probably due to a software bug).
+                */
+               flag |= REF_ISBROKEN;
+       }
+
+       if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
+               if (!refname_is_safe(refname))
+                       die("loose refname is dangerous: %s", refname);
+               oidclr(&oid);
+               flag |= REF_BAD_NAME | REF_ISBROKEN;
+       }
+       add_entry_to_dir(dir, create_ref_entry(refname, &oid, flag));
+}
+
 /*
  * Read the loose references from the namespace dirname into dir
  * (without recursing).  dirname must end with '/'.  dir must be the
@@ -257,8 +289,6 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
        strbuf_add(&refname, dirname, dirnamelen);
 
        while ((de = readdir(d)) != NULL) {
-               struct object_id oid;
-               int flag;
                unsigned char dtype;
 
                if (de->d_name[0] == '.')
@@ -274,33 +304,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
                                         create_dir_entry(dir->cache, refname.buf,
                                                          refname.len));
                } else if (dtype == DT_REG) {
-                       if (!refs_resolve_ref_unsafe(&refs->base,
-                                                    refname.buf,
-                                                    RESOLVE_REF_READING,
-                                                    &oid, &flag)) {
-                               oidclr(&oid);
-                               flag |= REF_ISBROKEN;
-                       } else if (is_null_oid(&oid)) {
-                               /*
-                                * It is so astronomically unlikely
-                                * that null_oid is the OID of an
-                                * actual object that we consider its
-                                * appearance in a loose reference
-                                * file to be repo corruption
-                                * (probably due to a software bug).
-                                */
-                               flag |= REF_ISBROKEN;
-                       }
-
-                       if (check_refname_format(refname.buf,
-                                                REFNAME_ALLOW_ONELEVEL)) {
-                               if (!refname_is_safe(refname.buf))
-                                       die("loose refname is dangerous: %s", refname.buf);
-                               oidclr(&oid);
-                               flag |= REF_BAD_NAME | REF_ISBROKEN;
-                       }
-                       add_entry_to_dir(dir,
-                                        create_ref_entry(refname.buf, &oid, flag));
+                       loose_fill_ref_dir_regular_file(refs, refname.buf, dir);
                }
                strbuf_setlen(&refname, dirnamelen);
        }
@@ -311,9 +315,59 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
        add_per_worktree_entries_to_dir(dir, dirname);
 }
 
-static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs)
+/*
+ * Add pseudorefs to the ref dir by parsing the directory for any files
+ * which follow the pseudoref syntax.
+ */
+static void add_pseudoref_and_head_entries(struct ref_store *ref_store,
+                                        struct ref_dir *dir,
+                                        const char *dirname)
+{
+       struct files_ref_store *refs =
+               files_downcast(ref_store, REF_STORE_READ, "fill_ref_dir");
+       struct strbuf path = STRBUF_INIT, refname = STRBUF_INIT;
+       struct dirent *de;
+       size_t dirnamelen;
+       DIR *d;
+
+       files_ref_path(refs, &path, dirname);
+
+       d = opendir(path.buf);
+       if (!d) {
+               strbuf_release(&path);
+               return;
+       }
+
+       strbuf_addstr(&refname, dirname);
+       dirnamelen = refname.len;
+
+       while ((de = readdir(d)) != NULL) {
+               unsigned char dtype;
+
+               if (de->d_name[0] == '.')
+                       continue;
+               if (ends_with(de->d_name, ".lock"))
+                       continue;
+               strbuf_addstr(&refname, de->d_name);
+
+               dtype = get_dtype(de, &path, 1);
+               if (dtype == DT_REG && (is_pseudoref(ref_store, de->d_name) ||
+                                                               is_headref(ref_store, de->d_name)))
+                       loose_fill_ref_dir_regular_file(refs, refname.buf, dir);
+
+               strbuf_setlen(&refname, dirnamelen);
+       }
+       strbuf_release(&refname);
+       strbuf_release(&path);
+       closedir(d);
+}
+
+static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs,
+                                            unsigned int flags)
 {
        if (!refs->loose) {
+               struct ref_dir *dir;
+
                /*
                 * Mark the top-level directory complete because we
                 * are about to read the only subdirectory that can
@@ -324,12 +378,17 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs)
                /* We're going to fill the top level ourselves: */
                refs->loose->root->flag &= ~REF_INCOMPLETE;
 
+               dir = get_ref_dir(refs->loose->root);
+
+               if (flags & DO_FOR_EACH_INCLUDE_ROOT_REFS)
+                       add_pseudoref_and_head_entries(dir->cache->ref_store, dir,
+                                                      refs->loose->root->name);
+
                /*
                 * Add an incomplete entry for "refs/" (to be filled
                 * lazily):
                 */
-               add_entry_to_dir(get_ref_dir(refs->loose->root),
-                                create_dir_entry(refs->loose, "refs/", 5));
+               add_entry_to_dir(dir, create_dir_entry(refs->loose, "refs/", 5));
        }
        return refs->loose;
 }
@@ -857,7 +916,7 @@ static struct ref_iterator *files_ref_iterator_begin(
         * disk, and re-reads it if not.
         */
 
-       loose_iter = cache_ref_iterator_begin(get_loose_ref_cache(refs),
+       loose_iter = cache_ref_iterator_begin(get_loose_ref_cache(refs, flags),
                                              prefix, ref_store->repo, 1);
 
        /*
@@ -879,8 +938,7 @@ static struct ref_iterator *files_ref_iterator_begin(
 
        CALLOC_ARRAY(iter, 1);
        ref_iterator = &iter->base;
-       base_ref_iterator_init(ref_iterator, &files_ref_iterator_vtable,
-                              overlay_iter->ordered);
+       base_ref_iterator_init(ref_iterator, &files_ref_iterator_vtable);
        iter->iter0 = overlay_iter;
        iter->repo = ref_store->repo;
        iter->flags = flags;
@@ -1218,7 +1276,7 @@ static int files_pack_refs(struct ref_store *ref_store,
 
        packed_refs_lock(refs->packed_ref_store, LOCK_DIE_ON_ERROR, &err);
 
-       iter = cache_ref_iterator_begin(get_loose_ref_cache(refs), NULL,
+       iter = cache_ref_iterator_begin(get_loose_ref_cache(refs, 0), NULL,
                                        the_repository, 0);
        while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
                /*
@@ -1263,54 +1321,6 @@ static int files_pack_refs(struct ref_store *ref_store,
        return 0;
 }
 
-static int files_delete_refs(struct ref_store *ref_store, const char *msg,
-                            struct string_list *refnames, unsigned int flags)
-{
-       struct files_ref_store *refs =
-               files_downcast(ref_store, REF_STORE_WRITE, "delete_refs");
-       struct strbuf err = STRBUF_INIT;
-       int i, result = 0;
-
-       if (!refnames->nr)
-               return 0;
-
-       if (packed_refs_lock(refs->packed_ref_store, 0, &err))
-               goto error;
-
-       if (refs_delete_refs(refs->packed_ref_store, msg, refnames, flags)) {
-               packed_refs_unlock(refs->packed_ref_store);
-               goto error;
-       }
-
-       packed_refs_unlock(refs->packed_ref_store);
-
-       for (i = 0; i < refnames->nr; i++) {
-               const char *refname = refnames->items[i].string;
-
-               if (refs_delete_ref(&refs->base, msg, refname, NULL, flags))
-                       result |= error(_("could not remove reference %s"), refname);
-       }
-
-       strbuf_release(&err);
-       return result;
-
-error:
-       /*
-        * If we failed to rewrite the packed-refs file, then it is
-        * unsafe to try to remove loose refs, because doing so might
-        * expose an obsolete packed value for a reference that might
-        * even point at an object that has been garbage collected.
-        */
-       if (refnames->nr == 1)
-               error(_("could not delete reference %s: %s"),
-                     refnames->items[0].string, err.buf);
-       else
-               error(_("could not delete references: %s"), err.buf);
-
-       strbuf_release(&err);
-       return -1;
-}
-
 /*
  * People using contrib's git-new-workdir have .git/logs/refs ->
  * /some/other/path/.git/logs/refs, and that may live on another device.
@@ -2164,10 +2174,8 @@ static int files_for_each_reflog_ent(struct ref_store *ref_store,
 
 struct files_reflog_iterator {
        struct ref_iterator base;
-
        struct ref_store *ref_store;
        struct dir_iterator *dir_iterator;
-       struct object_id oid;
 };
 
 static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
@@ -2178,25 +2186,13 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
        int ok;
 
        while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
-               int flags;
-
                if (!S_ISREG(diter->st.st_mode))
                        continue;
-               if (diter->basename[0] == '.')
-                       continue;
-               if (ends_with(diter->basename, ".lock"))
+               if (check_refname_format(diter->basename,
+                                        REFNAME_ALLOW_ONELEVEL))
                        continue;
 
-               if (!refs_resolve_ref_unsafe(iter->ref_store,
-                                            diter->relative_path, 0,
-                                            &iter->oid, &flags)) {
-                       error("bad ref for %s", diter->path.buf);
-                       continue;
-               }
-
                iter->base.refname = diter->relative_path;
-               iter->base.oid = &iter->oid;
-               iter->base.flags = flags;
                return ITER_OK;
        }
 
@@ -2241,7 +2237,7 @@ static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
 
        strbuf_addf(&sb, "%s/logs", gitdir);
 
-       diter = dir_iterator_begin(sb.buf, 0);
+       diter = dir_iterator_begin(sb.buf, DIR_ITERATOR_SORTED);
        if (!diter) {
                strbuf_release(&sb);
                return empty_ref_iterator_begin();
@@ -2250,7 +2246,7 @@ static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
        CALLOC_ARRAY(iter, 1);
        ref_iterator = &iter->base;
 
-       base_ref_iterator_init(ref_iterator, &files_reflog_iterator_vtable, 0);
+       base_ref_iterator_init(ref_iterator, &files_reflog_iterator_vtable);
        iter->dir_iterator = diter;
        iter->ref_store = ref_store;
        strbuf_release(&sb);
@@ -2258,32 +2254,6 @@ static struct ref_iterator *reflog_iterator_begin(struct ref_store *ref_store,
        return ref_iterator;
 }
 
-static enum iterator_selection reflog_iterator_select(
-       struct ref_iterator *iter_worktree,
-       struct ref_iterator *iter_common,
-       void *cb_data UNUSED)
-{
-       if (iter_worktree) {
-               /*
-                * We're a bit loose here. We probably should ignore
-                * common refs if they are accidentally added as
-                * per-worktree refs.
-                */
-               return ITER_SELECT_0;
-       } else if (iter_common) {
-               if (parse_worktree_ref(iter_common->refname, NULL, NULL,
-                                      NULL) == REF_WORKTREE_SHARED)
-                       return ITER_SELECT_1;
-
-               /*
-                * The main ref store may contain main worktree's
-                * per-worktree refs, which should be ignored
-                */
-               return ITER_SKIP_1;
-       } else
-               return ITER_DONE;
-}
-
 static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_store)
 {
        struct files_ref_store *refs =
@@ -2294,9 +2264,9 @@ static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_st
                return reflog_iterator_begin(ref_store, refs->gitcommondir);
        } else {
                return merge_ref_iterator_begin(
-                       0, reflog_iterator_begin(ref_store, refs->base.gitdir),
+                       reflog_iterator_begin(ref_store, refs->base.gitdir),
                        reflog_iterator_begin(ref_store, refs->gitcommondir),
-                       reflog_iterator_select, refs);
+                       ref_iterator_select, refs);
        }
 }
 
@@ -3266,28 +3236,52 @@ static int files_reflog_expire(struct ref_store *ref_store,
        return -1;
 }
 
-static int files_init_db(struct ref_store *ref_store, struct strbuf *err UNUSED)
+static int files_init_db(struct ref_store *ref_store,
+                        int flags,
+                        struct strbuf *err UNUSED)
 {
        struct files_ref_store *refs =
                files_downcast(ref_store, REF_STORE_WRITE, "init_db");
        struct strbuf sb = STRBUF_INIT;
 
        /*
-        * Create .git/refs/{heads,tags}
+        * We need to create a "refs" dir in any case so that older versions of
+        * Git can tell that this is a repository. This serves two main purposes:
+        *
+        * - Clients will know to stop walking the parent-directory chain when
+        *   detecting the Git repository. Otherwise they may end up detecting
+        *   a Git repository in a parent directory instead.
+        *
+        * - Instead of failing to detect a repository with unknown reference
+        *   format altogether, old clients will print an error saying that
+        *   they do not understand the reference format extension.
         */
-       files_ref_path(refs, &sb, "refs/heads");
+       strbuf_addf(&sb, "%s/refs", ref_store->gitdir);
        safe_create_dir(sb.buf, 1);
+       adjust_shared_perm(sb.buf);
 
-       strbuf_reset(&sb);
-       files_ref_path(refs, &sb, "refs/tags");
-       safe_create_dir(sb.buf, 1);
+       /*
+        * There is no need to create directories for common refs when creating
+        * a worktree ref store.
+        */
+       if (!(flags & REFS_INIT_DB_IS_WORKTREE)) {
+               /*
+                * Create .git/refs/{heads,tags}
+                */
+               strbuf_reset(&sb);
+               files_ref_path(refs, &sb, "refs/heads");
+               safe_create_dir(sb.buf, 1);
+
+               strbuf_reset(&sb);
+               files_ref_path(refs, &sb, "refs/tags");
+               safe_create_dir(sb.buf, 1);
+       }
 
        strbuf_release(&sb);
        return 0;
 }
 
 struct ref_storage_be refs_be_files = {
-       .next = NULL,
        .name = "files",
        .init = files_ref_store_create,
        .init_db = files_init_db,
@@ -3298,7 +3292,6 @@ struct ref_storage_be refs_be_files = {
 
        .pack_refs = files_pack_refs,
        .create_symref = files_create_symref,
-       .delete_refs = files_delete_refs,
        .rename_ref = files_rename_ref,
        .copy_ref = files_copy_ref,
 
index 6b680f610efbee4e144cfa41763f45834b39d210..9db8b056d56d190fe9ea2087bc327f0154b6ecd2 100644 (file)
@@ -25,11 +25,9 @@ int ref_iterator_abort(struct ref_iterator *ref_iterator)
 }
 
 void base_ref_iterator_init(struct ref_iterator *iter,
-                           struct ref_iterator_vtable *vtable,
-                           int ordered)
+                           struct ref_iterator_vtable *vtable)
 {
        iter->vtable = vtable;
-       iter->ordered = !!ordered;
        iter->refname = NULL;
        iter->oid = NULL;
        iter->flags = 0;
@@ -74,7 +72,7 @@ struct ref_iterator *empty_ref_iterator_begin(void)
        struct empty_ref_iterator *iter = xcalloc(1, sizeof(*iter));
        struct ref_iterator *ref_iterator = &iter->base;
 
-       base_ref_iterator_init(ref_iterator, &empty_ref_iterator_vtable, 1);
+       base_ref_iterator_init(ref_iterator, &empty_ref_iterator_vtable);
        return ref_iterator;
 }
 
@@ -98,6 +96,49 @@ struct merge_ref_iterator {
        struct ref_iterator **current;
 };
 
+enum iterator_selection ref_iterator_select(struct ref_iterator *iter_worktree,
+                                           struct ref_iterator *iter_common,
+                                           void *cb_data UNUSED)
+{
+       if (iter_worktree && !iter_common) {
+               /*
+                * Return the worktree ref if there are no more common refs.
+                */
+               return ITER_SELECT_0;
+       } else if (iter_common) {
+               /*
+                * In case we have pending worktree and common refs we need to
+                * yield them based on their lexicographical order. Worktree
+                * refs that have the same name as common refs shadow the
+                * latter.
+                */
+               if (iter_worktree) {
+                       int cmp = strcmp(iter_worktree->refname,
+                                        iter_common->refname);
+                       if (cmp < 0)
+                               return ITER_SELECT_0;
+                       else if (!cmp)
+                               return ITER_SELECT_0_SKIP_1;
+               }
+
+                /*
+                 * We now know that the lexicographically-next ref is a common
+                 * ref. When the common ref is a shared one we return it.
+                 */
+               if (parse_worktree_ref(iter_common->refname, NULL, NULL,
+                                      NULL) == REF_WORKTREE_SHARED)
+                       return ITER_SELECT_1;
+
+               /*
+                * Otherwise, if the common ref is a per-worktree ref we skip
+                * it because it would belong to the main worktree, not ours.
+                */
+               return ITER_SKIP_1;
+       } else {
+               return ITER_DONE;
+       }
+}
+
 static int merge_ref_iterator_advance(struct ref_iterator *ref_iterator)
 {
        struct merge_ref_iterator *iter =
@@ -207,7 +248,6 @@ static struct ref_iterator_vtable merge_ref_iterator_vtable = {
 };
 
 struct ref_iterator *merge_ref_iterator_begin(
-               int ordered,
                struct ref_iterator *iter0, struct ref_iterator *iter1,
                ref_iterator_select_fn *select, void *cb_data)
 {
@@ -222,7 +262,7 @@ struct ref_iterator *merge_ref_iterator_begin(
         * references through only if they exist in both iterators.
         */
 
-       base_ref_iterator_init(ref_iterator, &merge_ref_iterator_vtable, ordered);
+       base_ref_iterator_init(ref_iterator, &merge_ref_iterator_vtable);
        iter->iter0 = iter0;
        iter->iter1 = iter1;
        iter->select = select;
@@ -271,12 +311,9 @@ struct ref_iterator *overlay_ref_iterator_begin(
        } else if (is_empty_ref_iterator(back)) {
                ref_iterator_abort(back);
                return front;
-       } else if (!front->ordered || !back->ordered) {
-               BUG("overlay_ref_iterator requires ordered inputs");
        }
 
-       return merge_ref_iterator_begin(1, front, back,
-                                       overlay_iterator_select, NULL);
+       return merge_ref_iterator_begin(front, back, overlay_iterator_select, NULL);
 }
 
 struct prefix_ref_iterator {
@@ -315,16 +352,12 @@ static int prefix_ref_iterator_advance(struct ref_iterator *ref_iterator)
 
                if (cmp > 0) {
                        /*
-                        * If the source iterator is ordered, then we
+                        * As the source iterator is ordered, we
                         * can stop the iteration as soon as we see a
                         * refname that comes after the prefix:
                         */
-                       if (iter->iter0->ordered) {
-                               ok = ref_iterator_abort(iter->iter0);
-                               break;
-                       } else {
-                               continue;
-                       }
+                       ok = ref_iterator_abort(iter->iter0);
+                       break;
                }
 
                if (iter->trim) {
@@ -396,7 +429,7 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
        CALLOC_ARRAY(iter, 1);
        ref_iterator = &iter->base;
 
-       base_ref_iterator_init(ref_iterator, &prefix_ref_iterator_vtable, iter0->ordered);
+       base_ref_iterator_init(ref_iterator, &prefix_ref_iterator_vtable);
 
        iter->iter0 = iter0;
        iter->prefix = xstrdup(prefix);
index 5963e67c14c6c4b7dff3986764666d2dafabf3e4..4e826c05ff2b34986a5844cd40734b10b0298204 100644 (file)
@@ -1111,7 +1111,7 @@ static struct ref_iterator *packed_ref_iterator_begin(
 
        CALLOC_ARRAY(iter, 1);
        ref_iterator = &iter->base;
-       base_ref_iterator_init(ref_iterator, &packed_ref_iterator_vtable, 1);
+       base_ref_iterator_init(ref_iterator, &packed_ref_iterator_vtable);
 
        if (exclude_patterns)
                populate_excluded_jump_list(iter, snapshot, exclude_patterns);
@@ -1245,6 +1245,7 @@ static const char PACKED_REFS_HEADER[] =
        "# pack-refs with: peeled fully-peeled sorted \n";
 
 static int packed_init_db(struct ref_store *ref_store UNUSED,
+                         int flags UNUSED,
                          struct strbuf *err UNUSED)
 {
        /* Nothing to do. */
@@ -1687,55 +1688,6 @@ static int packed_initial_transaction_commit(struct ref_store *ref_store UNUSED,
        return ref_transaction_commit(transaction, err);
 }
 
-static int packed_delete_refs(struct ref_store *ref_store, const char *msg,
-                            struct string_list *refnames, unsigned int flags)
-{
-       struct packed_ref_store *refs =
-               packed_downcast(ref_store, REF_STORE_WRITE, "delete_refs");
-       struct strbuf err = STRBUF_INIT;
-       struct ref_transaction *transaction;
-       struct string_list_item *item;
-       int ret;
-
-       (void)refs; /* We need the check above, but don't use the variable */
-
-       if (!refnames->nr)
-               return 0;
-
-       /*
-        * Since we don't check the references' old_oids, the
-        * individual updates can't fail, so we can pack all of the
-        * updates into a single transaction.
-        */
-
-       transaction = ref_store_transaction_begin(ref_store, &err);
-       if (!transaction)
-               return -1;
-
-       for_each_string_list_item(item, refnames) {
-               if (ref_transaction_delete(transaction, item->string, NULL,
-                                          flags, msg, &err)) {
-                       warning(_("could not delete reference %s: %s"),
-                               item->string, err.buf);
-                       strbuf_reset(&err);
-               }
-       }
-
-       ret = ref_transaction_commit(transaction, &err);
-
-       if (ret) {
-               if (refnames->nr == 1)
-                       error(_("could not delete reference %s: %s"),
-                             refnames->items[0].string, err.buf);
-               else
-                       error(_("could not delete references: %s"), err.buf);
-       }
-
-       ref_transaction_free(transaction);
-       strbuf_release(&err);
-       return ret;
-}
-
 static int packed_pack_refs(struct ref_store *ref_store UNUSED,
                            struct pack_refs_opts *pack_opts UNUSED)
 {
@@ -1753,7 +1705,6 @@ static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_s
 }
 
 struct ref_storage_be refs_be_packed = {
-       .next = NULL,
        .name = "packed",
        .init = packed_ref_store_create,
        .init_db = packed_init_db,
@@ -1764,7 +1715,6 @@ struct ref_storage_be refs_be_packed = {
 
        .pack_refs = packed_pack_refs,
        .create_symref = NULL,
-       .delete_refs = packed_delete_refs,
        .rename_ref = NULL,
        .copy_ref = NULL,
 
index a372a00941fda659cc60722452c8766f9c7de455..9f9797209a4545576f3ce5c9a9327c47e3319df1 100644 (file)
@@ -486,7 +486,7 @@ struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
 
        CALLOC_ARRAY(iter, 1);
        ref_iterator = &iter->base;
-       base_ref_iterator_init(ref_iterator, &cache_ref_iterator_vtable, 1);
+       base_ref_iterator_init(ref_iterator, &cache_ref_iterator_vtable);
        ALLOC_GROW(iter->levels, 10, iter->levels_alloc);
 
        iter->levels_nr = 1;
index 9db8aec4da8eef6fb9542a9db5d1cbae01c129e6..56641aa57a138da17037307d37e1ca28baa2a1ee 100644 (file)
@@ -260,6 +260,12 @@ enum do_for_each_ref_flags {
         * INCLUDE_BROKEN, since they are otherwise not included at all.
         */
        DO_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 << 2),
+
+       /*
+        * Include root refs i.e. HEAD and pseudorefs along with the regular
+        * refs.
+        */
+       DO_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3),
 };
 
 /*
@@ -312,13 +318,6 @@ enum do_for_each_ref_flags {
  */
 struct ref_iterator {
        struct ref_iterator_vtable *vtable;
-
-       /*
-        * Does this `ref_iterator` iterate over references in order
-        * by refname?
-        */
-       unsigned int ordered : 1;
-
        const char *refname;
        const struct object_id *oid;
        unsigned int flags;
@@ -386,15 +385,22 @@ typedef enum iterator_selection ref_iterator_select_fn(
                struct ref_iterator *iter0, struct ref_iterator *iter1,
                void *cb_data);
 
+/*
+ * An implementation of ref_iterator_select_fn that merges worktree and common
+ * refs. Per-worktree refs from the common iterator are ignored, worktree refs
+ * override common refs. Refs are selected lexicographically.
+ */
+enum iterator_selection ref_iterator_select(struct ref_iterator *iter_worktree,
+                                           struct ref_iterator *iter_common,
+                                           void *cb_data);
+
 /*
  * Iterate over the entries from iter0 and iter1, with the values
  * interleaved as directed by the select function. The iterator takes
  * ownership of iter0 and iter1 and frees them when the iteration is
- * over. A derived class should set `ordered` to 1 or 0 based on
- * whether it generates its output in order by reference name.
+ * over.
  */
 struct ref_iterator *merge_ref_iterator_begin(
-               int ordered,
                struct ref_iterator *iter0, struct ref_iterator *iter1,
                ref_iterator_select_fn *select, void *cb_data);
 
@@ -423,8 +429,6 @@ struct ref_iterator *overlay_ref_iterator_begin(
  * As an convenience to callers, if prefix is the empty string and
  * trim is zero, this function returns iter0 directly, without
  * wrapping it.
- *
- * The resulting ref_iterator is ordered if iter0 is.
  */
 struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
                                               const char *prefix,
@@ -435,14 +439,11 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
 /*
  * Base class constructor for ref_iterators. Initialize the
  * ref_iterator part of iter, setting its vtable pointer as specified.
- * `ordered` should be set to 1 if the iterator will iterate over
- * references in order by refname; otherwise it should be set to 0.
  * This is meant to be called only by the initializers of derived
  * classes.
  */
 void base_ref_iterator_init(struct ref_iterator *iter,
-                           struct ref_iterator_vtable *vtable,
-                           int ordered);
+                           struct ref_iterator_vtable *vtable);
 
 /*
  * Base class destructor for ref_iterators. Destroy the ref_iterator
@@ -529,7 +530,9 @@ typedef struct ref_store *ref_store_init_fn(struct repository *repo,
                                            const char *gitdir,
                                            unsigned int flags);
 
-typedef int ref_init_db_fn(struct ref_store *refs, struct strbuf *err);
+typedef int ref_init_db_fn(struct ref_store *refs,
+                          int flags,
+                          struct strbuf *err);
 
 typedef int ref_transaction_prepare_fn(struct ref_store *refs,
                                       struct ref_transaction *transaction,
@@ -553,8 +556,6 @@ typedef int create_symref_fn(struct ref_store *ref_store,
                             const char *ref_target,
                             const char *refs_heads_master,
                             const char *logmsg);
-typedef int delete_refs_fn(struct ref_store *ref_store, const char *msg,
-                          struct string_list *refnames, unsigned int flags);
 typedef int rename_ref_fn(struct ref_store *ref_store,
                          const char *oldref, const char *newref,
                          const char *logmsg);
@@ -665,7 +666,6 @@ typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refnam
                                 struct strbuf *referent);
 
 struct ref_storage_be {
-       struct ref_storage_be *next;
        const char *name;
        ref_store_init_fn *init;
        ref_init_db_fn *init_db;
@@ -677,7 +677,6 @@ struct ref_storage_be {
 
        pack_refs_fn *pack_refs;
        create_symref_fn *create_symref;
-       delete_refs_fn *delete_refs;
        rename_ref_fn *rename_ref;
        copy_ref_fn *copy_ref;
 
@@ -695,6 +694,7 @@ struct ref_storage_be {
 };
 
 extern struct ref_storage_be refs_be_files;
+extern struct ref_storage_be refs_be_reftable;
 extern struct ref_storage_be refs_be_packed;
 
 /*
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
new file mode 100644 (file)
index 0000000..eaa8296
--- /dev/null
@@ -0,0 +1,2249 @@
+#include "../git-compat-util.h"
+#include "../abspath.h"
+#include "../chdir-notify.h"
+#include "../environment.h"
+#include "../gettext.h"
+#include "../hash.h"
+#include "../hex.h"
+#include "../iterator.h"
+#include "../ident.h"
+#include "../lockfile.h"
+#include "../object.h"
+#include "../path.h"
+#include "../refs.h"
+#include "../reftable/reftable-stack.h"
+#include "../reftable/reftable-record.h"
+#include "../reftable/reftable-error.h"
+#include "../reftable/reftable-iterator.h"
+#include "../reftable/reftable-merged.h"
+#include "../setup.h"
+#include "../strmap.h"
+#include "refs-internal.h"
+
+/*
+ * Used as a flag in ref_update::flags when the ref_update was via an
+ * update to HEAD.
+ */
+#define REF_UPDATE_VIA_HEAD (1 << 8)
+
+struct reftable_ref_store {
+       struct ref_store base;
+
+       /*
+        * The main stack refers to the common dir and thus contains common
+        * refs as well as refs of the main repository.
+        */
+       struct reftable_stack *main_stack;
+       /*
+        * The worktree stack refers to the gitdir in case the refdb is opened
+        * via a worktree. It thus contains the per-worktree refs.
+        */
+       struct reftable_stack *worktree_stack;
+       /*
+        * Map of worktree stacks by their respective worktree names. The map
+        * is populated lazily when we try to resolve `worktrees/$worktree` refs.
+        */
+       struct strmap worktree_stacks;
+       struct reftable_write_options write_options;
+
+       unsigned int store_flags;
+       int err;
+};
+
+/*
+ * Downcast ref_store to reftable_ref_store. Die if ref_store is not a
+ * reftable_ref_store. required_flags is compared with ref_store's store_flags
+ * to ensure the ref_store has all required capabilities. "caller" is used in
+ * any necessary error messages.
+ */
+static struct reftable_ref_store *reftable_be_downcast(struct ref_store *ref_store,
+                                                      unsigned int required_flags,
+                                                      const char *caller)
+{
+       struct reftable_ref_store *refs;
+
+       if (ref_store->be != &refs_be_reftable)
+               BUG("ref_store is type \"%s\" not \"reftables\" in %s",
+                   ref_store->be->name, caller);
+
+       refs = (struct reftable_ref_store *)ref_store;
+
+       if ((refs->store_flags & required_flags) != required_flags)
+               BUG("operation %s requires abilities 0x%x, but only have 0x%x",
+                   caller, required_flags, refs->store_flags);
+
+       return refs;
+}
+
+/*
+ * Some refs are global to the repository (refs/heads/{*}), while others are
+ * local to the worktree (eg. HEAD, refs/bisect/{*}). We solve this by having
+ * multiple separate databases (ie. multiple reftable/ directories), one for
+ * the shared refs, one for the current worktree refs, and one for each
+ * additional worktree. For reading, we merge the view of both the shared and
+ * the current worktree's refs, when necessary.
+ *
+ * This function also optionally assigns the rewritten reference name that is
+ * local to the stack. This translation is required when using worktree refs
+ * like `worktrees/$worktree/refs/heads/foo` as worktree stacks will store
+ * those references in their normalized form.
+ */
+static struct reftable_stack *stack_for(struct reftable_ref_store *store,
+                                       const char *refname,
+                                       const char **rewritten_ref)
+{
+       const char *wtname;
+       int wtname_len;
+
+       if (!refname)
+               return store->main_stack;
+
+       switch (parse_worktree_ref(refname, &wtname, &wtname_len, rewritten_ref)) {
+       case REF_WORKTREE_OTHER: {
+               static struct strbuf wtname_buf = STRBUF_INIT;
+               struct strbuf wt_dir = STRBUF_INIT;
+               struct reftable_stack *stack;
+
+               /*
+                * We're using a static buffer here so that we don't need to
+                * allocate the worktree name whenever we look up a reference.
+                * This could be avoided if the strmap interface knew how to
+                * handle keys with a length.
+                */
+               strbuf_reset(&wtname_buf);
+               strbuf_add(&wtname_buf, wtname, wtname_len);
+
+               /*
+                * There is an edge case here: when the worktree references the
+                * current worktree, then we set up the stack once via
+                * `worktree_stacks` and once via `worktree_stack`. This is
+                * wasteful, but in the reading case it shouldn't matter. And
+                * in the writing case we would notice that the stack is locked
+                * already and error out when trying to write a reference via
+                * both stacks.
+                */
+               stack = strmap_get(&store->worktree_stacks, wtname_buf.buf);
+               if (!stack) {
+                       strbuf_addf(&wt_dir, "%s/worktrees/%s/reftable",
+                                   store->base.repo->commondir, wtname_buf.buf);
+
+                       store->err = reftable_new_stack(&stack, wt_dir.buf,
+                                                       store->write_options);
+                       assert(store->err != REFTABLE_API_ERROR);
+                       strmap_put(&store->worktree_stacks, wtname_buf.buf, stack);
+               }
+
+               strbuf_release(&wt_dir);
+               return stack;
+       }
+       case REF_WORKTREE_CURRENT:
+               /*
+                * If there is no worktree stack then we're currently in the
+                * main worktree. We thus return the main stack in that case.
+                */
+               if (!store->worktree_stack)
+                       return store->main_stack;
+               return store->worktree_stack;
+       case REF_WORKTREE_MAIN:
+       case REF_WORKTREE_SHARED:
+               return store->main_stack;
+       default:
+               BUG("unhandled worktree reference type");
+       }
+}
+
+static int should_write_log(struct ref_store *refs, const char *refname)
+{
+       if (log_all_ref_updates == LOG_REFS_UNSET)
+               log_all_ref_updates = is_bare_repository() ? LOG_REFS_NONE : LOG_REFS_NORMAL;
+
+       switch (log_all_ref_updates) {
+       case LOG_REFS_NONE:
+               return refs_reflog_exists(refs, refname);
+       case LOG_REFS_ALWAYS:
+               return 1;
+       case LOG_REFS_NORMAL:
+               if (should_autocreate_reflog(refname))
+                       return 1;
+               return refs_reflog_exists(refs, refname);
+       default:
+               BUG("unhandled core.logAllRefUpdates value %d", log_all_ref_updates);
+       }
+}
+
+static void clear_reftable_log_record(struct reftable_log_record *log)
+{
+       switch (log->value_type) {
+       case REFTABLE_LOG_UPDATE:
+               /*
+                * When we write log records, the hashes are owned by the
+                * caller and thus shouldn't be free'd.
+                */
+               log->value.update.old_hash = NULL;
+               log->value.update.new_hash = NULL;
+               break;
+       case REFTABLE_LOG_DELETION:
+               break;
+       }
+       reftable_log_record_release(log);
+}
+
+static void fill_reftable_log_record(struct reftable_log_record *log)
+{
+       const char *info = git_committer_info(0);
+       struct ident_split split = {0};
+       int sign = 1;
+
+       if (split_ident_line(&split, info, strlen(info)))
+               BUG("failed splitting committer info");
+
+       reftable_log_record_release(log);
+       log->value_type = REFTABLE_LOG_UPDATE;
+       log->value.update.name =
+               xstrndup(split.name_begin, split.name_end - split.name_begin);
+       log->value.update.email =
+               xstrndup(split.mail_begin, split.mail_end - split.mail_begin);
+       log->value.update.time = atol(split.date_begin);
+       if (*split.tz_begin == '-') {
+               sign = -1;
+               split.tz_begin++;
+       }
+       if (*split.tz_begin == '+') {
+               sign = 1;
+               split.tz_begin++;
+       }
+
+       log->value.update.tz_offset = sign * atoi(split.tz_begin);
+}
+
+static int read_ref_without_reload(struct reftable_stack *stack,
+                                  const char *refname,
+                                  struct object_id *oid,
+                                  struct strbuf *referent,
+                                  unsigned int *type)
+{
+       struct reftable_ref_record ref = {0};
+       int ret;
+
+       ret = reftable_stack_read_ref(stack, refname, &ref);
+       if (ret)
+               goto done;
+
+       if (ref.value_type == REFTABLE_REF_SYMREF) {
+               strbuf_reset(referent);
+               strbuf_addstr(referent, ref.value.symref);
+               *type |= REF_ISSYMREF;
+       } else if (reftable_ref_record_val1(&ref)) {
+               oidread(oid, reftable_ref_record_val1(&ref));
+       } else {
+               /* We got a tombstone, which should not happen. */
+               BUG("unhandled reference value type %d", ref.value_type);
+       }
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       reftable_ref_record_release(&ref);
+       return ret;
+}
+
+static struct ref_store *reftable_be_init(struct repository *repo,
+                                         const char *gitdir,
+                                         unsigned int store_flags)
+{
+       struct reftable_ref_store *refs = xcalloc(1, sizeof(*refs));
+       struct strbuf path = STRBUF_INIT;
+       int is_worktree;
+       mode_t mask;
+
+       mask = umask(0);
+       umask(mask);
+
+       base_ref_store_init(&refs->base, repo, gitdir, &refs_be_reftable);
+       strmap_init(&refs->worktree_stacks);
+       refs->store_flags = store_flags;
+       refs->write_options.block_size = 4096;
+       refs->write_options.hash_id = repo->hash_algo->format_id;
+       refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
+
+       /*
+        * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.
+        * This stack contains both the shared and the main worktree refs.
+        *
+        * Note that we don't try to resolve the path in case we have a
+        * worktree because `get_common_dir_noenv()` already does it for us.
+        */
+       is_worktree = get_common_dir_noenv(&path, gitdir);
+       if (!is_worktree) {
+               strbuf_reset(&path);
+               strbuf_realpath(&path, gitdir, 0);
+       }
+       strbuf_addstr(&path, "/reftable");
+       refs->err = reftable_new_stack(&refs->main_stack, path.buf,
+                                      refs->write_options);
+       if (refs->err)
+               goto done;
+
+       /*
+        * If we're in a worktree we also need to set up the worktree reftable
+        * stack that is contained in the per-worktree GIT_DIR.
+        *
+        * Ideally, we would also add the stack to our worktree stack map. But
+        * we have no way to figure out the worktree name here and thus can't
+        * do it efficiently.
+        */
+       if (is_worktree) {
+               strbuf_reset(&path);
+               strbuf_addf(&path, "%s/reftable", gitdir);
+
+               refs->err = reftable_new_stack(&refs->worktree_stack, path.buf,
+                                              refs->write_options);
+               if (refs->err)
+                       goto done;
+       }
+
+       chdir_notify_reparent("reftables-backend $GIT_DIR", &refs->base.gitdir);
+
+done:
+       assert(refs->err != REFTABLE_API_ERROR);
+       strbuf_release(&path);
+       return &refs->base;
+}
+
+static int reftable_be_init_db(struct ref_store *ref_store,
+                              int flags UNUSED,
+                              struct strbuf *err UNUSED)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "init_db");
+       struct strbuf sb = STRBUF_INIT;
+
+       strbuf_addf(&sb, "%s/reftable", refs->base.gitdir);
+       safe_create_dir(sb.buf, 1);
+       strbuf_reset(&sb);
+
+       strbuf_addf(&sb, "%s/HEAD", refs->base.gitdir);
+       write_file(sb.buf, "ref: refs/heads/.invalid");
+       adjust_shared_perm(sb.buf);
+       strbuf_reset(&sb);
+
+       strbuf_addf(&sb, "%s/refs", refs->base.gitdir);
+       safe_create_dir(sb.buf, 1);
+       strbuf_reset(&sb);
+
+       strbuf_addf(&sb, "%s/refs/heads", refs->base.gitdir);
+       write_file(sb.buf, "this repository uses the reftable format");
+       adjust_shared_perm(sb.buf);
+
+       strbuf_release(&sb);
+       return 0;
+}
+
+struct reftable_ref_iterator {
+       struct ref_iterator base;
+       struct reftable_ref_store *refs;
+       struct reftable_iterator iter;
+       struct reftable_ref_record ref;
+       struct object_id oid;
+
+       const char *prefix;
+       unsigned int flags;
+       int err;
+};
+
+static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
+{
+       struct reftable_ref_iterator *iter =
+               (struct reftable_ref_iterator *)ref_iterator;
+       struct reftable_ref_store *refs = iter->refs;
+
+       while (!iter->err) {
+               int flags = 0;
+
+               iter->err = reftable_iterator_next_ref(&iter->iter, &iter->ref);
+               if (iter->err)
+                       break;
+
+               /*
+                * The files backend only lists references contained in "refs/" unless
+                * the root refs are to be included. We emulate the same behaviour here.
+                */
+               if (!starts_with(iter->ref.refname, "refs/") &&
+                   !(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS &&
+                    (is_pseudoref(&iter->refs->base, iter->ref.refname) ||
+                     is_headref(&iter->refs->base, iter->ref.refname)))) {
+                       continue;
+               }
+
+               if (iter->prefix &&
+                   strncmp(iter->prefix, iter->ref.refname, strlen(iter->prefix))) {
+                       iter->err = 1;
+                       break;
+               }
+
+               if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY &&
+                   parse_worktree_ref(iter->ref.refname, NULL, NULL, NULL) !=
+                           REF_WORKTREE_CURRENT)
+                       continue;
+
+               switch (iter->ref.value_type) {
+               case REFTABLE_REF_VAL1:
+                       oidread(&iter->oid, iter->ref.value.val1);
+                       break;
+               case REFTABLE_REF_VAL2:
+                       oidread(&iter->oid, iter->ref.value.val2.value);
+                       break;
+               case REFTABLE_REF_SYMREF:
+                       if (!refs_resolve_ref_unsafe(&iter->refs->base, iter->ref.refname,
+                                                    RESOLVE_REF_READING, &iter->oid, &flags))
+                               oidclr(&iter->oid);
+                       break;
+               default:
+                       BUG("unhandled reference value type %d", iter->ref.value_type);
+               }
+
+               if (is_null_oid(&iter->oid))
+                       flags |= REF_ISBROKEN;
+
+               if (check_refname_format(iter->ref.refname, REFNAME_ALLOW_ONELEVEL)) {
+                       if (!refname_is_safe(iter->ref.refname))
+                               die(_("refname is dangerous: %s"), iter->ref.refname);
+                       oidclr(&iter->oid);
+                       flags |= REF_BAD_NAME | REF_ISBROKEN;
+               }
+
+               if (iter->flags & DO_FOR_EACH_OMIT_DANGLING_SYMREFS &&
+                   flags & REF_ISSYMREF &&
+                   flags & REF_ISBROKEN)
+                       continue;
+
+               if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
+                   !ref_resolves_to_object(iter->ref.refname, refs->base.repo,
+                                           &iter->oid, flags))
+                               continue;
+
+               iter->base.refname = iter->ref.refname;
+               iter->base.oid = &iter->oid;
+               iter->base.flags = flags;
+
+               break;
+       }
+
+       if (iter->err > 0) {
+               if (ref_iterator_abort(ref_iterator) != ITER_DONE)
+                       return ITER_ERROR;
+               return ITER_DONE;
+       }
+
+       if (iter->err < 0) {
+               ref_iterator_abort(ref_iterator);
+               return ITER_ERROR;
+       }
+
+       return ITER_OK;
+}
+
+static int reftable_ref_iterator_peel(struct ref_iterator *ref_iterator,
+                                     struct object_id *peeled)
+{
+       struct reftable_ref_iterator *iter =
+               (struct reftable_ref_iterator *)ref_iterator;
+
+       if (iter->ref.value_type == REFTABLE_REF_VAL2) {
+               oidread(peeled, iter->ref.value.val2.target_value);
+               return 0;
+       }
+
+       return -1;
+}
+
+static int reftable_ref_iterator_abort(struct ref_iterator *ref_iterator)
+{
+       struct reftable_ref_iterator *iter =
+               (struct reftable_ref_iterator *)ref_iterator;
+       reftable_ref_record_release(&iter->ref);
+       reftable_iterator_destroy(&iter->iter);
+       free(iter);
+       return ITER_DONE;
+}
+
+static struct ref_iterator_vtable reftable_ref_iterator_vtable = {
+       .advance = reftable_ref_iterator_advance,
+       .peel = reftable_ref_iterator_peel,
+       .abort = reftable_ref_iterator_abort
+};
+
+static struct reftable_ref_iterator *ref_iterator_for_stack(struct reftable_ref_store *refs,
+                                                           struct reftable_stack *stack,
+                                                           const char *prefix,
+                                                           int flags)
+{
+       struct reftable_merged_table *merged_table;
+       struct reftable_ref_iterator *iter;
+       int ret;
+
+       iter = xcalloc(1, sizeof(*iter));
+       base_ref_iterator_init(&iter->base, &reftable_ref_iterator_vtable);
+       iter->prefix = prefix;
+       iter->base.oid = &iter->oid;
+       iter->flags = flags;
+       iter->refs = refs;
+
+       ret = refs->err;
+       if (ret)
+               goto done;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               goto done;
+
+       merged_table = reftable_stack_merged_table(stack);
+
+       ret = reftable_merged_table_seek_ref(merged_table, &iter->iter, prefix);
+       if (ret)
+               goto done;
+
+done:
+       iter->err = ret;
+       return iter;
+}
+
+static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_store,
+                                                      const char *prefix,
+                                                      const char **exclude_patterns,
+                                                      unsigned int flags)
+{
+       struct reftable_ref_iterator *main_iter, *worktree_iter;
+       struct reftable_ref_store *refs;
+       unsigned int required_flags = REF_STORE_READ;
+
+       if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN))
+               required_flags |= REF_STORE_ODB;
+       refs = reftable_be_downcast(ref_store, required_flags, "ref_iterator_begin");
+
+       main_iter = ref_iterator_for_stack(refs, refs->main_stack, prefix, flags);
+
+       /*
+        * The worktree stack is only set when we're in an actual worktree
+        * right now. If we aren't, then we return the common reftable
+        * iterator, only.
+        */
+        if (!refs->worktree_stack)
+               return &main_iter->base;
+
+       /*
+        * Otherwise we merge both the common and the per-worktree refs into a
+        * single iterator.
+        */
+       worktree_iter = ref_iterator_for_stack(refs, refs->worktree_stack, prefix, flags);
+       return merge_ref_iterator_begin(&worktree_iter->base, &main_iter->base,
+                                       ref_iterator_select, NULL);
+}
+
+static int reftable_be_read_raw_ref(struct ref_store *ref_store,
+                                   const char *refname,
+                                   struct object_id *oid,
+                                   struct strbuf *referent,
+                                   unsigned int *type,
+                                   int *failure_errno)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_READ, "read_raw_ref");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       int ret;
+
+       if (refs->err < 0)
+               return refs->err;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               return ret;
+
+       ret = read_ref_without_reload(stack, refname, oid, referent, type);
+       if (ret < 0)
+               return ret;
+       if (ret > 0) {
+               *failure_errno = ENOENT;
+               return -1;
+       }
+
+       return 0;
+}
+
+static int reftable_be_read_symbolic_ref(struct ref_store *ref_store,
+                                        const char *refname,
+                                        struct strbuf *referent)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_READ, "read_symbolic_ref");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct reftable_ref_record ref = {0};
+       int ret;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               return ret;
+
+       ret = reftable_stack_read_ref(stack, refname, &ref);
+       if (ret == 0 && ref.value_type == REFTABLE_REF_SYMREF)
+               strbuf_addstr(referent, ref.value.symref);
+       else
+               ret = -1;
+
+       reftable_ref_record_release(&ref);
+       return ret;
+}
+
+/*
+ * Return the refname under which update was originally requested.
+ */
+static const char *original_update_refname(struct ref_update *update)
+{
+       while (update->parent_update)
+               update = update->parent_update;
+       return update->refname;
+}
+
+struct reftable_transaction_update {
+       struct ref_update *update;
+       struct object_id current_oid;
+};
+
+struct write_transaction_table_arg {
+       struct reftable_ref_store *refs;
+       struct reftable_stack *stack;
+       struct reftable_addition *addition;
+       struct reftable_transaction_update *updates;
+       size_t updates_nr;
+       size_t updates_alloc;
+       size_t updates_expected;
+};
+
+struct reftable_transaction_data {
+       struct write_transaction_table_arg *args;
+       size_t args_nr, args_alloc;
+};
+
+static void free_transaction_data(struct reftable_transaction_data *tx_data)
+{
+       if (!tx_data)
+               return;
+       for (size_t i = 0; i < tx_data->args_nr; i++) {
+               reftable_addition_destroy(tx_data->args[i].addition);
+               free(tx_data->args[i].updates);
+       }
+       free(tx_data->args);
+       free(tx_data);
+}
+
+/*
+ * Prepare transaction update for the given reference update. This will cause
+ * us to lock the corresponding reftable stack for concurrent modification.
+ */
+static int prepare_transaction_update(struct write_transaction_table_arg **out,
+                                     struct reftable_ref_store *refs,
+                                     struct reftable_transaction_data *tx_data,
+                                     struct ref_update *update,
+                                     struct strbuf *err)
+{
+       struct reftable_stack *stack = stack_for(refs, update->refname, NULL);
+       struct write_transaction_table_arg *arg = NULL;
+       size_t i;
+       int ret;
+
+       /*
+        * Search for a preexisting stack update. If there is one then we add
+        * the update to it, otherwise we set up a new stack update.
+        */
+       for (i = 0; !arg && i < tx_data->args_nr; i++)
+               if (tx_data->args[i].stack == stack)
+                       arg = &tx_data->args[i];
+
+       if (!arg) {
+               struct reftable_addition *addition;
+
+               ret = reftable_stack_reload(stack);
+               if (ret)
+                       return ret;
+
+               ret = reftable_stack_new_addition(&addition, stack);
+               if (ret) {
+                       if (ret == REFTABLE_LOCK_ERROR)
+                               strbuf_addstr(err, "cannot lock references");
+                       return ret;
+               }
+
+               ALLOC_GROW(tx_data->args, tx_data->args_nr + 1,
+                          tx_data->args_alloc);
+               arg = &tx_data->args[tx_data->args_nr++];
+               arg->refs = refs;
+               arg->stack = stack;
+               arg->addition = addition;
+               arg->updates = NULL;
+               arg->updates_nr = 0;
+               arg->updates_alloc = 0;
+               arg->updates_expected = 0;
+       }
+
+       arg->updates_expected++;
+
+       if (out)
+               *out = arg;
+
+       return 0;
+}
+
+/*
+ * Queue a reference update for the correct stack. We potentially need to
+ * handle multiple stack updates in a single transaction when it spans across
+ * multiple worktrees.
+ */
+static int queue_transaction_update(struct reftable_ref_store *refs,
+                                   struct reftable_transaction_data *tx_data,
+                                   struct ref_update *update,
+                                   struct object_id *current_oid,
+                                   struct strbuf *err)
+{
+       struct write_transaction_table_arg *arg = NULL;
+       int ret;
+
+       if (update->backend_data)
+               BUG("reference update queued more than once");
+
+       ret = prepare_transaction_update(&arg, refs, tx_data, update, err);
+       if (ret < 0)
+               return ret;
+
+       ALLOC_GROW(arg->updates, arg->updates_nr + 1,
+                  arg->updates_alloc);
+       arg->updates[arg->updates_nr].update = update;
+       oidcpy(&arg->updates[arg->updates_nr].current_oid, current_oid);
+       update->backend_data = &arg->updates[arg->updates_nr++];
+
+       return 0;
+}
+
+static int reftable_be_transaction_prepare(struct ref_store *ref_store,
+                                          struct ref_transaction *transaction,
+                                          struct strbuf *err)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE|REF_STORE_MAIN, "ref_transaction_prepare");
+       struct strbuf referent = STRBUF_INIT, head_referent = STRBUF_INIT;
+       struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
+       struct reftable_transaction_data *tx_data = NULL;
+       struct object_id head_oid;
+       unsigned int head_type = 0;
+       size_t i;
+       int ret;
+
+       ret = refs->err;
+       if (ret < 0)
+               goto done;
+
+       tx_data = xcalloc(1, sizeof(*tx_data));
+
+       /*
+        * Preprocess all updates. For one we check that there are no duplicate
+        * reference updates in this transaction. Second, we lock all stacks
+        * that will be modified during the transaction.
+        */
+       for (i = 0; i < transaction->nr; i++) {
+               ret = prepare_transaction_update(NULL, refs, tx_data,
+                                                transaction->updates[i], err);
+               if (ret)
+                       goto done;
+
+               string_list_append(&affected_refnames,
+                                  transaction->updates[i]->refname);
+       }
+
+       /*
+        * Now that we have counted updates per stack we can preallocate their
+        * arrays. This avoids having to reallocate many times.
+        */
+       for (i = 0; i < tx_data->args_nr; i++) {
+               CALLOC_ARRAY(tx_data->args[i].updates, tx_data->args[i].updates_expected);
+               tx_data->args[i].updates_alloc = tx_data->args[i].updates_expected;
+       }
+
+       /*
+        * Fail if a refname appears more than once in the transaction.
+        * This code is taken from the files backend and is a good candidate to
+        * be moved into the generic layer.
+        */
+       string_list_sort(&affected_refnames);
+       if (ref_update_reject_duplicates(&affected_refnames, err)) {
+               ret = TRANSACTION_GENERIC_ERROR;
+               goto done;
+       }
+
+       ret = read_ref_without_reload(stack_for(refs, "HEAD", NULL), "HEAD", &head_oid,
+                                     &head_referent, &head_type);
+       if (ret < 0)
+               goto done;
+
+       for (i = 0; i < transaction->nr; i++) {
+               struct ref_update *u = transaction->updates[i];
+               struct object_id current_oid = {0};
+               struct reftable_stack *stack;
+               const char *rewritten_ref;
+
+               stack = stack_for(refs, u->refname, &rewritten_ref);
+
+               /* Verify that the new object ID is valid. */
+               if ((u->flags & REF_HAVE_NEW) && !is_null_oid(&u->new_oid) &&
+                   !(u->flags & REF_SKIP_OID_VERIFICATION) &&
+                   !(u->flags & REF_LOG_ONLY)) {
+                       struct object *o = parse_object(refs->base.repo, &u->new_oid);
+                       if (!o) {
+                               strbuf_addf(err,
+                                           _("trying to write ref '%s' with nonexistent object %s"),
+                                           u->refname, oid_to_hex(&u->new_oid));
+                               ret = -1;
+                               goto done;
+                       }
+
+                       if (o->type != OBJ_COMMIT && is_branch(u->refname)) {
+                               strbuf_addf(err, _("trying to write non-commit object %s to branch '%s'"),
+                                           oid_to_hex(&u->new_oid), u->refname);
+                               ret = -1;
+                               goto done;
+                       }
+               }
+
+               /*
+                * When we update the reference that HEAD points to we enqueue
+                * a second log-only update for HEAD so that its reflog is
+                * updated accordingly.
+                */
+               if (head_type == REF_ISSYMREF &&
+                   !(u->flags & REF_LOG_ONLY) &&
+                   !(u->flags & REF_UPDATE_VIA_HEAD) &&
+                   !strcmp(rewritten_ref, head_referent.buf)) {
+                       struct ref_update *new_update;
+
+                       /*
+                        * First make sure that HEAD is not already in the
+                        * transaction. This check is O(lg N) in the transaction
+                        * size, but it happens at most once per transaction.
+                        */
+                       if (string_list_has_string(&affected_refnames, "HEAD")) {
+                               /* An entry already existed */
+                               strbuf_addf(err,
+                                           _("multiple updates for 'HEAD' (including one "
+                                           "via its referent '%s') are not allowed"),
+                                           u->refname);
+                               ret = TRANSACTION_NAME_CONFLICT;
+                               goto done;
+                       }
+
+                       new_update = ref_transaction_add_update(
+                                       transaction, "HEAD",
+                                       u->flags | REF_LOG_ONLY | REF_NO_DEREF,
+                                       &u->new_oid, &u->old_oid, u->msg);
+                       string_list_insert(&affected_refnames, new_update->refname);
+               }
+
+               ret = read_ref_without_reload(stack, rewritten_ref,
+                                             &current_oid, &referent, &u->type);
+               if (ret < 0)
+                       goto done;
+               if (ret > 0 && (!(u->flags & REF_HAVE_OLD) || is_null_oid(&u->old_oid))) {
+                       /*
+                        * The reference does not exist, and we either have no
+                        * old object ID or expect the reference to not exist.
+                        * We can thus skip below safety checks as well as the
+                        * symref splitting. But we do want to verify that
+                        * there is no conflicting reference here so that we
+                        * can output a proper error message instead of failing
+                        * at a later point.
+                        */
+                       ret = refs_verify_refname_available(ref_store, u->refname,
+                                                           &affected_refnames, NULL, err);
+                       if (ret < 0)
+                               goto done;
+
+                       /*
+                        * There is no need to write the reference deletion
+                        * when the reference in question doesn't exist.
+                        */
+                        if (u->flags & REF_HAVE_NEW && !is_null_oid(&u->new_oid)) {
+                                ret = queue_transaction_update(refs, tx_data, u,
+                                                               &current_oid, err);
+                                if (ret)
+                                        goto done;
+                        }
+
+                       continue;
+               }
+               if (ret > 0) {
+                       /* The reference does not exist, but we expected it to. */
+                       strbuf_addf(err, _("cannot lock ref '%s': "
+                                   "unable to resolve reference '%s'"),
+                                   original_update_refname(u), u->refname);
+                       ret = -1;
+                       goto done;
+               }
+
+               if (u->type & REF_ISSYMREF) {
+                       /*
+                        * The reftable stack is locked at this point already,
+                        * so it is safe to call `refs_resolve_ref_unsafe()`
+                        * here without causing races.
+                        */
+                       const char *resolved = refs_resolve_ref_unsafe(&refs->base, u->refname, 0,
+                                                                      &current_oid, NULL);
+
+                       if (u->flags & REF_NO_DEREF) {
+                               if (u->flags & REF_HAVE_OLD && !resolved) {
+                                       strbuf_addf(err, _("cannot lock ref '%s': "
+                                                   "error reading reference"), u->refname);
+                                       ret = -1;
+                                       goto done;
+                               }
+                       } else {
+                               struct ref_update *new_update;
+                               int new_flags;
+
+                               new_flags = u->flags;
+                               if (!strcmp(rewritten_ref, "HEAD"))
+                                       new_flags |= REF_UPDATE_VIA_HEAD;
+
+                               /*
+                                * If we are updating a symref (eg. HEAD), we should also
+                                * update the branch that the symref points to.
+                                *
+                                * This is generic functionality, and would be better
+                                * done in refs.c, but the current implementation is
+                                * intertwined with the locking in files-backend.c.
+                                */
+                               new_update = ref_transaction_add_update(
+                                               transaction, referent.buf, new_flags,
+                                               &u->new_oid, &u->old_oid, u->msg);
+                               new_update->parent_update = u;
+
+                               /*
+                                * Change the symbolic ref update to log only. Also, it
+                                * doesn't need to check its old OID value, as that will be
+                                * done when new_update is processed.
+                                */
+                               u->flags |= REF_LOG_ONLY | REF_NO_DEREF;
+                               u->flags &= ~REF_HAVE_OLD;
+
+                               if (string_list_has_string(&affected_refnames, new_update->refname)) {
+                                       strbuf_addf(err,
+                                                   _("multiple updates for '%s' (including one "
+                                                   "via symref '%s') are not allowed"),
+                                                   referent.buf, u->refname);
+                                       ret = TRANSACTION_NAME_CONFLICT;
+                                       goto done;
+                               }
+                               string_list_insert(&affected_refnames, new_update->refname);
+                       }
+               }
+
+               /*
+                * Verify that the old object matches our expectations. Note
+                * that the error messages here do not make a lot of sense in
+                * the context of the reftable backend as we never lock
+                * individual refs. But the error messages match what the files
+                * backend returns, which keeps our tests happy.
+                */
+               if (u->flags & REF_HAVE_OLD && !oideq(&current_oid, &u->old_oid)) {
+                       if (is_null_oid(&u->old_oid))
+                               strbuf_addf(err, _("cannot lock ref '%s': "
+                                           "reference already exists"),
+                                           original_update_refname(u));
+                       else if (is_null_oid(&current_oid))
+                               strbuf_addf(err, _("cannot lock ref '%s': "
+                                           "reference is missing but expected %s"),
+                                           original_update_refname(u),
+                                           oid_to_hex(&u->old_oid));
+                       else
+                               strbuf_addf(err, _("cannot lock ref '%s': "
+                                           "is at %s but expected %s"),
+                                           original_update_refname(u),
+                                           oid_to_hex(&current_oid),
+                                           oid_to_hex(&u->old_oid));
+                       ret = -1;
+                       goto done;
+               }
+
+               /*
+                * If all of the following conditions are true:
+                *
+                *   - We're not about to write a symref.
+                *   - We're not about to write a log-only entry.
+                *   - Old and new object ID are different.
+                *
+                * Then we're essentially doing a no-op update that can be
+                * skipped. This is not only for the sake of efficiency, but
+                * also skips writing unneeded reflog entries.
+                */
+               if ((u->type & REF_ISSYMREF) ||
+                   (u->flags & REF_LOG_ONLY) ||
+                   (u->flags & REF_HAVE_NEW && !oideq(&current_oid, &u->new_oid))) {
+                       ret = queue_transaction_update(refs, tx_data, u,
+                                                      &current_oid, err);
+                       if (ret)
+                               goto done;
+               }
+       }
+
+       transaction->backend_data = tx_data;
+       transaction->state = REF_TRANSACTION_PREPARED;
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       if (ret < 0) {
+               free_transaction_data(tx_data);
+               transaction->state = REF_TRANSACTION_CLOSED;
+               if (!err->len)
+                       strbuf_addf(err, _("reftable: transaction prepare: %s"),
+                                   reftable_error_str(ret));
+       }
+       string_list_clear(&affected_refnames, 0);
+       strbuf_release(&referent);
+       strbuf_release(&head_referent);
+
+       return ret;
+}
+
+static int reftable_be_transaction_abort(struct ref_store *ref_store,
+                                        struct ref_transaction *transaction,
+                                        struct strbuf *err)
+{
+       struct reftable_transaction_data *tx_data = transaction->backend_data;
+       free_transaction_data(tx_data);
+       transaction->state = REF_TRANSACTION_CLOSED;
+       return 0;
+}
+
+static int transaction_update_cmp(const void *a, const void *b)
+{
+       return strcmp(((struct reftable_transaction_update *)a)->update->refname,
+                     ((struct reftable_transaction_update *)b)->update->refname);
+}
+
+static int write_transaction_table(struct reftable_writer *writer, void *cb_data)
+{
+       struct write_transaction_table_arg *arg = cb_data;
+       struct reftable_merged_table *mt =
+               reftable_stack_merged_table(arg->stack);
+       uint64_t ts = reftable_stack_next_update_index(arg->stack);
+       struct reftable_log_record *logs = NULL;
+       size_t logs_nr = 0, logs_alloc = 0, i;
+       int ret = 0;
+
+       QSORT(arg->updates, arg->updates_nr, transaction_update_cmp);
+
+       reftable_writer_set_limits(writer, ts, ts);
+
+       for (i = 0; i < arg->updates_nr; i++) {
+               struct reftable_transaction_update *tx_update = &arg->updates[i];
+               struct ref_update *u = tx_update->update;
+
+               /*
+                * Write a reflog entry when updating a ref to point to
+                * something new in either of the following cases:
+                *
+                * - The reference is about to be deleted. We always want to
+                *   delete the reflog in that case.
+                * - REF_FORCE_CREATE_REFLOG is set, asking us to always create
+                *   the reflog entry.
+                * - `core.logAllRefUpdates` tells us to create the reflog for
+                *   the given ref.
+                */
+               if (u->flags & REF_HAVE_NEW && !(u->type & REF_ISSYMREF) && is_null_oid(&u->new_oid)) {
+                       struct reftable_log_record log = {0};
+                       struct reftable_iterator it = {0};
+
+                       /*
+                        * When deleting refs we also delete all reflog entries
+                        * with them. While it is not strictly required to
+                        * delete reflogs together with their refs, this
+                        * matches the behaviour of the files backend.
+                        *
+                        * Unfortunately, we have no better way than to delete
+                        * all reflog entries one by one.
+                        */
+                       ret = reftable_merged_table_seek_log(mt, &it, u->refname);
+                       while (ret == 0) {
+                               struct reftable_log_record *tombstone;
+
+                               ret = reftable_iterator_next_log(&it, &log);
+                               if (ret < 0)
+                                       break;
+                               if (ret > 0 || strcmp(log.refname, u->refname)) {
+                                       ret = 0;
+                                       break;
+                               }
+
+                               ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+                               tombstone = &logs[logs_nr++];
+                               tombstone->refname = xstrdup(u->refname);
+                               tombstone->value_type = REFTABLE_LOG_DELETION;
+                               tombstone->update_index = log.update_index;
+                       }
+
+                       reftable_log_record_release(&log);
+                       reftable_iterator_destroy(&it);
+
+                       if (ret)
+                               goto done;
+               } else if (u->flags & REF_HAVE_NEW &&
+                          (u->flags & REF_FORCE_CREATE_REFLOG ||
+                           should_write_log(&arg->refs->base, u->refname))) {
+                       struct reftable_log_record *log;
+
+                       ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+                       log = &logs[logs_nr++];
+                       memset(log, 0, sizeof(*log));
+
+                       fill_reftable_log_record(log);
+                       log->update_index = ts;
+                       log->refname = xstrdup(u->refname);
+                       log->value.update.new_hash = u->new_oid.hash;
+                       log->value.update.old_hash = tx_update->current_oid.hash;
+                       log->value.update.message =
+                               xstrndup(u->msg, arg->refs->write_options.block_size / 2);
+               }
+
+               if (u->flags & REF_LOG_ONLY)
+                       continue;
+
+               if (u->flags & REF_HAVE_NEW && is_null_oid(&u->new_oid)) {
+                       struct reftable_ref_record ref = {
+                               .refname = (char *)u->refname,
+                               .update_index = ts,
+                               .value_type = REFTABLE_REF_DELETION,
+                       };
+
+                       ret = reftable_writer_add_ref(writer, &ref);
+                       if (ret < 0)
+                               goto done;
+               } else if (u->flags & REF_HAVE_NEW) {
+                       struct reftable_ref_record ref = {0};
+                       struct object_id peeled;
+                       int peel_error;
+
+                       ref.refname = (char *)u->refname;
+                       ref.update_index = ts;
+
+                       peel_error = peel_object(&u->new_oid, &peeled);
+                       if (!peel_error) {
+                               ref.value_type = REFTABLE_REF_VAL2;
+                               memcpy(ref.value.val2.target_value, peeled.hash, GIT_MAX_RAWSZ);
+                               memcpy(ref.value.val2.value, u->new_oid.hash, GIT_MAX_RAWSZ);
+                       } else if (!is_null_oid(&u->new_oid)) {
+                               ref.value_type = REFTABLE_REF_VAL1;
+                               memcpy(ref.value.val1, u->new_oid.hash, GIT_MAX_RAWSZ);
+                       }
+
+                       ret = reftable_writer_add_ref(writer, &ref);
+                       if (ret < 0)
+                               goto done;
+               }
+       }
+
+       /*
+        * Logs are written at the end so that we do not have intermixed ref
+        * and log blocks.
+        */
+       if (logs) {
+               ret = reftable_writer_add_logs(writer, logs, logs_nr);
+               if (ret < 0)
+                       goto done;
+       }
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       for (i = 0; i < logs_nr; i++)
+               clear_reftable_log_record(&logs[i]);
+       free(logs);
+       return ret;
+}
+
+static int reftable_be_transaction_finish(struct ref_store *ref_store,
+                                         struct ref_transaction *transaction,
+                                         struct strbuf *err)
+{
+       struct reftable_transaction_data *tx_data = transaction->backend_data;
+       int ret = 0;
+
+       for (size_t i = 0; i < tx_data->args_nr; i++) {
+               ret = reftable_addition_add(tx_data->args[i].addition,
+                                           write_transaction_table, &tx_data->args[i]);
+               if (ret < 0)
+                       goto done;
+
+               ret = reftable_addition_commit(tx_data->args[i].addition);
+               if (ret < 0)
+                       goto done;
+       }
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       free_transaction_data(tx_data);
+       transaction->state = REF_TRANSACTION_CLOSED;
+
+       if (ret) {
+               strbuf_addf(err, _("reftable: transaction failure: %s"),
+                           reftable_error_str(ret));
+               return -1;
+       }
+       return ret;
+}
+
+static int reftable_be_initial_transaction_commit(struct ref_store *ref_store UNUSED,
+                                                 struct ref_transaction *transaction,
+                                                 struct strbuf *err)
+{
+       return ref_transaction_commit(transaction, err);
+}
+
+static int reftable_be_pack_refs(struct ref_store *ref_store,
+                                struct pack_refs_opts *opts)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB, "pack_refs");
+       struct reftable_stack *stack;
+       int ret;
+
+       if (refs->err)
+               return refs->err;
+
+       stack = refs->worktree_stack;
+       if (!stack)
+               stack = refs->main_stack;
+
+       ret = reftable_stack_compact_all(stack, NULL);
+       if (ret)
+               goto out;
+       ret = reftable_stack_clean(stack);
+       if (ret)
+               goto out;
+
+out:
+       return ret;
+}
+
+struct write_create_symref_arg {
+       struct reftable_ref_store *refs;
+       struct reftable_stack *stack;
+       const char *refname;
+       const char *target;
+       const char *logmsg;
+};
+
+static int write_create_symref_table(struct reftable_writer *writer, void *cb_data)
+{
+       struct write_create_symref_arg *create = cb_data;
+       uint64_t ts = reftable_stack_next_update_index(create->stack);
+       struct reftable_ref_record ref = {
+               .refname = (char *)create->refname,
+               .value_type = REFTABLE_REF_SYMREF,
+               .value.symref = (char *)create->target,
+               .update_index = ts,
+       };
+       struct reftable_log_record log = {0};
+       struct object_id new_oid;
+       struct object_id old_oid;
+       int ret;
+
+       reftable_writer_set_limits(writer, ts, ts);
+
+       ret = reftable_writer_add_ref(writer, &ref);
+       if (ret)
+               return ret;
+
+       /*
+        * Note that it is important to try and resolve the reference before we
+        * write the log entry. This is because `should_write_log()` will munge
+        * `core.logAllRefUpdates`, which is undesirable when we create a new
+        * repository because it would be written into the config. As HEAD will
+        * not resolve for new repositories this ordering will ensure that this
+        * never happens.
+        */
+       if (!create->logmsg ||
+           !refs_resolve_ref_unsafe(&create->refs->base, create->target,
+                                    RESOLVE_REF_READING, &new_oid, NULL) ||
+           !should_write_log(&create->refs->base, create->refname))
+               return 0;
+
+       fill_reftable_log_record(&log);
+       log.refname = xstrdup(create->refname);
+       log.update_index = ts;
+       log.value.update.message = xstrndup(create->logmsg,
+                                           create->refs->write_options.block_size / 2);
+       log.value.update.new_hash = new_oid.hash;
+       if (refs_resolve_ref_unsafe(&create->refs->base, create->refname,
+                                   RESOLVE_REF_READING, &old_oid, NULL))
+               log.value.update.old_hash = old_oid.hash;
+
+       ret = reftable_writer_add_log(writer, &log);
+       clear_reftable_log_record(&log);
+       return ret;
+}
+
+static int reftable_be_create_symref(struct ref_store *ref_store,
+                                    const char *refname,
+                                    const char *target,
+                                    const char *logmsg)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "create_symref");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct write_create_symref_arg arg = {
+               .refs = refs,
+               .stack = stack,
+               .refname = refname,
+               .target = target,
+               .logmsg = logmsg,
+       };
+       int ret;
+
+       ret = refs->err;
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               goto done;
+
+       ret = reftable_stack_add(stack, &write_create_symref_table, &arg);
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       if (ret)
+               error("unable to write symref for %s: %s", refname,
+                     reftable_error_str(ret));
+       return ret;
+}
+
+struct write_copy_arg {
+       struct reftable_ref_store *refs;
+       struct reftable_stack *stack;
+       const char *oldname;
+       const char *newname;
+       const char *logmsg;
+       int delete_old;
+};
+
+static int write_copy_table(struct reftable_writer *writer, void *cb_data)
+{
+       struct write_copy_arg *arg = cb_data;
+       uint64_t deletion_ts, creation_ts;
+       struct reftable_merged_table *mt = reftable_stack_merged_table(arg->stack);
+       struct reftable_ref_record old_ref = {0}, refs[2] = {0};
+       struct reftable_log_record old_log = {0}, *logs = NULL;
+       struct reftable_iterator it = {0};
+       struct string_list skip = STRING_LIST_INIT_NODUP;
+       struct strbuf errbuf = STRBUF_INIT;
+       size_t logs_nr = 0, logs_alloc = 0, i;
+       int ret;
+
+       if (reftable_stack_read_ref(arg->stack, arg->oldname, &old_ref)) {
+               ret = error(_("refname %s not found"), arg->oldname);
+               goto done;
+       }
+       if (old_ref.value_type == REFTABLE_REF_SYMREF) {
+               ret = error(_("refname %s is a symbolic ref, copying it is not supported"),
+                           arg->oldname);
+               goto done;
+       }
+
+       /*
+        * There's nothing to do in case the old and new name are the same, so
+        * we exit early in that case.
+        */
+       if (!strcmp(arg->oldname, arg->newname)) {
+               ret = 0;
+               goto done;
+       }
+
+       /*
+        * Verify that the new refname is available.
+        */
+       string_list_insert(&skip, arg->oldname);
+       ret = refs_verify_refname_available(&arg->refs->base, arg->newname,
+                                           NULL, &skip, &errbuf);
+       if (ret < 0) {
+               error("%s", errbuf.buf);
+               goto done;
+       }
+
+       /*
+        * When deleting the old reference we have to use two update indices:
+        * once to delete the old ref and its reflog, and once to create the
+        * new ref and its reflog. They need to be staged with two separate
+        * indices because the new reflog needs to encode both the deletion of
+        * the old branch and the creation of the new branch, and we cannot do
+        * two changes to a reflog in a single update.
+        */
+       deletion_ts = creation_ts = reftable_stack_next_update_index(arg->stack);
+       if (arg->delete_old)
+               creation_ts++;
+       reftable_writer_set_limits(writer, deletion_ts, creation_ts);
+
+       /*
+        * Add the new reference. If this is a rename then we also delete the
+        * old reference.
+        */
+       refs[0] = old_ref;
+       refs[0].refname = (char *)arg->newname;
+       refs[0].update_index = creation_ts;
+       if (arg->delete_old) {
+               refs[1].refname = (char *)arg->oldname;
+               refs[1].value_type = REFTABLE_REF_DELETION;
+               refs[1].update_index = deletion_ts;
+       }
+       ret = reftable_writer_add_refs(writer, refs, arg->delete_old ? 2 : 1);
+       if (ret < 0)
+               goto done;
+
+       /*
+        * When deleting the old branch we need to create a reflog entry on the
+        * new branch name that indicates that the old branch has been deleted
+        * and then recreated. This is a tad weird, but matches what the files
+        * backend does.
+        */
+       if (arg->delete_old) {
+               struct strbuf head_referent = STRBUF_INIT;
+               struct object_id head_oid;
+               int append_head_reflog;
+               unsigned head_type = 0;
+
+               ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+               memset(&logs[logs_nr], 0, sizeof(logs[logs_nr]));
+               fill_reftable_log_record(&logs[logs_nr]);
+               logs[logs_nr].refname = (char *)arg->newname;
+               logs[logs_nr].update_index = deletion_ts;
+               logs[logs_nr].value.update.message =
+                       xstrndup(arg->logmsg, arg->refs->write_options.block_size / 2);
+               logs[logs_nr].value.update.old_hash = old_ref.value.val1;
+               logs_nr++;
+
+               ret = read_ref_without_reload(arg->stack, "HEAD", &head_oid, &head_referent, &head_type);
+               if (ret < 0)
+                       goto done;
+               append_head_reflog = (head_type & REF_ISSYMREF) && !strcmp(head_referent.buf, arg->oldname);
+               strbuf_release(&head_referent);
+
+               /*
+                * The files backend uses `refs_delete_ref()` to delete the old
+                * branch name, which will append a reflog entry for HEAD in
+                * case it points to the old branch.
+                */
+               if (append_head_reflog) {
+                       ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+                       logs[logs_nr] = logs[logs_nr - 1];
+                       logs[logs_nr].refname = "HEAD";
+                       logs_nr++;
+               }
+       }
+
+       /*
+        * Create the reflog entry for the newly created branch.
+        */
+       ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+       memset(&logs[logs_nr], 0, sizeof(logs[logs_nr]));
+       fill_reftable_log_record(&logs[logs_nr]);
+       logs[logs_nr].refname = (char *)arg->newname;
+       logs[logs_nr].update_index = creation_ts;
+       logs[logs_nr].value.update.message =
+               xstrndup(arg->logmsg, arg->refs->write_options.block_size / 2);
+       logs[logs_nr].value.update.new_hash = old_ref.value.val1;
+       logs_nr++;
+
+       /*
+        * In addition to writing the reflog entry for the new branch, we also
+        * copy over all log entries from the old reflog. Last but not least,
+        * when renaming we also have to delete all the old reflog entries.
+        */
+       ret = reftable_merged_table_seek_log(mt, &it, arg->oldname);
+       if (ret < 0)
+               goto done;
+
+       while (1) {
+               ret = reftable_iterator_next_log(&it, &old_log);
+               if (ret < 0)
+                       goto done;
+               if (ret > 0 || strcmp(old_log.refname, arg->oldname)) {
+                       ret = 0;
+                       break;
+               }
+
+               free(old_log.refname);
+
+               /*
+                * Copy over the old reflog entry with the new refname.
+                */
+               ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+               logs[logs_nr] = old_log;
+               logs[logs_nr].refname = (char *)arg->newname;
+               logs_nr++;
+
+               /*
+                * Delete the old reflog entry in case we are renaming.
+                */
+               if (arg->delete_old) {
+                       ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+                       memset(&logs[logs_nr], 0, sizeof(logs[logs_nr]));
+                       logs[logs_nr].refname = (char *)arg->oldname;
+                       logs[logs_nr].value_type = REFTABLE_LOG_DELETION;
+                       logs[logs_nr].update_index = old_log.update_index;
+                       logs_nr++;
+               }
+
+               /*
+                * Transfer ownership of the log record we're iterating over to
+                * the array of log records. Otherwise, the pointers would get
+                * free'd or reallocated by the iterator.
+                */
+               memset(&old_log, 0, sizeof(old_log));
+       }
+
+       ret = reftable_writer_add_logs(writer, logs, logs_nr);
+       if (ret < 0)
+               goto done;
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       reftable_iterator_destroy(&it);
+       string_list_clear(&skip, 0);
+       strbuf_release(&errbuf);
+       for (i = 0; i < logs_nr; i++) {
+               if (!strcmp(logs[i].refname, "HEAD"))
+                       continue;
+               if (logs[i].value.update.old_hash == old_ref.value.val1)
+                       logs[i].value.update.old_hash = NULL;
+               if (logs[i].value.update.new_hash == old_ref.value.val1)
+                       logs[i].value.update.new_hash = NULL;
+               logs[i].refname = NULL;
+               reftable_log_record_release(&logs[i]);
+       }
+       free(logs);
+       reftable_ref_record_release(&old_ref);
+       reftable_log_record_release(&old_log);
+       return ret;
+}
+
+static int reftable_be_rename_ref(struct ref_store *ref_store,
+                                 const char *oldrefname,
+                                 const char *newrefname,
+                                 const char *logmsg)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
+       struct reftable_stack *stack = stack_for(refs, newrefname, &newrefname);
+       struct write_copy_arg arg = {
+               .refs = refs,
+               .stack = stack,
+               .oldname = oldrefname,
+               .newname = newrefname,
+               .logmsg = logmsg,
+               .delete_old = 1,
+       };
+       int ret;
+
+       ret = refs->err;
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               goto done;
+       ret = reftable_stack_add(stack, &write_copy_table, &arg);
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       return ret;
+}
+
+static int reftable_be_copy_ref(struct ref_store *ref_store,
+                               const char *oldrefname,
+                               const char *newrefname,
+                               const char *logmsg)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "copy_ref");
+       struct reftable_stack *stack = stack_for(refs, newrefname, &newrefname);
+       struct write_copy_arg arg = {
+               .refs = refs,
+               .stack = stack,
+               .oldname = oldrefname,
+               .newname = newrefname,
+               .logmsg = logmsg,
+       };
+       int ret;
+
+       ret = refs->err;
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               goto done;
+       ret = reftable_stack_add(stack, &write_copy_table, &arg);
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       return ret;
+}
+
+struct reftable_reflog_iterator {
+       struct ref_iterator base;
+       struct reftable_ref_store *refs;
+       struct reftable_iterator iter;
+       struct reftable_log_record log;
+       char *last_name;
+       int err;
+};
+
+static int reftable_reflog_iterator_advance(struct ref_iterator *ref_iterator)
+{
+       struct reftable_reflog_iterator *iter =
+               (struct reftable_reflog_iterator *)ref_iterator;
+
+       while (!iter->err) {
+               iter->err = reftable_iterator_next_log(&iter->iter, &iter->log);
+               if (iter->err)
+                       break;
+
+               /*
+                * We want the refnames that we have reflogs for, so we skip if
+                * we've already produced this name. This could be faster by
+                * seeking directly to reflog@update_index==0.
+                */
+               if (iter->last_name && !strcmp(iter->log.refname, iter->last_name))
+                       continue;
+
+               if (check_refname_format(iter->log.refname,
+                                        REFNAME_ALLOW_ONELEVEL))
+                       continue;
+
+               free(iter->last_name);
+               iter->last_name = xstrdup(iter->log.refname);
+               iter->base.refname = iter->log.refname;
+
+               break;
+       }
+
+       if (iter->err > 0) {
+               if (ref_iterator_abort(ref_iterator) != ITER_DONE)
+                       return ITER_ERROR;
+               return ITER_DONE;
+       }
+
+       if (iter->err < 0) {
+               ref_iterator_abort(ref_iterator);
+               return ITER_ERROR;
+       }
+
+       return ITER_OK;
+}
+
+static int reftable_reflog_iterator_peel(struct ref_iterator *ref_iterator,
+                                                struct object_id *peeled)
+{
+       BUG("reftable reflog iterator cannot be peeled");
+       return -1;
+}
+
+static int reftable_reflog_iterator_abort(struct ref_iterator *ref_iterator)
+{
+       struct reftable_reflog_iterator *iter =
+               (struct reftable_reflog_iterator *)ref_iterator;
+       reftable_log_record_release(&iter->log);
+       reftable_iterator_destroy(&iter->iter);
+       free(iter->last_name);
+       free(iter);
+       return ITER_DONE;
+}
+
+static struct ref_iterator_vtable reftable_reflog_iterator_vtable = {
+       .advance = reftable_reflog_iterator_advance,
+       .peel = reftable_reflog_iterator_peel,
+       .abort = reftable_reflog_iterator_abort
+};
+
+static struct reftable_reflog_iterator *reflog_iterator_for_stack(struct reftable_ref_store *refs,
+                                                                 struct reftable_stack *stack)
+{
+       struct reftable_merged_table *merged_table;
+       struct reftable_reflog_iterator *iter;
+       int ret;
+
+       iter = xcalloc(1, sizeof(*iter));
+       base_ref_iterator_init(&iter->base, &reftable_reflog_iterator_vtable);
+       iter->refs = refs;
+
+       ret = refs->err;
+       if (ret)
+               goto done;
+
+       ret = reftable_stack_reload(refs->main_stack);
+       if (ret < 0)
+               goto done;
+
+       merged_table = reftable_stack_merged_table(stack);
+
+       ret = reftable_merged_table_seek_log(merged_table, &iter->iter, "");
+       if (ret < 0)
+               goto done;
+
+done:
+       iter->err = ret;
+       return iter;
+}
+
+static struct ref_iterator *reftable_be_reflog_iterator_begin(struct ref_store *ref_store)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_READ, "reflog_iterator_begin");
+       struct reftable_reflog_iterator *main_iter, *worktree_iter;
+
+       main_iter = reflog_iterator_for_stack(refs, refs->main_stack);
+       if (!refs->worktree_stack)
+               return &main_iter->base;
+
+       worktree_iter = reflog_iterator_for_stack(refs, refs->worktree_stack);
+
+       return merge_ref_iterator_begin(&worktree_iter->base, &main_iter->base,
+                                       ref_iterator_select, NULL);
+}
+
+static int yield_log_record(struct reftable_log_record *log,
+                           each_reflog_ent_fn fn,
+                           void *cb_data)
+{
+       struct object_id old_oid, new_oid;
+       const char *full_committer;
+
+       oidread(&old_oid, log->value.update.old_hash);
+       oidread(&new_oid, log->value.update.new_hash);
+
+       /*
+        * When both the old object ID and the new object ID are null
+        * then this is the reflog existence marker. The caller must
+        * not be aware of it.
+        */
+       if (is_null_oid(&old_oid) && is_null_oid(&new_oid))
+               return 0;
+
+       full_committer = fmt_ident(log->value.update.name, log->value.update.email,
+                                  WANT_COMMITTER_IDENT, NULL, IDENT_NO_DATE);
+       return fn(&old_oid, &new_oid, full_committer,
+                 log->value.update.time, log->value.update.tz_offset,
+                 log->value.update.message, cb_data);
+}
+
+static int reftable_be_for_each_reflog_ent_reverse(struct ref_store *ref_store,
+                                                  const char *refname,
+                                                  each_reflog_ent_fn fn,
+                                                  void *cb_data)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_READ, "for_each_reflog_ent_reverse");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct reftable_merged_table *mt = NULL;
+       struct reftable_log_record log = {0};
+       struct reftable_iterator it = {0};
+       int ret;
+
+       if (refs->err < 0)
+               return refs->err;
+
+       mt = reftable_stack_merged_table(stack);
+       ret = reftable_merged_table_seek_log(mt, &it, refname);
+       while (!ret) {
+               ret = reftable_iterator_next_log(&it, &log);
+               if (ret < 0)
+                       break;
+               if (ret > 0 || strcmp(log.refname, refname)) {
+                       ret = 0;
+                       break;
+               }
+
+               ret = yield_log_record(&log, fn, cb_data);
+               if (ret)
+                       break;
+       }
+
+       reftable_log_record_release(&log);
+       reftable_iterator_destroy(&it);
+       return ret;
+}
+
+static int reftable_be_for_each_reflog_ent(struct ref_store *ref_store,
+                                          const char *refname,
+                                          each_reflog_ent_fn fn,
+                                          void *cb_data)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_READ, "for_each_reflog_ent");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct reftable_merged_table *mt = NULL;
+       struct reftable_log_record *logs = NULL;
+       struct reftable_iterator it = {0};
+       size_t logs_alloc = 0, logs_nr = 0, i;
+       int ret;
+
+       if (refs->err < 0)
+               return refs->err;
+
+       mt = reftable_stack_merged_table(stack);
+       ret = reftable_merged_table_seek_log(mt, &it, refname);
+       while (!ret) {
+               struct reftable_log_record log = {0};
+
+               ret = reftable_iterator_next_log(&it, &log);
+               if (ret < 0)
+                       goto done;
+               if (ret > 0 || strcmp(log.refname, refname)) {
+                       reftable_log_record_release(&log);
+                       ret = 0;
+                       break;
+               }
+
+               ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+               logs[logs_nr++] = log;
+       }
+
+       for (i = logs_nr; i--;) {
+               ret = yield_log_record(&logs[i], fn, cb_data);
+               if (ret)
+                       goto done;
+       }
+
+done:
+       reftable_iterator_destroy(&it);
+       for (i = 0; i < logs_nr; i++)
+               reftable_log_record_release(&logs[i]);
+       free(logs);
+       return ret;
+}
+
+static int reftable_be_reflog_exists(struct ref_store *ref_store,
+                                    const char *refname)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_READ, "reflog_exists");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct reftable_merged_table *mt = reftable_stack_merged_table(stack);
+       struct reftable_log_record log = {0};
+       struct reftable_iterator it = {0};
+       int ret;
+
+       ret = refs->err;
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_reload(stack);
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_merged_table_seek_log(mt, &it, refname);
+       if (ret < 0)
+               goto done;
+
+       /*
+        * Check whether we get at least one log record for the given ref name.
+        * If so, the reflog exists, otherwise it doesn't.
+        */
+       ret = reftable_iterator_next_log(&it, &log);
+       if (ret < 0)
+               goto done;
+       if (ret > 0) {
+               ret = 0;
+               goto done;
+       }
+
+       ret = strcmp(log.refname, refname) == 0;
+
+done:
+       reftable_iterator_destroy(&it);
+       reftable_log_record_release(&log);
+       if (ret < 0)
+               ret = 0;
+       return ret;
+}
+
+struct write_reflog_existence_arg {
+       struct reftable_ref_store *refs;
+       const char *refname;
+       struct reftable_stack *stack;
+};
+
+static int write_reflog_existence_table(struct reftable_writer *writer,
+                                       void *cb_data)
+{
+       struct write_reflog_existence_arg *arg = cb_data;
+       uint64_t ts = reftable_stack_next_update_index(arg->stack);
+       struct reftable_log_record log = {0};
+       int ret;
+
+       ret = reftable_stack_read_log(arg->stack, arg->refname, &log);
+       if (ret <= 0)
+               goto done;
+
+       reftable_writer_set_limits(writer, ts, ts);
+
+       /*
+        * The existence entry has both old and new object ID set to the the
+        * null object ID. Our iterators are aware of this and will not present
+        * them to their callers.
+        */
+       log.refname = xstrdup(arg->refname);
+       log.update_index = ts;
+       log.value_type = REFTABLE_LOG_UPDATE;
+       ret = reftable_writer_add_log(writer, &log);
+
+done:
+       assert(ret != REFTABLE_API_ERROR);
+       reftable_log_record_release(&log);
+       return ret;
+}
+
+static int reftable_be_create_reflog(struct ref_store *ref_store,
+                                    const char *refname,
+                                    struct strbuf *errmsg)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "create_reflog");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct write_reflog_existence_arg arg = {
+               .refs = refs,
+               .stack = stack,
+               .refname = refname,
+       };
+       int ret;
+
+       ret = refs->err;
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               goto done;
+
+       ret = reftable_stack_add(stack, &write_reflog_existence_table, &arg);
+
+done:
+       return ret;
+}
+
+struct write_reflog_delete_arg {
+       struct reftable_stack *stack;
+       const char *refname;
+};
+
+static int write_reflog_delete_table(struct reftable_writer *writer, void *cb_data)
+{
+       struct write_reflog_delete_arg *arg = cb_data;
+       struct reftable_merged_table *mt =
+               reftable_stack_merged_table(arg->stack);
+       struct reftable_log_record log = {0}, tombstone = {0};
+       struct reftable_iterator it = {0};
+       uint64_t ts = reftable_stack_next_update_index(arg->stack);
+       int ret;
+
+       reftable_writer_set_limits(writer, ts, ts);
+
+       /*
+        * In order to delete a table we need to delete all reflog entries one
+        * by one. This is inefficient, but the reftable format does not have a
+        * better marker right now.
+        */
+       ret = reftable_merged_table_seek_log(mt, &it, arg->refname);
+       while (ret == 0) {
+               ret = reftable_iterator_next_log(&it, &log);
+               if (ret < 0)
+                       break;
+               if (ret > 0 || strcmp(log.refname, arg->refname)) {
+                       ret = 0;
+                       break;
+               }
+
+               tombstone.refname = (char *)arg->refname;
+               tombstone.value_type = REFTABLE_LOG_DELETION;
+               tombstone.update_index = log.update_index;
+
+               ret = reftable_writer_add_log(writer, &tombstone);
+       }
+
+       reftable_log_record_release(&log);
+       reftable_iterator_destroy(&it);
+       return ret;
+}
+
+static int reftable_be_delete_reflog(struct ref_store *ref_store,
+                                    const char *refname)
+{
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "delete_reflog");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct write_reflog_delete_arg arg = {
+               .stack = stack,
+               .refname = refname,
+       };
+       int ret;
+
+       ret = reftable_stack_reload(stack);
+       if (ret)
+               return ret;
+       ret = reftable_stack_add(stack, &write_reflog_delete_table, &arg);
+
+       assert(ret != REFTABLE_API_ERROR);
+       return ret;
+}
+
+struct reflog_expiry_arg {
+       struct reftable_stack *stack;
+       struct reftable_log_record *records;
+       struct object_id update_oid;
+       const char *refname;
+       size_t len;
+};
+
+static int write_reflog_expiry_table(struct reftable_writer *writer, void *cb_data)
+{
+       struct reflog_expiry_arg *arg = cb_data;
+       uint64_t ts = reftable_stack_next_update_index(arg->stack);
+       uint64_t live_records = 0;
+       size_t i;
+       int ret;
+
+       for (i = 0; i < arg->len; i++)
+               if (arg->records[i].value_type == REFTABLE_LOG_UPDATE)
+                       live_records++;
+
+       reftable_writer_set_limits(writer, ts, ts);
+
+       if (!is_null_oid(&arg->update_oid)) {
+               struct reftable_ref_record ref = {0};
+               struct object_id peeled;
+
+               ref.refname = (char *)arg->refname;
+               ref.update_index = ts;
+
+               if (!peel_object(&arg->update_oid, &peeled)) {
+                       ref.value_type = REFTABLE_REF_VAL2;
+                       memcpy(ref.value.val2.target_value, peeled.hash, GIT_MAX_RAWSZ);
+                       memcpy(ref.value.val2.value, arg->update_oid.hash, GIT_MAX_RAWSZ);
+               } else {
+                       ref.value_type = REFTABLE_REF_VAL1;
+                       memcpy(ref.value.val1, arg->update_oid.hash, GIT_MAX_RAWSZ);
+               }
+
+               ret = reftable_writer_add_ref(writer, &ref);
+               if (ret < 0)
+                       return ret;
+       }
+
+       /*
+        * When there are no more entries left in the reflog we empty it
+        * completely, but write a placeholder reflog entry that indicates that
+        * the reflog still exists.
+        */
+       if (!live_records) {
+               struct reftable_log_record log = {
+                       .refname = (char *)arg->refname,
+                       .value_type = REFTABLE_LOG_UPDATE,
+                       .update_index = ts,
+               };
+
+               ret = reftable_writer_add_log(writer, &log);
+               if (ret)
+                       return ret;
+       }
+
+       for (i = 0; i < arg->len; i++) {
+               ret = reftable_writer_add_log(writer, &arg->records[i]);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
+static int reftable_be_reflog_expire(struct ref_store *ref_store,
+                                    const char *refname,
+                                    unsigned int flags,
+                                    reflog_expiry_prepare_fn prepare_fn,
+                                    reflog_expiry_should_prune_fn should_prune_fn,
+                                    reflog_expiry_cleanup_fn cleanup_fn,
+                                    void *policy_cb_data)
+{
+       /*
+        * For log expiry, we write tombstones for every single reflog entry
+        * that is to be expired. This means that the entries are still
+        * retrievable by delving into the stack, and expiring entries
+        * paradoxically takes extra memory. This memory is only reclaimed when
+        * compacting the reftable stack.
+        *
+        * It would be better if the refs backend supported an API that sets a
+        * criterion for all refs, passing the criterion to pack_refs().
+        *
+        * On the plus side, because we do the expiration per ref, we can easily
+        * insert the reflog existence dummies.
+        */
+       struct reftable_ref_store *refs =
+               reftable_be_downcast(ref_store, REF_STORE_WRITE, "reflog_expire");
+       struct reftable_stack *stack = stack_for(refs, refname, &refname);
+       struct reftable_merged_table *mt = reftable_stack_merged_table(stack);
+       struct reftable_log_record *logs = NULL;
+       struct reftable_log_record *rewritten = NULL;
+       struct reftable_ref_record ref_record = {0};
+       struct reftable_iterator it = {0};
+       struct reftable_addition *add = NULL;
+       struct reflog_expiry_arg arg = {0};
+       struct object_id oid = {0};
+       uint8_t *last_hash = NULL;
+       size_t logs_nr = 0, logs_alloc = 0, i;
+       int ret;
+
+       if (refs->err < 0)
+               return refs->err;
+
+       ret = reftable_stack_reload(stack);
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_merged_table_seek_log(mt, &it, refname);
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_new_addition(&add, stack);
+       if (ret < 0)
+               goto done;
+
+       ret = reftable_stack_read_ref(stack, refname, &ref_record);
+       if (ret < 0)
+               goto done;
+       if (reftable_ref_record_val1(&ref_record))
+               oidread(&oid, reftable_ref_record_val1(&ref_record));
+       prepare_fn(refname, &oid, policy_cb_data);
+
+       while (1) {
+               struct reftable_log_record log = {0};
+               struct object_id old_oid, new_oid;
+
+               ret = reftable_iterator_next_log(&it, &log);
+               if (ret < 0)
+                       goto done;
+               if (ret > 0 || strcmp(log.refname, refname)) {
+                       reftable_log_record_release(&log);
+                       break;
+               }
+
+               oidread(&old_oid, log.value.update.old_hash);
+               oidread(&new_oid, log.value.update.new_hash);
+
+               /*
+                * Skip over the reflog existence marker. We will add it back
+                * in when there are no live reflog records.
+                */
+               if (is_null_oid(&old_oid) && is_null_oid(&new_oid)) {
+                       reftable_log_record_release(&log);
+                       continue;
+               }
+
+               ALLOC_GROW(logs, logs_nr + 1, logs_alloc);
+               logs[logs_nr++] = log;
+       }
+
+       /*
+        * We need to rewrite all reflog entries according to the pruning
+        * callback function:
+        *
+        *   - If a reflog entry shall be pruned we mark the record for
+        *     deletion.
+        *
+        *   - Otherwise we may have to rewrite the chain of reflog entries so
+        *     that gaps created by just-deleted records get backfilled.
+        */
+       CALLOC_ARRAY(rewritten, logs_nr);
+       for (i = logs_nr; i--;) {
+               struct reftable_log_record *dest = &rewritten[i];
+               struct object_id old_oid, new_oid;
+
+               *dest = logs[i];
+               oidread(&old_oid, logs[i].value.update.old_hash);
+               oidread(&new_oid, logs[i].value.update.new_hash);
+
+               if (should_prune_fn(&old_oid, &new_oid, logs[i].value.update.email,
+                                   (timestamp_t)logs[i].value.update.time,
+                                   logs[i].value.update.tz_offset,
+                                   logs[i].value.update.message,
+                                   policy_cb_data)) {
+                       dest->value_type = REFTABLE_LOG_DELETION;
+               } else {
+                       if ((flags & EXPIRE_REFLOGS_REWRITE) && last_hash)
+                               dest->value.update.old_hash = last_hash;
+                       last_hash = logs[i].value.update.new_hash;
+               }
+       }
+
+       if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash &&
+           reftable_ref_record_val1(&ref_record))
+               oidread(&arg.update_oid, last_hash);
+
+       arg.records = rewritten;
+       arg.len = logs_nr;
+       arg.stack = stack,
+       arg.refname = refname,
+
+       ret = reftable_addition_add(add, &write_reflog_expiry_table, &arg);
+       if (ret < 0)
+               goto done;
+
+       /*
+        * Future improvement: we could skip writing records that were
+        * not changed.
+        */
+       if (!(flags & EXPIRE_REFLOGS_DRY_RUN))
+               ret = reftable_addition_commit(add);
+
+done:
+       if (add)
+               cleanup_fn(policy_cb_data);
+       assert(ret != REFTABLE_API_ERROR);
+
+       reftable_ref_record_release(&ref_record);
+       reftable_iterator_destroy(&it);
+       reftable_addition_destroy(add);
+       for (i = 0; i < logs_nr; i++)
+               reftable_log_record_release(&logs[i]);
+       free(logs);
+       free(rewritten);
+       return ret;
+}
+
+struct ref_storage_be refs_be_reftable = {
+       .name = "reftable",
+       .init = reftable_be_init,
+       .init_db = reftable_be_init_db,
+       .transaction_prepare = reftable_be_transaction_prepare,
+       .transaction_finish = reftable_be_transaction_finish,
+       .transaction_abort = reftable_be_transaction_abort,
+       .initial_transaction_commit = reftable_be_initial_transaction_commit,
+
+       .pack_refs = reftable_be_pack_refs,
+       .create_symref = reftable_be_create_symref,
+       .rename_ref = reftable_be_rename_ref,
+       .copy_ref = reftable_be_copy_ref,
+
+       .iterator_begin = reftable_be_iterator_begin,
+       .read_raw_ref = reftable_be_read_raw_ref,
+       .read_symbolic_ref = reftable_be_read_symbolic_ref,
+
+       .reflog_iterator_begin = reftable_be_reflog_iterator_begin,
+       .for_each_reflog_ent = reftable_be_for_each_reflog_ent,
+       .for_each_reflog_ent_reverse = reftable_be_for_each_reflog_ent_reverse,
+       .reflog_exists = reftable_be_reflog_exists,
+       .create_reflog = reftable_be_create_reflog,
+       .delete_reflog = reftable_be_delete_reflog,
+       .reflog_expire = reftable_be_reflog_expire,
+};
index f761e48028c4490e40728fd2879a7520297a0e41..0785aff941bdc2d84181651a48f35cfaaefaede9 100644 (file)
@@ -64,12 +64,11 @@ void free_names(char **a)
        reftable_free(a);
 }
 
-int names_length(char **names)
+size_t names_length(char **names)
 {
        char **p = names;
-       for (; *p; p++) {
-               /* empty */
-       }
+       while (*p)
+               p++;
        return p - names;
 }
 
@@ -89,17 +88,13 @@ void parse_names(char *buf, int size, char ***namesp)
                        next = end;
                }
                if (p < next) {
-                       if (names_len == names_cap) {
-                               names_cap = 2 * names_cap + 1;
-                               names = reftable_realloc(
-                                       names, names_cap * sizeof(*names));
-                       }
+                       REFTABLE_ALLOC_GROW(names, names_len + 1, names_cap);
                        names[names_len++] = xstrdup(p);
                }
                p = next + 1;
        }
 
-       names = reftable_realloc(names, (names_len + 1) * sizeof(*names));
+       REFTABLE_REALLOC_ARRAY(names, names_len + 1);
        names[names_len] = NULL;
        *namesp = names;
 }
index 096b36862b9f4ebf14be7c3074d6f86d5e92c22c..91f3533efee501faf3e461f7206dbc7a964da98e 100644 (file)
@@ -44,14 +44,27 @@ void parse_names(char *buf, int size, char ***namesp);
 int names_equal(char **a, char **b);
 
 /* returns the array size of a NULL-terminated array of strings. */
-int names_length(char **names);
+size_t names_length(char **names);
 
 /* Allocation routines; they invoke the functions set through
  * reftable_set_alloc() */
 void *reftable_malloc(size_t sz);
 void *reftable_realloc(void *p, size_t sz);
 void reftable_free(void *p);
-void *reftable_calloc(size_t sz);
+void *reftable_calloc(size_t nelem, size_t elsize);
+
+#define REFTABLE_ALLOC_ARRAY(x, alloc) (x) = reftable_malloc(st_mult(sizeof(*(x)), (alloc)))
+#define REFTABLE_CALLOC_ARRAY(x, alloc) (x) = reftable_calloc((alloc), sizeof(*(x)))
+#define REFTABLE_REALLOC_ARRAY(x, alloc) (x) = reftable_realloc((x), st_mult(sizeof(*(x)), (alloc)))
+#define REFTABLE_ALLOC_GROW(x, nr, alloc) \
+       do { \
+               if ((nr) > alloc) { \
+                       alloc = 2 * (alloc) + 1; \
+                       if (alloc < (nr)) \
+                               alloc = (nr); \
+                       REFTABLE_REALLOC_ARRAY(x, alloc); \
+               } \
+       } while (0)
 
 /* Find the longest shared prefix size of `a` and `b` */
 struct strbuf;
index 1df3d8a0f09671c74143e655cb2963adda872545..72eb73b3806d623010c0e224f4f8ce77d555ce43 100644 (file)
@@ -51,12 +51,7 @@ static int block_writer_register_restart(struct block_writer *w, int n,
        if (2 + 3 * rlen + n > w->block_size - w->next)
                return -1;
        if (is_restart) {
-               if (w->restart_len == w->restart_cap) {
-                       w->restart_cap = w->restart_cap * 2 + 1;
-                       w->restarts = reftable_realloc(
-                               w->restarts, sizeof(uint32_t) * w->restart_cap);
-               }
-
+               REFTABLE_ALLOC_GROW(w->restarts, w->restart_len + 1, w->restart_cap);
                w->restarts[w->restart_len++] = w->next;
        }
 
@@ -148,8 +143,10 @@ int block_writer_finish(struct block_writer *w)
                int block_header_skip = 4 + w->header_off;
                uLongf src_len = w->next - block_header_skip;
                uLongf dest_cap = src_len * 1.001 + 12;
+               uint8_t *compressed;
+
+               REFTABLE_ALLOC_ARRAY(compressed, dest_cap);
 
-               uint8_t *compressed = reftable_malloc(dest_cap);
                while (1) {
                        uLongf out_dest_len = dest_cap;
                        int zresult = compress2(compressed, &out_dest_len,
@@ -206,9 +203,9 @@ int block_reader_init(struct block_reader *br, struct reftable_block *block,
                uLongf dst_len = sz - block_header_skip; /* total size of dest
                                                            buffer. */
                uLongf src_len = block->len - block_header_skip;
-               /* Log blocks specify the *uncompressed* size in their header.
-                */
-               uncompressed = reftable_malloc(sz);
+
+               /* Log blocks specify the *uncompressed* size in their header. */
+               REFTABLE_ALLOC_ARRAY(uncompressed, sz);
 
                /* Copy over the block header verbatim. It's not compressed. */
                memcpy(uncompressed, block->data, block_header_skip);
@@ -342,8 +339,7 @@ int block_iter_next(struct block_iter *it, struct reftable_record *rec)
                return -1;
        string_view_consume(&in, n);
 
-       strbuf_reset(&it->last_key);
-       strbuf_addbuf(&it->last_key, &it->key);
+       strbuf_swap(&it->last_key, &it->key);
        it->next_off += start.len - in.len;
        return 0;
 }
@@ -385,23 +381,23 @@ int block_reader_seek(struct block_reader *br, struct block_iter *it,
                .key = *want,
                .r = br,
        };
-       struct reftable_record rec = reftable_new_record(block_reader_type(br));
-       int err = 0;
        struct block_iter next = BLOCK_ITER_INIT;
+       struct reftable_record rec;
+       int err = 0, i;
 
-       int i = binsearch(br->restart_count, &restart_key_less, &args);
        if (args.error) {
                err = REFTABLE_FORMAT_ERROR;
                goto done;
        }
 
-       it->br = br;
-       if (i > 0) {
-               i--;
-               it->next_off = block_reader_restart_offset(br, i);
-       } else {
+       i = binsearch(br->restart_count, &restart_key_less, &args);
+       if (i > 0)
+               it->next_off = block_reader_restart_offset(br, i - 1);
+       else
                it->next_off = br->header_off + 4;
-       }
+       it->br = br;
+
+       reftable_record_init(&rec, block_reader_type(br));
 
        /* We're looking for the last entry less/equal than the wanted key, so
           we have to go one entry too far and then back up.
index c00bbc8aed50f02d21ed06c046bed3c5d4c2f17f..e162c6e33fa00af4e2b3b653c0d6210aea57c803 100644 (file)
@@ -36,7 +36,7 @@ static void test_block_read_write(void)
        int j = 0;
        struct strbuf want = STRBUF_INIT;
 
-       block.data = reftable_calloc(block_size);
+       REFTABLE_CALLOC_ARRAY(block.data, block_size);
        block.len = block_size;
        block.source = malloc_block_source();
        block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
@@ -49,13 +49,11 @@ static void test_block_read_write(void)
 
        for (i = 0; i < N; i++) {
                char name[100];
-               uint8_t hash[GIT_SHA1_RAWSZ];
                snprintf(name, sizeof(name), "branch%02d", i);
-               memset(hash, i, sizeof(hash));
 
                rec.u.ref.refname = name;
                rec.u.ref.value_type = REFTABLE_REF_VAL1;
-               rec.u.ref.value.val1 = hash;
+               memset(rec.u.ref.value.val1, i, GIT_SHA1_RAWSZ);
 
                names[i] = xstrdup(name);
                n = block_writer_add(&bw, &rec);
index a1ea3044292ef2032485bad261ffa5ed178421bc..eeed254ba9c2da51177eb7ed81fbf16d17ba183b 100644 (file)
@@ -29,7 +29,7 @@ static int strbuf_read_block(void *v, struct reftable_block *dest, uint64_t off,
 {
        struct strbuf *b = v;
        assert(off + size <= b->len);
-       dest->data = reftable_calloc(size);
+       REFTABLE_CALLOC_ARRAY(dest->data, size);
        memcpy(dest->data, b->buf + off, size);
        dest->len = size;
        return size;
@@ -76,8 +76,8 @@ struct reftable_block_source malloc_block_source(void)
 }
 
 struct file_block_source {
-       int fd;
        uint64_t size;
+       unsigned char *data;
 };
 
 static uint64_t file_size(void *b)
@@ -87,19 +87,12 @@ static uint64_t file_size(void *b)
 
 static void file_return_block(void *b, struct reftable_block *dest)
 {
-       if (dest->len)
-               memset(dest->data, 0xff, dest->len);
-       reftable_free(dest->data);
 }
 
-static void file_close(void *b)
+static void file_close(void *v)
 {
-       int fd = ((struct file_block_source *)b)->fd;
-       if (fd > 0) {
-               close(fd);
-               ((struct file_block_source *)b)->fd = 0;
-       }
-
+       struct file_block_source *b = v;
+       munmap(b->data, b->size);
        reftable_free(b);
 }
 
@@ -108,9 +101,7 @@ static int file_read_block(void *v, struct reftable_block *dest, uint64_t off,
 {
        struct file_block_source *b = v;
        assert(off + size <= b->size);
-       dest->data = reftable_malloc(size);
-       if (pread_in_full(b->fd, dest->data, size, off) != size)
-               return -1;
+       dest->data = b->data + off;
        dest->len = size;
        return size;
 }
@@ -125,26 +116,26 @@ static struct reftable_block_source_vtable file_vtable = {
 int reftable_block_source_from_file(struct reftable_block_source *bs,
                                    const char *name)
 {
-       struct stat st = { 0 };
-       int err = 0;
-       int fd = open(name, O_RDONLY);
-       struct file_block_source *p = NULL;
+       struct file_block_source *p;
+       struct stat st;
+       int fd;
+
+       fd = open(name, O_RDONLY);
        if (fd < 0) {
-               if (errno == ENOENT) {
+               if (errno == ENOENT)
                        return REFTABLE_NOT_EXIST_ERROR;
-               }
                return -1;
        }
 
-       err = fstat(fd, &st);
-       if (err < 0) {
+       if (fstat(fd, &st) < 0) {
                close(fd);
                return REFTABLE_IO_ERROR;
        }
 
-       p = reftable_calloc(sizeof(struct file_block_source));
+       REFTABLE_CALLOC_ARRAY(p, 1);
        p->size = st.st_size;
-       p->fd = fd;
+       p->data = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+       close(fd);
 
        assert(!bs->ops);
        bs->ops = &file_vtable;
index a8d174c040658edda3d2c45a9df2f692aef41c9d..8b5ebf6183a97f3ea16a0773880ccd3b835ef68e 100644 (file)
@@ -160,8 +160,7 @@ int new_indexed_table_ref_iter(struct indexed_table_ref_iter **dest,
                               int oid_len, uint64_t *offsets, int offset_len)
 {
        struct indexed_table_ref_iter empty = INDEXED_TABLE_REF_ITER_INIT;
-       struct indexed_table_ref_iter *itr =
-               reftable_calloc(sizeof(struct indexed_table_ref_iter));
+       struct indexed_table_ref_iter *itr = reftable_calloc(1, sizeof(*itr));
        int err = 0;
 
        *itr = empty;
index 574394092d1c2241e794cda58564382a1e8b42dc..1aa6cd31b74954da9b1b5140cd350459c37c1378 100644 (file)
@@ -19,24 +19,23 @@ https://developers.google.com/open-source/licenses/bsd
 
 static int merged_iter_init(struct merged_iter *mi)
 {
-       int i = 0;
-       for (i = 0; i < mi->stack_len; i++) {
-               struct reftable_record rec = reftable_new_record(mi->typ);
-               int err = iterator_next(&mi->stack[i], &rec);
-               if (err < 0) {
+       for (size_t i = 0; i < mi->stack_len; i++) {
+               struct pq_entry e = {
+                       .index = i,
+               };
+               int err;
+
+               reftable_record_init(&e.rec, mi->typ);
+               err = iterator_next(&mi->stack[i], &e.rec);
+               if (err < 0)
                        return err;
-               }
-
                if (err > 0) {
                        reftable_iterator_destroy(&mi->stack[i]);
-                       reftable_record_release(&rec);
-               } else {
-                       struct pq_entry e = {
-                               .rec = rec,
-                               .index = i,
-                       };
-                       merged_iter_pqueue_add(&mi->pq, &e);
+                       reftable_record_release(&e.rec);
+                       continue;
                }
+
+               merged_iter_pqueue_add(&mi->pq, &e);
        }
 
        return 0;
@@ -45,24 +44,23 @@ static int merged_iter_init(struct merged_iter *mi)
 static void merged_iter_close(void *p)
 {
        struct merged_iter *mi = p;
-       int i = 0;
+
        merged_iter_pqueue_release(&mi->pq);
-       for (i = 0; i < mi->stack_len; i++) {
+       for (size_t i = 0; i < mi->stack_len; i++)
                reftable_iterator_destroy(&mi->stack[i]);
-       }
        reftable_free(mi->stack);
-       strbuf_release(&mi->key);
-       strbuf_release(&mi->entry_key);
 }
 
 static int merged_iter_advance_nonnull_subiter(struct merged_iter *mi,
                                               size_t idx)
 {
        struct pq_entry e = {
-               .rec = reftable_new_record(mi->typ),
                .index = idx,
        };
-       int err = iterator_next(&mi->stack[idx], &e.rec);
+       int err;
+
+       reftable_record_init(&e.rec, mi->typ);
+       err = iterator_next(&mi->stack[idx], &e.rec);
        if (err < 0)
                return err;
 
@@ -105,14 +103,19 @@ static int merged_iter_next_entry(struct merged_iter *mi,
          such a deployment, the loop below must be changed to collect all
          entries for the same key, and return new the newest one.
        */
-       reftable_record_key(&entry.rec, &mi->entry_key);
        while (!merged_iter_pqueue_is_empty(mi->pq)) {
                struct pq_entry top = merged_iter_pqueue_top(mi->pq);
-               int cmp = 0;
-
-               reftable_record_key(&top.rec, &mi->key);
+               int cmp;
+
+               /*
+                * When the next entry comes from the same queue as the current
+                * entry then it must by definition be larger. This avoids a
+                * comparison in the most common case.
+                */
+               if (top.index == entry.index)
+                       break;
 
-               cmp = strbuf_cmp(&mi->key, &mi->entry_key);
+               cmp = reftable_record_cmp(&top.rec, &entry.rec);
                if (cmp > 0)
                        break;
 
@@ -123,12 +126,12 @@ static int merged_iter_next_entry(struct merged_iter *mi,
                reftable_record_release(&top.rec);
        }
 
-       reftable_record_copy_from(rec, &entry.rec, hash_size(mi->hash_id));
+       reftable_record_release(rec);
+       *rec = entry.rec;
 
 done:
-       reftable_record_release(&entry.rec);
-       strbuf_release(&mi->entry_key);
-       strbuf_release(&mi->key);
+       if (err)
+               reftable_record_release(&entry.rec);
        return err;
 }
 
@@ -168,14 +171,14 @@ static void iterator_from_merged_iter(struct reftable_iterator *it,
 }
 
 int reftable_new_merged_table(struct reftable_merged_table **dest,
-                             struct reftable_table *stack, int n,
+                             struct reftable_table *stack, size_t n,
                              uint32_t hash_id)
 {
        struct reftable_merged_table *m = NULL;
        uint64_t last_max = 0;
        uint64_t first_min = 0;
-       int i = 0;
-       for (i = 0; i < n; i++) {
+
+       for (size_t i = 0; i < n; i++) {
                uint64_t min = reftable_table_min_update_index(&stack[i]);
                uint64_t max = reftable_table_max_update_index(&stack[i]);
 
@@ -190,7 +193,7 @@ int reftable_new_merged_table(struct reftable_merged_table **dest,
                }
        }
 
-       m = reftable_calloc(sizeof(struct reftable_merged_table));
+       REFTABLE_CALLOC_ARRAY(m, 1);
        m->stack = stack;
        m->stack_len = n;
        m->min = first_min;
@@ -239,50 +242,36 @@ static int merged_table_seek_record(struct reftable_merged_table *mt,
                                    struct reftable_iterator *it,
                                    struct reftable_record *rec)
 {
-       struct reftable_iterator *iters = reftable_calloc(
-               sizeof(struct reftable_iterator) * mt->stack_len);
        struct merged_iter merged = {
-               .stack = iters,
                .typ = reftable_record_type(rec),
                .hash_id = mt->hash_id,
                .suppress_deletions = mt->suppress_deletions,
-               .key = STRBUF_INIT,
-               .entry_key = STRBUF_INIT,
        };
-       int n = 0;
-       int err = 0;
-       int i = 0;
-       for (i = 0; i < mt->stack_len && err == 0; i++) {
-               int e = reftable_table_seek_record(&mt->stack[i], &iters[n],
-                                                  rec);
-               if (e < 0) {
-                       err = e;
-               }
-               if (e == 0) {
-                       n++;
-               }
-       }
-       if (err < 0) {
-               int i = 0;
-               for (i = 0; i < n; i++) {
-                       reftable_iterator_destroy(&iters[i]);
-               }
-               reftable_free(iters);
-               return err;
+       struct merged_iter *p;
+       int err;
+
+       REFTABLE_CALLOC_ARRAY(merged.stack, mt->stack_len);
+       for (size_t i = 0; i < mt->stack_len; i++) {
+               err = reftable_table_seek_record(&mt->stack[i],
+                                                &merged.stack[merged.stack_len], rec);
+               if (err < 0)
+                       goto out;
+               if (!err)
+                       merged.stack_len++;
        }
 
-       merged.stack_len = n;
        err = merged_iter_init(&merged);
-       if (err < 0) {
+       if (err < 0)
+               goto out;
+
+       p = reftable_malloc(sizeof(struct merged_iter));
+       *p = merged;
+       iterator_from_merged_iter(it, p);
+
+out:
+       if (err < 0)
                merged_iter_close(&merged);
-               return err;
-       } else {
-               struct merged_iter *p =
-                       reftable_malloc(sizeof(struct merged_iter));
-               *p = merged;
-               iterator_from_merged_iter(it, p);
-       }
-       return 0;
+       return err;
 }
 
 int reftable_merged_table_seek_ref(struct reftable_merged_table *mt,
index d5b39dfe7f1e3b54b5dc5e7ae46068155794986f..7d9f95d27ed0a44c4208e743b6b83ba4cdc5536c 100644 (file)
@@ -31,8 +31,6 @@ struct merged_iter {
        uint8_t typ;
        int suppress_deletions;
        struct merged_iter_pqueue pq;
-       struct strbuf key;
-       struct strbuf entry_key;
 };
 
 void merged_table_release(struct reftable_merged_table *mt);
index 0d6e0d4bf572f46683a1a9a3c6e1c128ed51f928..d0f77a3b8f51e0abb9af1162106c757d3fc3e553 100644 (file)
@@ -42,7 +42,7 @@ static void write_test_table(struct strbuf *buf,
                }
        }
 
-       w = reftable_new_writer(&strbuf_add_void, buf, &opts);
+       w = reftable_new_writer(&strbuf_add_void, &noop_flush, buf, &opts);
        reftable_writer_set_limits(w, min, max);
 
        for (i = 0; i < n; i++) {
@@ -70,7 +70,7 @@ static void write_test_log_table(struct strbuf *buf,
                .exact_log_message = 1,
        };
        struct reftable_writer *w = NULL;
-       w = reftable_new_writer(&strbuf_add_void, buf, &opts);
+       w = reftable_new_writer(&strbuf_add_void, &noop_flush, buf, &opts);
        reftable_writer_set_limits(w, update_index, update_index);
 
        for (i = 0; i < n; i++) {
@@ -88,16 +88,17 @@ static struct reftable_merged_table *
 merged_table_from_records(struct reftable_ref_record **refs,
                          struct reftable_block_source **source,
                          struct reftable_reader ***readers, int *sizes,
-                         struct strbuf *buf, int n)
+                         struct strbuf *buf, size_t n)
 {
-       int i = 0;
        struct reftable_merged_table *mt = NULL;
+       struct reftable_table *tabs;
        int err;
-       struct reftable_table *tabs =
-               reftable_calloc(n * sizeof(struct reftable_table));
-       *readers = reftable_calloc(n * sizeof(struct reftable_reader *));
-       *source = reftable_calloc(n * sizeof(**source));
-       for (i = 0; i < n; i++) {
+
+       REFTABLE_CALLOC_ARRAY(tabs, n);
+       REFTABLE_CALLOC_ARRAY(*readers, n);
+       REFTABLE_CALLOC_ARRAY(*source, n);
+
+       for (size_t i = 0; i < n; i++) {
                write_test_table(&buf[i], refs[i], sizes[i]);
                block_source_from_strbuf(&(*source)[i], &buf[i]);
 
@@ -122,13 +123,11 @@ static void readers_destroy(struct reftable_reader **readers, size_t n)
 
 static void test_merged_between(void)
 {
-       uint8_t hash1[GIT_SHA1_RAWSZ] = { 1, 2, 3, 0 };
-
        struct reftable_ref_record r1[] = { {
                .refname = "b",
                .update_index = 1,
                .value_type = REFTABLE_REF_VAL1,
-               .value.val1 = hash1,
+               .value.val1 = { 1, 2, 3, 0 },
        } };
        struct reftable_ref_record r2[] = { {
                .refname = "a",
@@ -164,26 +163,24 @@ static void test_merged_between(void)
 
 static void test_merged(void)
 {
-       uint8_t hash1[GIT_SHA1_RAWSZ] = { 1 };
-       uint8_t hash2[GIT_SHA1_RAWSZ] = { 2 };
        struct reftable_ref_record r1[] = {
                {
                        .refname = "a",
                        .update_index = 1,
                        .value_type = REFTABLE_REF_VAL1,
-                       .value.val1 = hash1,
+                       .value.val1 = { 1 },
                },
                {
                        .refname = "b",
                        .update_index = 1,
                        .value_type = REFTABLE_REF_VAL1,
-                       .value.val1 = hash1,
+                       .value.val1 = { 1 },
                },
                {
                        .refname = "c",
                        .update_index = 1,
                        .value_type = REFTABLE_REF_VAL1,
-                       .value.val1 = hash1,
+                       .value.val1 = { 1 },
                }
        };
        struct reftable_ref_record r2[] = { {
@@ -196,13 +193,13 @@ static void test_merged(void)
                        .refname = "c",
                        .update_index = 3,
                        .value_type = REFTABLE_REF_VAL1,
-                       .value.val1 = hash2,
+                       .value.val1 = { 2 },
                },
                {
                        .refname = "d",
                        .update_index = 3,
                        .value_type = REFTABLE_REF_VAL1,
-                       .value.val1 = hash1,
+                       .value.val1 = { 1 },
                },
        };
 
@@ -235,14 +232,10 @@ static void test_merged(void)
        while (len < 100) { /* cap loops/recursion. */
                struct reftable_ref_record ref = { NULL };
                int err = reftable_iterator_next_ref(&it, &ref);
-               if (err > 0) {
+               if (err > 0)
                        break;
-               }
-               if (len == cap) {
-                       cap = 2 * cap + 1;
-                       out = reftable_realloc(
-                               out, sizeof(struct reftable_ref_record) * cap);
-               }
+
+               REFTABLE_ALLOC_GROW(out, len + 1, cap);
                out[len++] = ref;
        }
        reftable_iterator_destroy(&it);
@@ -269,16 +262,17 @@ static struct reftable_merged_table *
 merged_table_from_log_records(struct reftable_log_record **logs,
                              struct reftable_block_source **source,
                              struct reftable_reader ***readers, int *sizes,
-                             struct strbuf *buf, int n)
+                             struct strbuf *buf, size_t n)
 {
-       int i = 0;
        struct reftable_merged_table *mt = NULL;
+       struct reftable_table *tabs;
        int err;
-       struct reftable_table *tabs =
-               reftable_calloc(n * sizeof(struct reftable_table));
-       *readers = reftable_calloc(n * sizeof(struct reftable_reader *));
-       *source = reftable_calloc(n * sizeof(**source));
-       for (i = 0; i < n; i++) {
+
+       REFTABLE_CALLOC_ARRAY(tabs, n);
+       REFTABLE_CALLOC_ARRAY(*readers, n);
+       REFTABLE_CALLOC_ARRAY(*source, n);
+
+       for (size_t i = 0; i < n; i++) {
                write_test_log_table(&buf[i], logs[i], sizes[i], i + 1);
                block_source_from_strbuf(&(*source)[i], &buf[i]);
 
@@ -372,14 +366,10 @@ static void test_merged_logs(void)
        while (len < 100) { /* cap loops/recursion. */
                struct reftable_log_record log = { NULL };
                int err = reftable_iterator_next_log(&it, &log);
-               if (err > 0) {
+               if (err > 0)
                        break;
-               }
-               if (len == cap) {
-                       cap = 2 * cap + 1;
-                       out = reftable_realloc(
-                               out, sizeof(struct reftable_log_record) * cap);
-               }
+
+               REFTABLE_ALLOC_GROW(out, len + 1, cap);
                out[len++] = log;
        }
        reftable_iterator_destroy(&it);
@@ -416,7 +406,7 @@ static void test_default_write_opts(void)
        struct reftable_write_options opts = { 0 };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
 
        struct reftable_ref_record rec = {
                .refname = "master",
@@ -424,7 +414,7 @@ static void test_default_write_opts(void)
        };
        int err;
        struct reftable_block_source source = { NULL };
-       struct reftable_table *tab = reftable_calloc(sizeof(*tab) * 1);
+       struct reftable_table *tab = reftable_calloc(1, sizeof(*tab));
        uint32_t hash_id;
        struct reftable_reader *rd = NULL;
        struct reftable_merged_table *merged = NULL;
index dcefeb793a9051b75a276732a32d88809bb86d94..e0ccce2b9779a8bfd1acac6d42bc7d0e46e3fe0e 100644 (file)
@@ -14,20 +14,9 @@ https://developers.google.com/open-source/licenses/bsd
 
 int pq_less(struct pq_entry *a, struct pq_entry *b)
 {
-       struct strbuf ak = STRBUF_INIT;
-       struct strbuf bk = STRBUF_INIT;
-       int cmp = 0;
-       reftable_record_key(&a->rec, &ak);
-       reftable_record_key(&b->rec, &bk);
-
-       cmp = strbuf_cmp(&ak, &bk);
-
-       strbuf_release(&ak);
-       strbuf_release(&bk);
-
+       int cmp = reftable_record_cmp(&a->rec, &b->rec);
        if (cmp == 0)
                return a->index > b->index;
-
        return cmp < 0;
 }
 
@@ -75,13 +64,9 @@ void merged_iter_pqueue_add(struct merged_iter_pqueue *pq, const struct pq_entry
 {
        int i = 0;
 
-       if (pq->len == pq->cap) {
-               pq->cap = 2 * pq->cap + 1;
-               pq->heap = reftable_realloc(pq->heap,
-                                           pq->cap * sizeof(struct pq_entry));
-       }
-
+       REFTABLE_ALLOC_GROW(pq->heap, pq->len + 1, pq->cap);
        pq->heap[pq->len++] = *e;
+
        i = pq->len - 1;
        while (i > 0) {
                int j = (i - 1) / 2;
index bcb82530d6ce35e8a0a582d9718090067b238899..44b84a125e43b3f0de9460b019854e22835d39e6 100644 (file)
@@ -37,8 +37,9 @@ void reftable_free(void *p)
                free(p);
 }
 
-void *reftable_calloc(size_t sz)
+void *reftable_calloc(size_t nelem, size_t elsize)
 {
+       size_t sz = st_mult(nelem, elsize);
        void *p = reftable_malloc(sz);
        memset(p, 0, sz);
        return p;
index 64dc366fb15935c55c5377ec9d4f1b74640cc3f6..b113daab77336c240d10f64ce9890ff04f5f366a 100644 (file)
@@ -357,24 +357,32 @@ static int table_iter_next(struct table_iter *ti, struct reftable_record *rec)
 
        while (1) {
                struct table_iter next = TABLE_ITER_INIT;
-               int err = 0;
-               if (ti->is_finished) {
+               int err;
+
+               if (ti->is_finished)
                        return 1;
-               }
 
+               /*
+                * Check whether the current block still has more records. If
+                * so, return it. If the iterator returns positive then the
+                * current block has been exhausted.
+                */
                err = table_iter_next_in_block(ti, rec);
-               if (err <= 0) {
+               if (err <= 0)
                        return err;
-               }
 
+               /*
+                * Otherwise, we need to continue to the next block in the
+                * table and retry. If there are no more blocks then the
+                * iterator is drained.
+                */
                err = table_iter_next_block(&next, ti);
-               if (err != 0) {
-                       ti->is_finished = 1;
-               }
                table_iter_block_done(ti);
-               if (err != 0) {
+               if (err) {
+                       ti->is_finished = 1;
                        return err;
                }
+
                table_iter_copy_from(ti, &next);
                block_iter_close(&next.bi);
        }
@@ -444,13 +452,13 @@ static int reader_start(struct reftable_reader *r, struct table_iter *ti,
 static int reader_seek_linear(struct table_iter *ti,
                              struct reftable_record *want)
 {
-       struct reftable_record rec =
-               reftable_new_record(reftable_record_type(want));
        struct strbuf want_key = STRBUF_INIT;
        struct strbuf got_key = STRBUF_INIT;
        struct table_iter next = TABLE_ITER_INIT;
+       struct reftable_record rec;
        int err = -1;
 
+       reftable_record_init(&rec, reftable_record_type(want));
        reftable_record_key(want, &want_key);
 
        while (1) {
@@ -508,8 +516,38 @@ static int reader_seek_indexed(struct reftable_reader *r,
        if (err < 0)
                goto done;
 
+       /*
+        * The index may consist of multiple levels, where each level may have
+        * multiple index blocks. We start by doing a linear search in the
+        * highest layer that identifies the relevant index block as well as
+        * the record inside that block that corresponds to our wanted key.
+        */
        err = reader_seek_linear(&index_iter, &want_index);
+       if (err < 0)
+               goto done;
+
+       /*
+        * Traverse down the levels until we find a non-index entry.
+        */
        while (1) {
+               /*
+                * In case we seek a record that does not exist the index iter
+                * will tell us that the iterator is over. This works because
+                * the last index entry of the current level will contain the
+                * last key it knows about. So in case our seeked key is larger
+                * than the last indexed key we know that it won't exist.
+                *
+                * There is one subtlety in the layout of the index section
+                * that makes this work as expected: the highest-level index is
+                * at end of the section and will point backwards and thus we
+                * start reading from the end of the index section, not the
+                * beginning.
+                *
+                * If that wasn't the case and the order was reversed then the
+                * linear seek would seek into the lower levels and traverse
+                * all levels of the index only to find out that the key does
+                * not exist.
+                */
                err = table_iter_next(&index_iter, &index_result);
                table_iter_block_done(&index_iter);
                if (err != 0)
@@ -539,8 +577,7 @@ static int reader_seek_indexed(struct reftable_reader *r,
 
        if (err == 0) {
                struct table_iter empty = TABLE_ITER_INIT;
-               struct table_iter *malloced =
-                       reftable_calloc(sizeof(struct table_iter));
+               struct table_iter *malloced = reftable_calloc(1, sizeof(*malloced));
                *malloced = empty;
                table_iter_copy_from(malloced, &next);
                iterator_from_table_iter(it, malloced);
@@ -635,8 +672,7 @@ void reader_close(struct reftable_reader *r)
 int reftable_new_reader(struct reftable_reader **p,
                        struct reftable_block_source *src, char const *name)
 {
-       struct reftable_reader *rd =
-               reftable_calloc(sizeof(struct reftable_reader));
+       struct reftable_reader *rd = reftable_calloc(1, sizeof(*rd));
        int err = init_reader(rd, src, name);
        if (err == 0) {
                *p = rd;
@@ -711,7 +747,7 @@ static int reftable_reader_refs_for_unindexed(struct reftable_reader *r,
                                              uint8_t *oid)
 {
        struct table_iter ti_empty = TABLE_ITER_INIT;
-       struct table_iter *ti = reftable_calloc(sizeof(struct table_iter));
+       struct table_iter *ti = reftable_calloc(1, sizeof(*ti));
        struct filtering_ref_iterator *filter = NULL;
        struct filtering_ref_iterator empty = FILTERING_REF_ITERATOR_INIT;
        int oid_len = hash_size(r->hash_id);
index 79cd4e4c28abc4dbbad43f219b11fe4c0b28e5c3..363fe0f998b91f72002f819c396893b8086dc992 100644 (file)
@@ -51,26 +51,25 @@ static void write_table(char ***names, struct strbuf *buf, int N,
                .hash_id = hash_id,
        };
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, buf, &opts);
        struct reftable_ref_record ref = { NULL };
        int i = 0, n;
        struct reftable_log_record log = { NULL };
        const struct reftable_stats *stats = NULL;
-       *names = reftable_calloc(sizeof(char *) * (N + 1));
+
+       REFTABLE_CALLOC_ARRAY(*names, N + 1);
+
        reftable_writer_set_limits(w, update_index, update_index);
        for (i = 0; i < N; i++) {
-               uint8_t hash[GIT_SHA256_RAWSZ] = { 0 };
                char name[100];
                int n;
 
-               set_test_hash(hash, i);
-
                snprintf(name, sizeof(name), "refs/heads/branch%02d", i);
 
                ref.refname = name;
                ref.update_index = update_index;
                ref.value_type = REFTABLE_REF_VAL1;
-               ref.value.val1 = hash;
+               set_test_hash(ref.value.val1, i);
                (*names)[i] = xstrdup(name);
 
                n = reftable_writer_add_ref(w, &ref);
@@ -133,7 +132,7 @@ static void test_log_buffer_size(void)
                                           .message = "commit: 9\n",
                                   } } };
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
 
        /* This tests buffer extension for log compression. Must use a random
           hash, to ensure that the compressed part is larger than the original.
@@ -174,7 +173,7 @@ static void test_log_overflow(void)
                                           .message = msg,
                                   } } };
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
 
        uint8_t hash1[GIT_SHA1_RAWSZ]  = {1}, hash2[GIT_SHA1_RAWSZ] = { 2 };
 
@@ -191,7 +190,7 @@ static void test_log_overflow(void)
 static void test_log_write_read(void)
 {
        int N = 2;
-       char **names = reftable_calloc(sizeof(char *) * (N + 1));
+       char **names = reftable_calloc(N + 1, sizeof(*names));
        int err;
        struct reftable_write_options opts = {
                .block_size = 256,
@@ -205,7 +204,7 @@ static void test_log_write_read(void)
        struct reftable_block_source source = { NULL };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        const struct reftable_stats *stats = NULL;
        reftable_writer_set_limits(w, 0, N);
        for (i = 0; i < N; i++) {
@@ -297,7 +296,7 @@ static void test_log_zlib_corruption(void)
        struct reftable_block_source source = { 0 };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        const struct reftable_stats *stats = NULL;
        uint8_t hash1[GIT_SHA1_RAWSZ] = { 1 };
        uint8_t hash2[GIT_SHA1_RAWSZ] = { 2 };
@@ -522,7 +521,7 @@ static void test_table_read_write_seek_index(void)
 static void test_table_refs_for(int indexed)
 {
        int N = 50;
-       char **want_names = reftable_calloc(sizeof(char *) * (N + 1));
+       char **want_names = reftable_calloc(N + 1, sizeof(*want_names));
        int want_names_len = 0;
        uint8_t want_hash[GIT_SHA1_RAWSZ];
 
@@ -538,7 +537,7 @@ static void test_table_refs_for(int indexed)
 
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
 
        struct reftable_iterator it = { NULL };
        int j;
@@ -549,8 +548,6 @@ static void test_table_refs_for(int indexed)
                uint8_t hash[GIT_SHA1_RAWSZ];
                char fill[51] = { 0 };
                char name[100];
-               uint8_t hash1[GIT_SHA1_RAWSZ];
-               uint8_t hash2[GIT_SHA1_RAWSZ];
                struct reftable_ref_record ref = { NULL };
 
                memset(hash, i, sizeof(hash));
@@ -560,11 +557,9 @@ static void test_table_refs_for(int indexed)
                name[40] = 0;
                ref.refname = name;
 
-               set_test_hash(hash1, i / 4);
-               set_test_hash(hash2, 3 + i / 4);
                ref.value_type = REFTABLE_REF_VAL2;
-               ref.value.val2.value = hash1;
-               ref.value.val2.target_value = hash2;
+               set_test_hash(ref.value.val2.value, i / 4);
+               set_test_hash(ref.value.val2.target_value, 3 + i / 4);
 
                /* 80 bytes / entry, so 3 entries per block. Yields 17
                 */
@@ -572,8 +567,8 @@ static void test_table_refs_for(int indexed)
                n = reftable_writer_add_ref(w, &ref);
                EXPECT(n == 0);
 
-               if (!memcmp(hash1, want_hash, GIT_SHA1_RAWSZ) ||
-                   !memcmp(hash2, want_hash, GIT_SHA1_RAWSZ)) {
+               if (!memcmp(ref.value.val2.value, want_hash, GIT_SHA1_RAWSZ) ||
+                   !memcmp(ref.value.val2.target_value, want_hash, GIT_SHA1_RAWSZ)) {
                        want_names[want_names_len++] = xstrdup(name);
                }
        }
@@ -635,7 +630,7 @@ static void test_write_empty_table(void)
        struct reftable_write_options opts = { 0 };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        struct reftable_block_source source = { NULL };
        struct reftable_reader *rd = NULL;
        struct reftable_ref_record rec = { NULL };
@@ -673,12 +668,11 @@ static void test_write_object_id_min_length(void)
        };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
-       uint8_t hash[GIT_SHA1_RAWSZ] = {42};
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        struct reftable_ref_record ref = {
                .update_index = 1,
                .value_type = REFTABLE_REF_VAL1,
-               .value.val1 = hash,
+               .value.val1 = {42},
        };
        int err;
        int i;
@@ -709,12 +703,11 @@ static void test_write_object_id_length(void)
        };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
-       uint8_t hash[GIT_SHA1_RAWSZ] = {42};
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        struct reftable_ref_record ref = {
                .update_index = 1,
                .value_type = REFTABLE_REF_VAL1,
-               .value.val1 = hash,
+               .value.val1 = {42},
        };
        int err;
        int i;
@@ -744,7 +737,7 @@ static void test_write_empty_key(void)
        struct reftable_write_options opts = { 0 };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        struct reftable_ref_record ref = {
                .refname = "",
                .update_index = 1,
@@ -767,7 +760,7 @@ static void test_write_key_order(void)
        struct reftable_write_options opts = { 0 };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        struct reftable_ref_record refs[2] = {
                {
                        .refname = "b",
@@ -797,6 +790,139 @@ static void test_write_key_order(void)
        strbuf_release(&buf);
 }
 
+static void test_write_multiple_indices(void)
+{
+       struct reftable_write_options opts = {
+               .block_size = 100,
+       };
+       struct strbuf writer_buf = STRBUF_INIT, buf = STRBUF_INIT;
+       struct reftable_block_source source = { 0 };
+       struct reftable_iterator it = { 0 };
+       const struct reftable_stats *stats;
+       struct reftable_writer *writer;
+       struct reftable_reader *reader;
+       int err, i;
+
+       writer = reftable_new_writer(&strbuf_add_void, &noop_flush, &writer_buf, &opts);
+       reftable_writer_set_limits(writer, 1, 1);
+       for (i = 0; i < 100; i++) {
+               struct reftable_ref_record ref = {
+                       .update_index = 1,
+                       .value_type = REFTABLE_REF_VAL1,
+                       .value.val1 = {i},
+               };
+
+               strbuf_reset(&buf);
+               strbuf_addf(&buf, "refs/heads/%04d", i);
+               ref.refname = buf.buf,
+
+               err = reftable_writer_add_ref(writer, &ref);
+               EXPECT_ERR(err);
+       }
+
+       for (i = 0; i < 100; i++) {
+               unsigned char hash[GIT_SHA1_RAWSZ] = {i};
+               struct reftable_log_record log = {
+                       .update_index = 1,
+                       .value_type = REFTABLE_LOG_UPDATE,
+                       .value.update = {
+                               .old_hash = hash,
+                               .new_hash = hash,
+                       },
+               };
+
+               strbuf_reset(&buf);
+               strbuf_addf(&buf, "refs/heads/%04d", i);
+               log.refname = buf.buf,
+
+               err = reftable_writer_add_log(writer, &log);
+               EXPECT_ERR(err);
+       }
+
+       reftable_writer_close(writer);
+
+       /*
+        * The written data should be sufficiently large to result in indices
+        * for each of the block types.
+        */
+       stats = reftable_writer_stats(writer);
+       EXPECT(stats->ref_stats.index_offset > 0);
+       EXPECT(stats->obj_stats.index_offset > 0);
+       EXPECT(stats->log_stats.index_offset > 0);
+
+       block_source_from_strbuf(&source, &writer_buf);
+       err = reftable_new_reader(&reader, &source, "filename");
+       EXPECT_ERR(err);
+
+       /*
+        * Seeking the log uses the log index now. In case there is any
+        * confusion regarding indices we would notice here.
+        */
+       err = reftable_reader_seek_log(reader, &it, "");
+       EXPECT_ERR(err);
+
+       reftable_iterator_destroy(&it);
+       reftable_writer_free(writer);
+       reftable_reader_free(reader);
+       strbuf_release(&writer_buf);
+       strbuf_release(&buf);
+}
+
+static void test_write_multi_level_index(void)
+{
+       struct reftable_write_options opts = {
+               .block_size = 100,
+       };
+       struct strbuf writer_buf = STRBUF_INIT, buf = STRBUF_INIT;
+       struct reftable_block_source source = { 0 };
+       struct reftable_iterator it = { 0 };
+       const struct reftable_stats *stats;
+       struct reftable_writer *writer;
+       struct reftable_reader *reader;
+       int err;
+
+       writer = reftable_new_writer(&strbuf_add_void, &noop_flush, &writer_buf, &opts);
+       reftable_writer_set_limits(writer, 1, 1);
+       for (size_t i = 0; i < 200; i++) {
+               struct reftable_ref_record ref = {
+                       .update_index = 1,
+                       .value_type = REFTABLE_REF_VAL1,
+                       .value.val1 = {i},
+               };
+
+               strbuf_reset(&buf);
+               strbuf_addf(&buf, "refs/heads/%03" PRIuMAX, (uintmax_t)i);
+               ref.refname = buf.buf,
+
+               err = reftable_writer_add_ref(writer, &ref);
+               EXPECT_ERR(err);
+       }
+       reftable_writer_close(writer);
+
+       /*
+        * The written refs should be sufficiently large to result in a
+        * multi-level index.
+        */
+       stats = reftable_writer_stats(writer);
+       EXPECT(stats->ref_stats.max_index_level == 2);
+
+       block_source_from_strbuf(&source, &writer_buf);
+       err = reftable_new_reader(&reader, &source, "filename");
+       EXPECT_ERR(err);
+
+       /*
+        * Seeking the last ref should work as expected.
+        */
+       err = reftable_reader_seek_ref(reader, &it, "refs/heads/199");
+       EXPECT_ERR(err);
+
+       reftable_iterator_destroy(&it);
+       reftable_writer_free(writer);
+       reftable_reader_free(reader);
+       strbuf_release(&writer_buf);
+       strbuf_release(&buf);
+}
+
 static void test_corrupt_table_empty(void)
 {
        struct strbuf buf = STRBUF_INIT;
@@ -846,5 +972,7 @@ int readwrite_test_main(int argc, const char *argv[])
        RUN_TEST(test_log_overflow);
        RUN_TEST(test_write_object_id_length);
        RUN_TEST(test_write_object_id_min_length);
+       RUN_TEST(test_write_multiple_indices);
+       RUN_TEST(test_write_multi_level_index);
        return 0;
 }
index fbaa1fbef56c52fed8391c7bcef2efd035eb588b..d6bb42e887423d95f2fcc1b2b146505ab4bef62a 100644 (file)
@@ -76,7 +76,7 @@ int reftable_is_block_type(uint8_t typ)
        return 0;
 }
 
-uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec)
+const unsigned char *reftable_ref_record_val1(const struct reftable_ref_record *rec)
 {
        switch (rec->value_type) {
        case REFTABLE_REF_VAL1:
@@ -88,7 +88,7 @@ uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec)
        }
 }
 
-uint8_t *reftable_ref_record_val2(const struct reftable_ref_record *rec)
+const unsigned char *reftable_ref_record_val2(const struct reftable_ref_record *rec)
 {
        switch (rec->value_type) {
        case REFTABLE_REF_VAL2:
@@ -219,13 +219,10 @@ static void reftable_ref_record_copy_from(void *rec, const void *src_rec,
        case REFTABLE_REF_DELETION:
                break;
        case REFTABLE_REF_VAL1:
-               ref->value.val1 = reftable_malloc(hash_size);
                memcpy(ref->value.val1, src->value.val1, hash_size);
                break;
        case REFTABLE_REF_VAL2:
-               ref->value.val2.value = reftable_malloc(hash_size);
                memcpy(ref->value.val2.value, src->value.val2.value, hash_size);
-               ref->value.val2.target_value = reftable_malloc(hash_size);
                memcpy(ref->value.val2.target_value,
                       src->value.val2.target_value, hash_size);
                break;
@@ -242,7 +239,7 @@ static char hexdigit(int c)
        return 'a' + (c - 10);
 }
 
-static void hex_format(char *dest, uint8_t *src, int hash_size)
+static void hex_format(char *dest, const unsigned char *src, int hash_size)
 {
        assert(hash_size > 0);
        if (src) {
@@ -299,11 +296,8 @@ void reftable_ref_record_release(struct reftable_ref_record *ref)
                reftable_free(ref->value.symref);
                break;
        case REFTABLE_REF_VAL2:
-               reftable_free(ref->value.val2.target_value);
-               reftable_free(ref->value.val2.value);
                break;
        case REFTABLE_REF_VAL1:
-               reftable_free(ref->value.val1);
                break;
        case REFTABLE_REF_DELETION:
                break;
@@ -383,10 +377,11 @@ static int reftable_ref_record_decode(void *rec, struct strbuf key,
 
        assert(hash_size > 0);
 
-       r->refname = reftable_realloc(r->refname, key.len + 1);
+       r->refname = reftable_malloc(key.len + 1);
        memcpy(r->refname, key.buf, key.len);
-       r->update_index = update_index;
        r->refname[key.len] = 0;
+
+       r->update_index = update_index;
        r->value_type = val_type;
        switch (val_type) {
        case REFTABLE_REF_VAL1:
@@ -394,7 +389,6 @@ static int reftable_ref_record_decode(void *rec, struct strbuf key,
                        return -1;
                }
 
-               r->value.val1 = reftable_malloc(hash_size);
                memcpy(r->value.val1, in.buf, hash_size);
                string_view_consume(&in, hash_size);
                break;
@@ -404,11 +398,9 @@ static int reftable_ref_record_decode(void *rec, struct strbuf key,
                        return -1;
                }
 
-               r->value.val2.value = reftable_malloc(hash_size);
                memcpy(r->value.val2.value, in.buf, hash_size);
                string_view_consume(&in, hash_size);
 
-               r->value.val2.target_value = reftable_malloc(hash_size);
                memcpy(r->value.val2.target_value, in.buf, hash_size);
                string_view_consume(&in, hash_size);
                break;
@@ -439,7 +431,6 @@ static int reftable_ref_record_is_deletion_void(const void *p)
                (const struct reftable_ref_record *)p);
 }
 
-
 static int reftable_ref_record_equal_void(const void *a,
                                          const void *b, int hash_size)
 {
@@ -448,6 +439,13 @@ static int reftable_ref_record_equal_void(const void *a,
        return reftable_ref_record_equal(ra, rb, hash_size);
 }
 
+static int reftable_ref_record_cmp_void(const void *_a, const void *_b)
+{
+       const struct reftable_ref_record *a = _a;
+       const struct reftable_ref_record *b = _b;
+       return strcmp(a->refname, b->refname);
+}
+
 static void reftable_ref_record_print_void(const void *rec,
                                           int hash_size)
 {
@@ -464,6 +462,7 @@ static struct reftable_record_vtable reftable_ref_record_vtable = {
        .release = &reftable_ref_record_release_void,
        .is_deletion = &reftable_ref_record_is_deletion_void,
        .equal = &reftable_ref_record_equal_void,
+       .cmp = &reftable_ref_record_cmp_void,
        .print = &reftable_ref_record_print_void,
 };
 
@@ -506,12 +505,13 @@ static void reftable_obj_record_copy_from(void *rec, const void *src_rec,
                (const struct reftable_obj_record *)src_rec;
 
        reftable_obj_record_release(obj);
-       obj->hash_prefix = reftable_malloc(src->hash_prefix_len);
+
+       REFTABLE_ALLOC_ARRAY(obj->hash_prefix, src->hash_prefix_len);
        obj->hash_prefix_len = src->hash_prefix_len;
        if (src->hash_prefix_len)
                memcpy(obj->hash_prefix, src->hash_prefix, obj->hash_prefix_len);
 
-       obj->offsets = reftable_malloc(src->offset_len * sizeof(uint64_t));
+       REFTABLE_ALLOC_ARRAY(obj->offsets, src->offset_len);
        obj->offset_len = src->offset_len;
        COPY_ARRAY(obj->offsets, src->offsets, src->offset_len);
 }
@@ -568,7 +568,8 @@ static int reftable_obj_record_decode(void *rec, struct strbuf key,
        int n = 0;
        uint64_t last;
        int j;
-       r->hash_prefix = reftable_malloc(key.len);
+
+       REFTABLE_ALLOC_ARRAY(r->hash_prefix, key.len);
        memcpy(r->hash_prefix, key.buf, key.len);
        r->hash_prefix_len = key.len;
 
@@ -586,7 +587,7 @@ static int reftable_obj_record_decode(void *rec, struct strbuf key,
        if (count == 0)
                return start.len - in.len;
 
-       r->offsets = reftable_malloc(count * sizeof(uint64_t));
+       REFTABLE_ALLOC_ARRAY(r->offsets, count);
        r->offset_len = count;
 
        n = get_var_int(&r->offsets[0], &in);
@@ -634,6 +635,25 @@ static int reftable_obj_record_equal_void(const void *a, const void *b, int hash
        return 1;
 }
 
+static int reftable_obj_record_cmp_void(const void *_a, const void *_b)
+{
+       const struct reftable_obj_record *a = _a;
+       const struct reftable_obj_record *b = _b;
+       int cmp;
+
+       cmp = memcmp(a->hash_prefix, b->hash_prefix,
+                    a->hash_prefix_len > b->hash_prefix_len ?
+                    a->hash_prefix_len : b->hash_prefix_len);
+       if (cmp)
+               return cmp;
+
+       /*
+        * When the prefix is the same then the object record that is longer is
+        * considered to be bigger.
+        */
+       return a->hash_prefix_len - b->hash_prefix_len;
+}
+
 static struct reftable_record_vtable reftable_obj_record_vtable = {
        .key = &reftable_obj_record_key,
        .type = BLOCK_TYPE_OBJ,
@@ -644,6 +664,7 @@ static struct reftable_record_vtable reftable_obj_record_vtable = {
        .release = &reftable_obj_record_release,
        .is_deletion = &not_a_deletion,
        .equal = &reftable_obj_record_equal_void,
+       .cmp = &reftable_obj_record_cmp_void,
        .print = &reftable_obj_record_print,
 };
 
@@ -724,12 +745,12 @@ static void reftable_log_record_copy_from(void *rec, const void *src_rec,
                }
 
                if (dst->value.update.new_hash) {
-                       dst->value.update.new_hash = reftable_malloc(hash_size);
+                       REFTABLE_ALLOC_ARRAY(dst->value.update.new_hash, hash_size);
                        memcpy(dst->value.update.new_hash,
                               src->value.update.new_hash, hash_size);
                }
                if (dst->value.update.old_hash) {
-                       dst->value.update.old_hash = reftable_malloc(hash_size);
+                       REFTABLE_ALLOC_ARRAY(dst->value.update.old_hash, hash_size);
                        memcpy(dst->value.update.old_hash,
                               src->value.update.old_hash, hash_size);
                }
@@ -962,6 +983,22 @@ static int reftable_log_record_equal_void(const void *a,
                                         hash_size);
 }
 
+static int reftable_log_record_cmp_void(const void *_a, const void *_b)
+{
+       const struct reftable_log_record *a = _a;
+       const struct reftable_log_record *b = _b;
+       int cmp = strcmp(a->refname, b->refname);
+       if (cmp)
+               return cmp;
+
+       /*
+        * Note that the comparison here is reversed. This is because the
+        * update index is reversed when comparing keys. For reference, see how
+        * we handle this in reftable_log_record_key()`.
+        */
+       return b->update_index - a->update_index;
+}
+
 int reftable_log_record_equal(const struct reftable_log_record *a,
                              const struct reftable_log_record *b, int hash_size)
 {
@@ -1011,6 +1048,7 @@ static struct reftable_record_vtable reftable_log_record_vtable = {
        .release = &reftable_log_record_release_void,
        .is_deletion = &reftable_log_record_is_deletion_void,
        .equal = &reftable_log_record_equal_void,
+       .cmp = &reftable_log_record_cmp_void,
        .print = &reftable_log_record_print_void,
 };
 
@@ -1086,6 +1124,13 @@ static int reftable_index_record_equal(const void *a, const void *b, int hash_si
        return ia->offset == ib->offset && !strbuf_cmp(&ia->last_key, &ib->last_key);
 }
 
+static int reftable_index_record_cmp(const void *_a, const void *_b)
+{
+       const struct reftable_index_record *a = _a;
+       const struct reftable_index_record *b = _b;
+       return strbuf_cmp(&a->last_key, &b->last_key);
+}
+
 static void reftable_index_record_print(const void *rec, int hash_size)
 {
        const struct reftable_index_record *idx = rec;
@@ -1103,6 +1148,7 @@ static struct reftable_record_vtable reftable_index_record_vtable = {
        .release = &reftable_index_record_release,
        .is_deletion = &not_a_deletion,
        .equal = &reftable_index_record_equal,
+       .cmp = &reftable_index_record_cmp,
        .print = &reftable_index_record_print,
 };
 
@@ -1156,6 +1202,14 @@ int reftable_record_is_deletion(struct reftable_record *rec)
                reftable_record_data(rec));
 }
 
+int reftable_record_cmp(struct reftable_record *a, struct reftable_record *b)
+{
+       if (a->type != b->type)
+               BUG("cannot compare reftable records of different type");
+       return reftable_record_vtable(a)->cmp(
+               reftable_record_data(a), reftable_record_data(b));
+}
+
 int reftable_record_equal(struct reftable_record *a, struct reftable_record *b, int hash_size)
 {
        if (a->type != b->type)
@@ -1164,7 +1218,7 @@ int reftable_record_equal(struct reftable_record *a, struct reftable_record *b,
                reftable_record_data(a), reftable_record_data(b), hash_size);
 }
 
-static int hash_equal(uint8_t *a, uint8_t *b, int hash_size)
+static int hash_equal(const unsigned char *a, const unsigned char *b, int hash_size)
 {
        if (a && b)
                return !memcmp(a, b, hash_size);
@@ -1266,45 +1320,22 @@ reftable_record_vtable(struct reftable_record *rec)
        abort();
 }
 
-struct reftable_record reftable_new_record(uint8_t typ)
+void reftable_record_init(struct reftable_record *rec, uint8_t typ)
 {
-       struct reftable_record clean = {
-               .type = typ,
-       };
+       memset(rec, 0, sizeof(*rec));
+       rec->type = typ;
 
-       /* the following is involved, but the naive solution (just return
-        * `clean` as is, except for BLOCK_TYPE_INDEX), returns a garbage
-        * clean.u.obj.offsets pointer on Windows VS CI.  Go figure.
-        */
        switch (typ) {
-       case BLOCK_TYPE_OBJ:
-       {
-               struct reftable_obj_record obj = { 0 };
-               clean.u.obj = obj;
-               break;
-       }
-       case BLOCK_TYPE_INDEX:
-       {
-               struct reftable_index_record idx = {
-                       .last_key = STRBUF_INIT,
-               };
-               clean.u.idx = idx;
-               break;
-       }
        case BLOCK_TYPE_REF:
-       {
-               struct reftable_ref_record ref = { 0 };
-               clean.u.ref = ref;
-               break;
-       }
        case BLOCK_TYPE_LOG:
-       {
-               struct reftable_log_record log = { 0 };
-               clean.u.log = log;
-               break;
-       }
+       case BLOCK_TYPE_OBJ:
+               return;
+       case BLOCK_TYPE_INDEX:
+               strbuf_init(&rec->u.idx.last_key, 0);
+               return;
+       default:
+               BUG("unhandled record type");
        }
-       return clean;
 }
 
 void reftable_record_print(struct reftable_record *rec, int hash_size)
index fd80cd451d5d4c3ffea93d5bb1c7a0014531fae9..a05e2be17971d5e26f27871159cda293aa2640ad 100644 (file)
@@ -62,6 +62,12 @@ struct reftable_record_vtable {
        /* Are two records equal? This assumes they have the same type. Returns 0 for non-equal. */
        int (*equal)(const void *a, const void *b, int hash_size);
 
+       /*
+        * Compare keys of two records with each other. The records must have
+        * the same type.
+        */
+       int (*cmp)(const void *a, const void *b);
+
        /* Print on stdout, for debugging. */
        void (*print)(const void *rec, int hash_size);
 };
@@ -69,9 +75,6 @@ struct reftable_record_vtable {
 /* returns true for recognized block types. Block start with the block type. */
 int reftable_is_block_type(uint8_t typ);
 
-/* return an initialized record for the given type */
-struct reftable_record reftable_new_record(uint8_t typ);
-
 /* Encode `key` into `dest`. Sets `is_restart` to indicate a restart. Returns
  * number of bytes written. */
 int reftable_encode_key(int *is_restart, struct string_view dest,
@@ -100,8 +103,8 @@ struct reftable_obj_record {
 /* record is a generic wrapper for different types of records. It is normally
  * created on the stack, or embedded within another struct. If the type is
  * known, a fresh instance can be initialized explicitly. Otherwise, use
- * reftable_new_record() to initialize generically (as the index_record is not
- * valid as 0-initialized structure)
+ * `reftable_record_init()` to initialize generically (as the index_record is
+ * not valid as 0-initialized structure)
  */
 struct reftable_record {
        uint8_t type;
@@ -113,7 +116,11 @@ struct reftable_record {
        } u;
 };
 
+/* Initialize the reftable record for the given type */
+void reftable_record_init(struct reftable_record *rec, uint8_t typ);
+
 /* see struct record_vtable */
+int reftable_record_cmp(struct reftable_record *a, struct reftable_record *b);
 int reftable_record_equal(struct reftable_record *a, struct reftable_record *b, int hash_size);
 void reftable_record_print(struct reftable_record *rec, int hash_size);
 void reftable_record_key(struct reftable_record *rec, struct strbuf *dest);
index 70ae78feca4f11cdb50f4fdcb08d90118bf487df..a86cff552661ba0f00be32200bf8b0c800a9fa87 100644 (file)
 
 static void test_copy(struct reftable_record *rec)
 {
-       struct reftable_record copy = { 0 };
+       struct reftable_record copy;
        uint8_t typ;
 
        typ = reftable_record_type(rec);
-       copy = reftable_new_record(typ);
+       reftable_record_init(&copy, typ);
        reftable_record_copy_from(&copy, rec, GIT_SHA1_RAWSZ);
        /* do it twice to catch memory leaks */
        reftable_record_copy_from(&copy, rec, GIT_SHA1_RAWSZ);
@@ -119,15 +119,10 @@ static void test_reftable_ref_record_roundtrip(void)
                case REFTABLE_REF_DELETION:
                        break;
                case REFTABLE_REF_VAL1:
-                       in.u.ref.value.val1 = reftable_malloc(GIT_SHA1_RAWSZ);
                        set_hash(in.u.ref.value.val1, 1);
                        break;
                case REFTABLE_REF_VAL2:
-                       in.u.ref.value.val2.value =
-                               reftable_malloc(GIT_SHA1_RAWSZ);
                        set_hash(in.u.ref.value.val2.value, 1);
-                       in.u.ref.value.val2.target_value =
-                               reftable_malloc(GIT_SHA1_RAWSZ);
                        set_hash(in.u.ref.value.val2.target_value, 2);
                        break;
                case REFTABLE_REF_SYMREF:
@@ -236,8 +231,8 @@ static void test_reftable_log_record_roundtrip(void)
                                .value_type = REFTABLE_LOG_UPDATE,
                                .value = {
                                        .update = {
-                                               .new_hash = reftable_calloc(GIT_SHA1_RAWSZ),
-                                               .old_hash = reftable_calloc(GIT_SHA1_RAWSZ),
+                                               .new_hash = reftable_calloc(GIT_SHA1_RAWSZ, 1),
+                                               .old_hash = reftable_calloc(GIT_SHA1_RAWSZ, 1),
                                                .name = xstrdup("old name"),
                                                .email = xstrdup("old@email"),
                                                .message = xstrdup("old message"),
index 957349693247ae34c0b248a130e1e97f83ba1a71..7570e4acf9eec740057a4c6ba8a615878f48799f 100644 (file)
@@ -140,8 +140,8 @@ int validate_ref_record_addition(struct reftable_table tab,
 {
        struct modification mod = {
                .tab = tab,
-               .add = reftable_calloc(sizeof(char *) * sz),
-               .del = reftable_calloc(sizeof(char *) * sz),
+               .add = reftable_calloc(sz, sizeof(*mod.add)),
+               .del = reftable_calloc(sz, sizeof(*mod.del)),
        };
        int i = 0;
        int err = 0;
index 699e1aea4122d66a8a00451521f7d902858474c2..b9cc62554ea1569a66e8fc08be40e04452e3032c 100644 (file)
@@ -30,7 +30,7 @@ static void test_conflict(void)
        struct reftable_write_options opts = { 0 };
        struct strbuf buf = STRBUF_INIT;
        struct reftable_writer *w =
-               reftable_new_writer(&strbuf_add_void, &buf, &opts);
+               reftable_new_writer(&strbuf_add_void, &noop_flush, &buf, &opts);
        struct reftable_ref_record rec = {
                .refname = "a/b",
                .value_type = REFTABLE_REF_SYMREF,
index 1a6d16915ab453b480f0ca657448034a11ddf6be..c91a2d83a2b8a956e4b2d4999b4548ed1860269b 100644 (file)
@@ -33,7 +33,7 @@ struct reftable_table;
    the stack array.
 */
 int reftable_new_merged_table(struct reftable_merged_table **dest,
-                             struct reftable_table *stack, int n,
+                             struct reftable_table *stack, size_t n,
                              uint32_t hash_id);
 
 /* returns an iterator positioned just before 'name' */
index 67104f8fbfecd7984127d29dd1ae3fa9bb263394..bb6e99acd3151ec75a7a2dc60e930064b7322e60 100644 (file)
@@ -9,6 +9,7 @@ https://developers.google.com/open-source/licenses/bsd
 #ifndef REFTABLE_RECORD_H
 #define REFTABLE_RECORD_H
 
+#include "hash-ll.h"
 #include <stdint.h>
 
 /*
@@ -38,10 +39,10 @@ struct reftable_ref_record {
 #define REFTABLE_NR_REF_VALUETYPES 4
        } value_type;
        union {
-               uint8_t *val1; /* malloced hash. */
+               unsigned char val1[GIT_MAX_RAWSZ];
                struct {
-                       uint8_t *value; /* first value, malloced hash  */
-                       uint8_t *target_value; /* second value, malloced hash */
+                       unsigned char value[GIT_MAX_RAWSZ]; /* first hash  */
+                       unsigned char target_value[GIT_MAX_RAWSZ]; /* second hash */
                } val2;
                char *symref; /* referent, malloced 0-terminated string */
        } value;
@@ -49,11 +50,11 @@ struct reftable_ref_record {
 
 /* Returns the first hash, or NULL if `rec` is not of type
  * REFTABLE_REF_VAL1 or REFTABLE_REF_VAL2. */
-uint8_t *reftable_ref_record_val1(const struct reftable_ref_record *rec);
+const unsigned char *reftable_ref_record_val1(const struct reftable_ref_record *rec);
 
 /* Returns the second hash, or NULL if `rec` is not of type
  * REFTABLE_REF_VAL2. */
-uint8_t *reftable_ref_record_val2(const struct reftable_ref_record *rec);
+const unsigned char *reftable_ref_record_val2(const struct reftable_ref_record *rec);
 
 /* returns whether 'ref' represents a deletion */
 int reftable_ref_record_is_deletion(const struct reftable_ref_record *ref);
index db8de197f6c42a0de203fc1fbca8174f7f4d2938..7c7cae5f99b7cd4c2be74707bb550366e1088a35 100644 (file)
@@ -88,6 +88,7 @@ struct reftable_stats {
 /* reftable_new_writer creates a new writer */
 struct reftable_writer *
 reftable_new_writer(ssize_t (*writer_func)(void *, const void *, size_t),
+                   int (*flush_func)(void *),
                    void *writer_arg, struct reftable_write_options *opts);
 
 /* Set the range of update indices for the records we will add. When writing a
index 16bab82063d2b3e228abe05b3a8a26ffd310767c..b64e55648aa8798054bb7b8a781376e7fa3bc2af 100644 (file)
@@ -8,6 +8,7 @@ https://developers.google.com/open-source/licenses/bsd
 
 #include "stack.h"
 
+#include "../write-or-die.h"
 #include "system.h"
 #include "merged.h"
 #include "reader.h"
@@ -16,7 +17,6 @@ https://developers.google.com/open-source/licenses/bsd
 #include "reftable-record.h"
 #include "reftable-merged.h"
 #include "writer.h"
-
 #include "tempfile.h"
 
 static int stack_try_add(struct reftable_stack *st,
@@ -24,7 +24,8 @@ static int stack_try_add(struct reftable_stack *st,
                                            void *arg),
                         void *arg);
 static int stack_write_compact(struct reftable_stack *st,
-                              struct reftable_writer *wr, int first, int last,
+                              struct reftable_writer *wr,
+                              size_t first, size_t last,
                               struct reftable_log_expiry_config *config);
 static int stack_check_addition(struct reftable_stack *st,
                                const char *new_tab_name);
@@ -47,11 +48,17 @@ static ssize_t reftable_fd_write(void *arg, const void *data, size_t sz)
        return write_in_full(*fdp, data, sz);
 }
 
+static int reftable_fd_flush(void *arg)
+{
+       int *fdp = (int *)arg;
+
+       return fsync_component(FSYNC_COMPONENT_REFERENCE, *fdp);
+}
+
 int reftable_new_stack(struct reftable_stack **dest, const char *dir,
                       struct reftable_write_options config)
 {
-       struct reftable_stack *p =
-               reftable_calloc(sizeof(struct reftable_stack));
+       struct reftable_stack *p = reftable_calloc(1, sizeof(*p));
        struct strbuf list_file_name = STRBUF_INIT;
        int err = 0;
 
@@ -66,6 +73,7 @@ int reftable_new_stack(struct reftable_stack **dest, const char *dir,
        strbuf_addstr(&list_file_name, "/tables.list");
 
        p->list_file = strbuf_detach(&list_file_name, NULL);
+       p->list_fd = -1;
        p->reftable_dir = xstrdup(dir);
        p->config = config;
 
@@ -93,7 +101,7 @@ static int fd_read_lines(int fd, char ***namesp)
                goto done;
        }
 
-       buf = reftable_malloc(size + 1);
+       REFTABLE_ALLOC_ARRAY(buf, size + 1);
        if (read_in_full(fd, buf, size) != size) {
                err = REFTABLE_IO_ERROR;
                goto done;
@@ -113,7 +121,7 @@ int read_lines(const char *filename, char ***namesp)
        int err = 0;
        if (fd < 0) {
                if (errno == ENOENT) {
-                       *namesp = reftable_calloc(sizeof(char *));
+                       REFTABLE_CALLOC_ARRAY(*namesp, 1);
                        return 0;
                }
 
@@ -175,6 +183,12 @@ void reftable_stack_destroy(struct reftable_stack *st)
                st->readers_len = 0;
                FREE_AND_NULL(st->readers);
        }
+
+       if (st->list_fd >= 0) {
+               close(st->list_fd);
+               st->list_fd = -1;
+       }
+
        FREE_AND_NULL(st->list_file);
        FREE_AND_NULL(st->reftable_dir);
        reftable_free(st);
@@ -184,8 +198,7 @@ void reftable_stack_destroy(struct reftable_stack *st)
 static struct reftable_reader **stack_copy_readers(struct reftable_stack *st,
                                                   int cur_len)
 {
-       struct reftable_reader **cur =
-               reftable_calloc(sizeof(struct reftable_reader *) * cur_len);
+       struct reftable_reader **cur = reftable_calloc(cur_len, sizeof(*cur));
        int i = 0;
        for (i = 0; i < cur_len; i++) {
                cur[i] = st->readers[i];
@@ -196,18 +209,18 @@ static struct reftable_reader **stack_copy_readers(struct reftable_stack *st,
 static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
                                      int reuse_open)
 {
-       int cur_len = !st->merged ? 0 : st->merged->stack_len;
+       size_t cur_len = !st->merged ? 0 : st->merged->stack_len;
        struct reftable_reader **cur = stack_copy_readers(st, cur_len);
-       int err = 0;
-       int names_len = names_length(names);
+       size_t names_len = names_length(names);
        struct reftable_reader **new_readers =
-               reftable_calloc(sizeof(struct reftable_reader *) * names_len);
+               reftable_calloc(names_len, sizeof(*new_readers));
        struct reftable_table *new_tables =
-               reftable_calloc(sizeof(struct reftable_table) * names_len);
-       int new_readers_len = 0;
+               reftable_calloc(names_len, sizeof(*new_tables));
+       size_t new_readers_len = 0;
        struct reftable_merged_table *new_merged = NULL;
        struct strbuf table_path = STRBUF_INIT;
-       int i;
+       int err = 0;
+       size_t i;
 
        while (*names) {
                struct reftable_reader *rd = NULL;
@@ -215,11 +228,10 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
 
                /* this is linear; we assume compaction keeps the number of
                   tables under control so this is not quadratic. */
-               int j = 0;
-               for (j = 0; reuse_open && j < cur_len; j++) {
-                       if (cur[j] && 0 == strcmp(cur[j]->name, name)) {
-                               rd = cur[j];
-                               cur[j] = NULL;
+               for (i = 0; reuse_open && i < cur_len; i++) {
+                       if (cur[i] && 0 == strcmp(cur[i]->name, name)) {
+                               rd = cur[i];
+                               cur[i] = NULL;
                                break;
                        }
                }
@@ -304,69 +316,134 @@ static int tv_cmp(struct timeval *a, struct timeval *b)
 static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
                                             int reuse_open)
 {
-       struct timeval deadline = { 0 };
-       int err = gettimeofday(&deadline, NULL);
+       char **names = NULL, **names_after = NULL;
+       struct timeval deadline;
        int64_t delay = 0;
-       int tries = 0;
-       if (err < 0)
-               return err;
+       int tries = 0, err;
+       int fd = -1;
 
+       err = gettimeofday(&deadline, NULL);
+       if (err < 0)
+               goto out;
        deadline.tv_sec += 3;
+
        while (1) {
-               char **names = NULL;
-               char **names_after = NULL;
-               struct timeval now = { 0 };
-               int err = gettimeofday(&now, NULL);
-               int err2 = 0;
-               if (err < 0) {
-                       return err;
-               }
+               struct timeval now;
+
+               err = gettimeofday(&now, NULL);
+               if (err < 0)
+                       goto out;
 
-               /* Only look at deadlines after the first few times. This
-                  simplifies debugging in GDB */
+               /*
+                * Only look at deadlines after the first few times. This
+                * simplifies debugging in GDB.
+                */
                tries++;
-               if (tries > 3 && tv_cmp(&now, &deadline) >= 0) {
-                       break;
-               }
+               if (tries > 3 && tv_cmp(&now, &deadline) >= 0)
+                       goto out;
 
-               err = read_lines(st->list_file, &names);
-               if (err < 0) {
-                       free_names(names);
-                       return err;
-               }
-               err = reftable_stack_reload_once(st, names, reuse_open);
-               if (err == 0) {
-                       free_names(names);
-                       break;
-               }
-               if (err != REFTABLE_NOT_EXIST_ERROR) {
-                       free_names(names);
-                       return err;
-               }
+               fd = open(st->list_file, O_RDONLY);
+               if (fd < 0) {
+                       if (errno != ENOENT) {
+                               err = REFTABLE_IO_ERROR;
+                               goto out;
+                       }
 
-               /* err == REFTABLE_NOT_EXIST_ERROR can be caused by a concurrent
-                  writer. Check if there was one by checking if the name list
-                  changed.
-               */
-               err2 = read_lines(st->list_file, &names_after);
-               if (err2 < 0) {
-                       free_names(names);
-                       return err2;
+                       REFTABLE_CALLOC_ARRAY(names, 1);
+               } else {
+                       err = fd_read_lines(fd, &names);
+                       if (err < 0)
+                               goto out;
                }
 
+               err = reftable_stack_reload_once(st, names, reuse_open);
+               if (!err)
+                       break;
+               if (err != REFTABLE_NOT_EXIST_ERROR)
+                       goto out;
+
+               /*
+                * REFTABLE_NOT_EXIST_ERROR can be caused by a concurrent
+                * writer. Check if there was one by checking if the name list
+                * changed.
+                */
+               err = read_lines(st->list_file, &names_after);
+               if (err < 0)
+                       goto out;
                if (names_equal(names_after, names)) {
-                       free_names(names);
-                       free_names(names_after);
-                       return err;
+                       err = REFTABLE_NOT_EXIST_ERROR;
+                       goto out;
                }
+
                free_names(names);
+               names = NULL;
                free_names(names_after);
+               names_after = NULL;
+               close(fd);
+               fd = -1;
 
                delay = delay + (delay * rand()) / RAND_MAX + 1;
                sleep_millisec(delay);
        }
 
-       return 0;
+out:
+       /*
+        * Invalidate the stat cache. It is sufficient to only close the file
+        * descriptor and keep the cached stat info because we never use the
+        * latter when the former is negative.
+        */
+       if (st->list_fd >= 0) {
+               close(st->list_fd);
+               st->list_fd = -1;
+       }
+
+       /*
+        * Cache stat information in case it provides a useful signal to us.
+        * According to POSIX, "The st_ino and st_dev fields taken together
+        * uniquely identify the file within the system." That being said,
+        * Windows is not POSIX compliant and we do not have these fields
+        * available. So the information we have there is insufficient to
+        * determine whether two file descriptors point to the same file.
+        *
+        * While we could fall back to using other signals like the file's
+        * mtime, those are not sufficient to avoid races. We thus refrain from
+        * using the stat cache on such systems and fall back to the secondary
+        * caching mechanism, which is to check whether contents of the file
+        * have changed.
+        *
+        * On other systems which are POSIX compliant we must keep the file
+        * descriptor open. This is to avoid a race condition where two
+        * processes access the reftable stack at the same point in time:
+        *
+        *   1. A reads the reftable stack and caches its stat info.
+        *
+        *   2. B updates the stack, appending a new table to "tables.list".
+        *      This will both use a new inode and result in a different file
+        *      size, thus invalidating A's cache in theory.
+        *
+        *   3. B decides to auto-compact the stack and merges two tables. The
+        *      file size now matches what A has cached again. Furthermore, the
+        *      filesystem may decide to recycle the inode number of the file
+        *      we have replaced in (2) because it is not in use anymore.
+        *
+        *   4. A reloads the reftable stack. Neither the inode number nor the
+        *      file size changed. If the timestamps did not change either then
+        *      we think the cached copy of our stack is up-to-date.
+        *
+        * By keeping the file descriptor open the inode number cannot be
+        * recycled, mitigating the race.
+        */
+       if (!err && fd >= 0 && !fstat(fd, &st->list_st) &&
+           st->list_st.st_dev && st->list_st.st_ino) {
+               st->list_fd = fd;
+               fd = -1;
+       }
+
+       if (fd >= 0)
+               close(fd);
+       free_names(names);
+       free_names(names_after);
+       return err;
 }
 
 /* -1 = error
@@ -375,8 +452,44 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
 static int stack_uptodate(struct reftable_stack *st)
 {
        char **names = NULL;
-       int err = read_lines(st->list_file, &names);
+       int err;
        int i = 0;
+
+       /*
+        * When we have cached stat information available then we use it to
+        * verify whether the file has been rewritten.
+        *
+        * Note that we explicitly do not want to use `stat_validity_check()`
+        * and friends here because they may end up not comparing the `st_dev`
+        * and `st_ino` fields. These functions thus cannot guarantee that we
+        * indeed still have the same file.
+        */
+       if (st->list_fd >= 0) {
+               struct stat list_st;
+
+               if (stat(st->list_file, &list_st) < 0) {
+                       /*
+                        * It's fine for "tables.list" to not exist. In that
+                        * case, we have to refresh when the loaded stack has
+                        * any readers.
+                        */
+                       if (errno == ENOENT)
+                               return !!st->readers_len;
+                       return REFTABLE_IO_ERROR;
+               }
+
+               /*
+                * When "tables.list" refers to the same file we can assume
+                * that it didn't change. This is because we always use
+                * rename(3P) to update the file and never write to it
+                * directly.
+                */
+               if (st->list_st.st_dev == list_st.st_dev &&
+                   st->list_st.st_ino == list_st.st_ino)
+                       return 0;
+       }
+
+       err = read_lines(st->list_file, &names);
        if (err < 0)
                return err;
 
@@ -425,9 +538,6 @@ int reftable_stack_add(struct reftable_stack *st,
                return err;
        }
 
-       if (!st->disable_auto_compact)
-               return reftable_stack_auto_compact(st);
-
        return 0;
 }
 
@@ -446,7 +556,7 @@ struct reftable_addition {
        struct reftable_stack *stack;
 
        char **new_tables;
-       int new_tables_len;
+       size_t new_tables_len, new_tables_cap;
        uint64_t next_update_index;
 };
 
@@ -497,8 +607,9 @@ done:
 
 static void reftable_addition_close(struct reftable_addition *add)
 {
-       int i = 0;
        struct strbuf nm = STRBUF_INIT;
+       size_t i;
+
        for (i = 0; i < add->new_tables_len; i++) {
                stack_filename(&nm, add->stack, add->new_tables[i]);
                unlink(nm.buf);
@@ -508,6 +619,7 @@ static void reftable_addition_close(struct reftable_addition *add)
        reftable_free(add->new_tables);
        add->new_tables = NULL;
        add->new_tables_len = 0;
+       add->new_tables_cap = 0;
 
        delete_tempfile(&add->lock_file);
        strbuf_release(&nm);
@@ -526,8 +638,8 @@ int reftable_addition_commit(struct reftable_addition *add)
 {
        struct strbuf table_list = STRBUF_INIT;
        int lock_file_fd = get_tempfile_fd(add->lock_file);
-       int i = 0;
        int err = 0;
+       size_t i;
 
        if (add->new_tables_len == 0)
                goto done;
@@ -548,6 +660,9 @@ int reftable_addition_commit(struct reftable_addition *add)
                goto done;
        }
 
+       fsync_component_or_die(FSYNC_COMPONENT_REFERENCE, lock_file_fd,
+                              get_tempfile_path(add->lock_file));
+
        err = rename_tempfile(&add->lock_file, add->stack->list_file);
        if (err < 0) {
                err = REFTABLE_IO_ERROR;
@@ -555,14 +670,14 @@ int reftable_addition_commit(struct reftable_addition *add)
        }
 
        /* success, no more state to clean up. */
-       for (i = 0; i < add->new_tables_len; i++) {
+       for (i = 0; i < add->new_tables_len; i++)
                reftable_free(add->new_tables[i]);
-       }
        reftable_free(add->new_tables);
        add->new_tables = NULL;
        add->new_tables_len = 0;
+       add->new_tables_cap = 0;
 
-       err = reftable_stack_reload(add->stack);
+       err = reftable_stack_reload_maybe_reuse(add->stack, 1);
        if (err)
                goto done;
 
@@ -579,7 +694,7 @@ int reftable_stack_new_addition(struct reftable_addition **dest,
 {
        int err = 0;
        struct reftable_addition empty = REFTABLE_ADDITION_INIT;
-       *dest = reftable_calloc(sizeof(**dest));
+       REFTABLE_CALLOC_ARRAY(*dest, 1);
        **dest = empty;
        err = reftable_stack_init_addition(*dest, st);
        if (err) {
@@ -642,7 +757,7 @@ int reftable_addition_add(struct reftable_addition *add,
                        goto done;
                }
        }
-       wr = reftable_new_writer(reftable_fd_write, &tab_fd,
+       wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd,
                                 &add->stack->config);
        err = write_table(wr, arg);
        if (err < 0)
@@ -687,11 +802,9 @@ int reftable_addition_add(struct reftable_addition *add,
                goto done;
        }
 
-       add->new_tables = reftable_realloc(add->new_tables,
-                                          sizeof(*add->new_tables) *
-                                                  (add->new_tables_len + 1));
-       add->new_tables[add->new_tables_len] = strbuf_detach(&next_name, NULL);
-       add->new_tables_len++;
+       REFTABLE_ALLOC_GROW(add->new_tables, add->new_tables_len + 1,
+                           add->new_tables_cap);
+       add->new_tables[add->new_tables_len++] = strbuf_detach(&next_name, NULL);
 done:
        if (tab_fd > 0) {
                close(tab_fd);
@@ -717,7 +830,8 @@ uint64_t reftable_stack_next_update_index(struct reftable_stack *st)
        return 1;
 }
 
-static int stack_compact_locked(struct reftable_stack *st, int first, int last,
+static int stack_compact_locked(struct reftable_stack *st,
+                               size_t first, size_t last,
                                struct strbuf *temp_tab,
                                struct reftable_log_expiry_config *config)
 {
@@ -734,7 +848,13 @@ static int stack_compact_locked(struct reftable_stack *st, int first, int last,
        strbuf_addstr(temp_tab, ".temp.XXXXXX");
 
        tab_fd = mkstemp(temp_tab->buf);
-       wr = reftable_new_writer(reftable_fd_write, &tab_fd, &st->config);
+       if (st->config.default_permissions &&
+           chmod(temp_tab->buf, st->config.default_permissions) < 0) {
+               err = REFTABLE_IO_ERROR;
+               goto done;
+       }
+
+       wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd, &st->config);
 
        err = stack_write_compact(st, wr, first, last, config);
        if (err < 0)
@@ -761,22 +881,21 @@ done:
 }
 
 static int stack_write_compact(struct reftable_stack *st,
-                              struct reftable_writer *wr, int first, int last,
+                              struct reftable_writer *wr,
+                              size_t first, size_t last,
                               struct reftable_log_expiry_config *config)
 {
-       int subtabs_len = last - first + 1;
+       size_t subtabs_len = last - first + 1;
        struct reftable_table *subtabs = reftable_calloc(
-               sizeof(struct reftable_table) * (last - first + 1));
+               last - first + 1, sizeof(*subtabs));
        struct reftable_merged_table *mt = NULL;
-       int err = 0;
        struct reftable_iterator it = { NULL };
        struct reftable_ref_record ref = { NULL };
        struct reftable_log_record log = { NULL };
-
        uint64_t entries = 0;
+       int err = 0;
 
-       int i = 0, j = 0;
-       for (i = first, j = 0; i <= last; i++) {
+       for (size_t i = first, j = 0; i <= last; i++) {
                struct reftable_reader *t = st->readers[i];
                reftable_table_from_reader(&subtabs[j++], t);
                st->stats.bytes += t->size;
@@ -801,18 +920,16 @@ static int stack_write_compact(struct reftable_stack *st,
                        err = 0;
                        break;
                }
-               if (err < 0) {
-                       break;
-               }
+               if (err < 0)
+                       goto done;
 
                if (first == 0 && reftable_ref_record_is_deletion(&ref)) {
                        continue;
                }
 
                err = reftable_writer_add_ref(wr, &ref);
-               if (err < 0) {
-                       break;
-               }
+               if (err < 0)
+                       goto done;
                entries++;
        }
        reftable_iterator_destroy(&it);
@@ -827,9 +944,8 @@ static int stack_write_compact(struct reftable_stack *st,
                        err = 0;
                        break;
                }
-               if (err < 0) {
-                       break;
-               }
+               if (err < 0)
+                       goto done;
                if (first == 0 && reftable_log_record_is_deletion(&log)) {
                        continue;
                }
@@ -845,9 +961,8 @@ static int stack_write_compact(struct reftable_stack *st,
                }
 
                err = reftable_writer_add_log(wr, &log);
-               if (err < 0) {
-                       break;
-               }
+               if (err < 0)
+                       goto done;
                entries++;
        }
 
@@ -864,25 +979,20 @@ done:
 }
 
 /* <  0: error. 0 == OK, > 0 attempt failed; could retry. */
-static int stack_compact_range(struct reftable_stack *st, int first, int last,
+static int stack_compact_range(struct reftable_stack *st,
+                              size_t first, size_t last,
                               struct reftable_log_expiry_config *expiry)
 {
+       char **delete_on_success = NULL, **subtable_locks = NULL, **listp = NULL;
        struct strbuf temp_tab_file_name = STRBUF_INIT;
        struct strbuf new_table_name = STRBUF_INIT;
        struct strbuf lock_file_name = STRBUF_INIT;
        struct strbuf ref_list_contents = STRBUF_INIT;
        struct strbuf new_table_path = STRBUF_INIT;
+       size_t i, j, compact_count;
        int err = 0;
        int have_lock = 0;
        int lock_file_fd = -1;
-       int compact_count = last - first + 1;
-       char **listp = NULL;
-       char **delete_on_success =
-               reftable_calloc(sizeof(char *) * (compact_count + 1));
-       char **subtable_locks =
-               reftable_calloc(sizeof(char *) * (compact_count + 1));
-       int i = 0;
-       int j = 0;
        int is_empty_table = 0;
 
        if (first > last || (!expiry && first == last)) {
@@ -890,6 +1000,10 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
                goto done;
        }
 
+       compact_count = last - first + 1;
+       REFTABLE_CALLOC_ARRAY(delete_on_success, compact_count + 1);
+       REFTABLE_CALLOC_ARRAY(subtable_locks, compact_count + 1);
+
        st->stats.attempts++;
 
        strbuf_reset(&lock_file_name);
@@ -1015,6 +1129,14 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
                unlink(new_table_path.buf);
                goto done;
        }
+
+       err = fsync_component(FSYNC_COMPONENT_REFERENCE, lock_file_fd);
+       if (err < 0) {
+               err = REFTABLE_IO_ERROR;
+               unlink(new_table_path.buf);
+               goto done;
+       }
+
        err = close(lock_file_fd);
        lock_file_fd = -1;
        if (err < 0) {
@@ -1047,12 +1169,14 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
 done:
        free_names(delete_on_success);
 
-       listp = subtable_locks;
-       while (*listp) {
-               unlink(*listp);
-               listp++;
+       if (subtable_locks) {
+               listp = subtable_locks;
+               while (*listp) {
+                       unlink(*listp);
+                       listp++;
+               }
+               free_names(subtable_locks);
        }
-       free_names(subtable_locks);
        if (lock_file_fd >= 0) {
                close(lock_file_fd);
                lock_file_fd = -1;
@@ -1071,17 +1195,17 @@ done:
 int reftable_stack_compact_all(struct reftable_stack *st,
                               struct reftable_log_expiry_config *config)
 {
-       return stack_compact_range(st, 0, st->merged->stack_len - 1, config);
+       return stack_compact_range(st, 0, st->merged->stack_len ?
+                       st->merged->stack_len - 1 : 0, config);
 }
 
-static int stack_compact_range_stats(struct reftable_stack *st, int first,
-                                    int last,
+static int stack_compact_range_stats(struct reftable_stack *st,
+                                    size_t first, size_t last,
                                     struct reftable_log_expiry_config *config)
 {
        int err = stack_compact_range(st, first, last, config);
-       if (err > 0) {
+       if (err > 0)
                st->stats.failures++;
-       }
        return err;
 }
 
@@ -1101,12 +1225,11 @@ int fastlog2(uint64_t sz)
        return l - 1;
 }
 
-struct segment *sizes_to_segments(int *seglen, uint64_t *sizes, int n)
+struct segment *sizes_to_segments(size_t *seglen, uint64_t *sizes, size_t n)
 {
-       struct segment *segs = reftable_calloc(sizeof(struct segment) * n);
-       int next = 0;
+       struct segment *segs = reftable_calloc(n, sizeof(*segs));
        struct segment cur = { 0 };
-       int i = 0;
+       size_t next = 0, i;
 
        if (n == 0) {
                *seglen = 0;
@@ -1132,29 +1255,27 @@ struct segment *sizes_to_segments(int *seglen, uint64_t *sizes, int n)
        return segs;
 }
 
-struct segment suggest_compaction_segment(uint64_t *sizes, int n)
+struct segment suggest_compaction_segment(uint64_t *sizes, size_t n)
 {
-       int seglen = 0;
-       struct segment *segs = sizes_to_segments(&seglen, sizes, n);
        struct segment min_seg = {
                .log = 64,
        };
-       int i = 0;
+       struct segment *segs;
+       size_t seglen = 0, i;
+
+       segs = sizes_to_segments(&seglen, sizes, n);
        for (i = 0; i < seglen; i++) {
-               if (segment_size(&segs[i]) == 1) {
+               if (segment_size(&segs[i]) == 1)
                        continue;
-               }
 
-               if (segs[i].log < min_seg.log) {
+               if (segs[i].log < min_seg.log)
                        min_seg = segs[i];
-               }
        }
 
        while (min_seg.start > 0) {
-               int prev = min_seg.start - 1;
-               if (fastlog2(min_seg.bytes) < fastlog2(sizes[prev])) {
+               size_t prev = min_seg.start - 1;
+               if (fastlog2(min_seg.bytes) < fastlog2(sizes[prev]))
                        break;
-               }
 
                min_seg.start = prev;
                min_seg.bytes += sizes[prev];
@@ -1167,7 +1288,7 @@ struct segment suggest_compaction_segment(uint64_t *sizes, int n)
 static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st)
 {
        uint64_t *sizes =
-               reftable_calloc(sizeof(uint64_t) * st->merged->stack_len);
+               reftable_calloc(st->merged->stack_len, sizeof(*sizes));
        int version = (st->config.hash_id == GIT_SHA1_FORMAT_ID) ? 1 : 2;
        int overhead = header_size(version) - 1;
        int i = 0;
@@ -1266,17 +1387,12 @@ static int stack_check_addition(struct reftable_stack *st,
        while (1) {
                struct reftable_ref_record ref = { NULL };
                err = reftable_iterator_next_ref(&it, &ref);
-               if (err > 0) {
+               if (err > 0)
                        break;
-               }
                if (err < 0)
                        goto done;
 
-               if (len >= cap) {
-                       cap = 2 * cap + 1;
-                       refs = reftable_realloc(refs, cap * sizeof(refs[0]));
-               }
-
+               REFTABLE_ALLOC_GROW(refs, len + 1, cap);
                refs[len++] = ref;
        }
 
index f57005846e561272054883e856d7a1dd14863a19..d919455669ede0b2872a2d19ee12870479ab99ab 100644 (file)
@@ -14,7 +14,10 @@ https://developers.google.com/open-source/licenses/bsd
 #include "reftable-stack.h"
 
 struct reftable_stack {
+       struct stat list_st;
        char *list_file;
+       int list_fd;
+
        char *reftable_dir;
        int disable_auto_compact;
 
@@ -29,13 +32,13 @@ struct reftable_stack {
 int read_lines(const char *filename, char ***lines);
 
 struct segment {
-       int start, end;
+       size_t start, end;
        int log;
        uint64_t bytes;
 };
 
 int fastlog2(uint64_t sz);
-struct segment *sizes_to_segments(int *seglen, uint64_t *sizes, int n);
-struct segment suggest_compaction_segment(uint64_t *sizes, int n);
+struct segment *sizes_to_segments(size_t *seglen, uint64_t *sizes, size_t n);
+struct segment suggest_compaction_segment(uint64_t *sizes, size_t n);
 
 #endif
index 82280c2fd586e2464561765575127051dd77c15b..509f4866236024f5546100da7121996f1c963e08 100644 (file)
@@ -443,15 +443,16 @@ static void test_reftable_stack_add(void)
        int err = 0;
        struct reftable_write_options cfg = {
                .exact_log_message = 1,
+               .default_permissions = 0660,
        };
        struct reftable_stack *st = NULL;
        char *dir = get_tmp_dir(__LINE__);
-
        struct reftable_ref_record refs[2] = { { NULL } };
        struct reftable_log_record logs[2] = { { NULL } };
+       struct strbuf path = STRBUF_INIT;
+       struct stat stat_result;
        int N = ARRAY_SIZE(refs);
 
-
        err = reftable_new_stack(&st, dir, cfg);
        EXPECT_ERR(err);
        st->disable_auto_compact = 1;
@@ -462,7 +463,6 @@ static void test_reftable_stack_add(void)
                refs[i].refname = xstrdup(buf);
                refs[i].update_index = i + 1;
                refs[i].value_type = REFTABLE_REF_VAL1;
-               refs[i].value.val1 = reftable_malloc(GIT_SHA1_RAWSZ);
                set_test_hash(refs[i].value.val1, i);
 
                logs[i].refname = xstrdup(buf);
@@ -510,12 +510,32 @@ static void test_reftable_stack_add(void)
                reftable_log_record_release(&dest);
        }
 
+#ifndef GIT_WINDOWS_NATIVE
+       strbuf_addstr(&path, dir);
+       strbuf_addstr(&path, "/tables.list");
+       err = stat(path.buf, &stat_result);
+       EXPECT(!err);
+       EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
+
+       strbuf_reset(&path);
+       strbuf_addstr(&path, dir);
+       strbuf_addstr(&path, "/");
+       /* do not try at home; not an external API for reftable. */
+       strbuf_addstr(&path, st->readers[0]->name);
+       err = stat(path.buf, &stat_result);
+       EXPECT(!err);
+       EXPECT((stat_result.st_mode & 0777) == cfg.default_permissions);
+#else
+       (void) stat_result;
+#endif
+
        /* cleanup */
        reftable_stack_destroy(st);
        for (i = 0; i < N; i++) {
                reftable_ref_record_release(&refs[i]);
                reftable_log_record_release(&logs[i]);
        }
+       strbuf_release(&path);
        clear_dir(dir);
 }
 
@@ -599,7 +619,6 @@ static void test_reftable_stack_tombstone(void)
                refs[i].update_index = i + 1;
                if (i % 2 == 0) {
                        refs[i].value_type = REFTABLE_REF_VAL1;
-                       refs[i].value.val1 = reftable_malloc(GIT_SHA1_RAWSZ);
                        set_test_hash(refs[i].value.val1, i);
                }
 
@@ -713,7 +732,7 @@ static void test_sizes_to_segments(void)
        uint64_t sizes[] = { 2, 3, 4, 5, 7, 9 };
        /* .................0  1  2  3  4  5 */
 
-       int seglen = 0;
+       size_t seglen = 0;
        struct segment *segs =
                sizes_to_segments(&seglen, sizes, ARRAY_SIZE(sizes));
        EXPECT(segs[2].log == 3);
@@ -728,7 +747,7 @@ static void test_sizes_to_segments(void)
 
 static void test_sizes_to_segments_empty(void)
 {
-       int seglen = 0;
+       size_t seglen = 0;
        struct segment *segs = sizes_to_segments(&seglen, NULL, 0);
        EXPECT(seglen == 0);
        reftable_free(segs);
@@ -737,8 +756,7 @@ static void test_sizes_to_segments_empty(void)
 static void test_sizes_to_segments_all_equal(void)
 {
        uint64_t sizes[] = { 5, 5 };
-
-       int seglen = 0;
+       size_t seglen = 0;
        struct segment *segs =
                sizes_to_segments(&seglen, sizes, ARRAY_SIZE(sizes));
        EXPECT(seglen == 1);
index 04044fc1a0fb5ffa143264527b882afb752fc2c6..4066924eee45dc6b4fe5b353f7fe54c9dc9f7d7e 100644 (file)
@@ -20,3 +20,8 @@ ssize_t strbuf_add_void(void *b, const void *data, size_t sz)
        strbuf_add(b, data, sz);
        return sz;
 }
+
+int noop_flush(void *arg)
+{
+       return 0;
+}
index ee44f735aea51d03fc3400a9340ccbd7af881f9e..687390f9c239a397652a9a4c9a0bbb7a3510d232 100644 (file)
@@ -56,4 +56,6 @@ void set_test_hash(uint8_t *p, int i);
  */
 ssize_t strbuf_add_void(void *b, const void *data, size_t sz);
 
+int noop_flush(void *);
+
 #endif
index a5bf880985472dee7cd7c9169047752245599488..528f33ae388d0a6ad93eaa5e3f604596f07071fb 100644 (file)
@@ -20,8 +20,8 @@ struct tree_node *tree_search(void *key, struct tree_node **rootp,
                if (!insert) {
                        return NULL;
                } else {
-                       struct tree_node *n =
-                               reftable_calloc(sizeof(struct tree_node));
+                       struct tree_node *n;
+                       REFTABLE_CALLOC_ARRAY(n, 1);
                        n->key = key;
                        *rootp = n;
                        return *rootp;
index 2e322a5683d081eea60fc85dfc4d792ce89b7a93..1d9ff0fbfabcc387e29697c0458467c882708c39 100644 (file)
@@ -49,7 +49,7 @@ static int padded_write(struct reftable_writer *w, uint8_t *data, size_t len,
 {
        int n = 0;
        if (w->pending_padding > 0) {
-               uint8_t *zeroed = reftable_calloc(w->pending_padding);
+               uint8_t *zeroed = reftable_calloc(w->pending_padding, sizeof(*zeroed));
                int n = w->write(w->write_arg, zeroed, w->pending_padding);
                if (n < 0)
                        return n;
@@ -121,10 +121,10 @@ static struct strbuf reftable_empty_strbuf = STRBUF_INIT;
 
 struct reftable_writer *
 reftable_new_writer(ssize_t (*writer_func)(void *, const void *, size_t),
+                   int (*flush_func)(void *),
                    void *writer_arg, struct reftable_write_options *opts)
 {
-       struct reftable_writer *wp =
-               reftable_calloc(sizeof(struct reftable_writer));
+       struct reftable_writer *wp = reftable_calloc(1, sizeof(*wp));
        strbuf_init(&wp->block_writer_data.last_key, 0);
        options_set_defaults(opts);
        if (opts->block_size >= (1 << 24)) {
@@ -132,10 +132,11 @@ reftable_new_writer(ssize_t (*writer_func)(void *, const void *, size_t),
                abort();
        }
        wp->last_key = reftable_empty_strbuf;
-       wp->block = reftable_calloc(opts->block_size);
+       REFTABLE_CALLOC_ARRAY(wp->block, opts->block_size);
        wp->write = writer_func;
        wp->write_arg = writer_arg;
        wp->opts = *opts;
+       wp->flush = flush_func;
        writer_reinit_block_writer(wp, BLOCK_TYPE_REF);
 
        return wp;
@@ -200,12 +201,7 @@ static void writer_index_hash(struct reftable_writer *w, struct strbuf *hash)
                return;
        }
 
-       if (key->offset_len == key->offset_cap) {
-               key->offset_cap = 2 * key->offset_cap + 1;
-               key->offsets = reftable_realloc(
-                       key->offsets, sizeof(uint64_t) * key->offset_cap);
-       }
-
+       REFTABLE_ALLOC_GROW(key->offsets, key->offset_len + 1, key->offset_cap);
        key->offsets[key->offset_len++] = off;
 }
 
@@ -377,20 +373,39 @@ int reftable_writer_add_logs(struct reftable_writer *w,
 
 static int writer_finish_section(struct reftable_writer *w)
 {
+       struct reftable_block_stats *bstats = NULL;
        uint8_t typ = block_writer_type(w->block_writer);
        uint64_t index_start = 0;
        int max_level = 0;
-       int threshold = w->opts.unpadded ? 1 : 3;
+       size_t threshold = w->opts.unpadded ? 1 : 3;
        int before_blocks = w->stats.idx_stats.blocks;
-       int err = writer_flush_block(w);
-       int i = 0;
-       struct reftable_block_stats *bstats = NULL;
+       int err;
+
+       err = writer_flush_block(w);
        if (err < 0)
                return err;
 
+       /*
+        * When the section we are about to index has a lot of blocks then the
+        * index itself may span across multiple blocks, as well. This would
+        * require a linear scan over index blocks only to find the desired
+        * indexed block, which is inefficient. Instead, we write a multi-level
+        * index where index records of level N+1 will refer to index blocks of
+        * level N. This isn't constant time, either, but at least logarithmic.
+        *
+        * This loop handles writing this multi-level index. Note that we write
+        * the lowest-level index pointing to the indexed blocks first. We then
+        * continue writing additional index levels until the current level has
+        * less blocks than the threshold so that the highest level will be at
+        * the end of the index section.
+        *
+        * Readers are thus required to start reading the index section from
+        * its end, which is why we set `index_start` to the beginning of the
+        * last index section.
+        */
        while (w->index_len > threshold) {
                struct reftable_index_record *idx = NULL;
-               int idx_len = 0;
+               size_t i, idx_len;
 
                max_level++;
                index_start = w->next;
@@ -409,35 +424,28 @@ static int writer_finish_section(struct reftable_writer *w)
                                        .idx = idx[i],
                                },
                        };
-                       if (block_writer_add(w->block_writer, &rec) == 0) {
-                               continue;
-                       }
 
-                       err = writer_flush_block(w);
+                       err = writer_add_record(w, &rec);
                        if (err < 0)
                                return err;
+               }
 
-                       writer_reinit_block_writer(w, BLOCK_TYPE_INDEX);
+               err = writer_flush_block(w);
+               if (err < 0)
+                       return err;
 
-                       err = block_writer_add(w->block_writer, &rec);
-                       if (err != 0) {
-                               /* write into fresh block should always succeed
-                                */
-                               abort();
-                       }
-               }
-               for (i = 0; i < idx_len; i++) {
+               for (i = 0; i < idx_len; i++)
                        strbuf_release(&idx[i].last_key);
-               }
                reftable_free(idx);
        }
 
+       /*
+        * The index may still contain a number of index blocks lower than the
+        * threshold. Clear it so that these entries don't leak into the next
+        * index section.
+        */
        writer_clear_index(w);
 
-       err = writer_flush_block(w);
-       if (err < 0)
-               return err;
-
        bstats = writer_reftable_block_stats(w, typ);
        bstats->index_blocks = w->stats.idx_stats.blocks - before_blocks;
        bstats->index_offset = index_start;
@@ -603,6 +611,12 @@ int reftable_writer_close(struct reftable_writer *w)
        put_be32(p, crc32(0, footer, p - footer));
        p += 4;
 
+       err = w->flush(w->write_arg);
+       if (err < 0) {
+               err = REFTABLE_IO_ERROR;
+               goto done;
+       }
+
        err = padded_write(w, footer, footer_size(writer_version(w)), 0);
        if (err < 0)
                goto done;
@@ -622,11 +636,8 @@ done:
 
 static void writer_clear_index(struct reftable_writer *w)
 {
-       int i = 0;
-       for (i = 0; i < w->index_len; i++) {
+       for (size_t i = 0; i < w->index_len; i++)
                strbuf_release(&w->index[i].last_key);
-       }
-
        FREE_AND_NULL(w->index);
        w->index_len = 0;
        w->index_cap = 0;
@@ -674,12 +685,7 @@ static int writer_flush_nonempty_block(struct reftable_writer *w)
        if (err < 0)
                return err;
 
-       if (w->index_cap == w->index_len) {
-               w->index_cap = 2 * w->index_cap + 1;
-               w->index = reftable_realloc(
-                       w->index,
-                       sizeof(struct reftable_index_record) * w->index_cap);
-       }
+       REFTABLE_ALLOC_GROW(w->index, w->index_len + 1, w->index_cap);
 
        ir.offset = w->next;
        strbuf_reset(&ir.last_key);
index 09b88673d9757536c3c0f5122f991703eb94a06e..8d0df9cc528dba79677716b6b6760b93c7dad057 100644 (file)
@@ -16,6 +16,7 @@ https://developers.google.com/open-source/licenses/bsd
 
 struct reftable_writer {
        ssize_t (*write)(void *, const void *, size_t);
+       int (*flush)(void *);
        void *write_arg;
        int pending_padding;
        struct strbuf last_key;
index 7f81bf3fafc4e5de90fa1fbf19c3b2cde26df8aa..1161dc7fed689259141ae2eb5403d84b906027d3 100644 (file)
@@ -1446,8 +1446,14 @@ static int stateless_connect(const char *service_name)
         * establish a stateless connection, otherwise we need to tell the
         * client to fallback to using other transport helper functions to
         * complete their request.
+        *
+        * The "git-upload-archive" service is a read-only operation. Fallback
+        * to use "git-upload-pack" service to discover protocol version.
         */
-       discover = discover_refs(service_name, 0);
+       if (!strcmp(service_name, "git-upload-archive"))
+               discover = discover_refs("git-upload-pack", 0);
+       else
+               discover = discover_refs(service_name, 0);
        if (discover->version != protocol_v2) {
                printf("fallback\n");
                fflush(stdout);
@@ -1485,9 +1491,11 @@ static int stateless_connect(const char *service_name)
 
        /*
         * Dump the capability listing that we got from the server earlier
-        * during the info/refs request.
+        * during the info/refs request. This does not work with the
+        * "git-upload-archive" service.
         */
-       write_or_die(rpc.in, discover->buf, discover->len);
+       if (strcmp(service_name, "git-upload-archive"))
+               write_or_die(rpc.in, discover->buf, discover->len);
 
        /* Until we see EOF keep sending POSTs */
        while (1) {
@@ -1563,8 +1571,11 @@ int cmd_main(int argc, const char **argv)
                if (buf.len == 0)
                        break;
                if (starts_with(buf.buf, "fetch ")) {
-                       if (nongit)
-                               die(_("remote-curl: fetch attempted without a local repo"));
+                       if (nongit) {
+                               setup_git_directory_gently(&nongit);
+                               if (nongit)
+                                       die(_("remote-curl: fetch attempted without a local repo"));
+                       }
                        parse_fetch(&buf);
 
                } else if (!strcmp(buf.buf, "list") || starts_with(buf.buf, "list ")) {
index 6bef95316af6573b5a6829ace42b183e25548939..9090632e96daddfc1217bc64ae4e0dac11bdb993 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -105,7 +105,7 @@ static int remotes_hash_cmp(const void *cmp_data UNUSED,
        b = container_of(entry_or_key, const struct remote, ent);
 
        if (key)
-               return strncmp(a->name, key->str, key->len) || a->name[key->len];
+               return !!xstrncmpz(a->name, key->str, key->len);
        else
                return strcmp(a->name, b->name);
 }
@@ -189,8 +189,7 @@ static int branches_hash_cmp(const void *cmp_data UNUSED,
        b = container_of(entry_or_key, const struct branch, ent);
 
        if (key)
-               return strncmp(a->name, key->str, key->len) ||
-                      a->name[key->len];
+               return !!xstrncmpz(a->name, key->str, key->len);
        else
                return strcmp(a->name, b->name);
 }
@@ -508,7 +507,7 @@ static void alias_all_urls(struct remote_state *remote_state)
        }
 }
 
-static void read_config(struct repository *repo)
+static void read_config(struct repository *repo, int early)
 {
        int flag;
 
@@ -517,7 +516,7 @@ static void read_config(struct repository *repo)
        repo->remote_state->initialized = 1;
 
        repo->remote_state->current_branch = NULL;
-       if (startup_info->have_repository) {
+       if (startup_info->have_repository && !early) {
                const char *head_ref = refs_resolve_ref_unsafe(
                        get_main_ref_store(repo), "HEAD", 0, NULL, &flag);
                if (head_ref && (flag & REF_ISSYMREF) &&
@@ -560,7 +559,7 @@ static const char *remotes_remote_for_branch(struct remote_state *remote_state,
 
 const char *remote_for_branch(struct branch *branch, int *explicit)
 {
-       read_config(the_repository);
+       read_config(the_repository, 0);
        die_on_missing_branch(the_repository, branch);
 
        return remotes_remote_for_branch(the_repository->remote_state, branch,
@@ -586,7 +585,7 @@ remotes_pushremote_for_branch(struct remote_state *remote_state,
 
 const char *pushremote_for_branch(struct branch *branch, int *explicit)
 {
-       read_config(the_repository);
+       read_config(the_repository, 0);
        die_on_missing_branch(the_repository, branch);
 
        return remotes_pushremote_for_branch(the_repository->remote_state,
@@ -598,7 +597,7 @@ static struct remote *remotes_remote_get(struct remote_state *remote_state,
 
 const char *remote_ref_for_branch(struct branch *branch, int for_push)
 {
-       read_config(the_repository);
+       read_config(the_repository, 0);
        die_on_missing_branch(the_repository, branch);
 
        if (branch) {
@@ -708,7 +707,13 @@ remotes_remote_get(struct remote_state *remote_state, const char *name)
 
 struct remote *remote_get(const char *name)
 {
-       read_config(the_repository);
+       read_config(the_repository, 0);
+       return remotes_remote_get(the_repository->remote_state, name);
+}
+
+struct remote *remote_get_early(const char *name)
+{
+       read_config(the_repository, 1);
        return remotes_remote_get(the_repository->remote_state, name);
 }
 
@@ -721,7 +726,7 @@ remotes_pushremote_get(struct remote_state *remote_state, const char *name)
 
 struct remote *pushremote_get(const char *name)
 {
-       read_config(the_repository);
+       read_config(the_repository, 0);
        return remotes_pushremote_get(the_repository->remote_state, name);
 }
 
@@ -737,7 +742,7 @@ int remote_is_configured(struct remote *remote, int in_repo)
 int for_each_remote(each_remote_fn fn, void *priv)
 {
        int i, result = 0;
-       read_config(the_repository);
+       read_config(the_repository, 0);
        for (i = 0; i < the_repository->remote_state->remotes_nr && !result;
             i++) {
                struct remote *remote =
@@ -1830,7 +1835,7 @@ struct branch *branch_get(const char *name)
 {
        struct branch *ret;
 
-       read_config(the_repository);
+       read_config(the_repository, 0);
        if (!name || !*name || !strcmp(name, "HEAD"))
                ret = the_repository->remote_state->current_branch;
        else
@@ -1972,7 +1977,7 @@ static const char *branch_get_push_1(struct remote_state *remote_state,
 
 const char *branch_get_push(struct branch *branch, struct strbuf *err)
 {
-       read_config(the_repository);
+       read_config(the_repository, 0);
        die_on_missing_branch(the_repository, branch);
 
        if (!branch)
index 3a7377ff9631262536583db7763f1f2136450d0a..dfd4837e602755806bcfc73a725c04394ef81c6c 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -118,6 +118,7 @@ struct remote {
  * and configuration.
  */
 struct remote *remote_get(const char *name);
+struct remote *remote_get_early(const char *name);
 
 struct remote *pushremote_get(const char *name);
 int remote_is_configured(struct remote *remote, int in_repo);
index 30cd4787627b7cacbc2dbceddc0babee1b72cb3e..a0b590bc6c0bb927fb0846055f4c4826e9558c80 100644 (file)
@@ -43,6 +43,7 @@ void prepare_repo_settings(struct repository *r)
        if (experimental) {
                r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
                r->settings.pack_use_bitmap_boundary_traversal = 1;
+               r->settings.pack_use_multi_pack_reuse = 1;
        }
        if (manyfiles) {
                r->settings.index_version = 4;
index a7679ceeaa45ce7a20094f9a29a82987290ad354..7aacb51b65cca69ec6acd0c879dd0aa5b15978b3 100644 (file)
@@ -104,6 +104,11 @@ void repo_set_hash_algo(struct repository *repo, int hash_algo)
        repo->hash_algo = &hash_algos[hash_algo];
 }
 
+void repo_set_ref_storage_format(struct repository *repo, unsigned int format)
+{
+       repo->ref_storage_format = format;
+}
+
 /*
  * Attempt to resolve and set the provided 'gitdir' for repository 'repo'.
  * Return 0 upon success and a non-zero value upon failure.
@@ -184,6 +189,7 @@ int repo_init(struct repository *repo,
                goto error;
 
        repo_set_hash_algo(repo, format.hash_algo);
+       repo_set_ref_storage_format(repo, format.ref_storage_format);
        repo->repository_format_worktree_config = format.worktree_config;
 
        /* take ownership of format.partial_clone */
@@ -256,8 +262,6 @@ static void repo_clear_path_cache(struct repo_path_cache *cache)
        FREE_AND_NULL(cache->merge_rr);
        FREE_AND_NULL(cache->merge_mode);
        FREE_AND_NULL(cache->merge_head);
-       FREE_AND_NULL(cache->merge_autostash);
-       FREE_AND_NULL(cache->auto_merge);
        FREE_AND_NULL(cache->fetch_head);
        FREE_AND_NULL(cache->shallow);
 }
index 5f18486f6465c44b44abb2ded74bcdda14ba7bd9..9bf1e33d2591bbd8d62c971dbc70790d250b021f 100644 (file)
@@ -24,6 +24,10 @@ enum fetch_negotiation_setting {
        FETCH_NEGOTIATION_NOOP,
 };
 
+#define REF_STORAGE_FORMAT_UNKNOWN  0
+#define REF_STORAGE_FORMAT_FILES    1
+#define REF_STORAGE_FORMAT_REFTABLE 2
+
 struct repo_settings {
        int initialized;
 
@@ -36,6 +40,7 @@ struct repo_settings {
        int sparse_index;
        int pack_read_reverse_index;
        int pack_use_bitmap_boundary_traversal;
+       int pack_use_multi_pack_reuse;
 
        /*
         * Does this repository have core.useReplaceRefs=true (on by
@@ -64,8 +69,6 @@ struct repo_path_cache {
        char *merge_rr;
        char *merge_mode;
        char *merge_head;
-       char *merge_autostash;
-       char *auto_merge;
        char *fetch_head;
        char *shallow;
 };
@@ -160,6 +163,9 @@ struct repository {
        /* Repository's current hash algorithm, as serialized on disk. */
        const struct git_hash_algo *hash_algo;
 
+       /* Repository's reference storage format, as serialized on disk. */
+       unsigned int ref_storage_format;
+
        /* A unique-id for tracing purposes. */
        int trace2_repo_id;
 
@@ -199,6 +205,7 @@ void repo_set_gitdir(struct repository *repo, const char *root,
                     const struct set_gitdir_args *extra_args);
 void repo_set_worktree(struct repository *repo, const char *path);
 void repo_set_hash_algo(struct repository *repo, int algo);
+void repo_set_ref_storage_format(struct repository *repo, unsigned int format);
 void initialize_the_repository(void);
 RESULT_MUST_BE_USED
 int repo_init(struct repository *r, const char *gitdir, const char *worktree);
index ca7e77ba68c1ad4aa49f032906ba419098be0d04..13c94ded03706dc3831b0948a1fa7438fa45ab9b 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -973,6 +973,9 @@ static int handle_cache(struct index_state *istate,
                        mmfile[i].ptr = repo_read_object_file(the_repository,
                                                              &ce->oid, &type,
                                                              &size);
+                       if (!mmfile[i].ptr)
+                               die(_("unable to read %s"),
+                                   oid_to_hex(&ce->oid));
                        mmfile[i].size = size;
                }
        }
diff --git a/reset.c b/reset.c
index 0f2ff0fe31531fc5602025cfcd866a9348cfcf63..d619cb7115323febadbf4ae84e6764200f962cab 100644 (file)
--- a/reset.c
+++ b/reset.c
@@ -157,6 +157,11 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
        }
 
        tree = parse_tree_indirect(oid);
+       if (!tree) {
+               ret = error(_("unable to read tree (%s)"), oid_to_hex(oid));
+               goto leave_reset_head;
+       }
+
        prime_cache_tree(r, r->index, tree);
 
        if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0) {
index 2424c9bd674e534909df89e25c21b5eb119fda05..8f0d638af1a14a7db97065c870d66e78ec8239cd 100644 (file)
@@ -385,9 +385,13 @@ static struct object *get_reference(struct rev_info *revs, const char *name,
 
        if (!object) {
                if (revs->ignore_missing)
-                       return object;
+                       return NULL;
                if (revs->exclude_promisor_objects && is_promisor_object(oid))
                        return NULL;
+               if (revs->do_not_die_on_missing_objects) {
+                       oidset_insert(&revs->missing_commits, oid);
+                       return NULL;
+               }
                die("bad object %s", name);
        }
        object->flags |= flags;
@@ -415,15 +419,21 @@ static struct commit *handle_commit(struct rev_info *revs,
         */
        while (object->type == OBJ_TAG) {
                struct tag *tag = (struct tag *) object;
+               struct object_id *oid;
                if (revs->tag_objects && !(flags & UNINTERESTING))
                        add_pending_object(revs, object, tag->tag);
-               object = parse_object(revs->repo, get_tagged_oid(tag));
+               oid = get_tagged_oid(tag);
+               object = parse_object(revs->repo, oid);
                if (!object) {
                        if (revs->ignore_missing_links || (flags & UNINTERESTING))
                                return NULL;
                        if (revs->exclude_promisor_objects &&
                            is_promisor_object(&tag->tagged->oid))
                                return NULL;
+                       if (revs->do_not_die_on_missing_objects && oid) {
+                               oidset_insert(&revs->missing_commits, oid);
+                               return NULL;
+                       }
                        die("bad object %s", oid_to_hex(&tag->tagged->oid));
                }
                object->flags |= flags;
@@ -1686,9 +1696,7 @@ static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
        return 0;
 }
 
-static int handle_one_reflog(const char *refname_in_wt,
-                            const struct object_id *oid UNUSED,
-                            int flag UNUSED, void *cb_data)
+static int handle_one_reflog(const char *refname_in_wt, void *cb_data)
 {
        struct all_refs_cb *cb = cb_data;
        struct strbuf refname = STRBUF_INIT;
@@ -1947,6 +1955,7 @@ void repo_init_revisions(struct repository *r,
        init_display_notes(&revs->notes_opt);
        list_objects_filter_init(&revs->filter);
        init_ref_exclusions(&revs->ref_excludes);
+       oidset_init(&revs->missing_commits, 0);
 }
 
 static void add_pending_commit_list(struct rev_info *revs,
@@ -2178,13 +2187,18 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl
        if (revarg_opt & REVARG_COMMITTISH)
                get_sha1_flags |= GET_OID_COMMITTISH;
 
+       /*
+        * Even if revs->do_not_die_on_missing_objects is set, we
+        * should error out if we can't even get an oid, as
+        * `--missing=print` should be able to report missing oids.
+        */
        if (get_oid_with_context(revs->repo, arg, get_sha1_flags, &oid, &oc))
                return revs->ignore_missing ? 0 : -1;
        if (!cant_be_filename)
                verify_non_filename(revs->prefix, arg);
        object = get_reference(revs, arg, &oid, flags ^ local_flags);
        if (!object)
-               return revs->ignore_missing ? 0 : -1;
+               return (revs->ignore_missing || revs->do_not_die_on_missing_objects) ? 0 : -1;
        add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);
        add_pending_object_with_path(revs, object, arg, oc.mode, oc.path);
        free(oc.path);
@@ -3830,8 +3844,6 @@ int prepare_revision_walk(struct rev_info *revs)
                                       FOR_EACH_OBJECT_PROMISOR_ONLY);
        }
 
-       oidset_init(&revs->missing_commits, 0);
-
        if (!revs->reflog_info)
                prepare_to_use_bloom_filter(revs);
        if (!revs->unsorted_input)
index 3cc88d8a8004d91eb2a404214f4ac136a845d61f..35dd7e561a60c56d2639068a6afde50099497d65 100644 (file)
@@ -474,7 +474,7 @@ static void print_advice(struct repository *r, int show_hint,
                 * of the commit itself so remove CHERRY_PICK_HEAD
                 */
                refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
-                               NULL, 0);
+                               NULL, REF_NO_DEREF);
                return;
        }
 
@@ -707,6 +707,8 @@ static int do_recursive_merge(struct repository *r,
        o.show_rename_progress = 1;
 
        head_tree = parse_tree_indirect(head);
+       if (!head_tree)
+               return error(_("unable to read tree (%s)"), oid_to_hex(head));
        next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r);
        base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r);
 
@@ -1667,7 +1669,7 @@ static int do_commit(struct repository *r,
                strbuf_release(&sb);
                if (!res) {
                        refs_delete_ref(get_main_ref_store(r), "",
-                                       "CHERRY_PICK_HEAD", NULL, 0);
+                                       "CHERRY_PICK_HEAD", NULL, REF_NO_DEREF);
                        unlink(git_path_merge_msg(r));
                        if (!is_rebase_i(opts))
                                print_commit_summary(r, NULL, &oid,
@@ -2406,9 +2408,10 @@ static int do_pick_commit(struct repository *r,
        } else if (allow == 2) {
                drop_commit = 1;
                refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
-                               NULL, 0);
+                               NULL, REF_NO_DEREF);
                unlink(git_path_merge_msg(r));
-               unlink(git_path_auto_merge(r));
+               refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
+                               NULL, REF_NO_DEREF);
                fprintf(stderr,
                        _("dropping %s %s -- patch contents already upstream\n"),
                        oid_to_hex(&commit->object.oid), msg.subject);
@@ -2802,7 +2805,7 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
 
        if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD")) {
                if (!refs_delete_ref(get_main_ref_store(r), "",
-                                    "CHERRY_PICK_HEAD", NULL, 0) &&
+                                    "CHERRY_PICK_HEAD", NULL, REF_NO_DEREF) &&
                    verbose)
                        warning(_("cancelling a cherry picking in progress"));
                opts.action = REPLAY_PICK;
@@ -2811,14 +2814,15 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
 
        if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) {
                if (!refs_delete_ref(get_main_ref_store(r), "", "REVERT_HEAD",
-                                    NULL, 0) &&
+                                    NULL, REF_NO_DEREF) &&
                    verbose)
                        warning(_("cancelling a revert in progress"));
                opts.action = REPLAY_REVERT;
                need_cleanup = 1;
        }
 
-       unlink(git_path_auto_merge(r));
+       refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
+                       NULL, REF_NO_DEREF);
 
        if (!need_cleanup)
                return;
@@ -3639,6 +3643,7 @@ static int do_exec(struct repository *r, const char *command_line)
        fprintf(stderr, _("Executing: %s\n"), command_line);
        cmd.use_shell = 1;
        strvec_push(&cmd.args, command_line);
+       strvec_push(&cmd.env, "GIT_CHERRY_PICK_HELP");
        status = run_command(&cmd);
 
        /* force re-reading of the cache */
@@ -3879,6 +3884,8 @@ static int do_reset(struct repository *r,
        }
 
        tree = parse_tree_indirect(&oid);
+       if (!tree)
+               return error(_("unable to read tree (%s)"), oid_to_hex(&oid));
        prime_cache_tree(r, r->index, tree);
 
        if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0)
@@ -4116,7 +4123,7 @@ static int do_merge(struct repository *r,
 
                strbuf_release(&ref_name);
                refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
-                               NULL, 0);
+                               NULL, REF_NO_DEREF);
                rollback_lock_file(&lock);
 
                ret = run_command(&cmd);
@@ -4461,12 +4468,17 @@ static enum todo_command peek_command(struct todo_list *todo_list, int offset)
        return -1;
 }
 
-void create_autostash(struct repository *r, const char *path)
+static void create_autostash_internal(struct repository *r,
+                                     const char *path,
+                                     const char *refname)
 {
        struct strbuf buf = STRBUF_INIT;
        struct lock_file lock_file = LOCK_INIT;
        int fd;
 
+       if (path && refname)
+               BUG("can only pass path or refname");
+
        fd = repo_hold_locked_index(r, &lock_file, 0);
        refresh_index(r->index, REFRESH_QUIET, NULL, NULL, NULL);
        if (0 <= fd)
@@ -4493,10 +4505,16 @@ void create_autostash(struct repository *r, const char *path)
                strbuf_reset(&buf);
                strbuf_add_unique_abbrev(&buf, &oid, DEFAULT_ABBREV);
 
-               if (safe_create_leading_directories_const(path))
-                       die(_("Could not create directory for '%s'"),
-                           path);
-               write_file(path, "%s", oid_to_hex(&oid));
+               if (path) {
+                       if (safe_create_leading_directories_const(path))
+                               die(_("Could not create directory for '%s'"),
+                                   path);
+                       write_file(path, "%s", oid_to_hex(&oid));
+               } else {
+                       refs_update_ref(get_main_ref_store(r), "", refname,
+                                       &oid, null_oid(), 0, UPDATE_REFS_DIE_ON_ERR);
+               }
+
                printf(_("Created autostash: %s\n"), buf.buf);
                if (reset_head(r, &ropts) < 0)
                        die(_("could not reset --hard"));
@@ -4507,6 +4525,16 @@ void create_autostash(struct repository *r, const char *path)
        strbuf_release(&buf);
 }
 
+void create_autostash(struct repository *r, const char *path)
+{
+       create_autostash_internal(r, path, NULL);
+}
+
+void create_autostash_ref(struct repository *r, const char *refname)
+{
+       create_autostash_internal(r, NULL, refname);
+}
+
 static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply)
 {
        struct child_process child = CHILD_PROCESS_INIT;
@@ -4584,6 +4612,41 @@ int apply_autostash_oid(const char *stash_oid)
        return apply_save_autostash_oid(stash_oid, 1);
 }
 
+static int apply_save_autostash_ref(struct repository *r, const char *refname,
+                                   int attempt_apply)
+{
+       struct object_id stash_oid;
+       char stash_oid_hex[GIT_MAX_HEXSZ + 1];
+       int flag, ret;
+
+       if (!refs_ref_exists(get_main_ref_store(r), refname))
+               return 0;
+
+       if (!refs_resolve_ref_unsafe(get_main_ref_store(r), refname,
+                                    RESOLVE_REF_READING, &stash_oid, &flag))
+               return -1;
+       if (flag & REF_ISSYMREF)
+               return error(_("autostash reference is a symref"));
+
+       oid_to_hex_r(stash_oid_hex, &stash_oid);
+       ret = apply_save_autostash_oid(stash_oid_hex, attempt_apply);
+
+       refs_delete_ref(get_main_ref_store(r), "", refname,
+                       &stash_oid, REF_NO_DEREF);
+
+       return ret;
+}
+
+int save_autostash_ref(struct repository *r, const char *refname)
+{
+       return apply_save_autostash_ref(r, refname, 0);
+}
+
+int apply_autostash_ref(struct repository *r, const char *refname)
+{
+       return apply_save_autostash_ref(r, refname, 1);
+}
+
 static int checkout_onto(struct repository *r, struct replay_opts *opts,
                         const char *onto_name, const struct object_id *onto,
                         const struct object_id *orig_head)
@@ -4766,8 +4829,10 @@ static int pick_commits(struct repository *r,
                        }
                        unlink(rebase_path_author_script());
                        unlink(git_path_merge_head(r));
-                       unlink(git_path_auto_merge(r));
-                       delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
+                       refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
+                                       NULL, REF_NO_DEREF);
+                       refs_delete_ref(get_main_ref_store(r), "", "REBASE_HEAD",
+                                       NULL, REF_NO_DEREF);
 
                        if (item->command == TODO_BREAK) {
                                if (!opts->verbose)
@@ -5108,7 +5173,7 @@ static int commit_staged_changes(struct repository *r,
                if (refs_ref_exists(get_main_ref_store(r),
                                    "CHERRY_PICK_HEAD") &&
                    refs_delete_ref(get_main_ref_store(r), "",
-                                   "CHERRY_PICK_HEAD", NULL, 0))
+                                   "CHERRY_PICK_HEAD", NULL, REF_NO_DEREF))
                        return error(_("could not remove CHERRY_PICK_HEAD"));
                if (unlink(git_path_merge_msg(r)) && errno != ENOENT)
                        return error_errno(_("could not remove '%s'"),
@@ -5122,7 +5187,8 @@ static int commit_staged_changes(struct repository *r,
                return error(_("could not commit staged changes."));
        unlink(rebase_path_amend());
        unlink(git_path_merge_head(r));
-       unlink(git_path_auto_merge(r));
+       refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
+                       NULL, REF_NO_DEREF);
        if (final_fixup) {
                unlink(rebase_path_fixup_msg());
                unlink(rebase_path_squash_msg());
index 913a0f652d9ab356bc066f162fa1e5197f6900eb..dcef7bb99c08b0f8e5a29905f8f3a4d6d2d34a45 100644 (file)
@@ -225,9 +225,12 @@ void commit_post_rewrite(struct repository *r,
                         const struct object_id *new_head);
 
 void create_autostash(struct repository *r, const char *path);
+void create_autostash_ref(struct repository *r, const char *refname);
 int save_autostash(const char *path);
+int save_autostash_ref(struct repository *r, const char *refname);
 int apply_autostash(const char *path);
 int apply_autostash_oid(const char *stash_oid);
+int apply_autostash_ref(struct repository *r, const char *refname);
 
 #define SUMMARY_INITIAL_COMMIT   (1 << 0)
 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
diff --git a/setup.c b/setup.c
index 75df6692ab3749cbe7e341fc498a587fc554b286..b69b1cbc2adb41aa5f4df8b1aff88761ea2cba5c 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -591,6 +591,17 @@ static enum extension_result handle_extension(const char *var,
                                     "extensions.objectformat", value);
                data->hash_algo = format;
                return EXTENSION_OK;
+       } else if (!strcmp(ext, "refstorage")) {
+               unsigned int format;
+
+               if (!value)
+                       return config_error_nonbool(var);
+               format = ref_storage_format_by_name(value);
+               if (format == REF_STORAGE_FORMAT_UNKNOWN)
+                       return error(_("invalid value for '%s': '%s'"),
+                                    "extensions.refstorage", value);
+               data->ref_storage_format = format;
+               return EXTENSION_OK;
        }
        return EXTENSION_UNKNOWN;
 }
@@ -1360,7 +1371,8 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
 
                if (is_git_directory(dir->buf)) {
                        trace2_data_string("setup", NULL, "implicit-bare-repository", dir->buf);
-                       if (get_allowed_bare_repo() == ALLOWED_BARE_REPO_EXPLICIT)
+                       if (get_allowed_bare_repo() == ALLOWED_BARE_REPO_EXPLICIT &&
+                           !ends_with_path_components(dir->buf, ".git"))
                                return GIT_DIR_DISALLOWED_BARE;
                        if (!ensure_valid_ownership(NULL, NULL, dir->buf, report))
                                return GIT_DIR_INVALID_OWNERSHIP;
@@ -1565,6 +1577,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
                }
                if (startup_info->have_repository) {
                        repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
+                       repo_set_ref_storage_format(the_repository,
+                                                   repo_fmt.ref_storage_format);
                        the_repository->repository_format_worktree_config =
                                repo_fmt.worktree_config;
                        /* take ownership of repo_fmt.partial_clone */
@@ -1658,6 +1672,8 @@ void check_repository_format(struct repository_format *fmt)
        check_repository_format_gently(get_git_dir(), fmt, NULL);
        startup_info->have_repository = 1;
        repo_set_hash_algo(the_repository, fmt->hash_algo);
+       repo_set_ref_storage_format(the_repository,
+                                   fmt->ref_storage_format);
        the_repository->repository_format_worktree_config =
                fmt->worktree_config;
        the_repository->repository_format_partial_clone =
@@ -1866,12 +1882,15 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)
        return 1;
 }
 
-void initialize_repository_version(int hash_algo, int reinit)
+void initialize_repository_version(int hash_algo,
+                                  unsigned int ref_storage_format,
+                                  int reinit)
 {
        char repo_version_string[10];
        int repo_version = GIT_REPO_VERSION;
 
-       if (hash_algo != GIT_HASH_SHA1)
+       if (hash_algo != GIT_HASH_SHA1 ||
+           ref_storage_format != REF_STORAGE_FORMAT_FILES)
                repo_version = GIT_REPO_VERSION_READ;
 
        /* This forces creation of new config file */
@@ -1884,23 +1903,72 @@ void initialize_repository_version(int hash_algo, int reinit)
                               hash_algos[hash_algo].name);
        else if (reinit)
                git_config_set_gently("extensions.objectformat", NULL);
+
+       if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
+               git_config_set("extensions.refstorage",
+                              ref_storage_format_to_name(ref_storage_format));
+}
+
+static int is_reinit(void)
+{
+       struct strbuf buf = STRBUF_INIT;
+       char junk[2];
+       int ret;
+
+       git_path_buf(&buf, "HEAD");
+       ret = !access(buf.buf, R_OK) || readlink(buf.buf, junk, sizeof(junk) - 1) != -1;
+       strbuf_release(&buf);
+       return ret;
+}
+
+void create_reference_database(unsigned int ref_storage_format,
+                              const char *initial_branch, int quiet)
+{
+       struct strbuf err = STRBUF_INIT;
+       int reinit = is_reinit();
+
+       repo_set_ref_storage_format(the_repository, ref_storage_format);
+       if (refs_init_db(get_main_ref_store(the_repository), 0, &err))
+               die("failed to set up refs db: %s", err.buf);
+
+       /*
+        * Point the HEAD symref to the initial branch with if HEAD does
+        * not yet exist.
+        */
+       if (!reinit) {
+               char *ref;
+
+               if (!initial_branch)
+                       initial_branch = git_default_branch_name(quiet);
+
+               ref = xstrfmt("refs/heads/%s", initial_branch);
+               if (check_refname_format(ref, 0) < 0)
+                       die(_("invalid initial branch name: '%s'"),
+                           initial_branch);
+
+               if (create_symref("HEAD", ref, NULL) < 0)
+                       exit(1);
+               free(ref);
+       }
+
+       if (reinit && initial_branch)
+               warning(_("re-init: ignored --initial-branch=%s"),
+                       initial_branch);
+
+       strbuf_release(&err);
 }
 
 static int create_default_files(const char *template_path,
                                const char *original_git_dir,
-                               const char *initial_branch,
                                const struct repository_format *fmt,
                                int prev_bare_repository,
-                               int init_shared_repository,
-                               int quiet)
+                               int init_shared_repository)
 {
        struct stat st1;
        struct strbuf buf = STRBUF_INIT;
        char *path;
-       char junk[2];
        int reinit;
        int filemode;
-       struct strbuf err = STRBUF_INIT;
        const char *init_template_dir = NULL;
        const char *work_tree = get_git_work_tree();
 
@@ -1920,6 +1988,8 @@ static int create_default_files(const char *template_path,
        reset_shared_repository();
        git_config(git_default_config, NULL);
 
+       reinit = is_reinit();
+
        /*
         * We must make sure command-line options continue to override any
         * values we might have just re-read from the config.
@@ -1963,40 +2033,7 @@ static int create_default_files(const char *template_path,
                adjust_shared_perm(get_git_dir());
        }
 
-       /*
-        * We need to create a "refs" dir in any case so that older
-        * versions of git can tell that this is a repository.
-        */
-       safe_create_dir(git_path("refs"), 1);
-       adjust_shared_perm(git_path("refs"));
-
-       if (refs_init_db(&err))
-               die("failed to set up refs db: %s", err.buf);
-
-       /*
-        * Point the HEAD symref to the initial branch with if HEAD does
-        * not yet exist.
-        */
-       path = git_path_buf(&buf, "HEAD");
-       reinit = (!access(path, R_OK)
-                 || readlink(path, junk, sizeof(junk)-1) != -1);
-       if (!reinit) {
-               char *ref;
-
-               if (!initial_branch)
-                       initial_branch = git_default_branch_name(quiet);
-
-               ref = xstrfmt("refs/heads/%s", initial_branch);
-               if (check_refname_format(ref, 0) < 0)
-                       die(_("invalid initial branch name: '%s'"),
-                           initial_branch);
-
-               if (create_symref("HEAD", ref, NULL) < 0)
-                       exit(1);
-               free(ref);
-       }
-
-       initialize_repository_version(fmt->hash_algo, 0);
+       initialize_repository_version(fmt->hash_algo, fmt->ref_storage_format, 0);
 
        /* Check filemode trustability */
        path = git_path_buf(&buf, "config");
@@ -2109,8 +2146,29 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash
        }
 }
 
+static void validate_ref_storage_format(struct repository_format *repo_fmt,
+                                       unsigned int format)
+{
+       const char *name = getenv("GIT_DEFAULT_REF_FORMAT");
+
+       if (repo_fmt->version >= 0 &&
+           format != REF_STORAGE_FORMAT_UNKNOWN &&
+           format != repo_fmt->ref_storage_format) {
+               die(_("attempt to reinitialize repository with different reference storage format"));
+       } else if (format != REF_STORAGE_FORMAT_UNKNOWN) {
+               repo_fmt->ref_storage_format = format;
+       } else if (name) {
+               format = ref_storage_format_by_name(name);
+               if (format == REF_STORAGE_FORMAT_UNKNOWN)
+                       die(_("unknown ref storage format '%s'"), name);
+               repo_fmt->ref_storage_format = format;
+       }
+}
+
 int init_db(const char *git_dir, const char *real_git_dir,
-           const char *template_dir, int hash, const char *initial_branch,
+           const char *template_dir, int hash,
+           unsigned int ref_storage_format,
+           const char *initial_branch,
            int init_shared_repository, unsigned int flags)
 {
        int reinit;
@@ -2153,16 +2211,22 @@ int init_db(const char *git_dir, const char *real_git_dir,
        check_repository_format(&repo_fmt);
 
        validate_hash_algorithm(&repo_fmt, hash);
+       validate_ref_storage_format(&repo_fmt, ref_storage_format);
 
        reinit = create_default_files(template_dir, original_git_dir,
-                                     initial_branch, &repo_fmt,
-                                     prev_bare_repository,
-                                     init_shared_repository,
-                                     flags & INIT_DB_QUIET);
-       if (reinit && initial_branch)
-               warning(_("re-init: ignored --initial-branch=%s"),
-                       initial_branch);
+                                     &repo_fmt, prev_bare_repository,
+                                     init_shared_repository);
+
+       /*
+        * Now that we have set up both the hash algorithm and the ref storage
+        * format we can update the repository's settings accordingly.
+        */
+       repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
+       repo_set_ref_storage_format(the_repository, repo_fmt.ref_storage_format);
 
+       if (!(flags & INIT_DB_SKIP_REFDB))
+               create_reference_database(repo_fmt.ref_storage_format,
+                                         initial_branch, flags & INIT_DB_QUIET);
        create_object_directory();
 
        if (get_shared_repository()) {
diff --git a/setup.h b/setup.h
index b48cf1c43b5a559057a2e92d2fe4250c15255344..3599aec93c5ac0b72aafaf3cdcb030831cc53e3b 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -115,6 +115,7 @@ struct repository_format {
        int worktree_config;
        int is_bare;
        int hash_algo;
+       unsigned int ref_storage_format;
        int sparse_index;
        char *work_tree;
        struct string_list unknown_extensions;
@@ -131,6 +132,7 @@ struct repository_format {
        .version = -1, \
        .is_bare = -1, \
        .hash_algo = GIT_HASH_SHA1, \
+       .ref_storage_format = REF_STORAGE_FORMAT_FILES, \
        .unknown_extensions = STRING_LIST_INIT_DUP, \
        .v1_only_extensions = STRING_LIST_INIT_DUP, \
 }
@@ -169,14 +171,20 @@ int verify_repository_format(const struct repository_format *format,
  */
 void check_repository_format(struct repository_format *fmt);
 
-#define INIT_DB_QUIET 0x0001
-#define INIT_DB_EXIST_OK 0x0002
+#define INIT_DB_QUIET      (1 << 0)
+#define INIT_DB_EXIST_OK   (1 << 1)
+#define INIT_DB_SKIP_REFDB (1 << 2)
 
 int init_db(const char *git_dir, const char *real_git_dir,
            const char *template_dir, int hash_algo,
+           unsigned int ref_storage_format,
            const char *initial_branch, int init_shared_repository,
            unsigned int flags);
-void initialize_repository_version(int hash_algo, int reinit);
+void initialize_repository_version(int hash_algo,
+                                  unsigned int ref_storage_format,
+                                  int reinit);
+void create_reference_database(unsigned int ref_storage_format,
+                              const char *initial_branch, int quiet);
 
 /*
  * NOTE NOTE NOTE!!
index aeb80fc4d5a33e1b5c6f2e1bbdf4cc3279802eef..29bebd30d8acbce9f50661cef48ecdbae1e41f5a 100644 (file)
@@ -108,3 +108,11 @@ endif
 define mkdir_p_parent_template
 $(if $(wildcard $(@D)),,$(QUIET_MKDIR_P_PARENT)$(shell mkdir -p $(@D)))
 endef
+
+## Getting sick of writing -L$(SOMELIBDIR) $(CC_LD_DYNPATH)$(SOMELIBDIR)?
+## Write $(call libpath_template,$(SOMELIBDIR)) instead, perhaps?
+## With CC_LD_DYNPATH set to either an empty string or to "-L", the
+## the directory is not shown the second time.
+define libpath_template
+-L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1))
+endef
index 3578feb28376e308ebb1ab1adc069c6860bbe72b..e48e40cae71f975f98f1874b90fc8889c0c710e2 100644 (file)
@@ -579,8 +579,9 @@ void expand_to_path(struct index_state *istate,
                replace++;
                temp = *replace;
                *replace = '\0';
+               substr_len = replace - path_mutable.buf;
                if (index_file_exists(istate, path_mutable.buf,
-                                     path_mutable.len, icase)) {
+                                     substr_len, icase)) {
                        /*
                         * We found a parent directory in the name-hash
                         * hashtable, because only sparse directory entries
@@ -593,7 +594,6 @@ void expand_to_path(struct index_state *istate,
                }
 
                *replace = temp;
-               substr_len = replace - path_mutable.buf;
        }
 
 cleanup:
index 9367ca099cd114d56d7b2103b0e56fa4933f5781..3c6bc049c15d44c33c064fecbbd2236571b2dadb 100644 (file)
@@ -31,6 +31,33 @@ void fill_stat_data(struct stat_data *sd, struct stat *st)
        sd->sd_size = munge_st_size(st->st_size);
 }
 
+static void set_times(struct stat *st, const struct stat_data *sd)
+{
+       st->st_ctime = sd->sd_ctime.sec;
+       st->st_mtime = sd->sd_mtime.sec;
+#ifdef NO_NSEC
+       ; /* nothing */
+#else
+#ifdef USE_ST_TIMESPEC
+       st->st_ctimespec.tv_nsec = sd->sd_ctime.nsec;
+       st->st_mtimespec.tv_nsec = sd->sd_mtime.nsec;
+#else
+       st->st_ctim.tv_nsec = sd->sd_ctime.nsec;
+       st->st_mtim.tv_nsec = sd->sd_mtime.nsec;
+#endif
+#endif
+}
+
+void fake_lstat_data(const struct stat_data *sd, struct stat *st)
+{
+       set_times(st, sd);
+       st->st_dev = sd->sd_dev;
+       st->st_ino = sd->sd_ino;
+       st->st_uid = sd->sd_uid;
+       st->st_gid = sd->sd_gid;
+       st->st_size = sd->sd_size;
+}
+
 int match_stat_data(const struct stat_data *sd, struct stat *st)
 {
        int changed = 0;
index 700f502ac0b3cb938c2f376653dc1e91ac4e6d24..5b21a30f90bfd2e1fed39fed0d61b9abb360af33 100644 (file)
@@ -46,6 +46,14 @@ struct stat_validity {
  */
 void fill_stat_data(struct stat_data *sd, struct stat *st);
 
+/*
+ * The inverse of the above.  When we know the cache_entry that
+ * contains sd is up-to-date, but still need to pretend we called
+ * lstat() to learn that fact, this function fills "st" enough to
+ * fool ie_match_stat().
+ */
+void fake_lstat_data(const struct stat_data *sd, struct stat *st);
+
 /*
  * Return 0 if st is consistent with a file not having been changed
  * since sd was filled.  If there are differences, return a
index f4dd482abc95e7c1668623be7c24ec163745e189..54130f6a38572b613d4b7ee8ae1cf3bc6035055d 100644 (file)
@@ -14,6 +14,8 @@
 #include "parse-options.h"
 #include "thread-utils.h"
 #include "tree-walk.h"
+#include "url.h"
+#include "urlmatch.h"
 
 /*
  * submodule cache lookup structure
@@ -228,6 +230,144 @@ in_component:
        return 0;
 }
 
+static int starts_with_dot_slash(const char *const path)
+{
+       return path_match_flags(path, PATH_MATCH_STARTS_WITH_DOT_SLASH |
+                               PATH_MATCH_XPLATFORM);
+}
+
+static int starts_with_dot_dot_slash(const char *const path)
+{
+       return path_match_flags(path, PATH_MATCH_STARTS_WITH_DOT_DOT_SLASH |
+                               PATH_MATCH_XPLATFORM);
+}
+
+static int submodule_url_is_relative(const char *url)
+{
+       return starts_with_dot_slash(url) || starts_with_dot_dot_slash(url);
+}
+
+/*
+ * Count directory components that a relative submodule URL should chop
+ * from the remote_url it is to be resolved against.
+ *
+ * In other words, this counts "../" components at the start of a
+ * submodule URL.
+ *
+ * Returns the number of directory components to chop and writes a
+ * pointer to the next character of url after all leading "./" and
+ * "../" components to out.
+ */
+static int count_leading_dotdots(const char *url, const char **out)
+{
+       int result = 0;
+       while (1) {
+               if (starts_with_dot_dot_slash(url)) {
+                       result++;
+                       url += strlen("../");
+                       continue;
+               }
+               if (starts_with_dot_slash(url)) {
+                       url += strlen("./");
+                       continue;
+               }
+               *out = url;
+               return result;
+       }
+}
+/*
+ * Check whether a transport is implemented by git-remote-curl.
+ *
+ * If it is, returns 1 and writes the URL that would be passed to
+ * git-remote-curl to the "out" parameter.
+ *
+ * Otherwise, returns 0 and leaves "out" untouched.
+ *
+ * Examples:
+ *   http::https://example.com/repo.git -> 1, https://example.com/repo.git
+ *   https://example.com/repo.git -> 1, https://example.com/repo.git
+ *   git://example.com/repo.git -> 0
+ *
+ * This is for use in checking for previously exploitable bugs that
+ * required a submodule URL to be passed to git-remote-curl.
+ */
+static int url_to_curl_url(const char *url, const char **out)
+{
+       /*
+        * We don't need to check for case-aliases, "http.exe", and so
+        * on because in the default configuration, is_transport_allowed
+        * prevents URLs with those schemes from being cloned
+        * automatically.
+        */
+       if (skip_prefix(url, "http::", out) ||
+           skip_prefix(url, "https::", out) ||
+           skip_prefix(url, "ftp::", out) ||
+           skip_prefix(url, "ftps::", out))
+               return 1;
+       if (starts_with(url, "http://") ||
+           starts_with(url, "https://") ||
+           starts_with(url, "ftp://") ||
+           starts_with(url, "ftps://")) {
+               *out = url;
+               return 1;
+       }
+       return 0;
+}
+
+int check_submodule_url(const char *url)
+{
+       const char *curl_url;
+
+       if (looks_like_command_line_option(url))
+               return -1;
+
+       if (submodule_url_is_relative(url) || starts_with(url, "git://")) {
+               char *decoded;
+               const char *next;
+               int has_nl;
+
+               /*
+                * This could be appended to an http URL and url-decoded;
+                * check for malicious characters.
+                */
+               decoded = url_decode(url);
+               has_nl = !!strchr(decoded, '\n');
+
+               free(decoded);
+               if (has_nl)
+                       return -1;
+
+               /*
+                * URLs which escape their root via "../" can overwrite
+                * the host field and previous components, resolving to
+                * URLs like https::example.com/submodule.git and
+                * https:///example.com/submodule.git that were
+                * susceptible to CVE-2020-11008.
+                */
+               if (count_leading_dotdots(url, &next) > 0 &&
+                   (*next == ':' || *next == '/'))
+                       return -1;
+       }
+
+       else if (url_to_curl_url(url, &curl_url)) {
+               int ret = 0;
+               char *normalized = url_normalize(curl_url, NULL);
+               if (normalized) {
+                       char *decoded = url_decode(normalized);
+                       if (strchr(decoded, '\n'))
+                               ret = -1;
+                       free(normalized);
+                       free(decoded);
+               } else {
+                       ret = -1;
+               }
+
+               return ret;
+       }
+
+       return 0;
+}
+
 static int name_and_item_from_var(const char *var, struct strbuf *name,
                                  struct strbuf *item)
 {
index 958f320ac6ce08a0b0ac856415a173d5fa7c2600..b6133af71b00d61abdafc3aa736fe4f4018695cf 100644 (file)
@@ -89,6 +89,9 @@ int config_set_in_gitmodules_file_gently(const char *key, const char *value);
  */
 int check_submodule_name(const char *name);
 
+/* Returns 0 if the URL valid per RFC3986 and -1 otherwise. */
+int check_submodule_url(const char *url);
+
 /*
  * Note: these helper functions exist solely to maintain backward
  * compatibility with 'fetch' and 'update_clone' storing configuration in
index 213da79f66116f3db835036140affb98406a934a..40f13a36857179c39d31891396c892c5b7e54f72 100644 (file)
@@ -1687,8 +1687,6 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
                task = get_fetch_task_from_changed(spf, err);
 
        if (task) {
-               struct strbuf submodule_prefix = STRBUF_INIT;
-
                child_process_init(cp);
                cp->dir = task->repo->gitdir;
                prepare_submodule_repo_env_in_gitdir(&cp->env);
@@ -1698,15 +1696,11 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
                        strvec_pushv(&cp->args, task->git_args.v);
                strvec_pushv(&cp->args, spf->args.v);
                strvec_push(&cp->args, task->default_argv);
-               strvec_push(&cp->args, "--submodule-prefix");
+               strvec_pushf(&cp->args, "--submodule-prefix=%s%s/",
+                            spf->prefix, task->sub->path);
 
-               strbuf_addf(&submodule_prefix, "%s%s/",
-                                               spf->prefix,
-                                               task->sub->path);
-               strvec_push(&cp->args, submodule_prefix.buf);
                *task_cb = task;
 
-               strbuf_release(&submodule_prefix);
                string_list_insert(&spf->seen_submodule_names, task->sub->name);
                return 1;
        }
@@ -1714,12 +1708,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
        if (spf->oid_fetch_tasks_nr) {
                struct fetch_task *task =
                        spf->oid_fetch_tasks[spf->oid_fetch_tasks_nr - 1];
-               struct strbuf submodule_prefix = STRBUF_INIT;
                spf->oid_fetch_tasks_nr--;
 
-               strbuf_addf(&submodule_prefix, "%s%s/",
-                           spf->prefix, task->sub->path);
-
                child_process_init(cp);
                prepare_submodule_repo_env_in_gitdir(&cp->env);
                cp->git_cmd = 1;
@@ -1728,8 +1718,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
                strvec_init(&cp->args);
                strvec_pushv(&cp->args, spf->args.v);
                strvec_push(&cp->args, "on-demand");
-               strvec_push(&cp->args, "--submodule-prefix");
-               strvec_push(&cp->args, submodule_prefix.buf);
+               strvec_pushf(&cp->args, "--submodule-prefix=%s%s/",
+                            spf->prefix, task->sub->path);
 
                /* NEEDSWORK: have get_default_remote from submodule--helper */
                strvec_push(&cp->args, "origin");
@@ -1737,7 +1727,6 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
                                          append_oid_to_argv, &cp->args);
 
                *task_cb = task;
-               strbuf_release(&submodule_prefix);
                return 1;
        }
 
index fae301248fe3d8d7394449b63a9282e74b522046..2d95046f26ec6ebad9d8707e8c002aadc665a282 100644 (file)
@@ -1,3 +1,6 @@
+# The default target of this Makefile is...
+all::
+
 # Import tree-wide shared Makefile behavior and libraries
 include ../shared.mak
 
@@ -6,6 +9,7 @@ include ../shared.mak
 # Copyright (c) 2005 Junio C Hamano
 #
 
+-include ../config.mak.uname
 -include ../config.mak.autogen
 -include ../config.mak
 
@@ -17,6 +21,7 @@ TAR ?= $(TAR)
 RM ?= rm -f
 PROVE ?= prove
 DEFAULT_TEST_TARGET ?= test
+DEFAULT_UNIT_TEST_TARGET ?= unit-tests-raw
 TEST_LINT ?= test-lint
 
 ifdef TEST_OUTPUT_DIRECTORY
@@ -41,13 +46,16 @@ TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
 TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
 CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
 CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
+UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c)
+UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%$(X),$(UNIT_TEST_SOURCES))
+UNIT_TESTS = $(sort $(filter-out unit-tests/bin/t-basic%,$(UNIT_TEST_PROGRAMS)))
 
 # `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
 # checks all tests in all scripts via a single invocation, so tell individual
 # scripts not to run the external "chainlint.pl" script themselves
 CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT &&
 
-all: $(DEFAULT_TEST_TARGET)
+all:: $(DEFAULT_TEST_TARGET)
 
 test: pre-clean check-chainlint $(TEST_LINT)
        $(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
@@ -65,6 +73,17 @@ prove: pre-clean check-chainlint $(TEST_LINT)
 $(T):
        @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
 
+$(UNIT_TESTS):
+       @echo "*** $@ ***"; $@
+
+.PHONY: unit-tests unit-tests-raw unit-tests-prove
+unit-tests: $(DEFAULT_UNIT_TEST_TARGET)
+
+unit-tests-raw: $(UNIT_TESTS)
+
+unit-tests-prove:
+       @echo "*** prove - unit tests ***"; $(PROVE) $(GIT_PROVE_OPTS) $(UNIT_TESTS)
+
 pre-clean:
        $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
 
@@ -141,4 +160,4 @@ perf:
        $(MAKE) -C perf/ all
 
 .PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
-       check-chainlint clean-chainlint test-chainlint
+       check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
index 36463d074259e3805e6de6d41d30bc3632b369f5..621d3b8c095441a8a8985b7f12363e26f8ab4d98 100644 (file)
--- a/t/README
+++ b/t/README
@@ -479,6 +479,9 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to
 use in the test scripts. Recognized values for <hash-algo> are "sha1"
 and "sha256".
 
+GIT_TEST_DEFAULT_REF_FORMAT=<format> specifies which ref storage format
+to use in the test scripts. Recognized values for <format> are "files".
+
 GIT_TEST_NO_WRITE_REV_INDEX=<boolean>, when true disables the
 'pack.writeReverseIndex' setting.
 
diff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c
deleted file mode 100644 (file)
index e5659df..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "test-tool.h"
-
-static int rc;
-
-static void report_error(const char *class, int ch)
-{
-       printf("%s classifies char %d (0x%02x) wrongly\n", class, ch, ch);
-       rc = 1;
-}
-
-static int is_in(const char *s, int ch)
-{
-       /*
-        * We can't find NUL using strchr. Accept it as the first
-        * character in the spec -- there are no empty classes.
-        */
-       if (ch == '\0')
-               return ch == *s;
-       if (*s == '\0')
-               s++;
-       return !!strchr(s, ch);
-}
-
-#define TEST_CLASS(t,s) {                      \
-       int i;                                  \
-       for (i = 0; i < 256; i++) {             \
-               if (is_in(s, i) != t(i))        \
-                       report_error(#t, i);    \
-       }                                       \
-       if (t(EOF))                             \
-               report_error(#t, EOF);          \
-}
-
-#define DIGIT "0123456789"
-#define LOWER "abcdefghijklmnopqrstuvwxyz"
-#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define PUNCT "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
-#define ASCII \
-       "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \
-       "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
-       "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" \
-       "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" \
-       "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" \
-       "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" \
-       "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" \
-       "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
-#define CNTRL \
-       "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \
-       "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
-       "\x7f"
-
-int cmd__ctype(int argc UNUSED, const char **argv UNUSED)
-{
-       TEST_CLASS(isdigit, DIGIT);
-       TEST_CLASS(isspace, " \n\r\t");
-       TEST_CLASS(isalpha, LOWER UPPER);
-       TEST_CLASS(isalnum, LOWER UPPER DIGIT);
-       TEST_CLASS(is_glob_special, "*?[\\");
-       TEST_CLASS(is_regex_special, "$()*+.?[\\^{|");
-       TEST_CLASS(is_pathspec_magic, "!\"#%&',-/:;<=>@_`~");
-       TEST_CLASS(isascii, ASCII);
-       TEST_CLASS(islower, LOWER);
-       TEST_CLASS(isupper, UPPER);
-       TEST_CLASS(iscntrl, CNTRL);
-       TEST_CLASS(ispunct, PUNCT);
-       TEST_CLASS(isxdigit, DIGIT "abcdefABCDEF");
-       TEST_CLASS(isprint, LOWER UPPER DIGIT PUNCT " ");
-
-       return rc;
-}
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
deleted file mode 100644 (file)
index cac20a7..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * "git fast-rebase" builtin command
- *
- * FAST: Forking Any Subprocesses (is) Taboo
- *
- * This is meant SOLELY as a demo of what is possible.  sequencer.c and
- * rebase.c should be refactored to use the ideas here, rather than attempting
- * to extend this file to replace those (unless Phillip or Dscho say that
- * refactoring is too hard and we need a clean slate, but I'm guessing that
- * refactoring is the better route).
- */
-
-#define USE_THE_INDEX_VARIABLE
-#include "test-tool.h"
-#include "cache-tree.h"
-#include "commit.h"
-#include "environment.h"
-#include "gettext.h"
-#include "hash.h"
-#include "hex.h"
-#include "lockfile.h"
-#include "merge-ort.h"
-#include "object-name.h"
-#include "read-cache-ll.h"
-#include "refs.h"
-#include "revision.h"
-#include "sequencer.h"
-#include "setup.h"
-#include "strvec.h"
-#include "tree.h"
-
-static const char *short_commit_name(struct commit *commit)
-{
-       return repo_find_unique_abbrev(the_repository, &commit->object.oid,
-                                      DEFAULT_ABBREV);
-}
-
-static struct commit *peel_committish(const char *name)
-{
-       struct object *obj;
-       struct object_id oid;
-
-       if (repo_get_oid(the_repository, name, &oid))
-               return NULL;
-       obj = parse_object(the_repository, &oid);
-       return (struct commit *)repo_peel_to_type(the_repository, name, 0, obj,
-                                                 OBJ_COMMIT);
-}
-
-static char *get_author(const char *message)
-{
-       size_t len;
-       const char *a;
-
-       a = find_commit_header(message, "author", &len);
-       if (a)
-               return xmemdupz(a, len);
-
-       return NULL;
-}
-
-static struct commit *create_commit(struct tree *tree,
-                                   struct commit *based_on,
-                                   struct commit *parent)
-{
-       struct object_id ret;
-       struct object *obj;
-       struct commit_list *parents = NULL;
-       char *author;
-       char *sign_commit = NULL;
-       struct commit_extra_header *extra;
-       struct strbuf msg = STRBUF_INIT;
-       const char *out_enc = get_commit_output_encoding();
-       const char *message = repo_logmsg_reencode(the_repository, based_on,
-                                                  NULL, out_enc);
-       const char *orig_message = NULL;
-       const char *exclude_gpgsig[] = { "gpgsig", NULL };
-
-       commit_list_insert(parent, &parents);
-       extra = read_commit_extra_headers(based_on, exclude_gpgsig);
-       find_commit_subject(message, &orig_message);
-       strbuf_addstr(&msg, orig_message);
-       author = get_author(message);
-       reset_ident_date();
-       if (commit_tree_extended(msg.buf, msg.len, &tree->object.oid, parents,
-                                &ret, author, NULL, sign_commit, extra)) {
-               error(_("failed to write commit object"));
-               return NULL;
-       }
-       free(author);
-       strbuf_release(&msg);
-
-       obj = parse_object(the_repository, &ret);
-       return (struct commit *)obj;
-}
-
-int cmd__fast_rebase(int argc, const char **argv)
-{
-       struct commit *onto;
-       struct commit *last_commit = NULL, *last_picked_commit = NULL;
-       struct object_id head;
-       struct lock_file lock = LOCK_INIT;
-       struct strvec rev_walk_args = STRVEC_INIT;
-       struct rev_info revs;
-       struct commit *commit;
-       struct merge_options merge_opt;
-       struct tree *next_tree, *base_tree, *head_tree;
-       struct merge_result result;
-       struct strbuf reflog_msg = STRBUF_INIT;
-       struct strbuf branch_name = STRBUF_INIT;
-       int ret = 0;
-
-       /*
-        * test-tool stuff doesn't set up the git directory by default; need to
-        * do that manually.
-        */
-       setup_git_directory();
-
-       if (argc == 2 && !strcmp(argv[1], "-h")) {
-               printf("Sorry, I am not a psychiatrist; I can not give you the help you need.  Oh, you meant usage...\n");
-               exit(129);
-       }
-
-       if (argc != 5 || strcmp(argv[1], "--onto"))
-               die("usage: read the code, figure out how to use it, then do so");
-
-       onto = peel_committish(argv[2]);
-       strbuf_addf(&branch_name, "refs/heads/%s", argv[4]);
-
-       /* Sanity check */
-       if (repo_get_oid(the_repository, "HEAD", &head))
-               die(_("Cannot read HEAD"));
-       assert(oideq(&onto->object.oid, &head));
-
-       repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
-       if (repo_read_index(the_repository) < 0)
-               BUG("Could not read index");
-
-       repo_init_revisions(the_repository, &revs, NULL);
-       revs.verbose_header = 1;
-       revs.max_parents = 1;
-       revs.cherry_mark = 1;
-       revs.limited = 1;
-       revs.reverse = 1;
-       revs.right_only = 1;
-       revs.sort_order = REV_SORT_IN_GRAPH_ORDER;
-       revs.topo_order = 1;
-       strvec_pushl(&rev_walk_args, "", argv[4], "--not", argv[3], NULL);
-
-       if (setup_revisions(rev_walk_args.nr, rev_walk_args.v, &revs, NULL) > 1) {
-               ret = error(_("unhandled options"));
-               goto cleanup;
-       }
-
-       strvec_clear(&rev_walk_args);
-
-       if (prepare_revision_walk(&revs) < 0) {
-               ret = error(_("error preparing revisions"));
-               goto cleanup;
-       }
-
-       init_merge_options(&merge_opt, the_repository);
-       memset(&result, 0, sizeof(result));
-       merge_opt.show_rename_progress = 1;
-       merge_opt.branch1 = "HEAD";
-       head_tree = repo_get_commit_tree(the_repository, onto);
-       result.tree = head_tree;
-       last_commit = onto;
-       while ((commit = get_revision(&revs))) {
-               struct commit *base;
-
-               fprintf(stderr, "Rebasing %s...\r",
-                       oid_to_hex(&commit->object.oid));
-               assert(commit->parents && !commit->parents->next);
-               base = commit->parents->item;
-
-               next_tree = repo_get_commit_tree(the_repository, commit);
-               base_tree = repo_get_commit_tree(the_repository, base);
-
-               merge_opt.branch2 = short_commit_name(commit);
-               merge_opt.ancestor = xstrfmt("parent of %s", merge_opt.branch2);
-
-               merge_incore_nonrecursive(&merge_opt,
-                                         base_tree,
-                                         result.tree,
-                                         next_tree,
-                                         &result);
-
-               free((char*)merge_opt.ancestor);
-               merge_opt.ancestor = NULL;
-               if (!result.clean)
-                       break;
-               last_picked_commit = commit;
-               last_commit = create_commit(result.tree, commit, last_commit);
-       }
-
-       merge_switch_to_result(&merge_opt, head_tree, &result, 1, !result.clean);
-
-       if (result.clean < 0)
-               exit(128);
-
-       if (result.clean) {
-               fprintf(stderr, "\nDone.\n");
-               strbuf_addf(&reflog_msg, "finish rebase %s onto %s",
-                           oid_to_hex(&last_picked_commit->object.oid),
-                           oid_to_hex(&last_commit->object.oid));
-               if (update_ref(reflog_msg.buf, branch_name.buf,
-                              &last_commit->object.oid,
-                              &last_picked_commit->object.oid,
-                              REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
-                       error(_("could not update %s"), argv[4]);
-                       die("Failed to update %s", argv[4]);
-               }
-               if (create_symref("HEAD", branch_name.buf, reflog_msg.buf) < 0)
-                       die(_("unable to update HEAD"));
-
-               prime_cache_tree(the_repository, the_repository->index,
-                                result.tree);
-       } else {
-               fprintf(stderr, "\nAborting: Hit a conflict.\n");
-               strbuf_addf(&reflog_msg, "rebase progress up to %s",
-                           oid_to_hex(&last_picked_commit->object.oid));
-               if (update_ref(reflog_msg.buf, "HEAD",
-                              &last_commit->object.oid,
-                              &head,
-                              REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
-                       error(_("could not update %s"), argv[4]);
-                       die("Failed to update %s", argv[4]);
-               }
-       }
-       if (write_locked_index(&the_index, &lock,
-                              COMMIT_LOCK | SKIP_IF_UNCHANGED))
-               die(_("unable to write %s"), get_index_file());
-
-       ret = (result.clean == 0);
-cleanup:
-       strbuf_release(&reflog_msg);
-       strbuf_release(&branch_name);
-       release_revisions(&revs);
-       return ret;
-}
diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c
deleted file mode 100644 (file)
index f0bf255..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "test-tool.h"
-#include "prio-queue.h"
-
-static int intcmp(const void *va, const void *vb, void *data UNUSED)
-{
-       const int *a = va, *b = vb;
-       return *a - *b;
-}
-
-static void show(int *v)
-{
-       if (!v)
-               printf("NULL\n");
-       else
-               printf("%d\n", *v);
-       free(v);
-}
-
-int cmd__prio_queue(int argc UNUSED, const char **argv)
-{
-       struct prio_queue pq = { intcmp };
-
-       while (*++argv) {
-               if (!strcmp(*argv, "get")) {
-                       void *peek = prio_queue_peek(&pq);
-                       void *get = prio_queue_get(&pq);
-                       if (peek != get)
-                               BUG("peek and get results do not match");
-                       show(get);
-               } else if (!strcmp(*argv, "dump")) {
-                       void *peek;
-                       void *get;
-                       while ((peek = prio_queue_peek(&pq))) {
-                               get = prio_queue_get(&pq);
-                               if (peek != get)
-                                       BUG("peek and get results do not match");
-                               show(get);
-                       }
-               } else if (!strcmp(*argv, "stack")) {
-                       pq.compare = NULL;
-               } else {
-                       int *v = xmalloc(sizeof(*v));
-                       *v = atoi(*argv);
-                       prio_queue_put(&pq, v);
-               }
-       }
-
-       clear_prio_queue(&pq);
-
-       return 0;
-}
index e9a444ddba55b49c9c47ceb3b27a31d3e022a8dc..4acae41bb993c883970227f394a61603a6e7152d 100644 (file)
@@ -6,6 +6,7 @@
 #include "pack-bitmap.h"
 #include "packfile.h"
 #include "setup.h"
+#include "gettext.h"
 
 static int read_midx_file(const char *object_dir, int show_objects)
 {
@@ -79,7 +80,7 @@ static int read_midx_checksum(const char *object_dir)
 static int read_midx_preferred_pack(const char *object_dir)
 {
        struct multi_pack_index *midx = NULL;
-       struct bitmap_index *bitmap = NULL;
+       uint32_t preferred_pack;
 
        setup_git_directory();
 
@@ -87,23 +88,45 @@ static int read_midx_preferred_pack(const char *object_dir)
        if (!midx)
                return 1;
 
-       bitmap = prepare_bitmap_git(the_repository);
-       if (!bitmap)
+       if (midx_preferred_pack(midx, &preferred_pack) < 0) {
+               warning(_("could not determine MIDX preferred pack"));
                return 1;
-       if (!bitmap_is_midx(bitmap)) {
-               free_bitmap_index(bitmap);
+       }
+
+       printf("%s\n", midx->pack_names[preferred_pack]);
+       return 0;
+}
+
+static int read_midx_bitmapped_packs(const char *object_dir)
+{
+       struct multi_pack_index *midx = NULL;
+       struct bitmapped_pack pack;
+       uint32_t i;
+
+       setup_git_directory();
+
+       midx = load_multi_pack_index(object_dir, 1);
+       if (!midx)
                return 1;
+
+       for (i = 0; i < midx->num_packs; i++) {
+               if (nth_bitmapped_pack(the_repository, midx, &pack, i) < 0)
+                       return 1;
+
+               printf("%s\n", pack_basename(pack.p));
+               printf("  bitmap_pos: %"PRIuMAX"\n", (uintmax_t)pack.bitmap_pos);
+               printf("  bitmap_nr: %"PRIuMAX"\n", (uintmax_t)pack.bitmap_nr);
        }
 
-       printf("%s\n", midx->pack_names[midx_preferred_pack(bitmap)]);
-       free_bitmap_index(bitmap);
+       close_midx(midx);
+
        return 0;
 }
 
 int cmd__read_midx(int argc, const char **argv)
 {
        if (!(argc == 2 || argc == 3))
-               usage("read-midx [--show-objects|--checksum|--preferred-pack] <object-dir>");
+               usage("read-midx [--show-objects|--checksum|--preferred-pack|--bitmap] <object-dir>");
 
        if (!strcmp(argv[1], "--show-objects"))
                return read_midx_file(argv[2], 1);
@@ -111,5 +134,7 @@ int cmd__read_midx(int argc, const char **argv)
                return read_midx_checksum(argv[2]);
        else if (!strcmp(argv[1], "--preferred-pack"))
                return read_midx_preferred_pack(argv[2]);
+       else if (!strcmp(argv[1], "--bitmap"))
+               return read_midx_bitmapped_packs(argv[2]);
        return read_midx_file(argv[1], 0);
 }
index 48552e6a9e0049365185499c02d9b1c7d1069d0c..7a0f6cac53d2433ade595ce95ab2d30e214b2ede 100644 (file)
@@ -221,15 +221,21 @@ static int cmd_verify_ref(struct ref_store *refs, const char **argv)
        return ret;
 }
 
+static int each_reflog(const char *refname, void *cb_data UNUSED)
+{
+       printf("%s\n", refname);
+       return 0;
+}
+
 static int cmd_for_each_reflog(struct ref_store *refs,
                               const char **argv UNUSED)
 {
-       return refs_for_each_reflog(refs, each_ref, NULL);
+       return refs_for_each_reflog(refs, each_reflog, NULL);
 }
 
-static int each_reflog(struct object_id *old_oid, struct object_id *new_oid,
-                      const char *committer, timestamp_t timestamp,
-                      int tz, const char *msg, void *cb_data UNUSED)
+static int each_reflog_ent(struct object_id *old_oid, struct object_id *new_oid,
+                          const char *committer, timestamp_t timestamp,
+                          int tz, const char *msg, void *cb_data UNUSED)
 {
        printf("%s %s %s %" PRItime " %+05d%s%s", oid_to_hex(old_oid),
               oid_to_hex(new_oid), committer, timestamp, tz,
@@ -241,14 +247,14 @@ static int cmd_for_each_reflog_ent(struct ref_store *refs, const char **argv)
 {
        const char *refname = notnull(*argv++, "refname");
 
-       return refs_for_each_reflog_ent(refs, refname, each_reflog, refs);
+       return refs_for_each_reflog_ent(refs, refname, each_reflog_ent, refs);
 }
 
 static int cmd_for_each_reflog_ent_reverse(struct ref_store *refs, const char **argv)
 {
        const char *refname = notnull(*argv++, "refname");
 
-       return refs_for_each_reflog_ent_reverse(refs, refname, each_reflog, refs);
+       return refs_for_each_reflog_ent_reverse(refs, refname, each_reflog_ent, refs);
 }
 
 static int cmd_reflog_exists(struct ref_store *refs, const char **argv)
@@ -298,16 +304,19 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv)
        const char *new_sha1_buf = notnull(*argv++, "new-sha1");
        const char *old_sha1_buf = notnull(*argv++, "old-sha1");
        unsigned int flags = arg_flags(*argv++, "flags", transaction_flags);
-       struct object_id old_oid;
+       struct object_id old_oid, *old_oid_ptr = NULL;
        struct object_id new_oid;
 
-       if (get_oid_hex(old_sha1_buf, &old_oid))
-               die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name);
+       if (*old_sha1_buf) {
+               if (get_oid_hex(old_sha1_buf, &old_oid))
+                       die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name);
+               old_oid_ptr = &old_oid;
+       }
        if (get_oid_hex(new_sha1_buf, &new_oid))
                die("cannot parse %s as %s", new_sha1_buf, the_hash_algo->name);
 
        return refs_update_ref(refs, msg, refname,
-                              &new_oid, &old_oid,
+                              &new_oid, old_oid_ptr,
                               flags, UPDATE_REFS_DIE_ON_ERR);
 }
 
index 50c154d0370bfbdd91b70747133977a752f2b504..7197969a08149699a14c758ceef1223e494b7c35 100644 (file)
@@ -9,12 +9,19 @@
 #include "submodule.h"
 
 #define TEST_TOOL_CHECK_NAME_USAGE \
-       "test-tool submodule check-name <name>"
+       "test-tool submodule check-name"
 static const char *submodule_check_name_usage[] = {
        TEST_TOOL_CHECK_NAME_USAGE,
        NULL
 };
 
+#define TEST_TOOL_CHECK_URL_USAGE \
+       "test-tool submodule check-url"
+static const char *submodule_check_url_usage[] = {
+       TEST_TOOL_CHECK_URL_USAGE,
+       NULL
+};
+
 #define TEST_TOOL_IS_ACTIVE_USAGE \
        "test-tool submodule is-active <name>"
 static const char *submodule_is_active_usage[] = {
@@ -31,31 +38,26 @@ static const char *submodule_resolve_relative_url_usage[] = {
 
 static const char *submodule_usage[] = {
        TEST_TOOL_CHECK_NAME_USAGE,
+       TEST_TOOL_CHECK_URL_USAGE,
        TEST_TOOL_IS_ACTIVE_USAGE,
        TEST_TOOL_RESOLVE_RELATIVE_URL_USAGE,
        NULL
 };
 
+typedef int (*check_fn_t)(const char *);
+
 /*
- * Exit non-zero if any of the submodule names given on the command line is
- * invalid. If no names are given, filter stdin to print only valid names
- * (which is primarily intended for testing).
+ * Apply 'check_fn' to each line of stdin, printing values that pass the check
+ * to stdout.
  */
-static int check_name(int argc, const char **argv)
+static int check_submodule(check_fn_t check_fn)
 {
-       if (argc > 1) {
-               while (*++argv) {
-                       if (check_submodule_name(*argv) < 0)
-                               return 1;
-               }
-       } else {
-               struct strbuf buf = STRBUF_INIT;
-               while (strbuf_getline(&buf, stdin) != EOF) {
-                       if (!check_submodule_name(buf.buf))
-                               printf("%s\n", buf.buf);
-               }
-               strbuf_release(&buf);
+       struct strbuf buf = STRBUF_INIT;
+       while (strbuf_getline(&buf, stdin) != EOF) {
+               if (!check_fn(buf.buf))
+                       printf("%s\n", buf.buf);
        }
+       strbuf_release(&buf);
        return 0;
 }
 
@@ -69,7 +71,20 @@ static int cmd__submodule_check_name(int argc, const char **argv)
        if (argc)
                usage_with_options(submodule_check_name_usage, options);
 
-       return check_name(argc, argv);
+       return check_submodule(check_submodule_name);
+}
+
+static int cmd__submodule_check_url(int argc, const char **argv)
+{
+       struct option options[] = {
+               OPT_END()
+       };
+       argc = parse_options(argc, argv, "test-tools", options,
+                            submodule_check_url_usage, 0);
+       if (argc)
+               usage_with_options(submodule_check_url_usage, options);
+
+       return check_submodule(check_submodule_url);
 }
 
 static int cmd__submodule_is_active(int argc, const char **argv)
@@ -195,6 +210,7 @@ static int cmd__submodule_config_writeable(int argc, const char **argv UNUSED)
 
 static struct test_cmd cmds[] = {
        { "check-name", cmd__submodule_check_name },
+       { "check-url", cmd__submodule_check_url },
        { "is-active", cmd__submodule_is_active },
        { "resolve-relative-url", cmd__submodule_resolve_relative_url},
        { "config-list", cmd__submodule_config_list },
index 876cd2dc313a73e48b55ba79488dbf2ea5887fa1..482a1e58a4b6ec922f1d5abd39848acda79a78bf 100644 (file)
@@ -19,7 +19,6 @@ static struct test_cmd cmds[] = {
        { "config", cmd__config },
        { "crontab", cmd__crontab },
        { "csprng", cmd__csprng },
-       { "ctype", cmd__ctype },
        { "date", cmd__date },
        { "delta", cmd__delta },
        { "dir-iterator", cmd__dir_iterator },
@@ -30,7 +29,6 @@ static struct test_cmd cmds[] = {
        { "dump-untracked-cache", cmd__dump_untracked_cache },
        { "env-helper", cmd__env_helper },
        { "example-decorate", cmd__example_decorate },
-       { "fast-rebase", cmd__fast_rebase },
        { "find-pack", cmd__find_pack },
        { "fsmonitor-client", cmd__fsmonitor_client },
        { "genrandom", cmd__genrandom },
@@ -57,7 +55,6 @@ static struct test_cmd cmds[] = {
        { "path-utils", cmd__path_utils },
        { "pcre2-config", cmd__pcre2_config },
        { "pkt-line", cmd__pkt_line },
-       { "prio-queue", cmd__prio_queue },
        { "proc-receive", cmd__proc_receive },
        { "progress", cmd__progress },
        { "reach", cmd__reach },
index 70dd4eba11905083f325409955b1b0f8ec18a883..b1be7cfcf593d0d34ac5f851738ae2fbdf93478f 100644 (file)
@@ -12,7 +12,6 @@ int cmd__chmtime(int argc, const char **argv);
 int cmd__config(int argc, const char **argv);
 int cmd__crontab(int argc, const char **argv);
 int cmd__csprng(int argc, const char **argv);
-int cmd__ctype(int argc, const char **argv);
 int cmd__date(int argc, const char **argv);
 int cmd__delta(int argc, const char **argv);
 int cmd__dir_iterator(int argc, const char **argv);
@@ -24,7 +23,6 @@ int cmd__dump_untracked_cache(int argc, const char **argv);
 int cmd__dump_reftable(int argc, const char **argv);
 int cmd__env_helper(int argc, const char **argv);
 int cmd__example_decorate(int argc, const char **argv);
-int cmd__fast_rebase(int argc, const char **argv);
 int cmd__find_pack(int argc, const char **argv);
 int cmd__fsmonitor_client(int argc, const char **argv);
 int cmd__genrandom(int argc, const char **argv);
@@ -50,7 +48,6 @@ int cmd__partial_clone(int argc, const char **argv);
 int cmd__path_utils(int argc, const char **argv);
 int cmd__pcre2_config(int argc, const char **argv);
 int cmd__pkt_line(int argc, const char **argv);
-int cmd__prio_queue(int argc, const char **argv);
 int cmd__proc_receive(int argc, const char **argv);
 int cmd__progress(int argc, const char **argv);
 int cmd__reach(int argc, const char **argv);
index 15fc9a31e2cc03689e76876693e39367626784ff..44799c0d38fdb35d1c56a3e9ac8d91a963d2ee1c 100644 (file)
@@ -50,6 +50,7 @@ helper_test_clean() {
        reject $1 https example.com user-overwrite
        reject $1 https example.com user-erase1
        reject $1 https example.com user-erase2
+       reject $1 https victim.example.com user
        reject $1 http path.tld user
        reject $1 https timeout.tld user
        reject $1 https sso.tld
index dbc99775934bbe9eb10f6a4ec6be43962615d90a..d83bafeab32d40d6fd373e084757221ac7181d06 100644 (file)
@@ -55,22 +55,31 @@ fi
 
 HTTPD_PARA=""
 
-for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' \
+                         '/usr/sbin/apache2' \
+                         "$(command -v httpd)" \
+                         "$(command -v apache2)"
 do
-       if test -x "$DEFAULT_HTTPD_PATH"
+       if test -n "$DEFAULT_HTTPD_PATH" && test -x "$DEFAULT_HTTPD_PATH"
        then
                break
        fi
 done
 
+if test -x "$DEFAULT_HTTPD_PATH"
+then
+       DETECTED_HTTPD_ROOT="$("$DEFAULT_HTTPD_PATH" -V 2>/dev/null | sed -n 's/^ -D HTTPD_ROOT="\(.*\)"$/\1/p')"
+fi
+
 for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
                                 '/usr/lib/apache2/modules' \
                                 '/usr/lib64/httpd/modules' \
                                 '/usr/lib/httpd/modules' \
                                 '/usr/libexec/httpd' \
-                                '/usr/lib/apache2'
+                                '/usr/lib/apache2' \
+                                "${DETECTED_HTTPD_ROOT:+${DETECTED_HTTPD_ROOT}/modules}"
 do
-       if test -d "$DEFAULT_HTTPD_MODULE_PATH"
+       if test -n "$DEFAULT_HTTPD_MODULE_PATH" && test -d "$DEFAULT_HTTPD_MODULE_PATH"
        then
                break
        fi
index 99a34d648742f669e7b501298a92fab401bc1971..d9c122f34828919da09284529b9e5a70b4ffeec1 100644 (file)
@@ -1 +1 @@
-user@host:xb4E8pqD81KQs
+user@host:$apr1$LGPmCZWj$9vxEwj5Z5GzQLBMxp3mCx1
index 77c25138e074005dbfd21fc726f230be615cd27f..2ad7705d9a3946f92487a8553526af945ce0bc71 100644 (file)
@@ -1 +1 @@
-proxuser:2x7tAukjAED5M
+proxuser:$apr1$RxS6MLkD$DYsqQdflheq4GPNxzJpx5.
diff --git a/t/perf/p5332-multi-pack-reuse.sh b/t/perf/p5332-multi-pack-reuse.sh
new file mode 100755 (executable)
index 0000000..5c6c575
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+test_description='tests pack performance with multi-pack reuse'
+
+. ./perf-lib.sh
+. "${TEST_DIRECTORY}/perf/lib-pack.sh"
+
+packdir=.git/objects/pack
+
+test_perf_large_repo
+
+find_pack () {
+       for idx in $packdir/pack-*.idx
+       do
+               if git show-index <$idx | grep -q "$1"
+               then
+                       basename $idx
+               fi || return 1
+       done
+}
+
+repack_into_n_chunks () {
+       git repack -adk &&
+
+       test "$1" -eq 1 && return ||
+
+       find $packdir -type f | sort >packs.before &&
+
+       # partition the repository into $1 chunks of consecutive commits, and
+       # then create $1 packs with the objects reachable from each chunk
+       # (excluding any objects reachable from the previous chunks)
+       sz="$(($(git rev-list --count --all) / $1))"
+       for rev in $(git rev-list --all | awk "NR % $sz == 0" | tac)
+       do
+               pack="$(echo "$rev" | git pack-objects --revs \
+                       --honor-pack-keep --delta-base-offset $packdir/pack)" &&
+               touch $packdir/pack-$pack.keep || return 1
+       done
+
+       # grab any remaining objects not packed by the previous step(s)
+       git pack-objects --revs --all --honor-pack-keep --delta-base-offset \
+               $packdir/pack &&
+
+       find $packdir -type f | sort >packs.after &&
+
+       # and install the whole thing
+       for f in $(comm -12 packs.before packs.after)
+       do
+               rm -f "$f" || return 1
+       done
+       rm -fr $packdir/*.keep
+}
+
+for nr_packs in 1 10 100
+do
+       test_expect_success "create $nr_packs-pack scenario" '
+               repack_into_n_chunks $nr_packs
+       '
+
+       test_expect_success "setup bitmaps for $nr_packs-pack scenario" '
+               find $packdir -type f -name "*.idx" | sed -e "s/.*\/\(.*\)$/+\1/g" |
+               git multi-pack-index write --stdin-packs --bitmap \
+                       --preferred-pack="$(find_pack $(git rev-parse HEAD))"
+       '
+
+       for reuse in single multi
+       do
+               test_perf "clone for $nr_packs-pack scenario ($reuse-pack reuse)" "
+                       git for-each-ref --format='%(objectname)' refs/heads refs/tags >in &&
+                       git -c pack.allowPackReuse=$reuse pack-objects \
+                               --revs --delta-base-offset --use-bitmap-index \
+                               --stdout <in >result
+               "
+
+               test_size "clone size for $nr_packs-pack scenario ($reuse-pack reuse)" '
+                       wc -c <result
+               '
+       done
+done
+
+test_done
diff --git a/t/perf/p6300-for-each-ref.sh b/t/perf/p6300-for-each-ref.sh
new file mode 100755 (executable)
index 0000000..fa7289c
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+test_description='performance of for-each-ref'
+. ./perf-lib.sh
+
+test_perf_fresh_repo
+
+ref_count_per_type=10000
+test_iteration_count=10
+
+test_expect_success "setup" '
+       test_commit_bulk $(( 1 + $ref_count_per_type )) &&
+
+       # Create refs
+       test_seq $ref_count_per_type |
+               sed "s,.*,update refs/heads/branch_& HEAD~&\nupdate refs/custom/special_& HEAD~&," |
+               git update-ref --stdin &&
+
+       # Create annotated tags
+       for i in $(test_seq $ref_count_per_type)
+       do
+               # Base tags
+               echo "tag tag_$i" &&
+               echo "mark :$i" &&
+               echo "from HEAD~$i" &&
+               printf "tagger %s <%s> %s\n" \
+                       "$GIT_COMMITTER_NAME" \
+                       "$GIT_COMMITTER_EMAIL" \
+                       "$GIT_COMMITTER_DATE" &&
+               echo "data <<EOF" &&
+               echo "tag $i" &&
+               echo "EOF" &&
+
+               # Nested tags
+               echo "tag nested_$i" &&
+               echo "from :$i" &&
+               printf "tagger %s <%s> %s\n" \
+                       "$GIT_COMMITTER_NAME" \
+                       "$GIT_COMMITTER_EMAIL" \
+                       "$GIT_COMMITTER_DATE" &&
+               echo "data <<EOF" &&
+               echo "nested tag $i" &&
+               echo "EOF" || return 1
+       done | git fast-import
+'
+
+test_for_each_ref () {
+       title="for-each-ref"
+       if test $# -gt 0; then
+               title="$title ($1)"
+               shift
+       fi
+       args="$@"
+
+       test_perf "$title" "
+               for i in \$(test_seq $test_iteration_count); do
+                       git for-each-ref $args >/dev/null
+               done
+       "
+}
+
+run_tests () {
+       test_for_each_ref "$1"
+       test_for_each_ref "$1, no sort" --no-sort
+       test_for_each_ref "$1, --count=1" --count=1
+       test_for_each_ref "$1, --count=1, no sort" --no-sort --count=1
+       test_for_each_ref "$1, tags" refs/tags/
+       test_for_each_ref "$1, tags, no sort" --no-sort refs/tags/
+       test_for_each_ref "$1, tags, dereferenced" '--format="%(refname) %(objectname) %(*objectname)"' refs/tags/
+       test_for_each_ref "$1, tags, dereferenced, no sort" --no-sort '--format="%(refname) %(objectname) %(*objectname)"' refs/tags/
+
+       test_perf "for-each-ref ($1, tags) + cat-file --batch-check (dereferenced)" "
+               for i in \$(test_seq $test_iteration_count); do
+                       git for-each-ref --format='%(objectname)^{} %(refname) %(objectname)' refs/tags/ | \
+                               git cat-file --batch-check='%(objectname) %(rest)' >/dev/null
+               done
+       "
+}
+
+run_tests "loose"
+
+test_expect_success 'pack refs' '
+       git pack-refs --all
+'
+run_tests "packed"
+
+test_done
index def22e70aed351e67288ac869a94180b72b2b06c..ab0c7634119282e6b2914f3ea50064b4daa92574 100644 (file)
@@ -31,7 +31,7 @@ unset GIT_CONFIG_NOSYSTEM
 GIT_CONFIG_SYSTEM="$TEST_DIRECTORY/perf/config"
 export GIT_CONFIG_SYSTEM
 
-if test -n "$GIT_TEST_INSTALLED" -a -z "$PERF_SET_GIT_TEST_INSTALLED"
+if test -n "$GIT_TEST_INSTALLED" && test -z "$PERF_SET_GIT_TEST_INSTALLED"
 then
        error "Do not use GIT_TEST_INSTALLED with the perf tests.
 
index 34115edec356831d4863a3ca891be0d885bf46fc..486ead21980ec27de640745fe2b67fe869a08b4c 100755 (executable)
@@ -91,10 +91,10 @@ set_git_test_installed () {
 run_dirs_helper () {
        mydir=${1%/}
        shift
-       while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
+       while test $# -gt 0 && test "$1" != -- && test ! -f "$1"; do
                shift
        done
-       if test $# -gt 0 -a "$1" = --; then
+       if test $# -gt 0 && test "$1" = --; then
                shift
        fi
 
@@ -124,7 +124,7 @@ run_dirs_helper () {
 }
 
 run_dirs () {
-       while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
+       while test $# -gt 0 && test "$1" != -- && test ! -f "$1"; do
                run_dirs_helper "$@"
                shift
        done
@@ -180,7 +180,8 @@ run_subsection () {
        GIT_PERF_AGGREGATING_LATER=t
        export GIT_PERF_AGGREGATING_LATER
 
-       if test $# = 0 -o "$1" = -- -o -f "$1"; then
+       if test $# = 0 || test "$1" = -- || test -f "$1"
+       then
                set -- . "$@"
        fi
 
index 2b78e3be4795096aa3d9eeb5f7b5c3dc3a24f717..b131d665db40e9858d4a3f9c13ab71eb77d6cc5f 100755 (executable)
@@ -532,6 +532,76 @@ test_expect_success 'init rejects attempts to initialize with different hash' '
        test_must_fail git -C sha256 init --object-format=sha1
 '
 
+test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage is not allowed with repo version 0' '
+       test_when_finished "rm -rf refstorage" &&
+       git init refstorage &&
+       git -C refstorage config extensions.refStorage files &&
+       test_must_fail git -C refstorage rev-parse 2>err &&
+       grep "repo version is 0, but v1-only extension found" err
+'
+
+test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage with files backend' '
+       test_when_finished "rm -rf refstorage" &&
+       git init refstorage &&
+       git -C refstorage config core.repositoryformatversion 1 &&
+       git -C refstorage config extensions.refStorage files &&
+       test_commit -C refstorage A &&
+       git -C refstorage rev-parse --verify HEAD
+'
+
+test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage with unknown backend' '
+       test_when_finished "rm -rf refstorage" &&
+       git init refstorage &&
+       git -C refstorage config core.repositoryformatversion 1 &&
+       git -C refstorage config extensions.refStorage garbage &&
+       test_must_fail git -C refstorage rev-parse 2>err &&
+       grep "invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}garbage${SQ}" err
+'
+
+test_expect_success DEFAULT_REPO_FORMAT 'init with GIT_DEFAULT_REF_FORMAT=files' '
+       test_when_finished "rm -rf refformat" &&
+       GIT_DEFAULT_REF_FORMAT=files git init refformat &&
+       echo 0 >expect &&
+       git -C refformat config core.repositoryformatversion >actual &&
+       test_cmp expect actual &&
+       test_must_fail git -C refformat config extensions.refstorage
+'
+
+test_expect_success 'init with GIT_DEFAULT_REF_FORMAT=garbage' '
+       test_when_finished "rm -rf refformat" &&
+       cat >expect <<-EOF &&
+       fatal: unknown ref storage format ${SQ}garbage${SQ}
+       EOF
+       test_must_fail env GIT_DEFAULT_REF_FORMAT=garbage git init refformat 2>err &&
+       test_cmp expect err
+'
+
+test_expect_success 'init with --ref-format=files' '
+       test_when_finished "rm -rf refformat" &&
+       git init --ref-format=files refformat &&
+       echo files >expect &&
+       git -C refformat rev-parse --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 're-init with same format' '
+       test_when_finished "rm -rf refformat" &&
+       git init --ref-format=files refformat &&
+       git init --ref-format=files refformat &&
+       echo files >expect &&
+       git -C refformat rev-parse --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'init with --ref-format=garbage' '
+       test_when_finished "rm -rf refformat" &&
+       cat >expect <<-EOF &&
+       fatal: unknown ref storage format ${SQ}garbage${SQ}
+       EOF
+       test_must_fail git init --ref-format=garbage refformat 2>err &&
+       test_cmp expect err
+'
+
 test_expect_success MINGW 'core.hidedotfiles = false' '
        git config --global core.hidedotfiles false &&
        rm -rf newdir &&
index aee2298f01331acdf3d73c1657f1a29ed1c8616b..774b52c2980ca10e6183cf74ad10427f00c2514b 100755 (executable)
@@ -19,6 +19,20 @@ attr_check () {
        test_must_be_empty err
 }
 
+attr_check_object_mode_basic () {
+       path="$1" &&
+       expect="$2" &&
+       check_opts="$3" &&
+       git check-attr $check_opts builtin_objectmode -- "$path" >actual 2>err &&
+       echo "$path: builtin_objectmode: $expect" >expect &&
+       test_cmp expect actual
+}
+
+attr_check_object_mode () {
+       attr_check_object_mode_basic "$@" &&
+       test_must_be_empty err
+}
+
 attr_check_quote () {
        path="$1" quoted_path="$2" expect="$3" &&
 
@@ -558,4 +572,66 @@ test_expect_success EXPENSIVE 'large attributes file ignored in index' '
        test_cmp expect err
 '
 
+test_expect_success 'builtin object mode attributes work (dir and regular paths)' '
+       >normal &&
+       attr_check_object_mode normal 100644 &&
+       mkdir dir &&
+       attr_check_object_mode dir 040000
+'
+
+test_expect_success POSIXPERM 'builtin object mode attributes work (executable)' '
+       >exec &&
+       chmod +x exec &&
+       attr_check_object_mode exec 100755
+'
+
+test_expect_success SYMLINKS 'builtin object mode attributes work (symlinks)' '
+       ln -s to_sym sym &&
+       attr_check_object_mode sym 120000
+'
+
+test_expect_success 'native object mode attributes work with --cached' '
+       >normal &&
+       git add normal &&
+       empty_blob=$(git rev-parse :normal) &&
+       git update-index --index-info <<-EOF &&
+       100755 $empty_blob 0    exec
+       120000 $empty_blob 0    symlink
+       EOF
+       attr_check_object_mode normal 100644 --cached &&
+       attr_check_object_mode exec 100755 --cached &&
+       attr_check_object_mode symlink 120000 --cached
+'
+
+test_expect_success 'check object mode attributes work for submodules' '
+       mkdir sub &&
+       (
+               cd sub &&
+               git init &&
+               mv .git .real &&
+               echo "gitdir: .real" >.git &&
+               test_commit first
+       ) &&
+       attr_check_object_mode sub 160000 &&
+       attr_check_object_mode sub unspecified --cached &&
+       git add sub &&
+       attr_check_object_mode sub 160000 --cached
+'
+
+test_expect_success 'we do not allow user defined builtin_* attributes' '
+       echo "foo* builtin_foo" >.gitattributes &&
+       git add .gitattributes 2>actual &&
+       echo "builtin_foo is not a valid attribute name: .gitattributes:1" >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'user defined builtin_objectmode values are ignored' '
+       echo "foo* builtin_objectmode=12345" >.gitattributes &&
+       git add .gitattributes &&
+       >foo_1 &&
+       attr_check_object_mode_basic foo_1 100644 &&
+       echo "builtin_objectmode is not a valid attribute name: .gitattributes:1" >expect &&
+       test_cmp expect err
+'
+
 test_done
diff --git a/t/t0009-prio-queue.sh b/t/t0009-prio-queue.sh
deleted file mode 100755 (executable)
index eea9910..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-
-test_description='basic tests for priority queue implementation'
-
-TEST_PASSES_SANITIZE_LEAK=true
-. ./test-lib.sh
-
-cat >expect <<'EOF'
-1
-2
-3
-4
-5
-5
-6
-7
-8
-9
-10
-EOF
-test_expect_success 'basic ordering' '
-       test-tool prio-queue 2 6 3 10 9 5 7 4 5 8 1 dump >actual &&
-       test_cmp expect actual
-'
-
-cat >expect <<'EOF'
-2
-3
-4
-1
-5
-6
-EOF
-test_expect_success 'mixed put and get' '
-       test-tool prio-queue 6 2 4 get 5 3 get get 1 dump >actual &&
-       test_cmp expect actual
-'
-
-cat >expect <<'EOF'
-1
-2
-NULL
-1
-2
-NULL
-EOF
-test_expect_success 'notice empty queue' '
-       test-tool prio-queue 1 2 get get get 1 2 get get get >actual &&
-       test_cmp expect actual
-'
-
-cat >expect <<'EOF'
-3
-2
-6
-4
-5
-1
-8
-EOF
-test_expect_success 'stack order' '
-       test-tool prio-queue stack 8 1 5 4 6 2 3 dump >actual &&
-       test_cmp expect actual
-'
-
-test_done
index c13057a4ca3be22e431771fd60d5ab0325349bdc..0dcfb760a2ba922570d12e17cc1ff6297bdab913 100755 (executable)
@@ -17,7 +17,6 @@ test_expect_success 'advice should be printed when config variable is unset' '
 test_expect_success 'advice should be printed when config variable is set to true' '
        cat >expect <<-\EOF &&
        hint: This is a piece of advice
-       hint: Disable this message with "git config advice.nestedTag false"
        EOF
        test_config advice.nestedTag true &&
        test-tool advise "This is a piece of advice" 2>actual &&
index a34de5642073d1323b37b7c82f56edfe798fcfdd..a7f4de4a43ffa022ae56ebf14999cbe81900a4a9 100755 (executable)
@@ -9,7 +9,7 @@ test_expect_success setup '
 
        git config core.autocrlf true &&
 
-       printf "CRLF line ending\r\nAnd another\r\n" > sample &&
+       printf "CRLF line ending\r\nAnd another\r\n" >sample &&
        git add sample &&
 
        test_tick &&
@@ -19,8 +19,9 @@ test_expect_success setup '
 
 test_expect_success 'tar archive' '
 
-       git archive --format=tar HEAD |
-       ( mkdir untarred && cd untarred && "$TAR" -xf - ) &&
+       git archive --format=tar HEAD >test.tar &&
+       mkdir untarred &&
+       "$TAR" xf test.tar -C untarred &&
 
        test_cmp sample untarred/sample
 
@@ -30,7 +31,11 @@ test_expect_success UNZIP 'zip archive' '
 
        git archive --format=zip HEAD >test.zip &&
 
-       ( mkdir unzipped && cd unzipped && "$GIT_UNZIP" ../test.zip ) &&
+       mkdir unzipped &&
+       (
+               cd unzipped &&
+               "$GIT_UNZIP" ../test.zip
+       ) &&
 
        test_cmp sample unzipped/sample
 
index 038b8b788d7dea688c2efa807e1d1856b8f33c13..804885637954a57ba85e139591e6a0f5a5167034 100755 (executable)
@@ -78,4 +78,12 @@ test_expect_success 'no trace when GIT_DIR is explicitly provided' '
        expect_accepted_explicit "$pwd/outer-repo/bare-repo"
 '
 
+test_expect_success 'no trace when "bare repository" is .git' '
+       expect_accepted_implicit -C outer-repo/.git
+'
+
+test_expect_success 'no trace when "bare repository" is a subdir of .git' '
+       expect_accepted_implicit -C outer-repo/.git/objects
+'
+
 test_done
index f18f9284a5bf3961a3f5373f887b808e55cd9b75..0ecec2ba71116959fd2efceac7fc46683d1a3e91 100755 (executable)
@@ -9,10 +9,6 @@ Verify wrappers and compatibility functions.
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
-test_expect_success 'character classes (isspace, isalpha etc.)' '
-       test-tool ctype
-'
-
 test_expect_success 'mktemp to nonexistent directory prints filename' '
        test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err &&
        grep "doesnotexist/test" err
diff --git a/t/t0080-unit-test-output.sh b/t/t0080-unit-test-output.sh
new file mode 100755 (executable)
index 0000000..6657c11
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+test_description='Test the output of the unit test framework'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+test_expect_success 'TAP output from unit tests' '
+       cat >expect <<-EOF &&
+       ok 1 - passing test
+       ok 2 - passing test and assertion return 1
+       # check "1 == 2" failed at t/unit-tests/t-basic.c:76
+       #    left: 1
+       #   right: 2
+       not ok 3 - failing test
+       ok 4 - failing test and assertion return 0
+       not ok 5 - passing TEST_TODO() # TODO
+       ok 6 - passing TEST_TODO() returns 1
+       # todo check ${SQ}check(x)${SQ} succeeded at t/unit-tests/t-basic.c:25
+       not ok 7 - failing TEST_TODO()
+       ok 8 - failing TEST_TODO() returns 0
+       # check "0" failed at t/unit-tests/t-basic.c:30
+       # skipping test - missing prerequisite
+       # skipping check ${SQ}1${SQ} at t/unit-tests/t-basic.c:32
+       ok 9 - test_skip() # SKIP
+       ok 10 - skipped test returns 1
+       # skipping test - missing prerequisite
+       ok 11 - test_skip() inside TEST_TODO() # SKIP
+       ok 12 - test_skip() inside TEST_TODO() returns 1
+       # check "0" failed at t/unit-tests/t-basic.c:48
+       not ok 13 - TEST_TODO() after failing check
+       ok 14 - TEST_TODO() after failing check returns 0
+       # check "0" failed at t/unit-tests/t-basic.c:56
+       not ok 15 - failing check after TEST_TODO()
+       ok 16 - failing check after TEST_TODO() returns 0
+       # check "!strcmp("\thello\\\\", "there\"\n")" failed at t/unit-tests/t-basic.c:61
+       #    left: "\011hello\\\\"
+       #   right: "there\"\012"
+       # check "!strcmp("NULL", NULL)" failed at t/unit-tests/t-basic.c:62
+       #    left: "NULL"
+       #   right: NULL
+       # check "${SQ}a${SQ} == ${SQ}\n${SQ}" failed at t/unit-tests/t-basic.c:63
+       #    left: ${SQ}a${SQ}
+       #   right: ${SQ}\012${SQ}
+       # check "${SQ}\\\\${SQ} == ${SQ}\\${SQ}${SQ}" failed at t/unit-tests/t-basic.c:64
+       #    left: ${SQ}\\\\${SQ}
+       #   right: ${SQ}\\${SQ}${SQ}
+       not ok 17 - messages from failing string and char comparison
+       # BUG: test has no checks at t/unit-tests/t-basic.c:91
+       not ok 18 - test with no checks
+       ok 19 - test with no checks returns 0
+       1..19
+       EOF
+
+       ! "$GIT_BUILD_DIR"/t/unit-tests/bin/t-basic >actual &&
+       test_cmp expect actual
+'
+
+test_done
index 8798feefe3f6700ee90d3854299802a60536df7d..fca39048fe8840099c2d7a393e91dfd3a6683029 100755 (executable)
@@ -39,9 +39,9 @@ test_expect_success 'sanity check "System Info" section' '
 
        sed -ne "/^\[System Info\]$/,/^$/p" <git-bugreport-format.txt >system &&
 
-       # The beginning should match "git version --build-info" verbatim,
+       # The beginning should match "git version --build-options" verbatim,
        # but rather than checking bit-for-bit equality, just test some basics.
-       grep "git version [0-9]." system &&
+       grep "git version " system &&
        grep "shell-path: ." system &&
 
        # After the version, there should be some more info.
index 095574bfc6edf2aaf835b2ff43bb8cd35f792591..72ae405c3ed979edee54cbe83e73ec566d23f6d1 100755 (executable)
@@ -32,9 +32,24 @@ commands.
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-credential.sh
 
+# If we're not given a specific external helper to run against,
+# there isn't much to test. But we can still run through our
+# battery of tests with a fake helper and check that the
+# test themselves are self-consistent and clean up after
+# themselves.
+#
+# We'll use the "store" helper, since we can easily inspect
+# its state by looking at the on-disk file. But since it doesn't
+# implement any caching or expiry logic, we'll cheat and override
+# the "check" function to just report all results as OK.
 if test -z "$GIT_TEST_CREDENTIAL_HELPER"; then
-       skip_all="used to test external credential helpers"
-       test_done
+       GIT_TEST_CREDENTIAL_HELPER=store
+       GIT_TEST_CREDENTIAL_HELPER_TIMEOUT=store
+       check () {
+               test "$1" = "approve" || return 0
+               git -c credential.helper=store credential approve
+       }
+       check_cleanup=t
 fi
 
 test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
@@ -59,4 +74,11 @@ fi
 # might be long-term system storage
 helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
 
+if test "$check_cleanup" = "t"
+then
+       test_expect_success 'test cleanup removes everything' '
+               test_must_be_empty "$HOME/.git-credentials"
+       '
+fi
+
 test_done
index 6b6424b3df17135666b332b7857ec8382c813ece..88a66f09040ce0aa2a3a653579d6c3685e750ba1 100755 (executable)
@@ -49,7 +49,7 @@ test_expect_success 'convert shallow clone to partial clone' '
        test_cmp_config -C client 1 core.repositoryformatversion
 '
 
-test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension' '
+test_expect_success DEFAULT_REPO_FORMAT 'convert to partial clone with noop extension' '
        rm -fr server client &&
        test_create_repo server &&
        test_commit -C server my_commit 1 &&
@@ -60,7 +60,7 @@ test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension'
        git -C client fetch --unshallow --filter="blob:none"
 '
 
-test_expect_success SHA1,REFFILES 'converting to partial clone fails with unrecognized extension' '
+test_expect_success DEFAULT_REPO_FORMAT 'converting to partial clone fails with unrecognized extension' '
        rm -fr server client &&
        test_create_repo server &&
        test_commit -C server my_commit 1 &&
@@ -665,6 +665,21 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' '
        git -C partial.git rev-list --objects --missing=print HEAD >out &&
        grep "[?]$FILE_HASH" out &&
 
+       # The no-lazy-fetch mechanism prevents Git from fetching
+       test_must_fail env GIT_NO_LAZY_FETCH=1 \
+               git -C partial.git cat-file -e "$FILE_HASH" &&
+
+       # The same with command line option to "git"
+       test_must_fail git --no-lazy-fetch -C partial.git cat-file -e "$FILE_HASH" &&
+
+       # The same, forcing a subprocess via an alias
+       test_must_fail git --no-lazy-fetch -C partial.git \
+               -c alias.foo="!git cat-file" foo -e "$FILE_HASH" &&
+
+       # Sanity check that the file is still missing
+       git -C partial.git rev-list --objects --missing=print HEAD >out &&
+       grep "[?]$FILE_HASH" out &&
+
        git -C full cat-file -s "$FILE_HASH" >expect &&
        test-tool partial-clone object-info partial.git "$FILE_HASH" >actual &&
        test_cmp expect actual &&
diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
new file mode 100755 (executable)
index 0000000..6421434
--- /dev/null
@@ -0,0 +1,475 @@
+#!/bin/sh
+
+test_description='Test reffiles backend'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+if ! test_have_prereq REFFILES
+then
+       skip_all='skipping reffiles specific tests'
+       test_done
+fi
+
+test_expect_success 'setup' '
+       git commit --allow-empty -m Initial &&
+       C=$(git rev-parse HEAD) &&
+       git commit --allow-empty -m Second &&
+       D=$(git rev-parse HEAD) &&
+       git commit --allow-empty -m Third &&
+       E=$(git rev-parse HEAD)
+'
+
+test_expect_success 'empty directory should not fool rev-parse' '
+       prefix=refs/e-rev-parse &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       echo "$C" >expected &&
+       git rev-parse $prefix/foo >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'empty directory should not fool for-each-ref' '
+       prefix=refs/e-for-each-ref &&
+       git update-ref $prefix/foo $C &&
+       git for-each-ref $prefix >expected &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       git for-each-ref $prefix >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'empty directory should not fool create' '
+       prefix=refs/e-create &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       printf "create %s $C\n" $prefix/foo |
+       git update-ref --stdin
+'
+
+test_expect_success 'empty directory should not fool verify' '
+       prefix=refs/e-verify &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       printf "verify %s $C\n" $prefix/foo |
+       git update-ref --stdin
+'
+
+test_expect_success 'empty directory should not fool 1-arg update' '
+       prefix=refs/e-update-1 &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       printf "update %s $D\n" $prefix/foo |
+       git update-ref --stdin
+'
+
+test_expect_success 'empty directory should not fool 2-arg update' '
+       prefix=refs/e-update-2 &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       printf "update %s $D $C\n" $prefix/foo |
+       git update-ref --stdin
+'
+
+test_expect_success 'empty directory should not fool 0-arg delete' '
+       prefix=refs/e-delete-0 &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       printf "delete %s\n" $prefix/foo |
+       git update-ref --stdin
+'
+
+test_expect_success 'empty directory should not fool 1-arg delete' '
+       prefix=refs/e-delete-1 &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       mkdir -p .git/$prefix/foo/bar/baz &&
+       printf "delete %s $C\n" $prefix/foo |
+       git update-ref --stdin
+'
+
+test_expect_success 'non-empty directory blocks create' '
+       prefix=refs/ne-create &&
+       mkdir -p .git/$prefix/foo/bar &&
+       : >.git/$prefix/foo/bar/baz.lock &&
+       test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/foo$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
+       EOF
+       printf "%s\n" "update $prefix/foo $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
+       EOF
+       printf "%s\n" "update $prefix/foo $D $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err
+'
+
+test_expect_success 'broken reference blocks create' '
+       prefix=refs/broken-create &&
+       mkdir -p .git/$prefix &&
+       echo "gobbledigook" >.git/$prefix/foo &&
+       test_when_finished "rm -f .git/$prefix/foo" &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
+       EOF
+       printf "%s\n" "update $prefix/foo $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
+       EOF
+       printf "%s\n" "update $prefix/foo $D $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err
+'
+
+test_expect_success 'non-empty directory blocks indirect create' '
+       prefix=refs/ne-indirect-create &&
+       git symbolic-ref $prefix/symref $prefix/foo &&
+       mkdir -p .git/$prefix/foo/bar &&
+       : >.git/$prefix/foo/bar/baz.lock &&
+       test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/symref$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
+       EOF
+       printf "%s\n" "update $prefix/symref $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
+       EOF
+       printf "%s\n" "update $prefix/symref $D $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err
+'
+
+test_expect_success 'broken reference blocks indirect create' '
+       prefix=refs/broken-indirect-create &&
+       git symbolic-ref $prefix/symref $prefix/foo &&
+       echo "gobbledigook" >.git/$prefix/foo &&
+       test_when_finished "rm -f .git/$prefix/foo" &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
+       EOF
+       printf "%s\n" "update $prefix/symref $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err &&
+       cat >expected <<-EOF &&
+       fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
+       EOF
+       printf "%s\n" "update $prefix/symref $D $C" |
+       test_must_fail git update-ref --stdin 2>output.err &&
+       test_cmp expected output.err
+'
+
+test_expect_success 'no bogus intermediate values during delete' '
+       prefix=refs/slow-transaction &&
+       # Set up a reference with differing loose and packed versions:
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       git update-ref $prefix/foo $D &&
+       # Now try to update the reference, but hold the `packed-refs` lock
+       # for a while to see what happens while the process is blocked:
+       : >.git/packed-refs.lock &&
+       test_when_finished "rm -f .git/packed-refs.lock" &&
+       {
+               # Note: the following command is intentionally run in the
+               # background. We increase the timeout so that `update-ref`
+               # attempts to acquire the `packed-refs` lock for much longer
+               # than it takes for us to do the check then delete it:
+               git -c core.packedrefstimeout=30000 update-ref -d $prefix/foo &
+       } &&
+       pid2=$! &&
+       # Give update-ref plenty of time to get to the point where it tries
+       # to lock packed-refs:
+       sleep 1 &&
+       # Make sure that update-ref did not complete despite the lock:
+       kill -0 $pid2 &&
+       # Verify that the reference still has its old value:
+       sha1=$(git rev-parse --verify --quiet $prefix/foo || echo undefined) &&
+       case "$sha1" in
+       $D)
+               # This is what we hope for; it means that nothing
+               # user-visible has changed yet.
+               : ;;
+       undefined)
+               # This is not correct; it means the deletion has happened
+               # already even though update-ref should not have been
+               # able to acquire the lock yet.
+               echo "$prefix/foo deleted prematurely" &&
+               break
+               ;;
+       $C)
+               # This value should never be seen. Probably the loose
+               # reference has been deleted but the packed reference
+               # is still there:
+               echo "$prefix/foo incorrectly observed to be C" &&
+               break
+               ;;
+       *)
+               # WTF?
+               echo "unexpected value observed for $prefix/foo: $sha1" &&
+               break
+               ;;
+       esac >out &&
+       rm -f .git/packed-refs.lock &&
+       wait $pid2 &&
+       test_must_be_empty out &&
+       test_must_fail git rev-parse --verify --quiet $prefix/foo
+'
+
+test_expect_success 'delete fails cleanly if packed-refs file is locked' '
+       prefix=refs/locked-packed-refs &&
+       # Set up a reference with differing loose and packed versions:
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       git update-ref $prefix/foo $D &&
+       git for-each-ref $prefix >unchanged &&
+       # Now try to delete it while the `packed-refs` lock is held:
+       : >.git/packed-refs.lock &&
+       test_when_finished "rm -f .git/packed-refs.lock" &&
+       test_must_fail git update-ref -d $prefix/foo >out 2>err &&
+       git for-each-ref $prefix >actual &&
+       test_grep "Unable to create $SQ.*packed-refs.lock$SQ: " err &&
+       test_cmp unchanged actual
+'
+
+test_expect_success 'delete fails cleanly if packed-refs.new write fails' '
+       # Setup and expectations are similar to the test above.
+       prefix=refs/failed-packed-refs &&
+       git update-ref $prefix/foo $C &&
+       git pack-refs --all &&
+       git update-ref $prefix/foo $D &&
+       git for-each-ref $prefix >unchanged &&
+       # This should not happen in practice, but it is an easy way to get a
+       # reliable error (we open with create_tempfile(), which uses O_EXCL).
+       : >.git/packed-refs.new &&
+       test_when_finished "rm -f .git/packed-refs.new" &&
+       test_must_fail git update-ref -d $prefix/foo &&
+       git for-each-ref $prefix >actual &&
+       test_cmp unchanged actual
+'
+
+RWT="test-tool ref-store worktree:wt"
+RMAIN="test-tool ref-store worktree:main"
+
+test_expect_success 'setup worktree' '
+       test_commit first &&
+       git worktree add -b wt-main wt &&
+       (
+               cd wt &&
+               test_commit second
+       )
+'
+
+# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should
+# only appear in the for-each-reflog output if it is called from the correct
+# worktree, which is exercised in this test. This test is poorly written for
+# mulitple reasons: 1) it creates invalidly formatted log entres. 2) it uses
+# direct FS access for creating the reflogs. 3) PSEUDO-WT and refs/bisect/random
+# do not create reflogs by default, so it is not testing a realistic scenario.
+test_expect_success 'for_each_reflog()' '
+       echo $ZERO_OID >.git/logs/PSEUDO_MAIN_HEAD &&
+       mkdir -p     .git/logs/refs/bisect &&
+       echo $ZERO_OID >.git/logs/refs/bisect/random &&
+
+       echo $ZERO_OID >.git/worktrees/wt/logs/PSEUDO_WT_HEAD &&
+       mkdir -p     .git/worktrees/wt/logs/refs/bisect &&
+       echo $ZERO_OID >.git/worktrees/wt/logs/refs/bisect/wt-random &&
+
+       $RWT for-each-reflog >actual &&
+       cat >expected <<-\EOF &&
+       HEAD
+       PSEUDO_WT_HEAD
+       refs/bisect/wt-random
+       refs/heads/main
+       refs/heads/wt-main
+       EOF
+       test_cmp expected actual &&
+
+       $RMAIN for-each-reflog >actual &&
+       cat >expected <<-\EOF &&
+       HEAD
+       PSEUDO_MAIN_HEAD
+       refs/bisect/random
+       refs/heads/main
+       refs/heads/wt-main
+       EOF
+       test_cmp expected actual
+'
+
+# Triggering the bug detected by this test requires a newline to fall
+# exactly BUFSIZ-1 bytes from the end of the file. We don't know
+# what that value is, since it's platform dependent. However, if
+# we choose some value N, we also catch any D which divides N evenly
+# (since we will read backwards in chunks of D). So we choose 8K,
+# which catches glibc (with an 8K BUFSIZ) and *BSD (1K).
+#
+# Each line is 114 characters, so we need 75 to still have a few before the
+# last 8K. The 89-character padding on the final entry lines up our
+# newline exactly.
+test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
+       git checkout -b reflogskip &&
+       zf=$(test_oid zero_2) &&
+       ident="abc <xyz> 0000000001 +0000" &&
+       for i in $(test_seq 1 75); do
+               printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
+               if test $i = 75; then
+                       for j in $(test_seq 1 89); do
+                               printf X || return 1
+                       done
+               else
+                       printf X
+               fi &&
+               printf "\n" || return 1
+       done >.git/logs/refs/heads/reflogskip &&
+       git rev-parse reflogskip@{73} >actual &&
+       echo ${zf}03 >expect &&
+       test_cmp expect actual
+'
+
+# This test takes a lock on an individual ref; this is not supported in
+# reftable.
+test_expect_success 'reflog expire operates on symref not referrent' '
+       git branch --create-reflog the_symref &&
+       git branch --create-reflog referrent &&
+       git update-ref referrent HEAD &&
+       git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
+       test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
+       touch .git/refs/heads/referrent.lock &&
+       git reflog expire --expire=all the_symref
+'
+
+test_expect_success 'empty reflog' '
+       test_when_finished "rm -rf empty" &&
+       git init empty &&
+       test_commit -C empty A &&
+       >empty/.git/logs/refs/heads/foo &&
+       git -C empty reflog expire --all 2>err &&
+       test_must_be_empty err
+'
+
+test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' '
+       ln -s does-not-exist .git/refs/heads/broken &&
+       test_must_fail git rev-parse --verify broken
+'
+
+test_expect_success 'log diagnoses bogus HEAD hash' '
+       git init empty &&
+       test_when_finished "rm -rf empty" &&
+       echo 1234abcd >empty/.git/refs/heads/main &&
+       test_must_fail git -C empty log 2>stderr &&
+       test_grep broken stderr
+'
+
+test_expect_success 'log diagnoses bogus HEAD symref' '
+       git init empty &&
+       test-tool -C empty ref-store main create-symref HEAD refs/heads/invalid.lock &&
+       test_must_fail git -C empty log 2>stderr &&
+       test_grep broken stderr &&
+       test_must_fail git -C empty log --default totally-bogus 2>stderr &&
+       test_grep broken stderr
+'
+
+test_expect_success 'empty directory removal' '
+       git branch d1/d2/r1 HEAD &&
+       git branch d1/r2 HEAD &&
+       test_path_is_file .git/refs/heads/d1/d2/r1 &&
+       test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
+       git branch -d d1/d2/r1 &&
+       test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
+       test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
+       test_path_is_file .git/refs/heads/d1/r2 &&
+       test_path_is_file .git/logs/refs/heads/d1/r2
+'
+
+test_expect_success 'symref empty directory removal' '
+       git branch e1/e2/r1 HEAD &&
+       git branch e1/r2 HEAD &&
+       git checkout e1/e2/r1 &&
+       test_when_finished "git checkout main" &&
+       test_path_is_file .git/refs/heads/e1/e2/r1 &&
+       test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
+       git update-ref -d HEAD &&
+       test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
+       test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
+       test_path_is_file .git/refs/heads/e1/r2 &&
+       test_path_is_file .git/logs/refs/heads/e1/r2 &&
+       test_path_is_file .git/logs/HEAD
+'
+
+test_expect_success 'directory not created deleting packed ref' '
+       git branch d1/d2/r1 HEAD &&
+       git pack-refs --all &&
+       test_path_is_missing .git/refs/heads/d1/d2 &&
+       git update-ref -d refs/heads/d1/d2/r1 &&
+       test_path_is_missing .git/refs/heads/d1/d2 &&
+       test_path_is_missing .git/refs/heads/d1
+'
+
+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
+       git branch --create-reflog u &&
+       mv .git/logs/refs/heads/u real-u &&
+       ln -s real-u .git/logs/refs/heads/u &&
+       test_must_fail git branch -m u v
+'
+
+test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
+       test_when_finished "rm -rf subdir" &&
+       git init --bare subdir &&
+
+       rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
+       ln -s ../.git/refs subdir/refs &&
+       ln -s ../.git/objects subdir/objects &&
+       ln -s ../.git/packed-refs subdir/packed-refs &&
+
+       git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
+       git rev-parse --absolute-git-dir >our.dir &&
+       ! test_cmp subdir.dir our.dir &&
+
+       git -C subdir log &&
+       git -C subdir branch rename-src &&
+       git rev-parse rename-src >expect &&
+       git -C subdir branch -m rename-src rename-dest &&
+       git rev-parse rename-dest >actual &&
+       test_cmp expect actual &&
+       git branch -D rename-dest
+'
+
+test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
+       git checkout main &&
+       mv .git/logs actual_logs &&
+       cmd //c "mklink /D .git\logs ..\actual_logs" &&
+       git rebase -f HEAD^ &&
+       test -L .git/logs &&
+       rm .git/logs &&
+       mv actual_logs .git/logs
+'
+
+test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
+       umask 077 &&
+       git config core.sharedRepository group &&
+       git reflog expire --all &&
+       actual="$(ls -l .git/logs/refs/heads/main)" &&
+       case "$actual" in
+       -rw-rw-*)
+               : happy
+               ;;
+       *)
+               echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
+               false
+               ;;
+       esac
+'
+
+test_done
similarity index 81%
rename from t/t3210-pack-refs.sh
rename to t/t0601-reffiles-pack-refs.sh
index 7f4e98db7db24363a451fa4b1ae8412b6e1277c3..c309d2bae8a19816907b81d82cef9099b2fa21e9 100755 (executable)
@@ -15,6 +15,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if ! test_have_prereq REFFILES
+then
+       skip_all='skipping reffiles specific tests'
+       test_done
+fi
+
 test_expect_success 'enable reflogs' '
        git config core.logallrefupdates true
 '
@@ -26,6 +32,14 @@ test_expect_success 'prepare a trivial repository' '
        HEAD=$(git rev-parse --verify HEAD)
 '
 
+test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
+       N=`find .git/refs -type f | wc -l` &&
+       test "$N" != 0 &&
+       test-tool ref-store main pack-refs PACK_REFS_PRUNE,PACK_REFS_ALL &&
+       N=`find .git/refs -type f` &&
+       test -z "$N"
+'
+
 SHA1=
 
 test_expect_success 'see if git show-ref works as expected' '
@@ -294,4 +308,54 @@ test_expect_success SYMLINKS 'pack symlinked packed-refs' '
        test "$(test_readlink .git/packed-refs)" = "my-deviant-packed-refs"
 '
 
+# The 'packed-refs' file is stored directly in .git/. This means it is global
+# to the repository, and can only contain refs that are shared across all
+# worktrees.
+test_expect_success 'refs/worktree must not be packed' '
+       test_commit initial &&
+       test_commit wt1 &&
+       test_commit wt2 &&
+       git worktree add wt1 wt1 &&
+       git worktree add wt2 wt2 &&
+       git checkout initial &&
+       git update-ref refs/worktree/foo HEAD &&
+       git -C wt1 update-ref refs/worktree/foo HEAD &&
+       git -C wt2 update-ref refs/worktree/foo HEAD &&
+       git pack-refs --all &&
+       test_path_is_missing .git/refs/tags/wt1 &&
+       test_path_is_file .git/refs/worktree/foo &&
+       test_path_is_file .git/worktrees/wt1/refs/worktree/foo &&
+       test_path_is_file .git/worktrees/wt2/refs/worktree/foo
+'
+
+# we do not want to count on running pack-refs to
+# actually pack it, as it is perfectly reasonable to
+# skip processing a broken ref
+test_expect_success 'create packed-refs file with broken ref' '
+       test_tick && git commit --allow-empty -m one &&
+       recoverable=$(git rev-parse HEAD) &&
+       test_tick && git commit --allow-empty -m two &&
+       missing=$(git rev-parse HEAD) &&
+       rm -f .git/refs/heads/main &&
+       cat >.git/packed-refs <<-EOF &&
+       $missing refs/heads/main
+       $recoverable refs/heads/other
+       EOF
+       echo $missing >expect &&
+       git rev-parse refs/heads/main >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'pack-refs does not silently delete broken packed ref' '
+       git pack-refs --all --prune &&
+       git rev-parse refs/heads/main >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'pack-refs does not drop broken refs during deletion' '
+       git update-ref -d refs/heads/other &&
+       git rev-parse refs/heads/main >actual &&
+       test_cmp expect actual
+'
+
 test_done
diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh
new file mode 100755 (executable)
index 0000000..6a131e4
--- /dev/null
@@ -0,0 +1,887 @@
+#!/bin/sh
+#
+# Copyright (c) 2020 Google LLC
+#
+
+test_description='reftable basics'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+if ! test_have_prereq REFTABLE
+then
+       skip_all='skipping reftable tests; set GIT_TEST_DEFAULT_REF_FORMAT=reftable'
+       test_done
+fi
+
+INVALID_OID=$(test_oid 001)
+
+test_expect_success 'init: creates basic reftable structures' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_path_is_dir repo/.git/reftable &&
+       test_path_is_file repo/.git/reftable/tables.list &&
+       echo reftable >expect &&
+       git -C repo rev-parse --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'init: sha256 object format via environment variable' '
+       test_when_finished "rm -rf repo" &&
+       GIT_DEFAULT_HASH=sha256 git init repo &&
+       cat >expect <<-EOF &&
+       sha256
+       reftable
+       EOF
+       git -C repo rev-parse --show-object-format --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'init: sha256 object format via option' '
+       test_when_finished "rm -rf repo" &&
+       git init --object-format=sha256 repo &&
+       cat >expect <<-EOF &&
+       sha256
+       reftable
+       EOF
+       git -C repo rev-parse --show-object-format --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'init: reinitializing reftable backend succeeds' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo for-each-ref >expect &&
+       git init --ref-format=reftable repo &&
+       git -C repo for-each-ref >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'init: reinitializing files with reftable backend fails' '
+       test_when_finished "rm -rf repo" &&
+       git init --ref-format=files repo &&
+       test_commit -C repo file &&
+
+       cp repo/.git/HEAD expect &&
+       test_must_fail git init --ref-format=reftable repo &&
+       test_cmp expect repo/.git/HEAD
+'
+
+test_expect_success 'init: reinitializing reftable with files backend fails' '
+       test_when_finished "rm -rf repo" &&
+       git init --ref-format=reftable repo &&
+       test_commit -C repo file &&
+
+       cp repo/.git/HEAD expect &&
+       test_must_fail git init --ref-format=files repo &&
+       test_cmp expect repo/.git/HEAD
+'
+
+test_expect_perms () {
+       local perms="$1"
+       local file="$2"
+       local actual=$(ls -l "$file") &&
+
+       case "$actual" in
+       $perms*)
+               : happy
+               ;;
+       *)
+               echo "$(basename $2) is not $perms but $actual"
+               false
+               ;;
+       esac
+}
+
+for umask in 002 022
+do
+       test_expect_success POSIXPERM 'init: honors core.sharedRepository' '
+               test_when_finished "rm -rf repo" &&
+               (
+                       umask $umask &&
+                       git init --shared=true repo &&
+                       test 1 = "$(git -C repo config core.sharedrepository)"
+               ) &&
+               test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
+               for table in repo/.git/reftable/*.ref
+               do
+                       test_expect_perms "-rw-rw-r--" "$table" ||
+                       return 1
+               done
+       '
+done
+
+test_expect_success 'clone: can clone reftable repository' '
+       test_when_finished "rm -rf repo clone" &&
+       git init repo &&
+       test_commit -C repo message1 file1 &&
+
+       git clone repo cloned &&
+       echo reftable >expect &&
+       git -C cloned rev-parse --show-ref-format >actual &&
+       test_cmp expect actual &&
+       test_path_is_file cloned/file1
+'
+
+test_expect_success 'clone: can clone reffiles into reftable repository' '
+       test_when_finished "rm -rf reffiles reftable" &&
+       git init --ref-format=files reffiles &&
+       test_commit -C reffiles A &&
+       git clone --ref-format=reftable ./reffiles reftable &&
+
+       git -C reffiles rev-parse HEAD >expect &&
+       git -C reftable rev-parse HEAD >actual &&
+       test_cmp expect actual &&
+
+       git -C reftable rev-parse --show-ref-format >actual &&
+       echo reftable >expect &&
+       test_cmp expect actual &&
+
+       git -C reffiles rev-parse --show-ref-format >actual &&
+       echo files >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'clone: can clone reftable into reffiles repository' '
+       test_when_finished "rm -rf reffiles reftable" &&
+       git init --ref-format=reftable reftable &&
+       test_commit -C reftable A &&
+       git clone --ref-format=files ./reftable reffiles &&
+
+       git -C reftable rev-parse HEAD >expect &&
+       git -C reffiles rev-parse HEAD >actual &&
+       test_cmp expect actual &&
+
+       git -C reftable rev-parse --show-ref-format >actual &&
+       echo reftable >expect &&
+       test_cmp expect actual &&
+
+       git -C reffiles rev-parse --show-ref-format >actual &&
+       echo files >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'ref transaction: corrupted tables cause failure' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file1 &&
+               for f in .git/reftable/*.ref
+               do
+                       : >"$f" || return 1
+               done &&
+               test_must_fail git update-ref refs/heads/main HEAD
+       )
+'
+
+test_expect_success 'ref transaction: corrupted tables.list cause failure' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file1 &&
+               echo garbage >.git/reftable/tables.list &&
+               test_must_fail git update-ref refs/heads/main HEAD
+       )
+'
+
+test_expect_success 'ref transaction: refuses to write ref causing F/D conflict' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo file &&
+       test_must_fail git -C repo update-ref refs/heads/main/forbidden
+'
+
+test_expect_success 'ref transaction: deleting ref with invalid name fails' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo file &&
+       test_must_fail git -C repo update-ref -d ../../my-private-file
+'
+
+test_expect_success 'ref transaction: can skip object ID verification' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_must_fail test-tool -C repo ref-store main update-ref msg refs/heads/branch $INVALID_OID $ZERO_OID 0 &&
+       test-tool -C repo ref-store main update-ref msg refs/heads/branch $INVALID_OID $ZERO_OID REF_SKIP_OID_VERIFICATION
+'
+
+test_expect_success 'ref transaction: updating same ref multiple times fails' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo A &&
+       cat >updates <<-EOF &&
+       update refs/heads/main $A
+       update refs/heads/main $A
+       EOF
+       cat >expect <<-EOF &&
+       fatal: multiple updates for ref ${SQ}refs/heads/main${SQ} not allowed
+       EOF
+       test_must_fail git -C repo update-ref --stdin <updates 2>err &&
+       test_cmp expect err
+'
+
+test_expect_success 'ref transaction: can delete symbolic self-reference with git-symbolic-ref(1)' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       git -C repo symbolic-ref refs/heads/self refs/heads/self &&
+       git -C repo symbolic-ref -d refs/heads/self
+'
+
+test_expect_success 'ref transaction: deleting symbolic self-reference without --no-deref fails' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       git -C repo symbolic-ref refs/heads/self refs/heads/self &&
+       cat >expect <<-EOF &&
+       error: multiple updates for ${SQ}refs/heads/self${SQ} (including one via symref ${SQ}refs/heads/self${SQ}) are not allowed
+       EOF
+       test_must_fail git -C repo update-ref -d refs/heads/self 2>err &&
+       test_cmp expect err
+'
+
+test_expect_success 'ref transaction: deleting symbolic self-reference with --no-deref succeeds' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       git -C repo symbolic-ref refs/heads/self refs/heads/self &&
+       git -C repo update-ref -d --no-deref refs/heads/self
+'
+
+test_expect_success 'ref transaction: creating symbolic ref fails with F/D conflict' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo A &&
+       cat >expect <<-EOF &&
+       error: unable to write symref for refs/heads: file/directory conflict
+       EOF
+       test_must_fail git -C repo symbolic-ref refs/heads refs/heads/foo 2>err &&
+       test_cmp expect err
+'
+
+test_expect_success 'ref transaction: ref deletion' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file &&
+               HEAD_OID=$(git show-ref -s --verify HEAD) &&
+               cat >expect <<-EOF &&
+               $HEAD_OID refs/heads/main
+               $HEAD_OID refs/tags/file
+               EOF
+               git show-ref >actual &&
+               test_cmp expect actual &&
+
+               test_must_fail git update-ref -d refs/tags/file $INVALID_OID &&
+               git show-ref >actual &&
+               test_cmp expect actual &&
+
+               git update-ref -d refs/tags/file $HEAD_OID &&
+               echo "$HEAD_OID refs/heads/main" >expect &&
+               git show-ref >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ref transaction: writes cause auto-compaction' '
+       test_when_finished "rm -rf repo" &&
+
+       git init repo &&
+       test_line_count = 1 repo/.git/reftable/tables.list &&
+
+       test_commit -C repo --no-tag A &&
+       test_line_count = 2 repo/.git/reftable/tables.list &&
+
+       test_commit -C repo --no-tag B &&
+       test_line_count = 1 repo/.git/reftable/tables.list
+'
+
+check_fsync_events () {
+       local trace="$1" &&
+       shift &&
+
+       cat >expect &&
+       sed -n \
+               -e '/^{"event":"counter",.*"category":"fsync",/ {
+                       s/.*"category":"fsync",//;
+                       s/}$//;
+                       p;
+               }' \
+               <"$trace" >actual &&
+       test_cmp expect actual
+}
+
+test_expect_success 'ref transaction: writes are synced' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo initial &&
+
+       GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+       GIT_TEST_FSYNC=true \
+               git -C repo -c core.fsync=reference \
+               -c core.fsyncMethod=fsync update-ref refs/heads/branch HEAD &&
+       check_fsync_events trace2.txt <<-EOF
+       "name":"hardware-flush","count":2
+       EOF
+'
+
+test_expect_success 'pack-refs: compacts tables' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+
+       test_commit -C repo A &&
+       ls -1 repo/.git/reftable >table-files &&
+       test_line_count = 4 table-files &&
+       test_line_count = 3 repo/.git/reftable/tables.list &&
+
+       git -C repo pack-refs &&
+       ls -1 repo/.git/reftable >table-files &&
+       test_line_count = 2 table-files &&
+       test_line_count = 1 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'pack-refs: prunes stale tables' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       touch repo/.git/reftable/stale-table.ref &&
+       git -C repo pack-refs &&
+       test_path_is_missing repo/.git/reftable/stable-ref.ref
+'
+
+test_expect_success 'pack-refs: does not prune non-table files' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       touch repo/.git/reftable/garbage &&
+       git -C repo pack-refs &&
+       test_path_is_file repo/.git/reftable/garbage
+'
+
+for umask in 002 022
+do
+       test_expect_success POSIXPERM 'pack-refs: honors core.sharedRepository' '
+               test_when_finished "rm -rf repo" &&
+               (
+                       umask $umask &&
+                       git init --shared=true repo &&
+                       test_commit -C repo A &&
+                       test_line_count = 3 repo/.git/reftable/tables.list
+               ) &&
+               git -C repo pack-refs &&
+               test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
+               for table in repo/.git/reftable/*.ref
+               do
+                       test_expect_perms "-rw-rw-r--" "$table" ||
+                       return 1
+               done
+       '
+done
+
+test_expect_success 'packed-refs: writes are synced' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo initial &&
+       test_line_count = 2 table-files &&
+
+       : >trace2.txt &&
+       GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+       GIT_TEST_FSYNC=true \
+               git -C repo -c core.fsync=reference \
+               -c core.fsyncMethod=fsync pack-refs &&
+       check_fsync_events trace2.txt <<-EOF
+       "name":"hardware-flush","count":2
+       EOF
+'
+
+test_expect_success 'ref iterator: bogus names are flagged' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit --no-tag file &&
+               test-tool ref-store main update-ref msg "refs/heads/bogus..name" $(git rev-parse HEAD) $ZERO_OID REF_SKIP_REFNAME_VERIFICATION &&
+
+               cat >expect <<-EOF &&
+               $ZERO_OID refs/heads/bogus..name 0xc
+               $(git rev-parse HEAD) refs/heads/main 0x0
+               EOF
+               test-tool ref-store main for-each-ref "" >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ref iterator: missing object IDs are not flagged' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test-tool ref-store main update-ref msg "refs/heads/broken-hash" $INVALID_OID $ZERO_OID REF_SKIP_OID_VERIFICATION &&
+
+               cat >expect <<-EOF &&
+               $INVALID_OID refs/heads/broken-hash 0x0
+               EOF
+               test-tool ref-store main for-each-ref "" >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'basic: commit and list refs' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo file &&
+       test_write_lines refs/heads/main refs/tags/file >expect &&
+       git -C repo for-each-ref --format="%(refname)" >actual &&
+       test_cmp actual expect
+'
+
+test_expect_success 'basic: can write large commit message' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       perl -e "
+               print \"this is a long commit message\" x 50000
+       " >commit-msg &&
+       git -C repo commit --allow-empty --file=../commit-msg
+'
+
+test_expect_success 'basic: show-ref fails with empty repository' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_must_fail git -C repo show-ref >actual &&
+       test_must_be_empty actual
+'
+
+test_expect_success 'basic: can check out unborn branch' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       git -C repo checkout -b main
+'
+
+test_expect_success 'basic: peeled tags are stored' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       test_commit -C repo file &&
+       git -C repo tag -m "annotated tag" test_tag HEAD &&
+       for ref in refs/heads/main refs/tags/file refs/tags/test_tag refs/tags/test_tag^{}
+       do
+               echo "$(git -C repo rev-parse "$ref") $ref" || return 1
+       done >expect &&
+       git -C repo show-ref -d >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'basic: for-each-ref can print symrefs' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file &&
+               git branch &&
+               git symbolic-ref refs/heads/sym refs/heads/main &&
+               cat >expected <<-EOF &&
+               refs/heads/main
+               EOF
+               git for-each-ref --format="%(symref)" refs/heads/sym >actual &&
+               test_cmp expected actual
+       )
+'
+
+test_expect_success 'basic: notes' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               write_script fake_editor <<-\EOF &&
+               echo "$MSG" >"$1"
+               echo "$MSG" >&2
+               EOF
+
+               test_commit 1st &&
+               test_commit 2nd &&
+               GIT_EDITOR=./fake_editor MSG=b4 git notes add &&
+               GIT_EDITOR=./fake_editor MSG=b3 git notes edit &&
+               echo b4 >expect &&
+               git notes --ref commits@{1} show >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'basic: stash' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file &&
+               git stash list >expect &&
+               test_line_count = 0 expect &&
+
+               echo hoi >>file.t &&
+               git stash push -m stashed &&
+               git stash list >expect &&
+               test_line_count = 1 expect &&
+
+               git stash clear &&
+               git stash list >expect &&
+               test_line_count = 0 expect
+       )
+'
+
+test_expect_success 'basic: cherry-pick' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit message1 file1 &&
+               test_commit message2 file2 &&
+               git branch source &&
+               git checkout HEAD^ &&
+               test_commit message3 file3 &&
+               git cherry-pick source &&
+               test_path_is_file file2
+       )
+'
+
+test_expect_success 'basic: rebase' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit message1 file1 &&
+               test_commit message2 file2 &&
+               git branch source &&
+               git checkout HEAD^ &&
+               test_commit message3 file3 &&
+               git rebase source &&
+               test_path_is_file file2
+       )
+'
+
+test_expect_success 'reflog: can delete separate reflog entries' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               test_commit file &&
+               test_commit file2 &&
+               test_commit file3 &&
+               test_commit file4 &&
+               git reflog >actual &&
+               grep file3 actual &&
+
+               git reflog delete HEAD@{1} &&
+               git reflog >actual &&
+               ! grep file3 actual
+       )
+'
+
+test_expect_success 'reflog: can switch to previous branch' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file1 &&
+               git checkout -b branch1 &&
+               test_commit file2 &&
+               git checkout -b branch2 &&
+               git switch - &&
+               git rev-parse --symbolic-full-name HEAD >actual &&
+               echo refs/heads/branch1 >expect &&
+               test_cmp actual expect
+       )
+'
+
+test_expect_success 'reflog: copying branch writes reflog entry' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit file1 &&
+               test_commit file2 &&
+               oid=$(git rev-parse --short HEAD) &&
+               git branch src &&
+               cat >expect <<-EOF &&
+               ${oid} dst@{0}: Branch: copied refs/heads/src to refs/heads/dst
+               ${oid} dst@{1}: branch: Created from main
+               EOF
+               git branch -c src dst &&
+               git reflog dst >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'reflog: renaming branch writes reflog entry' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               git symbolic-ref HEAD refs/heads/before &&
+               test_commit file &&
+               git show-ref >expected.refs &&
+               sed s/before/after/g <expected.refs >expected &&
+               git branch -M after &&
+               git show-ref >actual &&
+               test_cmp expected actual &&
+               echo refs/heads/after >expected &&
+               git symbolic-ref HEAD >actual &&
+               test_cmp expected actual
+       )
+'
+
+test_expect_success 'reflog: can store empty logs' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               test_must_fail test-tool ref-store main reflog-exists refs/heads/branch &&
+               test-tool ref-store main create-reflog refs/heads/branch &&
+               test-tool ref-store main reflog-exists refs/heads/branch &&
+               test-tool ref-store main for-each-reflog-ent-reverse refs/heads/branch >actual &&
+               test_must_be_empty actual
+       )
+'
+
+test_expect_success 'reflog: expiry empties reflog' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               test_commit initial &&
+               git checkout -b branch &&
+               test_commit fileA &&
+               test_commit fileB &&
+
+               cat >expect <<-EOF &&
+               commit: fileB
+               commit: fileA
+               branch: Created from HEAD
+               EOF
+               git reflog show --format="%gs" refs/heads/branch >actual &&
+               test_cmp expect actual &&
+
+               git reflog expire branch --expire=all &&
+               git reflog show --format="%gs" refs/heads/branch >actual &&
+               test_must_be_empty actual &&
+               test-tool ref-store main reflog-exists refs/heads/branch
+       )
+'
+
+test_expect_success 'reflog: can be deleted' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit initial &&
+               test-tool ref-store main reflog-exists refs/heads/main &&
+               test-tool ref-store main delete-reflog refs/heads/main &&
+               test_must_fail test-tool ref-store main reflog-exists refs/heads/main
+       )
+'
+
+test_expect_success 'reflog: garbage collection deletes reflog entries' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               for count in $(test_seq 1 10)
+               do
+                       test_commit "number $count" file.t $count number-$count ||
+                       return 1
+               done &&
+               git reflog refs/heads/main >actual &&
+               test_line_count = 10 actual &&
+               grep "commit (initial): number 1" actual &&
+               grep "commit: number 10" actual &&
+
+               git gc &&
+               git reflog refs/heads/main >actual &&
+               test_line_count = 0 actual
+       )
+'
+
+test_expect_success 'reflog: updates via HEAD update HEAD reflog' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit main-one &&
+               git checkout -b new-branch &&
+               test_commit new-one &&
+               test_commit new-two &&
+
+               echo new-one >expect &&
+               git log -1 --format=%s HEAD@{1} >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'worktree: adding worktree creates separate stack' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo worktree add ../worktree &&
+       test_path_is_file repo/.git/worktrees/worktree/refs/heads &&
+       echo "ref: refs/heads/.invalid" >expect &&
+       test_cmp expect repo/.git/worktrees/worktree/HEAD &&
+       test_path_is_dir repo/.git/worktrees/worktree/reftable &&
+       test_path_is_file repo/.git/worktrees/worktree/reftable/tables.list
+'
+
+test_expect_success 'worktree: pack-refs in main repo packs main refs' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+       git -C repo worktree add ../worktree &&
+
+       test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 4 repo/.git/reftable/tables.list &&
+       git -C repo pack-refs &&
+       test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: pack-refs in worktree packs worktree refs' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+       git -C repo worktree add ../worktree &&
+
+       test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 4 repo/.git/reftable/tables.list &&
+       git -C worktree pack-refs &&
+       test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 4 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: creating shared ref updates main stack' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo worktree add ../worktree &&
+       git -C repo pack-refs &&
+       git -C worktree pack-refs &&
+       test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list &&
+
+       git -C worktree update-ref refs/heads/shared HEAD &&
+       test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 2 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: creating per-worktree ref updates worktree stack' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo worktree add ../worktree &&
+       git -C repo pack-refs &&
+       git -C worktree pack-refs &&
+       test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list &&
+
+       git -C worktree update-ref refs/bisect/per-worktree HEAD &&
+       test_line_count = 2 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: creating per-worktree ref from main repo' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo worktree add ../worktree &&
+       git -C repo pack-refs &&
+       git -C worktree pack-refs &&
+       test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list &&
+
+       git -C repo update-ref worktrees/worktree/refs/bisect/per-worktree HEAD &&
+       test_line_count = 2 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: creating per-worktree ref from second worktree' '
+       test_when_finished "rm -rf repo wt1 wt2" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo worktree add ../wt1 &&
+       git -C repo worktree add ../wt2 &&
+       git -C repo pack-refs &&
+       git -C wt1 pack-refs &&
+       git -C wt2 pack-refs &&
+       test_line_count = 1 repo/.git/worktrees/wt1/reftable/tables.list &&
+       test_line_count = 1 repo/.git/worktrees/wt2/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list &&
+
+       git -C wt1 update-ref worktrees/wt2/refs/bisect/per-worktree HEAD &&
+       test_line_count = 1 repo/.git/worktrees/wt1/reftable/tables.list &&
+       test_line_count = 2 repo/.git/worktrees/wt2/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: can create shared and per-worktree ref in one transaction' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo A &&
+
+       git -C repo worktree add ../worktree &&
+       git -C repo pack-refs &&
+       git -C worktree pack-refs &&
+       test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 1 repo/.git/reftable/tables.list &&
+
+       cat >stdin <<-EOF &&
+       create worktrees/worktree/refs/bisect/per-worktree HEAD
+       create refs/branches/shared HEAD
+       EOF
+       git -C repo update-ref --stdin <stdin &&
+       test_line_count = 2 repo/.git/worktrees/worktree/reftable/tables.list &&
+       test_line_count = 2 repo/.git/reftable/tables.list
+'
+
+test_expect_success 'worktree: can access common refs' '
+       test_when_finished "rm -rf repo worktree" &&
+       git init repo &&
+       test_commit -C repo file1 &&
+       git -C repo branch branch1 &&
+       git -C repo worktree add ../worktree &&
+
+       echo refs/heads/worktree >expect &&
+       git -C worktree symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
+       git -C worktree checkout branch1
+'
+
+test_expect_success 'worktree: adds worktree with detached HEAD' '
+       test_when_finished "rm -rf repo worktree" &&
+
+       git init repo &&
+       test_commit -C repo A &&
+       git -C repo rev-parse main >expect &&
+
+       git -C repo worktree add --detach ../worktree main &&
+       git -C worktree rev-parse HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'fetch: accessing FETCH_HEAD special ref works' '
+       test_when_finished "rm -rf repo sub" &&
+
+       git init sub &&
+       test_commit -C sub two &&
+       git -C sub rev-parse HEAD >expect &&
+
+       git init repo &&
+       test_commit -C repo one &&
+       git -C repo fetch ../sub &&
+       git -C repo rev-parse FETCH_HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_done
diff --git a/t/t0611-reftable-httpd.sh b/t/t0611-reftable-httpd.sh
new file mode 100755 (executable)
index 0000000..5e05b9c
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+test_description='reftable HTTPD tests'
+
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-httpd.sh
+
+start_httpd
+
+REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo"
+
+test_expect_success 'serving ls-remote' '
+       git init --ref-format=reftable -b main "$REPO" &&
+       cd "$REPO" &&
+       test_commit m1 &&
+       >.git/git-daemon-export-ok &&
+       git ls-remote "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" | cut -f 2-2 -d "   " >actual &&
+       cat >expect <<-EOF &&
+       HEAD
+       refs/heads/main
+       refs/tags/m1
+       EOF
+       test_cmp actual expect
+'
+
+test_done
index f67611da28e6e27125008e5e7073cec8a2fd8752..e49b8024ac53659e17f22eb39e252aba73e56a6b 100755 (executable)
@@ -334,7 +334,7 @@ test_expect_success 'cone mode: set with nested folders' '
 
 test_expect_success 'cone mode: add independent path' '
        git -C repo sparse-checkout set deep/deeper1 &&
-       git -C repo sparse-checkout add folder1 &&
+       git -C repo sparse-checkout add --end-of-options folder1 &&
        cat >expect <<-\EOF &&
        /*
        !/*/
@@ -886,6 +886,12 @@ test_expect_success 'by default, cone mode will error out when passed files' '
        grep ".gitignore.*is not a directory" error
 '
 
+test_expect_success 'error on mistyped command line options' '
+       test_must_fail git -C repo sparse-checkout add --sikp-checks .gitignore 2>error &&
+
+       grep "unknown option.*sikp-checks" error
+'
+
 test_expect_success 'by default, non-cone mode will warn on individual files' '
        git -C repo sparse-checkout reapply --no-cone &&
        git -C repo sparse-checkout add .gitignore 2>warning &&
index f4e27521344920ca5cf85b20a263487e2d794b52..31c38786870849e7a815f32a08933f059c9c8ffb 100755 (executable)
@@ -1098,15 +1098,20 @@ test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
        test_must_fail git config --file=linktolinktonada --list
 '
 
-test_expect_success 'check split_cmdline return' "
-       git config alias.split-cmdline-fix 'echo \"' &&
-       test_must_fail git split-cmdline-fix &&
-       echo foo > foo &&
-       git add foo &&
-       git commit -m 'initial commit' &&
-       git config branch.main.mergeoptions 'echo \"' &&
-       test_must_fail git merge main
-"
+test_expect_success 'check split_cmdline return' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               git config alias.split-cmdline-fix "echo \"" &&
+               test_must_fail git split-cmdline-fix &&
+               echo foo >foo &&
+               git add foo &&
+               git commit -m "initial commit" &&
+               git config branch.main.mergeoptions "echo \"" &&
+               test_must_fail git merge main
+       )
+'
 
 test_expect_success 'git -c "key=value" support' '
        cat >expect <<-\EOF &&
@@ -1157,10 +1162,16 @@ test_expect_success 'git -c works with aliases of builtins' '
 '
 
 test_expect_success 'aliases can be CamelCased' '
-       test_config alias.CamelCased "rev-parse HEAD" &&
-       git CamelCased >out &&
-       git rev-parse HEAD >expect &&
-       test_cmp expect out
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit A &&
+               git config alias.CamelCased "rev-parse HEAD" &&
+               git CamelCased >out &&
+               git rev-parse HEAD >expect &&
+               test_cmp expect out
+       )
 '
 
 test_expect_success 'git -c does not split values on equals' '
@@ -2009,11 +2020,11 @@ test_expect_success '--show-origin getting a single key' '
 '
 
 test_expect_success 'set up custom config file' '
-       CUSTOM_CONFIG_FILE="custom.conf" &&
-       cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
+       cat >"custom.conf" <<-\EOF &&
        [user]
                custom = true
        EOF
+       CUSTOM_CONFIG_FILE="$(test-tool path-utils real_path custom.conf)"
 '
 
 test_expect_success !MINGW 'set up custom config file with special name characters' '
@@ -2052,22 +2063,33 @@ test_expect_success '--show-origin stdin with file include' '
 '
 
 test_expect_success '--show-origin blob' '
-       blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
-       cat >expect <<-EOF &&
-       blob:$blob      user.custom=true
-       EOF
-       git config --blob=$blob --show-origin --list >output &&
-       test_cmp expect output
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
+               cat >expect <<-EOF &&
+               blob:$blob      user.custom=true
+               EOF
+               git config --blob=$blob --show-origin --list >output &&
+               test_cmp expect output
+       )
 '
 
 test_expect_success '--show-origin blob ref' '
-       cat >expect <<-\EOF &&
-       blob:main:custom.conf   user.custom=true
-       EOF
-       git add "$CUSTOM_CONFIG_FILE" &&
-       git commit -m "new config file" &&
-       git config --blob=main:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
-       test_cmp expect output
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               cat >expect <<-\EOF &&
+               blob:main:custom.conf   user.custom=true
+               EOF
+               cp "$CUSTOM_CONFIG_FILE" custom.conf &&
+               git add custom.conf &&
+               git commit -m "new config file" &&
+               git config --blob=main:custom.conf --show-origin --list >output &&
+               test_cmp expect output
+       )
 '
 
 test_expect_success '--show-origin with --default' '
index e5a0d65caa3e4cc363319826f37a4254bfc99b33..b1eb5c01b899daf9a0075393e3e79d47da069d5d 100755 (executable)
@@ -137,22 +137,6 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
        test_cmp expect actual
 '
 
-test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
-       umask 077 &&
-       git config core.sharedRepository group &&
-       git reflog expire --all &&
-       actual="$(ls -l .git/logs/refs/heads/main)" &&
-       case "$actual" in
-       -rw-rw-*)
-               : happy
-               ;;
-       *)
-               echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
-               false
-               ;;
-       esac
-'
-
 test_expect_success POSIXPERM 'forced modes' '
        test_when_finished "rm -rf new" &&
        mkdir -p templates/hooks &&
index 179474fa651e159bf68714620ab4f1be2c259fe5..42caa0d2978b58755d43b3361589c6e7691c34db 100755 (executable)
@@ -9,10 +9,6 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-       test_oid_cache <<-\EOF &&
-       version sha1:0
-       version sha256:1
-       EOF
        cat >test.patch <<-\EOF &&
        diff --git a/test.txt b/test.txt
        new file mode 100644
@@ -28,7 +24,12 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'gitdir selection on normal repos' '
-       test_oid version >expect &&
+       if test_have_prereq DEFAULT_REPO_FORMAT
+       then
+               echo 0
+       else
+               echo 1
+       fi >expect &&
        git config core.repositoryformatversion >actual &&
        git -C test config core.repositoryformatversion >actual2 &&
        test_cmp expect actual &&
@@ -79,8 +80,13 @@ mkconfig () {
 
 while read outcome version extensions; do
        test_expect_success "$outcome version=$version $extensions" "
-               mkconfig $version $extensions >.git/config &&
-               check_${outcome}
+               test_when_finished 'rm -rf extensions' &&
+               git init extensions &&
+               (
+                       cd extensions &&
+                       mkconfig $version $extensions >.git/config &&
+                       check_${outcome}
+               )
        "
 done <<\EOF
 allow 0
@@ -94,7 +100,8 @@ allow 1 noop-v1
 EOF
 
 test_expect_success 'precious-objects allowed' '
-       mkconfig 1 preciousObjects >.git/config &&
+       git config core.repositoryFormatVersion 1 &&
+       git config extensions.preciousObjects 1 &&
        check_allow
 '
 
index c41cd9b6bf91b2fece4e5139613f59584e882e8f..6ebc3ef9453b71dbc7d90a052834af482dfd48ec 100755 (executable)
@@ -9,8 +9,6 @@ test_description='Test git update-ref and basic ref logging'
 Z=$ZERO_OID
 
 m=refs/heads/main
-n_dir=refs/heads/gu
-n=$n_dir/fixes
 outside=refs/foo
 bare=bare-repo
 
@@ -62,10 +60,10 @@ test_expect_success "delete $m without oldvalue verification" '
        test_must_fail git show-ref --verify -q $m
 '
 
-test_expect_success "fail to create $n" '
-       test_when_finished "rm -f .git/$n_dir" &&
-       touch .git/$n_dir &&
-       test_must_fail git update-ref $n $A
+test_expect_success "fail to create $n due to file/directory conflict" '
+       test_when_finished "git update-ref -d refs/heads/gu" &&
+       git update-ref refs/heads/gu $A &&
+       test_must_fail git update-ref refs/heads/gu/fixes $A
 '
 
 test_expect_success "create $m (by HEAD)" '
@@ -92,7 +90,8 @@ test_expect_success "deleting current branch adds message to HEAD's log" '
        git symbolic-ref HEAD $m &&
        git update-ref -m delete-$m -d $m &&
        test_must_fail git show-ref --verify -q $m &&
-       grep "delete-$m$" .git/logs/HEAD
+       test-tool ref-store main for-each-reflog-ent HEAD >actual &&
+       grep "delete-$m$" actual
 '
 
 test_expect_success "deleting by HEAD adds message to HEAD's log" '
@@ -101,7 +100,8 @@ test_expect_success "deleting by HEAD adds message to HEAD's log" '
        git symbolic-ref HEAD $m &&
        git update-ref -m delete-by-head -d HEAD &&
        test_must_fail git show-ref --verify -q $m &&
-       grep "delete-by-head$" .git/logs/HEAD
+       test-tool ref-store main for-each-reflog-ent HEAD >actual &&
+       grep "delete-by-head$" actual
 '
 
 test_expect_success 'update-ref does not create reflogs by default' '
@@ -132,7 +132,7 @@ test_expect_success 'creates no reflog in bare repository' '
 
 test_expect_success 'core.logAllRefUpdates=true creates reflog in bare repository' '
        test_when_finished "git -C $bare config --unset core.logAllRefUpdates && \
-               rm $bare/logs/$m" &&
+               test-tool ref-store main delete-reflog $m" &&
        git -C $bare config core.logAllRefUpdates true &&
        git -C $bare update-ref $m $bareB &&
        git -C $bare rev-parse $bareB >expect &&
@@ -221,27 +221,27 @@ test_expect_success 'delete symref without dereference when the referred ref is
 '
 
 test_expect_success 'update-ref -d is not confused by self-reference' '
+       test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" &&
        git symbolic-ref refs/heads/self refs/heads/self &&
-       test_when_finished "rm -f .git/refs/heads/self" &&
-       test_path_is_file .git/refs/heads/self &&
+       git symbolic-ref --no-recurse refs/heads/self &&
        test_must_fail git update-ref -d refs/heads/self &&
-       test_path_is_file .git/refs/heads/self
+       git symbolic-ref --no-recurse refs/heads/self
 '
 
 test_expect_success 'update-ref --no-deref -d can delete self-reference' '
+       test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" &&
        git symbolic-ref refs/heads/self refs/heads/self &&
-       test_when_finished "rm -f .git/refs/heads/self" &&
-       test_path_is_file .git/refs/heads/self &&
+       git symbolic-ref --no-recurse refs/heads/self &&
        git update-ref --no-deref -d refs/heads/self &&
        test_must_fail git show-ref --verify -q refs/heads/self
 '
 
-test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' '
+test_expect_success REFFILES 'update-ref --no-deref -d can delete reference to bad ref' '
        >.git/refs/heads/bad &&
        test_when_finished "rm -f .git/refs/heads/bad" &&
        git symbolic-ref refs/heads/ref-to-bad refs/heads/bad &&
        test_when_finished "git update-ref -d refs/heads/ref-to-bad" &&
-       test_path_is_file .git/refs/heads/ref-to-bad &&
+       git symbolic-ref --no-recurse refs/heads/ref-to-bad &&
        git update-ref --no-deref -d refs/heads/ref-to-bad &&
        test_must_fail git show-ref --verify -q refs/heads/ref-to-bad
 '
@@ -265,7 +265,10 @@ test_expect_success "(not) changed .git/$m" '
        ! test $B = $(git show-ref -s --verify $m)
 '
 
-rm -f .git/logs/refs/heads/main
+test_expect_success "clean up reflog" '
+       test-tool ref-store main delete-reflog $m
+'
+
 test_expect_success "create $m (logged by touch)" '
        test_config core.logAllRefUpdates false &&
        GIT_COMMITTER_DATE="2005-05-26 23:30" \
@@ -285,40 +288,13 @@ test_expect_success "set $m (logged by touch)" '
        test $A = $(git show-ref -s --verify $m)
 '
 
-test_expect_success 'empty directory removal' '
-       git branch d1/d2/r1 HEAD &&
-       git branch d1/r2 HEAD &&
-       test_path_is_file .git/refs/heads/d1/d2/r1 &&
-       test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
-       git branch -d d1/d2/r1 &&
-       test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
-       test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
-       test_path_is_file .git/refs/heads/d1/r2 &&
-       test_path_is_file .git/logs/refs/heads/d1/r2
-'
-
-test_expect_success 'symref empty directory removal' '
-       git branch e1/e2/r1 HEAD &&
-       git branch e1/r2 HEAD &&
-       git checkout e1/e2/r1 &&
-       test_when_finished "git checkout main" &&
-       test_path_is_file .git/refs/heads/e1/e2/r1 &&
-       test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
-       git update-ref -d HEAD &&
-       test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
-       test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
-       test_path_is_file .git/refs/heads/e1/r2 &&
-       test_path_is_file .git/logs/refs/heads/e1/r2 &&
-       test_path_is_file .git/logs/HEAD
-'
-
 cat >expect <<EOF
 $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000      Initial Creation
 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000      Switch
 $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
 EOF
 test_expect_success "verifying $m's log (logged by touch)" '
-       test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" &&
+       test_when_finished "git update-ref -d $m && git reflog expire --expire=all --all && rm -rf actual expect" &&
        test-tool ref-store main for-each-reflog-ent $m >actual &&
        test_cmp actual expect
 '
@@ -348,7 +324,7 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000   Switch
 $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
 EOF
 test_expect_success "verifying $m's log (logged by config)" '
-       test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" &&
+       test_when_finished "git update-ref -d $m && git reflog expire --expire=all --all && rm -rf actual expect" &&
        test-tool ref-store main for-each-reflog-ent $m >actual &&
        test_cmp actual expect
 '
@@ -447,17 +423,18 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' '
        test_grep -F "warning: log for ref $m unexpectedly ended on $ld" e
 '
 
-rm -f .git/$m .git/logs/$m expect
+rm -f expect
+git update-ref -d $m
 
-test_expect_success REFFILES 'query reflog with gap' '
+test_expect_success 'query reflog with gap' '
        test_when_finished "git update-ref -d $m" &&
 
-       git update-ref $m $F &&
-       cat >.git/logs/$m <<-EOF &&
-       $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
-       $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
-       $D $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
-       EOF
+       GIT_COMMITTER_DATE="1117150320 -0500" git update-ref $m $A &&
+       GIT_COMMITTER_DATE="1117150380 -0500" git update-ref $m $B &&
+       GIT_COMMITTER_DATE="1117150480 -0500" git update-ref $m $C &&
+       GIT_COMMITTER_DATE="1117150580 -0500" git update-ref $m $D &&
+       GIT_COMMITTER_DATE="1117150680 -0500" git update-ref $m $F &&
+       git reflog delete $m@{2} &&
 
        git rev-parse --verify "main@{2005-05-26 23:33:01}" >actual 2>stderr &&
        echo "$B" >expect &&
@@ -520,51 +497,51 @@ test_expect_success 'given old value for missing pseudoref, do not create' '
 
 test_expect_success 'create pseudoref' '
        git update-ref PSEUDOREF $A &&
-       test $A = $(git rev-parse PSEUDOREF)
+       test $A = $(git show-ref -s --verify PSEUDOREF)
 '
 
 test_expect_success 'overwrite pseudoref with no old value given' '
        git update-ref PSEUDOREF $B &&
-       test $B = $(git rev-parse PSEUDOREF)
+       test $B = $(git show-ref -s --verify PSEUDOREF)
 '
 
 test_expect_success 'overwrite pseudoref with correct old value' '
        git update-ref PSEUDOREF $C $B &&
-       test $C = $(git rev-parse PSEUDOREF)
+       test $C = $(git show-ref -s --verify PSEUDOREF)
 '
 
 test_expect_success 'do not overwrite pseudoref with wrong old value' '
        test_must_fail git update-ref PSEUDOREF $D $E 2>err &&
-       test $C = $(git rev-parse PSEUDOREF) &&
+       test $C = $(git show-ref -s --verify PSEUDOREF) &&
        test_grep "cannot lock ref.*expected" err
 '
 
 test_expect_success 'delete pseudoref' '
        git update-ref -d PSEUDOREF &&
-       test_must_fail git rev-parse PSEUDOREF
+       test_must_fail git show-ref -s --verify PSEUDOREF
 '
 
 test_expect_success 'do not delete pseudoref with wrong old value' '
        git update-ref PSEUDOREF $A &&
        test_must_fail git update-ref -d PSEUDOREF $B 2>err &&
-       test $A = $(git rev-parse PSEUDOREF) &&
+       test $A = $(git show-ref -s --verify PSEUDOREF) &&
        test_grep "cannot lock ref.*expected" err
 '
 
 test_expect_success 'delete pseudoref with correct old value' '
        git update-ref -d PSEUDOREF $A &&
-       test_must_fail git rev-parse PSEUDOREF
+       test_must_fail git show-ref -s --verify PSEUDOREF
 '
 
 test_expect_success 'create pseudoref with old OID zero' '
        git update-ref PSEUDOREF $A $Z &&
-       test $A = $(git rev-parse PSEUDOREF)
+       test $A = $(git show-ref -s --verify PSEUDOREF)
 '
 
 test_expect_success 'do not overwrite pseudoref with old OID zero' '
        test_when_finished git update-ref -d PSEUDOREF &&
        test_must_fail git update-ref PSEUDOREF $B $Z 2>err &&
-       test $A = $(git rev-parse PSEUDOREF) &&
+       test $A = $(git show-ref -s --verify PSEUDOREF) &&
        test_grep "already exists" err
 '
 
@@ -1664,13 +1641,4 @@ test_expect_success PIPE 'transaction flushes status updates' '
        test_cmp expected actual
 '
 
-test_expect_success 'directory not created deleting packed ref' '
-       git branch d1/d2/r1 HEAD &&
-       git pack-refs --all &&
-       test_path_is_missing .git/refs/heads/d1/d2 &&
-       git update-ref -d refs/heads/d1/d2/r1 &&
-       test_path_is_missing .git/refs/heads/d1/d2 &&
-       test_path_is_missing .git/refs/heads/d1
-'
-
 test_done
index 3241d3591799415e423e4f6155e4111de778a964..5c60d6f812dc20c1c86f5125b5feabb4ce1df9ce 100755 (executable)
@@ -106,9 +106,8 @@ test_expect_success LONG_REF 'we can parse long symbolic ref' '
 '
 
 test_expect_success 'symbolic-ref reports failure in exit code' '
-       test_when_finished "rm -f .git/HEAD.lock" &&
-       >.git/HEAD.lock &&
-       test_must_fail git symbolic-ref HEAD refs/heads/whatever
+       # Create d/f conflict to simulate failure.
+       test_must_fail git symbolic-ref refs/heads refs/heads/foo
 '
 
 test_expect_success 'symbolic-ref writes reflog entry' '
index 872ba8f1101a41f0d42d9c4ee43f6b95c63fc95b..33fb7a38ffff849db2a825de61eacbc34a8eb11d 100755 (executable)
@@ -174,6 +174,14 @@ test_expect_success 'show-ref --verify HEAD' '
        test_must_be_empty actual
 '
 
+test_expect_success 'show-ref --verify pseudorefs' '
+       git update-ref CHERRY_PICK_HEAD HEAD $ZERO_OID &&
+       test_when_finished "git update-ref -d CHERRY_PICK_HEAD" &&
+       git show-ref -s --verify HEAD >actual &&
+       git show-ref -s --verify CHERRY_PICK_HEAD >expect &&
+       test_cmp actual expect
+'
+
 test_expect_success 'show-ref --verify with dangling ref' '
        sha1_file() {
                echo "$*" | sed "s#..#.git/objects/&/#"
@@ -268,4 +276,14 @@ test_expect_success '--exists with directory fails with generic error' '
        test_cmp expect err
 '
 
+test_expect_success '--exists with non-existent special ref' '
+       test_expect_code 2 git show-ref --exists FETCH_HEAD
+'
+
+test_expect_success '--exists with existing special ref' '
+       test_when_finished "rm .git/FETCH_HEAD" &&
+       git rev-parse HEAD >.git/FETCH_HEAD &&
+       git show-ref --exists FETCH_HEAD
+'
+
 test_done
index 0369beea33b1aff41662390245fdf2ccf21b1cfb..98e9158bd2ab41f17af11612ef1bfd5e65796605 100755 (executable)
@@ -92,9 +92,6 @@ df_test() {
        else
                delname="$delref"
        fi &&
-       cat >expected-err <<-EOF &&
-       fatal: cannot lock ref $SQ$addname$SQ: $SQ$delref$SQ exists; cannot create $SQ$addref$SQ
-       EOF
        $pack &&
        if $add_del
        then
@@ -103,7 +100,7 @@ df_test() {
                printf "%s\n" "delete $delname" "create $addname $D"
        fi >commands &&
        test_must_fail git update-ref --stdin <commands 2>output.err &&
-       test_cmp expected-err output.err &&
+       grep "fatal:\( cannot lock ref $SQ$addname$SQ:\)\? $SQ$delref$SQ exists; cannot create $SQ$addref$SQ" output.err &&
        printf "%s\n" "$C $delref" >expected-refs &&
        git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs &&
        test_cmp expected-refs actual-refs
@@ -191,141 +188,69 @@ test_expect_success 'one new ref is a simple prefix of another' '
 
 '
 
-test_expect_success REFFILES 'empty directory should not fool rev-parse' '
-       prefix=refs/e-rev-parse &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       echo "$C" >expected &&
-       git rev-parse $prefix/foo >actual &&
-       test_cmp expected actual
-'
-
-test_expect_success REFFILES 'empty directory should not fool for-each-ref' '
-       prefix=refs/e-for-each-ref &&
-       git update-ref $prefix/foo $C &&
-       git for-each-ref $prefix >expected &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       git for-each-ref $prefix >actual &&
-       test_cmp expected actual
-'
-
-test_expect_success REFFILES 'empty directory should not fool create' '
-       prefix=refs/e-create &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       printf "create %s $C\n" $prefix/foo |
-       git update-ref --stdin
-'
-
-test_expect_success REFFILES 'empty directory should not fool verify' '
-       prefix=refs/e-verify &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       printf "verify %s $C\n" $prefix/foo |
-       git update-ref --stdin
-'
-
-test_expect_success REFFILES 'empty directory should not fool 1-arg update' '
-       prefix=refs/e-update-1 &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       printf "update %s $D\n" $prefix/foo |
-       git update-ref --stdin
-'
-
-test_expect_success REFFILES 'empty directory should not fool 2-arg update' '
-       prefix=refs/e-update-2 &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       printf "update %s $D $C\n" $prefix/foo |
-       git update-ref --stdin
-'
-
-test_expect_success REFFILES 'empty directory should not fool 0-arg delete' '
-       prefix=refs/e-delete-0 &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       printf "delete %s\n" $prefix/foo |
-       git update-ref --stdin
-'
-
-test_expect_success REFFILES 'empty directory should not fool 1-arg delete' '
-       prefix=refs/e-delete-1 &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       mkdir -p .git/$prefix/foo/bar/baz &&
-       printf "delete %s $C\n" $prefix/foo |
-       git update-ref --stdin
-'
-
-test_expect_success REFFILES 'D/F conflict prevents add long + delete short' '
+test_expect_success 'D/F conflict prevents add long + delete short' '
        df_test refs/df-al-ds --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents add short + delete long' '
+test_expect_success 'D/F conflict prevents add short + delete long' '
        df_test refs/df-as-dl --add-del foo foo/bar
 '
 
-test_expect_success REFFILES 'D/F conflict prevents delete long + add short' '
+test_expect_success 'D/F conflict prevents delete long + add short' '
        df_test refs/df-dl-as --del-add foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents delete short + add long' '
+test_expect_success 'D/F conflict prevents delete short + add long' '
        df_test refs/df-ds-al --del-add foo foo/bar
 '
 
-test_expect_success REFFILES 'D/F conflict prevents add long + delete short packed' '
+test_expect_success 'D/F conflict prevents add long + delete short packed' '
        df_test refs/df-al-dsp --pack --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents add short + delete long packed' '
+test_expect_success 'D/F conflict prevents add short + delete long packed' '
        df_test refs/df-as-dlp --pack --add-del foo foo/bar
 '
 
-test_expect_success REFFILES 'D/F conflict prevents delete long packed + add short' '
+test_expect_success 'D/F conflict prevents delete long packed + add short' '
        df_test refs/df-dlp-as --pack --del-add foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents delete short packed + add long' '
+test_expect_success 'D/F conflict prevents delete short packed + add long' '
        df_test refs/df-dsp-al --pack --del-add foo foo/bar
 '
 
 # Try some combinations involving symbolic refs...
 
-test_expect_success REFFILES 'D/F conflict prevents indirect add long + delete short' '
+test_expect_success 'D/F conflict prevents indirect add long + delete short' '
        df_test refs/df-ial-ds --sym-add --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents indirect add long + indirect delete short' '
+test_expect_success 'D/F conflict prevents indirect add long + indirect delete short' '
        df_test refs/df-ial-ids --sym-add --sym-del --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents indirect add short + indirect delete long' '
+test_expect_success 'D/F conflict prevents indirect add short + indirect delete long' '
        df_test refs/df-ias-idl --sym-add --sym-del --add-del foo foo/bar
 '
 
-test_expect_success REFFILES 'D/F conflict prevents indirect delete long + indirect add short' '
+test_expect_success 'D/F conflict prevents indirect delete long + indirect add short' '
        df_test refs/df-idl-ias --sym-add --sym-del --del-add foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents indirect add long + delete short packed' '
+test_expect_success 'D/F conflict prevents indirect add long + delete short packed' '
        df_test refs/df-ial-dsp --sym-add --pack --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents indirect add long + indirect delete short packed' '
+test_expect_success 'D/F conflict prevents indirect add long + indirect delete short packed' '
        df_test refs/df-ial-idsp --sym-add --sym-del --pack --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents add long + indirect delete short packed' '
+test_expect_success 'D/F conflict prevents add long + indirect delete short packed' '
        df_test refs/df-al-idsp --sym-del --pack --add-del foo/bar foo
 '
 
-test_expect_success REFFILES 'D/F conflict prevents indirect delete long packed + indirect add short' '
+test_expect_success 'D/F conflict prevents indirect delete long packed + indirect add short' '
        df_test refs/df-idlp-ias --sym-add --sym-del --pack --del-add foo/bar foo
 '
 
@@ -468,169 +393,4 @@ test_expect_success 'incorrect old value blocks indirect no-deref delete' '
        test_cmp expected output.err
 '
 
-test_expect_success REFFILES 'non-empty directory blocks create' '
-       prefix=refs/ne-create &&
-       mkdir -p .git/$prefix/foo/bar &&
-       : >.git/$prefix/foo/bar/baz.lock &&
-       test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/foo$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
-       EOF
-       printf "%s\n" "update $prefix/foo $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ
-       EOF
-       printf "%s\n" "update $prefix/foo $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err
-'
-
-test_expect_success REFFILES 'broken reference blocks create' '
-       prefix=refs/broken-create &&
-       mkdir -p .git/$prefix &&
-       echo "gobbledigook" >.git/$prefix/foo &&
-       test_when_finished "rm -f .git/$prefix/foo" &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
-       EOF
-       printf "%s\n" "update $prefix/foo $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/foo$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
-       EOF
-       printf "%s\n" "update $prefix/foo $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err
-'
-
-test_expect_success REFFILES 'non-empty directory blocks indirect create' '
-       prefix=refs/ne-indirect-create &&
-       git symbolic-ref $prefix/symref $prefix/foo &&
-       mkdir -p .git/$prefix/foo/bar &&
-       : >.git/$prefix/foo/bar/baz.lock &&
-       test_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/symref$SQ: there is a non-empty directory $SQ.git/$prefix/foo$SQ blocking reference $SQ$prefix/foo$SQ
-       EOF
-       printf "%s\n" "update $prefix/symref $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ
-       EOF
-       printf "%s\n" "update $prefix/symref $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err
-'
-
-test_expect_success REFFILES 'broken reference blocks indirect create' '
-       prefix=refs/broken-indirect-create &&
-       git symbolic-ref $prefix/symref $prefix/foo &&
-       echo "gobbledigook" >.git/$prefix/foo &&
-       test_when_finished "rm -f .git/$prefix/foo" &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
-       EOF
-       printf "%s\n" "update $prefix/symref $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err &&
-       cat >expected <<-EOF &&
-       fatal: cannot lock ref $SQ$prefix/symref$SQ: unable to resolve reference $SQ$prefix/foo$SQ: reference broken
-       EOF
-       printf "%s\n" "update $prefix/symref $D $C" |
-       test_must_fail git update-ref --stdin 2>output.err &&
-       test_cmp expected output.err
-'
-
-test_expect_success REFFILES 'no bogus intermediate values during delete' '
-       prefix=refs/slow-transaction &&
-       # Set up a reference with differing loose and packed versions:
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       git update-ref $prefix/foo $D &&
-       # Now try to update the reference, but hold the `packed-refs` lock
-       # for a while to see what happens while the process is blocked:
-       : >.git/packed-refs.lock &&
-       test_when_finished "rm -f .git/packed-refs.lock" &&
-       {
-               # Note: the following command is intentionally run in the
-               # background. We increase the timeout so that `update-ref`
-               # attempts to acquire the `packed-refs` lock for much longer
-               # than it takes for us to do the check then delete it:
-               git -c core.packedrefstimeout=30000 update-ref -d $prefix/foo &
-       } &&
-       pid2=$! &&
-       # Give update-ref plenty of time to get to the point where it tries
-       # to lock packed-refs:
-       sleep 1 &&
-       # Make sure that update-ref did not complete despite the lock:
-       kill -0 $pid2 &&
-       # Verify that the reference still has its old value:
-       sha1=$(git rev-parse --verify --quiet $prefix/foo || echo undefined) &&
-       case "$sha1" in
-       $D)
-               # This is what we hope for; it means that nothing
-               # user-visible has changed yet.
-               : ;;
-       undefined)
-               # This is not correct; it means the deletion has happened
-               # already even though update-ref should not have been
-               # able to acquire the lock yet.
-               echo "$prefix/foo deleted prematurely" &&
-               break
-               ;;
-       $C)
-               # This value should never be seen. Probably the loose
-               # reference has been deleted but the packed reference
-               # is still there:
-               echo "$prefix/foo incorrectly observed to be C" &&
-               break
-               ;;
-       *)
-               # WTF?
-               echo "unexpected value observed for $prefix/foo: $sha1" &&
-               break
-               ;;
-       esac >out &&
-       rm -f .git/packed-refs.lock &&
-       wait $pid2 &&
-       test_must_be_empty out &&
-       test_must_fail git rev-parse --verify --quiet $prefix/foo
-'
-
-test_expect_success REFFILES 'delete fails cleanly if packed-refs file is locked' '
-       prefix=refs/locked-packed-refs &&
-       # Set up a reference with differing loose and packed versions:
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       git update-ref $prefix/foo $D &&
-       git for-each-ref $prefix >unchanged &&
-       # Now try to delete it while the `packed-refs` lock is held:
-       : >.git/packed-refs.lock &&
-       test_when_finished "rm -f .git/packed-refs.lock" &&
-       test_must_fail git update-ref -d $prefix/foo >out 2>err &&
-       git for-each-ref $prefix >actual &&
-       test_grep "Unable to create $SQ.*packed-refs.lock$SQ: " err &&
-       test_cmp unchanged actual
-'
-
-test_expect_success REFFILES 'delete fails cleanly if packed-refs.new write fails' '
-       # Setup and expectations are similar to the test above.
-       prefix=refs/failed-packed-refs &&
-       git update-ref $prefix/foo $C &&
-       git pack-refs --all &&
-       git update-ref $prefix/foo $D &&
-       git for-each-ref $prefix >unchanged &&
-       # This should not happen in practice, but it is an easy way to get a
-       # reliable error (we open with create_tempfile(), which uses O_EXCL).
-       : >.git/packed-refs.new &&
-       test_when_finished "rm -f .git/packed-refs.new" &&
-       test_must_fail git update-ref -d $prefix/foo &&
-       git for-each-ref $prefix >actual &&
-       test_cmp unchanged actual
-'
-
 test_done
index e4627cf1b61f0b3128a79e28f15a9d5e5693e30c..a6bcd62ab658eefcd11ae1778692ad6d7f4c3008 100755 (executable)
@@ -15,14 +15,6 @@ test_expect_success 'setup' '
        test_commit one
 '
 
-test_expect_success REFFILES 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
-       N=`find .git/refs -type f | wc -l` &&
-       test "$N" != 0 &&
-       $RUN pack-refs PACK_REFS_PRUNE,PACK_REFS_ALL &&
-       N=`find .git/refs -type f` &&
-       test -z "$N"
-'
-
 test_expect_success 'create_symref(FOO, refs/heads/main)' '
        $RUN create-symref FOO refs/heads/main nothing &&
        echo refs/heads/main >expected &&
@@ -41,12 +33,6 @@ test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
        test_must_fail git rev-parse refs/tags/new-tag --
 '
 
-# In reftable, we keep the reflogs around for deleted refs.
-test_expect_success !REFFILES 'delete-reflog(FOO, refs/tags/new-tag)' '
-       $RUN delete-reflog FOO &&
-       $RUN delete-reflog refs/tags/new-tag
-'
-
 test_expect_success 'rename_refs(main, new-main)' '
        git rev-parse main >expected &&
        $RUN rename-ref refs/heads/main refs/heads/new-main &&
@@ -82,11 +68,11 @@ test_expect_success 'verify_ref(new-main)' '
 '
 
 test_expect_success 'for_each_reflog()' '
-       $RUN for-each-reflog | sort -k2 | cut -d" " -f 2- >actual &&
+       $RUN for-each-reflog >actual &&
        cat >expected <<-\EOF &&
-       HEAD 0x1
-       refs/heads/main 0x0
-       refs/heads/new-main 0x0
+       HEAD
+       refs/heads/main
+       refs/heads/new-main
        EOF
        test_cmp expected actual
 '
@@ -112,7 +98,7 @@ test_expect_success 'delete_reflog(HEAD)' '
        test_must_fail git reflog exists HEAD
 '
 
-test_expect_success REFFILES 'create-reflog(HEAD)' '
+test_expect_success 'create-reflog(HEAD)' '
        $RUN create-reflog HEAD &&
        git reflog exists HEAD
 '
index e6a7f7334b6a96e4aa310532c8dc7d6c727fdd16..c01f0f14a1266f93f9066c738693d7c8a9a526dc 100755 (executable)
@@ -63,11 +63,11 @@ test_expect_success 'verify_ref(new-main)' '
 '
 
 test_expect_success 'for_each_reflog()' '
-       $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
+       $RUN for-each-reflog >actual &&
        cat >expected <<-\EOF &&
-       HEAD 0x1
-       refs/heads/main 0x0
-       refs/heads/new-main 0x0
+       HEAD
+       refs/heads/main
+       refs/heads/new-main
        EOF
        test_cmp expected actual
 '
index 05b1881c5911780b53a3d882dbe1a4dfae0034d8..48b1c92a41450b25645d6cd782aa86c8e630164b 100755 (executable)
@@ -53,41 +53,4 @@ test_expect_success 'create_symref(FOO, refs/heads/main)' '
        test_cmp expected actual
 '
 
-# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should
-# only appear in the for-each-reflog output if it is called from the correct
-# worktree, which is exercised in this test. This test is poorly written (and
-# therefore marked REFFILES) for mulitple reasons: 1) it creates invalidly
-# formatted log entres. 2) it uses direct FS access for creating the reflogs. 3)
-# PSEUDO-WT and refs/bisect/random do not create reflogs by default, so it is
-# not testing a realistic scenario.
-test_expect_success REFFILES 'for_each_reflog()' '
-       echo $ZERO_OID > .git/logs/PSEUDO-MAIN &&
-       mkdir -p     .git/logs/refs/bisect &&
-       echo $ZERO_OID > .git/logs/refs/bisect/random &&
-
-       echo $ZERO_OID > .git/worktrees/wt/logs/PSEUDO-WT &&
-       mkdir -p     .git/worktrees/wt/logs/refs/bisect &&
-       echo $ZERO_OID > .git/worktrees/wt/logs/refs/bisect/wt-random &&
-
-       $RWT for-each-reflog | cut -d" " -f 2- | sort >actual &&
-       cat >expected <<-\EOF &&
-       HEAD 0x1
-       PSEUDO-WT 0x0
-       refs/bisect/wt-random 0x0
-       refs/heads/main 0x0
-       refs/heads/wt-main 0x0
-       EOF
-       test_cmp expected actual &&
-
-       $RMAIN for-each-reflog | cut -d" " -f 2- | sort >actual &&
-       cat >expected <<-\EOF &&
-       HEAD 0x1
-       PSEUDO-MAIN 0x0
-       refs/bisect/random 0x0
-       refs/heads/main 0x0
-       refs/heads/wt-main 0x0
-       EOF
-       test_cmp expected actual
-'
-
 test_done
index f23c0152a858265e4a8c6b0c068e00823aadb444..7748973733e6adab07117192accabf7698189681 100755 (executable)
@@ -5,6 +5,12 @@ test_description='avoid rewriting packed-refs unnecessarily'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if test_have_prereq !REFFILES
+then
+  skip_all='skipping files-backend specific pack-refs tests'
+  test_done
+fi
+
 # Add an identifying mark to the packed-refs file header line. This
 # shouldn't upset readers, and it should be omitted if the file is
 # ever rewritten.
index a0ff8d51f04b2d9ad34060a4f42290577d6673f7..5bf883f1e363306a74b15df1ab02988564aa3208 100755 (executable)
@@ -354,36 +354,6 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '
        test_must_be_empty actual
 '
 
-# Triggering the bug detected by this test requires a newline to fall
-# exactly BUFSIZ-1 bytes from the end of the file. We don't know
-# what that value is, since it's platform dependent. However, if
-# we choose some value N, we also catch any D which divides N evenly
-# (since we will read backwards in chunks of D). So we choose 8K,
-# which catches glibc (with an 8K BUFSIZ) and *BSD (1K).
-#
-# Each line is 114 characters, so we need 75 to still have a few before the
-# last 8K. The 89-character padding on the final entry lines up our
-# newline exactly.
-test_expect_success REFFILES,SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
-       git checkout -b reflogskip &&
-       zf=$(test_oid zero_2) &&
-       ident="abc <xyz> 0000000001 +0000" &&
-       for i in $(test_seq 1 75); do
-               printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
-               if test $i = 75; then
-                       for j in $(test_seq 1 89); do
-                               printf X || return 1
-                       done
-               else
-                       printf X
-               fi &&
-               printf "\n" || return 1
-       done >.git/logs/refs/heads/reflogskip &&
-       git rev-parse reflogskip@{73} >actual &&
-       echo ${zf}03 >expect &&
-       test_cmp expect actual
-'
-
 test_expect_success 'no segfaults for reflog containing non-commit sha1s' '
        git update-ref --create-reflog -m "Creating ref" \
                refs/tests/tree-in-reflog HEAD &&
@@ -397,18 +367,6 @@ test_expect_failure 'reflog with non-commit entries displays all entries' '
        test_line_count = 3 actual
 '
 
-# This test takes a lock on an individual ref; this is not supported in
-# reftable.
-test_expect_success REFFILES 'reflog expire operates on symref not referrent' '
-       git branch --create-reflog the_symref &&
-       git branch --create-reflog referrent &&
-       git update-ref referrent HEAD &&
-       git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
-       test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
-       touch .git/refs/heads/referrent.lock &&
-       git reflog expire --expire=all the_symref
-'
-
 test_expect_success 'continue walking past root commits' '
        git init orphanage &&
        (
@@ -478,4 +436,112 @@ test_expect_success 'empty reflog' '
        test_must_be_empty err
 '
 
+test_expect_success 'list reflogs' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               git reflog list >actual &&
+               test_must_be_empty actual &&
+
+               test_commit A &&
+               cat >expect <<-EOF &&
+               HEAD
+               refs/heads/main
+               EOF
+               git reflog list >actual &&
+               test_cmp expect actual &&
+
+               git branch b &&
+               cat >expect <<-EOF &&
+               HEAD
+               refs/heads/b
+               refs/heads/main
+               EOF
+               git reflog list >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'list reflogs with worktree' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               test_commit A &&
+               git worktree add wt &&
+               git -c core.logAllRefUpdates=always \
+                       update-ref refs/worktree/main HEAD &&
+               git -c core.logAllRefUpdates=always \
+                       update-ref refs/worktree/per-worktree HEAD &&
+               git -c core.logAllRefUpdates=always -C wt \
+                       update-ref refs/worktree/per-worktree HEAD &&
+               git -c core.logAllRefUpdates=always -C wt \
+                       update-ref refs/worktree/worktree HEAD &&
+
+               cat >expect <<-EOF &&
+               HEAD
+               refs/heads/main
+               refs/heads/wt
+               refs/worktree/main
+               refs/worktree/per-worktree
+               EOF
+               git reflog list >actual &&
+               test_cmp expect actual &&
+
+               cat >expect <<-EOF &&
+               HEAD
+               refs/heads/main
+               refs/heads/wt
+               refs/worktree/per-worktree
+               refs/worktree/worktree
+               EOF
+               git -C wt reflog list >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'reflog list returns error with additional args' '
+       cat >expect <<-EOF &&
+       error: list does not accept arguments: ${SQ}bogus${SQ}
+       EOF
+       test_must_fail git reflog list bogus 2>err &&
+       test_cmp expect err
+'
+
+test_expect_success 'reflog for symref with unborn target can be listed' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit A &&
+               git symbolic-ref HEAD refs/heads/unborn &&
+               cat >expect <<-EOF &&
+               HEAD
+               refs/heads/main
+               EOF
+               git reflog list >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'reflog with invalid object ID can be listed' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit A &&
+               test-tool ref-store main update-ref msg refs/heads/missing \
+                       $(test_oid deadbeef) "$ZERO_OID" REF_SKIP_OID_VERIFICATION &&
+               cat >expect <<-EOF &&
+               HEAD
+               refs/heads/main
+               refs/heads/missing
+               EOF
+               git reflog list >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done
index ea64cecf47bf14277c79cc54e954c64022e0519a..be6c3f472c176525b64383b726ad7b05b664accd 100755 (executable)
@@ -121,13 +121,12 @@ test_expect_success 'min/max age uses entry date to limit' '
 
 # Create a situation where the reflog and ref database disagree about the latest
 # state of HEAD.
-test_expect_success REFFILES 'walk prefers reflog to ref tip' '
+test_expect_success 'walk prefers reflog to ref tip' '
+       test_commit A &&
+       test_commit B &&
+       git reflog delete HEAD@{0} &&
        head=$(git rev-parse HEAD) &&
-       one=$(git rev-parse one) &&
-       ident="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" &&
-       echo "$head $one $ident broken reflog entry" >>.git/logs/HEAD &&
-
-       echo $one >expect &&
+       git rev-parse A >expect &&
        git log -g --format=%H -1 >actual &&
        test_cmp expect actual
 '
index 3b531842dd4c864b45bfd89c36e14f9327d6b29e..eb4eec8becbfa64efcde4e866334363a866c01a2 100755 (executable)
@@ -17,17 +17,6 @@ test_expect_success 'setup' '
        git -C wt2 update-ref refs/worktree/foo HEAD
 '
 
-# The 'packed-refs' file is stored directly in .git/. This means it is global
-# to the repository, and can only contain refs that are shared across all
-# worktrees.
-test_expect_success REFFILES 'refs/worktree must not be packed' '
-       git pack-refs --all &&
-       test_path_is_missing .git/refs/tags/wt1 &&
-       test_path_is_file .git/refs/worktree/foo &&
-       test_path_is_file .git/worktrees/wt1/refs/worktree/foo &&
-       test_path_is_file .git/worktrees/wt2/refs/worktree/foo
-'
-
 test_expect_success 'refs/worktree are per-worktree' '
        test_cmp_rev worktree/foo initial &&
        ( cd wt1 && test_cmp_rev worktree/foo wt1 ) &&
index 5d8c86b657399e0d8852909a33491449f1eaefa9..13595744190b54e539a581f2409ab3be5e3932d3 100755 (executable)
@@ -8,6 +8,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+if test_have_prereq !REFFILES
+then
+       skip_all='skipping `git for-each-ref --exclude` tests; need files backend'
+       test_done
+fi
+
 for_each_ref__exclude () {
        GIT_TRACE2_PERF=1 test-tool ref-store main \
                for-each-ref--exclude "$@" >actual.raw
index 68cc9e73d0c01bb7b9642b25d33155406662116c..0c00118c2b3f798777bad27a7082e5c0a2f29ea4 100755 (executable)
@@ -164,9 +164,9 @@ test_expect_success 'rev-parse skips symref pointing to broken name' '
 test_expect_success 'for-each-ref emits warnings for broken names' '
        test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID REF_SKIP_REFNAME_VERIFICATION &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" &&
-       printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
+       test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/badname" &&
-       printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref &&
+       test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" &&
        git for-each-ref >output 2>error &&
        ! grep -e "broken\.\.\.ref" output &&
@@ -257,7 +257,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' '
 '
 
 test_expect_success 'update-ref --no-deref -d can delete symref with broken name' '
-       printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref &&
+       test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" &&
        test_ref_exists refs/heads/broken...symref &&
        git update-ref --no-deref -d refs/heads/broken...symref >output 2>error &&
@@ -267,7 +267,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref with broken name
 '
 
 test_expect_success 'branch -d can delete symref with broken name' '
-       printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref &&
+       test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" &&
        test_ref_exists refs/heads/broken...symref &&
        git branch -d broken...symref >output 2>error &&
@@ -277,7 +277,7 @@ test_expect_success 'branch -d can delete symref with broken name' '
 '
 
 test_expect_success 'update-ref --no-deref -d can delete dangling symref with broken name' '
-       printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref &&
+       test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/idonotexist &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" &&
        test_ref_exists refs/heads/broken...symref &&
        git update-ref --no-deref -d refs/heads/broken...symref >output 2>error &&
@@ -287,7 +287,7 @@ test_expect_success 'update-ref --no-deref -d can delete dangling symref with br
 '
 
 test_expect_success 'branch -d can delete dangling symref with broken name' '
-       printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref &&
+       test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/idonotexist &&
        test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" &&
        test_ref_exists refs/heads/broken...symref &&
        git branch -d broken...symref >output 2>error &&
index 0e3e87d37a1d52417e91ff1fc51fc86a468f0c89..8a456b1142d1cc463f97c5e8809bcfc83ffa1e96 100755 (executable)
@@ -15,6 +15,7 @@ test_expect_success setup '
        git config --unset i18n.commitencoding &&
        git checkout HEAD^0 &&
        test_commit B fileB two &&
+       orig_head=$(git rev-parse HEAD) &&
        git tag -d A B &&
        git reflog expire --expire=now --all
 '
@@ -115,15 +116,15 @@ test_expect_success 'zlib corrupt loose object output ' '
 '
 
 test_expect_success 'branch pointing to non-commit' '
-       git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
+       tree_oid=$(git rev-parse --verify HEAD^{tree}) &&
        test_when_finished "git update-ref -d refs/heads/invalid" &&
+       test-tool ref-store main update-ref msg refs/heads/invalid $tree_oid $ZERO_OID REF_SKIP_OID_VERIFICATION &&
        test_must_fail git fsck 2>out &&
        test_grep "not a commit" out
 '
 
-test_expect_success 'HEAD link pointing at a funny object' '
-       test_when_finished "mv .git/SAVED_HEAD .git/HEAD" &&
-       mv .git/HEAD .git/SAVED_HEAD &&
+test_expect_success REFFILES 'HEAD link pointing at a funny object' '
+       test_when_finished "git update-ref HEAD $orig_head" &&
        echo $ZERO_OID >.git/HEAD &&
        # avoid corrupt/broken HEAD from interfering with repo discovery
        test_must_fail env GIT_DIR=.git git fsck 2>out &&
@@ -131,27 +132,25 @@ test_expect_success 'HEAD link pointing at a funny object' '
 '
 
 test_expect_success 'HEAD link pointing at a funny place' '
-       test_when_finished "mv .git/SAVED_HEAD .git/HEAD" &&
-       mv .git/HEAD .git/SAVED_HEAD &&
-       echo "ref: refs/funny/place" >.git/HEAD &&
+       test_when_finished "git update-ref --no-deref HEAD $orig_head" &&
+       test-tool ref-store main create-symref HEAD refs/funny/place &&
        # avoid corrupt/broken HEAD from interfering with repo discovery
        test_must_fail env GIT_DIR=.git git fsck 2>out &&
        test_grep "HEAD points to something strange" out
 '
 
-test_expect_success 'HEAD link pointing at a funny object (from different wt)' '
-       test_when_finished "mv .git/SAVED_HEAD .git/HEAD" &&
-       test_when_finished "rm -rf .git/worktrees wt" &&
+test_expect_success REFFILES 'HEAD link pointing at a funny object (from different wt)' '
+       test_when_finished "git update-ref HEAD $orig_head" &&
+       test_when_finished "git worktree remove -f wt" &&
        git worktree add wt &&
-       mv .git/HEAD .git/SAVED_HEAD &&
        echo $ZERO_OID >.git/HEAD &&
        # avoid corrupt/broken HEAD from interfering with repo discovery
        test_must_fail git -C wt fsck 2>out &&
        test_grep "main-worktree/HEAD: detached HEAD points" out
 '
 
-test_expect_success 'other worktree HEAD link pointing at a funny object' '
-       test_when_finished "rm -rf .git/worktrees other" &&
+test_expect_success REFFILES 'other worktree HEAD link pointing at a funny object' '
+       test_when_finished "git worktree remove -f other" &&
        git worktree add other &&
        echo $ZERO_OID >.git/worktrees/other/HEAD &&
        test_must_fail git fsck 2>out &&
@@ -159,17 +158,18 @@ test_expect_success 'other worktree HEAD link pointing at a funny object' '
 '
 
 test_expect_success 'other worktree HEAD link pointing at missing object' '
-       test_when_finished "rm -rf .git/worktrees other" &&
+       test_when_finished "git worktree remove -f other" &&
        git worktree add other &&
-       echo "Contents missing from repo" | git hash-object --stdin >.git/worktrees/other/HEAD &&
+       object_id=$(echo "Contents missing from repo" | git hash-object --stdin) &&
+       test-tool -C other ref-store main update-ref msg HEAD $object_id "" REF_NO_DEREF,REF_SKIP_OID_VERIFICATION &&
        test_must_fail git fsck 2>out &&
        test_grep "worktrees/other/HEAD: invalid sha1 pointer" out
 '
 
 test_expect_success 'other worktree HEAD link pointing at a funny place' '
-       test_when_finished "rm -rf .git/worktrees other" &&
+       test_when_finished "git worktree remove -f other" &&
        git worktree add other &&
-       echo "ref: refs/funny/place" >.git/worktrees/other/HEAD &&
+       git -C other symbolic-ref HEAD refs/funny/place &&
        test_must_fail git fsck 2>out &&
        test_grep "worktrees/other/HEAD points to something strange" out
 '
@@ -391,7 +391,7 @@ test_expect_success 'tag pointing to nonexistent' '
 
        tag=$(git hash-object -t tag -w --stdin <invalid-tag) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.git/refs/tags/invalid &&
+       git update-ref refs/tags/invalid $tag &&
        test_when_finished "git update-ref -d refs/tags/invalid" &&
        test_must_fail git fsck --tags >out &&
        test_grep "broken link" out
@@ -411,7 +411,7 @@ test_expect_success 'tag pointing to something else than its type' '
 
        tag=$(git hash-object -t tag -w --stdin <wrong-tag) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.git/refs/tags/wrong &&
+       git update-ref refs/tags/wrong $tag &&
        test_when_finished "git update-ref -d refs/tags/wrong" &&
        test_must_fail git fsck --tags
 '
@@ -428,7 +428,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' '
 
        tag=$(git hash-object --literally -t tag -w --stdin <wrong-tag) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.git/refs/tags/wrong &&
+       git update-ref refs/tags/wrong $tag &&
        test_when_finished "git update-ref -d refs/tags/wrong" &&
        git fsck --tags 2>out &&
 
@@ -452,7 +452,7 @@ test_expect_success 'tag with bad tagger' '
 
        tag=$(git hash-object --literally -t tag -w --stdin <wrong-tag) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.git/refs/tags/wrong &&
+       git update-ref refs/tags/wrong $tag &&
        test_when_finished "git update-ref -d refs/tags/wrong" &&
        test_must_fail git fsck --tags 2>out &&
        test_grep "error in tag .*: invalid author/committer" out
@@ -471,7 +471,7 @@ test_expect_success 'tag with NUL in header' '
 
        tag=$(git hash-object --literally -t tag -w --stdin <tag-NUL-header) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.git/refs/tags/wrong &&
+       git update-ref refs/tags/wrong $tag &&
        test_when_finished "git update-ref -d refs/tags/wrong" &&
        test_must_fail git fsck --tags 2>out &&
        test_grep "error in tag $tag.*unterminated header: NUL at offset" out
index 3f9e7f62e458c4db06a686700a15c5e08f47fad9..a669e592f1d95ca7e0dc575697342326a7a6654f 100755 (executable)
@@ -208,6 +208,23 @@ test_expect_success 'rev-parse --show-object-format in repo' '
        grep "unknown mode for --show-object-format: squeamish-ossifrage" err
 '
 
+test_expect_success 'rev-parse --show-ref-format' '
+       test_detect_ref_format >expect &&
+       git rev-parse --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'rev-parse --show-ref-format with invalid storage' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               git config extensions.refstorage broken &&
+               test_must_fail git rev-parse --show-ref-format 2>err &&
+               grep "error: invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}broken${SQ}" err
+       )
+'
+
 test_expect_success '--show-toplevel from subdir of working tree' '
        pwd >expect &&
        git -C sub/dir rev-parse --show-toplevel >actual &&
index bc136833c1098d1c4e43d4b05cfadc7bef50b24c..79df65ec7f619baa053b2aa50d5ec08557cb820a 100755 (executable)
@@ -144,11 +144,6 @@ test_expect_success 'main@{n} for various n' '
        test_must_fail git rev-parse --verify main@{$Np1}
 '
 
-test_expect_success SYMLINKS,REFFILES 'ref resolution not confused by broken symlinks' '
-       ln -s does-not-exist .git/refs/heads/broken &&
-       test_must_fail git rev-parse --verify broken
-'
-
 test_expect_success 'options can appear after --verify' '
        git rev-parse --verify HEAD >expect &&
        git rev-parse --verify -q HEAD >actual &&
index d9997e7b6b41a19537eed0bd512be1e8c78dc3d6..04f53b1ea14cb5046ee3cf3ad70804812c6fce8a 100755 (executable)
@@ -18,12 +18,12 @@ test_expect_success 'checkout should not start branch from a tree' '
        test_must_fail git checkout -b newbranch main^{tree}
 '
 
-test_expect_success 'checkout main from invalid HEAD' '
+test_expect_success REFFILES 'checkout main from invalid HEAD' '
        echo $ZERO_OID >.git/HEAD &&
        git checkout main --
 '
 
-test_expect_success 'checkout notices failure to lock HEAD' '
+test_expect_success REFFILES 'checkout notices failure to lock HEAD' '
        test_when_finished "rm -f .git/HEAD.lock" &&
        >.git/HEAD.lock &&
        test_must_fail git checkout -b other
@@ -31,11 +31,8 @@ test_expect_success 'checkout notices failure to lock HEAD' '
 
 test_expect_success 'create ref directory/file conflict scenario' '
        git update-ref refs/heads/outer/inner main &&
-
-       # do not rely on symbolic-ref to get a known state,
-       # as it may use the same code we are testing
        reset_to_df () {
-               echo "ref: refs/heads/outer" >.git/HEAD
+               git symbolic-ref HEAD refs/heads/outer
        }
 '
 
index 747eb5563eca8f1df4374f179a08019221ba1fac..c4f9bf09aa4fd8d541a858d55cfbff34e78de1c0 100755 (executable)
@@ -38,26 +38,32 @@ test_expect_success 'git checkout -p with staged changes' '
        verify_state dir/foo index index
 '
 
-test_expect_success 'git checkout -p HEAD with NO staged changes: abort' '
-       set_and_save_state dir/foo work head &&
-       test_write_lines n y n | git checkout -p HEAD &&
-       verify_saved_state bar &&
-       verify_saved_state dir/foo
-'
-
-test_expect_success 'git checkout -p HEAD with NO staged changes: apply' '
-       test_write_lines n y y | git checkout -p HEAD &&
-       verify_saved_state bar &&
-       verify_state dir/foo head head
-'
-
-test_expect_success 'git checkout -p HEAD with change already staged' '
-       set_state dir/foo index index &&
-       # the third n is to get out in case it mistakenly does not apply
-       test_write_lines n y n | git checkout -p HEAD &&
-       verify_saved_state bar &&
-       verify_state dir/foo head head
-'
+for opt in "HEAD" "@"
+do
+       test_expect_success "git checkout -p $opt with NO staged changes: abort" '
+               set_and_save_state dir/foo work head &&
+               test_write_lines n y n | git checkout -p $opt >output &&
+               verify_saved_state bar &&
+               verify_saved_state dir/foo &&
+               test_grep "Discard" output
+       '
+
+       test_expect_success "git checkout -p $opt with NO staged changes: apply" '
+               test_write_lines n y y | git checkout -p $opt >output &&
+               verify_saved_state bar &&
+               verify_state dir/foo head head &&
+               test_grep "Discard" output
+       '
+
+       test_expect_success "git checkout -p $opt with change already staged" '
+               set_state dir/foo index index &&
+               # the third n is to get out in case it mistakenly does not apply
+               test_write_lines n y n | git checkout -p $opt >output &&
+               verify_saved_state bar &&
+               verify_state dir/foo head head &&
+               test_grep "Discard" output
+       '
+done
 
 test_expect_success 'git checkout -p HEAD^...' '
        # the third n is to get out in case it mistakenly does not apply
index 947d1587ac8be9a2ab333049a2196c4e211185e6..a5c7358eeabefb3dacc94ae94e2c61d200381ac5 100755 (executable)
@@ -86,7 +86,7 @@ test_expect_success '--orphan makes reflog by default' '
        git rev-parse --verify delta@{0}
 '
 
-test_expect_success REFFILES '--orphan does not make reflog when core.logAllRefUpdates = false' '
+test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
        git checkout main &&
        git config core.logAllRefUpdates false &&
        git checkout --orphan epsilon &&
index 8202ef8c74f639fb53a16b943fb5923ecd4e420e..bce284c2978848967ffe88764e396fad5059df54 100755 (executable)
@@ -45,6 +45,18 @@ test_expect_success 'checkout branch does not detach' '
        check_not_detached
 '
 
+for opt in "HEAD" "@"
+do
+       test_expect_success "checkout $opt no-op/don't detach" '
+               reset &&
+               cat .git/HEAD >expect &&
+               git checkout $opt &&
+               cat .git/HEAD >actual &&
+               check_not_detached &&
+               test_cmp expect actual
+       '
+done
+
 test_expect_success 'checkout tag detaches' '
        reset &&
        git checkout tag &&
index a97416ce65474df17e4133c8e14b23736ab7fc8d..a3b1449ef1166756e5bd029a2f94ac6e1c50b03b 100755 (executable)
@@ -113,7 +113,7 @@ test_expect_success 'checkout of branch from multiple remotes fails with advice'
        test_grep ! "^hint: " stderr
 '
 
-test_expect_success PERL 'checkout -p with multiple remotes does not print advice' '
+test_expect_success 'checkout -p with multiple remotes does not print advice' '
        git checkout -B main &&
        test_might_fail git branch -D foo &&
 
index e247a4735bbc26b01fecd600ed3e529bea16f464..c91c4db9361133e4e790f2c0201c5f41c14eaff1 100755 (executable)
@@ -170,8 +170,10 @@ test_expect_success 'switch back when temporarily detached and checked out elsew
        # we test in both worktrees to ensure that works
        # as expected with "first" and "next" worktrees
        test_must_fail git -C wt1 switch shared &&
+       test_must_fail git -C wt1 switch -C shared &&
        git -C wt1 switch --ignore-other-worktrees shared &&
        test_must_fail git -C wt2 switch shared &&
+       test_must_fail git -C wt2 switch -C shared &&
        git -C wt2 switch --ignore-other-worktrees shared
 '
 
index b5c5c0ff7e37ced9b6b50a06e4ec3e30c536cd53..27e85be40ad6957f9070a609d83ae334776ed855 100755 (executable)
@@ -4,7 +4,7 @@ test_description='git restore --patch'
 
 . ./lib-patch-mode.sh
 
-test_expect_success PERL 'setup' '
+test_expect_success 'setup' '
        mkdir dir &&
        echo parent >dir/foo &&
        echo dummy >bar &&
@@ -16,43 +16,47 @@ test_expect_success PERL 'setup' '
        save_head
 '
 
-test_expect_success PERL 'restore -p without pathspec is fine' '
+test_expect_success 'restore -p without pathspec is fine' '
        echo q >cmd &&
        git restore -p <cmd
 '
 
 # note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
 
-test_expect_success PERL 'saying "n" does nothing' '
+test_expect_success 'saying "n" does nothing' '
        set_and_save_state dir/foo work head &&
        test_write_lines n n | git restore -p &&
        verify_saved_state bar &&
        verify_saved_state dir/foo
 '
 
-test_expect_success PERL 'git restore -p' '
+test_expect_success 'git restore -p' '
        set_and_save_state dir/foo work head &&
        test_write_lines n y | git restore -p &&
        verify_saved_state bar &&
        verify_state dir/foo head head
 '
 
-test_expect_success PERL 'git restore -p with staged changes' '
+test_expect_success 'git restore -p with staged changes' '
        set_state dir/foo work index &&
        test_write_lines n y | git restore -p &&
        verify_saved_state bar &&
        verify_state dir/foo index index
 '
 
-test_expect_success PERL 'git restore -p --source=HEAD' '
-       set_state dir/foo work index &&
-       # the third n is to get out in case it mistakenly does not apply
-       test_write_lines n y n | git restore -p --source=HEAD &&
-       verify_saved_state bar &&
-       verify_state dir/foo head index
-'
-
-test_expect_success PERL 'git restore -p --source=HEAD^' '
+for opt in "HEAD" "@"
+do
+       test_expect_success "git restore -p --source=$opt" '
+               set_state dir/foo work index &&
+               # the third n is to get out in case it mistakenly does not apply
+               test_write_lines n y n | git restore -p --source=$opt >output &&
+               verify_saved_state bar &&
+               verify_state dir/foo head index &&
+               test_grep "Discard" output
+       '
+done
+
+test_expect_success 'git restore -p --source=HEAD^' '
        set_state dir/foo work index &&
        # the third n is to get out in case it mistakenly does not apply
        test_write_lines n y n | git restore -p --source=HEAD^ &&
@@ -60,7 +64,7 @@ test_expect_success PERL 'git restore -p --source=HEAD^' '
        verify_state dir/foo parent index
 '
 
-test_expect_success PERL 'git restore -p --source=HEAD^...' '
+test_expect_success 'git restore -p --source=HEAD^...' '
        set_state dir/foo work index &&
        # the third n is to get out in case it mistakenly does not apply
        test_write_lines n y n | git restore -p --source=HEAD^... &&
@@ -68,7 +72,7 @@ test_expect_success PERL 'git restore -p --source=HEAD^...' '
        verify_state dir/foo parent index
 '
 
-test_expect_success PERL 'git restore -p handles deletion' '
+test_expect_success 'git restore -p handles deletion' '
        set_state dir/foo work index &&
        rm dir/foo &&
        test_write_lines n y | git restore -p &&
@@ -81,21 +85,21 @@ test_expect_success PERL 'git restore -p handles deletion' '
 # dir/foo.  There's always an extra 'n' to reject edits to dir/foo in
 # the failure case (and thus get out of the loop).
 
-test_expect_success PERL 'path limiting works: dir' '
+test_expect_success 'path limiting works: dir' '
        set_state dir/foo work head &&
        test_write_lines y n | git restore -p dir &&
        verify_saved_state bar &&
        verify_state dir/foo head head
 '
 
-test_expect_success PERL 'path limiting works: -- dir' '
+test_expect_success 'path limiting works: -- dir' '
        set_state dir/foo work head &&
        test_write_lines y n | git restore -p -- dir &&
        verify_saved_state bar &&
        verify_state dir/foo head head
 '
 
-test_expect_success PERL 'path limiting works: HEAD^ -- dir' '
+test_expect_success 'path limiting works: HEAD^ -- dir' '
        set_state dir/foo work head &&
        # the third n is to get out in case it mistakenly does not apply
        test_write_lines y n n | git restore -p --source=HEAD^ -- dir &&
@@ -103,7 +107,7 @@ test_expect_success PERL 'path limiting works: HEAD^ -- dir' '
        verify_state dir/foo parent head
 '
 
-test_expect_success PERL 'path limiting works: foo inside dir' '
+test_expect_success 'path limiting works: foo inside dir' '
        set_state dir/foo work head &&
        # the third n is to get out in case it mistakenly does not apply
        test_write_lines y n n | (cd dir && git restore -p foo) &&
@@ -111,7 +115,7 @@ test_expect_success PERL 'path limiting works: foo inside dir' '
        verify_state dir/foo head head
 '
 
-test_expect_success PERL 'none of this moved HEAD' '
+test_expect_success 'none of this moved HEAD' '
        verify_saved_head
 '
 
index 4b7627e8529a5b5fd33fe5344108cee83ee22a80..c28c04133c8a1c953406c5bdea0e83c8cb82870f 100755 (executable)
@@ -126,6 +126,28 @@ test_expect_success 'die the same branch is already checked out' '
        )
 '
 
+test_expect_success 'refuse to reset a branch in use elsewhere' '
+       (
+               cd here &&
+
+               # we know we are on detached HEAD but just in case ...
+               git checkout --detach HEAD &&
+               git rev-parse --verify HEAD >old.head &&
+
+               git rev-parse --verify refs/heads/newmain >old.branch &&
+               test_must_fail git checkout -B newmain 2>error &&
+               git rev-parse --verify refs/heads/newmain >new.branch &&
+               git rev-parse --verify HEAD >new.head &&
+
+               grep "already used by worktree at" error &&
+               test_cmp old.branch new.branch &&
+               test_cmp old.head new.head &&
+
+               # and we must be still on the same detached HEAD state
+               test_must_fail git symbolic-ref HEAD
+       )
+'
+
 test_expect_success SYMLINKS 'die the same branch is already checked out (symlink)' '
        head=$(git -C there rev-parse --git-path HEAD) &&
        ref=$(git -C there symbolic-ref HEAD) &&
@@ -468,7 +490,8 @@ test_expect_success 'put a worktree under rebase' '
                cd under-rebase &&
                set_fake_editor &&
                FAKE_LINES="edit 1" git rebase -i HEAD^ &&
-               git worktree list | grep "under-rebase.*detached HEAD"
+               git worktree list >actual &&
+               grep "under-rebase.*detached HEAD" actual
        )
 '
 
@@ -509,7 +532,8 @@ test_expect_success 'checkout a branch under bisect' '
                git bisect start &&
                git bisect bad &&
                git bisect good HEAD~2 &&
-               git worktree list | grep "under-bisect.*detached HEAD" &&
+               git worktree list >actual &&
+               grep "under-bisect.*detached HEAD" actual &&
                test_must_fail git worktree add new-bisect under-bisect &&
                ! test -d new-bisect
        )
index c54fd9ea06e6cce4c11729f109718454f5132261..e36f4d15f2ddd4f64d6aaf8e087370c3b9f92ce5 100755 (executable)
@@ -28,7 +28,7 @@ test_expect_success 'git branch --help should not have created a bogus branch' '
        test_ref_missing refs/heads/--help
 '
 
-test_expect_success 'branch -h in broken repository' '
+test_expect_success REFFILES 'branch -h in broken repository' '
        mkdir broken &&
        (
                cd broken &&
@@ -76,14 +76,14 @@ test_expect_success 'git branch HEAD should fail' '
 '
 
 cat >expect <<EOF
-$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000    branch: Created from main
+$HEAD refs/heads/d/e/f@{0}: branch: Created from main
 EOF
 test_expect_success 'git branch --create-reflog d/e/f should create a branch and a log' '
        GIT_COMMITTER_DATE="2005-05-26 23:30" \
        git -c core.logallrefupdates=false branch --create-reflog d/e/f &&
        test_ref_exists refs/heads/d/e/f &&
-       test_path_is_file .git/logs/refs/heads/d/e/f &&
-       test_cmp expect .git/logs/refs/heads/d/e/f
+       git reflog show --no-abbrev-commit refs/heads/d/e/f >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
@@ -203,10 +203,9 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
        test $(git rev-parse --abbrev-ref HEAD) = bam
 '
 
-test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '
-       msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
-       grep " $ZERO_OID.*$msg$" .git/logs/HEAD &&
-       grep "^$ZERO_OID.*$msg$" .git/logs/HEAD
+test_expect_success 'git branch -M baz bam should add entries to HEAD reflog' '
+       git reflog show HEAD >actual &&
+       grep "HEAD@{0}: Branch: renamed refs/heads/baz to refs/heads/bam" actual
 '
 
 test_expect_success 'git branch -M should leave orphaned HEAD alone' '
@@ -215,17 +214,20 @@ test_expect_success 'git branch -M should leave orphaned HEAD alone' '
                cd orphan &&
                test_commit initial &&
                git checkout --orphan lonely &&
-               grep lonely .git/HEAD &&
+               git symbolic-ref HEAD >expect &&
+               echo refs/heads/lonely >actual &&
+               test_cmp expect actual &&
                test_ref_missing refs/head/lonely &&
                git branch -M main mistress &&
-               grep lonely .git/HEAD
+               git symbolic-ref HEAD >expect &&
+               test_cmp expect actual
        )
 '
 
 test_expect_success 'resulting reflog can be shown by log -g' '
        oid=$(git rev-parse HEAD) &&
        cat >expect <<-EOF &&
-       HEAD@{0} $oid $msg
+       HEAD@{0} $oid Branch: renamed refs/heads/baz to refs/heads/bam
        HEAD@{2} $oid checkout: moving from foo to baz
        EOF
        git log -g --format="%gd %H %gs" -2 HEAD >actual &&
@@ -243,7 +245,7 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
        git worktree prune
 '
 
-test_expect_success 'git branch -M fails if updating any linked working tree fails' '
+test_expect_success REFFILES 'git branch -M fails if updating any linked working tree fails' '
        git worktree add -b baz bazdir1 &&
        git worktree add -f bazdir2 baz &&
        touch .git/worktrees/bazdir1/HEAD.lock &&
@@ -517,7 +519,7 @@ EOF
 
 mv .git/config .git/config-saved
 
-test_expect_success SHA1 'git branch -m q q2 without config should succeed' '
+test_expect_success DEFAULT_REPO_FORMAT 'git branch -m q q2 without config should succeed' '
        git branch -m q q2 &&
        git branch -m q2 q
 '
@@ -699,7 +701,8 @@ test_expect_success 'git branch -C c1 c2 should succeed when c1 is checked out'
 
 test_expect_success 'git branch -C c1 c2 should never touch HEAD' '
        msg="Branch: copied refs/heads/c1 to refs/heads/c2" &&
-       ! grep "$msg$" .git/logs/HEAD
+       git reflog HEAD >actual &&
+       ! grep "$msg$" actual
 '
 
 test_expect_success 'git branch -C main should work when main is checked out' '
@@ -809,7 +812,7 @@ test_expect_success 'deleting a symref' '
 
 test_expect_success 'deleting a dangling symref' '
        git symbolic-ref refs/heads/dangling-symref nowhere &&
-       test_path_is_file .git/refs/heads/dangling-symref &&
+       git symbolic-ref --no-recurse refs/heads/dangling-symref &&
        echo "Deleted branch dangling-symref (was nowhere)." >expect &&
        git branch -d dangling-symref >actual &&
        test_ref_missing refs/heads/dangling-symref &&
@@ -833,35 +836,6 @@ test_expect_success 'renaming a symref is not allowed' '
        test_ref_missing refs/heads/new-topic
 '
 
-test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
-       git branch --create-reflog u &&
-       mv .git/logs/refs/heads/u real-u &&
-       ln -s real-u .git/logs/refs/heads/u &&
-       test_must_fail git branch -m u v
-'
-
-test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
-       test_when_finished "rm -rf subdir" &&
-       git init --bare subdir &&
-
-       rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
-       ln -s ../.git/refs subdir/refs &&
-       ln -s ../.git/objects subdir/objects &&
-       ln -s ../.git/packed-refs subdir/packed-refs &&
-
-       git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
-       git rev-parse --absolute-git-dir >our.dir &&
-       ! test_cmp subdir.dir our.dir &&
-
-       git -C subdir log &&
-       git -C subdir branch rename-src &&
-       git rev-parse rename-src >expect &&
-       git -C subdir branch -m rename-src rename-dest &&
-       git rev-parse rename-dest >actual &&
-       test_cmp expect actual &&
-       git branch -D rename-dest
-'
-
 test_expect_success 'test tracking setup via --track' '
        git config remote.local.url . &&
        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
@@ -1140,14 +1114,14 @@ test_expect_success '--set-upstream-to notices an error to set branch as own ups
 
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
-$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000    branch: Created from main
+$HEAD refs/heads/g/h/i@{0}: branch: Created from main
 EOF
 test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
        GIT_COMMITTER_DATE="2005-05-26 23:30" \
        git checkout -b g/h/i -l main &&
        test_ref_exists refs/heads/g/h/i &&
-       test_path_is_file .git/logs/refs/heads/g/h/i &&
-       test_cmp expect .git/logs/refs/heads/g/h/i
+       git reflog show --no-abbrev-commit refs/heads/g/h/i >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'checkout -b makes reflog by default' '
@@ -1573,9 +1547,10 @@ test_expect_success 'tracking with unexpected .fetch refspec' '
 
 test_expect_success 'configured committerdate sort' '
        git init -b main sort &&
+       test_config -C sort branch.sort "committerdate" &&
+
        (
                cd sort &&
-               git config branch.sort committerdate &&
                test_commit initial &&
                git checkout -b a &&
                test_commit a &&
@@ -1595,9 +1570,10 @@ test_expect_success 'configured committerdate sort' '
 '
 
 test_expect_success 'option override configured sort' '
+       test_config -C sort branch.sort "committerdate" &&
+
        (
                cd sort &&
-               git config branch.sort committerdate &&
                git branch --sort=refname >actual &&
                cat >expect <<-\EOF &&
                  a
@@ -1609,10 +1585,70 @@ test_expect_success 'option override configured sort' '
        )
 '
 
+test_expect_success '--no-sort cancels config sort keys' '
+       test_config -C sort branch.sort "-refname" &&
+
+       (
+               cd sort &&
+
+               # objecttype is identical for all of them, so sort falls back on
+               # default (ascending refname)
+               git branch \
+                       --no-sort \
+                       --sort="objecttype" >actual &&
+               cat >expect <<-\EOF &&
+                 a
+               * b
+                 c
+                 main
+               EOF
+               test_cmp expect actual
+       )
+
+'
+
+test_expect_success '--no-sort cancels command line sort keys' '
+       (
+               cd sort &&
+
+               # objecttype is identical for all of them, so sort falls back on
+               # default (ascending refname)
+               git branch \
+                       --sort="-refname" \
+                       --no-sort \
+                       --sort="objecttype" >actual &&
+               cat >expect <<-\EOF &&
+                 a
+               * b
+                 c
+                 main
+               EOF
+               test_cmp expect actual
+       )
+'
+
+test_expect_success '--no-sort without subsequent --sort prints expected branches' '
+       (
+               cd sort &&
+
+               # Sort the results with `sort` for a consistent comparison
+               # against expected
+               git branch --no-sort | sort >actual &&
+               cat >expect <<-\EOF &&
+                 a
+                 c
+                 main
+               * b
+               EOF
+               test_cmp expect actual
+       )
+'
+
 test_expect_success 'invalid sort parameter in configuration' '
+       test_config -C sort branch.sort "v:notvalid" &&
+
        (
                cd sort &&
-               git config branch.sort "v:notvalid" &&
 
                # this works in the "listing" mode, so bad sort key
                # is a dying offence.
index 6a98b2df7611ed741be197640f20e1147794aa8d..a1139f79e2ccfdff2b562571bdd8bdf8aa974883 100755 (executable)
@@ -4,9 +4,6 @@ test_description='test show-branch'
 
 . ./test-lib.sh
 
-# arbitrary reference time: 2009-08-30 19:20:00
-GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
-
 test_expect_success 'error descriptions on empty repository' '
        current=$(git branch --show-current) &&
        cat >expect <<-EOF &&
@@ -187,18 +184,6 @@ test_expect_success 'show branch --merge-base with N arguments' '
        test_cmp expect actual
 '
 
-test_expect_success 'show branch --reflog=2' '
-       sed "s/^>       //" >expect <<-\EOF &&
-       >       ! [refs/heads/branch10@{0}] (4 years, 5 months ago) commit: branch10
-       >        ! [refs/heads/branch10@{1}] (4 years, 5 months ago) commit: branch10
-       >       --
-       >       +  [refs/heads/branch10@{0}] branch10
-       >       ++ [refs/heads/branch10@{1}] initial
-       EOF
-       git show-branch --reflog=2 >actual &&
-       test_cmp actual expect
-'
-
 # incompatible options
 while read combo
 do
@@ -264,4 +249,38 @@ test_expect_success 'error descriptions on orphan branch' '
        test_branch_op_in_wt -c new-branch
 '
 
+test_expect_success 'setup reflogs' '
+       test_commit base &&
+       git checkout -b branch &&
+       test_commit one &&
+       git reset --hard HEAD^ &&
+       test_commit two &&
+       test_commit three
+'
+
+test_expect_success '--reflog shows reflog entries' '
+       cat >expect <<-\EOF &&
+       ! [branch@{0}] (0 seconds ago) commit: three
+        ! [branch@{1}] (60 seconds ago) commit: two
+         ! [branch@{2}] (2 minutes ago) reset: moving to HEAD^
+          ! [branch@{3}] (2 minutes ago) commit: one
+       ----
+       +    [branch@{0}] three
+       ++   [branch@{1}] two
+          + [branch@{3}] one
+       ++++ [branch@{2}] base
+       EOF
+       # the output always contains relative timestamps; use
+       # a known time to get deterministic results
+       GIT_TEST_DATE_NOW=$test_tick \
+       git show-branch --reflog branch >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '--reflog handles missing reflog' '
+       git reflog expire --expire=now branch &&
+       git show-branch --reflog branch >actual &&
+       test_must_be_empty actual
+'
+
 test_done
index 24a539c662f6c1f941e4f8c2949cfdc07d3cf2e5..e1c8c5f70110aacfaa778194093f2a79251e055c 100755 (executable)
@@ -424,16 +424,6 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
        test_grep "already used by worktree at" err
 '
 
-test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
-       git checkout main &&
-       mv .git/logs actual_logs &&
-       cmd //c "mklink /D .git\logs ..\actual_logs" &&
-       git rebase -f HEAD^ &&
-       test -L .git/logs &&
-       rm .git/logs &&
-       mv actual_logs .git/logs
-'
-
 test_expect_success 'rebase when inside worktree subdirectory' '
        git init main-wt &&
        (
index c5f30554c6f356742732f8979a55c872441fb159..d1bead61fad03d8a847d75062ede8ad852f7d8e6 100755 (executable)
@@ -153,6 +153,18 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
        git rebase --continue
 '
 
+test_expect_success 'cherry-pick works with rebase --exec' '
+       test_when_finished "git cherry-pick --abort; \
+                           git rebase --abort; \
+                           git checkout primary" &&
+       echo "exec git cherry-pick G" >todo &&
+       (
+               set_replace_editor todo &&
+               test_must_fail git rebase -i D D
+       ) &&
+       test_cmp_rev G CHERRY_PICK_HEAD
+'
+
 test_expect_success 'rebase -x with empty command fails' '
        test_when_finished "git rebase --abort ||:" &&
        test_must_fail env git rebase -x "" @ 2>actual &&
@@ -2160,7 +2172,7 @@ test_expect_success '--update-refs: check failed ref update' '
        # recorded in the update-refs file. We will force-update the
        # "second" ref, but "git branch -f" will not work because of
        # the lock in the update-refs file.
-       git rev-parse third >.git/refs/heads/second &&
+       git update-ref refs/heads/second third &&
 
        test_must_fail git rebase --continue 2>err &&
        grep "update_ref failed for ref '\''refs/heads/second'\''" err &&
index ebbaed147a6ce2156472f45d88a0d300ec6612ac..9f49c4228b629589d7bfcf3435fda8e7c4b308be 100755 (executable)
@@ -40,9 +40,24 @@ testrebase() {
                test_path_is_missing "$state_dir"
        '
 
+       test_expect_success "pre rebase$type head is marked as reachable" '
+               # Clean up the state from the previous one
+               git checkout -f --detach pre-rebase &&
+               test_tick &&
+               git commit --amend --only -m "reworded" &&
+               orig_head=$(git rev-parse HEAD) &&
+               test_must_fail git rebase$type main &&
+               # Stop ORIG_HEAD marking $state_dir/orig-head as reachable
+               git update-ref -d ORIG_HEAD &&
+               git reflog expire --expire="$GIT_COMMITTER_DATE" --all &&
+               git prune --expire=now &&
+               git rebase --abort &&
+               test_cmp_rev $orig_head HEAD
+       '
+
        test_expect_success "rebase$type --abort after --skip" '
                # Clean up the state from the previous one
-               git reset --hard pre-rebase &&
+               git checkout -B to-rebase pre-rebase &&
                test_must_fail git rebase$type main &&
                test_path_is_dir "$state_dir" &&
                test_must_fail git rebase --skip &&
index a364530d7629fc0bb47c30211935b878e1aa9805..fcc40d6fe1fd5b2a9c4f2a5e4ede15e73c247790 100755 (executable)
@@ -43,7 +43,7 @@ test_auto_fixup () {
 
        git tag $1 &&
        test_tick &&
-       git rebase $2 -i HEAD^^^ &&
+       git rebase $2 HEAD^^^ &&
        git log --oneline >actual &&
        if test -n "$no_squash"
        then
@@ -61,15 +61,24 @@ test_auto_fixup () {
 }
 
 test_expect_success 'auto fixup (option)' '
-       test_auto_fixup final-fixup-option --autosquash
+       test_auto_fixup fixup-option --autosquash &&
+       test_auto_fixup fixup-option-i "--autosquash -i"
 '
 
-test_expect_success 'auto fixup (config)' '
+test_expect_success 'auto fixup (config true)' '
        git config rebase.autosquash true &&
-       test_auto_fixup final-fixup-config-true &&
+       test_auto_fixup ! fixup-config-true &&
+       test_auto_fixup fixup-config-true-i -i &&
        test_auto_fixup ! fixup-config-true-no --no-autosquash &&
+       test_auto_fixup ! fixup-config-true-i-no "-i --no-autosquash"
+'
+
+test_expect_success 'auto fixup (config false)' '
        git config rebase.autosquash false &&
-       test_auto_fixup ! final-fixup-config-false
+       test_auto_fixup ! fixup-config-false &&
+       test_auto_fixup ! fixup-config-false-i -i &&
+       test_auto_fixup fixup-config-false-yes --autosquash &&
+       test_auto_fixup fixup-config-false-i-yes "-i --autosquash"
 '
 
 test_auto_squash () {
@@ -87,7 +96,7 @@ test_auto_squash () {
        git commit -m "squash! first" -m "extra para for first" &&
        git tag $1 &&
        test_tick &&
-       git rebase $2 -i HEAD^^^ &&
+       git rebase $2 HEAD^^^ &&
        git log --oneline >actual &&
        if test -n "$no_squash"
        then
@@ -105,15 +114,24 @@ test_auto_squash () {
 }
 
 test_expect_success 'auto squash (option)' '
-       test_auto_squash final-squash --autosquash
+       test_auto_squash squash-option --autosquash &&
+       test_auto_squash squash-option-i "--autosquash -i"
 '
 
-test_expect_success 'auto squash (config)' '
+test_expect_success 'auto squash (config true)' '
        git config rebase.autosquash true &&
-       test_auto_squash final-squash-config-true &&
+       test_auto_squash ! squash-config-true &&
+       test_auto_squash squash-config-true-i -i &&
        test_auto_squash ! squash-config-true-no --no-autosquash &&
+       test_auto_squash ! squash-config-true-i-no "-i --no-autosquash"
+'
+
+test_expect_success 'auto squash (config false)' '
        git config rebase.autosquash false &&
-       test_auto_squash ! final-squash-config-false
+       test_auto_squash ! squash-config-false &&
+       test_auto_squash ! squash-config-false-i -i &&
+       test_auto_squash squash-config-false-yes --autosquash &&
+       test_auto_squash squash-config-false-i-yes "-i --autosquash"
 '
 
 test_expect_success 'misspelled auto squash' '
index 693934ee8be9600e6edda9e691b5415f8c153b34..1a820f148155cbc65e2e1ad07275e25510e083b9 100755 (executable)
@@ -333,4 +333,14 @@ test_expect_success 'never change active branch' '
        test_cmp_rev not-the-feature-branch unrelated-onto-branch
 '
 
+test_expect_success 'autostash commit is marked as reachable' '
+       echo changed >file0 &&
+       git rebase --autostash --exec "git prune --expire=now" \
+               feature-branch^ feature-branch &&
+       # git rebase succeeds if the stash cannot be applied so we need to check
+       # the contents of file0
+       echo changed >expect &&
+       test_cmp expect file0
+'
+
 test_done
index 2eba00bdf5898531744c8f77429a8f4d1ad1b91d..b40f26250b7e3d8ce95b149589822bd57d84dbbe 100755 (executable)
@@ -100,12 +100,6 @@ test_rebase_am_only () {
                test_must_fail git rebase $opt --root A
        "
 
-       test_expect_success "$opt incompatible with rebase.autosquash" "
-               git checkout B^0 &&
-               test_must_fail git -c rebase.autosquash=true rebase $opt A 2>err &&
-               grep -e --no-autosquash err
-       "
-
        test_expect_success "$opt incompatible with rebase.rebaseMerges" "
                git checkout B^0 &&
                test_must_fail git -c rebase.rebaseMerges=true rebase $opt A 2>err &&
@@ -118,12 +112,6 @@ test_rebase_am_only () {
                grep -e --no-update-refs err
        "
 
-       test_expect_success "$opt okay with overridden rebase.autosquash" "
-               test_when_finished \"git reset --hard B^0\" &&
-               git checkout B^0 &&
-               git -c rebase.autosquash=true rebase --no-autosquash $opt A
-       "
-
        test_expect_success "$opt okay with overridden rebase.rebaseMerges" "
                test_when_finished \"git reset --hard B^0\" &&
                git checkout B^0 &&
diff --git a/t/t3650-replay-basics.sh b/t/t3650-replay-basics.sh
new file mode 100755 (executable)
index 0000000..3896702
--- /dev/null
@@ -0,0 +1,198 @@
+#!/bin/sh
+
+test_description='basic git replay tests'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+GIT_AUTHOR_NAME=author@name
+GIT_AUTHOR_EMAIL=bogus@email@address
+export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
+
+test_expect_success 'setup' '
+       test_commit A &&
+       test_commit B &&
+
+       git switch -c topic1 &&
+       test_commit C &&
+       git switch -c topic2 &&
+       test_commit D &&
+       test_commit E &&
+       git switch topic1 &&
+       test_commit F &&
+       git switch -c topic3 &&
+       test_commit G &&
+       test_commit H &&
+       git switch -c topic4 main &&
+       test_commit I &&
+       test_commit J &&
+
+       git switch -c next main &&
+       test_commit K &&
+       git merge -m "Merge topic1" topic1 &&
+       git merge -m "Merge topic2" topic2 &&
+       git merge -m "Merge topic3" topic3 &&
+       >evil &&
+       git add evil &&
+       git commit --amend &&
+       git merge -m "Merge topic4" topic4 &&
+
+       git switch main &&
+       test_commit L &&
+       test_commit M &&
+
+       git switch -c conflict B &&
+       test_commit C.conflict C.t conflict
+'
+
+test_expect_success 'setup bare' '
+       git clone --bare . bare
+'
+
+test_expect_success 'using replay to rebase two branches, one on top of other' '
+       git replay --onto main topic1..topic2 >result &&
+
+       test_line_count = 1 result &&
+
+       git log --format=%s $(cut -f 3 -d " " result) >actual &&
+       test_write_lines E D M L B A >expect &&
+       test_cmp expect actual &&
+
+       printf "update refs/heads/topic2 " >expect &&
+       printf "%s " $(cut -f 3 -d " " result) >>expect &&
+       git rev-parse topic2 >>expect &&
+
+       test_cmp expect result
+'
+
+test_expect_success 'using replay on bare repo to rebase two branches, one on top of other' '
+       git -C bare replay --onto main topic1..topic2 >result-bare &&
+       test_cmp expect result-bare
+'
+
+test_expect_success 'using replay to rebase with a conflict' '
+       test_expect_code 1 git replay --onto topic1 B..conflict
+'
+
+test_expect_success 'using replay on bare repo to rebase with a conflict' '
+       test_expect_code 1 git -C bare replay --onto topic1 B..conflict
+'
+
+test_expect_success 'using replay to perform basic cherry-pick' '
+       # The differences between this test and previous ones are:
+       #   --advance vs --onto
+       # 2nd field of result is refs/heads/main vs. refs/heads/topic2
+       # 4th field of result is hash for main instead of hash for topic2
+
+       git replay --advance main topic1..topic2 >result &&
+
+       test_line_count = 1 result &&
+
+       git log --format=%s $(cut -f 3 -d " " result) >actual &&
+       test_write_lines E D M L B A >expect &&
+       test_cmp expect actual &&
+
+       printf "update refs/heads/main " >expect &&
+       printf "%s " $(cut -f 3 -d " " result) >>expect &&
+       git rev-parse main >>expect &&
+
+       test_cmp expect result
+'
+
+test_expect_success 'using replay on bare repo to perform basic cherry-pick' '
+       git -C bare replay --advance main topic1..topic2 >result-bare &&
+       test_cmp expect result-bare
+'
+
+test_expect_success 'replay on bare repo fails with both --advance and --onto' '
+       test_must_fail git -C bare replay --advance main --onto main topic1..topic2 >result-bare
+'
+
+test_expect_success 'replay fails when both --advance and --onto are omitted' '
+       test_must_fail git replay topic1..topic2 >result
+'
+
+test_expect_success 'using replay to also rebase a contained branch' '
+       git replay --contained --onto main main..topic3 >result &&
+
+       test_line_count = 2 result &&
+       cut -f 3 -d " " result >new-branch-tips &&
+
+       git log --format=%s $(head -n 1 new-branch-tips) >actual &&
+       test_write_lines F C M L B A >expect &&
+       test_cmp expect actual &&
+
+       git log --format=%s $(tail -n 1 new-branch-tips) >actual &&
+       test_write_lines H G F C M L B A >expect &&
+       test_cmp expect actual &&
+
+       printf "update refs/heads/topic1 " >expect &&
+       printf "%s " $(head -n 1 new-branch-tips) >>expect &&
+       git rev-parse topic1 >>expect &&
+       printf "update refs/heads/topic3 " >>expect &&
+       printf "%s " $(tail -n 1 new-branch-tips) >>expect &&
+       git rev-parse topic3 >>expect &&
+
+       test_cmp expect result
+'
+
+test_expect_success 'using replay on bare repo to also rebase a contained branch' '
+       git -C bare replay --contained --onto main main..topic3 >result-bare &&
+       test_cmp expect result-bare
+'
+
+test_expect_success 'using replay to rebase multiple divergent branches' '
+       git replay --onto main ^topic1 topic2 topic4 >result &&
+
+       test_line_count = 2 result &&
+       cut -f 3 -d " " result >new-branch-tips &&
+
+       git log --format=%s $(head -n 1 new-branch-tips) >actual &&
+       test_write_lines E D M L B A >expect &&
+       test_cmp expect actual &&
+
+       git log --format=%s $(tail -n 1 new-branch-tips) >actual &&
+       test_write_lines J I M L B A >expect &&
+       test_cmp expect actual &&
+
+       printf "update refs/heads/topic2 " >expect &&
+       printf "%s " $(head -n 1 new-branch-tips) >>expect &&
+       git rev-parse topic2 >>expect &&
+       printf "update refs/heads/topic4 " >>expect &&
+       printf "%s " $(tail -n 1 new-branch-tips) >>expect &&
+       git rev-parse topic4 >>expect &&
+
+       test_cmp expect result
+'
+
+test_expect_success 'using replay on bare repo to rebase multiple divergent branches, including contained ones' '
+       git -C bare replay --contained --onto main ^main topic2 topic3 topic4 >result &&
+
+       test_line_count = 4 result &&
+       cut -f 3 -d " " result >new-branch-tips &&
+
+       >expect &&
+       for i in 2 1 3 4
+       do
+               printf "update refs/heads/topic$i " >>expect &&
+               printf "%s " $(grep topic$i result | cut -f 3 -d " ") >>expect &&
+               git -C bare rev-parse topic$i >>expect || return 1
+       done &&
+
+       test_cmp expect result &&
+
+       test_write_lines F C M L B A >expect1 &&
+       test_write_lines E D C M L B A >expect2 &&
+       test_write_lines H G F C M L B A >expect3 &&
+       test_write_lines J I M L B A >expect4 &&
+
+       for i in 1 2 3 4
+       do
+               git -C bare log --format=%s $(grep topic$i result | cut -f 3 -d " ") >actual &&
+               test_cmp expect$i actual || return 1
+       done
+'
+
+test_done
index 3caf490e3996ec4379e84c6adfe5505723931622..00db82fb2455b8397de6ae0e5ea8e4fd96ed3d6c 100755 (executable)
@@ -200,7 +200,7 @@ test_expect_success 'drop stash reflog updates refs/stash' '
        test_cmp expect actual
 '
 
-test_expect_success REFFILES 'drop stash reflog updates refs/stash with rewrite' '
+test_expect_success 'drop stash reflog updates refs/stash with rewrite' '
        git init repo &&
        (
                cd repo &&
@@ -213,16 +213,16 @@ test_expect_success REFFILES 'drop stash reflog updates refs/stash with rewrite'
        new_oid="$(git -C repo rev-parse stash@{0})" &&
 
        cat >expect <<-EOF &&
-       $(test_oid zero) $old_oid
-       $old_oid $new_oid
+       $new_oid
+       $old_oid
        EOF
-       cut -d" " -f1-2 repo/.git/logs/refs/stash >actual &&
+       git -C repo reflog show refs/stash --format=%H >actual &&
        test_cmp expect actual &&
 
        git -C repo stash drop stash@{1} &&
-       cut -d" " -f1-2 repo/.git/logs/refs/stash >actual &&
+       git -C repo reflog show refs/stash --format=%H >actual &&
        cat >expect <<-EOF &&
-       $(test_oid zero) $new_oid
+       $new_oid
        EOF
        test_cmp expect actual
 '
index accfe3845c418ee90d8c9b1ec3100fa3e964d8d4..368fc2a6cc16755e4e2c6e9a7fba0e88bba5a033 100755 (executable)
@@ -3,12 +3,6 @@
 test_description='stash -p'
 . ./lib-patch-mode.sh
 
-if ! test_have_prereq PERL
-then
-       skip_all='skipping stash -p tests, perl not available'
-       test_done
-fi
-
 test_expect_success 'setup' '
        mkdir dir &&
        echo parent > dir/foo &&
index 1a7e2b0bcb5e3a3024ed482c855af6acfbe41e4e..1e3b2dbea48488ecb3a68a8dba82d57b6fbca2a7 100755 (executable)
@@ -519,7 +519,7 @@ test_expect_success 'log -S requires an argument' '
 '
 
 test_expect_success 'diff --cached on unborn branch' '
-       echo ref: refs/heads/unborn >.git/HEAD &&
+       git symbolic-ref HEAD refs/heads/unborn &&
        git diff --cached >result &&
        process_diffs result >actual &&
        process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached" >expected &&
index 5ced27ed45715ce337d82261b53f1c5c8b02a551..e37a1411ee247cc76083367870e0e0c2e16fbb84 100755 (executable)
@@ -1906,6 +1906,16 @@ body" &&
        grep "^body$" actual
 '
 
+test_expect_success 'cover letter with --cover-from-description subject (UTF-8 subject line)' '
+       test_config branch.rebuild-1.description "Café?
+
+body" &&
+       git checkout rebuild-1 &&
+       git format-patch --stdout --cover-letter --cover-from-description subject --encode-email-headers main >actual &&
+       grep "^Subject: \[PATCH 0/2\] =?UTF-8?q?Caf=C3=A9=3F?=$" actual &&
+       ! grep "Café" actual
+'
+
 test_expect_success 'cover letter with format.coverFromDescription = auto (short subject line)' '
        test_config branch.rebuild-1.description "config subject
 
index bf33aedf4b22868fd820330a460965d27e66cb91..8ebfa3c1be2fec46558c739fd3ccda37a952c225 100755 (executable)
@@ -118,4 +118,26 @@ test_expect_success 'log notes cache and still use cache for -p' '
        git log --no-walk -p refs/notes/textconv/magic HEAD
 '
 
+test_expect_success 'caching is silently ignored outside repo' '
+       mkdir -p non-repo &&
+       echo one >non-repo/one &&
+       echo two >non-repo/two &&
+       echo "* diff=test" >attr &&
+       test_expect_code 1 \
+       nongit git -c core.attributesFile="$PWD/attr" \
+                  -c diff.test.textconv="tr a-z A-Z <" \
+                  -c diff.test.cachetextconv=true \
+                  diff --no-index one two >actual &&
+       cat >expect <<-\EOF &&
+       diff --git a/one b/two
+       index 5626abf..f719efd 100644
+       --- a/one
+       +++ b/two
+       @@ -1 +1 @@
+       -ONE
+       +TWO
+       EOF
+       test_cmp expect actual
+'
+
 test_done
index e7a7295f1b687d1ed916e80e431e78c4c67657b7..4eb84440298552ec53520307641419a7f6d7fd77 100755 (executable)
@@ -41,7 +41,8 @@ test_expect_success FILEMODE 'same mode (index only)' '
        chmod +x file &&
        git add file &&
        git apply --cached patch-0.txt &&
-       git ls-files -s file | grep "^100755"
+       git ls-files -s file >ls-files-output &&
+       test_grep "^100755" ls-files-output
 '
 
 test_expect_success FILEMODE 'mode update (no index)' '
@@ -60,7 +61,8 @@ test_expect_success FILEMODE 'mode update (with index)' '
 test_expect_success FILEMODE 'mode update (index only)' '
        git reset --hard &&
        git apply --cached patch-1.txt &&
-       git ls-files -s file | grep "^100755"
+       git ls-files -s file >ls-files-output &&
+       test_grep "^100755" ls-files-output
 '
 
 test_expect_success FILEMODE 'empty mode is rejected' '
@@ -101,4 +103,31 @@ test_expect_success POSIXPERM 'do not use core.sharedRepository for working tree
        )
 '
 
+test_expect_success 'git apply respects core.fileMode' '
+       test_config core.fileMode false &&
+       echo true >script.sh &&
+       git add --chmod=+x script.sh &&
+       git ls-files -s script.sh >ls-files-output &&
+       test_grep "^100755" ls-files-output &&
+       test_tick && git commit -m "Add script" &&
+       git ls-tree -r HEAD script.sh >ls-tree-output &&
+       test_grep "^100755" ls-tree-output &&
+
+       echo true >>script.sh &&
+       test_tick && git commit -m "Modify script" script.sh &&
+       git format-patch -1 --stdout >patch &&
+       test_grep "^index.*100755$" patch &&
+
+       git switch -c branch HEAD^ &&
+       git apply --index patch 2>err &&
+       test_grep ! "has type 100644, expected 100755" err &&
+       git reset --hard &&
+
+       git apply patch 2>err &&
+       test_grep ! "has type 100644, expected 100755" err &&
+
+       git apply --cached patch 2>err &&
+       test_grep ! "has type 100644, expected 100755" err
+'
+
 test_done
index 708636671a3fd1dd8b63b34335dbe4535d7c58bb..60fe60d7610e2a8141c58385b2319c7fa43a5de3 100755 (executable)
@@ -2255,23 +2255,6 @@ test_expect_success 'log on empty repo fails' '
        test_grep does.not.have.any.commits stderr
 '
 
-test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
-       git init empty &&
-       test_when_finished "rm -rf empty" &&
-       echo 1234abcd >empty/.git/refs/heads/main &&
-       test_must_fail git -C empty log 2>stderr &&
-       test_grep broken stderr
-'
-
-test_expect_success REFFILES 'log diagnoses bogus HEAD symref' '
-       git init empty &&
-       echo "ref: refs/heads/invalid.lock" > empty/.git/HEAD &&
-       test_must_fail git -C empty log 2>stderr &&
-       test_grep broken stderr &&
-       test_must_fail git -C empty log --default totally-bogus 2>stderr &&
-       test_grep broken stderr
-'
-
 test_expect_success 'log does not default to HEAD when rev input is given' '
        git log --branches=does-not-exist >actual &&
        test_must_be_empty actual
index 21986a866df65c9ed9025f7ab48dc596e6df81ca..73ea9e515503baf7776aaba04a4b6d9de7e20c92 100755 (executable)
@@ -70,8 +70,14 @@ ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A
        cmp_filtered_decorations
 '
 
+remove_replace_refs () {
+       git for-each-ref 'refs/replace*/**' --format='delete %(refname)' >in &&
+       git update-ref --stdin <in &&
+       rm in
+}
+
 test_expect_success 'test coloring with replace-objects' '
-       test_when_finished rm -rf .git/refs/replace* &&
+       test_when_finished remove_replace_refs &&
        test_commit C &&
        test_commit D &&
 
@@ -99,7 +105,7 @@ EOF
 '
 
 test_expect_success 'test coloring with grafted commit' '
-       test_when_finished rm -rf .git/refs/replace* &&
+       test_when_finished remove_replace_refs &&
 
        git replace --graft HEAD HEAD~2 &&
 
index 12ac43687366d72f2fa2870c72a9d5563a05fc66..d83c1d172dd2626578bb9b0918f6856f91d17ed4 100755 (executable)
@@ -945,4 +945,37 @@ test_expect_success 'check the input format when --stdin is passed' '
        test_cmp expect actual
 '
 
+test_expect_success '--merge-base with tree OIDs' '
+       git merge-tree --merge-base=side1^ side1 side3 >with-commits &&
+       git merge-tree --merge-base=side1^^{tree} side1^{tree} side3^{tree} >with-trees &&
+       test_cmp with-commits with-trees
+'
+
+test_expect_success 'error out on missing tree objects' '
+       git init --bare missing-tree.git &&
+       git rev-list side3 >list &&
+       git rev-parse side3^: >>list &&
+       git pack-objects missing-tree.git/objects/pack/side3-tree-is-missing <list &&
+       side3=$(git rev-parse side3) &&
+       test_must_fail git --git-dir=missing-tree.git merge-tree $side3^ $side3 >actual 2>err &&
+       test_grep "Could not read $(git rev-parse $side3:)" err &&
+       test_must_be_empty actual
+'
+
+test_expect_success 'error out on missing blob objects' '
+       echo 1 | git hash-object -w --stdin >blob1 &&
+       echo 2 | git hash-object -w --stdin >blob2 &&
+       echo 3 | git hash-object -w --stdin >blob3 &&
+       printf "100644 blob $(cat blob1)\tblob\n" | git mktree >tree1 &&
+       printf "100644 blob $(cat blob2)\tblob\n" | git mktree >tree2 &&
+       printf "100644 blob $(cat blob3)\tblob\n" | git mktree >tree3 &&
+       git init --bare missing-blob.git &&
+       cat blob1 blob3 tree1 tree2 tree3 |
+       git pack-objects missing-blob.git/objects/pack/side1-whatever-is-missing &&
+       test_must_fail git --git-dir=missing-blob.git >actual 2>err \
+               merge-tree --merge-base=$(cat tree1) $(cat tree2) $(cat tree3) &&
+       test_grep "unable to read blob object $(cat blob2)" err &&
+       test_must_be_empty actual
+'
+
 test_done
index fc499cdff01d01a6079221e78b50a7924e5ecb71..961c6aac2561354f6ad57270c1362fe73c850924 100755 (executable)
@@ -239,4 +239,38 @@ check_zip with_untracked2
 check_added with_untracked2 untracked one/untracked
 check_added with_untracked2 untracked two/untracked
 
+# Test remote archive over HTTP protocol.
+#
+# Note: this should be the last part of this test suite, because
+# by including lib-httpd.sh, the test may end early if httpd tests
+# should not be run.
+#
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success "setup for HTTP protocol" '
+       cp -R bare.git "$HTTPD_DOCUMENT_ROOT_PATH/bare.git" &&
+       git -C "$HTTPD_DOCUMENT_ROOT_PATH/bare.git" \
+               config http.uploadpack true &&
+       set_askpass user@host pass@host
+'
+
+setup_askpass_helper
+
+test_expect_success 'remote archive does not work with protocol v1' '
+       test_must_fail git -c protocol.version=1 archive \
+               --remote="$HTTPD_URL/auth/smart/bare.git" \
+               --output=remote-http.zip HEAD >actual 2>&1 &&
+       cat >expect <<-EOF &&
+       fatal: can${SQ}t connect to subservice git-upload-archive
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'archive remote http repository' '
+       git archive --remote="$HTTPD_URL/auth/smart/bare.git" \
+               --output=remote-http.zip HEAD &&
+       test_cmp_bin d.zip remote-http.zip
+'
+
 test_done
index d402ec18b795c7ab5bc1b53d5eaaa4467e37fdbb..a58f91035d124d6710438c5524c91bdbf66b4e84 100755 (executable)
@@ -441,6 +441,47 @@ test_expect_success 'index-pack with --strict' '
        )
 '
 
+test_expect_success 'setup for --strict and --fsck-objects downgrading fsck msgs' '
+       git init strict &&
+       (
+               cd strict &&
+               test_commit first hello &&
+               cat >commit <<-EOF &&
+               tree $(git rev-parse HEAD^{tree})
+               parent $(git rev-parse HEAD)
+               author A U Thor
+               committer A U Thor
+
+               commit: this is a commit with bad emails
+
+               EOF
+               git hash-object --literally -t commit -w --stdin <commit >commit_list &&
+               git pack-objects test <commit_list >pack-name
+       )
+'
+
+test_with_bad_commit () {
+       must_fail_arg="$1" &&
+       must_pass_arg="$2" &&
+       (
+               cd strict &&
+               test_expect_fail git index-pack "$must_fail_arg" "test-$(cat pack-name).pack"
+               git index-pack "$must_pass_arg" "test-$(cat pack-name).pack"
+       )
+}
+
+test_expect_success 'index-pack with --strict downgrading fsck msgs' '
+       test_with_bad_commit --strict --strict="missingEmail=ignore"
+'
+
+test_expect_success 'index-pack with --fsck-objects downgrading fsck msgs' '
+       test_with_bad_commit --fsck-objects --fsck-objects="missingEmail=ignore"
+'
+
+test_expect_success 'cleanup for --strict and --fsck-objects downgrading fsck msgs' '
+       rm -rf strict
+'
+
 test_expect_success 'honor pack.packSizeLimit' '
        git config pack.packSizeLimit 3m &&
        packname_10=$(git pack-objects test-10 <obj-list) &&
index 230cb3871223e1f28482c841093cb7a0e6873754..d8d2e304687b2a9e6d9313d0daa8a77848410f41 100755 (executable)
@@ -111,30 +111,4 @@ test_expect_success 'pack-refs does not silently delete broken loose ref' '
        test_cmp expect actual
 '
 
-# we do not want to count on running pack-refs to
-# actually pack it, as it is perfectly reasonable to
-# skip processing a broken ref
-test_expect_success REFFILES 'create packed-refs file with broken ref' '
-       rm -f .git/refs/heads/main &&
-       cat >.git/packed-refs <<-EOF &&
-       $missing refs/heads/main
-       $recoverable refs/heads/other
-       EOF
-       echo $missing >expect &&
-       git rev-parse refs/heads/main >actual &&
-       test_cmp expect actual
-'
-
-test_expect_success REFFILES 'pack-refs does not silently delete broken packed ref' '
-       git pack-refs --all --prune &&
-       git rev-parse refs/heads/main >actual &&
-       test_cmp expect actual
-'
-
-test_expect_success REFFILES  'pack-refs does not drop broken refs during deletion' '
-       git update-ref -d refs/heads/other &&
-       git rev-parse refs/heads/main >actual &&
-       test_cmp expect actual
-'
-
 test_done
index 4c751a6871db5f41e64b3e060a6d728212458bed..a2b44426609fe5c52347510e8b82c9484897dea8 100755 (executable)
@@ -540,17 +540,17 @@ test_expect_success 'detect low chunk count' '
 
 test_expect_success 'detect missing OID fanout chunk' '
        corrupt_graph_and_verify $GRAPH_BYTE_OID_FANOUT_ID "\0" \
-               "missing the OID Fanout chunk"
+               "commit-graph required OID fanout chunk missing or corrupted"
 '
 
 test_expect_success 'detect missing OID lookup chunk' '
        corrupt_graph_and_verify $GRAPH_BYTE_OID_LOOKUP_ID "\0" \
-               "missing the OID Lookup chunk"
+               "commit-graph required OID lookup chunk missing or corrupted"
 '
 
 test_expect_success 'detect missing commit data chunk' '
        corrupt_graph_and_verify $GRAPH_BYTE_COMMIT_DATA_ID "\0" \
-               "missing the Commit Data chunk"
+               "commit-graph required commit data chunk missing or corrupted"
 '
 
 test_expect_success 'detect incorrect fanout' '
@@ -560,7 +560,7 @@ test_expect_success 'detect incorrect fanout' '
 
 test_expect_success 'detect incorrect fanout final value' '
        corrupt_graph_and_verify $GRAPH_BYTE_FANOUT2 "\01" \
-               "oid table and fanout disagree on size"
+               "OID lookup chunk is the wrong size"
 '
 
 test_expect_success 'detect incorrect OID order' '
@@ -842,7 +842,7 @@ test_expect_success 'reader notices too-small oid fanout chunk' '
        check_corrupt_chunk OIDF clear $(printf "000000%02x" $(test_seq 250)) &&
        cat >expect.err <<-\EOF &&
        error: commit-graph oid fanout chunk is wrong size
-       error: commit-graph is missing the OID Fanout chunk
+       error: commit-graph required OID fanout chunk missing or corrupted
        EOF
        test_cmp expect.err err
 '
@@ -850,7 +850,8 @@ test_expect_success 'reader notices too-small oid fanout chunk' '
 test_expect_success 'reader notices fanout/lookup table mismatch' '
        check_corrupt_chunk OIDF 1020 "FFFFFFFF" &&
        cat >expect.err <<-\EOF &&
-       error: commit-graph oid table and fanout disagree on size
+       error: commit-graph OID lookup chunk is the wrong size
+       error: commit-graph required OID lookup chunk missing or corrupted
        EOF
        test_cmp expect.err err
 '
@@ -866,6 +867,7 @@ test_expect_success 'reader notices out-of-bounds fanout' '
        check_corrupt_chunk OIDF 0 $(printf "%02x000000" $(test_seq 0 254)) &&
        cat >expect.err <<-\EOF &&
        error: commit-graph fanout values out of order
+       error: commit-graph required OID fanout chunk missing or corrupted
        EOF
        test_cmp expect.err err
 '
@@ -874,7 +876,7 @@ test_expect_success 'reader notices too-small commit data chunk' '
        check_corrupt_chunk CDAT clear 00000000 &&
        cat >expect.err <<-\EOF &&
        error: commit-graph commit data chunk is wrong size
-       error: commit-graph is missing the Commit Data chunk
+       error: commit-graph required commit data chunk missing or corrupted
        EOF
        test_cmp expect.err err
 '
index c4c6060cee432ed088d4d87338a3d311204ab5c8..dd09134db03638fd01e73d89acbac45cceaa6e46 100755 (executable)
@@ -1157,4 +1157,53 @@ test_expect_success 'reader notices too-small revindex chunk' '
        test_cmp expect.err err
 '
 
+test_expect_success 'reader notices out-of-bounds fanout' '
+       # This is similar to the out-of-bounds fanout test in t5318. The values
+       # in adjacent entries should be large but not identical (they
+       # are used as hi/lo starts for a binary search, which would then abort
+       # immediately).
+       corrupt_chunk OIDF 0 $(printf "%02x000000" $(test_seq 0 254)) &&
+       test_must_fail git log 2>err &&
+       cat >expect <<-\EOF &&
+       error: oid fanout out of order: fanout[254] = fe000000 > 5c = fanout[255]
+       fatal: multi-pack-index required OID fanout chunk missing or corrupted
+       EOF
+       test_cmp expect err
+'
+
+test_expect_success 'bitmapped packs are stored via the BTMP chunk' '
+       test_when_finished "rm -fr repo" &&
+       git init repo &&
+       (
+               cd repo &&
+
+               for i in 1 2 3 4 5
+               do
+                       test_commit "$i" &&
+                       git repack -d || return 1
+               done &&
+
+               find $objdir/pack -type f -name "*.idx" | xargs -n 1 basename |
+               sort >packs &&
+
+               git multi-pack-index write --stdin-packs <packs &&
+               test_must_fail test-tool read-midx --bitmap $objdir 2>err &&
+               cat >expect <<-\EOF &&
+               error: MIDX does not contain the BTMP chunk
+               EOF
+               test_cmp expect err &&
+
+               git multi-pack-index write --stdin-packs --bitmap \
+                       --preferred-pack="$(head -n1 <packs)" <packs  &&
+               test-tool read-midx --bitmap $objdir >actual &&
+               for i in $(test_seq $(wc -l <packs))
+               do
+                       sed -ne "${i}s/\.idx$/\.pack/p" packs &&
+                       echo "  bitmap_pos: $((($i - 1) * 3))" &&
+                       echo "  bitmap_nr: 3" || return 1
+               done >expect &&
+               test_cmp expect actual
+       )
+'
+
 test_done
diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh
new file mode 100755 (executable)
index 0000000..3c20738
--- /dev/null
@@ -0,0 +1,207 @@
+#!/bin/sh
+
+test_description='pack-objects multi-pack reuse'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-bitmap.sh
+
+objdir=.git/objects
+packdir=$objdir/pack
+
+test_pack_reused () {
+       test_trace2_data pack-objects pack-reused "$1"
+}
+
+test_packs_reused () {
+       test_trace2_data pack-objects packs-reused "$1"
+}
+
+
+# pack_position <object> </path/to/pack.idx
+pack_position () {
+       git show-index >objects &&
+       grep "$1" objects | cut -d" " -f1
+}
+
+# test_pack_objects_reused_all <pack-reused> <packs-reused>
+test_pack_objects_reused_all () {
+       : >trace2.txt &&
+       GIT_TRACE2_EVENT="$PWD/trace2.txt" \
+               git pack-objects --stdout --revs --all --delta-base-offset \
+               >/dev/null &&
+
+       test_pack_reused "$1" <trace2.txt &&
+       test_packs_reused "$2" <trace2.txt
+}
+
+# test_pack_objects_reused <pack-reused> <packs-reused>
+test_pack_objects_reused () {
+       : >trace2.txt &&
+       GIT_TRACE2_EVENT="$PWD/trace2.txt" \
+               git pack-objects --stdout --revs >/dev/null &&
+
+       test_pack_reused "$1" <trace2.txt &&
+       test_packs_reused "$2" <trace2.txt
+}
+
+test_expect_success 'preferred pack is reused for single-pack reuse' '
+       test_config pack.allowPackReuse single &&
+
+       for i in A B
+       do
+               test_commit "$i" &&
+               git repack -d || return 1
+       done &&
+
+       git multi-pack-index write --bitmap &&
+
+       test_pack_objects_reused_all 3 1
+'
+
+test_expect_success 'multi-pack reuse is disabled by default' '
+       test_pack_objects_reused_all 3 1
+'
+
+test_expect_success 'feature.experimental implies multi-pack reuse' '
+       test_config feature.experimental true &&
+
+       test_pack_objects_reused_all 6 2
+'
+
+test_expect_success 'multi-pack reuse can be disabled with feature.experimental' '
+       test_config feature.experimental true &&
+       test_config pack.allowPackReuse single &&
+
+       test_pack_objects_reused_all 3 1
+'
+
+test_expect_success 'enable multi-pack reuse' '
+       git config pack.allowPackReuse multi
+'
+
+test_expect_success 'reuse all objects from subset of bitmapped packs' '
+       test_commit C &&
+       git repack -d &&
+
+       git multi-pack-index write --bitmap &&
+
+       cat >in <<-EOF &&
+       $(git rev-parse C)
+       ^$(git rev-parse A)
+       EOF
+
+       test_pack_objects_reused 6 2 <in
+'
+
+test_expect_success 'reuse all objects from all packs' '
+       test_pack_objects_reused_all 9 3
+'
+
+test_expect_success 'reuse objects from first pack with middle gap' '
+       for i in D E F
+       do
+               test_commit "$i" || return 1
+       done &&
+
+       # Set "pack.window" to zero to ensure that we do not create any
+       # deltas, which could alter the amount of pack reuse we perform
+       # (if, for e.g., we are not sending one or more bases).
+       D="$(git -c pack.window=0 pack-objects --all --unpacked $packdir/pack)" &&
+
+       d_pos="$(pack_position $(git rev-parse D) <$packdir/pack-$D.idx)" &&
+       e_pos="$(pack_position $(git rev-parse E) <$packdir/pack-$D.idx)" &&
+       f_pos="$(pack_position $(git rev-parse F) <$packdir/pack-$D.idx)" &&
+
+       # commits F, E, and D, should appear in that order at the
+       # beginning of the pack
+       test $f_pos -lt $e_pos &&
+       test $e_pos -lt $d_pos &&
+
+       # Ensure that the pack we are constructing sorts ahead of any
+       # other packs in lexical/bitmap order by choosing it as the
+       # preferred pack.
+       git multi-pack-index write --bitmap --preferred-pack="pack-$D.idx" &&
+
+       cat >in <<-EOF &&
+       $(git rev-parse E)
+       ^$(git rev-parse D)
+       EOF
+
+       test_pack_objects_reused 3 1 <in
+'
+
+test_expect_success 'reuse objects from middle pack with middle gap' '
+       rm -fr $packdir/multi-pack-index* &&
+
+       # Ensure that the pack we are constructing sort into any
+       # position *but* the first one, by choosing a different pack as
+       # the preferred one.
+       git multi-pack-index write --bitmap --preferred-pack="pack-$A.idx" &&
+
+       cat >in <<-EOF &&
+       $(git rev-parse E)
+       ^$(git rev-parse D)
+       EOF
+
+       test_pack_objects_reused 3 1 <in
+'
+
+test_expect_success 'omit delta with uninteresting base (same pack)' '
+       git repack -adk &&
+
+       test_seq 32 >f &&
+       git add f &&
+       test_tick &&
+       git commit -m "delta" &&
+       delta="$(git rev-parse HEAD)" &&
+
+       test_seq 64 >f &&
+       test_tick &&
+       git commit -a -m "base" &&
+       base="$(git rev-parse HEAD)" &&
+
+       test_commit other &&
+
+       git repack -d &&
+
+       have_delta "$(git rev-parse $delta:f)" "$(git rev-parse $base:f)" &&
+
+       git multi-pack-index write --bitmap &&
+
+       cat >in <<-EOF &&
+       $(git rev-parse other)
+       ^$base
+       EOF
+
+       # We can only reuse the 3 objects corresponding to "other" from
+       # the latest pack.
+       #
+       # This is because even though we want "delta", we do not want
+       # "base", meaning that we have to inflate the delta/base-pair
+       # corresponding to the blob in commit "delta", which bypasses
+       # the pack-reuse mechanism.
+       #
+       # The remaining objects from the other pack are similarly not
+       # reused because their objects are on the uninteresting side of
+       # the query.
+       test_pack_objects_reused 3 1 <in
+'
+
+test_expect_success 'omit delta from uninteresting base (cross pack)' '
+       cat >in <<-EOF &&
+       $(git rev-parse $base)
+       ^$(git rev-parse $delta)
+       EOF
+
+       P="$(git pack-objects --revs $packdir/pack <in)" &&
+
+       git multi-pack-index write --bitmap --preferred-pack="pack-$P.idx" &&
+
+       packs_nr="$(find $packdir -type f -name "pack-*.pack" | wc -l)" &&
+       objects_nr="$(git rev-list --count --all --objects)" &&
+
+       test_pack_objects_reused_all $(($objects_nr - 1)) $packs_nr
+'
+
+test_done
index 91e87b1dd3a5dceb8af2ab614e1d968866dc8b28..33d34d5ae9e953e29f6dba8badb16922072cd76c 100755 (executable)
@@ -169,6 +169,7 @@ test_expect_success REFFILES 'fetch --prune fails to delete branches' '
        git clone . prune-fail &&
        cd prune-fail &&
        git update-ref refs/remotes/origin/extrabranch main &&
+       git pack-refs --all &&
        : this will prevent --prune from locking packed-refs for deleting refs, but adding loose refs still succeeds  &&
        >.git/packed-refs.new &&
 
index a95841dc368329286a798982ffac30b7321e02df..25772c85c5a9a89bf247cfa41cf9d8b127572cd8 100755 (executable)
@@ -24,6 +24,15 @@ setup_repository () {
        )
 }
 
+setup_test_clone () {
+       test_dir="$1" &&
+       git clone one "$test_dir" &&
+       for r in one two three
+       do
+               git -C "$test_dir" remote add "$r" "../$r" || return 1
+       done
+}
+
 test_expect_success setup '
        setup_repository one &&
        setup_repository two &&
@@ -209,4 +218,156 @@ test_expect_success 'git fetch --multiple --jobs=0 picks a default' '
         git fetch --multiple --jobs=0)
 '
 
+create_fetch_all_expect () {
+       cat >expect <<-\EOF
+         one/main
+         one/side
+         origin/HEAD -> origin/main
+         origin/main
+         origin/side
+         three/another
+         three/main
+         three/side
+         two/another
+         two/main
+         two/side
+       EOF
+}
+
+for fetch_all in true false
+do
+       test_expect_success "git fetch --all (works with fetch.all = $fetch_all)" '
+               test_dir="test_fetch_all_$fetch_all" &&
+               setup_test_clone "$test_dir" &&
+               (
+                       cd "$test_dir" &&
+                       git config fetch.all $fetch_all &&
+                       git fetch --all &&
+                       create_fetch_all_expect &&
+                       git branch -r >actual &&
+                       test_cmp expect actual
+               )
+       '
+done
+
+test_expect_success 'git fetch (fetch all remotes with fetch.all = true)' '
+       setup_test_clone test9 &&
+       (
+               cd test9 &&
+               git config fetch.all true &&
+               git fetch &&
+               git branch -r >actual &&
+               create_fetch_all_expect &&
+               test_cmp expect actual
+       )
+'
+
+create_fetch_one_expect () {
+       cat >expect <<-\EOF
+         one/main
+         one/side
+         origin/HEAD -> origin/main
+         origin/main
+         origin/side
+       EOF
+}
+
+test_expect_success 'git fetch one (explicit remote overrides fetch.all)' '
+       setup_test_clone test10 &&
+       (
+               cd test10 &&
+               git config fetch.all true &&
+               git fetch one &&
+               create_fetch_one_expect &&
+               git branch -r >actual &&
+               test_cmp expect actual
+       )
+'
+
+create_fetch_two_as_origin_expect () {
+       cat >expect <<-\EOF
+         origin/HEAD -> origin/main
+         origin/another
+         origin/main
+         origin/side
+       EOF
+}
+
+test_expect_success 'git config fetch.all false (fetch only default remote)' '
+       setup_test_clone test11 &&
+       (
+               cd test11 &&
+               git config fetch.all false &&
+               git remote set-url origin ../two &&
+               git fetch &&
+               create_fetch_two_as_origin_expect &&
+               git branch -r >actual &&
+               test_cmp expect actual
+       )
+'
+
+for fetch_all in true false
+do
+       test_expect_success "git fetch --no-all (fetch only default remote with fetch.all = $fetch_all)" '
+               test_dir="test_no_all_fetch_all_$fetch_all" &&
+               setup_test_clone "$test_dir" &&
+               (
+                       cd "$test_dir" &&
+                       git config fetch.all $fetch_all &&
+                       git remote set-url origin ../two &&
+                       git fetch --no-all &&
+                       create_fetch_two_as_origin_expect &&
+                       git branch -r >actual &&
+                       test_cmp expect actual
+               )
+       '
+done
+
+test_expect_success 'git fetch --no-all (fetch only default remote without fetch.all)' '
+       setup_test_clone test12 &&
+       (
+               cd test12 &&
+               git config --unset-all fetch.all || true &&
+               git remote set-url origin ../two &&
+               git fetch --no-all &&
+               create_fetch_two_as_origin_expect &&
+               git branch -r >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'git fetch --all --no-all (fetch only default remote)' '
+       setup_test_clone test13 &&
+       (
+               cd test13 &&
+               git remote set-url origin ../two &&
+               git fetch --all --no-all &&
+               create_fetch_two_as_origin_expect &&
+               git branch -r >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'git fetch --no-all one (fetch only explicit remote)' '
+       setup_test_clone test14 &&
+       (
+               cd test14 &&
+               git fetch --no-all one &&
+               create_fetch_one_expect &&
+               git branch -r >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'git fetch --no-all --all (fetch all remotes)' '
+       setup_test_clone test15 &&
+       (
+               cd test15 &&
+               git fetch --no-all --all &&
+               create_fetch_all_expect &&
+               git branch -r >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done
index 26e933f93ae7f72261046495f25f63af8c31349d..5e566205ba4b95830bd97c97b0092cb4a3356304 100755 (executable)
@@ -771,7 +771,7 @@ test_expect_success 'fetching submodule into a broken repository' '
        git -C dst fetch --recurse-submodules &&
 
        # Break the receiving submodule
-       rm -f dst/sub/.git/HEAD &&
+       rm -r dst/sub/.git/objects &&
 
        # NOTE: without the fix the following tests will recurse forever!
        # They should terminate with an error.
index df758e187dfdc2fc869ad5cb747d895a145d5e91..71428f3d5c760a9bdca7524e15cb9747e92cfd17 100755 (executable)
@@ -232,8 +232,9 @@ test_expect_success 'push --atomic fails on server-side errors' '
        test_config -C "$d" http.receivepack true &&
        up="$HTTPD_URL"/smart/atomic-branches.git &&
 
-       # break ref updates for other on the remote site
-       mkdir "$d/refs/heads/other.lock" &&
+       # Create d/f conflict to break ref updates for other on the remote site.
+       git -C "$d" update-ref -d refs/heads/other &&
+       git -C "$d" update-ref refs/heads/other/conflict HEAD &&
 
        # add the new commit to other
        git branch -f other collateral &&
@@ -241,18 +242,9 @@ test_expect_success 'push --atomic fails on server-side errors' '
        # --atomic should cause entire push to be rejected
        test_must_fail git push --atomic "$up" atomic other 2>output  &&
 
-       # the new branch should not have been created upstream
-       test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
-
-       # upstream should still reflect atomic2, the last thing we pushed
-       # successfully
-       git rev-parse atomic2 >expected &&
-       # ...to other.
-       git -C "$d" rev-parse refs/heads/other >actual &&
-       test_cmp expected actual &&
-
-       # the new branch should not have been created upstream
+       # The atomic and other branches should not be created upstream.
        test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
+       test_must_fail git -C "$d" show-ref --verify refs/heads/other &&
 
        # the failed refs should be indicated to the user
        grep "^ ! .*rejected.* other -> other .*atomic transaction failed" output &&
index e444b30bf6156817fa624a9a3c9ed7127e61c3e1..4c3b32785d580fb32846306df720629aee9b3a4b 100755 (executable)
@@ -66,11 +66,11 @@ test_expect_success 'create empty remote repository' '
        setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/empty.git"
 '
 
-test_expect_success 'empty dumb HTTP repository has default hash algorithm' '
+test_expect_success 'empty dumb HTTP repository falls back to SHA1' '
        test_when_finished "rm -fr clone-empty" &&
        git clone $HTTPD_URL/dumb/empty.git clone-empty &&
        git -C clone-empty rev-parse --show-object-format >empty-format &&
-       test "$(cat empty-format)" = "$(test_oid algo)"
+       test "$(cat empty-format)" = sha1
 '
 
 setup_askpass_helper
index e069737b80b7bd906afa1963f7b818ffac8ed2ca..a623a1058cd2acddcfca4b6712dcfa41e56dbb67 100755 (executable)
@@ -733,4 +733,22 @@ test_expect_success 'no empty path components' '
        ! grep "//" log
 '
 
+test_expect_success 'tag following always works over v0 http' '
+       upstream=$HTTPD_DOCUMENT_ROOT_PATH/tags &&
+       git init "$upstream" &&
+       (
+               cd "$upstream" &&
+               git commit --allow-empty -m base &&
+               git tag not-annotated &&
+               git tag -m foo annotated
+       ) &&
+       git init tags &&
+       git -C tags -c protocol.version=0 \
+               fetch --depth 1 $HTTPD_URL/smart/tags \
+               refs/tags/annotated:refs/tags/annotated &&
+       git -C "$upstream" for-each-ref refs/tags >expect &&
+       git -C tags for-each-ref >actual &&
+       test_cmp expect actual
+'
+
 test_done
index 996a08e90c9c2c5b2c37405b1b3082e82d29a7e8..1ca5f745e73bd30deb9fc2dfa79baa10d63345bf 100755 (executable)
@@ -33,6 +33,15 @@ test_expect_success 'clone with path bundle' '
        test_cmp expect actual
 '
 
+test_expect_success 'clone with path bundle and non-default hash' '
+       test_when_finished "rm -rf clone-path-non-default-hash" &&
+       GIT_DEFAULT_HASH=sha256 git clone --bundle-uri="clone-from/B.bundle" \
+               clone-from clone-path-non-default-hash &&
+       git -C clone-path-non-default-hash rev-parse refs/bundles/topic >actual &&
+       git -C clone-from rev-parse topic >expect &&
+       test_cmp expect actual
+'
+
 test_expect_success 'clone with file:// bundle' '
        git clone --bundle-uri="file://$(pwd)/clone-from/B.bundle" \
                clone-from clone-file &&
@@ -284,6 +293,15 @@ test_expect_success 'clone HTTP bundle' '
        test_config -C clone-http log.excludedecoration refs/bundle/
 '
 
+test_expect_success 'clone HTTP bundle with non-default hash' '
+       test_when_finished "rm -rf clone-http-non-default-hash" &&
+       GIT_DEFAULT_HASH=sha256 git clone --bundle-uri="$HTTPD_URL/B.bundle" \
+               "$HTTPD_URL/smart/fetch.git" clone-http-non-default-hash &&
+       git -C clone-http-non-default-hash rev-parse refs/bundles/topic >actual &&
+       git -C clone-from rev-parse topic >expect &&
+       test_cmp expect actual
+'
+
 test_expect_success 'clone bundle list (HTTP, no heuristic)' '
        test_when_finished rm -f trace*.txt &&
 
index 47eae641f018055f2200ef6e2581d8ac60364cdb..fb1b9c686db24a30f9dbd2f6f38f29bfc4624676 100755 (executable)
@@ -157,6 +157,23 @@ test_expect_success 'clone --mirror does not repeat tags' '
 
 '
 
+test_expect_success 'clone with files ref format' '
+       test_when_finished "rm -rf ref-storage" &&
+       git clone --ref-format=files --mirror src ref-storage &&
+       echo files >expect &&
+       git -C ref-storage rev-parse --show-ref-format >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'clone with garbage ref format' '
+       cat >expect <<-EOF &&
+       fatal: unknown ref storage format ${SQ}garbage${SQ}
+       EOF
+       test_must_fail git clone --ref-format=garbage --mirror src ref-storage 2>err &&
+       test_cmp expect err &&
+       test_path_is_missing ref-storage
+'
+
 test_expect_success 'clone to destination with trailing /' '
 
        git clone src target-1/ &&
index 946c5751885671859ae309458c34106b79d67966..a3055869bc7bc182e2e4af736b06785ee28bed85 100755 (executable)
@@ -65,7 +65,7 @@ test_expect_success 'Even without -l, local will make a hardlink' '
 '
 
 test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
-       echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
+       git -C a.git symbolic-ref HEAD refs/heads/nonexistent &&
        git clone a d &&
        (cd d &&
        git fetch &&
@@ -157,7 +157,7 @@ test_expect_success 'cloning locally respects "-u" for fetching refs' '
        test_must_fail git clone --bare -u false a should_not_work.git
 '
 
-test_expect_success 'local clone from repo with corrupt refs fails gracefully' '
+test_expect_success REFFILES 'local clone from repo with corrupt refs fails gracefully' '
        git init corrupt &&
        test_commit -C corrupt one &&
        echo a >corrupt/.git/refs/heads/topic &&
index 3c0c6047d5778cb478fa7b8a4903f4457107f30e..6ef4971845fb4407977e98cb62b3468abfca5838 100755 (executable)
@@ -221,7 +221,9 @@ test_expect_success 'clone of empty repo propagates name of default branch' '
        GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
        git -c init.defaultBranch=main -c protocol.version=2 \
                clone "file://$(pwd)/file_empty_parent" file_empty_child &&
-       grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
+       echo refs/heads/mydefaultbranch >expect &&
+       git -C file_empty_child symbolic-ref HEAD >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success '...but not if explicitly forbidden by config' '
@@ -234,7 +236,9 @@ test_expect_success '...but not if explicitly forbidden by config' '
        GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
        git -c init.defaultBranch=main -c protocol.version=2 \
                clone "file://$(pwd)/file_empty_parent" file_empty_child &&
-       ! grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
+       echo refs/heads/main >expect &&
+       git -C file_empty_child symbolic-ref HEAD >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'bare clone propagates empty default branch' '
@@ -247,7 +251,9 @@ test_expect_success 'bare clone propagates empty default branch' '
        git -c init.defaultBranch=main -c protocol.version=2 \
                clone --bare \
                "file://$(pwd)/file_empty_parent" file_empty_child.git &&
-       grep "refs/heads/mydefaultbranch" file_empty_child.git/HEAD
+       echo "refs/heads/mydefaultbranch" >expect &&
+       git -C file_empty_child.git symbolic-ref HEAD >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'clone propagates unborn HEAD from non-empty repo' '
@@ -265,7 +271,9 @@ test_expect_success 'clone propagates unborn HEAD from non-empty repo' '
        git -c init.defaultBranch=main -c protocol.version=2 \
                clone "file://$(pwd)/file_unborn_parent" \
                file_unborn_child 2>stderr &&
-       grep "refs/heads/mydefaultbranch" file_unborn_child/.git/HEAD &&
+       echo "refs/heads/mydefaultbranch" >expect &&
+       git -C file_unborn_child symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
        grep "warning: remote HEAD refers to nonexistent ref" stderr
 '
 
@@ -295,7 +303,9 @@ test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' '
        git -c init.defaultBranch=main -c protocol.version=2 \
                clone --bare "file://$(pwd)/file_unborn_parent" \
                file_unborn_child.git 2>stderr &&
-       grep "refs/heads/mydefaultbranch" file_unborn_child.git/HEAD &&
+       echo "refs/heads/mydefaultbranch" >expect &&
+       git -C file_unborn_child.git symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
        ! grep "warning:" stderr
 '
 
@@ -315,7 +325,9 @@ test_expect_success 'defaulted HEAD uses remote branch if available' '
        git -c init.defaultBranch=branchwithstuff -c protocol.version=2 \
                clone "file://$(pwd)/file_unborn_parent" \
                file_unborn_child 2>stderr &&
-       grep "refs/heads/branchwithstuff" file_unborn_child/.git/HEAD &&
+       echo "refs/heads/branchwithstuff" >expect &&
+       git -C file_unborn_child symbolic-ref HEAD >actual &&
+       test_cmp expect actual &&
        test_path_is_file file_unborn_child/stuff.t &&
        ! grep "warning:" stderr
 '
index 211672759a2260e5a1bb572f96aad93b3d3f91e5..127180e1c9a246769fb5bb7ede57f814abb4fc79 100755 (executable)
@@ -10,7 +10,10 @@ TEST_PASSES_SANITIZE_LEAK=true
 test_expect_success 'create repository and alternate directory' '
        test_commit 1 &&
        test_commit 2 &&
-       test_commit 3
+       test_commit 3 &&
+       git tag -m "tag message" annot_tag HEAD~1 &&
+       git tag regul_tag HEAD~1 &&
+       git branch a_branch HEAD~1
 '
 
 # We manually corrupt the repository, which means that the commit-graph may
@@ -46,9 +49,10 @@ do
                        git rev-list --objects --no-object-names \
                                HEAD ^$obj >expect.raw &&
 
-                       # Blobs are shared by all commits, so evethough a commit/tree
+                       # Blobs are shared by all commits, so evethough a commit/tree
                        # might be skipped, its blob must be accounted for.
-                       if [ $obj != "HEAD:1.t" ]; then
+                       if test $obj != "HEAD:1.t"
+                       then
                                echo $(git rev-parse HEAD:1.t) >>expect.raw &&
                                echo $(git rev-parse HEAD:2.t) >>expect.raw
                        fi &&
@@ -77,4 +81,69 @@ do
        done
 done
 
+for missing_tip in "annot_tag" "regul_tag" "a_branch" "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
+do
+       # We want to check that things work when both
+       #   - all the tips passed are missing (case existing_tip = ""), and
+       #   - there is one missing tip and one existing tip (case existing_tip = "HEAD")
+       for existing_tip in "" "HEAD"
+       do
+               for action in "allow-any" "print"
+               do
+                       test_expect_success "--missing=$action with tip '$missing_tip' missing and tip '$existing_tip'" '
+                               # Before the object is made missing, we use rev-list to
+                               # get the expected oids.
+                               if test "$existing_tip" = "HEAD"
+                               then
+                                       git rev-list --objects --no-object-names \
+                                               HEAD ^$missing_tip >expect.raw
+                               else
+                                       >expect.raw
+                               fi &&
+
+                               # Blobs are shared by all commits, so even though a commit/tree
+                               # might be skipped, its blob must be accounted for.
+                               if test "$existing_tip" = "HEAD" && test $missing_tip != "HEAD:1.t"
+                               then
+                                       echo $(git rev-parse HEAD:1.t) >>expect.raw &&
+                                       echo $(git rev-parse HEAD:2.t) >>expect.raw
+                               fi &&
+
+                               missing_oid="$(git rev-parse $missing_tip)" &&
+
+                               if test "$missing_tip" = "annot_tag"
+                               then
+                                       oid="$(git rev-parse $missing_tip^{commit})" &&
+                                       echo "$missing_oid" >>expect.raw
+                               else
+                                       oid="$missing_oid"
+                               fi &&
+
+                               path=".git/objects/$(test_oid_to_path $oid)" &&
+
+                               mv "$path" "$path.hidden" &&
+                               test_when_finished "mv $path.hidden $path" &&
+
+                               git rev-list --missing=$action --objects --no-object-names \
+                                    $missing_oid $existing_tip >actual.raw &&
+
+                               # When the action is to print, we should also add the missing
+                               # oid to the expect list.
+                               case $action in
+                               allow-any)
+                                       ;;
+                               print)
+                                       grep ?$oid actual.raw &&
+                                       echo ?$oid >>expect.raw
+                                       ;;
+                               esac &&
+
+                               sort actual.raw >actual &&
+                               sort expect.raw >expect &&
+                               test_cmp expect actual
+                       '
+               done
+       done
+done
+
 test_done
index 7b24d1684e33aca2aa7da45375e96b217e7cd040..cdc02706404b34b17b29692d72d97fab7eba58b1 100755 (executable)
@@ -878,7 +878,7 @@ test_expect_success 'broken branch creation' '
 
 echo "" > expected.ok
 cat > expected.missing-tree.default <<EOF
-fatal: unable to read tree $deleted
+fatal: unable to read tree ($deleted)
 EOF
 
 test_expect_success 'bisect fails if tree is broken on start commit' '
@@ -1182,7 +1182,7 @@ test_expect_success 'git bisect reset cleans bisection state properly' '
        git bisect bad $HASH4 &&
        git bisect reset &&
        test -z "$(git for-each-ref "refs/bisect/*")" &&
-       test_path_is_missing ".git/BISECT_EXPECTED_REV" &&
+       test_ref_missing BISECT_EXPECTED_REV &&
        test_path_is_missing ".git/BISECT_ANCESTORS_OK" &&
        test_path_is_missing ".git/BISECT_LOG" &&
        test_path_is_missing ".git/BISECT_RUN" &&
index 86c70521f1db7184e70c1eb6baf17883ecc6609f..a9656a1ec8a6d71814a5f17157eb0e2acbd4bf98 100755 (executable)
@@ -1,9 +1,12 @@
 #!/bin/sh
 
 test_description='rev-list combining bitmaps and filters'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-bitmap.sh
 
+
 test_expect_success 'set up bitmapped repo' '
        # one commit will have bitmaps, the other will not
        test_commit one &&
index a9c1e4e0ecd0edf0269d3c1506ea1c8715c58d07..120dcd74a51434303b8bd7e71d10a9cb120bf574 100755 (executable)
@@ -64,12 +64,24 @@ test_expect_success 'setup .gitattributes' '
        fileSetLabel label
        fileValue label=foo
        fileWrongLabel label☺
+       newFileA* labelA
+       newFileB* labelB
        EOF
        echo fileSetLabel label1 >sub/.gitattributes &&
        git add .gitattributes sub/.gitattributes &&
        git commit -m "add attributes"
 '
 
+test_expect_success 'setup .gitignore' '
+       cat <<-\EOF >.gitignore &&
+       actual
+       expect
+       pathspec_file
+       EOF
+       git add .gitignore &&
+       git commit -m "add gitignore"
+'
+
 test_expect_success 'check specific set attr' '
        cat <<-\EOF >expect &&
        fileSetLabel
@@ -150,6 +162,7 @@ test_expect_success 'check specific value attr (2)' '
 test_expect_success 'check unspecified attr' '
        cat <<-\EOF >expect &&
        .gitattributes
+       .gitignore
        fileA
        fileAB
        fileAC
@@ -175,6 +188,7 @@ test_expect_success 'check unspecified attr' '
 test_expect_success 'check unspecified attr (2)' '
        cat <<-\EOF >expect &&
        HEAD:.gitattributes
+       HEAD:.gitignore
        HEAD:fileA
        HEAD:fileAB
        HEAD:fileAC
@@ -200,6 +214,7 @@ test_expect_success 'check unspecified attr (2)' '
 test_expect_success 'check multiple unspecified attr' '
        cat <<-\EOF >expect &&
        .gitattributes
+       .gitignore
        fileC
        fileNoLabel
        fileWrongLabel
@@ -239,16 +254,99 @@ test_expect_success 'fail on multiple attr specifiers in one pathspec item' '
        test_grep "Only one" actual
 '
 
-test_expect_success 'fail if attr magic is used places not implemented' '
+test_expect_success 'fail if attr magic is used in places not implemented' '
        # The main purpose of this test is to check that we actually fail
        # when you attempt to use attr magic in commands that do not implement
-       # attr magic. This test does not advocate git-add to stay that way,
-       # though, but git-add is convenient as it has its own internal pathspec
-       # parsing.
-       test_must_fail git add ":(attr:labelB)" 2>actual &&
+       # attr magic. This test does not advocate check-ignore to stay that way.
+       # When you teach the command to grok the pathspec, you need to find
+       # another command to replace it for the test.
+       test_must_fail git check-ignore ":(attr:labelB)" 2>actual &&
        test_grep "magic not supported" actual
 '
 
+test_expect_success 'check that attr magic works for git stash push' '
+       cat <<-\EOF >expect &&
+       A       sub/newFileA-foo
+       EOF
+       >sub/newFileA-foo &&
+       >sub/newFileB-foo &&
+       git stash push --include-untracked -- ":(exclude,attr:labelB)" &&
+       git stash show --include-untracked --name-status >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check that attr magic works for git add --all' '
+       cat <<-\EOF >expect &&
+       sub/newFileA-foo
+       EOF
+       >sub/newFileA-foo &&
+       >sub/newFileB-foo &&
+       git add --all ":(exclude,attr:labelB)" &&
+       git diff --name-only --cached >actual &&
+       git restore -W -S . &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check that attr magic works for git add -u' '
+       cat <<-\EOF >expect &&
+       sub/fileA
+       EOF
+       >sub/newFileA-foo &&
+       >sub/newFileB-foo &&
+       >sub/fileA &&
+       >sub/fileB &&
+       git add -u ":(exclude,attr:labelB)" &&
+       git diff --name-only --cached  >actual &&
+       git restore -S -W . && rm sub/new* &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check that attr magic works for git add <path>' '
+       cat <<-\EOF >expect &&
+       fileA
+       fileB
+       sub/fileA
+       EOF
+       >fileA &&
+       >fileB &&
+       >sub/fileA &&
+       >sub/fileB &&
+       git add ":(exclude,attr:labelB)sub/*" &&
+       git diff --name-only --cached >actual &&
+       git restore -S -W . &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check that attr magic works for git -add .' '
+       cat <<-\EOF >expect &&
+       sub/fileA
+       EOF
+       >fileA &&
+       >fileB &&
+       >sub/fileA &&
+       >sub/fileB &&
+       cd sub &&
+       git add . ":(exclude,attr:labelB)" &&
+       cd .. &&
+       git diff --name-only --cached >actual &&
+       git restore -S -W . &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check that attr magic works for git add --pathspec-from-file' '
+       cat <<-\EOF >pathspec_file &&
+       :(exclude,attr:labelB)
+       EOF
+       cat <<-\EOF >expect &&
+       sub/newFileA-foo
+       EOF
+       >sub/newFileA-foo &&
+       >sub/newFileB-foo &&
+       git add --all --pathspec-from-file=pathspec_file &&
+       git diff --name-only --cached >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'abort on giving invalid label on the command line' '
        test_must_fail git ls-files . ":(attr:☺)"
 '
@@ -295,4 +393,31 @@ test_expect_success 'reading from .gitattributes in a subdirectory (3)' '
        test_cmp expect actual
 '
 
+test_expect_success POSIXPERM 'pathspec with builtin_objectmode attr can be used' '
+       >mode_exec_file_1 &&
+
+       git status -s ":(attr:builtin_objectmode=100644)mode_exec_*" >actual &&
+       echo ?? mode_exec_file_1 >expect &&
+       test_cmp expect actual &&
+
+       git add mode_exec_file_1 &&
+       chmod +x mode_exec_file_1 &&
+       git status -s ":(attr:builtin_objectmode=100755)mode_exec_*" >actual &&
+       echo AM mode_exec_file_1 >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success POSIXPERM 'builtin_objectmode attr can be excluded' '
+       >mode_1_regular &&
+       >mode_1_exec  &&
+       chmod +x mode_1_exec &&
+       git status -s ":(exclude,attr:builtin_objectmode=100644)" "mode_1_*" >actual &&
+       echo ?? mode_1_exec >expect &&
+       test_cmp expect actual &&
+
+       git status -s ":(exclude,attr:builtin_objectmode=100755)" "mode_1_*" >actual &&
+       echo ?? mode_1_regular >expect &&
+       test_cmp expect actual
+'
+
 test_done
index c65c795fce2a58bef7989b43ca05504bdee74193..eb6c8204e8bd0edd653d74102eb92db3da720202 100755 (executable)
@@ -1335,6 +1335,73 @@ test_expect_success '--no-sort cancels the previous sort keys' '
        test_cmp expected actual
 '
 
+test_expect_success '--no-sort without subsequent --sort prints expected refs' '
+       cat >expected <<-\EOF &&
+       refs/tags/multi-ref1-100000-user1
+       refs/tags/multi-ref1-100000-user2
+       refs/tags/multi-ref1-200000-user1
+       refs/tags/multi-ref1-200000-user2
+       refs/tags/multi-ref2-100000-user1
+       refs/tags/multi-ref2-100000-user2
+       refs/tags/multi-ref2-200000-user1
+       refs/tags/multi-ref2-200000-user2
+       EOF
+
+       # Sort the results with `sort` for a consistent comparison against
+       # expected
+       git for-each-ref \
+               --format="%(refname)" \
+               --no-sort \
+               "refs/tags/multi-*" | sort >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'set up custom date sorting' '
+       # Dates:
+       # - Wed Feb 07 2024 21:34:20 +0000
+       # - Tue Dec 14 1999 00:05:22 +0000
+       # - Fri Jun 04 2021 11:26:51 +0000
+       # - Mon Jan 22 2007 16:44:01 GMT+0000
+       i=1 &&
+       for when in 1707341660 945129922 1622806011 1169484241
+       do
+               GIT_COMMITTER_DATE="@$when +0000" \
+               GIT_COMMITTER_EMAIL="user@example.com" \
+               git tag -m "tag $when" custom-dates-$i &&
+               i=$(($i+1)) || return 1
+       done
+'
+
+test_expect_success 'sort by date defaults to full timestamp' '
+       cat >expected <<-\EOF &&
+       945129922 refs/tags/custom-dates-2
+       1169484241 refs/tags/custom-dates-4
+       1622806011 refs/tags/custom-dates-3
+       1707341660 refs/tags/custom-dates-1
+       EOF
+
+       git for-each-ref \
+               --format="%(creatordate:unix) %(refname)" \
+               --sort=creatordate \
+               "refs/tags/custom-dates-*" >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'sort by custom date format' '
+       cat >expected <<-\EOF &&
+       00:05:22 refs/tags/custom-dates-2
+       11:26:51 refs/tags/custom-dates-3
+       16:44:01 refs/tags/custom-dates-4
+       21:34:20 refs/tags/custom-dates-1
+       EOF
+
+       git for-each-ref \
+               --format="%(creatordate:format:%H:%M:%S) %(refname)" \
+               --sort="creatordate:format:%H:%M:%S" \
+               "refs/tags/custom-dates-*" >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
        test_when_finished "git checkout main" &&
        git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
@@ -1818,6 +1885,28 @@ test_expect_success 'git for-each-ref with non-existing refs' '
        test_must_be_empty actual
 '
 
+test_expect_success 'git for-each-ref with nested tags' '
+       git tag -am "Normal tag" nested/base HEAD &&
+       git tag -am "Nested tag" nested/nest1 refs/tags/nested/base &&
+       git tag -am "Double nested tag" nested/nest2 refs/tags/nested/nest1 &&
+
+       head_oid="$(git rev-parse HEAD)" &&
+       base_tag_oid="$(git rev-parse refs/tags/nested/base)" &&
+       nest1_tag_oid="$(git rev-parse refs/tags/nested/nest1)" &&
+       nest2_tag_oid="$(git rev-parse refs/tags/nested/nest2)" &&
+
+       cat >expect <<-EOF &&
+       refs/tags/nested/base $base_tag_oid tag $head_oid commit
+       refs/tags/nested/nest1 $nest1_tag_oid tag $head_oid commit
+       refs/tags/nested/nest2 $nest2_tag_oid tag $head_oid commit
+       EOF
+
+       git for-each-ref \
+               --format="%(refname) %(objectname) %(objecttype) %(*objectname) %(*objecttype)" \
+               refs/tags/nested/ >actual &&
+       test_cmp expect actual
+'
+
 GRADE_FORMAT="%(signature:grade)%0a%(signature:key)%0a%(signature:signer)%0a%(signature:fingerprint)%0a%(signature:primarykeyfingerprint)"
 TRUSTLEVEL_FORMAT="%(signature:trustlevel)%0a%(signature:key)%0a%(signature:signer)%0a%(signature:fingerprint)%0a%(signature:primarykeyfingerprint)"
 
index af223e44d679571b3148d265ebb09049275cef3a..948f1bb5f44e66b80004cce1b1ac2b9ee3bd4ac9 100755 (executable)
@@ -31,6 +31,37 @@ test_expect_success 'setup some history and refs' '
        git update-ref refs/odd/spot main
 '
 
+test_expect_success '--include-root-refs pattern prints pseudorefs' '
+       cat >expect <<-\EOF &&
+       HEAD
+       ORIG_HEAD
+       refs/heads/main
+       refs/heads/side
+       refs/odd/spot
+       refs/tags/annotated-tag
+       refs/tags/doubly-annotated-tag
+       refs/tags/doubly-signed-tag
+       refs/tags/four
+       refs/tags/one
+       refs/tags/signed-tag
+       refs/tags/three
+       refs/tags/two
+       EOF
+       git update-ref ORIG_HEAD main &&
+       git for-each-ref --format="%(refname)" --include-root-refs >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '--include-root-refs with other patterns' '
+       cat >expect <<-\EOF &&
+       HEAD
+       ORIG_HEAD
+       EOF
+       git update-ref ORIG_HEAD main &&
+       git for-each-ref --format="%(refname)" --include-root-refs "*HEAD" >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'filtering with --points-at' '
        cat >expect <<-\EOF &&
        refs/heads/main
@@ -45,8 +76,8 @@ test_expect_success 'check signed tags with --points-at' '
        sed -e "s/Z$//" >expect <<-\EOF &&
        refs/heads/side Z
        refs/tags/annotated-tag four
-       refs/tags/doubly-annotated-tag An annotated tag
-       refs/tags/doubly-signed-tag A signed tag
+       refs/tags/doubly-annotated-tag four
+       refs/tags/doubly-signed-tag four
        refs/tags/four Z
        refs/tags/signed-tag four
        EOF
index 2c92209ecabf5b17477522a328e64ac0c5e62ee1..fb872c5a1136fc523dacdf6f9778b37441905980 100755 (executable)
@@ -56,7 +56,67 @@ test_expect_success 'setup' '
        deduxit me super semitas jusitiae,
        EOF
 
-       printf "propter nomen suum." >>new4.txt
+       printf "propter nomen suum." >>new4.txt &&
+
+       cat >base.c <<-\EOF &&
+       int f(int x, int y)
+       {
+               if (x == 0)
+               {
+                       return y;
+               }
+               return x;
+       }
+
+       int g(size_t u)
+       {
+               while (u < 30)
+               {
+                       u++;
+               }
+               return u;
+       }
+       EOF
+
+       cat >ours.c <<-\EOF &&
+       int g(size_t u)
+       {
+               while (u < 30)
+               {
+                       u++;
+               }
+               return u;
+       }
+
+       int h(int x, int y, int z)
+       {
+               if (z == 0)
+               {
+                       return x;
+               }
+               return y;
+       }
+       EOF
+
+       cat >theirs.c <<-\EOF
+       int f(int x, int y)
+       {
+               if (x == 0)
+               {
+                       return y;
+               }
+               return x;
+       }
+
+       int g(size_t u)
+       {
+               while (u > 34)
+               {
+                       u--;
+               }
+               return u;
+       }
+       EOF
 '
 
 test_expect_success 'merge with no changes' '
@@ -447,4 +507,66 @@ test_expect_success '--object-id fails without repository' '
        grep "not a git repository" err
 '
 
+test_expect_success 'merging C files with "myers" diff algorithm creates some spurious conflicts' '
+       cat >expect.c <<-\EOF &&
+       int g(size_t u)
+       {
+               while (u < 30)
+               {
+                       u++;
+               }
+               return u;
+       }
+
+       int h(int x, int y, int z)
+       {
+       <<<<<<< ours.c
+               if (z == 0)
+       ||||||| base.c
+               while (u < 30)
+       =======
+               while (u > 34)
+       >>>>>>> theirs.c
+               {
+       <<<<<<< ours.c
+                       return x;
+       ||||||| base.c
+                       u++;
+       =======
+                       u--;
+       >>>>>>> theirs.c
+               }
+               return y;
+       }
+       EOF
+
+       test_must_fail git merge-file -p --diff3 --diff-algorithm myers ours.c base.c theirs.c >myers_output.c &&
+       test_cmp expect.c myers_output.c
+'
+
+test_expect_success 'merging C files with "histogram" diff algorithm avoids some spurious conflicts' '
+       cat >expect.c <<-\EOF &&
+       int g(size_t u)
+       {
+               while (u > 34)
+               {
+                       u--;
+               }
+               return u;
+       }
+
+       int h(int x, int y, int z)
+       {
+               if (z == 0)
+               {
+                       return x;
+               }
+               return y;
+       }
+       EOF
+
+       git merge-file -p --diff3 --diff-algorithm histogram ours.c base.c theirs.c >histogram_output.c &&
+       test_cmp expect.c histogram_output.c
+'
+
 test_done
index 72f8c1722ff76d332529450b4115d7afb39ed5ec..156a1efacfeabcba3cff34d1044efd522183f13d 100755 (executable)
@@ -42,11 +42,15 @@ test_expect_success setup '
        #!/bin/sh
 
        orig="$1" ours="$2" theirs="$3" exit="$4" path=$5
+       orig_name="$6" our_name="$7" their_name="$8"
        (
                echo "orig is $orig"
                echo "ours is $ours"
                echo "theirs is $theirs"
                echo "path is $path"
+               echo "orig_name is $orig_name"
+               echo "our_name is $our_name"
+               echo "their_name is $their_name"
                echo "=== orig ==="
                cat "$orig"
                echo "=== ours ==="
@@ -121,7 +125,7 @@ test_expect_success 'custom merge backend' '
 
        git reset --hard anchor &&
        git config --replace-all \
-       merge.custom.driver "./custom-merge %O %A %B 0 %P" &&
+       merge.custom.driver "./custom-merge %O %A %B 0 %P %S %X %Y" &&
        git config --replace-all \
        merge.custom.name "custom merge driver for testing" &&
 
@@ -132,7 +136,8 @@ test_expect_success 'custom merge backend' '
        o=$(git unpack-file main^:text) &&
        a=$(git unpack-file side^:text) &&
        b=$(git unpack-file main:text) &&
-       sh -c "./custom-merge $o $a $b 0 text" &&
+       base_revid=$(git rev-parse --short main^) &&
+       sh -c "./custom-merge $o $a $b 0 text $base_revid HEAD main" &&
        sed -e 1,3d $a >check-2 &&
        cmp check-1 check-2 &&
        rm -f $o $a $b
@@ -142,7 +147,7 @@ test_expect_success 'custom merge backend' '
 
        git reset --hard anchor &&
        git config --replace-all \
-       merge.custom.driver "./custom-merge %O %A %B 1 %P" &&
+       merge.custom.driver "./custom-merge %O %A %B 1 %P %S %X %Y" &&
        git config --replace-all \
        merge.custom.name "custom merge driver for testing" &&
 
@@ -159,7 +164,8 @@ test_expect_success 'custom merge backend' '
        o=$(git unpack-file main^:text) &&
        a=$(git unpack-file anchor:text) &&
        b=$(git unpack-file main:text) &&
-       sh -c "./custom-merge $o $a $b 0 text" &&
+       base_revid=$(git rev-parse --short main^) &&
+       sh -c "./custom-merge $o $a $b 0 text $base_revid HEAD main" &&
        sed -e 1,3d $a >check-2 &&
        cmp check-1 check-2 &&
        sed -e 1,3d -e 4q $a >check-3 &&
@@ -173,7 +179,7 @@ test_expect_success !WINDOWS 'custom merge driver that is killed with a signal'
 
        git reset --hard anchor &&
        git config --replace-all \
-       merge.custom.driver "./custom-merge %O %A %B 0 %P" &&
+       merge.custom.driver "./custom-merge %O %A %B 0 %P %S %X %Y" &&
        git config --replace-all \
        merge.custom.name "custom merge driver for testing" &&
 
index d02fa16614e0622585a7732942ee9d5b515e6afa..0f39ed0d08a34230c7c42f307992c20cc8b06d02 100755 (executable)
@@ -71,8 +71,9 @@ test_expect_success 'caching renames does not preclude finding new ones' '
 
                git switch upstream &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream~1..topic
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                git ls-files >tracked-files &&
                test_line_count = 2 tracked-files &&
@@ -140,8 +141,9 @@ test_expect_success 'cherry-pick both a commit and its immediate revert' '
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream~1..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                grep region_enter.*diffcore_rename trace.output >calls &&
                test_line_count = 1 calls
@@ -199,8 +201,9 @@ test_expect_success 'rename same file identically, then reintroduce it' '
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream~1..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                git ls-files >tracked &&
                test_line_count = 2 tracked &&
@@ -276,8 +279,9 @@ test_expect_success 'rename same file identically, then add file to old dir' '
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream~1..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                git ls-files >tracked &&
                test_line_count = 4 tracked &&
@@ -353,10 +357,7 @@ test_expect_success 'cached dir rename does not prevent noticing later conflict'
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test_must_fail test-tool fast-rebase --onto HEAD upstream~1 topic >output &&
-               #git cherry-pick upstream..topic &&
-
-               grep CONFLICT..rename/rename output &&
+               test_must_fail git replay --onto HEAD upstream~1..topic >output &&
 
                grep region_enter.*diffcore_rename trace.output >calls &&
                test_line_count = 2 calls
@@ -455,8 +456,9 @@ test_expect_success 'dir rename unneeded, then add new file to old dir' '
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                grep region_enter.*diffcore_rename trace.output >calls &&
                test_line_count = 2 calls &&
@@ -521,8 +523,9 @@ test_expect_success 'dir rename unneeded, then rename existing file into old dir
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                grep region_enter.*diffcore_rename trace.output >calls &&
                test_line_count = 3 calls &&
@@ -623,8 +626,9 @@ test_expect_success 'caching renames only on upstream side, part 1' '
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                grep region_enter.*diffcore_rename trace.output >calls &&
                test_line_count = 1 calls &&
@@ -681,8 +685,9 @@ test_expect_success 'caching renames only on upstream side, part 2' '
                GIT_TRACE2_PERF="$(pwd)/trace.output" &&
                export GIT_TRACE2_PERF &&
 
-               test-tool fast-rebase --onto HEAD upstream~1 topic &&
-               #git cherry-pick upstream..topic &&
+               git replay --onto HEAD upstream~1..topic >out &&
+               git update-ref --stdin <out &&
+               git checkout topic &&
 
                grep region_enter.*diffcore_rename trace.output >calls &&
                test_line_count = 2 calls &&
index 70650521b042b29b41ddf7b0ee794095063e457f..7a3f1cb27c12b468cb8a97e80c75a86070c7c4a8 100755 (executable)
@@ -113,7 +113,7 @@ test_expect_success 'merging should conflict for non fast-forward' '
         git checkout -b test-nonforward-a b &&
          if test "$GIT_TEST_MERGE_ALGORITHM" = ort
          then
-               test_must_fail git merge c >actual &&
+               test_must_fail git merge c 2>actual &&
                sub_expect="go to submodule (sub), and either merge commit $(git -C sub rev-parse --short sub-c)" &&
                grep "$sub_expect" actual
          else
@@ -154,9 +154,9 @@ test_expect_success 'merging should conflict for non fast-forward (resolution ex
          git rev-parse --short sub-d > ../expect) &&
          if test "$GIT_TEST_MERGE_ALGORITHM" = ort
          then
-               test_must_fail git merge c >actual &&
+               test_must_fail git merge c >actual 2>sub-actual &&
                sub_expect="go to submodule (sub), and either merge commit $(git -C sub rev-parse --short sub-c)" &&
-               grep "$sub_expect" actual
+               grep "$sub_expect" sub-actual
          else
                test_must_fail git merge c 2> actual
          fi &&
@@ -181,9 +181,9 @@ test_expect_success 'merging should fail for ambiguous common parent' '
         ) &&
         if test "$GIT_TEST_MERGE_ALGORITHM" = ort
         then
-               test_must_fail git merge c >actual &&
+               test_must_fail git merge c >actual 2>sub-actual &&
                sub_expect="go to submodule (sub), and either merge commit $(git -C sub rev-parse --short sub-c)" &&
-               grep "$sub_expect" actual
+               grep "$sub_expect" sub-actual
         else
                test_must_fail git merge c 2> actual
         fi &&
@@ -227,7 +227,7 @@ test_expect_success 'merging should fail for changes that are backwards' '
        git commit -a -m "f" &&
 
        git checkout -b test-backward e &&
-       test_must_fail git merge f >actual &&
+       test_must_fail git merge f 2>actual &&
        if test "$GIT_TEST_MERGE_ALGORITHM" = ort
     then
                sub_expect="go to submodule (sub), and either merge commit $(git -C sub rev-parse --short sub-d)" &&
@@ -535,7 +535,7 @@ test_expect_success 'merging should fail with no merge base' '
        git checkout -b b init &&
        git add sub &&
        git commit -m "b" &&
-       test_must_fail git merge a >actual &&
+       test_must_fail git merge a 2>actual &&
        if test "$GIT_TEST_MERGE_ALGORITHM" = ort
     then
                sub_expect="go to submodule (sub), and either merge commit $(git -C sub rev-parse --short HEAD^1)" &&
index f6aebe92ff9d94b20670f7436c57f8107bb3404a..5ab4d41ee7c6b122b8601bf8059eecafdf081c39 100755 (executable)
@@ -396,10 +396,7 @@ test_expect_success '--prune-empty is able to prune entire branch' '
        git branch prune-entire B &&
        git filter-branch -f --prune-empty --index-filter "git update-index --remove A.t B.t" prune-entire &&
        test_must_fail git rev-parse refs/heads/prune-entire &&
-       if test_have_prereq REFFILES
-       then
-               test_must_fail git reflog exists refs/heads/prune-entire
-       fi
+       test_must_fail git reflog exists refs/heads/prune-entire
 '
 
 test_expect_success '--remap-to-ancestor with filename filters' '
index e689db429292e60162d4f8f89905cc8489d7a3e0..b41a47eb943a03b1588bdc87802b0645944ce2ec 100755 (executable)
@@ -1862,6 +1862,51 @@ test_expect_success 'option override configured sort' '
        test_cmp expect actual
 '
 
+test_expect_success '--no-sort cancels config sort keys' '
+       test_config tag.sort "-refname" &&
+
+       # objecttype is identical for all of them, so sort falls back on
+       # default (ascending refname)
+       git tag -l \
+               --no-sort \
+               --sort="objecttype" \
+               "foo*" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.10
+       foo1.3
+       foo1.6
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success '--no-sort cancels command line sort keys' '
+       # objecttype is identical for all of them, so sort falls back on
+       # default (ascending refname)
+       git tag -l \
+               --sort="-refname" \
+               --no-sort \
+               --sort="objecttype" \
+               "foo*" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.10
+       foo1.3
+       foo1.6
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success '--no-sort without subsequent --sort prints expected tags' '
+       # Sort the results with `sort` for a consistent comparison against
+       # expected
+       git tag -l --no-sort "foo*" | sort >actual &&
+       cat >expect <<-\EOF &&
+       foo1.10
+       foo1.3
+       foo1.6
+       EOF
+       test_cmp expect actual
+'
+
 test_expect_success 'invalid sort parameter on command line' '
        test_must_fail git tag -l --sort=notvalid "foo*" >actual
 '
index 05079c7246482cb5a50bf1579914ef810e309cd7..f4f3b7a677aa16539f8277ce3d4132ade0b17168 100755 (executable)
@@ -5,7 +5,7 @@ test_description='git reset --patch'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./lib-patch-mode.sh
 
-test_expect_success PERL 'setup' '
+test_expect_success 'setup' '
        mkdir dir &&
        echo parent > dir/foo &&
        echo dummy > bar &&
@@ -19,42 +19,46 @@ test_expect_success PERL 'setup' '
 
 # note: bar sorts before foo, so the first 'n' is always to skip 'bar'
 
-test_expect_success PERL 'saying "n" does nothing' '
+test_expect_success 'saying "n" does nothing' '
        set_and_save_state dir/foo work work &&
        test_write_lines n n | git reset -p &&
        verify_saved_state dir/foo &&
        verify_saved_state bar
 '
 
-test_expect_success PERL 'git reset -p' '
-       test_write_lines n y | git reset -p >output &&
-       verify_state dir/foo work head &&
-       verify_saved_state bar &&
-       test_grep "Unstage" output
-'
-
-test_expect_success PERL 'git reset -p HEAD^' '
+for opt in "HEAD" "@" ""
+do
+       test_expect_success "git reset -p $opt" '
+               set_and_save_state dir/foo work work &&
+               test_write_lines n y | git reset -p $opt >output &&
+               verify_state dir/foo work head &&
+               verify_saved_state bar &&
+               test_grep "Unstage" output
+       '
+done
+
+test_expect_success 'git reset -p HEAD^' '
        test_write_lines n y | git reset -p HEAD^ >output &&
        verify_state dir/foo work parent &&
        verify_saved_state bar &&
        test_grep "Apply" output
 '
 
-test_expect_success PERL 'git reset -p HEAD^^{tree}' '
+test_expect_success 'git reset -p HEAD^^{tree}' '
        test_write_lines n y | git reset -p HEAD^^{tree} >output &&
        verify_state dir/foo work parent &&
        verify_saved_state bar &&
        test_grep "Apply" output
 '
 
-test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' '
+test_expect_success 'git reset -p HEAD^:dir/foo (blob fails)' '
        set_and_save_state dir/foo work work &&
        test_must_fail git reset -p HEAD^:dir/foo &&
        verify_saved_state dir/foo &&
        verify_saved_state bar
 '
 
-test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '
+test_expect_success 'git reset -p aaaaaaaa (unknown fails)' '
        set_and_save_state dir/foo work work &&
        test_must_fail git reset -p aaaaaaaa &&
        verify_saved_state dir/foo &&
@@ -66,27 +70,27 @@ test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '
 # dir/foo.  There's always an extra 'n' to reject edits to dir/foo in
 # the failure case (and thus get out of the loop).
 
-test_expect_success PERL 'git reset -p dir' '
+test_expect_success 'git reset -p dir' '
        set_state dir/foo work work &&
        test_write_lines y n | git reset -p dir &&
        verify_state dir/foo work head &&
        verify_saved_state bar
 '
 
-test_expect_success PERL 'git reset -p -- foo (inside dir)' '
+test_expect_success 'git reset -p -- foo (inside dir)' '
        set_state dir/foo work work &&
        test_write_lines y n | (cd dir && git reset -p -- foo) &&
        verify_state dir/foo work head &&
        verify_saved_state bar
 '
 
-test_expect_success PERL 'git reset -p HEAD^ -- dir' '
+test_expect_success 'git reset -p HEAD^ -- dir' '
        test_write_lines y n | git reset -p HEAD^ -- dir &&
        verify_state dir/foo work parent &&
        verify_saved_state bar
 '
 
-test_expect_success PERL 'none of this moved HEAD' '
+test_expect_success 'none of this moved HEAD' '
        verify_saved_head
 '
 
index d20e5709f91cd7b1a0107bf4ee1df6809001bd30..88d1c8adf42eec1c219f50b9765d5b3c10d706fa 100755 (executable)
@@ -34,7 +34,7 @@ test_expect_success 'reset $file' '
        test_cmp expect actual
 '
 
-test_expect_success PERL 'reset -p' '
+test_expect_success 'reset -p' '
        rm .git/index &&
        git add a &&
        echo y >yes &&
index 1a310a45fd35765167c8f2c06ea85dca8cab9749..611b3dd3aedb44c9b5d4657f3058c72a60258cb0 100755 (executable)
@@ -517,8 +517,12 @@ test_expect_success 'nested (empty) git should be kept' '
        git init empty_repo &&
        mkdir to_clean &&
        >to_clean/should_clean.this &&
+       # Note that we put the expect file in the .git directory so that it
+       # does not get cleaned.
+       find empty_repo | sort >.git/expect &&
        git clean -f -d &&
-       test_path_is_file empty_repo/.git/HEAD &&
+       find empty_repo | sort >actual &&
+       test_cmp .git/expect actual &&
        test_path_is_missing to_clean
 '
 
@@ -559,10 +563,10 @@ test_expect_success 'giving path in nested git work tree will NOT remove it' '
                mkdir -p bar/baz &&
                test_commit msg bar/baz/hello.world
        ) &&
+       find repo | sort >expect &&
        git clean -f -d repo/bar/baz &&
-       test_path_is_file repo/.git/HEAD &&
-       test_path_is_dir repo/bar/ &&
-       test_path_is_file repo/bar/baz/hello.world
+       find repo | sort >actual &&
+       test_cmp expect actual
 '
 
 test_expect_success 'giving path to nested .git will not remove it' '
@@ -573,10 +577,10 @@ test_expect_success 'giving path to nested .git will not remove it' '
                git init &&
                test_commit msg hello.world
        ) &&
+       find repo | sort >expect &&
        git clean -f -d repo/.git &&
-       test_path_is_file repo/.git/HEAD &&
-       test_path_is_dir repo/.git/refs &&
-       test_path_is_dir repo/.git/objects &&
+       find repo | sort >actual &&
+       test_cmp expect actual &&
        test_path_is_dir untracked/
 '
 
@@ -588,9 +592,10 @@ test_expect_success 'giving path to nested .git/ will NOT remove contents' '
                git init &&
                test_commit msg hello.world
        ) &&
+       find repo | sort >expect &&
        git clean -f -d repo/.git/ &&
-       test_path_is_dir repo/.git &&
-       test_path_is_file repo/.git/HEAD &&
+       find repo | sort >actual &&
+       test_cmp expect actual &&
        test_path_is_dir untracked/
 '
 
index 2b3c363078bc06219c8b5c16b02f331b447f5102..aa2fdc31d1a672cb229457b05adcce90bd204aa6 100755 (executable)
@@ -116,7 +116,7 @@ test_expect_success 'rebasing submodule that should conflict' '
        test_tick &&
        git commit -m fourth &&
 
-       test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 >actual_output &&
+       test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 2>actual_output &&
        git ls-files -s submodule >actual &&
        (
                cd submodule &&
index 35a31acd4d7e26bc3bf8f42853d80593488c9227..46d4fb0354b13d585260587d78d27d1e9c545f1c 100755 (executable)
@@ -45,6 +45,32 @@ test_expect_success 'check names' '
        test_cmp expect actual
 '
 
+test_expect_success 'check urls' '
+       cat >expect <<-\EOF &&
+       ./bar/baz/foo.git
+       https://example.com/foo.git
+       http://example.com:80/deeper/foo.git
+       EOF
+
+       test-tool submodule check-url >actual <<-\EOF &&
+       ./bar/baz/foo.git
+       https://example.com/foo.git
+       http://example.com:80/deeper/foo.git
+       -a./foo
+       ../../..//test/foo.git
+       ../../../../../:localhost:8080/foo.git
+       ..\../.\../:example.com/foo.git
+       ./%0ahost=example.com/foo.git
+       https://one.example.com/evil?%0ahost=two.example.com
+       https:///example.com/foo.git
+       http://example.com:test/foo.git
+       https::example.com/foo.git
+       http:::example.com/foo.git
+       EOF
+
+       test_cmp expect actual
+'
+
 test_expect_success 'create innocent subrepo' '
        git init innocent &&
        git -C innocent commit --allow-empty -m foo
index 3d8500a52e50c004544c6df62cf123b8aeb62a99..bced44a0fc915f430ccc41d54fbd8bc48df2cef8 100755 (executable)
@@ -3,8 +3,7 @@
 # Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
 #
 
-# FIXME: Test the various index usages, -i and -o, test reflog,
-# signoff
+# FIXME: Test the various index usages, test reflog
 
 test_description='git commit'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
@@ -92,6 +91,34 @@ test_expect_success '--long fails with nothing to commit' '
        test_must_fail git commit -m initial --long
 '
 
+test_expect_success 'fail to commit untracked file (even with --include/--only)' '
+       echo content >baz &&
+       error="error: pathspec .baz. did not match any file(s) known to git" &&
+
+       test_must_fail git commit -m "baz" baz 2>err &&
+       test_grep -e "$error" err &&
+
+       test_must_fail git commit --only -m "baz" baz 2>err &&
+       test_grep -e "$error" err &&
+
+       # TODO: as for --include, the below command will fail because
+       # nothing is staged. If something was staged, it would not fail
+       # even though the provided pathspec does not match any tracked
+       # path. (However, the untracked paths that match the pathspec are
+       # not committed and only the staged changes get committed.)
+       # In either cases, no error is returned to stderr like in (--only
+       # and without --only/--include) cases. In a similar manner,
+       # "git add -u baz" also does not error out.
+       #
+       # Therefore, the below test is just to document the current behavior
+       # and is not an endorsement to the current behavior, and we may
+       # want to fix this. And when that happens, this test should be
+       # updated accordingly.
+
+       test_must_fail git commit --include -m "baz" baz 2>err &&
+       test_must_be_empty err
+'
+
 test_expect_success 'setup: non-initial commit' '
        echo bongo bongo bongo >file &&
        git commit -m next -a
@@ -117,6 +144,51 @@ test_expect_success '--long with stuff to commit returns ok' '
        git commit -m next -a --long
 '
 
+for opt in "" "-o" "--only"
+do
+       test_expect_success 'exclude additional staged changes when given pathspec' '
+               echo content >>file &&
+               echo content >>baz &&
+               git add baz &&
+               git commit $opt -m "file" file &&
+
+               git diff --name-only >actual &&
+               test_must_be_empty actual &&
+
+               test_write_lines baz >expect &&
+               git diff --name-only --cached >actual &&
+               test_cmp expect actual &&
+
+               test_write_lines file >expect &&
+               git diff --name-only HEAD^ HEAD >actual &&
+               test_cmp expect actual
+       '
+done
+
+test_expect_success '-i/--include includes staged changes' '
+       echo content >>file &&
+       echo content >>baz &&
+       git add file &&
+
+       # baz is in the index, therefore, it will be committed
+       git commit --include -m "file and baz" baz  &&
+
+       git diff --name-only HEAD >remaining &&
+       test_must_be_empty remaining &&
+
+       test_write_lines baz file >expect &&
+       git diff --name-only HEAD^ HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '--include and --only do not mix' '
+       test_when_finished "git reset --hard" &&
+       echo content >>file &&
+       echo content >>baz &&
+       test_must_fail git commit --include --only -m "file baz" file baz 2>actual &&
+       test_grep -e "fatal: options .-i/--include. and .-o/--only. cannot be used together" actual
+'
+
 test_expect_success 'commit message from non-existing file' '
        echo more bongo: bongo bongo bongo bongo >file &&
        test_must_fail git commit -F gah -a
@@ -389,6 +461,28 @@ test_expect_success 'amend commit to fix date' '
 
 '
 
+test_expect_success 'amend commit to add signoff' '
+
+       test_commit "msg" file content &&
+       git commit --amend --signoff &&
+       test_commit_message HEAD <<-EOF
+       msg
+
+       Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+       EOF
+'
+
+test_expect_success 'amend does not add signoff if it already exists' '
+
+       test_commit --signoff "tenor" file newcontent &&
+       git commit --amend --signoff &&
+       test_commit_message HEAD <<-EOF
+       tenor
+
+       Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+       EOF
+'
+
 test_expect_success 'commit mentions forced date in output' '
        git commit --amend --date=2010-01-02T03:04:05 >output &&
        grep "Date: *Sat Jan 2 03:04:05 2010" output
index 998a2103c7440f00788ec4c0ef607f8c48781660..b4de10a5ddac0a2a890adaeb559f1b2afea15bb3 100755 (executable)
@@ -3,12 +3,6 @@
 test_description='hunk edit with "commit -p -m"'
 . ./test-lib.sh
 
-if ! test_have_prereq PERL
-then
-       skip_all="skipping '$test_description' tests, perl not available"
-       test_done
-fi
-
 test_expect_success 'setup (initial)' '
        echo line1 >file &&
        git add file &&
index 78503158fd699d2df75e8fbbbaf164a129f2578b..363f9dc0e41b2686aa9892d5e21e153ca54727b9 100755 (executable)
@@ -978,7 +978,7 @@ test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '
        mkdir test_unicode/nfd &&
        mkdir test_unicode/nfd/d_${utf8_nfd} &&
 
-       git -C test_unicode fsmonitor--daemon stop &&
+       test-tool -C test_unicode fsmonitor-client query --token 0 &&
 
        if test_have_prereq UNICODE_NFC_PRESERVED
        then
index 6a36be1e63c2bb84871e521349917be30ec6b3e3..96ae5d5880d6a597d0c553c4535081c2e51356df 100755 (executable)
@@ -91,58 +91,67 @@ test_expect_success 'difftool forwards arguments to diff' '
        rm for-diff
 '
 
-test_expect_success 'difftool ignores exit code' '
-       test_config difftool.error.cmd false &&
-       git difftool -y -t error branch
-'
+for opt in '' '--dir-diff'
+do
+       test_expect_success "difftool ${opt} ignores exit code" "
+               test_config difftool.error.cmd false &&
+               git difftool ${opt} -y -t error branch
+       "
 
-test_expect_success 'difftool forwards exit code with --trust-exit-code' '
-       test_config difftool.error.cmd false &&
-       test_must_fail git difftool -y --trust-exit-code -t error branch
-'
+       test_expect_success "difftool ${opt} forwards exit code with --trust-exit-code" "
+               test_config difftool.error.cmd false &&
+               test_must_fail git difftool ${opt} -y --trust-exit-code -t error branch
+       "
 
-test_expect_success 'difftool forwards exit code with --trust-exit-code for built-ins' '
-       test_config difftool.vimdiff.path false &&
-       test_must_fail git difftool -y --trust-exit-code -t vimdiff branch
-'
+       test_expect_success "difftool ${opt} forwards exit code with --trust-exit-code for built-ins" "
+               test_config difftool.vimdiff.path false &&
+               test_must_fail git difftool ${opt} -y --trust-exit-code -t vimdiff branch
+       "
 
-test_expect_success 'difftool honors difftool.trustExitCode = true' '
-       test_config difftool.error.cmd false &&
-       test_config difftool.trustExitCode true &&
-       test_must_fail git difftool -y -t error branch
-'
+       test_expect_success "difftool ${opt} honors difftool.trustExitCode = true" "
+               test_config difftool.error.cmd false &&
+               test_config difftool.trustExitCode true &&
+               test_must_fail git difftool ${opt} -y -t error branch
+       "
 
-test_expect_success 'difftool honors difftool.trustExitCode = false' '
-       test_config difftool.error.cmd false &&
-       test_config difftool.trustExitCode false &&
-       git difftool -y -t error branch
-'
+       test_expect_success "difftool ${opt} honors difftool.trustExitCode = false" "
+               test_config difftool.error.cmd false &&
+               test_config difftool.trustExitCode false &&
+               git difftool ${opt} -y -t error branch
+       "
 
-test_expect_success 'difftool ignores exit code with --no-trust-exit-code' '
-       test_config difftool.error.cmd false &&
-       test_config difftool.trustExitCode true &&
-       git difftool -y --no-trust-exit-code -t error branch
-'
+       test_expect_success "difftool ${opt} ignores exit code with --no-trust-exit-code" "
+               test_config difftool.error.cmd false &&
+               test_config difftool.trustExitCode true &&
+               git difftool ${opt} -y --no-trust-exit-code -t error branch
+       "
 
-test_expect_success 'difftool stops on error with --trust-exit-code' '
-       test_when_finished "rm -f for-diff .git/fail-right-file" &&
-       test_when_finished "git reset -- for-diff" &&
-       write_script .git/fail-right-file <<-\EOF &&
-       echo failed
-       exit 1
-       EOF
-       >for-diff &&
-       git add for-diff &&
-       test_must_fail git difftool -y --trust-exit-code \
-               --extcmd .git/fail-right-file branch >actual &&
-       test_line_count = 1 actual
-'
+       test_expect_success "difftool ${opt} stops on error with --trust-exit-code" "
+               test_when_finished 'rm -f for-diff .git/fail-right-file' &&
+               test_when_finished 'git reset -- for-diff' &&
+               write_script .git/fail-right-file <<-\EOF &&
+               echo failed
+               exit 1
+               EOF
+               >for-diff &&
+               git add for-diff &&
+               test_must_fail git difftool ${opt} -y --trust-exit-code \
+                       --extcmd .git/fail-right-file branch >actual &&
+               test_line_count = 1 actual
+       "
 
-test_expect_success 'difftool honors exit status if command not found' '
-       test_config difftool.nonexistent.cmd i-dont-exist &&
-       test_config difftool.trustExitCode false &&
-       test_must_fail git difftool -y -t nonexistent branch
-'
+       test_expect_success "difftool ${opt} honors exit status if command not found" "
+               test_config difftool.nonexistent.cmd i-dont-exist &&
+               test_config difftool.trustExitCode false &&
+               if test "${opt}" = '--dir-diff'
+               then
+                       expected_code=127
+               else
+                       expected_code=128
+               fi &&
+               test_expect_code \${expected_code} git difftool ${opt} -y -t nonexistent branch
+       "
+done
 
 test_expect_success 'difftool honors --gui' '
        difftool_test_setup &&
index 935df6a1dbb00e486e217c26f518b6e8e862a78c..0943dfa18a3f97b7e351346d089efdd878f6ca68 100755 (executable)
@@ -67,6 +67,51 @@ test_expect_success 'maintenance.auto config option' '
        test_subcommand ! git maintenance run --auto --quiet  <false
 '
 
+test_expect_success 'register uses XDG_CONFIG_HOME config if it exists' '
+       test_when_finished rm -r .config/git/config &&
+       (
+               XDG_CONFIG_HOME=.config &&
+               export XDG_CONFIG_HOME &&
+               mkdir -p $XDG_CONFIG_HOME/git &&
+               >$XDG_CONFIG_HOME/git/config &&
+               git maintenance register &&
+               git config --file=$XDG_CONFIG_HOME/git/config --get maintenance.repo >actual &&
+               pwd >expect &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'register does not need XDG_CONFIG_HOME config to exist' '
+       test_when_finished git maintenance unregister &&
+       test_path_is_missing $XDG_CONFIG_HOME/git/config &&
+       git maintenance register &&
+       git config --global --get maintenance.repo >actual &&
+       pwd >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'unregister uses XDG_CONFIG_HOME config if it exists' '
+       test_when_finished rm -r .config/git/config &&
+       (
+               XDG_CONFIG_HOME=.config &&
+               export XDG_CONFIG_HOME &&
+               mkdir -p $XDG_CONFIG_HOME/git &&
+               >$XDG_CONFIG_HOME/git/config &&
+               git maintenance register &&
+               git maintenance unregister &&
+               test_must_fail git config --file=$XDG_CONFIG_HOME/git/config --get maintenance.repo >actual &&
+               test_must_be_empty actual
+       )
+'
+
+test_expect_success 'unregister does not need XDG_CONFIG_HOME config to exist' '
+       test_path_is_missing $XDG_CONFIG_HOME/git/config &&
+       git maintenance register &&
+       git maintenance unregister &&
+       test_must_fail git config --global --get maintenance.repo >actual &&
+       test_must_be_empty actual
+'
+
 test_expect_success 'maintenance.<task>.enabled' '
        git config maintenance.gc.enabled false &&
        git config maintenance.commit-graph.enabled true &&
@@ -157,7 +202,8 @@ test_expect_success 'prefetch multiple remotes' '
        fetchargs="--prefetch --prune --no-tags --no-write-fetch-head --recurse-submodules=no --quiet" &&
        test_subcommand git fetch remote1 $fetchargs <run-prefetch.txt &&
        test_subcommand git fetch remote2 $fetchargs <run-prefetch.txt &&
-       test_path_is_missing .git/refs/remotes &&
+       git for-each-ref refs/remotes >actual &&
+       test_must_be_empty actual &&
        git log prefetch/remotes/remote1/one &&
        git log prefetch/remotes/remote2/two &&
        git fetch --all &&
index 348cc40658235239c7e68671738cd030871451ad..d5b98e615bca6647761e0e6f046d474ea8275015 100755 (executable)
@@ -196,4 +196,15 @@ EOF
        test_cmp expected actual
 '
 
+test_expect_success 'padding must be non-negative' '
+       cat >input <<\EOF &&
+1 2 3 4 5 6
+EOF
+       cat >expected <<\EOF &&
+fatal: --padding must be non-negative
+EOF
+       test_must_fail git column --mode=column --padding=-1 <input >actual 2>&1 &&
+       test_cmp expected actual
+'
+
 test_done
index d8d536269cf73d64d9d2df593667c17c826479c5..8ca24670acb5a9280a163b11682e9a0dd52eaaa5 100755 (executable)
@@ -11,7 +11,7 @@ test_expect_success 'setup repo with a git repo inside it' '
        (
                cd s &&
                git init &&
-               test -f .git/HEAD &&
+               git symbolic-ref HEAD &&
                > .git/a &&
                echo a > a &&
                svn_cmd add .git a &&
index 09606f1b3cfeb4244de4fbc12e4e96ddb7fd7de5..926ac8143943c91493eb9be0e42ca365fae56971 100755 (executable)
@@ -20,11 +20,7 @@ test_expect_success 'empty directories exist' '
                cd cloned &&
                for i in a b c d d/e d/e/f "weird file name"
                do
-                       if ! test -d "$i"
-                       then
-                               echo >&2 "$i does not exist" &&
-                               exit 1
-                       fi
+                       test_path_is_dir "$i" || exit 1
                done
        )
 '
@@ -37,11 +33,7 @@ test_expect_success 'option automkdirs set to false' '
                git svn fetch &&
                for i in a b c d d/e d/e/f "weird file name"
                do
-                       if test -d "$i"
-                       then
-                               echo >&2 "$i exists" &&
-                               exit 1
-                       fi
+                       test_path_is_missing "$i" || exit 1
                done
        )
 '
@@ -52,7 +44,7 @@ test_expect_success 'more emptiness' '
 
 test_expect_success 'git svn rebase creates empty directory' '
        ( cd cloned && git svn rebase ) &&
-       test -d cloned/"! !"
+       test_path_is_dir cloned/"! !"
 '
 
 test_expect_success 'git svn mkdirs recreates empty directories' '
@@ -62,11 +54,7 @@ test_expect_success 'git svn mkdirs recreates empty directories' '
                git svn mkdirs &&
                for i in a b c d d/e d/e/f "weird file name" "! !"
                do
-                       if ! test -d "$i"
-                       then
-                               echo >&2 "$i does not exist" &&
-                               exit 1
-                       fi
+                       test_path_is_dir "$i" || exit 1
                done
        )
 '
@@ -78,25 +66,13 @@ test_expect_success 'git svn mkdirs -r works' '
                git svn mkdirs -r7 &&
                for i in a b c d d/e d/e/f "weird file name"
                do
-                       if ! test -d "$i"
-                       then
-                               echo >&2 "$i does not exist" &&
-                               exit 1
-                       fi
+                       test_path_is_dir "$i" || exit 1
                done &&
 
-               if test -d "! !"
-               then
-                       echo >&2 "$i should not exist" &&
-                       exit 1
-               fi &&
+               test_path_is_missing "! !" || exit 1 &&
 
                git svn mkdirs -r8 &&
-               if ! test -d "! !"
-               then
-                       echo >&2 "$i not exist" &&
-                       exit 1
-               fi
+               test_path_is_dir "! !" || exit 1
        )
 '
 
@@ -114,11 +90,7 @@ test_expect_success 'empty directories in trunk exist' '
                cd trunk &&
                for i in a "weird file name"
                do
-                       if ! test -d "$i"
-                       then
-                               echo >&2 "$i does not exist" &&
-                               exit 1
-                       fi
+                       test_path_is_dir "$i" || exit 1
                done
        )
 '
@@ -129,7 +101,7 @@ test_expect_success 'remove a top-level directory from svn' '
 
 test_expect_success 'removed top-level directory does not exist' '
        git svn clone "$svnrepo" removed &&
-       test ! -e removed/d
+       test_path_is_missing removed/d
 
 '
 unhandled=.git/svn/refs/remotes/git-svn/unhandled.log
@@ -143,15 +115,11 @@ test_expect_success 'git svn gc-ed files work' '
                        svn_cmd mkdir -m gz "$svnrepo"/gz &&
                        git reset --hard $(git rev-list HEAD | tail -1) &&
                        git svn rebase &&
-                       test -f "$unhandled".gz &&
-                       test -f "$unhandled" &&
+                       test_path_is_file "$unhandled".gz &&
+                       test_path_is_file "$unhandled" &&
                        for i in a b c "weird file name" gz "! !"
                        do
-                               if ! test -d "$i"
-                               then
-                                       echo >&2 "$i does not exist" &&
-                                       exit 1
-                               fi
+                               test_path_is_dir "$i" || exit 1
                        done
                fi
        )
index c8e6c0733f41cf90a41941a3ad3550efb7ea56f1..d1dec89c3b7f6c46f18a2838c3d8cdba640146ea 100755 (executable)
@@ -46,6 +46,14 @@ setup_hook()
                        "passed to setup_hook" >&2 ; return 1; }
        echo "cnt=$skip_revs" > "$hook_type-counter"
        rm -f "$rawsvnrepo/hooks/"*-commit # drop previous hooks
+
+       # Subversion hooks run with an empty environment by default. We thus
+       # need to propagate PATH so that we can find executables.
+       cat >"$rawsvnrepo/conf/hooks-env" <<-EOF
+       [default]
+       PATH = ${PATH}
+       EOF
+
        hook="$rawsvnrepo/hooks/$hook_type"
        cat > "$hook" <<- 'EOF1'
                #!/bin/sh
@@ -63,7 +71,6 @@ EOF1
        if [ "$hook_type" = "pre-commit" ]; then
                echo "echo 'commit disallowed' >&2; exit 1" >>"$hook"
        else
-               echo "PATH=\"$PATH\"; export PATH" >>"$hook"
                echo "svnconf=\"$svnconf\"" >>"$hook"
                cat >>"$hook" <<- 'EOF2'
                        cd work-auto-commits.svn
index 4432a30d10b69a168ca477f222bfa52d36447006..428339e342751e02e3c9fe5b8053c0ccc6fee4b8 100755 (executable)
@@ -154,7 +154,14 @@ test_expect_success 'scalar clone' '
                test_cmp expect actual &&
 
                test_path_is_missing 1/2 &&
-               test_must_fail git rev-list --missing=print $second &&
+
+               # This relies on the fact that the presence of "--missing"
+               # on the command line forces lazy fetching off before
+               # "$second^{blob}" gets parsed.  Without "^{blob}", a
+               # bare object name "$second" is taken into the queue and
+               # the command may not fail with a fixed "rev-list --missing".
+               test_must_fail git rev-list --missing=print "$second^{blob}" -- &&
+
                git rev-list $second &&
                git cat-file blob $second >actual &&
                echo "second" >expect &&
index 0333065d4d60a0113cb5ac1de391a4a997d2eaa8..7679780fb87b4f14e9c0f5a22708b1e8925a4d53 100755 (executable)
@@ -627,6 +627,7 @@ test_expect_success \
 test_expect_success 'setup' '
        version=$(git config core.repositoryformatversion) &&
        algo=$(test_might_fail git config extensions.objectformat) &&
+       refstorage=$(test_might_fail git config extensions.refstorage) &&
        cat >.git/config <<-\EOF &&
        # testing noval and alternate separator
        [gitweb]
@@ -637,6 +638,10 @@ test_expect_success 'setup' '
        if test -n "$algo"
        then
                git config extensions.objectformat "$algo"
+       fi &&
+       if test -n "$refstorage"
+       then
+               git config extensions.refstorage "$refstorage"
        fi
 '
 
index a7c3b4eb63abfe251dcb9edc4b14b136dcfc91c6..b16c284181b8707ed21c85efa0e0a0fea128faae 100755 (executable)
@@ -5,6 +5,17 @@
 
 test_description='test bash completion'
 
+# The Bash completion scripts must not print anything to either stdout or
+# stderr, which we try to verify. When tracing is enabled without support for
+# BASH_XTRACEFD this assertion will fail, so we have to mark the test as
+# untraceable with such ancient Bash versions.
+test_untraceable=UnfortunatelyYes
+
+# Override environment and always use master for the default initial branch
+# name for these tests, so that rev completion candidates are as expected.
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 . ./lib-bash.sh
 
 complete ()
@@ -87,9 +98,11 @@ test_completion ()
        else
                sed -e 's/Z$//' |sort >expected
        fi &&
-       run_completion "$1" &&
+       run_completion "$1" >"$TRASH_DIRECTORY"/bash-completion-output 2>&1 &&
        sort out >out_sorted &&
-       test_cmp expected out_sorted
+       test_cmp expected out_sorted &&
+       test_must_be_empty "$TRASH_DIRECTORY"/bash-completion-output &&
+       rm "$TRASH_DIRECTORY"/bash-completion-output
 }
 
 # Test __gitcomp.
@@ -1259,6 +1272,142 @@ test_expect_success 'git switch - with no options, complete local branches and u
        EOF
 '
 
+test_expect_success 'git bisect - when not bisecting, complete only replay and start subcommands' '
+       test_completion "git bisect " <<-\EOF
+       replay Z
+       start Z
+       EOF
+'
+
+test_expect_success 'git bisect - complete options to start subcommand' '
+       test_completion "git bisect start --" <<-\EOF
+       --term-new Z
+       --term-bad Z
+       --term-old Z
+       --term-good Z
+       --no-checkout Z
+       --first-parent Z
+       EOF
+'
+
+test_expect_success 'setup for git-bisect tests requiring a repo' '
+       git init git-bisect &&
+       (
+               cd git-bisect &&
+               echo "initial contents" >file &&
+               git add file &&
+               git commit -am "Initial commit" &&
+               git tag initial &&
+               echo "new line" >>file &&
+               git commit -am "First change" &&
+               echo "another new line" >>file &&
+               git commit -am "Second change" &&
+               git tag final
+       )
+'
+
+test_expect_success 'git bisect - start subcommand arguments before double-dash are completed as revs' '
+       (
+               cd git-bisect &&
+               test_completion "git bisect start " <<-\EOF
+               HEAD Z
+               final Z
+               initial Z
+               master Z
+               EOF
+       )
+'
+
+# Note that these arguments are <pathspec>s, which in practice the fallback
+# completion (not the git completion) later ends up completing as paths.
+test_expect_success 'git bisect - start subcommand arguments after double-dash are not completed' '
+       (
+               cd git-bisect &&
+               test_completion "git bisect start final initial -- " ""
+       )
+'
+
+test_expect_success 'setup for git-bisect tests requiring ongoing bisection' '
+       (
+               cd git-bisect &&
+               git bisect start --term-new=custom_new --term-old=custom_old final initial
+       )
+'
+
+test_expect_success 'git-bisect - when bisecting all subcommands are candidates' '
+       (
+               cd git-bisect &&
+               test_completion "git bisect " <<-\EOF
+               start Z
+               bad Z
+               custom_new Z
+               custom_old Z
+               new Z
+               good Z
+               old Z
+               terms Z
+               skip Z
+               reset Z
+               visualize Z
+               replay Z
+               log Z
+               run Z
+               help Z
+               EOF
+       )
+'
+
+test_expect_success 'git-bisect - options to terms subcommand are candidates' '
+       (
+               cd git-bisect &&
+               test_completion "git bisect terms --" <<-\EOF
+               --term-bad Z
+               --term-good Z
+               --term-new Z
+               --term-old Z
+               EOF
+       )
+'
+
+test_expect_success 'git-bisect - git-log options to visualize subcommand are candidates' '
+       (
+               cd git-bisect &&
+               # The completion used for git-log and here does not complete
+               # every git-log option, so rather than hope to stay in sync
+               # with exactly what it does we will just spot-test here.
+               test_completion "git bisect visualize --sta" <<-\EOF &&
+               --stat Z
+               EOF
+               test_completion "git bisect visualize --summar" <<-\EOF
+               --summary Z
+               EOF
+       )
+'
+
+test_expect_success 'git-bisect - view subcommand is not a candidate' '
+       (
+               cd git-bisect &&
+               test_completion "git bisect vi" <<-\EOF
+               visualize Z
+               EOF
+       )
+'
+
+test_expect_success 'git-bisect - existing view subcommand is recognized and enables completion of git-log options' '
+       (
+               cd git-bisect &&
+               # The completion used for git-log and here does not complete
+               # every git-log option, so rather than hope to stay in sync
+               # with exactly what it does we will just spot-test here.
+               test_completion "git bisect view --sta" <<-\EOF &&
+               --stat Z
+               EOF
+               test_completion "git bisect view --summar" <<-\EOF
+               --summary Z
+               EOF
+       )
+'
+
 test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
        test_completion "git checkout " <<-\EOF
        HEAD Z
@@ -1571,7 +1720,7 @@ test_expect_success FUNNYNAMES,!CYGWIN 'cone mode sparse-checkout completes dire
        )
 '
 
-test_expect_success 'non-cone mode sparse-checkout uses bash completion' '
+test_expect_success 'non-cone mode sparse-checkout gives rooted paths' '
        # reset sparse-checkout repo to non-cone mode
        git -C sparse-checkout sparse-checkout disable &&
        git -C sparse-checkout sparse-checkout set --no-cone &&
@@ -1581,7 +1730,12 @@ test_expect_success 'non-cone mode sparse-checkout uses bash completion' '
                # expected to be empty since we have not configured
                # custom completion for non-cone mode
                test_completion "git sparse-checkout set f" <<-\EOF
-
+               /folder1/0/1/t.txt Z
+               /folder1/expected Z
+               /folder1/out Z
+               /folder1/out_sorted Z
+               /folder2/0/t.txt Z
+               /folder3/t.txt Z
                EOF
        )
 '
@@ -1920,6 +2074,14 @@ test_expect_success 'git checkout - --orphan with branch already provided comple
        EOF
 '
 
+test_expect_success 'git restore completes modified files' '
+       test_commit A a.file &&
+       echo B >a.file &&
+       test_completion "git restore a." <<-\EOF
+       a.file
+       EOF
+'
+
 test_expect_success 'teardown after ref completion' '
        git branch -d matching-branch &&
        git tag -d matching-tag &&
@@ -2562,6 +2724,35 @@ test_expect_success 'git config - variable name include' '
        EOF
 '
 
+test_expect_success 'setup for git config submodule tests' '
+       test_create_repo sub &&
+       test_commit -C sub initial &&
+       git submodule add ./sub
+'
+
+test_expect_success 'git config - variable name - submodule and __git_compute_first_level_config_vars_for_section' '
+       test_completion "git config submodule." <<-\EOF
+       submodule.active Z
+       submodule.alternateErrorStrategy Z
+       submodule.alternateLocation Z
+       submodule.fetchJobs Z
+       submodule.propagateBranches Z
+       submodule.recurse Z
+       submodule.sub.Z
+       EOF
+'
+
+test_expect_success 'git config - variable name - __git_compute_second_level_config_vars_for_section' '
+       test_completion "git config submodule.sub." <<-\EOF
+       submodule.sub.url Z
+       submodule.sub.update Z
+       submodule.sub.branch Z
+       submodule.sub.fetchRecurseSubmodules Z
+       submodule.sub.ignore Z
+       submodule.sub.active Z
+       EOF
+'
+
 test_expect_success 'git config - value' '
        test_completion "git config color.pager " <<-\EOF
        false Z
@@ -2715,4 +2906,31 @@ test_expect_success '__git_complete' '
        test_must_fail __git_complete ga missing
 '
 
+test_expect_success '__git_pseudoref_exists' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               sane_unset __git_repo_path &&
+
+               # HEAD should exist, even if it points to an unborn branch.
+               __git_pseudoref_exists HEAD >output 2>&1 &&
+               test_must_be_empty output &&
+
+               # HEAD points to an existing branch, so it should exist.
+               test_commit A &&
+               __git_pseudoref_exists HEAD >output 2>&1 &&
+               test_must_be_empty output &&
+
+               # CHERRY_PICK_HEAD does not exist, so the existence check should fail.
+               ! __git_pseudoref_exists CHERRY_PICK_HEAD >output 2>&1 &&
+               test_must_be_empty output &&
+
+               # CHERRY_PICK_HEAD points to a commit, so it should exist.
+               git update-ref CHERRY_PICK_HEAD A &&
+               __git_pseudoref_exists CHERRY_PICK_HEAD >output 2>&1 &&
+               test_must_be_empty output
+       )
+'
+
 test_done
index 5eb57914abc493b6cb261b676b27d935f1b919ae..b5eaf7fdc1186d4420388c355e794bfdba783f2f 100644 (file)
@@ -1659,6 +1659,11 @@ test_detect_hash () {
        test_hash_algo="${GIT_TEST_DEFAULT_HASH:-sha1}"
 }
 
+# Detect the hash algorithm in use.
+test_detect_ref_format () {
+       echo "${GIT_TEST_DEFAULT_REF_FORMAT:-files}"
+}
+
 # Load common hash metadata and common placeholder object IDs for use with
 # test_oid.
 test_oid_init () {
@@ -1874,6 +1879,20 @@ test_region () {
        return 0
 }
 
+# Check that the given data fragment was included as part of the
+# trace2-format trace on stdin.
+#
+#      test_trace2_data <category> <key> <value>
+#
+# For example, to look for trace2_data_intmax("pack-objects", repo,
+# "reused", N) in an invocation of "git pack-objects", run:
+#
+#      GIT_TRACE2_EVENT="$(pwd)/trace.txt" git pack-objects ... &&
+#      test_trace2_data pack-objects reused N <trace2.txt
+test_trace2_data () {
+       grep -e '"category":"'"$1"'","key":"'"$2"'","value":"'"$3"'"'
+}
+
 # Given a GIT_TRACE2_EVENT log over stdin, writes to stdout a list of URLs
 # sent to git-remote-https child processes.
 test_remote_https_urls() {
index 970c6538cba7a8d9465b6774b23e367c4b257d88..33405c90d740d4c4e4fac93cfa8a713939a39348 100644 (file)
@@ -42,8 +42,8 @@ finalize_test_case_output () {
        fixed)
                echo >>$github_markup_output "::notice::fixed: $this_test.$test_count $1"
                ;;
-       ok)
-               # Exit without printing the "ok" tests
+       ok|broken)
+               # Exit without printing the "ok" or ""broken" tests
                return
                ;;
        esac
index 876b99562a323ee351d4afe0fe2afbca34fb46bc..c8af8dab795604998475e5fdff21137534c7f39b 100644 (file)
@@ -542,6 +542,8 @@ export EDITOR
 
 GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}"
 export GIT_DEFAULT_HASH
+GIT_DEFAULT_REF_FORMAT="${GIT_TEST_DEFAULT_REF_FORMAT:-files}"
+export GIT_DEFAULT_REF_FORMAT
 GIT_TEST_MERGE_ALGORITHM="${GIT_TEST_MERGE_ALGORITHM:-ort}"
 export GIT_TEST_MERGE_ALGORITHM
 
@@ -1295,6 +1297,11 @@ test_done () {
                EOF
        fi
 
+       if test -z "$passes_sanitize_leak" && test_bool_env TEST_PASSES_SANITIZE_LEAK false
+       then
+               BAIL_OUT "Please, set TEST_PASSES_SANITIZE_LEAK before sourcing test-lib.sh"
+       fi
+
        if test "$test_fixed" != 0
        then
                say_color error "# $test_fixed known breakage(s) vanished; please update test(s)"
@@ -1745,7 +1752,16 @@ parisc* | hppa*)
        ;;
 esac
 
-test_set_prereq REFFILES
+case "$GIT_DEFAULT_REF_FORMAT" in
+files)
+       test_set_prereq REFFILES;;
+reftable)
+       test_set_prereq REFTABLE;;
+*)
+       echo 2>&1 "error: unknown ref format $GIT_DEFAULT_REF_FORMAT"
+       exit 1
+       ;;
+esac
 
 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
 test -z "$NO_CURL" && test_set_prereq LIBCURL
@@ -1936,6 +1952,10 @@ test_lazy_prereq SHA1 '
        esac
 '
 
+test_lazy_prereq DEFAULT_REPO_FORMAT '
+       test_have_prereq SHA1,REFFILES
+'
+
 # Ensure that no test accidentally triggers a Git command
 # that runs the actual maintenance scheduler, affecting a user's
 # system permanently.
diff --git a/t/unit-tests/.gitignore b/t/unit-tests/.gitignore
new file mode 100644 (file)
index 0000000..5e56e04
--- /dev/null
@@ -0,0 +1 @@
+/bin
diff --git a/t/unit-tests/t-basic.c b/t/unit-tests/t-basic.c
new file mode 100644 (file)
index 0000000..fda1ae5
--- /dev/null
@@ -0,0 +1,95 @@
+#include "test-lib.h"
+
+/*
+ * The purpose of this "unit test" is to verify a few invariants of the unit
+ * test framework itself, as well as to provide examples of output from actually
+ * failing tests. As such, it is intended that this test fails, and thus it
+ * should not be run as part of `make unit-tests`. Instead, we verify it behaves
+ * as expected in the integration test t0080-unit-test-output.sh
+ */
+
+/* Used to store the return value of check_int(). */
+static int check_res;
+
+/* Used to store the return value of TEST(). */
+static int test_res;
+
+static void t_res(int expect)
+{
+       check_int(check_res, ==, expect);
+       check_int(test_res, ==, expect);
+}
+
+static void t_todo(int x)
+{
+       check_res = TEST_TODO(check(x));
+}
+
+static void t_skip(void)
+{
+       check(0);
+       test_skip("missing prerequisite");
+       check(1);
+}
+
+static int do_skip(void)
+{
+       test_skip("missing prerequisite");
+       return 1;
+}
+
+static void t_skip_todo(void)
+{
+       check_res = TEST_TODO(do_skip());
+}
+
+static void t_todo_after_fail(void)
+{
+       check(0);
+       TEST_TODO(check(0));
+}
+
+static void t_fail_after_todo(void)
+{
+       check(1);
+       TEST_TODO(check(0));
+       check(0);
+}
+
+static void t_messages(void)
+{
+       check_str("\thello\\", "there\"\n");
+       check_str("NULL", NULL);
+       check_char('a', ==, '\n');
+       check_char('\\', ==, '\'');
+}
+
+static void t_empty(void)
+{
+       ; /* empty */
+}
+
+int cmd_main(int argc, const char **argv)
+{
+       test_res = TEST(check_res = check_int(1, ==, 1), "passing test");
+       TEST(t_res(1), "passing test and assertion return 1");
+       test_res = TEST(check_res = check_int(1, ==, 2), "failing test");
+       TEST(t_res(0), "failing test and assertion return 0");
+       test_res = TEST(t_todo(0), "passing TEST_TODO()");
+       TEST(t_res(1), "passing TEST_TODO() returns 1");
+       test_res = TEST(t_todo(1), "failing TEST_TODO()");
+       TEST(t_res(0), "failing TEST_TODO() returns 0");
+       test_res = TEST(t_skip(), "test_skip()");
+       TEST(check_int(test_res, ==, 1), "skipped test returns 1");
+       test_res = TEST(t_skip_todo(), "test_skip() inside TEST_TODO()");
+       TEST(t_res(1), "test_skip() inside TEST_TODO() returns 1");
+       test_res = TEST(t_todo_after_fail(), "TEST_TODO() after failing check");
+       TEST(check_int(test_res, ==, 0), "TEST_TODO() after failing check returns 0");
+       test_res = TEST(t_fail_after_todo(), "failing check after TEST_TODO()");
+       TEST(check_int(test_res, ==, 0), "failing check after TEST_TODO() returns 0");
+       TEST(t_messages(), "messages from failing string and char comparison");
+       test_res = TEST(t_empty(), "test with no checks");
+       TEST(check_int(test_res, ==, 0), "test with no checks returns 0");
+
+       return test_done();
+}
diff --git a/t/unit-tests/t-ctype.c b/t/unit-tests/t-ctype.c
new file mode 100644 (file)
index 0000000..f315489
--- /dev/null
@@ -0,0 +1,80 @@
+#include "test-lib.h"
+
+static int is_in(const char *s, int ch)
+{
+       /*
+        * We can't find NUL using strchr. Accept it as the first
+        * character in the spec -- there are no empty classes.
+        */
+       if (ch == '\0')
+               return ch == *s;
+       if (*s == '\0')
+               s++;
+       return !!strchr(s, ch);
+}
+
+/* Macro to test a character type */
+#define TEST_CTYPE_FUNC(func, string) \
+static void test_ctype_##func(void) { \
+       for (int i = 0; i < 256; i++) { \
+               if (!check_int(func(i), ==, is_in(string, i))) \
+                       test_msg("       i: 0x%02x", i); \
+       } \
+       if (!check(!func(EOF))) \
+                       test_msg("      i: 0x%02x (EOF)", EOF); \
+}
+
+#define TEST_CHAR_CLASS(class) TEST(test_ctype_##class(), #class " works")
+
+#define DIGIT "0123456789"
+#define LOWER "abcdefghijklmnopqrstuvwxyz"
+#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+#define PUNCT "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
+#define ASCII \
+       "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \
+       "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
+       "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" \
+       "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" \
+       "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" \
+       "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" \
+       "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" \
+       "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
+#define CNTRL \
+       "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \
+       "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \
+       "\x7f"
+
+TEST_CTYPE_FUNC(isdigit, DIGIT)
+TEST_CTYPE_FUNC(isspace, " \n\r\t")
+TEST_CTYPE_FUNC(isalpha, LOWER UPPER)
+TEST_CTYPE_FUNC(isalnum, LOWER UPPER DIGIT)
+TEST_CTYPE_FUNC(is_glob_special, "*?[\\")
+TEST_CTYPE_FUNC(is_regex_special, "$()*+.?[\\^{|")
+TEST_CTYPE_FUNC(is_pathspec_magic, "!\"#%&',-/:;<=>@_`~")
+TEST_CTYPE_FUNC(isascii, ASCII)
+TEST_CTYPE_FUNC(islower, LOWER)
+TEST_CTYPE_FUNC(isupper, UPPER)
+TEST_CTYPE_FUNC(iscntrl, CNTRL)
+TEST_CTYPE_FUNC(ispunct, PUNCT)
+TEST_CTYPE_FUNC(isxdigit, DIGIT "abcdefABCDEF")
+TEST_CTYPE_FUNC(isprint, LOWER UPPER DIGIT PUNCT " ")
+
+int cmd_main(int argc, const char **argv) {
+       /* Run all character type tests */
+       TEST_CHAR_CLASS(isspace);
+       TEST_CHAR_CLASS(isdigit);
+       TEST_CHAR_CLASS(isalpha);
+       TEST_CHAR_CLASS(isalnum);
+       TEST_CHAR_CLASS(is_glob_special);
+       TEST_CHAR_CLASS(is_regex_special);
+       TEST_CHAR_CLASS(is_pathspec_magic);
+       TEST_CHAR_CLASS(isascii);
+       TEST_CHAR_CLASS(islower);
+       TEST_CHAR_CLASS(isupper);
+       TEST_CHAR_CLASS(iscntrl);
+       TEST_CHAR_CLASS(ispunct);
+       TEST_CHAR_CLASS(isxdigit);
+       TEST_CHAR_CLASS(isprint);
+
+       return test_done();
+}
diff --git a/t/unit-tests/t-mem-pool.c b/t/unit-tests/t-mem-pool.c
new file mode 100644 (file)
index 0000000..a0d57df
--- /dev/null
@@ -0,0 +1,31 @@
+#include "test-lib.h"
+#include "mem-pool.h"
+
+static void setup_static(void (*f)(struct mem_pool *), size_t block_alloc)
+{
+       struct mem_pool pool = { .block_alloc = block_alloc };
+       f(&pool);
+       mem_pool_discard(&pool, 0);
+}
+
+static void t_calloc_100(struct mem_pool *pool)
+{
+       size_t size = 100;
+       char *buffer = mem_pool_calloc(pool, 1, size);
+       for (size_t i = 0; i < size; i++)
+               check_int(buffer[i], ==, 0);
+       if (!check(pool->mp_block != NULL))
+               return;
+       check(pool->mp_block->next_free != NULL);
+       check(pool->mp_block->end != NULL);
+}
+
+int cmd_main(int argc, const char **argv)
+{
+       TEST(setup_static(t_calloc_100, 1024 * 1024),
+            "mem_pool_calloc returns 100 zeroed bytes with big block");
+       TEST(setup_static(t_calloc_100, 1),
+            "mem_pool_calloc returns 100 zeroed bytes with tiny block");
+
+       return test_done();
+}
diff --git a/t/unit-tests/t-prio-queue.c b/t/unit-tests/t-prio-queue.c
new file mode 100644 (file)
index 0000000..d78b002
--- /dev/null
@@ -0,0 +1,98 @@
+#include "test-lib.h"
+#include "prio-queue.h"
+
+static int intcmp(const void *va, const void *vb, void *data UNUSED)
+{
+       const int *a = va, *b = vb;
+       return *a - *b;
+}
+
+
+#define MISSING  -1
+#define DUMP    -2
+#define STACK   -3
+#define GET     -4
+#define REVERSE  -5
+
+static int show(int *v)
+{
+       return v ? *v : MISSING;
+}
+
+static void test_prio_queue(int *input, int *result, size_t input_size)
+{
+       struct prio_queue pq = { intcmp };
+
+       for (int i = 0, j = 0; i < input_size; i++) {
+               void *peek, *get;
+               switch(input[i]) {
+               case GET:
+                       peek = prio_queue_peek(&pq);
+                       get = prio_queue_get(&pq);
+                       if (!check(peek == get))
+                               return;
+                       if(!check_int(result[j++], ==, show(get)))
+                               test_msg("failed at result[] index %d", j-1);
+                       break;
+               case DUMP:
+                       while ((peek = prio_queue_peek(&pq))) {
+                               get = prio_queue_get(&pq);
+                               if (!check(peek == get))
+                                       return;
+                               if(!check_int(result[j++], ==, show(get)))
+                                       test_msg("failed at result[] index %d", j-1);
+                       }
+                       break;
+               case STACK:
+                       pq.compare = NULL;
+                       break;
+               case REVERSE:
+                       prio_queue_reverse(&pq);
+                       break;
+               default:
+                       prio_queue_put(&pq, &input[i]);
+                       break;
+               }
+       }
+       clear_prio_queue(&pq);
+}
+
+#define BASIC_INPUT 2, 6, 3, 10, 9, 5, 7, 4, 5, 8, 1, DUMP
+#define BASIC_RESULT 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10
+
+#define MIXED_PUT_GET_INPUT 6, 2, 4, GET, 5, 3, GET, GET, 1, DUMP
+#define MIXED_PUT_GET_RESULT 2, 3, 4, 1, 5, 6
+
+#define EMPTY_QUEUE_INPUT 1, 2, GET, GET, GET, 1, 2, GET, GET, GET
+#define EMPTY_QUEUE_RESULT 1, 2, MISSING, 1, 2, MISSING
+
+#define STACK_INPUT STACK, 8, 1, 5, 4, 6, 2, 3, DUMP
+#define STACK_RESULT 3, 2, 6, 4, 5, 1, 8
+
+#define REVERSE_STACK_INPUT STACK, 1, 2, 3, 4, 5, 6, REVERSE, DUMP
+#define REVERSE_STACK_RESULT 1, 2, 3, 4, 5, 6
+
+#define TEST_INPUT(INPUT, RESULT, name)                        \
+  static void test_##name(void)                                \
+{                                                              \
+       int input[] = {INPUT};                                  \
+       int result[] = {RESULT};                                \
+       test_prio_queue(input, result, ARRAY_SIZE(input));      \
+}
+
+TEST_INPUT(BASIC_INPUT, BASIC_RESULT, basic)
+TEST_INPUT(MIXED_PUT_GET_INPUT, MIXED_PUT_GET_RESULT, mixed)
+TEST_INPUT(EMPTY_QUEUE_INPUT, EMPTY_QUEUE_RESULT, empty)
+TEST_INPUT(STACK_INPUT, STACK_RESULT, stack)
+TEST_INPUT(REVERSE_STACK_INPUT, REVERSE_STACK_RESULT, reverse)
+
+int cmd_main(int argc, const char **argv)
+{
+       TEST(test_basic(), "prio-queue works for basic input");
+       TEST(test_mixed(), "prio-queue works for mixed put & get commands");
+       TEST(test_empty(), "prio-queue works when queue is empty");
+       TEST(test_stack(), "prio-queue works when used as a LIFO stack");
+       TEST(test_reverse(), "prio-queue works when LIFO stack is reversed");
+
+       return test_done();
+}
diff --git a/t/unit-tests/t-strbuf.c b/t/unit-tests/t-strbuf.c
new file mode 100644 (file)
index 0000000..de434a4
--- /dev/null
@@ -0,0 +1,120 @@
+#include "test-lib.h"
+#include "strbuf.h"
+
+/* wrapper that supplies tests with an empty, initialized strbuf */
+static void setup(void (*f)(struct strbuf*, void*), void *data)
+{
+       struct strbuf buf = STRBUF_INIT;
+
+       f(&buf, data);
+       strbuf_release(&buf);
+       check_uint(buf.len, ==, 0);
+       check_uint(buf.alloc, ==, 0);
+}
+
+/* wrapper that supplies tests with a populated, initialized strbuf */
+static void setup_populated(void (*f)(struct strbuf*, void*), char *init_str, void *data)
+{
+       struct strbuf buf = STRBUF_INIT;
+
+       strbuf_addstr(&buf, init_str);
+       check_uint(buf.len, ==, strlen(init_str));
+       f(&buf, data);
+       strbuf_release(&buf);
+       check_uint(buf.len, ==, 0);
+       check_uint(buf.alloc, ==, 0);
+}
+
+static int assert_sane_strbuf(struct strbuf *buf)
+{
+       /* Initialized strbufs should always have a non-NULL buffer */
+       if (!check(!!buf->buf))
+               return 0;
+       /* Buffers should always be NUL-terminated */
+       if (!check_char(buf->buf[buf->len], ==, '\0'))
+               return 0;
+       /*
+        * Freshly-initialized strbufs may not have a dynamically allocated
+        * buffer
+        */
+       if (buf->len == 0 && buf->alloc == 0)
+               return 1;
+       /* alloc must be at least one byte larger than len */
+       return check_uint(buf->len, <, buf->alloc);
+}
+
+static void t_static_init(void)
+{
+       struct strbuf buf = STRBUF_INIT;
+
+       check_uint(buf.len, ==, 0);
+       check_uint(buf.alloc, ==, 0);
+       check_char(buf.buf[0], ==, '\0');
+}
+
+static void t_dynamic_init(void)
+{
+       struct strbuf buf;
+
+       strbuf_init(&buf, 1024);
+       check(assert_sane_strbuf(&buf));
+       check_uint(buf.len, ==, 0);
+       check_uint(buf.alloc, >=, 1024);
+       check_char(buf.buf[0], ==, '\0');
+       strbuf_release(&buf);
+}
+
+static void t_addch(struct strbuf *buf, void *data)
+{
+       const char *p_ch = data;
+       const char ch = *p_ch;
+       size_t orig_alloc = buf->alloc;
+       size_t orig_len = buf->len;
+
+       if (!check(assert_sane_strbuf(buf)))
+               return;
+       strbuf_addch(buf, ch);
+       if (!check(assert_sane_strbuf(buf)))
+               return;
+       if (!(check_uint(buf->len, ==, orig_len + 1) &&
+             check_uint(buf->alloc, >=, orig_alloc)))
+               return; /* avoid de-referencing buf->buf */
+       check_char(buf->buf[buf->len - 1], ==, ch);
+       check_char(buf->buf[buf->len], ==, '\0');
+}
+
+static void t_addstr(struct strbuf *buf, void *data)
+{
+       const char *text = data;
+       size_t len = strlen(text);
+       size_t orig_alloc = buf->alloc;
+       size_t orig_len = buf->len;
+
+       if (!check(assert_sane_strbuf(buf)))
+               return;
+       strbuf_addstr(buf, text);
+       if (!check(assert_sane_strbuf(buf)))
+               return;
+       if (!(check_uint(buf->len, ==, orig_len + len) &&
+             check_uint(buf->alloc, >=, orig_alloc) &&
+             check_uint(buf->alloc, >, orig_len + len) &&
+             check_char(buf->buf[orig_len + len], ==, '\0')))
+           return;
+       check_str(buf->buf + orig_len, text);
+}
+
+int cmd_main(int argc, const char **argv)
+{
+       if (!TEST(t_static_init(), "static initialization works"))
+               test_skip_all("STRBUF_INIT is broken");
+       TEST(t_dynamic_init(), "dynamic initialization works");
+       TEST(setup(t_addch, "a"), "strbuf_addch adds char");
+       TEST(setup(t_addch, ""), "strbuf_addch adds NUL char");
+       TEST(setup_populated(t_addch, "initial value", "a"),
+            "strbuf_addch appends to initial value");
+       TEST(setup(t_addstr, "hello there"), "strbuf_addstr adds string");
+       TEST(setup_populated(t_addstr, "initial value", "hello there"),
+            "strbuf_addstr appends string to initial value");
+
+       return test_done();
+}
diff --git a/t/unit-tests/test-lib.c b/t/unit-tests/test-lib.c
new file mode 100644 (file)
index 0000000..66d6980
--- /dev/null
@@ -0,0 +1,407 @@
+#include "test-lib.h"
+
+enum result {
+       RESULT_NONE,
+       RESULT_FAILURE,
+       RESULT_SKIP,
+       RESULT_SUCCESS,
+       RESULT_TODO
+};
+
+static struct {
+       enum result result;
+       int count;
+       unsigned failed :1;
+       unsigned lazy_plan :1;
+       unsigned running :1;
+       unsigned skip_all :1;
+       unsigned todo :1;
+} ctx = {
+       .lazy_plan = 1,
+       .result = RESULT_NONE,
+};
+
+/*
+ * Visual C interpolates the absolute Windows path for `__FILE__`,
+ * but we want to see relative paths, as verified by t0080.
+ * There are other compilers that do the same, and are not for
+ * Windows.
+ */
+#include "dir.h"
+
+static const char *make_relative(const char *location)
+{
+       static char prefix[] = __FILE__, buf[PATH_MAX], *p;
+       static size_t prefix_len;
+       static int need_bs_to_fs = -1;
+
+       /* one-time preparation */
+       if (need_bs_to_fs < 0) {
+               size_t len = strlen(prefix);
+               char needle[] = "t\\unit-tests\\test-lib.c";
+               size_t needle_len = strlen(needle);
+
+               if (len < needle_len)
+                       die("unexpected prefix '%s'", prefix);
+
+               /*
+                * The path could be relative (t/unit-tests/test-lib.c)
+                * or full (/home/user/git/t/unit-tests/test-lib.c).
+                * Check the slash between "t" and "unit-tests".
+                */
+               prefix_len = len - needle_len;
+               if (prefix[prefix_len + 1] == '/') {
+                       /* Oh, we're not Windows */
+                       for (size_t i = 0; i < needle_len; i++)
+                               if (needle[i] == '\\')
+                                       needle[i] = '/';
+                       need_bs_to_fs = 0;
+               } else {
+                       need_bs_to_fs = 1;
+               }
+
+               /*
+                * prefix_len == 0 if the compiler gives paths relative
+                * to the root of the working tree.  Otherwise, we want
+                * to see that we did find the needle[] at a directory
+                * boundary.  Again we rely on that needle[] begins with
+                * "t" followed by the directory separator.
+                */
+               if (fspathcmp(needle, prefix + prefix_len) ||
+                   (prefix_len && prefix[prefix_len - 1] != needle[1]))
+                       die("unexpected suffix of '%s'", prefix);
+       }
+
+       /*
+        * Does it not start with the expected prefix?
+        * Return it as-is without making it worse.
+        */
+       if (prefix_len && fspathncmp(location, prefix, prefix_len))
+               return location;
+
+       /*
+        * If we do not need to munge directory separator, we can return
+        * the substring at the tail of the location.
+        */
+       if (!need_bs_to_fs)
+               return location + prefix_len;
+
+       /* convert backslashes to forward slashes */
+       strlcpy(buf, location + prefix_len, sizeof(buf));
+       for (p = buf; *p; p++)
+               if (*p == '\\')
+                       *p = '/';
+       return buf;
+}
+
+static void msg_with_prefix(const char *prefix, const char *format, va_list ap)
+{
+       fflush(stderr);
+       if (prefix)
+               fprintf(stdout, "%s", prefix);
+       vprintf(format, ap); /* TODO: handle newlines */
+       putc('\n', stdout);
+       fflush(stdout);
+}
+
+void test_msg(const char *format, ...)
+{
+       va_list ap;
+
+       va_start(ap, format);
+       msg_with_prefix("# ", format, ap);
+       va_end(ap);
+}
+
+void test_plan(int count)
+{
+       assert(!ctx.running);
+
+       fflush(stderr);
+       printf("1..%d\n", count);
+       fflush(stdout);
+       ctx.lazy_plan = 0;
+}
+
+int test_done(void)
+{
+       assert(!ctx.running);
+
+       if (ctx.lazy_plan)
+               test_plan(ctx.count);
+
+       return ctx.failed;
+}
+
+void test_skip(const char *format, ...)
+{
+       va_list ap;
+
+       assert(ctx.running);
+
+       ctx.result = RESULT_SKIP;
+       va_start(ap, format);
+       if (format)
+               msg_with_prefix("# skipping test - ", format, ap);
+       va_end(ap);
+}
+
+void test_skip_all(const char *format, ...)
+{
+       va_list ap;
+       const char *prefix;
+
+       if (!ctx.count && ctx.lazy_plan) {
+               /* We have not printed a test plan yet */
+               prefix = "1..0 # SKIP ";
+               ctx.lazy_plan = 0;
+       } else {
+               /* We have already printed a test plan */
+               prefix = "Bail out! # ";
+               ctx.failed = 1;
+       }
+       ctx.skip_all = 1;
+       ctx.result = RESULT_SKIP;
+       va_start(ap, format);
+       msg_with_prefix(prefix, format, ap);
+       va_end(ap);
+}
+
+int test__run_begin(void)
+{
+       assert(!ctx.running);
+
+       ctx.count++;
+       ctx.result = RESULT_NONE;
+       ctx.running = 1;
+
+       return ctx.skip_all;
+}
+
+static void print_description(const char *format, va_list ap)
+{
+       if (format) {
+               fputs(" - ", stdout);
+               vprintf(format, ap);
+       }
+}
+
+int test__run_end(int was_run UNUSED, const char *location, const char *format, ...)
+{
+       va_list ap;
+
+       assert(ctx.running);
+       assert(!ctx.todo);
+
+       fflush(stderr);
+       va_start(ap, format);
+       if (!ctx.skip_all) {
+               switch (ctx.result) {
+               case RESULT_SUCCESS:
+                       printf("ok %d", ctx.count);
+                       print_description(format, ap);
+                       break;
+
+               case RESULT_FAILURE:
+                       printf("not ok %d", ctx.count);
+                       print_description(format, ap);
+                       break;
+
+               case RESULT_TODO:
+                       printf("not ok %d", ctx.count);
+                       print_description(format, ap);
+                       printf(" # TODO");
+                       break;
+
+               case RESULT_SKIP:
+                       printf("ok %d", ctx.count);
+                       print_description(format, ap);
+                       printf(" # SKIP");
+                       break;
+
+               case RESULT_NONE:
+                       test_msg("BUG: test has no checks at %s",
+                                make_relative(location));
+                       printf("not ok %d", ctx.count);
+                       print_description(format, ap);
+                       ctx.result = RESULT_FAILURE;
+                       break;
+               }
+       }
+       va_end(ap);
+       ctx.running = 0;
+       if (ctx.skip_all)
+               return 1;
+       putc('\n', stdout);
+       fflush(stdout);
+       ctx.failed |= ctx.result == RESULT_FAILURE;
+
+       return ctx.result != RESULT_FAILURE;
+}
+
+static void test_fail(void)
+{
+       assert(ctx.result != RESULT_SKIP);
+
+       ctx.result = RESULT_FAILURE;
+}
+
+static void test_pass(void)
+{
+       assert(ctx.result != RESULT_SKIP);
+
+       if (ctx.result == RESULT_NONE)
+               ctx.result = RESULT_SUCCESS;
+}
+
+static void test_todo(void)
+{
+       assert(ctx.result != RESULT_SKIP);
+
+       if (ctx.result != RESULT_FAILURE)
+               ctx.result = RESULT_TODO;
+}
+
+int test_assert(const char *location, const char *check, int ok)
+{
+       assert(ctx.running);
+
+       if (ctx.result == RESULT_SKIP) {
+               test_msg("skipping check '%s' at %s", check,
+                        make_relative(location));
+               return 1;
+       }
+       if (!ctx.todo) {
+               if (ok) {
+                       test_pass();
+               } else {
+                       test_msg("check \"%s\" failed at %s", check,
+                                make_relative(location));
+                       test_fail();
+               }
+       }
+
+       return !!ok;
+}
+
+void test__todo_begin(void)
+{
+       assert(ctx.running);
+       assert(!ctx.todo);
+
+       ctx.todo = 1;
+}
+
+int test__todo_end(const char *location, const char *check, int res)
+{
+       assert(ctx.running);
+       assert(ctx.todo);
+
+       ctx.todo = 0;
+       if (ctx.result == RESULT_SKIP)
+               return 1;
+       if (res) {
+               test_msg("todo check '%s' succeeded at %s", check,
+                        make_relative(location));
+               test_fail();
+       } else {
+               test_todo();
+       }
+
+       return !res;
+}
+
+int check_bool_loc(const char *loc, const char *check, int ok)
+{
+       return test_assert(loc, check, ok);
+}
+
+union test__tmp test__tmp[2];
+
+int check_int_loc(const char *loc, const char *check, int ok,
+                 intmax_t a, intmax_t b)
+{
+       int ret = test_assert(loc, check, ok);
+
+       if (!ret) {
+               test_msg("   left: %"PRIdMAX, a);
+               test_msg("  right: %"PRIdMAX, b);
+       }
+
+       return ret;
+}
+
+int check_uint_loc(const char *loc, const char *check, int ok,
+                  uintmax_t a, uintmax_t b)
+{
+       int ret = test_assert(loc, check, ok);
+
+       if (!ret) {
+               test_msg("   left: %"PRIuMAX, a);
+               test_msg("  right: %"PRIuMAX, b);
+       }
+
+       return ret;
+}
+
+static void print_one_char(char ch, char quote)
+{
+       if ((unsigned char)ch < 0x20u || ch == 0x7f) {
+               /* TODO: improve handling of \a, \b, \f ... */
+               printf("\\%03o", (unsigned char)ch);
+       } else {
+               if (ch == '\\' || ch == quote)
+                       putc('\\', stdout);
+               putc(ch, stdout);
+       }
+}
+
+static void print_char(const char *prefix, char ch)
+{
+       printf("# %s: '", prefix);
+       print_one_char(ch, '\'');
+       fputs("'\n", stdout);
+}
+
+int check_char_loc(const char *loc, const char *check, int ok, char a, char b)
+{
+       int ret = test_assert(loc, check, ok);
+
+       if (!ret) {
+               fflush(stderr);
+               print_char("   left", a);
+               print_char("  right", b);
+               fflush(stdout);
+       }
+
+       return ret;
+}
+
+static void print_str(const char *prefix, const char *str)
+{
+       printf("# %s: ", prefix);
+       if (!str) {
+               fputs("NULL\n", stdout);
+       } else {
+               putc('"', stdout);
+               while (*str)
+                       print_one_char(*str++, '"');
+               fputs("\"\n", stdout);
+       }
+}
+
+int check_str_loc(const char *loc, const char *check,
+                 const char *a, const char *b)
+{
+       int ok = (!a && !b) || (a && b && !strcmp(a, b));
+       int ret = test_assert(loc, check, ok);
+
+       if (!ret) {
+               fflush(stderr);
+               print_str("   left", a);
+               print_str("  right", b);
+               fflush(stdout);
+       }
+
+       return ret;
+}
diff --git a/t/unit-tests/test-lib.h b/t/unit-tests/test-lib.h
new file mode 100644 (file)
index 0000000..a8f07ae
--- /dev/null
@@ -0,0 +1,149 @@
+#ifndef TEST_LIB_H
+#define TEST_LIB_H
+
+#include "git-compat-util.h"
+
+/*
+ * Run a test function, returns 1 if the test succeeds, 0 if it
+ * fails. If test_skip_all() has been called then the test will not be
+ * run. The description for each test should be unique. For example:
+ *
+ *  TEST(test_something(arg1, arg2), "something %d %d", arg1, arg2)
+ */
+#define TEST(t, ...)                                   \
+       test__run_end(test__run_begin() ? 0 : (t, 1),   \
+                     TEST_LOCATION(),  __VA_ARGS__)
+
+/*
+ * Print a test plan, should be called before any tests. If the number
+ * of tests is not known in advance test_done() will automatically
+ * print a plan at the end of the test program.
+ */
+void test_plan(int count);
+
+/*
+ * test_done() must be called at the end of main(). It will print the
+ * plan if plan() was not called at the beginning of the test program
+ * and returns the exit code for the test program.
+ */
+int test_done(void);
+
+/* Skip the current test. */
+__attribute__((format (printf, 1, 2)))
+void test_skip(const char *format, ...);
+
+/* Skip all remaining tests. */
+__attribute__((format (printf, 1, 2)))
+void test_skip_all(const char *format, ...);
+
+/* Print a diagnostic message to stdout. */
+__attribute__((format (printf, 1, 2)))
+void test_msg(const char *format, ...);
+
+/*
+ * Test checks are built around test_assert(). checks return 1 on
+ * success, 0 on failure. If any check fails then the test will fail. To
+ * create a custom check define a function that wraps test_assert() and
+ * a macro to wrap that function to provide a source location and
+ * stringified arguments. Custom checks that take pointer arguments
+ * should be careful to check that they are non-NULL before
+ * dereferencing them. For example:
+ *
+ *  static int check_oid_loc(const char *loc, const char *check,
+ *                          struct object_id *a, struct object_id *b)
+ *  {
+ *         int res = test_assert(loc, check, a && b && oideq(a, b));
+ *
+ *         if (!res) {
+ *                 test_msg("   left: %s", a ? oid_to_hex(a) : "NULL";
+ *                 test_msg("  right: %s", b ? oid_to_hex(a) : "NULL";
+ *
+ *         }
+ *         return res;
+ *  }
+ *
+ *  #define check_oid(a, b) \
+ *         check_oid_loc(TEST_LOCATION(), "oideq("#a", "#b")", a, b)
+ */
+int test_assert(const char *location, const char *check, int ok);
+
+/* Helper macro to pass the location to checks */
+#define TEST_LOCATION() TEST__MAKE_LOCATION(__LINE__)
+
+/* Check a boolean condition. */
+#define check(x)                               \
+       check_bool_loc(TEST_LOCATION(), #x, x)
+int check_bool_loc(const char *loc, const char *check, int ok);
+
+/*
+ * Compare two integers. Prints a message with the two values if the
+ * comparison fails. NB this is not thread safe.
+ */
+#define check_int(a, op, b)                                            \
+       (test__tmp[0].i = (a), test__tmp[1].i = (b),                    \
+        check_int_loc(TEST_LOCATION(), #a" "#op" "#b,                  \
+                      test__tmp[0].i op test__tmp[1].i,                \
+                      test__tmp[0].i, test__tmp[1].i))
+int check_int_loc(const char *loc, const char *check, int ok,
+                 intmax_t a, intmax_t b);
+
+/*
+ * Compare two unsigned integers. Prints a message with the two values
+ * if the comparison fails. NB this is not thread safe.
+ */
+#define check_uint(a, op, b)                                           \
+       (test__tmp[0].u = (a), test__tmp[1].u = (b),                    \
+        check_uint_loc(TEST_LOCATION(), #a" "#op" "#b,                 \
+                       test__tmp[0].u op test__tmp[1].u,               \
+                       test__tmp[0].u, test__tmp[1].u))
+int check_uint_loc(const char *loc, const char *check, int ok,
+                  uintmax_t a, uintmax_t b);
+
+/*
+ * Compare two chars. Prints a message with the two values if the
+ * comparison fails. NB this is not thread safe.
+ */
+#define check_char(a, op, b)                                           \
+       (test__tmp[0].c = (a), test__tmp[1].c = (b),                    \
+        check_char_loc(TEST_LOCATION(), #a" "#op" "#b,                 \
+                       test__tmp[0].c op test__tmp[1].c,               \
+                       test__tmp[0].c, test__tmp[1].c))
+int check_char_loc(const char *loc, const char *check, int ok,
+                  char a, char b);
+
+/* Check whether two strings are equal. */
+#define check_str(a, b)                                                        \
+       check_str_loc(TEST_LOCATION(), "!strcmp("#a", "#b")", a, b)
+int check_str_loc(const char *loc, const char *check,
+                 const char *a, const char *b);
+
+/*
+ * Wrap a check that is known to fail. If the check succeeds then the
+ * test will fail. Returns 1 if the check fails, 0 if it
+ * succeeds. For example:
+ *
+ *  TEST_TODO(check(0));
+ */
+#define TEST_TODO(check) \
+       (test__todo_begin(), test__todo_end(TEST_LOCATION(), #check, check))
+
+/* Private helpers */
+
+#define TEST__STR(x) #x
+#define TEST__MAKE_LOCATION(line) __FILE__ ":" TEST__STR(line)
+
+union test__tmp {
+       intmax_t i;
+       uintmax_t u;
+       char c;
+};
+
+extern union test__tmp test__tmp[2];
+
+int test__run_begin(void);
+__attribute__((format (printf, 3, 4)))
+int test__run_end(int, const char *, const char *, ...);
+void test__todo_begin(void);
+int test__todo_end(const char *, const char *, int);
+
+#endif /* TEST_LIB_H */
index 669ebaf68be006ee53911f02da72e56cb5a100f0..3c8ee19975bb74d755fd40d3ee8d27fbaecc0e58 100755 (executable)
@@ -23,7 +23,7 @@ memcheck)
        VALGRIND_MAJOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*\([0-9]*\)')
        VALGRIND_MINOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*[0-9]*\.\([0-9]*\)')
        test 3 -gt "$VALGRIND_MAJOR" ||
-       test 3 -eq "$VALGRIND_MAJOR" -a 4 -gt "$VALGRIND_MINOR" ||
+       { test 3 -eq "$VALGRIND_MAJOR" && test 4 -gt "$VALGRIND_MINOR"; } ||
        TOOL_OPTIONS="$TOOL_OPTIONS --track-origins=yes"
        ;;
 *)
index e34a8f47cfbf5cba150e1aa7c6267fc2b1c080c0..dd6002b393738df81c7ecfc85deb4ed0abe4943c 100644 (file)
@@ -17,6 +17,7 @@
 #include "refspec.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "packfile.h"
 
 static int debug;
 
@@ -432,6 +433,8 @@ static int fetch_with_fetch(struct transport *transport,
                        warning(_("%s unexpectedly said: '%s'"), data->name, buf.buf);
        }
        strbuf_release(&buf);
+
+       reprepare_packed_git(the_repository);
        return 0;
 }
 
@@ -626,7 +629,8 @@ static int process_connect_service(struct transport *transport,
                ret = run_connect(transport, &cmdbuf);
        } else if (data->stateless_connect &&
                   (get_protocol_version_config() == protocol_v2) &&
-                  !strcmp("git-upload-pack", name)) {
+                  (!strcmp("git-upload-pack", name) ||
+                   !strcmp("git-upload-archive", name))) {
                strbuf_addf(&cmdbuf, "stateless-connect %s\n", name);
                ret = run_connect(transport, &cmdbuf);
                if (ret)
@@ -643,6 +647,7 @@ static int process_connect(struct transport *transport,
        struct helper_data *data = transport->data;
        const char *name;
        const char *exec;
+       int ret;
 
        name = for_push ? "git-receive-pack" : "git-upload-pack";
        if (for_push)
@@ -650,7 +655,10 @@ static int process_connect(struct transport *transport,
        else
                exec = data->transport_options.uploadpack;
 
-       return process_connect_service(transport, name, exec);
+       ret = process_connect_service(transport, name, exec);
+       if (ret)
+               do_take_over(transport);
+       return ret;
 }
 
 static int connect_helper(struct transport *transport, const char *name,
@@ -660,14 +668,14 @@ static int connect_helper(struct transport *transport, const char *name,
 
        /* Get_helper so connect is inited. */
        get_helper(transport);
-       if (!data->connect)
-               die(_("operation not supported by protocol"));
 
        if (!process_connect_service(transport, name, exec))
                die(_("can't connect to subservice %s"), name);
 
        fd[0] = data->helper->out;
        fd[1] = data->helper->in;
+
+       do_take_over(transport);
        return 0;
 }
 
@@ -682,10 +690,8 @@ static int fetch_refs(struct transport *transport,
 
        get_helper(transport);
 
-       if (process_connect(transport, 0)) {
-               do_take_over(transport);
+       if (process_connect(transport, 0))
                return transport->vtable->fetch_refs(transport, nr_heads, to_fetch);
-       }
 
        /*
         * If we reach here, then the server, the client, and/or the transport
@@ -1142,10 +1148,8 @@ static int push_refs(struct transport *transport,
 {
        struct helper_data *data = transport->data;
 
-       if (process_connect(transport, 1)) {
-               do_take_over(transport);
+       if (process_connect(transport, 1))
                return transport->vtable->push_refs(transport, remote_refs, flags);
-       }
 
        if (!remote_refs) {
                fprintf(stderr,
@@ -1186,11 +1190,9 @@ static struct ref *get_refs_list(struct transport *transport, int for_push,
 {
        get_helper(transport);
 
-       if (process_connect(transport, for_push)) {
-               do_take_over(transport);
+       if (process_connect(transport, for_push))
                return transport->vtable->get_refs_list(transport, for_push,
                                                        transport_options);
-       }
 
        return get_refs_list_using_list(transport, for_push);
 }
@@ -1274,10 +1276,8 @@ static int get_bundle_uri(struct transport *transport)
 {
        get_helper(transport);
 
-       if (process_connect(transport, 0)) {
-               do_take_over(transport);
+       if (process_connect(transport, 0))
                return transport->vtable->get_bundle_uri(transport);
-       }
 
        return -1;
 }
index bd7899e9bf5550b2b333dbbcf85a5b98c7813ad2..df518ead70c387dd354dd69a5ee4af8a3ab0d560 100644 (file)
@@ -1467,6 +1467,7 @@ int transport_push(struct repository *r,
        if (porcelain && !push_ret)
                puts("Done");
        else if (!quiet && !ret && !transport_refs_pushed(remote_refs))
+               /* stable plumbing output; do not modify or localize */
                fprintf(stderr, "Everything up-to-date\n");
 
 done:
index b517792ba23a2104f5f8207519e64cbc5d2daaa4..690fa6569bd7fe03ca104e3e789fd67b58e41270 100644 (file)
@@ -100,7 +100,7 @@ void *fill_tree_descriptor(struct repository *r,
        if (oid) {
                buf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL);
                if (!buf)
-                       die("unable to read tree %s", oid_to_hex(oid));
+                       die(_("unable to read tree (%s)"), oid_to_hex(oid));
        }
        init_tree_desc(desc, buf, size);
        return buf;
index 2537affa90762228a19d305be749f410d5afb5dc..6e0d441ef523edaeca10ffdf2e13f8d52ee592d0 100644 (file)
@@ -463,7 +463,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
 
  fail:
        free(output_state);
-       send_client_data(3, abort_msg, sizeof(abort_msg),
+       send_client_data(3, abort_msg, strlen(abort_msg),
                         pack_data->use_sideband);
        die("git upload-pack: %s", abort_msg);
 }
index e399543823bdf2c0c8f24fb87f7622ac4d8a366b..92ef649c99ef49d1b21688584ad7d3bbbff6b737 100644 (file)
@@ -3,6 +3,7 @@
 #include "userdiff.h"
 #include "attr.h"
 #include "strbuf.h"
+#include "environment.h"
 
 static struct userdiff_driver *drivers;
 static int ndrivers;
@@ -323,8 +324,7 @@ static int userdiff_find_by_namelen_cb(struct userdiff_driver *driver,
 {
        struct find_by_namelen_data *cb_data = priv;
 
-       if (!strncmp(driver->name, cb_data->name, cb_data->len) &&
-           !driver->name[cb_data->len]) {
+       if (!xstrncmpz(driver->name, cb_data->name, cb_data->len)) {
                cb_data->driver = driver;
                return 1; /* tell the caller to stop iterating */
        }
@@ -460,7 +460,8 @@ struct userdiff_driver *userdiff_get_textconv(struct repository *r,
        if (!driver->textconv)
                return NULL;
 
-       if (driver->textconv_want_cache && !driver->textconv_cache) {
+       if (driver->textconv_want_cache && !driver->textconv_cache &&
+           have_git_dir()) {
                struct notes_cache *c = xmalloc(sizeof(*c));
                struct strbuf name = STRBUF_INIT;
 
index 1399d452accaa3d0bdadd759c95fa7fd704f0a95..b02a05a74a341157fa8dff7da22936127bebf18e 100644 (file)
 #include "wt-status.h"
 #include "config.h"
 
+void free_worktree(struct worktree *worktree)
+{
+       if (!worktree)
+               return;
+       free(worktree->path);
+       free(worktree->id);
+       free(worktree->head_ref);
+       free(worktree->lock_reason);
+       free(worktree->prune_reason);
+       free(worktree);
+}
+
 void free_worktrees(struct worktree **worktrees)
 {
        int i = 0;
-
-       for (i = 0; worktrees[i]; i++) {
-               free(worktrees[i]->path);
-               free(worktrees[i]->id);
-               free(worktrees[i]->head_ref);
-               free(worktrees[i]->lock_reason);
-               free(worktrees[i]->prune_reason);
-               free(worktrees[i]);
-       }
+       for (i = 0; worktrees[i]; i++)
+               free_worktree(worktrees[i]);
        free (worktrees);
 }
 
@@ -51,7 +56,7 @@ static void add_head_info(struct worktree *wt)
 /**
  * get the main worktree
  */
-static struct worktree *get_main_worktree(void)
+static struct worktree *get_main_worktree(int skip_reading_head)
 {
        struct worktree *worktree = NULL;
        struct strbuf worktree_path = STRBUF_INIT;
@@ -70,11 +75,13 @@ static struct worktree *get_main_worktree(void)
         */
        worktree->is_bare = (is_bare_repository_cfg == 1) ||
                is_bare_repository();
-       add_head_info(worktree);
+       if (!skip_reading_head)
+               add_head_info(worktree);
        return worktree;
 }
 
-static struct worktree *get_linked_worktree(const char *id)
+struct worktree *get_linked_worktree(const char *id,
+                                    int skip_reading_head)
 {
        struct worktree *worktree = NULL;
        struct strbuf path = STRBUF_INIT;
@@ -93,7 +100,8 @@ static struct worktree *get_linked_worktree(const char *id)
        CALLOC_ARRAY(worktree, 1);
        worktree->path = strbuf_detach(&worktree_path, NULL);
        worktree->id = xstrdup(id);
-       add_head_info(worktree);
+       if (!skip_reading_head)
+               add_head_info(worktree);
 
 done:
        strbuf_release(&path);
@@ -118,7 +126,14 @@ static void mark_current_worktree(struct worktree **worktrees)
        free(git_dir);
 }
 
-struct worktree **get_worktrees(void)
+/*
+ * NEEDSWORK: This function exists so that we can look up metadata of a
+ * worktree without trying to access any of its internals like the refdb. It
+ * would be preferable to instead have a corruption-tolerant function for
+ * retrieving worktree metadata that could be used when the worktree is known
+ * to not be in a healthy state, e.g. when creating or repairing it.
+ */
+static struct worktree **get_worktrees_internal(int skip_reading_head)
 {
        struct worktree **list = NULL;
        struct strbuf path = STRBUF_INIT;
@@ -128,7 +143,7 @@ struct worktree **get_worktrees(void)
 
        ALLOC_ARRAY(list, alloc);
 
-       list[counter++] = get_main_worktree();
+       list[counter++] = get_main_worktree(skip_reading_head);
 
        strbuf_addf(&path, "%s/worktrees", get_git_common_dir());
        dir = opendir(path.buf);
@@ -137,7 +152,7 @@ struct worktree **get_worktrees(void)
                while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
                        struct worktree *linked = NULL;
 
-                       if ((linked = get_linked_worktree(d->d_name))) {
+                       if ((linked = get_linked_worktree(d->d_name, skip_reading_head))) {
                                ALLOC_GROW(list, counter + 1, alloc);
                                list[counter++] = linked;
                        }
@@ -151,6 +166,11 @@ struct worktree **get_worktrees(void)
        return list;
 }
 
+struct worktree **get_worktrees(void)
+{
+       return get_worktrees_internal(0);
+}
+
 const char *get_worktree_git_dir(const struct worktree *wt)
 {
        if (!wt)
@@ -591,7 +611,7 @@ static void repair_noop(int iserr UNUSED,
 
 void repair_worktrees(worktree_repair_fn fn, void *cb_data)
 {
-       struct worktree **worktrees = get_worktrees();
+       struct worktree **worktrees = get_worktrees_internal(1);
        struct worktree **wt = worktrees + 1; /* +1 skips main worktree */
 
        if (!fn)
index ce45b66de9e82d4d619b6f74e0e77c8bd5ab3f53..f14784a2ff871c69e5b5e28466439201721407b2 100644 (file)
@@ -57,6 +57,13 @@ struct worktree *find_worktree(struct worktree **list,
                               const char *prefix,
                               const char *arg);
 
+/*
+ * Look up the worktree corresponding to `id`, or NULL of no such worktree
+ * exists.
+ */
+struct worktree *get_linked_worktree(const char *id,
+                                    int skip_reading_head);
+
 /*
  * Return the worktree corresponding to `path`, or NULL if no such worktree
  * exists.
@@ -134,6 +141,11 @@ void repair_worktrees(worktree_repair_fn, void *cb_data);
  */
 void repair_worktree_at_path(const char *, worktree_repair_fn, void *cb_data);
 
+/*
+ * Free up the memory for a worktree.
+ */
+void free_worktree(struct worktree *);
+
 /*
  * Free up the memory for worktree(s)
  */
index b17ca58f8bf8256aaab93ce57d0c8959495ca55d..7108a92b52ce06e5674aadfc5c89d05157a9db93 100644 (file)
@@ -1300,26 +1300,32 @@ static char *read_line_from_git_path(const char *filename)
 static int split_commit_in_progress(struct wt_status *s)
 {
        int split_in_progress = 0;
-       char *head, *orig_head, *rebase_amend, *rebase_orig_head;
+       struct object_id head_oid, orig_head_oid;
+       char *rebase_amend, *rebase_orig_head;
+       int head_flags, orig_head_flags;
 
        if ((!s->amend && !s->nowarn && !s->workdir_dirty) ||
            !s->branch || strcmp(s->branch, "HEAD"))
                return 0;
 
-       head = read_line_from_git_path("HEAD");
-       orig_head = read_line_from_git_path("ORIG_HEAD");
+       if (read_ref_full("HEAD", RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
+                         &head_oid, &head_flags) ||
+           read_ref_full("ORIG_HEAD", RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
+                         &orig_head_oid, &orig_head_flags))
+               return 0;
+       if (head_flags & REF_ISSYMREF || orig_head_flags & REF_ISSYMREF)
+               return 0;
+
        rebase_amend = read_line_from_git_path("rebase-merge/amend");
        rebase_orig_head = read_line_from_git_path("rebase-merge/orig-head");
 
-       if (!head || !orig_head || !rebase_amend || !rebase_orig_head)
+       if (!rebase_amend || !rebase_orig_head)
                ; /* fall through, no split in progress */
        else if (!strcmp(rebase_amend, rebase_orig_head))
-               split_in_progress = !!strcmp(head, rebase_amend);
-       else if (strcmp(orig_head, rebase_orig_head))
+               split_in_progress = !!strcmp(oid_to_hex(&head_oid), rebase_amend);
+       else if (strcmp(oid_to_hex(&orig_head_oid), rebase_orig_head))
                split_in_progress = 1;
 
-       free(head);
-       free(orig_head);
        free(rebase_amend);
        free(rebase_orig_head);