From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] rev-list: add "--objects=self-sufficient" flag.
Date: Thu, 07 Jul 2005 16:50:04 -0700 [thread overview]
Message-ID: <7vfyuqfa6r.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vll4ifbq8.fsf_-_@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Thu, 07 Jul 2005 16:16:47 -0700")
When --objects=self-sufficient is specified instead of usual
"--objects", rev-list shows all objects reachable from trees
associated with the commits in its output. This can be used to
ensure that a single pack can be used to recreate the tree
associated with every commit in it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
*** This makes things easier for the dumb puller because
*** self-sufficient pack means less falling back on traditional
*** http-pull.
rev-list.c | 7 ++-
t/t6100-rev-list-object.sh | 97 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 102 insertions(+), 2 deletions(-)
create mode 100644 t/t6100-rev-list-object.sh
60563326cea81f89098a88ab716fb4f02e326b43
diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -27,6 +27,7 @@ static int bisect_list = 0;
static int tag_objects = 0;
static int tree_objects = 0;
static int blob_objects = 0;
+static int objects_self_sufficient = 0;
static int verbose_header = 0;
static int show_parents = 0;
static int hdr_termination = 0;
@@ -198,7 +199,7 @@ static void mark_tree_uninteresting(stru
struct object *obj = &tree->object;
struct tree_entry_list *entry;
- if (!tree_objects)
+ if (!tree_objects || objects_self_sufficient)
return;
if (obj->flags & UNINTERESTING)
return;
@@ -448,7 +449,9 @@ int main(int argc, char **argv)
bisect_list = 1;
continue;
}
- if (!strcmp(arg, "--objects")) {
+ if (!strncmp(arg, "--objects", 9)) {
+ if (!strcmp(arg+9, "=self-sufficient"))
+ objects_self_sufficient = 1;
tag_objects = 1;
tree_objects = 1;
blob_objects = 1;
diff --git a/t/t6100-rev-list-object.sh b/t/t6100-rev-list-object.sh
new file mode 100644
--- /dev/null
+++ b/t/t6100-rev-list-object.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-rev-list --objects test.
+
+'
+. ./test-lib.sh
+
+GIT_AUTHOR_DATE='+0000 946684801'
+GIT_AUTHOR_NAME=none
+GIT_AUTHOR_EMAIL=none@none
+GIT_COMMITTER_DATE='+0000 946684801'
+GIT_COMMITTER_NAME=none
+GIT_COMMITTER_EMAIL=none@none
+export GIT_AUTHOR_DATE GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL \
+ GIT_COMMITTER_DATE GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+sedScript='s/^\('"$_x40"' [^ ]*\) .*/\1/p'
+
+test_expect_success setup '
+ for i in frotz nitfol
+ do
+ echo $i >$i &&
+ git-update-cache --add $i || exit
+ done &&
+ tree0=$(git-write-tree) &&
+ commit0=$(git-commit-tree $tree0) &&
+ echo $tree0 &&
+ echo $commit0 &&
+ git-ls-tree -r $tree0 &&
+ echo nitfol nitfol >nitfol &&
+ git-update-cache --add nitfol &&
+ tree1=$(git-write-tree) &&
+ commit1=$(git-commit-tree $tree1 -p $commit0) &&
+ echo $tree1 &&
+ echo $commit1 &&
+ git-ls-tree -r $tree1
+' </dev/null
+
+test_expect_success 'pack #0' '
+ name0=$(git-rev-list --objects $commit0 | \
+ git-pack-objects pk0) &&
+ ls pk0-* &&
+ git-verify-pack -v pk0-$name0.idx |
+ sed -ne "$sedScript" | sort >contents.0
+'
+
+test_expect_success 'pack #1 (commit 1 except commit 0)' '
+ name1=$(git-rev-list --objects $commit1 ^$commit0 | \
+ git-pack-objects pk1) &&
+ ls pk1-* &&
+ git-verify-pack -v pk1-$name1.idx |
+ sed -ne "$sedScript" | sort >contents.1
+'
+
+test_expect_success 'there should not be any overlaps' '
+ case $(comm -12 contents.0 contents.1 | wc -l) in
+ 0) ;;
+ *) false ;;
+ esac
+'
+
+test_expect_success 'pack #2 (commit 1 unpacked only)' '
+ ln pk0-* .git/objects/pack/. &&
+ name2=$(git-rev-list --objects --unpacked $commit1 | \
+ git-pack-objects pk2) &&
+ ls pk2-* &&
+ git-verify-pack -v pk1-$name2.idx |
+ sed -ne "$sedScript" | sort >contents.2
+'
+
+test_expect_success 'pack #1 and #2 should be the same' '
+ diff contents.1 contents.2
+'
+
+test_expect_success 'pack #3 (commit 1 except commit 0, self-sufficient)' '
+ name3=$(git-rev-list --objects=self-sufficient $commit1 ^$commit0 | \
+ git-pack-objects pk3) &&
+ ls pk3-* &&
+ git-verify-pack -v pk3-$name3.idx |
+ sed -ne "$sedScript" | sort >contents.3
+'
+
+ls_tree_to_invent='s/^[0-9]* \([^ ]*\) \('"$_x40"'\) .*/\2 \1/'
+test_expect_success 'make sure pack #3 is not missing anything from commit1' '
+ (
+ echo "$tree1 tree"
+ echo "$commit1 commit"
+ git-ls-tree "$tree1" | sed -e "$ls_tree_to_invent"
+ ) | sort >tree-contents.1 &&
+ comm -23 tree-contents.1 contents.3 >missing.3 &&
+ diff /dev/null missing.3
+'
------------
next prev parent reply other threads:[~2005-07-07 23:52 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-03 23:46 [ANNOUNCE] Cogito-0.12 Petr Baudis
2005-07-06 12:01 ` Brian Gerst
2005-07-07 14:45 ` Petr Baudis
2005-07-07 17:21 ` Junio C Hamano
2005-07-07 19:04 ` Linus Torvalds
2005-07-07 19:57 ` Junio C Hamano
2005-07-07 21:58 ` Linus Torvalds
2005-07-07 22:10 ` Junio C Hamano
2005-07-07 20:00 ` Junio C Hamano
2005-07-07 21:29 ` Eric W. Biederman
2005-07-07 22:23 ` Linus Torvalds
2005-07-08 2:11 ` Eric W. Biederman
2005-07-08 1:54 ` Dumb servers (was: [ANNOUNCE] Cogito-0.12) Kevin Smith
2005-07-08 2:27 ` Linus Torvalds
2005-07-07 22:14 ` [ANNOUNCE] Cogito-0.12 Petr Baudis
2005-07-07 22:52 ` Linus Torvalds
2005-07-07 23:16 ` [PATCH] Pull efficiently from a dumb git store Junio C Hamano
2005-07-07 23:50 ` Junio C Hamano [this message]
2005-07-07 23:58 ` [PATCH] rev-list: add "--objects=self-sufficient" flag Linus Torvalds
2005-07-08 1:02 ` [PATCH] rev-list: add "--full-objects" flag Junio C Hamano
2005-07-08 1:33 ` Linus Torvalds
2005-07-08 1:46 ` Linus Torvalds
2005-07-08 2:17 ` Junio C Hamano
2005-07-08 2:39 ` Linus Torvalds
2005-07-09 21:09 ` Eric W. Biederman
2005-07-10 5:11 ` Linus Torvalds
2005-07-10 6:28 ` Junio C Hamano
2005-07-10 21:48 ` Sven Verdoolaege
2005-07-10 22:36 ` Linus Torvalds
2005-07-11 15:19 ` Eric W. Biederman
2005-07-11 16:38 ` Linus Torvalds
2005-07-12 0:44 ` Eric W. Biederman
2005-07-12 1:14 ` Linus Torvalds
2005-07-12 2:38 ` Eric W. Biederman
2005-07-12 3:21 ` Linus Torvalds
2005-07-12 3:39 ` Eric W. Biederman
2005-07-12 4:48 ` Linus Torvalds
2005-07-11 17:53 ` Linus Torvalds
[not found] ` <7vy88gzn6s.fsf@assigned-by-dhcp.cox.net>
[not found] ` <Pine.LNX.4.58.0507082109140.17536@g5.osdl.org>
[not found] ` <7vfyumj8hn.fsf_-_@assigned-by-dhcp.cox.net>
2005-07-11 7:00 ` [PATCH] Check packs and then files Junio C Hamano
2005-07-08 1:03 ` [PATCH] Give --full-objects flag to rev-list when preparing a dumb server Junio C Hamano
2005-07-07 23:50 ` [PATCH] Use --objects=self-sufficient flag to rev-list Junio C Hamano
2005-07-07 23:52 ` [ANNOUNCE] Cogito-0.12 Tony Luck
2005-07-07 23:54 ` Junio C Hamano
2005-07-07 23:59 ` Linus Torvalds
2005-07-08 0:09 ` Tony Luck
2005-07-08 0:23 ` Linus Torvalds
2005-07-09 21:58 ` Russell King
2005-07-09 22:29 ` Russell King
2005-07-09 23:46 ` Junio C Hamano
2005-07-10 5:02 ` Linus Torvalds
2005-07-10 5:15 ` Linus Torvalds
2005-07-10 6:55 ` Russell King
2005-07-10 7:15 ` Junio C Hamano
2005-07-10 12:46 ` Russell King
2005-07-10 16:51 ` Linus Torvalds
2005-07-10 19:15 ` Russell King
2005-07-10 20:03 ` Linus Torvalds
2005-07-10 20:32 ` Russell King
2005-07-10 21:40 ` Linus Torvalds
2005-07-10 8:09 ` Russell King
2005-07-10 14:59 ` Petr Baudis
2005-07-11 20:30 ` Chris Wright
2005-07-08 0:09 ` Linus Torvalds
2005-07-08 8:14 ` Petr Baudis
2005-07-08 15:56 ` Daniel Barkalow
2005-07-07 6:22 ` Chris Wright
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vfyuqfa6r.fsf_-_@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).