Skip to content

Instantly share code, notes, and snippets.

@mattcree
Last active May 17, 2024 13:48
Show Gist options
  • Save mattcree/b5fcd364c97219465f37b62598db36b0 to your computer and use it in GitHub Desktop.
Save mattcree/b5fcd364c97219465f37b62598db36b0 to your computer and use it in GitHub Desktop.
Recreating a git log bug

Usage

Please find the reference repository here https://github.com/mattcree/reference-repository/raw/main/reference.tgz

There are three arguments for the script

  1. Path to git
  2. Name of folder to extract reference repository into
  3. Name of folder to clone test repository into

i.e.

$ ./induce.sh /usr/bin/git reference test-1

Running the script with the same args twice will simply run the problematic git log command

#!/bin/bash
git_path=$1
reference_repo=$2
clone_repo=$3
# Unzip into the first arg if it doesn't exist
if [ ! -d $reference_repo ]; then
tar -xzvf reference.tgz $reference_repo
fi
# Create the clone repo dir if it doesn't exist
if [ ! -d $clone_repo ]; then
mkdir $clone_repo
$git_path -c core.symlinks=false -c gc.auto=0 clone --reference ./$reference_repo --dissociate --filter=blob:none --no-checkout -b master https://github.com/mattcree/dissociate-clone-issue ./$clone_repo
fi
cd $clone_repo
if [ ! -f ".git/objects/pack/pack-9ed6acfb725ba7d4353b93ecb7f1f116568a4872.pack" ]; then
echo "Pack file does not exist"
else
echo "Pack file exists!"
fi
(set -x; GIT_TRACE=2 GIT_CURL_VERBOSE=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 GIT_TRACE_SETUP=2 GIT_TRACE_SHALLOW=2 $git_path -c core.symlinks=false -c gc.auto=0 -C . log -100 --first-parent --pretty="%H %an %ct %s" master b3447a67238c760aa2845d32e5eb95b96e67c733)
+ GIT_CURL_VERBOSE=2
12:07:25.510803 git.c:463 trace: built-in: git clone --reference ./reference --dissociate --filter=blob:none --no-checkout -b master https://github.com/mattcree/dissociate-clone-issue ./filtered
12:07:25.542735 run-command.c:657 trace: run_command: git remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:25.549898 git.c:750 trace: exec: git-remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:25.550687 run-command.c:657 trace: run_command: git-remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:25.958880 run-command.c:657 trace: run_command: unset GIT_CONFIG_PARAMETERS GIT_DIR; git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:25.965797 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/reference
12:07:25.966647 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/reference
12:07:25.966650 trace.c:316 setup: worktree: (null)
12:07:25.966651 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:25.966653 trace.c:318 setup: prefix: (null)
12:07:25.966654 git.c:463 trace: built-in: git for-each-ref '--format=%(objectname)'
12:07:25.968420 trace.c:414 performance: 0.003121000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:26.141936 run-command.c:657 trace: run_command: git index-pack --stdin --fix-thin '--keep=fetch-pack 47296 on Matt-Cree’s-MBP' --promisor
12:07:26.145079 trace.c:414 performance: 0.595477000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:26.151981 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.152968 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.152969 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:26.152971 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:26.152974 trace.c:318 setup: prefix: (null)
12:07:26.152976 git.c:463 trace: built-in: git index-pack --stdin --fix-thin '--keep=fetch-pack 47296 on Matt-Cree’s-MBP' --promisor
12:07:26.156674 trace.c:414 performance: 0.006013000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git index-pack --stdin --fix-thin '--keep=fetch-pack 47296 on Matt-Cree’s-MBP' --promisor
12:07:26.158069 run-command.c:657 trace: run_command: git rev-list --objects --stdin --exclude-promisor-objects --not --all --quiet --alternate-refs
12:07:26.165248 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.166270 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.166272 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:26.166285 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:26.166293 trace.c:318 setup: prefix: (null)
12:07:26.166295 git.c:463 trace: built-in: git rev-list --objects --stdin --exclude-promisor-objects --not --all --quiet --alternate-refs
12:07:26.168751 run-command.c:657 trace: run_command: unset GIT_CONFIG_PARAMETERS GIT_DIR GIT_PREFIX; git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:26.176018 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/reference
12:07:26.176942 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/reference
12:07:26.176946 trace.c:316 setup: worktree: (null)
12:07:26.176947 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:26.176948 trace.c:318 setup: prefix: (null)
12:07:26.176950 git.c:463 trace: built-in: git for-each-ref '--format=%(objectname)'
12:07:26.178363 trace.c:414 performance: 0.002871000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:26.179015 trace.c:414 performance: 0.014292000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git rev-list --objects --stdin --exclude-promisor-objects --not --all --quiet --alternate-refs
12:07:26.185646 run-command.c:657 trace: run_command: git repack -a -d
12:07:26.193171 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.194183 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.194185 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:26.194186 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:26.194189 trace.c:318 setup: prefix: (null)
12:07:26.194191 git.c:463 trace: built-in: git repack -a -d
12:07:26.195416 run-command.c:657 trace: run_command: git pack-objects --delta-base-offset <redacted>/commit-history-bug/filtered/.git/objects/pack/.tmp-47303-pack
12:07:26.201966 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.202563 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.202565 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:26.202566 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:26.202569 trace.c:318 setup: prefix: (null)
12:07:26.202572 git.c:463 trace: built-in: git pack-objects --delta-base-offset <redacted>/commit-history-bug/filtered/.git/objects/pack/.tmp-47303-pack
12:07:26.205451 trace.c:414 performance: 0.003816000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git pack-objects --delta-base-offset <redacted>/commit-history-bug/filtered/.git/objects/pack/.tmp-47303-pack
12:07:26.205746 run-command.c:657 trace: run_command: git pack-objects --delta-base-offset <redacted>/commit-history-bug/filtered/.git/objects/pack/.tmp-47303-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects --exclude-promisor-objects --keep-pack=.tmp-47303-pack-059e7aaa63f455bb24ac59c4af995ac3261f4ae3.pack
12:07:26.211999 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.212564 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/filtered/.git
12:07:26.212569 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:26.212570 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:26.212572 trace.c:318 setup: prefix: (null)
12:07:26.212574 git.c:463 trace: built-in: git pack-objects --delta-base-offset <redacted>/commit-history-bug/filtered/.git/objects/pack/.tmp-47303-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects --exclude-promisor-objects --keep-pack=.tmp-47303-pack-059e7aaa63f455bb24ac59c4af995ac3261f4ae3.pack
12:07:26.230423 trace.c:414 performance: 0.018731000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git pack-objects --delta-base-offset <redacted>/commit-history-bug/filtered/.git/objects/pack/.tmp-47303-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects --exclude-promisor-objects --keep-pack=.tmp-47303-pack-059e7aaa63f455bb24ac59c4af995ac3261f4ae3.pack
12:07:26.235095 trace.c:414 performance: 0.042390000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git repack -a -d
12:07:26.235681 trace.c:414 performance: 0.724927000 s: git command: /opt/homebrew/bin/git -c core.symlinks=false -c gc.auto=0 clone --reference ./reference --dissociate --filter=blob:none --no-checkout -b master https://github.com/mattcree/dissociate-clone-issue ./filtered
+ GIT_CURL_VERBOSE=2
12:07:26.242697 trace.c:314 setup: git_dir: .git
12:07:26.243462 trace.c:315 setup: git_common_dir: .git
12:07:26.243467 trace.c:316 setup: worktree: <redacted>/commit-history-bug/filtered
12:07:26.243468 trace.c:317 setup: cwd: <redacted>/commit-history-bug/filtered
12:07:26.243471 trace.c:318 setup: prefix: (null)
12:07:26.243472 git.c:463 trace: built-in: git log -100 --first-parent '--pretty=%H %an %ct %s' master b3447a67238c760aa2845d32e5eb95b96e67c733
12:07:26.245271 trace.c:414 performance: 0.002880000 s: git command: /opt/homebrew/bin/git -c core.symlinks=false -c gc.auto=0 log -100 --first-parent '--pretty=%H %an %ct %s' master b3447a67238c760aa2845d32e5eb95b96e67c733
+ GIT_CURL_VERBOSE=2
12:07:37.397484 git.c:463 trace: built-in: git clone --reference ./reference --dissociate --no-checkout -b master https://github.com/mattcree/dissociate-clone-issue ./not-filtered
12:07:37.421640 run-command.c:657 trace: run_command: git remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:37.428608 git.c:750 trace: exec: git-remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:37.429353 run-command.c:657 trace: run_command: git-remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:37.807763 run-command.c:657 trace: run_command: unset GIT_CONFIG_PARAMETERS GIT_DIR; git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:37.814804 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/reference
12:07:37.815718 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/reference
12:07:37.815722 trace.c:316 setup: worktree: (null)
12:07:37.815723 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:37.815724 trace.c:318 setup: prefix: (null)
12:07:37.815726 git.c:463 trace: built-in: git for-each-ref '--format=%(objectname)'
12:07:37.816838 trace.c:414 performance: 0.002778000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:37.984274 run-command.c:657 trace: run_command: git index-pack --stdin --fix-thin '--keep=fetch-pack 47450 on Matt-Cree’s-MBP' --check-self-contained-and-connected
12:07:37.985694 trace.c:414 performance: 0.557327000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git remote-https origin https://github.com/mattcree/dissociate-clone-issue
12:07:37.992154 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:37.992900 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:37.992902 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:37.992903 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:37.992905 trace.c:318 setup: prefix: (null)
12:07:37.992907 git.c:463 trace: built-in: git index-pack --stdin --fix-thin '--keep=fetch-pack 47450 on Matt-Cree’s-MBP' --check-self-contained-and-connected
12:07:37.996956 trace.c:414 performance: 0.006054000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git index-pack --stdin --fix-thin '--keep=fetch-pack 47450 on Matt-Cree’s-MBP' --check-self-contained-and-connected
12:07:37.997656 run-command.c:657 trace: run_command: git rev-list --objects --stdin --not --all --quiet --alternate-refs
12:07:38.009023 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:38.011735 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:38.011737 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:38.011744 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:38.011747 trace.c:318 setup: prefix: (null)
12:07:38.011748 git.c:463 trace: built-in: git rev-list --objects --stdin --not --all --quiet --alternate-refs
12:07:38.013873 run-command.c:657 trace: run_command: unset GIT_CONFIG_PARAMETERS GIT_DIR GIT_PREFIX; git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:38.020591 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/reference
12:07:38.021298 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/reference
12:07:38.021302 trace.c:316 setup: worktree: (null)
12:07:38.021303 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:38.021304 trace.c:318 setup: prefix: (null)
12:07:38.021306 git.c:463 trace: built-in: git for-each-ref '--format=%(objectname)'
12:07:38.022591 trace.c:414 performance: 0.002487000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git --git-dir=<redacted>/commit-history-bug/reference for-each-ref '--format=%(objectname)'
12:07:38.026916 trace.c:414 performance: 0.023285000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git rev-list --objects --stdin --not --all --quiet --alternate-refs
12:07:38.032060 run-command.c:657 trace: run_command: git repack -a -d
12:07:38.038606 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:38.039446 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:38.039451 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:38.039452 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:38.039455 trace.c:318 setup: prefix: (null)
12:07:38.039457 git.c:463 trace: built-in: git repack -a -d
12:07:38.040656 run-command.c:657 trace: run_command: git pack-objects --delta-base-offset <redacted>/commit-history-bug/not-filtered/.git/objects/pack/.tmp-47467-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects
12:07:38.047012 trace.c:314 setup: git_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:38.047547 trace.c:315 setup: git_common_dir: <redacted>/commit-history-bug/not-filtered/.git
12:07:38.047549 trace.c:316 setup: worktree: <redacted>/commit-history-bug
12:07:38.047550 trace.c:317 setup: cwd: <redacted>/commit-history-bug
12:07:38.047552 trace.c:318 setup: prefix: (null)
12:07:38.047554 git.c:463 trace: built-in: git pack-objects --delta-base-offset <redacted>/commit-history-bug/not-filtered/.git/objects/pack/.tmp-47467-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects
12:07:38.070112 trace.c:414 performance: 0.023463000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git pack-objects --delta-base-offset <redacted>/commit-history-bug/not-filtered/.git/objects/pack/.tmp-47467-pack --keep-true-parents --honor-pack-keep --non-empty --all --reflog --indexed-objects
12:07:38.074524 trace.c:414 performance: 0.036304000 s: git command: /opt/homebrew/opt/git/libexec/git-core/git repack -a -d
12:07:38.075106 trace.c:414 performance: 0.677636000 s: git command: /opt/homebrew/bin/git -c core.symlinks=false -c gc.auto=0 clone --reference ./reference --dissociate --no-checkout -b master https://github.com/mattcree/dissociate-clone-issue ./not-filtered
+ GIT_CURL_VERBOSE=2
12:07:38.083647 trace.c:314 setup: git_dir: .git
12:07:38.084302 trace.c:315 setup: git_common_dir: .git
12:07:38.084304 trace.c:316 setup: worktree: <redacted>/commit-history-bug/not-filtered
12:07:38.084306 trace.c:317 setup: cwd: <redacted>/commit-history-bug/not-filtered
12:07:38.084309 trace.c:318 setup: prefix: (null)
12:07:38.084311 git.c:463 trace: built-in: git log -100 --first-parent '--pretty=%H %an %ct %s' master b3447a67238c760aa2845d32e5eb95b96e67c733
12:07:38.086281 trace.c:414 performance: 0.003053000 s: git command: /opt/homebrew/bin/git -c core.symlinks=false -c gc.auto=0 log -100 --first-parent '--pretty=%H %an %ct %s' master b3447a67238c760aa2845d32e5eb95b96e67c733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment