From 00bf685975d7a4a163d8a57d1a666ae6642c6441 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 19 May 2023 04:17:49 +0000 Subject: [PATCH 1/6] show-ref doc: update for internal consistency - Use inline-code syntax for options where appropriate. - Use code blocks to clarify output format. - Use 'OID' (for 'object ID') instead of 'SHA-1' as we support different hashing algorithms these days. Signed-off-by: Sean Allred Signed-off-by: Junio C Hamano --- Documentation/git-show-ref.txt | 40 ++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt index d1d56f68b4..44c7387d78 100644 --- a/Documentation/git-show-ref.txt +++ b/Documentation/git-show-ref.txt @@ -23,7 +23,7 @@ particular ref exists. By default, shows the tags, heads, and remote refs. -The --exclude-existing form is a filter that does the inverse. It reads +The `--exclude-existing` form is a filter that does the inverse. It reads refs from stdin, one ref per line, and shows those that don't exist in the local repository. @@ -47,14 +47,14 @@ OPTIONS -d:: --dereference:: - Dereference tags into object IDs as well. They will be shown with "{caret}{}" + Dereference tags into object IDs as well. They will be shown with `{caret}{}` appended. -s:: --hash[=]:: - Only show the SHA-1 hash, not the reference name. When combined with - --dereference the dereferenced tag will still be shown after the SHA-1. + Only show the OID, not the reference name. When combined with + `--dereference`, the dereferenced tag will still be shown after the OID. --verify:: @@ -70,15 +70,15 @@ OPTIONS -q:: --quiet:: - Do not print any results to stdout. When combined with `--verify` this + Do not print any results to stdout. When combined with `--verify`, this can be used to silently check if a reference exists. --exclude-existing[=]:: - Make 'git show-ref' act as a filter that reads refs from stdin of the - form "`^(?:\s)?(?:\^{})?$`" + Make `git show-ref` act as a filter that reads refs from stdin of the + form `^(?:\s)?(?:\^{})?$` and performs the following actions on each: - (1) strip "{caret}{}" at the end of line if any; + (1) strip `{caret}{}` at the end of line if any; (2) ignore if pattern is provided and does not head-match refname; (3) warn if refname is not a well-formed refname and skip; (4) ignore if refname is a ref that exists in the local repository; @@ -96,7 +96,13 @@ OPTIONS OUTPUT ------ -The output is in the format: '' '' ''. +The output is in the format: + +------------ + SP LF +------------ + +For example, ----------------------------------------------------------------------------- $ git show-ref --head --dereference @@ -110,7 +116,13 @@ $ git show-ref --head --dereference ... ----------------------------------------------------------------------------- -When using --hash (and not --dereference) the output format is: '' +When using `--hash` (and not `--dereference`), the output is in the format: + +------------ + LF +------------ + +For example, ----------------------------------------------------------------------------- $ git show-ref --heads --hash @@ -142,10 +154,10 @@ When using the `--verify` flag, the command requires an exact path: will only match the exact branch called "master". -If nothing matches, 'git show-ref' will return an error code of 1, +If nothing matches, `git show-ref` will return an error code of 1, and in the case of verification, it will show an error message. -For scripting, you can ask it to be quiet with the "--quiet" flag, which +For scripting, you can ask it to be quiet with the `--quiet` flag, which allows you to do things like ----------------------------------------------------------------------------- @@ -157,11 +169,11 @@ to check whether a particular branch exists or not (notice how we don't actually want to show any results, and we want to use the full refname for it in order to not trigger the problem with ambiguous partial matches). -To show only tags, or only proper branch heads, use "--tags" and/or "--heads" +To show only tags, or only proper branch heads, use `--tags` and/or `--heads` respectively (using both means that it shows tags and heads, but not other random references under the refs/ subdirectory). -To do automatic tag object dereferencing, use the "-d" or "--dereference" +To do automatic tag object dereferencing, use the `-d` or `--dereference` flag, so you can do ----------------------------------------------------------------------------- From 0f45b5bc32c177461793b11650baed4018a740aa Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 19 May 2023 04:17:50 +0000 Subject: [PATCH 2/6] show-branch doc: say , not The glossary defines 'ref' as the official name of the thing, and the output from "git grep -e ', not . In addition, the page already says in its SYNOPSIS section for the command when it is used in the mode to follow the reflogs. Strictly speaking, many references of these should be updated to after adding an explanation on how these s are discovered (i.e. we take , , or and starting from these commits, follow their ancestry or reflog entries to list commits), but that would be a lot bigger change I would rather not to do in this patch, whose primary purpose is to make the existing documentation more consistent. Signed-off-by: Junio C Hamano Signed-off-by: Sean Allred Signed-off-by: Junio C Hamano --- Documentation/git-show-branch.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index 71f608b1ff..58cf6210cd 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -74,8 +74,7 @@ OPTIONS that is the common ancestor of all the branches. This flag tells the command to go more common commits beyond that. When is negative, display only the - s given, without showing the commit ancestry - tree. + s given, without showing the commit ancestry tree. --list:: Synonym to `--more=-1` @@ -88,8 +87,8 @@ OPTIONS the case of three or more commits. --independent:: - Among the s given, display only the ones that - cannot be reached from any other . + Among the s given, display only the ones that cannot be + reached from any other . --no-name:: Do not show naming strings for each commit. @@ -132,10 +131,11 @@ are mutually exclusive. OUTPUT ------ -Given N , the first N lines are the one-line -description from their commit message. The branch head that is -pointed at by $GIT_DIR/HEAD is prefixed with an asterisk `*` -character while other heads are prefixed with a `!` character. + +Given N s, the first N lines are the one-line description from +their commit message. The branch head that is pointed at by +$GIT_DIR/HEAD is prefixed with an asterisk `*` character while other +heads are prefixed with a `!` character. Following these N lines, one-line log for each commit is displayed, indented N places. If a commit is on the I-th From 21c9bac2c73b0acdb804913a6bc3b83ceb58119c Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 19 May 2023 04:17:51 +0000 Subject: [PATCH 3/6] ls-remote doc: remove redundant --tags example The --tags option is already demonstrated in the later example that lists version-patterned tags. As it doesn't appear to add anything to the documentation, it ought to be removed to keep the documentation easier to read. Signed-off-by: Sean Allred Signed-off-by: Junio C Hamano --- Documentation/git-ls-remote.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index ff3da547dd..af71cf4a92 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -100,13 +100,6 @@ EXAMPLES -------- ---- -$ git ls-remote --tags . -d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99 -f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1 -7ceca275d047c90c0c7d5afb13ab97efdf51bd6e refs/tags/v0.99.3 -c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2 -0918385dbd9656cab0d1d81ba7453d49bbc16250 refs/tags/junio-gpg-pub - $ git ls-remote http://www.kernel.org/pub/scm/git/git.git master seen rc 5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/seen From e959fa452f5928502c26569eadf054a43b815dc0 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 19 May 2023 04:17:52 +0000 Subject: [PATCH 4/6] ls-remote doc: show peeled tags in examples Without `--refs`, this command will show peeled tags. Make this clearer in the examples to further mitigate the possibility of surprises in consuming scripts. Signed-off-by: Sean Allred Signed-off-by: Junio C Hamano --- Documentation/git-ls-remote.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index af71cf4a92..aabc1a7b90 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -106,10 +106,10 @@ c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/seen $ git remote add korg http://www.kernel.org/pub/scm/git/git.git $ git ls-remote --tags korg v\* -d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99 -f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1 -c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2 -7ceca275d047c90c0c7d5afb13ab97efdf51bd6e refs/tags/v0.99.3 +485a869c64a68cc5795dd99689797c5900f4716d refs/tags/v2.39.2 +cbf04937d5b9fcf0a76c28f69e6294e9e3ecd7e6 refs/tags/v2.39.2^{} +d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 +73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{} ---- SEE ALSO From a5b076321a4fe19fd25a3192304cb88abf9aefbf Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 19 May 2023 04:17:53 +0000 Subject: [PATCH 5/6] ls-remote doc: explain what each example does While it's good to have several examples to solidify the output pattern and generally demonstrate how to use the command, most other EXAMPLES sections (e.g., git-show-branch.txt, git-remote.txt) additionally describe the problem/situation to which the example is applicable. Follow this example in the ls-remote documentation. Signed-off-by: Sean Allred Signed-off-by: Junio C Hamano --- Documentation/git-ls-remote.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index aabc1a7b90..c0b2facef4 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -99,13 +99,18 @@ OPTIONS EXAMPLES -------- +* List all references matching given patterns: ++ ---- $ git ls-remote http://www.kernel.org/pub/scm/git/git.git master seen rc 5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/seen +---- -$ git remote add korg http://www.kernel.org/pub/scm/git/git.git -$ git ls-remote --tags korg v\* +* List only tags matching a given wildcard pattern: ++ +---- +$ git ls-remote --tags http://www.kernel.org/pub/scm/git/git.git v\* 485a869c64a68cc5795dd99689797c5900f4716d refs/tags/v2.39.2 cbf04937d5b9fcf0a76c28f69e6294e9e3ecd7e6 refs/tags/v2.39.2^{} d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 From 51f9d2e56306deeb547c7d62e46598df2d285fe3 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 19 May 2023 04:17:54 +0000 Subject: [PATCH 6/6] ls-remote doc: document the output format While well-established, the output format of ls-remote was not actually documented. This patch adds an OUTPUT section to the documentation following the format of git-show-ref.txt (which has similar semantics). Add a basic example immediately after this to solidify the 'normal' output format. Signed-off-by: Sean Allred Signed-off-by: Junio C Hamano --- Documentation/git-ls-remote.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index c0b2facef4..1c4f696ab5 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -96,9 +96,35 @@ OPTIONS separator (so `bar` matches `refs/heads/bar` but not `refs/heads/foobar`). +OUTPUT +------ + +The output is in the format: + +------------ + TAB LF +------------ + +When showing an annotated tag, unless `--refs` is given, two such +lines are shown: one with the refname for the tag itself as ``, +and another with `` followed by `^{}`. The `` on the latter +line shows the name of the object the tag points at. + EXAMPLES -------- +* List all references (including symbolics and pseudorefs), peeling + tags: ++ +---- +$ git ls-remote +27d43aaaf50ef0ae014b88bba294f93658016a2e HEAD +950264636c68591989456e3ba0a5442f93152c1a refs/heads/main +d9ab777d41f92a8c1684c91cfb02053d7dd1046b refs/heads/next +d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 +73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{} +---- + * List all references matching given patterns: + ----