From: Nguyễn Thái Ngọc Duy Date: Sun, 05 Sep 2010 06:47:32 GMT Subject: [PATCH 05/17] pack-objects: support narrow packs with pathspecs Message-ID: <1283669264-15759-6-git-send-email-pclouds@gmail.com> In-Reply-To: <1283669264-15759-1-git-send-email-pclouds@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/git-pack-objects.txt | 2 +- builtin/pack-objects.c | 18 ++++++++++++++++-- t/t6000-rev-list-misc.sh | 9 +++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index 8ed09c0..cad8c06 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -13,7 +13,7 @@ SYNOPSIS [--no-reuse-delta] [--delta-base-offset] [--non-empty] [--local] [--incremental] [--window=N] [--depth=N] [--revs [--unpacked | --all]*] [--stdout | base-name] - [--keep-true-parents] < object-list + [--keep-true-parents] [ -- path... ] < object-list DESCRIPTION diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 789f6bf..26044b8 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -30,8 +30,8 @@ static const char pack_usage[] = " [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset]\n" " [--threads=N] [--non-empty] [--revs [--unpacked | --all]*]\n" " [--reflog] [--stdout | base-name] [--include-tag]\n" - " [--keep-unreachable | --unpack-unreachable \n" - " [= rp_ac_alloc) { + rp_ac_alloc = rp_ac + (argc-i) + 1; + rp_av = xrealloc(rp_av, rp_ac_alloc * sizeof(*rp_av)); + } + memcpy(rp_av+rp_ac, argv+i, sizeof(*argv)*(argc-i)); + rp_ac += argc-i; + } + if (!pack_to_stdout && !pack_size_limit) pack_size_limit = pack_size_limit_cfg; if (pack_to_stdout && pack_size_limit) diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh index b6a7c9c..0386313 100755 --- a/t/t6000-rev-list-misc.sh +++ b/t/t6000-rev-list-misc.sh @@ -31,6 +31,15 @@ test_expect_success 'rev-list --objects with pathspecs and deeper paths' ' ! grep unwanted_file output ' +test_expect_success 'pack-objects with pathspecs' ' + echo HEAD|git pack-objects --revs --stdout -- foo > output.pack && + git index-pack --stdin -o output.idx < output.pack && + git verify-pack -v output.pack >output && + grep "^e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 blob" output && + test "$(grep blob output|wc -l)" = 1 && + test "$(grep tree output|wc -l)" = 2 +' + test_expect_success 'rev-list --objects with pathspecs and copied files' ' git checkout --orphan junio-testcase && git rm -rf . && -- 1.7.1.rc1.69.g24c2f7