Adding Correct Useage Notification and -h Help flag
PATCH 1/1 Adding Correct Useage Notification and -h Help flag
okay this is my first patch so take it easy on me.
I have added both a Correct Useage notification when git is called on its own without any other parameters and a -h help flag which lists available scripts for the git command.
Signature · 4 lines
James Purser Winnet Developer +61 2 4223 4131 http://www.winnet.com.au
Added a couple of lines to the git wrapper. Includes Correct Useage and available scripts
---
commit bfe72d41d70f9e4c0a6ab0ec6cf49347f980f4de
tree a8eed80ea2ac00ffee0b4f12ed4c931ca7761000
parent 940c1bb0181cb20454bf3573134175f86983a0ce
author James Purser <[email protected]> Tue, 14 Jun 2005 11:40:20 +1000 committer James Purser <[email protected]> Tue, 14 Jun 2005 11:40:20 +1000
git | 31 ++++++++++++++++++++++++++++--- 1 files changed, 28 insertions(+), 3 deletions(-)
git +28 -3
@@ -1,4 +1,29 @@ #!/bin/sh -cmd="git-$1-script" -shift -exec $cmd "$@" +if [ "$1" = "" ] +then + echo "Correct Useage: git [-h] [SCRIPT]"; +else + if [ "$1" = "-h" ] + then + echo "This is a basic script wrapper for certain git functions. The available commands are: + +git apply-patch +git commit +git cvsimport +git deltafy +git diff +git fetch +git log +git merge-one-file +git prune +git pull +git status +git tag +"; + else + cmd="git-$1-script"; + shift; + exec $cmd "$@"; + fi +fi +
Quoted 3 lines
Quoted 3 lines
Added a couple of lines to the git wrapper. Includes Correct Useage and available scripts
I like the general direction of making "git" wrapper novice friendly, but have some suggestions to the implementation.
(0) Do not mention that only certain subset is accessible. Just saying "Available commands are:" would be enough, and would not leave the end user wondering what he is missing.
(1) Instead of explicitly checking for -h, you may want to
structure it like this:
#!/bin/sh
cmd="git-$1-script";
shift;
exec $cmd "$@";
echo "Usage: git <subcommand> [<param>...]"
echo 'Available commands are:"
git bar
git foo
...
'
exit 1
Alternatively, you could say:
#!/bin/sh
case "$1" in
-h)
echo "Usage: git <subcommand> [<param>...]"
echo 'Available commands are:
git bar
git foo
...
'
exit 0 ;;
esac
cmd="git-$1-script";
shift;
exec $cmd "$@";
git -h
exit 1(2) Maintaining the list of commands by hand in git script
itself have an advantage that you _could_ describe the
options and parameters they take, but you are not doing
that in your patch (hint, hint).
If all you give is the list of subcommand names, have
git.in as a source file, and create the "list of available
commands" from the Makefile, like this:
=== Makefile ===
...
git : git.in
/bin/sh ls -1 git-*-script | \
sed -e 's/git-\(.*\)-script/git \1/' >.git-cmd-list
sed -e '/@@LIST_OF_COMMANDS@@/{s/.*//;r .git-cmd-list;}' <[email protected] >$@
rm -f .git-cmd-list
=== git.in ===
#!/bin/sh
cmd="git-$1-script";
shift;
exec $cmd "$@";
echo "Usage: git <subcommand> [<param>...]"
echo 'Available commands are:
@@LIST_OF_COMMANDS@@
'Thanks for the tips, I shall submit a new patch along these lines when I get home from work tonight.
Quoted 79 lines · Junio C Hamano
Quoted 2 lines
Quoted 2 lines
Added a couple of lines to the git wrapper. Includes Correct Useage and available scripts
I like the general direction of making "git" wrapper novice friendly, but have some suggestions to the implementation.
(0) Do not mention that only certain subset is accessible. Just saying "Available commands are:" would be enough, and would not leave the end user wondering what he is missing.
(1) Instead of explicitly checking for -h, you may want to
structure it like this: #!/bin/sh cmd="git-$1-script"; shift; exec $cmd "$@"; echo "Usage: git <subcommand> [<param>...]" echo 'Available commands are:" git bar git foo ... ' exit 1 Alternatively, you could say: #!/bin/sh case "$1" in -h) echo "Usage: git <subcommand> [<param>...]" echo 'Available commands are: git bar git foo ... ' exit 0 ;; esac cmd="git-$1-script"; shift; exec $cmd "$@"; git -h exit 1(2) Maintaining the list of commands by hand in git script
itself have an advantage that you _could_ describe the options and parameters they take, but you are not doing that in your patch (hint, hint). If all you give is the list of subcommand names, have git.in as a source file, and create the "list of available commands" from the Makefile, like this: === Makefile === ... git : git.in /bin/sh ls -1 git-*-script | \ sed -e 's/git-\(.*\)-script/git \1/' >.git-cmd-list sed -e '/@@LIST_OF_COMMANDS@@/{s/.*//;r .git-cmd-list;}' <[email protected] >$@ rm -f .git-cmd-list === git.in === #!/bin/sh cmd="git-$1-script"; shift; exec $cmd "$@"; echo "Usage: git <subcommand> [<param>...]" echo 'Available commands are: @@LIST_OF_COMMANDS@@ '-
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
James Purser Winnet Developer +61 2 4223 4131 http://www.winnet.com.au
One thing I would like to double check.
When running git commit I am told to run git-update-cache against the files I want to commit. Would it be easier to have the git-commit-script run this itself? Take out that second step and all that.
Signature · 4 lines
James Purser Winnet Developer +61 2 4223 4131 http://www.winnet.com.au
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"JP" == James Purser <[email protected]> writes:
JP> When running git commit I am told to run git-update-cache JP> against the files I want to commit. Would it be easier to JP> have the git-commit-script run this itself? Take out that JP> second step and all that.
That's a question better asked Linus, not me. My preference would be (1) to ask the user if he wants us to automatically run git-update-cache to all of those files, giving him an option to decline and sort things out himself; or (2) leave things as they are.
The core GIT treats the index file and the working directory contents two logically separate entities, and we always require the user to consciously tell us what to put in and remove from the index file. The core GIT is all about committed tree objects and the index file, and the working directory is merely a temporary area the user can use to build the state the user wishes to have in the index file. From this point of view, running git-update-cache ourselves without asking the user is a definite no-no.
Heres the revised patch along the lines you recommended yesterday. I am still working on some of the command descriptions.
On the git-update-cache question, I think having a flag [-u] or something like that in git commit would allow the user to decide to run git-update-cache on only the files specified in the git commit command.
Quoted 75 lines · Junio C Hamano
Quoted 2 lines
Quoted 2 lines
Added a couple of lines to the git wrapper. Includes Correct Useage and available scripts
I like the general direction of making "git" wrapper novice friendly, but have some suggestions to the implementation.
(0) Do not mention that only certain subset is accessible. Just saying "Available commands are:" would be enough, and would not leave the end user wondering what he is missing.
(1) Instead of explicitly checking for -h, you may want to
structure it like this: #!/bin/sh cmd="git-$1-script"; shift; exec $cmd "$@"; echo "Usage: git <subcommand> [<param>...]" echo 'Available commands are:" git bar git foo ... ' exit 1 Alternatively, you could say: #!/bin/sh case "$1" in -h) echo "Usage: git <subcommand> [<param>...]" echo 'Available commands are: git bar git foo ... ' exit 0 ;; esac cmd="git-$1-script"; shift; exec $cmd "$@"; git -h exit 1(2) Maintaining the list of commands by hand in git script
itself have an advantage that you _could_ describe the options and parameters they take, but you are not doing that in your patch (hint, hint). If all you give is the list of subcommand names, have git.in as a source file, and create the "list of available commands" from the Makefile, like this: === Makefile === ... git : git.in /bin/sh ls -1 git-*-script | \ sed -e 's/git-\(.*\)-script/git \1/' >.git-cmd-list sed -e '/@@LIST_OF_COMMANDS@@/{s/.*//;r .git-cmd-list;}' <[email protected] >$@ rm -f .git-cmd-list === git.in === #!/bin/sh cmd="git-$1-script"; shift; exec $cmd "$@"; echo "Usage: git <subcommand> [<param>...]" echo 'Available commands are: @@LIST_OF_COMMANDS@@ '
Quoted 4 lines
-
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Make the git wrapper a little bit more newbie friendly, when called on its own or with the -h flag will return a list of the commands available
---
commit 2ad499f75f0982953e43904085bd1b48dd821c4d
tree f137c4f3f5ee027b8b4d25a0434929e12eb7c51c
parent de4971b50076b5ef901c2ae0bbee9dd2c14f06ea
parent de4971b50076b5ef901c2ae0bbee9dd2c14f06ea
author James Purser <[email protected]> Wed, 15 Jun 2005 07:43:20 committer James Purser <[email protected]> Wed, 15 Jun 2005 07:43:20
git | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 55 insertions(+), 3 deletions(-)
git +55 -3
@@ -1,4 +1,56 @@ #!/bin/sh -cmd="git-$1-script" -shift -exec $cmd "$@" + +case "$1" in +-h|"") + echo "Useage: git <subcommand> [<param 1>, <param 2> ...]" + echo "Available commands are: + +git apply-patch <patch file> + + Applies patch file to local files + +git commit <file 1> <file 2> ... + + Commits local changes to the cache. Before running this script you will need to run git-update-cache on the files you wish to commit. + + Will accept wildcards ie git commit git-*-scripts + +git cvsimport [-v] [-z fuzz] <cvsroot> <module> + + CVS to Git import tool. Relies on the cvsps package at least 2.1 + + -v Verbose output + -z + <cvsroot> Path to CVS Repository + <module> Module you want to import into git + +git deltafy: + +git diff [<File 1>, <File 2>, ...] + + Diffs between the git cache and specified files. If no files are specified then creates a Diff between contents of the cache and all current files. + +git fetch: + +git log: + +git merge-one-file: + +git prune: + +git pull: + +git status: + +git tag: +" + exit 0 ;; +esac + +cmd="git-$1-script"; +shift; +exec $cmd "$@"; +git -h +exit 1 + +