Message ID | a20bf8de8645c19a02838d70a7c2c3b00378a50d.1670433958.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Optionally skip hashing index on write | expand |
On Wed, Dec 07 2022, Derrick Stolee via GitGitGadget wrote: > From: Derrick Stolee <derrickstolee@github.com> > [...] > +# Given a filename, extract its trailing hash as a hex string > +test_trailing_hash () { > + local file="$1" && > + tail -c $(test_oid rawsz) "$file" | \ > + test-tool hexdump | \ You don't need the "\"'s here. > + sed "s/ //g" > +} At the end of this series we have one test file using this test_trailing_hash, can't we just add it to t1600-index.sh?
On 12/7/2022 5:27 PM, Ævar Arnfjörð Bjarmason wrote: > > On Wed, Dec 07 2022, Derrick Stolee via GitGitGadget wrote: > >> From: Derrick Stolee <derrickstolee@github.com> >> [...] >> +# Given a filename, extract its trailing hash as a hex string >> +test_trailing_hash () { >> + local file="$1" && >> + tail -c $(test_oid rawsz) "$file" | \ >> + test-tool hexdump | \ > > You don't need the "\"'s here. Thanks. >> + sed "s/ //g" >> +} > > At the end of this series we have one test file using this > test_trailing_hash, can't we just add it to t1600-index.sh? I imagine that it would be helpful to access the trailing hash for testing other file formats in the future. It certainly could have helped the incremental commit-graph work, so we could check that the filenames do match the trailing hashes. Thanks, -Stolee
diff --git a/t/t1600-index.sh b/t/t1600-index.sh index df07c587e0e..55816756607 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -69,6 +69,9 @@ test_expect_success 'index.skipHash config option' ' ( rm -f .git/index && git -c index.skipHash=true add a && + test_trailing_hash .git/index >hash && + echo $(test_oid zero) >expect && + test_cmp expect hash && git fsck ) ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 796093a7b32..e88acfdb68a 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1875,3 +1875,11 @@ test_cmp_config_output () { sort config-actual >sorted-actual && test_cmp sorted-expect sorted-actual } + +# Given a filename, extract its trailing hash as a hex string +test_trailing_hash () { + local file="$1" && + tail -c $(test_oid rawsz) "$file" | \ + test-tool hexdump | \ + sed "s/ //g" +}