{"thread":{"id":"57635","subject":"[PATCH] cli: add -v and -h shorthands","startedAt":"2022-03-30T17:01:32Z","lastAt":"2022-03-30T17:28:35Z","messageCount":2,"participants":["Garrit Franke","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"452670","messageId":"20220330170059.5075-1-garrit@slashdev.space","threadId":"57635","inReplyTo":null,"subject":"[PATCH] cli: add -v and -h shorthands","fromName":"Garrit Franke","fromEmail":"garrit@slashdev.space","sentAt":"2022-03-30T17:00:59Z","receivedAt":"2022-03-30T17:01:32Z","isPatch":true,"sender":{"key":"garrit@slashdev.space","avatar":"https://avatars.githubusercontent.com/u/32395585?v=4"},"body":"If \"-v\" or \"-h\" is passed as a flag, they will be interpreted as\na \"version\" or \"help\" command respectively.\n\nSigned-off-by: Garrit Franke <garrit@slashdev.space>\n---\nI'm not sure if this was already discussed in the past or if there are\nreasons against this, but it would be quite handy if these shorthands\nexisted for git.\n\nSince this is my first patch for this project, I'm very happy to take\nyour feedback!\n\n Documentation/git.txt |  4 +++-\n git.c                 | 15 ++++++++++++---\n po/bg.po              |  4 ++--\n po/ca.po              |  4 ++--\n po/de.po              |  4 ++--\n po/el.po              |  4 ++--\n po/es.po              |  4 ++--\n po/fr.po              |  4 ++--\n po/git.pot            |  2 +-\n po/id.po              |  4 ++--\n po/it.po              |  4 ++--\n po/ko.po              |  4 ++--\n po/pl.po              |  4 ++--\n po/pt_PT.po           |  2 +-\n po/ru.po              |  4 ++--\n po/sv.po              |  4 ++--\n po/tr.po              |  4 ++--\n po/vi.po              |  4 ++--\n po/zh_CN.po           |  4 ++--\n po/zh_TW.po           |  4 ++--\n t/t0012-help.sh       |  2 +-\n 21 files changed, 50 insertions(+), 39 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 13f83a2..302607a 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -9,7 +9,7 @@ git - the stupid content tracker\n SYNOPSIS\n --------\n [verse]\n-'git' [--version] [--help] [-C <path>] [-c <name>=<value>]\n+'git' [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n     [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n     [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]\n     [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n@@ -39,6 +39,7 @@ or https://git-scm.com/docs.\n \n OPTIONS\n -------\n+-v::\n --version::\n \tPrints the Git suite version that the 'git' program came from.\n +\n@@ -46,6 +47,7 @@ This option is internally converted to `git version ...` and accepts\n the same options as the linkgit:git-version[1] command. If `--help` is\n also given, it takes precedence over `--version`.\n \n+-h::\n --help::\n \tPrints the synopsis and a list of the most commonly used\n \tcommands. If the option `--all` or `-a` is given then all\ndiff --git a/git.c b/git.c\nindex a25940d..6888c11 100644\n--- a/git.c\n+++ b/git.c\n@@ -25,7 +25,7 @@ struct cmd_struct {\n };\n \n const char git_usage_string[] =\n-\tN_(\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\tN_(\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \t   \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \t   \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\\n\"\n \t   \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n@@ -146,7 +146,10 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t * commands can be written with \"--\" prepended\n \t\t * to make them look like flags.\n \t\t */\n-\t\tif (!strcmp(cmd, \"--help\") || !strcmp(cmd, \"--version\"))\n+\t\tif (!strcmp(cmd, \"-h\") ||\n+\t\t\t!strcmp(cmd, \"--help\") ||\n+\t\t\t!strcmp(cmd, \"-v\") ||\n+\t\t\t!strcmp(cmd, \"--version\"))\n \t\t\tbreak;\n \n \t\t/*\n@@ -893,7 +896,13 @@ int cmd_main(int argc, const char **argv)\n \thandle_options(&argv, &argc, NULL);\n \tif (argc > 0) {\n \t\t/* translate --help and --version into commands */\n-\t\tskip_prefix(argv[0], \"--\", &argv[0]);\n+\t\tif (!strcmp(\"-v\", argv[0])) {\n+\t\t\targv[0] = \"version\";\n+\t\t} else if (!strcmp(\"-h\", argv[0])) {\n+\t\t\targv[0] = \"help\";\n+\t\t} else {\n+\t\t\tskip_prefix(argv[0], \"--\", &argv[0]);\n+\t\t}\n \t} else {\n \t\t/* The user didn't specify a command; give them help */\n \t\tcommit_pager_choice();\ndiff --git a/po/bg.po b/po/bg.po\nindex 8328531..7f9994b 100644\n--- a/po/bg.po\n+++ b/po/bg.po\n@@ -24979,7 +24979,7 @@ msgstr \"само за изчистване на грешки\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24987,7 +24987,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C ПЪТ] [-c ИМЕ=СТОЙНОСТ]\\n\"\n+\"git [-v | --version] [-h | --help] [-C ПЪТ] [-c ИМЕ=СТОЙНОСТ]\\n\"\n \"           [--exec-path[=ПЪТ]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/ca.po b/po/ca.po\nindex afcffad..33ecccf 100644\n--- a/po/ca.po\n+++ b/po/ca.po\n@@ -24451,14 +24451,14 @@ msgstr \"només útil per a la depuració\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\\n\"\n \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\\n\"\n \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\ndiff --git a/po/de.po b/po/de.po\nindex 19ffd9a..0ea3f93 100644\n--- a/po/de.po\n+++ b/po/de.po\n@@ -24744,7 +24744,7 @@ msgstr \"nur nützlich für Fehlersuche\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24752,7 +24752,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <Pfad>] [-c <Name>=<Wert>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <Pfad>] [-c <Name>=<Wert>]\\n\"\n \"           [--exec-path[=<Pfad>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/el.po b/po/el.po\nindex 703f46d..7191847 100644\n--- a/po/el.po\n+++ b/po/el.po\n@@ -18927,14 +18927,14 @@ msgstr \"\"\n \n #: git.c:27\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <διαδρομή>] [-c <όνομα>=<τιμή>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <διαδρομή>] [-c <όνομα>=<τιμή>]\\n\"\n \"           [--exec-path[=<διαδρομή>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/es.po b/po/es.po\nindex ced2eb6..a812bf4 100644\n--- a/po/es.po\n+++ b/po/es.po\n@@ -24475,7 +24475,7 @@ msgstr \"solo útil para depurar\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24483,7 +24483,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <ruta>] [-c <nombre>=<valor>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <ruta>] [-c <nombre>=<valor>]\\n\"\n \"            [--exec-path [= <path>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"            [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/fr.po b/po/fr.po\nindex fc00401..da60c9c 100644\n--- a/po/fr.po\n+++ b/po/fr.po\n@@ -24687,7 +24687,7 @@ msgstr \"seulement utile pour le débogage\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24695,7 +24695,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <chemin>] [-c <nom>=<valeur>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <chemin>] [-c <nom>=<valeur>]\\n\"\n \"           [--exec-path[=<chemin>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/git.pot b/po/git.pot\nindex 196249a..2cb3747 100644\n--- a/po/git.pot\n+++ b/po/git.pot\n@@ -22653,7 +22653,7 @@ msgstr \"\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/id.po b/po/id.po\nindex aa6f170..edb702e 100644\n--- a/po/id.po\n+++ b/po/id.po\n@@ -23740,7 +23740,7 @@ msgstr \"hanya berguna untuk penirkutuan\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -23748,7 +23748,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <jalur>] [-c <nama>=<nilai>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <jalur>] [-c <nama>=<nilai>]\\n\"\n \"           [--exec-path[=<jalur>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/it.po b/po/it.po\nindex c315608..d003e24 100644\n--- a/po/it.po\n+++ b/po/it.po\n@@ -23422,14 +23422,14 @@ msgstr \"esci subito dopo aver annunciato le funzionalità\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <percorso>] [-c <nome>=<valore>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <percorso>] [-c <nome>=<valore>]\\n\"\n \"           [--exec-path[=<percorso>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/ko.po b/po/ko.po\nindex 5d190e5..bd41856 100644\n--- a/po/ko.po\n+++ b/po/ko.po\n@@ -15225,14 +15225,14 @@ msgstr \"디버깅 메시지를 표준오류로 출력합니다\"\n \n #: git.c:27\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <경로>] [-c <이름>=<값>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <경로>] [-c <이름>=<값>]\\n\"\n \"           [--exec-path[=<경로>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/pl.po b/po/pl.po\nindex 0ec127e..de64558 100644\n--- a/po/pl.po\n+++ b/po/pl.po\n@@ -24406,7 +24406,7 @@ msgstr \"przydatne tylko do odpluskwiania\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24414,7 +24414,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <ścieżka>] [-c <nazwa>=<wartość>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <ścieżka>] [-c <nazwa>=<wartość>]\\n\"\n \"           [--exec-path[=<ścieżka>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/pt_PT.po b/po/pt_PT.po\nindex 70e5c6d..912cb12 100644\n--- a/po/pt_PT.po\n+++ b/po/pt_PT.po\n@@ -23666,7 +23666,7 @@ msgstr \"apenas útil para depuração\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/ru.po b/po/ru.po\nindex 993d106..2de033a 100644\n--- a/po/ru.po\n+++ b/po/ru.po\n@@ -21748,12 +21748,12 @@ msgstr \"\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\\n\"\n \"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n \"           <command> [<args>]\"\n-msgstr \"git [--version] [--help] [-C <путь>] [-c <имя>=<значение>]\\n           [--exec-path[=<путь>]] [--html-path] [--man-path] [--info-path]\\n           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\\n           [--git-dir=<путь>] [--work-tree=<путь>] [--namespace=<имя>]\\n           <команда> [<аргументы>]\"\n+msgstr \"git [-v | --version] [-h | --help] [-C <путь>] [-c <имя>=<значение>]\\n           [--exec-path[=<путь>]] [--html-path] [--man-path] [--info-path]\\n           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\\n           [--git-dir=<путь>] [--work-tree=<путь>] [--namespace=<имя>]\\n           <команда> [<аргументы>]\"\n \n #: git.c:35\n msgid \"\"\ndiff --git a/po/sv.po b/po/sv.po\nindex fd32ede..8b1b1d8 100644\n--- a/po/sv.po\n+++ b/po/sv.po\n@@ -24126,7 +24126,7 @@ msgstr \"endast användbart vid felsökning\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24134,7 +24134,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <sökväg>] [-c <namn>=<värde>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <sökväg>] [-c <namn>=<värde>]\\n\"\n \"           [--exec-path[=<sökväg>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/tr.po b/po/tr.po\nindex 6afb871..0f39310 100644\n--- a/po/tr.po\n+++ b/po/tr.po\n@@ -24215,7 +24215,7 @@ msgstr \"yalnızca hata ayıklama için yararlı\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24223,7 +24223,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <yol>] [-c <ad>=<değer>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <yol>] [-c <ad>=<değer>]\\n\"\n \"           [--exec-path[=<yol>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/vi.po b/po/vi.po\nindex 0d5b144..f3ba1bb 100644\n--- a/po/vi.po\n+++ b/po/vi.po\n@@ -24290,7 +24290,7 @@ msgstr \"chỉ hữu ích khi cần gỡ lỗi\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -24298,7 +24298,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C </đường/dẫn/>] [-c <tên>=<giá trị>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C </đường/dẫn/>] [-c <tên>=<giá trị>]\\n\"\n \"           [--exec-path[=</đường/dẫn/>]] [--html-path] [--man-path] [--info-\"\n \"path]\\n\"\n \"           [-p | --paginate | -P --no-pager] [--no-replace-objects] [--\"\ndiff --git a/po/zh_CN.po b/po/zh_CN.po\nindex 484f2d8..a91a280 100644\n--- a/po/zh_CN.po\n+++ b/po/zh_CN.po\n@@ -23838,7 +23838,7 @@ msgstr \"只对调试有用\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -23846,7 +23846,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <路径>] [-c <名称>=<取值>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <路径>] [-c <名称>=<取值>]\\n\"\n \"           [--exec-path[=<路径>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/po/zh_TW.po b/po/zh_TW.po\nindex 60fe123..5cad03c 100644\n--- a/po/zh_TW.po\n+++ b/po/zh_TW.po\n@@ -23689,7 +23689,7 @@ msgstr \"只對除錯有用\"\n \n #: git.c:28\n msgid \"\"\n-\"git [--version] [--help] [-C <path>] [-c <name>=<value>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\\n\"\n \"           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\n@@ -23697,7 +23697,7 @@ msgid \"\"\n \"           [--super-prefix=<path>] [--config-env=<name>=<envvar>]\\n\"\n \"           <command> [<args>]\"\n msgstr \"\"\n-\"git [--version] [--help] [-C <路徑>] [-c <名稱>=<數值>]\\n\"\n+\"git [-v | --version] [-h | --help] [-C <路徑>] [-c <名稱>=<數值>]\\n\"\n \"           [--exec-path[=<路徑>]] [--html-path] [--man-path] [--info-path]\\n\"\n \"           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--\"\n \"bare]\\n\"\ndiff --git a/t/t0012-help.sh b/t/t0012-help.sh\nindex 6c3e1f7..6c33a43 100755\n--- a/t/t0012-help.sh\n+++ b/t/t0012-help.sh\n@@ -181,7 +181,7 @@ for cmd in git \"git help\"\n do\n \ttest_expect_success \"'$cmd' section spacing\" '\n \t\ttest_section_spacing_trailer git help <<-\\EOF &&\n-\t\tusage: git [--version] [--help] [-C <path>] [-c <name>=<value>]\n+\t\tusage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n \n \t\tThese are common Git commands used in various situations:\n \n-- \n2.35.1\n\n"},{"id":"452675","messageId":"220330.86r16jnydf.gmgdl@evledraar.gmail.com","threadId":"57635","inReplyTo":"20220330170059.5075-1-garrit@slashdev.space","subject":"Re: [PATCH] cli: add -v and -h shorthands","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-30T17:17:53Z","receivedAt":"2022-03-30T17:28:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Mar 30 2022, Garrit Franke wrote:\n\n> If \"-v\" or \"-h\" is passed as a flag, they will be interpreted as\n> a \"version\" or \"help\" command respectively.\n\nThey won't, try e.g. \"./git -h\" before/after this change. On a second\nreading I see that there's an implied \"change the behavior to ...\"\nthere.\n\nBut it would really help if the commit message discussed what we did\nbefore, what we do now, and why the change is safe/OK.\n\nI *think* we just emit the message about an unknown option before, and\nthis makes it synonymous with --verbose/verbose and --help/(but not\n\"help\"), but saying so would be useful :)\n\n> Since this is my first patch for this project, I'm very happy to take\n> your feedback!\n\nWelcome to git development!\n\n>  Documentation/git.txt |  4 +++-\n>  git.c                 | 15 ++++++++++++---\n>  po/bg.po              |  4 ++--\n>  po/ca.po              |  4 ++--\n>  po/de.po              |  4 ++--\n>  po/el.po              |  4 ++--\n>  po/es.po              |  4 ++--\n>  po/fr.po              |  4 ++--\n>  po/git.pot            |  2 +-\n>  po/id.po              |  4 ++--\n>  po/it.po              |  4 ++--\n>  po/ko.po              |  4 ++--\n>  po/pl.po              |  4 ++--\n>  po/pt_PT.po           |  2 +-\n>  po/ru.po              |  4 ++--\n>  po/sv.po              |  4 ++--\n>  po/tr.po              |  4 ++--\n>  po/vi.po              |  4 ++--\n>  po/zh_CN.po           |  4 ++--\n>  po/zh_TW.po           |  4 ++--\n\nThis *.po stuff is a well-meaning change, but please leave this out of\nthe patch.\n\nThe translation files are updated by a process that the translation\nteams(s) use, see po/README.md. I think changing this from under them is\nprobably more disruptive than not.\n\n> -\t\tif (!strcmp(cmd, \"--help\") || !strcmp(cmd, \"--version\"))\n> +\t\tif (!strcmp(cmd, \"-h\") ||\n> +\t\t\t!strcmp(cmd, \"--help\") ||\n> +\t\t\t!strcmp(cmd, \"-v\") ||\n> +\t\t\t!strcmp(cmd, \"--version\"))\n\nnit: minimize the diff here perhaps by keeping the existing line, and\ndoing -h or -v on a new line? Your indentation here is also off.\n\n> @@ -893,7 +896,13 @@ int cmd_main(int argc, const char **argv)\n>  \thandle_options(&argv, &argc, NULL);\n>  \tif (argc > 0) {\n>  \t\t/* translate --help and --version into commands */\n> -\t\tskip_prefix(argv[0], \"--\", &argv[0]);\n> +\t\tif (!strcmp(\"-v\", argv[0])) {\n> +\t\t\targv[0] = \"version\";\n> +\t\t} else if (!strcmp(\"-h\", argv[0])) {\n> +\t\t\targv[0] = \"help\";\n> +\t\t} else {\n> +\t\t\tskip_prefix(argv[0], \"--\", &argv[0]);\n> +\t\t}\n\nDon't use {} braces here, see CodingGudielines.\n\nFWIW I have an existing branch (unsubmitted) at\nhttps://github.com/avar/git/tree/avar/parse-options-h-3 where I added\nsome tests for \"git cmd -h\" behavior, which seems to pass with this\nchange (not unexpected, as this is for the top-level command).\n"}]}