Re: [PATCH] fast-import: add 'ls' command

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] fast-import: add 'ls' command

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:09

Jonathan Nieder [off-list ref] writes:
I somewhat agree.  Actually I would go further: the word "index" brings
to mind .git/index and its in-core counterpart, so at the same time as
documenting it better, we might look into making it more self-
explanatory.  Maybe a syntax like

	ls current "path/to/entry"

would make it clearer that this is about directory entries in
fast-import's active commit and not necessarily the usual index file?
I think that explains the feature better.  I was wondering if the stream
somehow wanted to access the state the index of the repository happens to
be.
I am not sure what syntax other vcs-es use for tree-ishes.  To avoid
name clashes (what if 'current' is the low-level name of a tree-ish?),
an alternative might be

	ls-tree :11 "path/to/historical/entry"
	ls "path/to/current/entry"
Is it an option to use "ls" for both cases and treat one-arg and two-arg
cases differently?

Re: [PATCH] fast-import: add 'ls' command

From: David Barr <hidden>
Date: 2016-06-15 22:50:09

quoted
I somewhat agree.  Actually I would go further: the word "index" brings
to mind .git/index and its in-core counterpart, so at the same time as
documenting it better, we might look into making it more self-
explanatory.  Maybe a syntax like

      ls current "path/to/entry"

would make it clearer that this is about directory entries in
fast-import's active commit and not necessarily the usual index file?
I think that explains the feature better.  I was wondering if the stream
somehow wanted to access the state the index of the repository happens to
be.
quoted
I am not sure what syntax other vcs-es use for tree-ishes.  To avoid
name clashes (what if 'current' is the low-level name of a tree-ish?),
an alternative might be

      ls-tree :11 "path/to/historical/entry"
      ls "path/to/current/entry"
Is it an option to use "ls" for both cases and treat one-arg and two-arg
cases differently?
I like that idea, its not hard to implement if we keep quoting mandatory.

--
David Barr.

---
diff --git a/fast-import.c b/fast-import.c
index 854398a..0b0f2a1 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2922,8 +2922,7 @@ static void parse_ls(struct branch *b)
 
 	/* ls SP <treeish> SP <path> */
 	p = command_buf.buf + strlen("ls ");
-	if(!prefixcmp(p, "index")) {
-		p += strlen("index");
+	if(*p == '"') {
 		if (!b)
 			die("Not in a commit: %s", command_buf.buf);
 		root = &b->branch_tree;
@@ -2932,9 +2931,9 @@ static void parse_ls(struct branch *b)
 		root = new_tree_entry();
 		hashcpy(root->versions[1].sha1, e->idx.sha1);
 		load_tree(root);
+		if (*p++ != ' ')
+			die("Missing space after tree-ish: %s", command_buf.buf);
 	}
-	if (*p++ != ' ')
-		die("Missing space after SHA1: %s", command_buf.buf);
 	if (unquote_c_style(&uq, p, &p))
 		die("Invalid path: %s", command_buf.buf);
 	if (*p)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help