* Some Documentation/Usage Notes
@ 2005-12-06 5:21 Jon Loeliger
2005-12-06 6:11 ` Junio C Hamano
2005-12-06 6:25 ` Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: Jon Loeliger @ 2005-12-06 5:21 UTC (permalink / raw)
To: git
Note to $self -- here are some tidbits ToDo:
o --help doesn't work on:
git-hash-object
git-init-db
git-write-tree
o There is an odd <any-file-on-the-filesystem> argment named
in the git-hash-object documentation. Would <file> be better
and more consistent? Or is there some subtlety that I am missing?
o Someone might want to check my --template=<dir> description
on git-init-db, or make it clearer.
o Work towards moving uniform description of all environment
variables in one includable/referenceable Documentation/ file?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Some Documentation/Usage Notes
2005-12-06 5:21 Some Documentation/Usage Notes Jon Loeliger
@ 2005-12-06 6:11 ` Junio C Hamano
2005-12-06 6:25 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2005-12-06 6:11 UTC (permalink / raw)
To: Jon Loeliger; +Cc: git
Jon Loeliger <jdl@freescale.com> writes:
> Note to $self -- here are some tidbits ToDo:
>
> o --help doesn't work on:
> git-hash-object
> git-init-db
> git-write-tree
Noted. Thanks.
> o There is an odd <any-file-on-the-filesystem> argment named
> in the git-hash-object documentation. Would <file> be better
> and more consistent? Or is there some subtlety that I am missing?
The subtlety is that it is the only parameter to the coreish
command set that happily named a file outside the project
directory (i.e. you can say "git-hash-object /etc/passwd" but
you cannot say "git-update-index /etc/passwd" --- even if your
repository is at /.git, you would say "git-update-index
etc/passwd" for that). But you are right. That distinction is
irrelevant.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Some Documentation/Usage Notes
2005-12-06 5:21 Some Documentation/Usage Notes Jon Loeliger
2005-12-06 6:11 ` Junio C Hamano
@ 2005-12-06 6:25 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2005-12-06 6:25 UTC (permalink / raw)
To: Jon Loeliger; +Cc: git
Jon Loeliger <jdl@freescale.com> writes:
> o --help doesn't work on:
> git-hash-object
> git-init-db
> git-write-tree
Something like this?
-- >8 --
[PATCH] misc fixes.
- It was cumbersome to feed hash-object the file '-t' (you
could have said "./-t", though). Teach it '--' that
terminates the option list, like everybody else. There is no
way to extract usage string from the command either, so teach
it "--help" as well.
- "git-init-db junk" does not complain but just ignores "junk".
Die with the usage string in such a case.
- "git-write-tree junk" complains and dies, but it does not say
what option it supports. Die with the usage string in such a
case.
---
diff --git a/hash-object.c b/hash-object.c
index ccba11c..6227936 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -31,19 +31,30 @@ int main(int argc, char **argv)
int write_object = 0;
const char *prefix = NULL;
int prefix_length = -1;
+ int no_more_flags = 0;
for (i = 1 ; i < argc; i++) {
- if (!strcmp(argv[i], "-t")) {
- if (argc <= ++i)
- die(hash_object_usage);
- type = argv[i];
- }
- else if (!strcmp(argv[i], "-w")) {
- if (prefix_length < 0) {
- prefix = setup_git_directory();
- prefix_length = prefix ? strlen(prefix) : 0;
+ if (!no_more_flags && argv[i][0] == '-') {
+ if (!strcmp(argv[i], "-t")) {
+ if (argc <= ++i)
+ die(hash_object_usage);
+ type = argv[i];
+ }
+ else if (!strcmp(argv[i], "-w")) {
+ if (prefix_length < 0) {
+ prefix = setup_git_directory();
+ prefix_length =
+ prefix ? strlen(prefix) : 0;
+ }
+ write_object = 1;
}
- write_object = 1;
+ else if (!strcmp(argv[i], "--")) {
+ no_more_flags = 1;
+ }
+ else if (!strcmp(argv[i], "--help"))
+ usage(hash_object_usage);
+ else
+ die(hash_object_usage);
}
else {
const char *arg = argv[i];
@@ -51,6 +62,7 @@ int main(int argc, char **argv)
arg = prefix_filename(prefix, prefix_length,
arg);
hash_object(arg, type, write_object);
+ no_more_flags = 1;
}
}
return 0;
diff --git a/init-db.c b/init-db.c
index 8195b68..ead37b5 100644
--- a/init-db.c
+++ b/init-db.c
@@ -237,9 +237,7 @@ int main(int argc, char **argv)
for (i = 1; i < argc; i++, argv++) {
char *arg = argv[1];
- if (arg[0] != '-')
- break;
- else if (!strncmp(arg, "--template=", 11))
+ if (!strncmp(arg, "--template=", 11))
template_dir = arg+11;
else
die(init_db_usage);
diff --git a/write-tree.c b/write-tree.c
index 0aac32f..18507db 100644
--- a/write-tree.c
+++ b/write-tree.c
@@ -83,6 +83,8 @@ static int write_tree(struct cache_entry
return nr;
}
+static const char write_tree_usage[] = "git-write-tree [--missing-ok]";
+
int main(int argc, char **argv)
{
int i, funny;
@@ -95,8 +97,10 @@ int main(int argc, char **argv)
if (argc == 2) {
if (!strcmp(argv[1], "--missing-ok"))
missing_ok = 1;
+ else if (!strcmp(argv[1], "--help"))
+ usage(write_tree_usage);
else
- die("unknown option %s", argv[1]);
+ die(write_tree_usage);
}
if (argc > 2)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-06 6:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-06 5:21 Some Documentation/Usage Notes Jon Loeliger
2005-12-06 6:11 ` Junio C Hamano
2005-12-06 6:25 ` 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;
as well as URLs for NNTP newsgroup(s).