* [PATCH] Make -p flag optional from commit-tree.
@ 2005-04-21 22:42 Junio C Hamano
0 siblings, 0 replies; only message in thread
From: Junio C Hamano @ 2005-04-21 22:42 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
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++;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-04-21 22:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-21 22:42 [PATCH] Make -p flag optional from commit-tree Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox