{"thread":{"id":"232","subject":"[PATCH] Make -p flag optional from commit-tree.","startedAt":"2005-04-21T22:42:59Z","lastAt":"2005-04-21T22:42:59Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1209","messageId":"7v4qdzeop8.fsf@assigned-by-dhcp.cox.net","threadId":"232","inReplyTo":null,"subject":"[PATCH] Make -p flag optional from commit-tree.","fromName":"Junio C Hamano","fromEmail":"junio@siamese.dyndns.org","sentAt":"2005-04-21T22:42:59Z","receivedAt":"2005-04-21T22:42:59Z","isPatch":true,"sender":{"key":"junio@siamese.dyndns.org","avatar":null},"body":"We cannot currently say:\n\n $ commit-tree $(write-tree) $(cat .git/heads/junio .git/heads/linus)\n\nThe above must be written as:\n\n $ commit-tree $(write-tree) \\\n     -p $(cat .git/heads/junio) \\\n     -p $(cat .git/heads/linus)\n\nThis patch makes -p flag optional.  Existing scripts are\nhopefully not affected because they are passing -p properly.  If\nwe want to introduce non parent-ID parameters to commit-tree\nlater, we can give them their own -flag letters.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n commit-tree.c |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\ncommit-tree.c: c0b07f89286c3f6cceae8122b4c3142c8efaf8e1\n--- a/commit-tree.c\n+++ b/commit-tree.c\n@@ -297,10 +297,17 @@ int main(int argc, char **argv)\n \t\tusage(commit_tree_usage);\n \n \tcheck_valid(tree_sha1, \"tree\");\n-\tfor (i = 2; i < argc; i += 2) {\n-\t\tchar *a, *b;\n-\t\ta = argv[i]; b = argv[i+1];\n-\t\tif (!b || strcmp(a, \"-p\") || get_sha1_hex(b, parent_sha1[parents]))\n+\tfor (i = 2; i < argc; i++) {\n+\t\t/* Historically commit-tree required -p in front of\n+\t\t * each parent commit ID.  This is confusing.  We can\n+\t\t * add non parent commit ID parameter later by defining\n+\t\t * flags other than \"-p\" so let's just ignore them. \n+\t\t */\n+\t\tif (! strcmp(argv[i], \"-p\"))\n+\t\t\tcontinue;\n+\n+\t\t/* Currently it just expects parent IDs. */\n+\t\tif (get_sha1_hex(argv[i], parent_sha1[parents]))\n \t\t\tusage(commit_tree_usage);\n \t\tcheck_valid(parent_sha1[parents], \"commit\");\n \t\tparents++;\n\n"}]}