All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nicolas Pitre" <nico@fluxnic.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 09/10] repack: add --pack-version and fall back to core.preferredPackVersion
Date: Thu, 26 Sep 2013 09:26:48 +0700	[thread overview]
Message-ID: <1380162409-18224-10-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1380162409-18224-1-git-send-email-pclouds@gmail.com>


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-repack.txt |  6 +++++-
 git-repack.sh                |  8 +++++++-
 t/t7700-repack.sh            | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 4c1aff6..c43eb4a 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -9,7 +9,7 @@ git-repack - Pack unpacked objects in a repository
 SYNOPSIS
 --------
 [verse]
-'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [--window=<n>] [--depth=<n>]
+'git repack' [options]
 
 DESCRIPTION
 -----------
@@ -110,6 +110,10 @@ other objects in that pack they already have locally.
 	The default is unlimited, unless the config variable
 	`pack.packSizeLimit` is set.
 
+--pack-version=<version>::
+	Force the version for the generated pack.
+	Valid values are 2 and 4. Default value is specified by
+	core.preferredPackVersion setting. See linkgit:git-config[1].
 
 Configuration
 -------------
diff --git a/git-repack.sh b/git-repack.sh
index 7579331..0d898eb 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -21,12 +21,13 @@ window=         size of the window used for delta compression
 window-memory=  same as the above, but limit memory size instead of entries count
 depth=          limits the maximum delta depth
 max-pack-size=  maximum size of each packfile
+pack-version=   format version of the output pack
 "
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
 no_update_info= all_into_one= remove_redundant= unpack_unreachable=
-local= no_reuse= extra=
+local= no_reuse= extra= packver=
 while test $# != 0
 do
 	case "$1" in
@@ -43,6 +44,8 @@ do
 	-l)	local=--local ;;
 	--max-pack-size|--window|--window-memory|--depth)
 		extra="$extra $1=$2"; shift ;;
+	--pack-version)
+		packver="$2"; shift ;;
 	--) shift; break;;
 	*)	usage ;;
 	esac
@@ -92,6 +95,9 @@ esac
 
 mkdir -p "$PACKDIR" || exit
 
+[ -n "$packver" ] || packver="`git config --int core.preferredPackVersion`"
+[ -n "$packver" ] && args="$args --version=$packver"
+
 args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
 names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
 	exit 1
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index d954b84..8383e1b 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -164,5 +164,40 @@ test_expect_success 'objects made unreachable by grafts only are kept' '
 	git cat-file -t $H1
 	'
 
+test_expect_success 'repack respects core.preferredPackVersion' '
+	git init pv4 &&
+	(
+		unset GIT_TEST_PACKV4 &&
+		cd pv4 &&
+		test_commit one &&
+		test_commit two &&
+		test_commit three &&
+		git config core.preferredPackVersion 4 &&
+		git repack -ad &&
+		P=`ls .git/objects/pack/pack-*.pack` &&
+		# Offset 4 is pack version
+		test-dump ntohl "$P" 4 >ver.actual &&
+		echo 4 >ver.expected &&
+		test_cmp ver.expected ver.actual
+	)
+'
+
+test_expect_success 'repack --pack-version=4' '
+	git init pv4.2 &&
+	(
+		unset GIT_TEST_PACKV4 &&
+		cd pv4.2 &&
+		test_commit one &&
+		test_commit two &&
+		test_commit three &&
+		git repack -ad --pack-version=4 &&
+		P=`ls .git/objects/pack/pack-*.pack` &&
+		# Offset 4 is pack version
+		test-dump ntohl "$P" 4 >ver.actual &&
+		echo 4 >ver.expected &&
+		test_cmp ver.expected ver.actual
+	)
+'
+
 test_done
 
-- 
1.8.2.82.gc24b958

  parent reply	other threads:[~2013-09-26  2:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-26  2:26 [PATCH 00/10] pack v4 UI support Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 01/10] test-dump: new test program to examine binary data Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 02/10] config: add core.preferredPackVersion Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 03/10] upload-pack: new capability to send pack v4 Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 04/10] fetch: new option to set preferred pack version for transfer Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 05/10] clone: " Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 06/10] fetch: pack v4 support on smart http Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` [PATCH 07/10] receive-pack: request for packv4 if it's the preferred version Nguyễn Thái Ngọc Duy
2013-10-17 17:26   ` Junio C Hamano
2013-09-26  2:26 ` [PATCH 08/10] send-pack: support pack v4 Nguyễn Thái Ngọc Duy
2013-09-26  2:26 ` Nguyễn Thái Ngọc Duy [this message]
2013-09-26  8:32   ` [PATCH] repack: Add --version parameter Stefan Beller
2013-09-26 10:17     ` Felipe Contreras
2013-09-28  8:53       ` Stefan Beller
2013-09-26 11:42     ` Duy Nguyen
2013-09-28  8:54       ` Stefan Beller
2013-09-26  2:26 ` [PATCH 10/10] count-objects: report pack v4 usage Nguyễn Thái Ngọc Duy
2013-09-26  4:51 ` [PATCH 00/10] pack v4 UI support Nicolas Pitre
2013-09-26  5:09   ` Duy Nguyen
2013-09-27  2:59     ` Nicolas Pitre

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=1380162409-18224-10-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=nico@fluxnic.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.