Skip to contentSkip to conversation

make usage text consistent in git commands

PATCH In review David Aguilar 2 participants 20 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

cover make usage text consistent in git commands

Various helper commands around Git say "Usage: ..." when invoked as "git $cmd -h". This is inconsitent with the core git commands which all use the lowercase "usage: ..." form.

Adjust these so that they match the convention used by builtin/help.c and git.c.

I fixed a tiny problem in import-zips.py while I was in there, though it's unlikely that anyone uses such an old Python these days.

There are still one or two results for "git grep Usage:" near the tests, but end users do not ever see them so I figured it was best to leave them as-is.

David Aguilar (16):
git-sh-setup: make usage text consistent
git-svn: make usage text consistent
git-relink: make usage text consistent
git-merge-one-file: make usage text consistent
git-archimport: make usage text consistent
git-cvsexportcommit: make usage text consistent
git-cvsimport: make usage text consistent
git-cvsimport: make usage text consistent contrib/credential: make usage text consistent contrib/fast-import: make usage text consistent contrib/fast-import/import-zips.py: fix broken error message contrib/fast-import/import-zips.py: use spaces instead of tabs contrib/examples: make usage text consistent contrib/hooks/setgitperms.perl: make usage text consistent templates/hooks--update.sample: make usage text consistent Documentation/user-manual.txt: make usage text consistent

 Documentation/user-manual.txt                      |  4 +-
 .../gnome-keyring/git-credential-gnome-keyring.c   |  2 +-
 .../osxkeychain/git-credential-osxkeychain.c       |  2 +-
 .../credential/wincred/git-credential-wincred.c    |  2 +-
 contrib/examples/git-remote.perl                   |  2 +-
 contrib/examples/git-svnimport.perl                |  2 +-
 contrib/fast-import/git-import.perl                |  2 +-
 contrib/fast-import/git-import.sh                  |  2 +-
 contrib/fast-import/import-zips.py                 | 98 +++++++++++-----------
 contrib/hooks/setgitperms.perl                     |  2 +-
 git-archimport.perl                                |  2 +-
 git-cvsexportcommit.perl                           |  2 +-
 git-cvsimport.perl                                 |  2 +-
 git-cvsserver.perl                                 |  2 +-
 git-merge-one-file.sh                              |  2 +-
 git-relink.perl                                    |  2 +-
 git-sh-setup.sh                                    |  6 +-
 git-svn.perl                                       |  2 +-
 templates/hooks--update.sample                     |  2 +-
 19 files changed, 70 insertions(+), 70 deletions(-)
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#1 lore raw

PATCH 1/16 git-sh-setup: make usage text consistent

mergetool, bisect, and other commands that use git-sh-setup print a usage string that is inconsistent with the rest of Git when they are invoked as "git $cmd -h".

The compiled builtins use the lowercase "usage:" string but these commands say "Usage:". Adjust the shell library to make these consistent.

---
 git-sh-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
git-sh-setup.sh +3 -3
index 795edd2..9cfbe7f 100644
@@ -84,14 +84,14 @@ if test -n "$OPTIONS_SPEC"; then
 else
 	dashless=$(basename "$0" | sed -e 's/-/ /')
 	usage() {
-		die "Usage: $dashless $USAGE"
+		die "usage: $dashless $USAGE"
 	}
 
 	if [ -z "$LONG_USAGE" ]
 	then
-		LONG_USAGE="Usage: $dashless $USAGE"
+		LONG_USAGE="usage: $dashless $USAGE"
 	else
-		LONG_USAGE="Usage: $dashless $USAGE
+		LONG_USAGE="usage: $dashless $USAGE
 
 $LONG_USAGE"
 	fi
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#2 lore raw

PATCH 2/16 git-svn: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-svn.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-svn.perl +1 -1
index b46795f..a93166f 100755
@@ -382,7 +382,7 @@ sub usage {
 	my $fd = $exit ? \*STDERR : \*STDOUT;
 	print $fd <<"";
 git-svn - bidirectional operations between a single Subversion tree and git
-Usage: git svn <command> [options] [arguments]\n
+usage: git svn <command> [options] [arguments]\n
 
 	print $fd "Available commands:\n" unless $cmd;
 
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#3 lore raw

PATCH 3/16 git-relink: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-relink.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-relink.perl +1 -1
index f29285c..236a352 100755
@@ -163,7 +163,7 @@ sub link_two_files($$) {
 
 
 sub usage() {
-	print("Usage: git relink [--safe] <dir>... <master_dir> \n");
+	print("usage: git relink [--safe] <dir>... <master_dir> \n");
 	print("All directories should contain a .git/objects/ subdirectory.\n");
 	print("Options\n");
 	print("\t--safe\t" .
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#4 lore raw

PATCH 4/16 git-merge-one-file: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-merge-one-file.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-merge-one-file.sh +1 -1
index f612cb8..3373c04 100755
@@ -18,7 +18,7 @@
 
 USAGE='<orig blob> <our blob> <their blob> <path>'
 USAGE="$USAGE <orig mode> <our mode> <their mode>"
-LONG_USAGE="Usage: git merge-one-file $USAGE
+LONG_USAGE="usage: git merge-one-file $USAGE
 
 Blob ids and modes should be empty for missing files."
 
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#5 lore raw

PATCH 5/16 git-archimport: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-archimport.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-archimport.perl +1 -1
index bc32f18..9cb123a 100755
@@ -75,7 +75,7 @@ our($opt_h,$opt_f,$opt_v,$opt_T,$opt_t,$opt_D,$opt_a,$opt_o);
 
 sub usage() {
     print STDERR <<END;
-Usage: git archimport     # fetch/update GIT from Arch
+usage: git archimport     # fetch/update GIT from Arch
        [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ] [ -D depth ] [ -t tempdir ]
        repository/arch-branch [ repository/arch-branch] ...
 END
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#6 lore raw

PATCH 6/16 git-cvsexportcommit: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-cvsexportcommit.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-cvsexportcommit.perl +1 -1
index e6bf252..d13f02d 100755
@@ -420,7 +420,7 @@ sleep(1);
 
 sub usage {
 	print STDERR <<END;
-Usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c] [-f] [-u] [-k] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
+usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c] [-f] [-u] [-k] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
 END
 	exit(1);
 }
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#7 lore raw

PATCH 7/16 git-cvsimport: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-cvsimport.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-cvsimport.perl +1 -1
index 344f120..73d367c 100755
@@ -38,7 +38,7 @@ sub usage(;$) {
 	my $msg = shift;
 	print(STDERR "Error: $msg\n") if $msg;
 	print STDERR <<END;
-Usage: git cvsimport     # fetch/update GIT from CVS
+usage: git cvsimport     # fetch/update GIT from CVS
        [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
        [-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]
        [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#8 lore raw

PATCH 8/16 git-cvsimport: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 git-cvsserver.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-cvsserver.perl +1 -1
index 3679074..f1c3f49 100755
@@ -107,7 +107,7 @@ my $work =
 $log->info("--------------- STARTING -----------------");
 
 my $usage =
-    "Usage: git cvsserver [options] [pserver|server] [<directory> ...]\n".
+    "usage: git cvsserver [options] [pserver|server] [<directory> ...]\n".
     "    --base-path <path>  : Prepend to requested CVSROOT\n".
     "                          Can be read from GIT_CVSSERVER_BASE_PATH\n".
     "    --strict-paths      : Don't allow recursing into subdirectories\n".
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#9 lore raw

PATCH 9/16 contrib/credential: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-
 contrib/credential/osxkeychain/git-credential-osxkeychain.c     | 2 +-
 contrib/credential/wincred/git-credential-wincred.c             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c +1 -1
index 41f61c5..f2cdefe 100644
@@ -401,7 +401,7 @@ static void usage(const char *name)
 	const char *basename = strrchr(name,'/');
 
 	basename = (basename) ? basename + 1 : name;
-	fprintf(stderr, "Usage: %s <", basename);
+	fprintf(stderr, "usage: %s <", basename);
 	while(try_op->name) {
 		fprintf(stderr,"%s",(try_op++)->name);
 		if(try_op->name)
contrib/credential/osxkeychain/git-credential-osxkeychain.c +1 -1
index 6beed12..3940202 100644
@@ -154,7 +154,7 @@ static void read_credential(void)
 int main(int argc, const char **argv)
 {
 	const char *usage =
-		"Usage: git credential-osxkeychain <get|store|erase>";
+		"usage: git credential-osxkeychain <get|store|erase>";
 
 	if (!argv[1])
 		die(usage);
contrib/credential/wincred/git-credential-wincred.c +1 -1
index cbaec5f..6619492 100644
@@ -313,7 +313,7 @@ static void read_credential(void)
 int main(int argc, char *argv[])
 {
 	const char *usage =
-	    "Usage: git credential-wincred <get|store|erase>\n";
+	    "usage: git credential-wincred <get|store|erase>\n";
 
 	if (!argv[1])
 		die(usage);
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#10 lore raw

PATCH 10/16 contrib/fast-import: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 contrib/fast-import/git-import.perl | 2 +-
 contrib/fast-import/git-import.sh   | 2 +-
 contrib/fast-import/import-zips.py  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
contrib/fast-import/git-import.perl +1 -1
index f9fef6d..0891b9e 100755
@@ -7,7 +7,7 @@
 use strict;
 use File::Find;
 
-my $USAGE = 'Usage: git-import branch import-message';
+my $USAGE = 'usage: git-import branch import-message';
 my $branch = shift or die "$USAGE\n";
 my $message = shift or die "$USAGE\n";
 
contrib/fast-import/git-import.sh +1 -1
index 0ca7718..f8d803c 100755
@@ -5,7 +5,7 @@
 # but is meant to be a simple fast-import example.
 
 if [ -z "$1" -o -z "$2" ]; then
-	echo "Usage: git-import branch import-message"
+	echo "usage: git-import branch import-message"
 	exit 1
 fi
 
contrib/fast-import/import-zips.py +1 -1
index 5cec9b0..f54c65b 100755
@@ -19,7 +19,7 @@ if hexversion < 0x01060000:
         sys.exit(1)
 
 if len(argv) < 2:
-	print 'Usage:', argv[0], '<zipfile>...'
+	print 'usage:', argv[0], '<zipfile>...'
 	exit(1)
 
 branch_ref = 'refs/heads/import-zips'
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#11 lore raw

PATCH 11/16 contrib/fast-import/import-zips.py: fix broken error message

The 'sys' module is not imported but all of the bits we want from it are. Adjust the script to not fail when run on old Python versions and fix the inconsistent use of tabs.

---
 contrib/fast-import/import-zips.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
contrib/fast-import/import-zips.py +3 -3
index f54c65b..b528798 100755
@@ -14,9 +14,9 @@ from time import mktime
 from zipfile import ZipFile
 
 if hexversion < 0x01060000:
-        # The limiter is the zipfile module
-        sys.stderr.write("import-zips.py: requires Python 1.6.0 or later.\n")
-        sys.exit(1)
+	# The limiter is the zipfile module
+	stderr.write("import-zips.py: requires Python 1.6.0 or later.\n")
+	exit(1)
 
 if len(argv) < 2:
 	print 'usage:', argv[0], '<zipfile>...'
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#12 lore raw

PATCH 12/16 contrib/fast-import/import-zips.py: use spaces instead of tabs

Follow the conventional Python style by using 4-space indents instead of hard tabs.

---
 contrib/fast-import/import-zips.py | 98 +++++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 49 deletions(-)
contrib/fast-import/import-zips.py +49 -49
index b528798..d12c296 100755
@@ -14,13 +14,13 @@ from time import mktime
 from zipfile import ZipFile
 
 if hexversion < 0x01060000:
-	# The limiter is the zipfile module
-	stderr.write("import-zips.py: requires Python 1.6.0 or later.\n")
-	exit(1)
+    # The limiter is the zipfile module
+    stderr.write("import-zips.py: requires Python 1.6.0 or later.\n")
+    exit(1)
 
 if len(argv) < 2:
-	print 'usage:', argv[0], '<zipfile>...'
-	exit(1)
+    print 'usage:', argv[0], '<zipfile>...'
+    exit(1)
 
 branch_ref = 'refs/heads/import-zips'
 committer_name = 'Z Ip Creator'
@@ -28,51 +28,51 @@ committer_email = '[email protected]'
 
 fast_import = popen('git fast-import --quiet', 'w')
 def printlines(list):
-	for str in list:
-		fast_import.write(str + "\n")
+    for str in list:
+        fast_import.write(str + "\n")
 
 for zipfile in argv[1:]:
-	commit_time = 0
-	next_mark = 1
-	common_prefix = None
-	mark = dict()
-
-	zip = ZipFile(zipfile, 'r')
-	for name in zip.namelist():
-		if name.endswith('/'):
-			continue
-		info = zip.getinfo(name)
-
-		if commit_time < info.date_time:
-			commit_time = info.date_time
-		if common_prefix == None:
-			common_prefix = name[:name.rfind('/') + 1]
-		else:
-			while not name.startswith(common_prefix):
-				last_slash = common_prefix[:-1].rfind('/') + 1
-				common_prefix = common_prefix[:last_slash]
-
-		mark[name] = ':' + str(next_mark)
-		next_mark += 1
-
-		printlines(('blob', 'mark ' + mark[name], \
-					'data ' + str(info.file_size)))
-		fast_import.write(zip.read(name) + "\n")
-
-	committer = committer_name + ' <' + committer_email + '> %d +0000' % \
-		mktime(commit_time + (0, 0, 0))
-
-	printlines(('commit ' + branch_ref, 'committer ' + committer, \
-		'data <<EOM', 'Imported from ' + zipfile + '.', 'EOM', \
-		'', 'deleteall'))
-
-	for name in mark.keys():
-		fast_import.write('M 100644 ' + mark[name] + ' ' +
-			name[len(common_prefix):] + "\n")
-
-	printlines(('',  'tag ' + path.basename(zipfile), \
-		'from ' + branch_ref, 'tagger ' + committer, \
-		'data <<EOM', 'Package ' + zipfile, 'EOM', ''))
+    commit_time = 0
+    next_mark = 1
+    common_prefix = None
+    mark = dict()
+
+    zip = ZipFile(zipfile, 'r')
+    for name in zip.namelist():
+        if name.endswith('/'):
+            continue
+        info = zip.getinfo(name)
+
+        if commit_time < info.date_time:
+            commit_time = info.date_time
+        if common_prefix == None:
+            common_prefix = name[:name.rfind('/') + 1]
+        else:
+            while not name.startswith(common_prefix):
+                last_slash = common_prefix[:-1].rfind('/') + 1
+                common_prefix = common_prefix[:last_slash]
+
+        mark[name] = ':' + str(next_mark)
+        next_mark += 1
+
+        printlines(('blob', 'mark ' + mark[name], \
+                    'data ' + str(info.file_size)))
+        fast_import.write(zip.read(name) + "\n")
+
+    committer = committer_name + ' <' + committer_email + '> %d +0000' % \
+        mktime(commit_time + (0, 0, 0))
+
+    printlines(('commit ' + branch_ref, 'committer ' + committer, \
+        'data <<EOM', 'Imported from ' + zipfile + '.', 'EOM', \
+        '', 'deleteall'))
+
+    for name in mark.keys():
+        fast_import.write('M 100644 ' + mark[name] + ' ' +
+            name[len(common_prefix):] + "\n")
+
+    printlines(('',  'tag ' + path.basename(zipfile), \
+        'from ' + branch_ref, 'tagger ' + committer, \
+        'data <<EOM', 'Package ' + zipfile, 'EOM', ''))
 
 if fast_import.close():
-	exit(1)
+    exit(1)
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#13 lore raw

PATCH 13/16 contrib/examples: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 contrib/examples/git-remote.perl    | 2 +-
 contrib/examples/git-svnimport.perl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
contrib/examples/git-remote.perl +1 -1
index b17952a..b549a3c 100755
@@ -347,7 +347,7 @@ sub rm_remote {
 }
 
 sub add_usage {
-	print STDERR "Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\n";
+	print STDERR "usage: git remote add [-f] [-t track]* [-m master] <name> <url>\n";
 	exit(1);
 }
 
contrib/examples/git-svnimport.perl +1 -1
index b09ff8f..c414f0d 100755
@@ -36,7 +36,7 @@ our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,
 
 sub usage() {
 	print STDERR <<END;
-Usage: ${\basename $0}     # fetch/update GIT from SVN
+usage: ${\basename $0}     # fetch/update GIT from SVN
        [-o branch-for-HEAD] [-h] [-v] [-l max_rev] [-R repack_each_revs]
        [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
        [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#14 lore raw

PATCH 14/16 contrib/hooks/setgitperms.perl: make usage text consistent

Use a lowercase "usage:" string for consistency with Git with Git with Git with Git.

---
 contrib/hooks/setgitperms.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/hooks/setgitperms.perl +1 -1
index a577ad0..2770a1b 100644
@@ -24,7 +24,7 @@ use File::Find;
 use File::Basename;
 
 my $usage =
-"Usage: setgitperms.perl [OPTION]... <--read|--write>
+"usage: setgitperms.perl [OPTION]... <--read|--write>
 This program uses a file `.gitmeta` to store/restore permissions and uid/gid
 info for all files/dirs tracked by git in the repository.
 
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#15 lore raw

PATCH 15/16 templates/hooks--update.sample: make usage text consistent

Use a lowercase "usage:" string for consistency with Git.

---
 templates/hooks--update.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
templates/hooks--update.sample +1 -1
index 71ab04e..d847583 100755
@@ -38,7 +38,7 @@ if [ -z "$GIT_DIR" ]; then
 fi
 
 if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
-	echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
+	echo "usage: $0 <ref> <oldrev> <newrev>" >&2
 	exit 1
 fi
 
Signature · 1 line
1.8.2.rc0.247.g811e0c0
#16 lore raw

PATCH 16/16 Documentation/user-manual.txt: make usage text consistent

Use a lowercase "usage:" string in the example script for consistency with Git.

---
 Documentation/user-manual.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/user-manual.txt +2 -2
index 5f36f81..35a279a 100644
@@ -2337,7 +2337,7 @@ origin)
 	fi
 	;;
 *)
-	echo "Usage: $0 origin|test|release" 1>&2
+	echo "usage: $0 origin|test|release" 1>&2
 	exit 1
 	;;
 esac
@@ -2351,7 +2351,7 @@ pname=$0
 
 usage()
 {
-	echo "Usage: $pname branch test|release" 1>&2
+	echo "usage: $pname branch test|release" 1>&2
 	exit 1
 }
 
Signature · 1 line
1.8.2.rc0.247.g811e0c0
Reviewed-by on v1 1/16
#17 lore raw

Re: [PATCH 01/16] git-sh-setup: make usage text consistent

In reply to David Aguilar
Quoted 7 lines · David Aguilar

mergetool, bisect, and other commands that use git-sh-setup print a usage string that is inconsistent with the rest of Git when they are invoked as "git $cmd -h".

The compiled builtins use the lowercase "usage:" string but these commands say "Usage:". Adjust the shell library to make these consistent.

Scripts could be grepping for Usage:, but they are asking for trouble and if anything should check for status 129 instead. And luckily we have been careful about not checking for this in tests. Thanks for the fix.

Reviewed-by on the v1 series
#18 lore raw
In reply to David Aguilar
Quoted 3 lines · David Aguilar

git-sh-setup: make usage text consistent
git-svn: make usage text consistent
git-relink: make usage text consistent

[...]

Micronit: titles like

git-relink: use a lowercase "usage:" string

would make the effect of these patches easier to see in the shortlog.

With or without that change, all of these except patches 11 and 12 are

I have no opinion about patches 11 and 12. :)

Thanks,
Jonathan

#19 lore raw
Quoted 11 lines · Jonathan Nieder
Quoted 3 lines · David Aguilar

git-sh-setup: make usage text consistent
git-svn: make usage text consistent
git-relink: make usage text consistent

[...]

Micronit: titles like

git-relink: use a lowercase "usage:" string

Quoted 7 lines

would make the effect of these patches easier to see in the shortlog.

With or without that change, all of these except patches 11 and 12 are

I have no opinion about patches 11 and 12. :)

Thanks for the review. I will post a re-roll later to fix these.

Signature · 1 line
David