From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 11/32] rev-list: support --narrow-tree
Date: Wed, 25 Aug 2010 08:20:01 +1000 [thread overview]
Message-ID: <1282688422-7738-12-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1282688422-7738-1-git-send-email-pclouds@gmail.com>
These options allow plumbing to access narrow tree traverse modes.
As a consequence, tests can now be written to test these modes.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
revision.c | 5 ++
t/t6061-rev-list-narrow.sh | 158 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 163 insertions(+), 0 deletions(-)
create mode 100755 t/t6061-rev-list-narrow.sh
diff --git a/revision.c b/revision.c
index 7e82efd..a4eb11f 100644
--- a/revision.c
+++ b/revision.c
@@ -1562,6 +1562,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
read_revisions_from_stdin(revs, &prune_data);
continue;
}
+ if (!prefixcmp(arg, "--narrow-tree=")) {
+ revs->narrow_prefix = arg + 14;
+ revs->narrow_tree = 1;
+ continue;
+ }
opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
if (opts > 0) {
diff --git a/t/t6061-rev-list-narrow.sh b/t/t6061-rev-list-narrow.sh
new file mode 100755
index 0000000..e489347
--- /dev/null
+++ b/t/t6061-rev-list-narrow.sh
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+test_description='rev-list in narrow tree mode'
+
+. ./test-lib.sh
+
+# Normal tree
+cat <<EOF >revlist.expected
+ba7a30916c792624a8372cb26da50f5594098222
+3b52e9990a52d9ea46b25199b5810566324759f4
+573541ac9702dd3969c9bc859d2b91ec1f7e6e56 f0
+fa0bba1767985729582729a12a5459cd041d6cf6 t1
+f599e28b8ab0d8c9c57a486c89c4a5132dcbd3b2 t1/f10
+d81015b2a1c40fc6cbc5bf5a8b16949018c3aede t1/t12
+52bd8e43afb01d0c9747f1fedf2fc94684ee4cc4 t1/t12/f120
+74a398027f0b59183db54ca8c67dc30b5aeed0ff t2
+209e3ef4b6247ce746048d5711befda46206d235 t2/f20
+EOF
+
+# narrowed down tree
+cat <<EOF >t12.expected
+ba7a30916c792624a8372cb26da50f5594098222
+3b52e9990a52d9ea46b25199b5810566324759f4
+fa0bba1767985729582729a12a5459cd041d6cf6 t1
+d81015b2a1c40fc6cbc5bf5a8b16949018c3aede t1/t12
+52bd8e43afb01d0c9747f1fedf2fc94684ee4cc4 t1/t12/f120
+EOF
+
+# local tree
+cat <<EOF >t12-subtree.expected
+ba7a30916c792624a8372cb26da50f5594098222
+c0167b5ce78e9fb801ef96dcc319f3411d35278b
+e9a12654c859aff51978b25b2a6c5eddf6c1e13c t1
+d81015b2a1c40fc6cbc5bf5a8b16949018c3aede t1/t12
+52bd8e43afb01d0c9747f1fedf2fc94684ee4cc4 t1/t12/f120
+EOF
+
+cat <<EOF >t2.expected
+ba7a30916c792624a8372cb26da50f5594098222
+3b52e9990a52d9ea46b25199b5810566324759f4
+74a398027f0b59183db54ca8c67dc30b5aeed0ff t2
+209e3ef4b6247ce746048d5711befda46206d235 t2/f20
+EOF
+
+test_expect_success setup '
+ test_tick &&
+ mkdir t1 t2 t1/t12 &&
+ echo 0 > f0 &&
+ echo 10 > t1/f10 &&
+ echo 120 > t1/t12/f120 &&
+ echo 20 > t2/f20
+ git add t1 t2 f0 && git commit -m initial &&
+ C1=`git rev-parse HEAD` &&
+ T2=`git rev-parse HEAD^{tree}` &&
+ git rev-list --objects HEAD >result &&
+ test_cmp revlist.expected result
+'
+
+cat <<EOF >branch1.expected
+7475cb8a389b36ce238b9ee6cbfdfa26a1b67e35
+ba7a30916c792624a8372cb26da50f5594098222
+aa0602ee56ea4cb5e5bfff8713bb8a9a6ab4303e
+407c07594c8083c3d0521a1cb463b1204d880c13 f0
+d77d258d806b2aa7cdb5a301e6a54f023d9bdcfe t1
+737483f30ba682e414d715f7976fe9a9904fdbc0 t1/f10
+ab246f7eb05e94f695d2a0e30093d94fde7b837e t1/t12
+04156ae83e615fa5b6019170928bc131539f9996 t1/t12/f120
+1da4df952e59f2fa7ff211a8ee9f72b3174bbfb7 t2
+9aa2407894b849226773016ef5d68c5b87a23926 t2/f20
+3b52e9990a52d9ea46b25199b5810566324759f4
+573541ac9702dd3969c9bc859d2b91ec1f7e6e56 f0
+fa0bba1767985729582729a12a5459cd041d6cf6 t1
+f599e28b8ab0d8c9c57a486c89c4a5132dcbd3b2 t1/f10
+d81015b2a1c40fc6cbc5bf5a8b16949018c3aede t1/t12
+52bd8e43afb01d0c9747f1fedf2fc94684ee4cc4 t1/t12/f120
+74a398027f0b59183db54ca8c67dc30b5aeed0ff t2
+209e3ef4b6247ce746048d5711befda46206d235 t2/f20
+EOF
+
+test_expect_success 'setup branch1' '
+ echo common >> t1/t12/f120 &&
+ echo branch1 >> t1/f10 &&
+ echo branch1 >> t2/f20 &&
+ echo branch1 >> f0 &&
+ git add -u && git commit -m branch1 &&
+ BRANCH1=`git rev-parse HEAD` &&
+ git rev-list --objects $BRANCH1 > result &&
+ test_cmp branch1.expected result
+'
+
+cat <<EOF >branch2.expected
+af9c31c0e217154296d93d66b9a5a41892c7b321
+ba7a30916c792624a8372cb26da50f5594098222
+72e05e456b9ff4c01ccf6178ce60d9b52b41aae4
+573541ac9702dd3969c9bc859d2b91ec1f7e6e56 f0
+4fc1656b01ce8b21987c55a2870b8c9a431ec772 t1
+f599e28b8ab0d8c9c57a486c89c4a5132dcbd3b2 t1/f10
+ab246f7eb05e94f695d2a0e30093d94fde7b837e t1/t12
+04156ae83e615fa5b6019170928bc131539f9996 t1/t12/f120
+cef4db52388f5e0853acc772faa68058436a95ff t2
+7319a2144592e50a564d49902302a8b1bad2f49c t2/f20
+3b52e9990a52d9ea46b25199b5810566324759f4
+fa0bba1767985729582729a12a5459cd041d6cf6 t1
+d81015b2a1c40fc6cbc5bf5a8b16949018c3aede t1/t12
+52bd8e43afb01d0c9747f1fedf2fc94684ee4cc4 t1/t12/f120
+74a398027f0b59183db54ca8c67dc30b5aeed0ff t2
+209e3ef4b6247ce746048d5711befda46206d235 t2/f20
+EOF
+
+test_expect_success 'setup branch2' '
+ git reset --hard HEAD^ &&
+ echo common >> t1/t12/f120 &&
+ echo branch2 >> t2/f20 &&
+ git add -u && git commit -m branch2 &&
+ BRANCH2=`git rev-parse HEAD` &&
+ git rev-list --objects $BRANCH2 > result &&
+ test_cmp branch2.expected result
+'
+
+test_expect_success 'setup merge' '
+ git reset --hard HEAD^
+ MERGE=`echo merge | git commit-tree $T2 -p $BRANCH1 -p $BRANCH2`
+'
+
+test_expect_success 'rev-list --narrow-tree=t2' '
+ git rev-list --objects --narrow-tree=t2 HEAD >result &&
+ test_cmp t2.expected result
+'
+
+test_expect_success 'rev-list --narrow-tree=t1/t12' '
+ git rev-list --objects --narrow-tree=t1/t12 HEAD >result &&
+ test_cmp t12.expected result
+'
+
+cat <<EOF >merge.expected
+0da28f8308e336bd4b2c26b61c7fc44e41a30e49
+7475cb8a389b36ce238b9ee6cbfdfa26a1b67e35
+af9c31c0e217154296d93d66b9a5a41892c7b321
+ba7a30916c792624a8372cb26da50f5594098222
+74a398027f0b59183db54ca8c67dc30b5aeed0ff t2
+3b52e9990a52d9ea46b25199b5810566324759f4
+fa0bba1767985729582729a12a5459cd041d6cf6 t1
+d81015b2a1c40fc6cbc5bf5a8b16949018c3aede t1/t12
+52bd8e43afb01d0c9747f1fedf2fc94684ee4cc4 t1/t12/f120
+aa0602ee56ea4cb5e5bfff8713bb8a9a6ab4303e
+d77d258d806b2aa7cdb5a301e6a54f023d9bdcfe t1
+ab246f7eb05e94f695d2a0e30093d94fde7b837e t1/t12
+04156ae83e615fa5b6019170928bc131539f9996 t1/t12/f120
+72e05e456b9ff4c01ccf6178ce60d9b52b41aae4
+4fc1656b01ce8b21987c55a2870b8c9a431ec772 t1
+EOF
+
+test_expect_success 'rev-list --narrow-tree=t1/t12 with merges' '
+ git rev-list --objects --narrow-tree=t1/t12 $MERGE >result &&
+ test_cmp merge.expected result
+'
+
+test_done
--
1.7.1.rc1.69.g24c2f7
next prev parent reply other threads:[~2010-08-24 22:22 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-24 22:19 [RFD PATCH 00/32] subtree clone v2 Nguyễn Thái Ngọc Duy
2010-08-24 22:19 ` [PATCH 01/32] add const to ce_write() Nguyễn Thái Ngọc Duy
2010-08-24 22:19 ` [PATCH 02/32] cache-tree: abstract out write_sha1_file from cache_tree_update() Nguyễn Thái Ngọc Duy
2010-08-24 22:41 ` Jonathan Nieder
2010-08-24 22:19 ` [PATCH 03/32] cache-tree: ignore CE_REMOVE entries in verify_cache() Nguyễn Thái Ngọc Duy
2010-08-24 23:15 ` Jonathan Nieder
2010-08-25 0:23 ` Nguyen Thai Ngoc Duy
2010-08-25 0:48 ` Jonathan Nieder
2010-08-24 22:19 ` [PATCH 04/32] move do_compress() from pack-objects.c to pack-write.c Nguyễn Thái Ngọc Duy
2010-08-24 23:25 ` Jonathan Nieder
2010-08-25 3:19 ` Nguyen Thai Ngoc Duy
2010-08-24 22:19 ` [PATCH 05/32] pack-write: add functions for creating simple packs Nguyễn Thái Ngọc Duy
2010-08-24 22:19 ` [PATCH 06/32] tree.c: Add {set,clear}_tree_marks Nguyễn Thái Ngọc Duy
2010-08-24 22:19 ` [PATCH 07/32] tree.c: find_subtree() to search for a tree Nguyễn Thái Ngọc Duy
2010-08-25 3:35 ` Elijah Newren
2010-08-25 3:43 ` Nguyen Thai Ngoc Duy
2010-08-25 5:35 ` Elijah Newren
2010-08-24 22:19 ` [PATCH 08/32] Add $GIT_DIR/narrow check Nguyễn Thái Ngọc Duy
2010-08-24 22:19 ` [PATCH 09/32] index: make narrow index incompatible with older git Nguyễn Thái Ngọc Duy
2010-08-24 23:43 ` Jonathan Nieder
2010-08-25 0:25 ` Nguyen Thai Ngoc Duy
2010-08-24 22:20 ` [PATCH 10/32] rev-list: support traversing in narrow repository mode Nguyễn Thái Ngọc Duy
2010-08-25 4:11 ` Elijah Newren
2010-08-24 22:20 ` Nguyễn Thái Ngọc Duy [this message]
2010-08-25 3:59 ` [PATCH 11/32] rev-list: support --narrow-tree Elijah Newren
2010-08-25 22:11 ` Nguyen Thai Ngoc Duy
2010-08-24 22:20 ` [PATCH 12/32] pack-objects: " Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 13/32] upload-pack: support narrow-tree capability Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 14/32] fetch-pack: support --narrow-tree Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 15/32] unpack_trees: only unpack $GIT_DIR/narrow subtree in narrow repository Nguyễn Thái Ngọc Duy
2010-08-25 5:04 ` Elijah Newren
2010-08-25 5:38 ` Nguyen Thai Ngoc Duy
2010-08-24 22:20 ` [PATCH 16/32] cache-tree: only cache tree within narrow area Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 17/32] tree-diff: add narrow versions of diff_{root_,}tree_sha1 Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 18/32] log-tree: use narrow version of diff_tree_sha1 Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 19/32] clone: support --narrow option Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 20/32] narrow-tree: add join_narrow_tree to do tree fixup for commits Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 21/32] commit: add narrow's commit_tree version Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 22/32] commit: use commit_narrow_tree() to support narrow repo Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 23/32] commit-tree: require --narrow-base in " Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 24/32] merge: refuse to merge if narrow bases are different Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 25/32] merge: prepare commit properly in narrow mode Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 26/32] Add upload-narrow-base command Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 27/32] rev-list: traverse some more trees to make upload-narrow-base happy Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 28/32] narrow-tree: add oldest_narrow_base() Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 29/32] Add command fetch-narrow-base Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 30/32] merge: support merging when narrow bases are different Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 31/32] send-pack: do not use thin pack in narrow mode Nguyễn Thái Ngọc Duy
2010-08-24 22:20 ` [PATCH 32/32] daemon: support upload-narrow-base Nguyễn Thái Ngọc Duy
2010-08-24 22:37 ` [RFD PATCH 00/32] subtree clone v2 Jonathan Nieder
2010-08-24 22:47 ` Nguyen Thai Ngoc Duy
2010-08-24 23:09 ` Jonathan Nieder
2010-08-25 0:20 ` Nguyen Thai Ngoc Duy
2010-08-25 4:37 ` Elijah Newren
2010-08-25 5:21 ` Nguyen Thai Ngoc Duy
2010-08-25 5:31 ` Elijah Newren
2010-08-25 6:21 ` Nguyen Thai Ngoc Duy
2010-08-25 13:06 ` Elijah Newren
2010-08-25 22:13 ` Nguyen Thai Ngoc Duy
2010-08-26 2:50 ` Elijah Newren
2010-08-26 3:52 ` Nguyen Thai Ngoc Duy
2010-08-26 4:39 ` Elijah Newren
2010-08-26 4:45 ` Nguyen Thai Ngoc Duy
2010-08-25 5:21 ` Elijah Newren
2010-08-25 19:27 ` Junio C Hamano
2010-08-25 20:43 ` Elijah Newren
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=1282688422-7738-12-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/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).