threads / patch / 2485

patchBugfix: stop if directory already exists

Subject: [PATCH] Bugfix: stop if directory already exists

## tl;dr

8 messages between Nov 13, 2005 and Nov 14, 2005. Diffs are folded; open one to read it.

replies: 7people: 3as markdown or json

Josef Weidendorfer· Nov 13, 2005, 14:03 UTC · lore

Fix a typo: We do not want to run the directory as command, and want to terminate if the directory exists Additionally, update the usage message

Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
---
Regarding the usage: I do not think that on an error condition
the usage string should be outputted. This helps nothing:
either the user knows the usage, and can see what is wrong by
the error message, or he should look up the man page.
Should we use "git clone" or "git-clone" in the usage message?
Or perhaps
 usage: git clone ...
 For more details, see 'man git-clone'
?
 git-clone.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

applies-to: 62fad3f1275b9bbf07fba50c328a3bd730c3454c 3de065bff303bd4caa433dfa685fdc1164be2b81

Show changes to git-clone.sh +2 −2
diff --git a/git-clone.sh b/git-clone.sh
index f99e0ad..c09979a 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -9,7 +9,7 @@
 unset CDPATH
 
 usage() {
-	echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] [-n] <repo> <dir>"
+	echo >&2 "* git clone [-l [-s]] [-q] [-u <upload-pack>] [-n] <repo> [<dir>]"
 	exit 1
 }
 
@@ -98,7 +98,7 @@ fi
 dir="$2"
 # Try using "humanish" part of source repo if user didn't specify one
 [ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*/||g')
-[ -e "$dir" ] && $(echo "$dir already exists."; usage)
+[ -e "$dir" ] && echo "$dir already exists." && usage
 mkdir -p "$dir" &&
 D=$(
 	(cd "$dir" && git-init-db && pwd)
---
0.99.9.GIT
Junio C Hamano· Nov 14, 2005, 08:57 UTC · re: Josef Weidendorfer · lore

Re: [PATCH] Bugfix: stop if directory already exists

Josef Weidendorfer <Josef.Weidendorfer@gmx.de> writes:
> Fix a typo: We do not want to run the directory as command,
> and want to terminate if the directory exists
> Additionally, update the usage message
Thanks.
> Should we use "git clone" or "git-clone" in the usage message?

I think "git clone" is probably preferred, given that we would eventually want to be able to install them outside /usr/bin/, leaving "git" wrapper (and very small number of other programs) in /usr/bin/.

>  usage: git clone ...
>  For more details, see 'man git-clone'

My understanding of UNIX tradition of "usage:" is to be short and sweet, to primarily help people who already know the command but sometimes cannot remember how exactly the options are spelled (e.g. "was that -F to specify the inter-field separator to "sort" command? Ah, no, it wants -t -- silly me must be doing too much awk these days"). And "for more details see man" goes without saying.

Andreas Ericsson· Nov 14, 2005, 09:28 UTC · re: Junio C Hamano · lore

Re: [PATCH] Bugfix: stop if directory already exists

Junio C Hamano wrote:
Show 7 quoted lines
> 
>> usage: git clone ...
>> For more details, see 'man git-clone'
> 
> 
> And "for more details see man" goes without saying.
> 
But we name them differently, as hpa pointed out some week ago.

When I see "usage: <prog> <command>" I expect to find the info in "man <prog>". Soon, this will work to get the right page

	git --help <command>
-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Josef Weidendorfer· Nov 14, 2005, 10:36 UTC · re: Andreas Ericsson · lore

Re: [PATCH] Bugfix: stop if directory already exists

On Monday 14 November 2005 10:28, Andreas Ericsson wrote:
Show 6 quoted lines
> But we name them differently, as hpa pointed out some week ago.
> 
> When I see "usage: <prog> <command>" I expect to find the info in "man 
> <prog>". Soon, this will work to get the right page
> 
> 	git --help <command>

This is a nice feature, but still needs educating the user. I think that the idea of a huge git man page is not that bad; for sure, it can be created automatically.

A huge man page helps searching a command name (Ah, what was the command to see commit logs per file? What is the counterpart of "cvs update" called?).

Josef
Andreas Ericsson· Nov 14, 2005, 10:47 UTC · re: Josef Weidendorfer · lore

Re: [PATCH] Bugfix: stop if directory already exists

Josef Weidendorfer wrote:
Show 11 quoted lines
> On Monday 14 November 2005 10:28, Andreas Ericsson wrote:
> 
>>But we name them differently, as hpa pointed out some week ago.
>>
>>When I see "usage: <prog> <command>" I expect to find the info in "man 
>><prog>". Soon, this will work to get the right page
>>
>>	git --help <command>
> 
> 
> This is a nice feature, but still needs educating the user.
This feature goes away with the huge man-page.
Show 7 quoted lines
> I think that the idea of a huge git man page is not that bad; for sure,
> it can be created automatically.
> 
> A huge man page helps searching a command name (Ah, what was the
> command to see commit logs per file?  What is the counterpart of
> "cvs update" called?).
> 

This is already implemented (sort of), but perhaps have both? Or pointers to the other man-pages from the "git" one (as is already sort of done).

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Junio C Hamano· Nov 14, 2005, 21:30 UTC · re: Andreas Ericsson · lore

Re: [PATCH] Bugfix: stop if directory already exists

Andreas Ericsson <ae@op5.se> writes:
Show 10 quoted lines
> Junio C Hamano wrote:
>>
>>> usage: git clone ...
>>> For more details, see 'man git-clone'
>> And "for more details see man" goes without saying.
>
> But we name them differently, as hpa pointed out some week ago.
>
> When I see "usage: <prog> <command>" I expect to find the info in "man 
> <prog>".
... meaning, "man git", which would list the subcommands.

And a user who got "usage: git clone blah" and did "man git" once is intelligent enough to know and remember "man git" lists the subcommands, what she wanted to know about was listed as "git-clone(1)", and she had to do "man git-clone", so next time around we should be able to expect her to do "man git-commit". Am I overestimating the users or overtaxing them?

Josef Weidendorfer· Nov 14, 2005, 09:29 UTC · re: Junio C Hamano · lore

Re: [PATCH] Bugfix: stop if directory already exists

On Monday 14 November 2005 09:57, Junio C Hamano wrote:
Show 6 quoted lines
> Josef Weidendorfer <Josef.Weidendorfer@gmx.de> writes:
> >  usage: git clone ...
> >  For more details, see 'man git-clone'
> 
> doing too much awk these days").  And "for more details see man"
> goes without saying.

Of course; it was more about the current inconsistency: usage says "git clone", but for the man page, you have to know that there is an additional command "git-clone" with extra man page. Usually, if I see e.g. "usage: cvs diff", I look up the man page of "cvs" searching for "diff" on it, not "cvs-diff".

So just another suggestion: Why not put most of the documentation in a huge "git" man page? cvs does this (3601 lines here), all the shells have huge man pages (bash: 4794). We would be in a good tradition ;-)

Josef
Andreas Ericsson· Nov 14, 2005, 09:37 UTC · re: Josef Weidendorfer · lore

Re: [PATCH] Bugfix: stop if directory already exists

Josef Weidendorfer wrote:
> So just another suggestion: Why not put most of the
> documentation in a huge "git" man page?
Becuase it's horrible. I like the fact that they are split up.
> cvs does this (3601 lines
> here), all the shells have huge man pages (bash: 4794).
> We would be in a good tradition ;-)
> 

We would be in tradition, but not necessarily a good one. Just because some stupid swede let some herrings ferment in a tin can some 800 years ago there's really no need to say "surströmming! What a clever idea!!" and actually eat the horrible things.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

← back to recent threads