threads / patch / 925

patchAdding Correct Useage Notification and -h Help flag

Subject: [PATCH] Adding Correct Useage Notification and -h Help flag

## tl;dr

6 messages between Jun 14, 2005 and Jun 14, 2005. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

James Purser· Jun 14, 2005, 01:47 UTC · lore
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.

Signed-off-by: James Purser <purserj@k-sit.com>
-- 
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 <purserj@k-sit.com> Tue, 14 Jun 2005 11:40:20 +1000
committer James Purser <purserj@k-sit.com> Tue, 14 Jun 2005 11:40:20 +1000

 git |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/git b/git
--- a/git
+++ b/git
@@ -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
+
Junio C Hamano· Jun 14, 2005, 02:23 UTC · re: James Purser · lore

Re: [PATCH] Adding Correct Useage Notification and -h Help flag

>>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;}' <$@.in >$@
         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@@
     '
James Purser· Jun 14, 2005, 02:28 UTC · re: Junio C Hamano · lore

Re: [PATCH] Adding Correct Useage Notification and -h Help flag

Thanks for the tips, I shall submit a new patch along these lines when I get home from work tonight.

On Tue, 2005-06-14 at 12:23, Junio C Hamano wrote:
Show 79 quoted 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;}' <$@.in >$@
>          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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
James Purser
Winnet Developer
+61 2 4223 4131
http://www.winnet.com.au
James Purser· Jun 14, 2005, 05:25 UTC · re: Junio C Hamano · lore

Re: [PATCH] Adding Correct Useage Notification and -h Help flag

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.

-- 
James Purser
Winnet Developer
+61 2 4223 4131
http://www.winnet.com.au
Junio C Hamano· Jun 14, 2005, 05:52 UTC · re: James Purser · lore

Re: [PATCH] Adding Correct Useage Notification and -h Help flag

>>>>> "JP" == James Purser <purserj@winnsw.com.au> 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.

James Purser· Jun 14, 2005, 21:49 UTC · re: Junio C Hamano · lore

Re: [PATCH] Adding Correct Useage Notification and -h Help flag

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.

Signed-off-by: James Purser <purserj@k-sit.com>
On Tue, 2005-06-14 at 12:23, Junio C Hamano wrote:
Show 79 quoted 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;}' <$@.in >$@
>          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 majordomo@vger.kernel.org
> 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 <purserj@k-sit.com> Wed, 15 Jun 2005 07:43:20 committer James Purser <purserj@k-sit.com> Wed, 15 Jun 2005 07:43:20

 git |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 55 insertions(+), 3 deletions(-)
Show changes to git +55 −3
diff --git a/git b/git
--- a/git
+++ b/git
@@ -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
+
+

← back to recent threads