Skip to content

Unset objectFormat in git init#1048

Merged
j178 merged 2 commits intomasterfrom
object-format
Nov 9, 2025
Merged

Unset objectFormat in git init#1048
j178 merged 2 commits intomasterfrom
object-format

Conversation

@j178
Copy link
Owner

@j178 j178 commented Nov 8, 2025

Trying to workaround #1028

@j178 j178 added the enhancement New feature or request label Nov 8, 2025
@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.82%. Comparing base (1032757) to head (056bd68).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1048   +/-   ##
=======================================
  Coverage   89.81%   89.82%           
=======================================
  Files          72       72           
  Lines       13290    13292    +2     
=======================================
+ Hits        11936    11939    +3     
+ Misses       1354     1353    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Nov 8, 2025

📦 Cargo Bloat Comparison

Binary size change: +0.00% (16.2 MiB → 16.2 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size          Crate Name
 0.6%   1.3% 101.3KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3%  97.4KiB           prek prek::builtin::pre_commit_hooks::Implemented::run::{{closure}}
 0.6%   1.2%  94.2KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}
 0.4%   1.0%  72.7KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.6%  48.8KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.4%  32.5KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.4%  32.3KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  31.9KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  31.5KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  30.7KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.3%  25.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.2%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.8KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.8KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::languages::golang::installer::GoInstaller::install::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
39.9%  87.6%   6.5MiB                And 10186 smaller methods. Use -n N to show more.
45.6% 100.0%   7.4MiB                .text section size, the file size is 16.2MiB

Base Branch Results

 File  .text     Size          Crate Name
 0.6%   1.3% 101.3KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3%  97.4KiB           prek prek::builtin::pre_commit_hooks::Implemented::run::{{closure}}
 0.6%   1.2%  94.2KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}
 0.4%   1.0%  72.7KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.6%  48.8KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.1KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.4%  32.5KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.2%   0.4%  32.3KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  31.9KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  31.5KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  30.7KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.3%  25.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.2%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.8KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.8KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::languages::golang::installer::GoInstaller::install::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
39.9%  87.6%   6.5MiB                And 10186 smaller methods. Use -n N to show more.
45.6% 100.0%   7.4MiB                .text section size, the file size is 16.2MiB

@FirelightFlagboy
Copy link

I tested your proposed fix using the same sample configuration:

Nixpkgs override to use the proposed patch:
pkgs.prek.overrideAttrs (
        final: old:
        let
          rev = "427e63f5e3d211849e3f3bdfb92c8d509f61d13d";
        in
        {
          version = old.version + "+dev.${builtins.substring 0 6 rev}";
          src = pkgs.fetchFromGitHub {
            owner = "j178";
            repo = "prek";
            inherit rev;
            sha256 = "sha256-+8ff6YVnuERyHMH7/1l7hcXBZMF0lQ3AMSLEBJRyj2A=";
            # sha256 = pkgs.lib.fakeSha256;
          };
          cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
            inherit (final) pname src version;
            hash = "sha256-o2+ssBIwDRgtZ8B8AUyqIquGcsCqAz/+30ExREu0QJU=";
          };
          cargoSha256 = pkgs.lib.fakeSha256;
          doCheck = false;
        }
      )

I get the following error:

DEBUG prek: 0.2.13
DEBUG Args: ["prek", "-vvv"]
DEBUG Git root: /tmp/foo
TRACE Executing `/etc/profiles/per-user/redacted/bin/git ls-files --unmerged`
DEBUG Found workspace root at `/tmp/foo`
TRACE Include selectors: ``
TRACE Skip selectors: ``
DEBUG discover{root="/tmp/foo" config=None refresh=false}: Loaded workspace from cache
DEBUG discover{root="/tmp/foo" config=None refresh=false}: Loading project configuration path=.pre-commit-config.yaml
TRACE discover{root="/tmp/foo" config=None refresh=false}: close time.busy=245µs time.idle=1.89µs
TRACE Executing `/etc/profiles/per-user/redacted/bin/git diff --exit-code --name-only -z /tmp/foo/.pre-commit-config.yaml`
TRACE Checking lock resource="store" path=/home/redacted/.cache/prek/.lock
DEBUG Acquired lock resource="store"
DEBUG Cloning repo target=/home/redacted/.cache/prek/scratch/.tmp810YP3 repo=https://github.com/pre-commit/pre-commit-hooks@v6.0.0
TRACE Executing `/etc/profiles/per-user/redacted/bin/git init --template= /home/redacted/.cache/prek/scratch/.tmp810YP3`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmp810YP3 && /etc/profiles/per-user/redacted/bin/git config --unset extensions.objectFormat`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmp810YP3 && /etc/profiles/per-user/redacted/bin/git remote add origin https://github.com/pre-commit/pre-commit-hooks`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmp810YP3 && /etc/profiles/per-user/redacted/bin/git fetch origin v6.0.0 --depth=1`
 WARN Failed to shallow clone, falling back to full clone err=Command(Status { summary: "git shallow clone", error: StatusError { status: ExitStatus(unix_wait_status(64768)), output: Some(Output { status: ExitStatus(unix_wait_status(64768)), stdout: "", stderr: "From https://github.com/pre-commit/pre-commit-hooks\n * tag               v6.0.0     -> FETCH_HEAD\nerror: reftable: transaction prepare: corrupt reftable file\n" }) } })
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmp810YP3 && /etc/profiles/per-user/redacted/bin/git fetch origin --tags`
TRACE Released lock path=/home/redacted/.cache/prek/.lock
error: Failed to initialize repo `https://github.com/pre-commit/pre-commit-hooks`
  caused by: Command `git full clone` exited with an error:

[status]
signal: 11 (SIGSEGV) (core dumped)

Note

The additional step git config --unset ... is correctly executed

I've tried to replicate the error manually and I get the same result (an error):

$ git init /tmp/bar
Initialized empty Git repository in /tmp/bar/.git/
$ cd bar
$ git config --unset extensions.objectformat
$ git config extensions.objectformat      
sha256
$ git remote add origin https://github.com/pre-commit/pre-commit-hooks
$ git fetch origin v6.0.0 --depth=1                                   
remote: Enumerating objects: 111, done.
remote: Counting objects: 100% (111/111), done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 111 (delta 8), reused 44 (delta 6), pack-reused 0 (from 0)
Receiving objects: 100% (111/111), 67.23 KiB | 3.73 MiB/s, done.
Resolving deltas: 100% (8/8), done.
From https://github.com/pre-commit/pre-commit-hooks
 * tag               v6.0.0     -> FETCH_HEAD
error: reftable: transaction prepare: corrupt reftable file

I've tried to go a little further manually and I think I've found something that work:

$ git -c init.defaultobjectformat='' init /tmp/bar
warning: unknown hash algorithm ''
Initialized empty Git repository in /tmp/bar/.git/
$ cd /tmp/bar
$ git remote add origin https://github.com/pre-commit/pre-commit-hooks
$ git fetch origin v6.0.0 --depth=1
remote: Enumerating objects: 111, done.
remote: Counting objects: 100% (111/111), done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 111 (delta 8), reused 44 (delta 6), pack-reused 0 (from 0)
Receiving objects: 100% (111/111), 67.23 KiB | 3.20 MiB/s, done.
Resolving deltas: 100% (8/8), done.
From https://github.com/pre-commit/pre-commit-hooks
 * tag               v6.0.0     -> FETCH_HEAD

@j178
Copy link
Owner Author

j178 commented Nov 8, 2025

Weird, the git config --unset trick works on my Mac. I'll try git -c init.defaultobjectformat='' init.

@j178 j178 changed the title Unset extensions.objectFormat in the remote repo Unset objectFormat in git init Nov 8, 2025
@j178
Copy link
Owner Author

j178 commented Nov 9, 2025

@FirelightFlagboy Can you try this patch again?

Copy link

@FirelightFlagboy FirelightFlagboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work 💪

$ prek -vvv             
DEBUG prek: 0.2.13
DEBUG Args: ["prek", "-vvv"]
DEBUG Git root: /tmp/foo
TRACE Executing `/etc/profiles/per-user/redacted/bin/git ls-files --unmerged`
DEBUG Found workspace root at `/tmp/foo`
TRACE Include selectors: ``
TRACE Skip selectors: ``
DEBUG discover{root="/tmp/foo" config=None refresh=false}: Performing fresh workspace discovery
DEBUG Loading project configuration path=.pre-commit-config.yaml
TRACE discover{root="/tmp/foo" config=None refresh=false}: close time.busy=2.06ms time.idle=1.55µs
TRACE Executing `/etc/profiles/per-user/redacted/bin/git diff --exit-code --name-only -z /tmp/foo/.pre-commit-config.yaml`
TRACE Checking lock resource="store" path=/home/redacted/.cache/prek/.lock
DEBUG Acquired lock resource="store"
DEBUG Cloning repo target=/home/redacted/.cache/prek/scratch/.tmpYNzplN repo=https://github.com/pre-commit/pre-commit-hooks@v6.0.0
TRACE Executing `/etc/profiles/per-user/redacted/bin/git -c init.defaultObjectFormat= init --template= /home/redacted/.cache/prek/scratch/.tmpYNzplN`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmpYNzplN && /etc/profiles/per-user/redacted/bin/git remote add origin https://github.com/pre-commit/pre-commit-hooks`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmpYNzplN && /etc/profiles/per-user/redacted/bin/git fetch origin v6.0.0 --depth=1`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmpYNzplN && /etc/profiles/per-user/redacted/bin/git checkout FETCH_HEAD`
TRACE Executing `cd /home/redacted/.cache/prek/scratch/.tmpYNzplN && /etc/profiles/per-user/redacted/bin/git submodule update --init --recursive --depth=1`
DEBUG Hooks going to run: ["mixed-line-ending", "trailing-whitespace"]
DEBUG No matching environment found for hook `mixed-line-ending`, installing...
DEBUG Found uv in PATH: /nix/store/n6chrdybb91npp8gvf8mjk55smx4sn8s-uv-0.8.23/bin/uv
TRACE Using system uv version 0.8.23 at /nix/store/n6chrdybb91npp8gvf8mjk55smx4sn8s-uv-0.8.23/bin/uv
DEBUG Installing environment hook=mixed-line-ending target=/home/redacted/.cache/prek/hooks/python-3D5V2qtv6tsNtL88eh0F
TRACE Executing `/nix/store/n6chrdybb91npp8gvf8mjk55smx4sn8s-uv-0.8.23/bin/uv venv /home/redacted/.cache/prek/hooks/python-3D5V2qtv6tsNtL88eh0F --python-preference managed --no-project [...]`
DEBUG Venv created successfully with no downloads: `/home/redacted/.cache/prek/hooks/python-3D5V2qtv6tsNtL88eh0F`
TRACE Installing dependencies from repo path: /home/redacted/.cache/prek/repos/9f2aecb6df5c72eb
TRACE Executing `cd /home/redacted/.cache/prek/repos/9f2aecb6df5c72eb && /nix/store/n6chrdybb91npp8gvf8mjk55smx4sn8s-uv-0.8.23/bin/uv pip install .`
TRACE Executing `/home/redacted/.cache/prek/hooks/python-3D5V2qtv6tsNtL88eh0F/bin/python -I -c import sys
print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
print(sys.base_exec_prefix)
 [...]`
DEBUG Installed hook `mixed-line-ending` in `/home/redacted/.cache/prek/hooks/python-3D5V2qtv6tsNtL88eh0F`
DEBUG Found installed environment for hook `trailing-whitespace` at `/home/redacted/.cache/prek/hooks/python-3D5V2qtv6tsNtL88eh0F`
TRACE Released lock path=/home/redacted/.cache/prek/.lock
TRACE Executing `/etc/profiles/per-user/redacted/bin/git diff --diff-filter=A --name-only -z -- /tmp/foo`
TRACE Executing `/etc/profiles/per-user/redacted/bin/git write-tree`
TRACE Executing `/etc/profiles/per-user/redacted/bin/git diff-index --binary --exit-code 6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321 -- /tmp/foo [...]`
DEBUG Working tree is clean
TRACE Executing `/etc/profiles/per-user/redacted/bin/git rev-parse --git-dir`
TRACE Executing `cd /tmp/foo && /etc/profiles/per-user/redacted/bin/git diff --cached --name-only --diff-filter=ACMRTUXB -z`
DEBUG Staged files: 0
TRACE Executing `/etc/profiles/per-user/redacted/bin/git diff -- /tmp/foo`
TRACE Files for project `.` after filtered: 0
TRACE Files for hook `mixed-line-ending` after filtered: 0
mixed line ending....................................(no files to check)Skipped
TRACE Files for hook `trailing-whitespace` after filtered: 0
trim trailing whitespace.............................(no files to check)Skipped

@j178 j178 merged commit 2f52478 into master Nov 9, 2025
21 checks passed
@j178 j178 deleted the object-format branch November 9, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants