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

[PATCH] Make -p flag optional from commit-tree.

From
JHJunio C Hamano <junio@siamese.dyndns.org>
Date
Apr 21, 2005, 22:42 UTC
Message-ID
<7v4qdzeop8.fsf@assigned-by-dhcp.cox.net>
We cannot currently say:
 $ commit-tree $(write-tree) $(cat .git/heads/junio .git/heads/linus)
The above must be written as:
 $ commit-tree $(write-tree) \
     -p $(cat .git/heads/junio) \
     -p $(cat .git/heads/linus)

This patch makes -p flag optional. Existing scripts are hopefully not affected because they are passing -p properly. If we want to introduce non parent-ID parameters to commit-tree later, we can give them their own -flag letters.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 commit-tree.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
commit-tree.c: c0b07f89286c3f6cceae8122b4c3142c8efaf8e1
--- a/commit-tree.c
+++ b/commit-tree.c
@@ -297,10 +297,17 @@ int main(int argc, char **argv)
 		usage(commit_tree_usage);
 
 	check_valid(tree_sha1, "tree");
-	for (i = 2; i < argc; i += 2) {
-		char *a, *b;
-		a = argv[i]; b = argv[i+1];
-		if (!b || strcmp(a, "-p") || get_sha1_hex(b, parent_sha1[parents]))
+	for (i = 2; i < argc; i++) {
+		/* Historically commit-tree required -p in front of
+		 * each parent commit ID.  This is confusing.  We can
+		 * add non parent commit ID parameter later by defining
+		 * flags other than "-p" so let's just ignore them. 
+		 */
+		if (! strcmp(argv[i], "-p"))
+			continue;
+
+		/* Currently it just expects parent IDs. */
+		if (get_sha1_hex(argv[i], parent_sha1[parents]))
 			usage(commit_tree_usage);
 		check_valid(parent_sha1[parents], "commit");
 		parents++;
Message 1 of 1 in “Make -p flag optional from commit-tree.”
  1. Make -p flag optional from commit-tree.Junio C Hamano, Apr 21, 2005

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.