git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Shallow clone: low level machinery.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 2, 2006, 00:48 UTC
Message-ID
<Pine.LNX.4.63.0602020113200.30910@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vbqxqbz9q.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 1 Feb 2006, Junio C Hamano wrote:
Show 15 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> > Worse, you cannot pull from older servers into shallow repos.
> >> 
> >> "have X" means different thing if you do not have matching
> >> grafts information, so I suspect that is fundamentally
> >> unsolvable.
> >
> > If the shallow-capable client could realize that the server is not 
> > shallow-capable *and* the local repo is shallow, and refuse to operate 
> > (unless called with "-f", in which case the result may or may not be a 
> > broken repo, which has to be fixed up manually by copying 
> > over ORIG_HEAD to HEAD).
> 
> "If ... refuse to operate" then?

Just skip the "If". I'll start to enclose all emails I write in <tired>..</tired> blocks.

> > Of course, the client has to know that the local repo is shallow, which it 
> > must not determine by looking at the grafts file.
> 
> Sorry, I fail to understand this requirement.  Why is it "it must not"?
See below.
Show 7 quoted lines
> > If you introduce a different "have X" -- like "have-no-parent X" -- and 
> > teach git-rev-list that "~A" means "traverse the tree of A, but not A's 
> > parents", you'd basically have everything you need, right?
> 
> If you have such a modified rev-list, yes.  I was having doubts
> about keeping an obvious correctness guarantee when doing such
> "rev-list ~A".
I think it would be trivial: just resolve ~A to the tree A points to:

-- snip -- [PATCH] rev-list: Support "~treeish"

Now, "git rev-list --objects ~some_rev" traverses just the tree of some_rev.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 rev-list.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
43267e65c9ad933ad1a49005c4b61c23adaec372
diff --git a/rev-list.c b/rev-list.c
index 8012762..a196110 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -720,6 +720,24 @@ static void handle_one_commit(struct com
 	commit_list_insert(com, lst);
 }
 
+static void handle_tree(const unsigned char *sha1)
+{
+	struct object *object;
+
+	object = parse_object(sha1);
+	if (!object)
+		die("bad object %s", sha1_to_hex(sha1));
+
+	if (object->type == tree_type)
+		add_pending_object(object, "");
+	else if (object->type == commit_type) {
+		struct commit *commit = (struct commit *)object;
+		if (parse_commit(commit) < 0)
+			die("unable to parse commit %s", sha1_to_hex(sha1));
+		add_pending_object(&(commit->tree->object), "");
+	}
+}
+
 /* for_each_ref() callback does not allow user data -- Yuck. */
 static struct commit_list **global_lst;
 
@@ -865,6 +883,11 @@ int main(int argc, const char **argv)
 			flags = UNINTERESTING;
 			arg++;
 			limited = 1;
+		} else if (*arg == '~') {
+			if (get_sha1(arg + 1, sha1) < 0)
+				die("cannot get '%s'", arg);
+			handle_tree(sha1);
+			continue;
 		}
 		if (get_sha1(arg, sha1) < 0) {
 			struct stat st;
-- 
1.1.4.g9bd9d-dirty
-- snap --

> > Yes, I agree. But again, the local repo has to know which grafts were 
> > introduced by making the repo shallow.
> 
> I am not sure I understand.  grafts are grafts are grafts.

Exactly. And grafts are grafts are not necessarily cutoffs.

Now, is it possible that a fetch does something unintended, when there are 
grafts which are not cutoffs? I don't know yet, but I think so.

Ciao,
Dscho
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 30 in “[RFC] shallow clone”
  1. Junio C HamanoJan 30, 2006
  2. Johannes SchindelinJan 30, 2006
  3. Simon RichterJan 30, 2006
  4. Johannes SchindelinJan 30, 2006
  5. Simon RichterJan 30, 2006
  6. Junio C HamanoJan 30, 2006
  7. Johannes SchindelinJan 31, 2006
  8. Simon RichterJan 31, 2006
  9. Johannes SchindelinJan 31, 2006
  10. Simon RichterJan 31, 2006
  11. Junio C HamanoJan 30, 2006
  12. FranckJan 31, 2006
  13. Junio C HamanoJan 31, 2006
  14. FranckJan 31, 2006
  15. Junio C HamanoJan 30, 2006
  16. Shallow clone: low level machinery.Junio C Hamano, Jan 31, 2006
  17. Johannes SchindelinJan 31, 2006
  18. Junio C HamanoJan 31, 2006
  19. Johannes SchindelinJan 31, 2006
  20. Junio C HamanoJan 31, 2006
  21. Johannes SchindelinFeb 1, 2006
  22. Junio C HamanoFeb 1, 2006
  23. Johannes SchindelinFeb 2, 2006
  24. Junio C HamanoFeb 2, 2006
  25. Johannes SchindelinFeb 2, 2006
  26. Junio C HamanoFeb 2, 2006
  27. Johannes SchindelinJan 31, 2006
  28. Junio C HamanoJan 31, 2006
  29. Johannes SchindelinFeb 1, 2006
  30. FranckJan 31, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.