Skip to content

Commit

Permalink
tg: clean up help usage output
Browse files Browse the repository at this point in the history
Vastly improve the usability of the various commands'
help usage output.

Signed-off-by: Kyle J. McKay <[email protected]>
  • Loading branch information
mackyle committed Sep 8, 2021
1 parent 1e85b94 commit 2e5f2f3
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 62 deletions.
21 changes: 3 additions & 18 deletions README_DOCS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1032,13 +1032,14 @@ tg create
probably what you normally want to do in this case anyway so you can
just run ``tg create --base HEAD`` to accomplish that).

In an alternative use case, if ``-r <branch>`` is given instead of a
In an alternative use case, if ``-r <rbranch>`` is given instead of a
dependency list, the topic branch is created based on the given
remote branch. With just ``-r`` the remote branch name is assumed
to be the same as the local topic branch being created. Since no
new commits are created in this mode (only two refs will be updated)
the editor will never be run for this use case. Note that no other
options may be combined with ``-r``.
options may be combined with ``-r`` although a global ``-r`` option
can be used to alter which remote ``<rbranch>`` refers to.

The ``--quiet`` (or ``-q``) option suppresses most informational
messages.
Expand Down Expand Up @@ -1127,10 +1128,6 @@ tg files
~~~~~~~~
List files changed by the current or specified topic branch.

Options:
-i list files based on index instead of branch
-w list files based on working tree instead of branch

tg info
~~~~~~~
Show summary information about the current or specified topic
Expand Down Expand Up @@ -1192,10 +1189,6 @@ tg info
basis for the ``tg next`` and ``tg prev`` operations with the first
patch shown being considered the first and so on up to the last.

Options:
-i Use TopGit metadata from the index instead of the branch
-w Use TopGit metadata from the working tree instead of the branch

tg patch
~~~~~~~~
Generate a patch from the current or specified topic branch.
Expand Down Expand Up @@ -1261,10 +1254,6 @@ tg mail
to let ``git send-email`` ask for confirmation before sending any
mail.

Options:
-i base patch generation on index instead of branch
-w base patch generation on working tree instead of branch

| TODO: ``tg mail patchfile`` to mail an already exported patch
| TODO: mailing patch series
| TODO: specifying additional options and addresses on command line
Expand Down Expand Up @@ -1435,10 +1424,6 @@ tg summary
symbolic ref to. The ``tg summary @`` and ``tg summary @ @`` commands
can be quite useful.

Options:
-i Use TopGit metadata from the index instead of the branch
-w Use TopGit metadata from the working tree instead of the branch

tg contains
~~~~~~~~~~~
Search all TopGit-controlled branches (and optionally their remotes)
Expand Down
10 changes: 7 additions & 3 deletions tg-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
# TopGit - A different patch queue manager
# (C) Petr Baudis <[email protected]> 2008
# (C) Per Cederqvist <[email protected]> 2010
# (C) Kyle J. McKay <[email protected]> 2017
# All rights reserved.
# (C) Kyle J. McKay <[email protected]> 2017, 2021
# All rights reserved
# GPLv2

USAGE="Usage: ${tgname:-tg} [...] base [--short[=n] | --no-short] [--] [branch...]"
USAGE="\
Usage: ${tgname:-tg} [...] base [--short[=<n>] | --no-short] [--] [branch...]
Options:
--short[=<n>] display shortened hashes (default)
--no-short display full hashes"

usage()
{
Expand Down
18 changes: 13 additions & 5 deletions tg-checkout.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/bin/sh
# TopGit - A different patch queue manager
# Copyright (C) 2013 Per Cederqvist <[email protected]>
# Copyright (C) 2015,2017,2018 Kyle J. McKay <[email protected]>
# All rights reserved.
# Copyright (C) 2015,2017,2018,2021 Kyle J. McKay <[email protected]>
# All rights reserved
# GPLv2

## Parse options

USAGE="\
Usage: ${tgname:-tg} [...] checkout [--iow] [-f] [-b <branch>] (next | prev) [<steps>]
Or: ${tgname:-tg} [...] checkout [--iow] [-f] (next | prev) -a
Or: ${tgname:-tg} [...] checkout [--iow] [-f] [goto] [--] <pattern> | --series[=<head>]"
Usage: ${tgname:-tg} [...] checkout [<opt>...] [-b <branch>] (next | prev) [<steps>]
Or: ${tgname:-tg} [...] checkout [<opt>...] (next | prev) -a
Or: ${tgname:-tg} [...] checkout [<opt>...] [goto] [--] <pattern> | --series[=<head>]
Options:
--iow pass '--ignore-other-worktrees' to git >= v2.5.0
--force / -f pass '--force' option to git
--merge / -m pass '--merge' option to git
--quiet / -q pass '--quiet' option to git
--branch <branch> start at branch <branch> instead of HEAD
-b <branch> alias for --branch <branch>
--all / -a step as many times as possible"

usage()
{
Expand Down
22 changes: 20 additions & 2 deletions tg-create.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# TopGit - A different patch queue manager
# Copyright (C) 2008 Petr Baudis <[email protected]>
# Copyright (C) 2015,2016,2017 Kyle J. McKay <[email protected]>
# Copyright (C) 2015,2016,2017,2021 Kyle J. McKay <[email protected]>
# All rights reserved
# GPLv2

Expand All @@ -25,7 +25,25 @@ quiet=
branchtype=PATCH
branchdesc=patch

USAGE="Usage: ${tgname:-tg} [... -r remote] create [-q] [-m <msg> | -F <file>] [--topmsg <msg> | --topmsg-file <file>] [--no-edit] [--no-commit | --no-update] [--base] [<name> [<dep>...|-r [<rname>]] ]"
USAGE="\
Usage: ${tgname:-tg} [...] create [<option>...] [<name> [<dep>...]]
Or: ${tgname:-tg} [...] create [<option>...] --base <name> [<committish>]
Or: ${tgname:-tg} [-r <remote>] create [<option>...] <name> -r [<rbranch>]
Options:
--no-deps alternate spelling of '--base'
--quiet / -q suppress most informational messages
--message <msg> replace default commit message
-m <msg> (default message is \"tg create <name>\")
--file <file> replace default commit message
-F <file> with contents of <file>
--topmsg <msg> use <msg> as .topmsg and skip editor
--tm <msg> (<msg> may be reformatted with a warning)
--topmsg-file <f> use contents of file <f> as --topmsg
--tF <file> alias for --topmsg-file <file>
--force / -f ignore tag with same name as new branch
--no-edit do not run the editor on default .topmsg
--no-commit / -n stop before actually making the commit
--no-update do not run 'tg update' (implied by -n)"

usage()
{
Expand Down
2 changes: 1 addition & 1 deletion tg-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Usage: ${tgname:-tg} [...] export [--collapse] [--force] [<option>...] <newbranc
Options:
-s <mode> set subject bracketed [strings] strip mode
--notes[=<ref>] export .topmsg --- comment to notes ref <ref>
--no-notes discard .topmsg --- comment"
--no-notes discard .topmsg --- comment (default)"

usage()
{
Expand Down
30 changes: 22 additions & 8 deletions tg-files.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
#!/bin/sh
# TopGit - A different patch queue manager
# (c) Petr Baudis <[email protected]> 2008
# Copyright (C) Petr Baudis <[email protected]> 2008
# Copyright (C) 2021 Kyle J. McKay <[email protected]>
# All rights reserved
# GPLv2

USAGE="\
Usage: ${tgname:-tg} [...] files [-i | -w] [<name>]
Options:
-i use TopGit metadata from index instead of HEAD branch
-w use metadata from working directory instead of branch"

usage()
{
if [ "${1:-0}" != 0 ]; then
printf '%s\n' "$USAGE" >&2
else
printf '%s\n' "$USAGE"
fi
exit ${1:-0}
}

name=
head_from=


## Parse options

while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-h|--help)
usage;;
-i|-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from="$arg";;
-*)
echo "Usage: ${tgname:-tg} [...] files [-i | -w] [<name>]" >&2
exit 1;;
usage 1;;
*)
[ -z "$name" ] || die "name already specified ($name)"
name="$arg";;
esac
done


head="$(git symbolic-ref -q HEAD)" || :
head="${head#refs/heads/}"

Expand All @@ -44,6 +61,3 @@ v_pretty_tree b_tree -t "$name" -b
v_pretty_tree t_tree -t "$name" $head_from

git diff-tree --name-only -r $b_tree $t_tree

# vim:noet

2 changes: 1 addition & 1 deletion tg-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Usage: ${tgname:-tg} [...] import [-d <base-branch>] [<option>...] <range>...
Options:
-p <prefix> prepend <prefix> to branch names (default is 't/')
--notes[=<ref>] import notes ref <ref> to .topmsg --- comment
--no-notes do not import any notes ref --- comment"
--no-notes do not import any notes ref --- comment (default)"

## Parse options

Expand Down
7 changes: 5 additions & 2 deletions tg-info.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/sh
# TopGit - A different patch queue manager
# Copyright (C) Petr Baudis <[email protected]> 2008
# Copyright (C) Kyle J. McKay <[email protected]> 2015, 2016, 2017, 2018
# Copyright (C) Kyle J. McKay <[email protected]> 2015, 2016, 2017, 2018, 2021
# GPLv2

USAGE="\
Usage: ${tgname:-tg} [...] info [-i | -w] [--heads | --leaves | --series[=<head>]] [<name>]
Or: ${tgname:-tg} [...] info [-i | -w] [--deps | --dependencies | --dependents] [<name>]"
Or: ${tgname:-tg} [...] info [-i | -w] [--deps | --dependencies | --dependents] [<name>]
Options:
-i use TopGit metadata from index instead of HEAD branch
-w use metadata from working directory instead of branch"

usage()
{
Expand Down
22 changes: 19 additions & 3 deletions tg-mail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,34 @@
# TopGit - A different patch queue manager
# GPLv2

USAGE="\
Usage: ${tgname:-tg} [...] mail [-s <send-email-args>] [-r <reference-msgid>] [-i | -w] [<name>]
Options:
-i use TopGit metadata from index instead of HEAD branch
-w use metadata from working directory instead of branch"

usage()
{
if [ "${1:-0}" != 0 ]; then
printf '%s\n' "$USAGE" >&2
else
printf '%s\n' "$USAGE"
fi
exit ${1:-0}
}

name=
head_from=
send_email_args=
in_reply_to=


## Parse options

while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-h|--help)
usage;;
-i|-w)
[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
head_from="$arg";;
Expand All @@ -21,8 +38,7 @@ while [ -n "$1" ]; do
-r)
in_reply_to="$1"; shift;;
-*)
echo "Usage: ${tgname:-tg} [...] mail [-s <send-email-args>] [-r <reference-msgid>] [-i | -w] [<name>]" >&2
exit 1;;
usage 1;;
*)
[ -z "$name" ] || die "name already specified ($name)"
name="$arg";;
Expand Down
27 changes: 23 additions & 4 deletions tg-revert.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
#!/bin/sh
# TopGit revert command
# Copyright (C) 2015 Kyle J. McKay <[email protected]>
# All rights reserved.
# Copyright (C) 2015,2021 Kyle J. McKay <[email protected]>
# All rights reserved
# GPLv2

USAGE="\
Usage: ${tgname:-tg} [...] revert (-f | -i | -n) [-q] [--tgish-only] [--no-deps] [--no-stash] [--exclude <ref>...] (<tagname> | --stash) [<ref>...]
Or: ${tgname:-tg} [...] revert [-l] [--no-short] [--hash] [--tgish-only] [(--deps | --rdeps)] [--exclude <ref>...] (<tagname> | --stash) [(--[topgit-]heads] | <ref>...)]"
Usage: ${tgname:-tg} [...] revert (-f | -i | -n) [<opt>...] (<tagname> | --stash) [<ref>...]
Or: ${tgname:-tg} [...] revert [<opt>...] (<tagname> | --stash) [(--[topgit-]heads] | <ref>...)]
Options:
--quiet / -q suppress non-dry-run ref change messages
--force / -f force revert operation to make changes
--dry-run / -n show '-f' changes but don't actually make them
--interactive / -i edit revert instruction sheet before proceeding
--list / -l list mode (default if no -f, -n or -i present)
--short[=<n>] display shortened hashes (default unless --hash)
--no-short display full hashes (default for --hash-only)
--hash-only show only hashes in list mode (aka '--hash')
--no-stash skip preliminary stash before making changes
--exclude <ref> exclude <ref> during operation (may be repeated)
--tgish-only exclude non-TopGit branches (aka '--tgish')
--no-deps do not include dependencies in revert mode
--deps include dependencies in list mode
--rdeps list relationships like 'tg summary --rdeps'
--stash specifies a <tagname> of refs/tgstash
--heads list only merge-base --independent heads
--heads-independent alternate spelling of '--heads'
--topgit-heads list only independent TopGit branch heads"

usage()
{
Expand Down
Loading

0 comments on commit 2e5f2f3

Please sign in to comment.