]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse-options: exit 0 on -h
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 8 Jul 2026 00:15:57 +0000 (00:15 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Jul 2026 00:48:57 +0000 (17:48 -0700)
The standard philosophy for Unix software when a help option (such as
--help) is specified is that the software should exit 0, printing the
help output to standard output, since the standard output is for
user-requested output and the program performed the requested task
successfully.  If the user specifies an incorrect option, then the help
output should be printed to standard error (since the user has made a
mistake) and it should exit unsuccessfully.

Most of our commands currently exit 129 on receiving the -h option to
print the short help, which does not line up with the standard
philosophy above.  Let's change that to exit 0 instead.

This requires changes to a variety of tests which previously wanted the
129 exit code, so update them.  Note that because git diff does its own
option parsing, it still exits with 129, so update some of the tests to
expect either exit status.

Some commands also now pass with -h but not --help-all, so handle those
cases differently for those commands.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
37 files changed:
builtin/blame.c
builtin/shortlog.c
builtin/update-index.c
contrib/subtree/t/t7900-subtree.sh
parse-options.c
t/for-each-ref-tests.sh
t/t0012-help.sh
t/t0040-parse-options.sh
t/t0450-txt-doc-vs-help.sh
t/t0610-reftable-basics.sh
t/t1403-show-ref.sh
t/t1410-reflog.sh
t/t1418-reflog-exists.sh
t/t1502-rev-parse-parseopt.sh
t/t1517-outside-repo.sh
t/t1800-hook.sh
t/t1900-repo-info.sh
t/t1901-repo-structure.sh
t/t2006-checkout-index-basic.sh
t/t2107-update-index-basic.sh
t/t3004-ls-files-basic.sh
t/t3200-branch.sh
t/t3903-stash.sh
t/t4200-rerere.sh
t/t5200-update-server-info.sh
t/t5304-prune.sh
t/t5400-send-pack.sh
t/t5512-ls-remote.sh
t/t6300-for-each-ref.sh
t/t6500-gc.sh
t/t7030-verify-tag.sh
t/t7508-status.sh
t/t7510-signed-commit.sh
t/t7600-merge.sh
t/t7800-difftool.sh
t/t7900-maintenance.sh
usage.c

index 65d43c7d484335bb9af594ce83e0122b80735164..38749f79c2328ccdee3a0172c090c52f4e765679 100644 (file)
@@ -1013,6 +1013,7 @@ int cmd_blame(int argc,
                case PARSE_OPT_UNKNOWN:
                        break;
                case PARSE_OPT_HELP:
+                       exit(0);
                case PARSE_OPT_HELP_ERROR:
                case PARSE_OPT_ERROR:
                case PARSE_OPT_SUBCOMMAND:
index cd262bd3763e973d14244b4e565216914c760a2b..4c78d2e5badb82e8faa1b363bb98707ba5dde114 100644 (file)
@@ -433,6 +433,7 @@ int cmd_shortlog(int argc,
                case PARSE_OPT_UNKNOWN:
                        break;
                case PARSE_OPT_HELP:
+                       exit(0);
                case PARSE_OPT_HELP_ERROR:
                case PARSE_OPT_ERROR:
                case PARSE_OPT_SUBCOMMAND:
index ac4610ec94af90e1c419293bcabdb3b4ce2e702b..6810327209658c718f4c05ca66e9e0a5d3464cda 100644 (file)
@@ -1133,6 +1133,7 @@ int cmd_update_index(int argc,
                        break;
                switch (parseopt_state) {
                case PARSE_OPT_HELP:
+                       exit(0);
                case PARSE_OPT_HELP_ERROR:
                case PARSE_OPT_ERROR:
                        exit(129);
index 4194687cfbb9b5066f1694b0bbbe3cd2839c5bd3..c10f283b38d92db42e94d5c464191337b068a74d 100755 (executable)
@@ -99,7 +99,7 @@ test_create_subtree_add () {
 }
 
 test_expect_success 'shows short help text for -h' '
-       test_expect_code 129 git subtree -h >out 2>err &&
+       git subtree -h >out 2>err &&
        test_must_be_empty err &&
        grep -e "^ *or: git subtree pull" out &&
        grep -F -e "--[no-]annotate" out
index cc3a8b0fe3c658d09f98b96a65ace743cb8ea32e..08c21d9fc0a585e2d5ab00ef119f89ccc2656c3f 100644 (file)
@@ -1135,8 +1135,9 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
                case PARSE_OPT_UNKNOWN:
                        goto unknown;
                case PARSE_OPT_HELP:
-               case PARSE_OPT_HELP_ERROR:
                        goto show_usage;
+               case PARSE_OPT_HELP_ERROR:
+                       goto show_usage_stderr;
                case PARSE_OPT_NON_OPTION:
                case PARSE_OPT_SUBCOMMAND:
                case PARSE_OPT_COMPLETE:
@@ -1170,6 +1171,9 @@ unknown:
  show_usage:
        return usage_with_options_internal(ctx, usagestr, options,
                                           USAGE_NORMAL, USAGE_TO_STDOUT);
+ show_usage_stderr:
+       return usage_with_options_internal(ctx, usagestr, options,
+                                          USAGE_NORMAL, USAGE_TO_STDERR);
 }
 
 int parse_options_end(struct parse_opt_ctx_t *ctx)
@@ -1201,6 +1205,7 @@ int parse_options(int argc, const char **argv,
        parse_options_start_1(&ctx, argc, argv, prefix, options, flags);
        switch (parse_options_step(&ctx, options, usagestr)) {
        case PARSE_OPT_HELP:
+               exit(0);
        case PARSE_OPT_HELP_ERROR:
        case PARSE_OPT_ERROR:
                exit(129);
@@ -1500,11 +1505,11 @@ void show_usage_with_options_if_asked(int ac, const char **av,
                if (!strcmp(av[1], "-h")) {
                        usage_with_options_internal(NULL, usagestr, opts,
                                                    USAGE_NORMAL, USAGE_TO_STDOUT);
-                       exit(129);
+                       exit(0);
                } else if (!strcmp(av[1], "--help-all")) {
                        usage_with_options_internal(NULL, usagestr, opts,
                                                    USAGE_FULL, USAGE_TO_STDOUT);
-                       exit(129);
+                       exit(0);
                }
        }
 }
index bd2d45c9719f066242aa4ec1d17ba3526bdd795a..b95e5b6ca05a4483a675514cdce48dc51ee35f9c 100644 (file)
@@ -522,7 +522,7 @@ test_expect_success 'Verify descending sort' '
 '
 
 test_expect_success 'Give help even with invalid sort atoms' '
-       test_expect_code 129 ${git_for_each_ref} --sort=bogus -h >actual 2>&1 &&
+       ${git_for_each_ref} --sort=bogus -h >actual 2>&1 &&
        grep "^usage: ${git_for_each_ref}" actual
 '
 
index c33501bdcd2b9b64cb945aae17ed8fac753b2d63..7815ff14f247b7f909923e8d1b06582b00297582 100755 (executable)
@@ -260,7 +260,7 @@ do
                (
                        GIT_CEILING_DIRECTORIES=$(pwd) &&
                        export GIT_CEILING_DIRECTORIES &&
-                       test_expect_code 129 git -C sub $builtin -h >output 2>err
+                       git -C sub $builtin -h >output 2>err
                ) &&
                test_must_be_empty err &&
                test_grep usage output
index ca55ea8228c3789c5089d9141412224589ac18f7..30895ad6d2f4f9354da65831a171af1d8188a452 100755 (executable)
@@ -68,7 +68,7 @@ Alias
 EOF
 
 test_expect_success 'test help' '
-       test_must_fail test-tool parse-options -h >output 2>output.err &&
+       test-tool parse-options -h >output 2>output.err &&
        test_must_be_empty output.err &&
        test_cmp expect output
 '
index 822b0d55a50ae7e600fca13a1c3a7b4b21ed6913..d2844368e44d35b688b92c3c22829eaf1fe6ccd6 100755 (executable)
@@ -29,7 +29,7 @@ help_to_synopsis () {
                return 0
        fi &&
        mkdir -p "$out_dir" &&
-       test_expect_code 129 git $builtin -h >"$out.raw" 2>&1 &&
+       test_might_fail git $builtin -h >"$out.raw" 2>&1 &&
        sed -n \
                -e '1,/^$/ {
                        /^$/d;
index e19e0368989d5042aeb9e422df5d3754c460416a..4135db95edb365d89aa09e5762ee84635523d071 100755 (executable)
@@ -15,9 +15,9 @@ export GIT_TEST_DEFAULT_REF_FORMAT
 INVALID_OID=$(test_oid 001)
 
 test_expect_success 'pack-refs does not crash with -h' '
-       test_expect_code 129 git pack-refs -h >usage &&
+       git pack-refs -h >usage &&
        test_grep "[Uu]sage: git pack-refs " usage &&
-       test_expect_code 129 nongit git pack-refs -h >usage &&
+       nongit git pack-refs -h >usage &&
        test_grep "[Uu]sage: git pack-refs " usage
 '
 
index 36c903ca1901bfd38577310ed3f42201f75fac63..db4300da44706050ad8f3f56b716384598473c46 100755 (executable)
@@ -165,7 +165,7 @@ test_expect_success 'show-ref --branches, --tags, --head, pattern' '
 '
 
 test_expect_success 'show-ref --heads is deprecated and hidden' '
-       test_expect_code 129 git show-ref -h >short-help &&
+       git show-ref -h >short-help &&
        test_grep ! -e --heads short-help &&
        git show-ref --heads >actual 2>warning &&
        test_grep ! deprecated warning &&
index ce71f9a30ae1ee54f678c6e99bbd0a82fd4041bc..6e921bc1678503344f9e9b756c575d3bda5e712e 100755 (executable)
@@ -107,12 +107,12 @@ test_expect_success setup '
 '
 
 test_expect_success 'correct usage on sub-command -h' '
-       test_expect_code 129 git reflog expire -h >err &&
+       git reflog expire -h >err &&
        grep "git reflog expire" err
 '
 
 test_expect_success 'correct usage on "git reflog show -h"' '
-       test_expect_code 129 git reflog show -h >err &&
+       git reflog show -h >err &&
        grep -F "git reflog [show]" err
 '
 
index d51ecd5e9250f004e0b0c894b308172237e5666c..10387792e31039f8a439da3b74c97793a03ccf27 100755 (executable)
@@ -12,7 +12,7 @@ test_expect_success 'setup' '
 
 test_expect_success 'usage' '
        test_expect_code 129 git reflog exists &&
-       test_expect_code 129 git reflog exists -h
+       git reflog exists -h
 '
 
 test_expect_success 'usage: unknown option' '
index 455608c42947c768b764167f64a712636bacf6c2..fa97591b9f8102c9686f9021675f6dc5963de4a2 100755 (executable)
@@ -75,7 +75,7 @@ EOF
 '
 
 test_expect_success 'test --parseopt help output' '
-       test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec &&
+       git rev-parse --parseopt -- -h > output < optionspec &&
        test_cmp "$TEST_DIRECTORY/t1502/optionspec.help" output
 '
 
@@ -89,7 +89,7 @@ test_expect_success 'test --parseopt help output no switches' '
 |EOF
 |exit 0
 END_EXPECT
-       test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec_no_switches &&
+       git rev-parse --parseopt -- -h > output < optionspec_no_switches &&
        test_cmp expect output
 '
 
@@ -103,7 +103,7 @@ test_expect_success 'test --parseopt help output hidden switches' '
 |EOF
 |exit 0
 END_EXPECT
-       test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec_only_hidden_switches &&
+       git rev-parse --parseopt -- -h > output < optionspec_only_hidden_switches &&
        test_cmp expect output
 '
 
@@ -119,7 +119,7 @@ test_expect_success 'test --parseopt help-all output hidden switches' '
 |EOF
 |exit 0
 END_EXPECT
-       test_expect_code 129 git rev-parse --parseopt -- --help-all > output < optionspec_only_hidden_switches &&
+       git rev-parse --parseopt -- --help-all > output < optionspec_only_hidden_switches &&
        test_cmp expect output
 '
 
@@ -258,7 +258,7 @@ test_expect_success 'test --parseopt help output: "wrapped" options normal "or:"
        |exit 0
        END_EXPECT
 
-       test_must_fail git rev-parse --parseopt -- -h <spec >actual &&
+       git rev-parse --parseopt -- -h <spec >actual &&
        test_cmp expect actual
 '
 
@@ -296,12 +296,12 @@ test_expect_success 'test --parseopt help output: multi-line blurb after empty l
        |exit 0
        END_EXPECT
 
-       test_must_fail git rev-parse --parseopt -- -h <spec >actual &&
+       git rev-parse --parseopt -- -h <spec >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'test --parseopt help output for optionspec-neg' '
-       test_expect_code 129 git rev-parse --parseopt -- \
+       git rev-parse --parseopt -- \
                -h >output <"$TEST_DIRECTORY/t1502/optionspec-neg" &&
        test_cmp "$TEST_DIRECTORY/t1502/optionspec-neg.help" output
 '
index 03fa2f9cdfdb0d9030a418e08b28db690872f461..d1e915786eadb9affc53adadbcfa188f9ed6aa5a 100755 (executable)
@@ -129,18 +129,25 @@ do
        archimport | citool | credential-netrc | credential-libsecret | \
        credential-osxkeychain | cvsexportcommit | cvsimport | cvsserver | \
        daemon | \
-       difftool--helper | filter-branch | format-rev | fsck-objects | \
-       get-tar-commit-id | \
+       difftool--helper | format-rev | fsck-objects |  get-tar-commit-id | \
        gui | gui--askpass | \
-       http-backend | http-fetch | http-push | init-db | instaweb | \
-       merge-octopus | merge-one-file | merge-resolve | mergetool | \
-       mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
-       remote-http | remote-https | replay | request-pull | send-email | \
-       sh-i18n--envsubst | shell | show | stage | submodule | svn | \
-       upload-archive--writer | upload-pack | web--browse | whatchanged)
-               expect_outcome=expect_failure ;;
+       http-backend | http-fetch | http-push | init-db | \
+       mktag | p4 | p4.py | pickaxe | remote-ftp | remote-ftps | \
+       remote-http | remote-https | replay | send-email | \
+       sh-i18n--envsubst | shell | show | stage | \
+       upload-archive--writer | upload-pack | whatchanged)
+               h_expect_outcome=expect_failure
+               all_expect_outcome=expect_failure
+               ;;
+       filter-branch | merge-octopus | merge-one-file | merge-resolve | \
+       mergetool | submodule | svn | web--browse)
+               h_expect_outcome=expect_success
+               all_expect_outcome=expect_failure
+               ;;
        *)
-               expect_outcome=expect_success ;;
+               h_expect_outcome=expect_success
+               all_expect_outcome=expect_success
+               ;;
        esac
        case "$cmd" in
        instaweb)
@@ -150,20 +157,20 @@ do
        *)
                prereq= ;;
        esac
-       test_$expect_outcome $prereq "'git $cmd -h' outside a repository" '
-               test_expect_code 129 nongit git $cmd -h >usage &&
+       test_$h_expect_outcome $prereq "'git $cmd -h' outside a repository" '
+               nongit git $cmd -h >usage &&
                test_grep "[Uu]sage: git $cmd " usage
        '
-       test_$expect_outcome $prereq "'git $cmd --help-all' outside a repository" '
-               test_expect_code 129 nongit git $cmd --help-all >usage &&
+       test_$all_expect_outcome $prereq "'git $cmd --help-all' outside a repository" '
+               nongit git $cmd --help-all >usage &&
                test_grep "[Uu]sage: git $cmd " usage
        '
 done
 
 test_expect_success 'fmt-merge-msg does not crash with -h' '
-       test_expect_code 129 git fmt-merge-msg -h >usage &&
+       git fmt-merge-msg -h >usage &&
        test_grep "[Uu]sage: git fmt-merge-msg " usage &&
-       test_expect_code 129 nongit git fmt-merge-msg -h >usage &&
+       nongit git fmt-merge-msg -h >usage &&
        test_grep "[Uu]sage: git fmt-merge-msg " usage
 '
 
index 0132e772e472e27fe2dba2e431f61068f4317629..2ea9fa13c53149ddbe3620f3448569786e02b869 100755 (executable)
@@ -75,10 +75,10 @@ sentinel_detector () {
 test_expect_success 'git hook usage' '
        test_expect_code 129 git hook &&
        test_expect_code 129 git hook run &&
-       test_expect_code 129 git hook run -h &&
+       git hook run -h &&
        test_expect_code 129 git hook run --unknown 2>err &&
        test_expect_code 129 git hook list &&
-       test_expect_code 129 git hook list -h &&
+       git hook list -h &&
        grep "unknown option" err
 '
 
index 39bb77dda0c327951a59778cfbaae7dfd488ebf9..826686955d7457fa19f0cd41af7db84d2d71d9d8 100755 (executable)
@@ -150,7 +150,7 @@ test_expect_success 'git repo info --keys uses lines as its default output forma
 '
 
 test_expect_success 'git repo info -h shows only repo info usage' '
-       test_must_fail git repo info -h >actual &&
+       git repo info -h >actual &&
        test_grep "git repo info" actual &&
        test_grep ! "git repo structure" actual
 '
index 10050abd70fd67b6c7657557b5a49dd63474f99e..02cc2b594a48b56389b8b1d110f6d6689fa9b0f7 100755 (executable)
@@ -225,7 +225,7 @@ test_expect_success 'progress meter option' '
 '
 
 test_expect_success 'git repo structure -h shows only repo structure usage' '
-       test_must_fail git repo structure -h >actual &&
+       git repo structure -h >actual &&
        test_grep "git repo structure" actual &&
        test_grep ! "git repo info" actual
 '
index fedd2cc097f349663f24c76fdea2600c67624795..6538a24c951f9b156319a2414d3e0414ee4d0c5a 100755 (executable)
@@ -16,15 +16,15 @@ test_expect_success 'checkout-index -h in broken repository' '
                cd broken &&
                git init &&
                >.git/index &&
-               test_expect_code 129 git checkout-index -h >usage 2>&1
+               git checkout-index -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage" broken/usage
 '
 
 test_expect_success 'checkout-index does not crash with -h' '
-       test_expect_code 129 git checkout-index -h >usage &&
+       git checkout-index -h >usage &&
        test_grep "[Uu]sage: git checkout-index " usage &&
-       test_expect_code 129 nongit git checkout-index -h >usage &&
+       nongit git checkout-index -h >usage &&
        test_grep "[Uu]sage: git checkout-index " usage
 '
 
index 3bffe5da8a87cc4ba9701010f3d8aac4cedaa846..004878322e05ea5f5dcf90e38ea67d563482ba69 100755 (executable)
@@ -23,7 +23,7 @@ test_expect_success 'update-index -h with corrupt index' '
                cd broken &&
                git init &&
                >.git/index &&
-               test_expect_code 129 git update-index -h >usage 2>&1
+               git update-index -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage: git update-index" broken/usage
 '
index 4034a5a59f58d8bf255669a9a4a85e922d2fa14f..c57afcb84120f452935a1c0541e89f70a6cf941b 100755 (executable)
@@ -29,15 +29,15 @@ test_expect_success 'ls-files -h in corrupt repository' '
                cd broken &&
                git init &&
                >.git/index &&
-               test_expect_code 129 git ls-files -h >usage 2>&1
+               git ls-files -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage: git ls-files " broken/usage
 '
 
 test_expect_success 'ls-files does not crash with -h' '
-       test_expect_code 129 git ls-files -h >usage &&
+       git ls-files -h >usage &&
        test_grep "[Uu]sage: git ls-files " usage &&
-       test_expect_code 129 nongit git ls-files -h >usage &&
+       nongit git ls-files -h >usage &&
        test_grep "[Uu]sage: git ls-files " usage
 '
 
index e7829c2c4bfdc3d26724a56ba109034a12d7103a..dec0e77e3c18fde4c4536997626fba6ad571b5b4 100755 (executable)
@@ -33,7 +33,7 @@ test_expect_success REFFILES 'branch -h in broken repository' '
                cd broken &&
                git init -b main &&
                >.git/refs/heads/main &&
-               test_expect_code 129 git branch -h >usage 2>&1
+               git branch -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage" broken/usage
 '
index ecc35aae82a5fe52b3f9cee195ff024b97940abb..bc07e2a6eca43502b937264c0a74b423acf70737 100755 (executable)
@@ -27,13 +27,13 @@ test_expect_success 'usage on cmd and subcommand invalid option' '
 '
 
 test_expect_success 'usage on main command -h emits a summary of subcommands' '
-       test_expect_code 129 git stash -h >usage &&
+       git stash -h >usage &&
        grep -F "usage: git stash list" usage &&
        grep -F "or: git stash show" usage
 '
 
 test_expect_success 'usage for subcommands should emit subcommand usage' '
-       test_expect_code 129 git stash push -h >usage &&
+       git stash push -h >usage &&
        grep -F "usage: git stash [push" usage
 '
 
index 1717f407c80d86246fa9198f5633bfca70dbef58..e1b474cc0f7795fbac95a32fce28814ff6452c81 100755 (executable)
@@ -438,7 +438,7 @@ test_expect_success 'rerere --no-no-rerere-autoupdate' '
 '
 
 test_expect_success 'rerere -h' '
-       test_must_fail git rerere -h >help &&
+       git rerere -h >help &&
        test_grep [Uu]sage help
 '
 
index a551e955b5524b7ff6f189500ec90c8b3b8ecdb8..a0630cc1fc8245fa6f96924feaee8f9138c59f91 100755 (executable)
@@ -47,7 +47,7 @@ test_expect_success 'midx does not create duplicate pack entries' '
 '
 
 test_expect_success 'update-server-info does not crash with -h' '
-       test_expect_code 129 git update-server-info -h >usage &&
+       git update-server-info -h >usage &&
        test_grep "[Uu]sage: git update-server-info " usage
 '
 
index 2be7cd30dece6e6eeb6d1a59083e4dbc707c92dc..e26e833d898a965878dd8235c9e8452a3ae0acab 100755 (executable)
@@ -365,7 +365,7 @@ test_expect_success 'gc.recentObjectsHook' '
 '
 
 test_expect_success 'prune does not crash with -h' '
-       test_expect_code 129 git prune -h >usage &&
+       git prune -h >usage &&
        test_grep "[Uu]sage: git prune " usage
 '
 
index b32a0a6aa77e12b51639a2f04fcdaf49bb8b1203..6aa5838e2b582ab0891a5ce35f567c8f1b8e7ab0 100755 (executable)
@@ -56,9 +56,9 @@ test_expect_success setup '
        git log'
 
 test_expect_success 'send-pack does not crash with -h' '
-       test_expect_code 129 git send-pack -h >usage &&
+       git send-pack -h >usage &&
        test_grep "[Uu]sage: git send-pack " usage &&
-       test_expect_code 129 nongit git send-pack -h >usage &&
+       nongit git send-pack -h >usage &&
        test_grep "[Uu]sage: git send-pack " usage
 '
 
index 5930f55186db23a806b95f4b0565d9c713e7fc68..8345bc0b1420a2b35a0bfece31efea27ce6a4f84 100755 (executable)
@@ -86,7 +86,7 @@ test_expect_success 'ls-remote -h is deprecated w/o warning' '
 '
 
 test_expect_success 'ls-remote --heads is deprecated and hidden w/o warning' '
-       test_expect_code 129 git ls-remote -h >short-help &&
+       git ls-remote -h >short-help &&
        test_grep ! -e --head short-help &&
        git ls-remote --heads self >actual 2>warning &&
        test_cmp expected.branches actual &&
index 1d9809114d2c8f0a7c65d5ea045d31e6d8baf884..6d27b42ff10f9ba4dc7f130aa0c34f5eb08daacf 100755 (executable)
@@ -8,9 +8,9 @@ test_description='for-each-ref test'
 . ./test-lib.sh
 
 test_expect_success "for-each-ref does not crash with -h" '
-       test_expect_code 129 git for-each-ref -h >usage &&
+       git for-each-ref -h >usage &&
        test_grep "[Uu]sage: git for-each-ref " usage &&
-       test_expect_code 129 nongit git for-each-ref -h >usage &&
+       nongit git for-each-ref -h >usage &&
        test_grep "[Uu]sage: git for-each-ref " usage
 '
 
index ea9aaad47091a40b53e1e09f4e02910fda111529..b40d13d7ff1ad1c8ddf5c4842dd67674b049e123 100755 (executable)
@@ -35,7 +35,7 @@ test_expect_success 'gc -h with invalid configuration' '
                cd broken &&
                git init &&
                echo "[gc] pruneexpire = CORRUPT" >>.git/config &&
-               test_expect_code 129 git gc -h >usage 2>&1
+               git gc -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage" broken/usage
 '
index 2c147072c17f4cd0cd1b10831c79f875a8bfc079..3bc5d1e9a272f46df8fe36a240935478e91a6ccf 100755 (executable)
@@ -8,9 +8,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
 test_expect_success GPG 'verify-tag does not crash with -h' '
-       test_expect_code 129 git verify-tag -h >usage &&
+       git verify-tag -h >usage &&
        test_grep "[Uu]sage: git verify-tag " usage &&
-       test_expect_code 129 nongit git verify-tag -h >usage &&
+       nongit git verify-tag -h >usage &&
        test_grep "[Uu]sage: git verify-tag " usage
 '
 
index c2057bc94c38c1edfda20b813ec583f4c64f3a24..de7d7beec38db5846774c6f44d406e6b3e0c6fbf 100755 (executable)
@@ -16,7 +16,7 @@ test_expect_success 'status -h in broken repository' '
                cd broken &&
                git init &&
                echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
-               test_expect_code 129 git status -h >usage 2>&1
+               git status -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage" broken/usage
 '
@@ -28,7 +28,7 @@ test_expect_success 'commit -h in broken repository' '
                cd broken &&
                git init &&
                echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
-               test_expect_code 129 git commit -h >usage 2>&1
+               git commit -h >usage 2>&1
        ) &&
        test_grep "[Uu]sage" broken/usage
 '
index aa9108da54452d3c5f73a9a39d394f8e2e1b1b7c..e641f9e334686adfa4071b957d6c68b07d57c1f6 100755 (executable)
@@ -9,9 +9,9 @@ GNUPGHOME_NOT_USED=$GNUPGHOME
 . "$TEST_DIRECTORY/lib-gpg.sh"
 
 test_expect_success GPG 'verify-commit does not crash with -h' '
-       test_expect_code 129 git verify-commit -h >usage &&
+       git verify-commit -h >usage &&
        test_grep "[Uu]sage: git verify-commit " usage &&
-       test_expect_code 129 nongit git verify-commit -h >usage &&
+       nongit git verify-commit -h >usage &&
        test_grep "[Uu]sage: git verify-commit " usage
 '
 
index f877d9a4339c4cfb211b64a145865be531fee132..fd3d1d67f9a62ae4348d5c9cd53126a091c7fc09 100755 (executable)
@@ -173,7 +173,7 @@ test_expect_success 'merge -h with invalid index' '
                cd broken &&
                git init &&
                >.git/index &&
-               test_expect_code 129 git merge -h >usage
+               git merge -h >usage
        ) &&
        test_grep "[Uu]sage: git merge" broken/usage
 '
index 8a91ff3603ff9281f77a7a35c654c91808ec45e4..961de3efab6387b5c00a4717e85aeb160cef0dca 100755 (executable)
@@ -27,12 +27,11 @@ prompt_given ()
 }
 
 test_expect_success 'basic usage requires no repo' '
-       test_expect_code 129 git difftool -h >output &&
+       git difftool -h >output &&
        test_grep ^usage: output &&
        # create a ceiling directory to prevent Git from finding a repo
        mkdir -p not/repo &&
        test_when_finished rm -r not &&
-       test_expect_code 129 \
        env GIT_CEILING_DIRECTORIES="$(pwd)/not" \
        git -C not/repo difftool -h >output &&
        test_grep ^usage: output
index d7f82e1bec163f310ea3491d012d9f723d443e61..9886f641fc970225794c0377207461153aa972d1 100755 (executable)
@@ -35,7 +35,7 @@ test_systemd_analyze_verify () {
 }
 
 test_expect_success 'help text' '
-       test_expect_code 129 git maintenance -h >actual &&
+       git maintenance -h >actual &&
        test_grep "usage: git maintenance <subcommand>" actual &&
        test_expect_code 129 git maintenance barf 2>err &&
        test_grep "unknown subcommand: \`barf'\''" err &&
diff --git a/usage.c b/usage.c
index 527edb1e792269ae9ead5bae5a7944d0d949e5ce..3f0118ab2a041167e54a1e5b0784e6ffa39b15f4 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -188,7 +188,7 @@ static void show_usage_if_asked_helper(const char *err, ...)
        va_start(params, err);
        vfreportf(stdout, _("usage: "), err, params);
        va_end(params);
-       exit(129);
+       exit(0);
 }
 
 void show_usage_if_asked(int ac, const char **av, const char *err)