From: drafnel@gmail.com
To: gitster@pobox.com
Cc: git@vger.kernel.org, Brandon Casey <drafnel@gmail.com>
Subject: [PATCH 1/3] repack: modify behavior of -A option to leave unreferenced objects unpacked
Date: Fri, 9 May 2008 23:01:55 -0500 [thread overview]
Message-ID: <3927888.1210392047922.JavaMail.teamon@b303.teamon.com> (raw)
In-Reply-To: <7vabj0b1re.fsf@gitster.siamese.dyndns.org>
From: Brandon Casey <drafnel@gmail.com>
The previous behavior of the -A option was to retain any previously
packed objects which had become unreferenced, and place them into the newly
created pack file. Since git-gc, when run automatically with the --auto
option, calls repack with the -A option, this had the effect of retaining
unreferenced packed objects indefinitely. To avoid this scenario, the
user was required to run git-gc with the little known --prune option or
to manually run repack with the -a option.
This patch changes the behavior of the -A option so that unreferenced
objects that exist in any pack file being replaced, will be unpacked into
the repository. The unreferenced loose objects can then be garbage collected
by git-gc (i.e. git-prune) based on the gc.pruneExpire setting.
Also add new tests for checking whether unreferenced objects which were
previously packed are properly left in the repository unpacked after
repacking.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
git-repack.sh | 18 +++++++++---
t/t7701-repack-unpack-unreachable.sh | 47 ++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 5 deletions(-)
create mode 100755 t/t7701-repack-unpack-unreachable.sh
diff --git a/git-repack.sh b/git-repack.sh
index e18eb3f..a0e06ed 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -30,7 +30,7 @@ do
-n) no_update_info=t ;;
-a) all_into_one=t ;;
-A) all_into_one=t
- keep_unreachable=--keep-unreachable ;;
+ keep_unreachable=t ;;
-d) remove_redundant=t ;;
-q) quiet=-q ;;
-f) no_reuse=--no-reuse-object ;;
@@ -78,9 +78,6 @@ case ",$all_into_one," in
if test -z "$args"
then
args='--unpacked --incremental'
- elif test -n "$keep_unreachable"
- then
- args="$args $keep_unreachable"
fi
;;
esac
@@ -130,7 +127,18 @@ then
do
case " $fullbases " in
*" $e "*) ;;
- *) rm -f "$e.pack" "$e.idx" "$e.keep" ;;
+ *)
+ rm -f "$e.idx" "$e.keep"
+ if test -n "$keep_unreachable" &&
+ test -f "$e.pack"
+ then
+ git unpack-objects < "$e.pack" || {
+ echo >&2 "Failed unpacking unreachable objects from redundant pack file $e.pack"
+ exit 1
+ }
+ fi
+ rm -f "$e.pack"
+ ;;
esac
done
)
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
new file mode 100755
index 0000000..6a5211f
--- /dev/null
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+test_description='git-repack works correctly'
+
+. ./test-lib.sh
+
+test_expect_success '-A option leaves unreachable objects unpacked' '
+ echo content > file1 &&
+ git add . &&
+ git commit -m initial_commit &&
+ # create a transient branch with unique content
+ git checkout -b transient_branch &&
+ echo more content >> file1 &&
+ # record the objects created in the database for file, commit, tree
+ fsha1=$(git hash-object file1) &&
+ git commit -a -m more_content &&
+ csha1=$(git rev-parse HEAD^{commit}) &&
+ tsha1=$(git rev-parse HEAD^{tree}) &&
+ git checkout master &&
+ echo even more content >> file1 &&
+ git commit -a -m even_more_content &&
+ # delete the transient branch
+ git branch -D transient_branch &&
+ # pack the repo
+ git repack -A -d -l &&
+ # verify objects are packed in repository
+ test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+ grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
+ sort | uniq | wc -l) &&
+ git show $fsha1 &&
+ git show $csha1 &&
+ git show $tsha1 &&
+ # now expire the reflog
+ sleep 1 &&
+ git reflog expire --expire-unreachable=now --all &&
+ # and repack
+ git repack -A -d -l &&
+ # verify objects are retained unpacked
+ test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+ grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
+ sort | uniq | wc -l) &&
+ git show $fsha1 &&
+ git show $csha1 &&
+ git show $tsha1
+'
+
+test_done
--
1.5.5.67.g9a49
next prev parent reply other threads:[~2008-05-10 4:02 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-08 17:45 git gc & deleted branches Guido Ostkamp
2008-05-08 18:39 ` Jeff King
2008-05-08 18:55 ` Guido Ostkamp
2008-05-08 20:07 ` Brandon Casey
2008-05-08 20:52 ` Guido Ostkamp
2008-05-08 21:01 ` Jeff King
2008-05-08 21:15 ` Nicolas Pitre
2008-05-08 21:17 ` Jeff King
2008-05-08 21:23 ` Brandon Casey
2008-05-08 21:31 ` Jeff King
2008-05-08 21:40 ` Brandon Casey
2008-05-08 21:44 ` Jeff King
2008-05-08 21:53 ` Brandon Casey
2008-05-08 22:48 ` Jeff King
2008-05-09 1:41 ` Brandon Casey
2008-05-09 3:21 ` Junio C Hamano
[not found] ` <ee63ef30805082105w7f04a2d1y65a4618aeb787cac@mail.gmail.com>
[not found] ` <7v1w4bb291.fsf@gitster.siamese.dyndns.org>
2008-05-10 3:32 ` Brandon Casey
2008-05-10 4:15 ` Brandon Casey
2008-05-10 4:01 ` [PATCH 0/3] leave unreferenced objects unpacked drafnel
2008-05-10 4:01 ` drafnel [this message]
2008-05-10 6:03 ` [PATCH 1/3] repack: modify behavior of -A option to " Jeff King
2008-05-11 1:10 ` Nicolas Pitre
2008-05-11 1:23 ` Junio C Hamano
2008-05-11 4:16 ` Brandon Casey
2008-05-11 4:51 ` Brandon Casey
2008-05-10 4:01 ` [PATCH 2/3] git-gc: always use -A when manually repacking drafnel
2008-05-10 4:01 ` [PATCH 3/3] builtin-gc.c: deprecate --prune, it now really has no effect drafnel
2008-05-09 4:19 ` git gc & deleted branches Jeff King
2008-05-09 15:00 ` Geert Bosch
2008-05-09 15:14 ` Brandon Casey
2008-05-09 15:53 ` Jeff King
2008-05-09 15:56 ` Brandon Casey
2008-05-09 16:12 ` Nicolas Pitre
2008-05-09 16:54 ` Brandon Casey
2008-05-09 22:33 ` Junio C Hamano
2008-05-09 23:09 ` [PATCH] Updating documentation to match Brandon Casey's proposed git-repack patch Chris Frey
2008-05-10 0:07 ` git gc & deleted branches Jeremy Maitin-Shepard
2008-05-10 0:20 ` Shawn O. Pearce
2008-05-10 0:43 ` Jeremy Maitin-Shepard
2008-05-10 1:21 ` Junio C Hamano
2008-05-10 1:51 ` Jeremy Maitin-Shepard
2008-05-10 5:25 ` Jeff King
2008-05-10 5:36 ` Jeremy Maitin-Shepard
2008-05-10 9:04 ` Johannes Schindelin
2008-05-10 16:24 ` Jeremy Maitin-Shepard
2008-05-11 11:11 ` Johannes Schindelin
2008-05-11 18:39 ` Junio C Hamano
2008-05-08 21:33 ` Guido Ostkamp
2008-05-08 20:56 ` Jeff King
2008-05-08 20:51 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3927888.1210392047922.JavaMail.teamon@b303.teamon.com \
--to=drafnel@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).