git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/5] t7700-repack: add two new tests demonstrating repacking flaws

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Mar 20, 2009, 03:47 UTC
Message-ID
<t_s5aa51o2kq_ePRWgLTEpak5ue1ZM7YICzIF-RsnmN68psiOC0Tnz9bsH5tTxgVEU0bxG-OtJ8@cipher.nrlssc.navy.mil>
In-Reply-To
<t_s5aa51o2kq_ePRWgLTEkVg4HqH1dQa6_mVq4djPPG4Vxylm2hNqmx7fPC2W5AsfcXg83DYbGc@cipher.nrlssc.navy.mil>
  1) The new --kept-pack-only mechansim of rev-list/pack-objects has
     replaced --unpacked=.  This new mechansim does not operate solely on
     "local" packs now.  The result is that objects residing in an alternate
     pack which has a .keep file will not be repacked with repack -a.
     This flaw is only apparent when a commit object is the one residing in
     an alternate kept pack.
  2) The 'repack unpacked objects' and 'loosen unpacked objects' mechanisms
     of pack-objects, i.e. --keep-unreachable and --unpack-unreachable,
     now do not operate solely on local packs.  The --keep-unreachable
     option no longer has any callers, but --unpack-unreachable is used when
     repack is called with '-A -d' and the local repo has existing packs.
     In this case, objects residing in alternate, not-kept packs will be
     loosened, and then immediately deleted by repack's call to
     prune-packed.
     The test must manually call pack-objects to avoid the call to
     prune-packed that is made by repack when -d is used.
---
 t/t7700-repack.sh |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index f5682d6..e869995 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -88,5 +88,49 @@ test_expect_failure 'packed obs in alt ODB are repacked when local repo has pack
 	done
 '
 
+test_expect_failure 'packed obs in alternate ODB kept pack are repacked' '
+	# swap the .keep so the commit object is in the pack with .keep
+	for p in alt_objects/pack/*.pack
+	do
+		base_name=$(basename $p .pack)
+		if test -f alt_objects/pack/$base_name.keep
+		then
+			rm alt_objects/pack/$base_name.keep
+		else
+			touch alt_objects/pack/$base_name.keep
+		fi
+	done
+	git repack -a -d &&
+	myidx=$(ls -1 .git/objects/pack/*.idx) &&
+	test -f "$myidx" &&
+	for p in alt_objects/pack/*.idx; do
+		git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
+	done | while read sha1 rest; do
+		if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
+			echo "Missing object in local pack: $sha1"
+			return 1
+		fi
+	done
+'
+
+test_expect_failure 'packed unreachable obs in alternate ODB are not loosened' '
+	rm -f alt_objects/pack/*.keep &&
+	mv .git/objects/pack/* alt_objects/pack/ &&
+	csha1=$(git rev-parse HEAD^{commit}) &&
+	git reset --hard HEAD^ &&
+	sleep 1 &&
+	git reflog expire --expire=now --expire-unreachable=now --all &&
+	# The pack-objects call on the next line is equivalent to
+	# git repack -A -d without the call to prune-packed
+	git pack-objects --honor-pack-keep --non-empty --all --reflog \
+	    --unpack-unreachable </dev/null pack &&
+	rm -f .git/objects/pack/* &&
+	mv pack-* .git/objects/pack/ &&
+	test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+		egrep "^$csha1 " | sort | uniq | wc -l) &&
+	echo > .git/objects/info/alternates &&
+	test_must_fail git show $csha1
+'
+
 test_done
 
-- 
1.6.2.16.geb16e
Previous: Brandon CaseyNext: Brandon Casey
Message 12 of 17 in “"git repack -a -d" improvements”
  1. 0/6 "git repack -a -d" improvementsJunio C Hamano, Feb 28, 2009
  2. 1/6 git-repack: resist stray environment variableJunio C Hamano, Feb 28, 2009
  3. 2/6 has_sha1_pack(): refactor "pretend these packs do not exist" interfaceJunio C Hamano, Feb 28, 2009
  4. 3/6 has_sha1_kept_pack(): take "struct rev_info"Junio C Hamano, Feb 28, 2009
  5. 4/6 Consolidate ignore_packed logic moreJunio C Hamano, Feb 28, 2009
  6. 5/6 Simplify is_kept_pack()Junio C Hamano, Feb 28, 2009
  7. 6/6 is_kept_pack(): final clean-upJunio C Hamano, Feb 28, 2009
  8. Kjetil BarvikFeb 28, 2009
  9. Junio C HamanoFeb 28, 2009
  10. Brandon CaseyMar 18, 2009
  11. 0/5 repack improvementsBrandon Casey, Mar 20, 2009
  12. 1/5 t7700-repack: add two new tests demonstrating repacking flawsBrandon Casey, Mar 20, 2009
  13. 2/5 git-repack.sh: don't use --kept-pack-only option to pack-objectsBrandon Casey, Mar 20, 2009
  14. 3/5 pack-objects: only repack or loosen objects residing in "local" packsBrandon Casey, Mar 20, 2009
  15. 4/5 t7700-repack: repack -a now works properly, expect success from testBrandon Casey, Mar 20, 2009
  16. 5/5 Remove --kept-pack-only option and associated infrastructureBrandon Casey, Mar 20, 2009
  17. Brandon CaseyMar 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.