usage: do not insist that standard input must come from a file

The synopsys text and the usage string of subcommands that read list of things from the standard input are often shown like this: git gostak [--distim] < <list-of-doshes> This is problematic in a number of ways: * The way to use these commands is more often to feed them the output from another command, not feed them from a file. * Manual pages outside Git, commands that operate on the data read from the standard input, e.g "sort", "grep", "sed", etc., are not described with such a "< redirection-from-file" in their synopsys text. Our doing so introduces inconsistency. * We do not insist on where the output should go, by saying git gostak [--distim] < <list-of-doshes> > <output> * As it is our convention to enclose placeholders inside <braket>, the redirection operator followed by a placeholder filename becomes very hard to read, both in the documentation and in the help text. Let's clean them all up, after making sure that the documentation clearly describes the modes that take information from the standard input and what kind of things are expected on the input. [jc: stole example for fmt-merge-msg from Jonathan] Helped-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 16, 2015 at 11:27 UTC 33e8fc87407505c3a96792fc47189d57b97b34c3
25 files changed +64 -41
Documentation/git-cat-file.txt
+1 -1
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git cat-file' (-t [--allow-unknown-type]| -s [--allow-unknown-type]| -e | -p | <type> | --textconv ) <object>
13 -'git cat-file' (--batch | --batch-check) [--follow-symlinks] < <list-of-objects>
13 +'git cat-file' (--batch | --batch-check) [--follow-symlinks]
14
15 DESCRIPTION
16 -----------
Documentation/git-check-attr.txt
+3 -2
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git check-attr' [-a | --all | attr...] [--] pathname...
13 -'git check-attr' --stdin [-z] [-a | --all | attr...] < <list-of-paths>
13 +'git check-attr' --stdin [-z] [-a | --all | attr...]
14
15 DESCRIPTION
16 -----------
@@ -28,7 +28,8 @@ OPTIONS
28 Consider `.gitattributes` in the index only, ignoring the working tree.
29
30 --stdin::
31 - Read file names from stdin instead of from the command-line.
31 + Read pathnames from the standard input, one per line,
32 + instead of from the command-line.
33
34 -z::
35 The output format is modified to be machine-parseable.
Documentation/git-check-ignore.txt
+3 -2
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git check-ignore' [options] pathname...
13 -'git check-ignore' [options] --stdin < <list-of-paths>
13 +'git check-ignore' [options] --stdin
14
15 DESCRIPTION
16 -----------
@@ -35,7 +35,8 @@ OPTIONS
35 for each given pathname.
36
37 --stdin::
38 - Read file names from stdin instead of from the command-line.
38 + Read pathnames from the standard input, one per line,
39 + instead of from the command-line.
40
41 -z::
42 The output format is modified to be machine-parseable (see
Documentation/git-commit-tree.txt
+1 -1
@@ -9,7 +9,7 @@ git-commit-tree - Create a new commit object
9 SYNOPSIS
10 --------
11 [verse]
12 -'git commit-tree' <tree> [(-p <parent>)...] < changelog
12 +'git commit-tree' <tree> [(-p <parent>)...]
13 'git commit-tree' [(-p <parent>)...] [-S[<keyid>]] [(-m <message>)...]
14 [(-F <file>)...] <tree>
15
Documentation/git-fmt-merge-msg.txt
+13 -1
@@ -9,7 +9,7 @@ git-fmt-merge-msg - Produce a merge commit message
9 SYNOPSIS
10 --------
11 [verse]
12 -'git fmt-merge-msg' [-m <message>] [--log[=<n>] | --no-log] <$GIT_DIR/FETCH_HEAD
12 +'git fmt-merge-msg' [-m <message>] [--log[=<n>] | --no-log]
13 'git fmt-merge-msg' [-m <message>] [--log[=<n>] | --no-log] -F <file>
14
15 DESCRIPTION
@@ -57,6 +57,18 @@ merge.summary::
57 Synonym to `merge.log`; this is deprecated and will be removed in
58 the future.
59
60 +EXAMPLE
61 +-------
62 +
63 +--
64 +$ git fetch origin master
65 +$ git fmt-merge-msg --log <$GIT_DIR/FETCH_HEAD
66 +--
67 +
68 +Print a log message describing a merge of the "master" branch from
69 +the "origin" remote.
70 +
71 +
72 SEE ALSO
73 --------
74 linkgit:git-merge[1]
Documentation/git-get-tar-commit-id.txt
+7 -5
@@ -9,17 +9,19 @@ git-get-tar-commit-id - Extract commit ID from an archive created using git-arch
9 SYNOPSIS
10 --------
11 [verse]
12 -'git get-tar-commit-id' < <tarfile>
12 +'git get-tar-commit-id'
13
14
15 DESCRIPTION
16 -----------
17 -Acts as a filter, extracting the commit ID stored in archives created by
18 -'git archive'. It reads only the first 1024 bytes of input, thus its
19 -runtime is not influenced by the size of <tarfile> very much.
17 +
18 +Read a tar archive created by 'git archive' from the standard input
19 +and extract the commit ID stored in it. It reads only the first
20 +1024 bytes of input, thus its runtime is not influenced by the size
21 +of the tar archive very much.
22
23 If no commit ID is found, 'git get-tar-commit-id' quietly exists with a
22 -return code of 1. This can happen if <tarfile> had not been created
24 +return code of 1. This can happen if the archive had not been created
25 using 'git archive' or if the first parameter of 'git archive' had been
26 a tree ID instead of a commit ID or tag.
27
Documentation/git-hash-object.txt
+3 -2
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git hash-object' [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin [--literally]] [--] <file>...
13 -'git hash-object' [-t <type>] [-w] --stdin-paths [--no-filters] < <list-of-paths>
13 +'git hash-object' [-t <type>] [-w] --stdin-paths [--no-filters]
14
15 DESCRIPTION
16 -----------
@@ -35,7 +35,8 @@ OPTIONS
35 Read the object from standard input instead of from a file.
36
37 --stdin-paths::
38 - Read file names from stdin instead of from the command-line.
38 + Read file names from the standard input, one per line, instead
39 + of from the command-line.
40
41 --path::
42 Hash object as it were located at the given path. The location of
Documentation/git-mktag.txt
+3 -2
@@ -9,7 +9,7 @@ git-mktag - Creates a tag object
9 SYNOPSIS
10 --------
11 [verse]
12 -'git mktag' < signature_file
12 +'git mktag'
13
14 DESCRIPTION
15 -----------
@@ -20,7 +20,8 @@ The output is the new tag's <object> identifier.
20
21 Tag Format
22 ----------
23 -A tag signature file has a very simple fixed format: four lines of
23 +A tag signature file, to be fed to this command's standard input,
24 +has a very simple fixed format: four lines of
25
26 object <sha1>
27 type <typename>
Documentation/git-patch-id.txt
+3 -1
@@ -8,10 +8,12 @@ git-patch-id - Compute unique ID for a patch
8 SYNOPSIS
9 --------
10 [verse]
11 -'git patch-id' [--stable | --unstable] < <patch>
11 +'git patch-id' [--stable | --unstable]
12
13 DESCRIPTION
14 -----------
15 +Read a patch from the standard input and compute the patch ID for it.
16 +
17 A "patch ID" is nothing but a sum of SHA-1 of the file diffs associated with a
18 patch, with whitespace and line numbers ignored. As such, it's "reasonably
19 stable", but at the same time also reasonably unique, i.e., two patches that
Documentation/git-show-index.txt
+4 -3
@@ -9,13 +9,14 @@ git-show-index - Show packed archive index
9 SYNOPSIS
10 --------
11 [verse]
12 -'git show-index' < idx-file
12 +'git show-index'
13
14
15 DESCRIPTION
16 -----------
17 -Reads given idx file for packed Git archive created with
18 -'git pack-objects' command, and dumps its contents.
17 +Read the idx file for a Git packfile created with
18 +'git pack-objects' command from the standard input, and
19 +dump its contents.
20
21 The information it outputs is subset of what you can get from
22 'git verify-pack -v'; this command only shows the packfile
Documentation/git-show-ref.txt
+4 -3
@@ -11,7 +11,7 @@ SYNOPSIS
11 'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
12 [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
13 [--heads] [--] [<pattern>...]
14 -'git show-ref' --exclude-existing[=<pattern>] < ref-list
14 +'git show-ref' --exclude-existing[=<pattern>]
15
16 DESCRIPTION
17 -----------
@@ -23,8 +23,9 @@ particular ref exists.
23
24 By default, shows the tags, heads, and remote refs.
25
26 -The --exclude-existing form is a filter that does the inverse, it shows the
27 -refs from stdin that don't exist in the local repository.
26 +The --exclude-existing form is a filter that does the inverse. It reads
27 +refs from stdin, one ref per line, and shows those that don't exist in
28 +the local repository.
29
30 Use of this utility is encouraged in favor of directly accessing files under
31 the `.git` directory.
Documentation/git-stripspace.txt
+5 -4
@@ -9,14 +9,15 @@ git-stripspace - Remove unnecessary whitespace
9 SYNOPSIS
10 --------
11 [verse]
12 -'git stripspace' [-s | --strip-comments] < input
13 -'git stripspace' [-c | --comment-lines] < input
12 +'git stripspace' [-s | --strip-comments]
13 +'git stripspace' [-c | --comment-lines]
14
15 DESCRIPTION
16 -----------
17
18 -Clean the input in the manner used by Git for text such as commit
19 -messages, notes, tags and branch descriptions.
18 +Read text, such as commit messages, notes, tags and branch
19 +descriptions, from the standard input and clean it in the manner
20 +used by Git.
21
22 With no arguments, this will:
23
Documentation/git-unpack-objects.txt
+1 -1
@@ -9,7 +9,7 @@ git-unpack-objects - Unpack objects from a packed archive
9 SYNOPSIS
10 --------
11 [verse]
12 -'git unpack-objects' [-n] [-q] [-r] [--strict] < <packfile>
12 +'git unpack-objects' [-n] [-q] [-r] [--strict]
13
14
15 DESCRIPTION
builtin/cat-file.c
+1 -1
@@ -426,7 +426,7 @@ static int batch_objects(struct batch_options *opt)
426
427 static const char * const cat_file_usage[] = {
428 N_("git cat-file (-t [--allow-unknown-type]|-s [--allow-unknown-type]|-e|-p|<type>|--textconv) <object>"),
429 - N_("git cat-file (--batch | --batch-check) [--follow-symlinks] < <list-of-objects>"),
429 + N_("git cat-file (--batch | --batch-check) [--follow-symlinks]"),
430 NULL
431 };
432
builtin/check-attr.c
+1 -1
@@ -9,7 +9,7 @@ static int cached_attrs;
9 static int stdin_paths;
10 static const char * const check_attr_usage[] = {
11 N_("git check-attr [-a | --all | <attr>...] [--] <pathname>..."),
12 -N_("git check-attr --stdin [-z] [-a | --all | <attr>...] < <list-of-paths>"),
12 +N_("git check-attr --stdin [-z] [-a | --all | <attr>...]"),
13 NULL
14 };
15
builtin/check-ignore.c
+1 -1
@@ -8,7 +8,7 @@
8 static int quiet, verbose, stdin_paths, show_non_matching, no_index;
9 static const char * const check_ignore_usage[] = {
10 "git check-ignore [<options>] <pathname>...",
11 -"git check-ignore [<options>] --stdin < <list-of-paths>",
11 +"git check-ignore [<options>] --stdin",
12 NULL
13 };
14
builtin/commit-tree.c
+1 -1
@@ -10,7 +10,7 @@
10 #include "utf8.h"
11 #include "gpg-interface.h"
12
13 -static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [-m <message>] [-F <file>] <sha1> <changelog";
13 +static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [-m <message>] [-F <file>] <sha1>";
14
15 static const char *sign_commit;
16
builtin/get-tar-commit-id.c
+1 -1
@@ -8,7 +8,7 @@
8 #include "quote.h"
9
10 static const char builtin_get_tar_commit_id_usage[] =
11 -"git get-tar-commit-id < <tarfile>";
11 +"git get-tar-commit-id";
12
13 /* ustar header + extended global header content */
14 #define RECORDSIZE (512)
builtin/hash-object.c
+1 -1
@@ -78,7 +78,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
78 {
79 static const char * const hash_object_usage[] = {
80 N_("git hash-object [-t <type>] [-w] [--path=<file> | --no-filters] [--stdin] [--] <file>..."),
81 - N_("git hash-object --stdin-paths < <list-of-paths>"),
81 + N_("git hash-object --stdin-paths"),
82 NULL
83 };
84 const char *type = blob_type;
builtin/mktag.c
+1 -1
@@ -154,7 +154,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
154 unsigned char result_sha1[20];
155
156 if (argc != 1)
157 - usage("git mktag < signaturefile");
157 + usage("git mktag");
158
159 if (strbuf_read(&buf, 0, 4096) < 0) {
160 die_errno("could not read from stdin");
builtin/patch-id.c
+1 -1
@@ -165,7 +165,7 @@ static void generate_id_list(int stable)
165 strbuf_release(&line_buf);
166 }
167
168 -static const char patch_id_usage[] = "git patch-id [--stable | --unstable] < patch";
168 +static const char patch_id_usage[] = "git patch-id [--stable | --unstable]";
169
170 static int git_patch_id_config(const char *var, const char *value, void *cb)
171 {
builtin/show-ref.c
+1 -1
@@ -8,7 +8,7 @@
8
9 static const char * const show_ref_usage[] = {
10 N_("git show-ref [-q | --quiet] [--verify] [--head] [-d | --dereference] [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [<pattern>...]"),
11 - N_("git show-ref --exclude-existing[=<pattern>] < <ref-list>"),
11 + N_("git show-ref --exclude-existing[=<pattern>]"),
12 NULL
13 };
14
builtin/stripspace.c
+2 -2
@@ -78,8 +78,8 @@ static void comment_lines(struct strbuf *buf)
78 }
79
80 static const char *usage_msg = "\n"
81 -" git stripspace [-s | --strip-comments] < input\n"
82 -" git stripspace [-c | --comment-lines] < input";
81 +" git stripspace [-s | --strip-comments]\n"
82 +" git stripspace [-c | --comment-lines]";
83
84 int cmd_stripspace(int argc, const char **argv, const char *prefix)
85 {
builtin/unpack-objects.c
+1 -1
@@ -13,7 +13,7 @@
13 #include "fsck.h"
14
15 static int dry_run, quiet, recover, has_errors, strict;
16 -static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict] < pack-file";
16 +static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict]";
17
18 /* We always read in 4kB chunks. */
19 static unsigned char buffer[4096];
show-index.c
+1 -1
@@ -2,7 +2,7 @@
2 #include "pack.h"
3
4 static const char show_index_usage[] =
5 -"git show-index < <packed archive index>";
5 +"git show-index";
6
7 int main(int argc, char **argv)
8 {