From e5a329a279c7ecb5214ccc049ca659aa3ad733cf Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 11 Dec 2018 14:46:07 +0900 Subject: [PATCH 1/8] run-command: report exec failure In 321fd823 ("run-command: mark path lookup errors with ENOENT", 2018-10-24), we rewrote the logic to execute a command by looking in the directories on $PATH; as a side effect, a request to run a command that is not found on $PATH is noticed even before a child process is forked to execute it. We however stopped to report an exec failure in such a case by mistake. Add a logic to report the error unless silent-exec-failure is requested, to match the original code. Reported-by: John Passaro Signed-off-by: Junio C Hamano --- run-command.c | 2 ++ t/t0061-run-command.sh | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/run-command.c b/run-command.c index d679cc267c..e2bc18a083 100644 --- a/run-command.c +++ b/run-command.c @@ -728,6 +728,8 @@ fail_pipe: if (prepare_cmd(&argv, cmd) < 0) { failed_errno = errno; cmd->pid = -1; + if (!cmd->silent_exec_failure) + error_errno("cannot run %s", cmd->argv[0]); goto end_of_spawn; } diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index b9cfc03a53..8a484878ec 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -14,11 +14,13 @@ EOF >empty test_expect_success 'start_command reports ENOENT (slash)' ' - test-tool run-command start-command-ENOENT ./does-not-exist + test-tool run-command start-command-ENOENT ./does-not-exist 2>err && + test_i18ngrep "\./does-not-exist" err ' test_expect_success 'start_command reports ENOENT (no slash)' ' - test-tool run-command start-command-ENOENT does-not-exist + test-tool run-command start-command-ENOENT does-not-exist 2>err && + test_i18ngrep "does-not-exist" err ' test_expect_success 'run_command can run a command' ' @@ -34,7 +36,8 @@ test_expect_success 'run_command is restricted to PATH' ' write_script should-not-run <<-\EOF && echo yikes EOF - test_must_fail test-tool run-command run-command should-not-run + test_must_fail test-tool run-command run-command should-not-run 2>err && + test_i18ngrep "should-not-run" err ' test_expect_success !MINGW 'run_command can run a script without a #! line' ' From 5acea87c3abfa5316fa27476c02e46eded8b26ae Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 11 Dec 2018 06:58:10 -0800 Subject: [PATCH 2/8] help.h: fix coding style We want a space after the `while` keyword. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- help.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help.h b/help.h index 9eab6a3f89..a141e209ae 100644 --- a/help.h +++ b/help.h @@ -15,7 +15,7 @@ struct cmdnames { static inline void mput_char(char c, unsigned int num) { - while(num--) + while (num--) putchar(c); } From 1c4b985965a4c424e7e5ae4756e139c98183278d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 11 Dec 2018 06:58:11 -0800 Subject: [PATCH 3/8] help -a: handle aliases with long names gracefully We take pains to determine the longest command beforehand, so that we can align the category column after printing the command names. However, then we re-use that value when printing the aliases. If any alias name is longer than the longest command name, we consequently try to add a negative number of spaces (but `mput_char()` does not expect any negative values and simply decrements until the value is 0, i.e. it tries to add close to 2**31 spaces). Let's fix this by adjusting the `longest` variable before printing the aliases. This fixes https://github.com/git-for-windows/git/issues/1975. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- help.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/help.c b/help.c index 4745b32299..ff05fd22df 100644 --- a/help.c +++ b/help.c @@ -83,8 +83,9 @@ static void print_command_list(const struct cmdname_help *cmds, for (i = 0; cmds[i].name; i++) { if (cmds[i].category & mask) { + size_t len = strlen(cmds[i].name); printf(" %s ", cmds[i].name); - mput_char(' ', longest - strlen(cmds[i].name)); + mput_char(' ', longest > len ? longest - len : 1); puts(_(cmds[i].help)); } } @@ -526,6 +527,13 @@ void list_all_cmds_help(void) git_config(get_alias, &alias_list); string_list_sort(&alias_list); + + for (i = 0; i < alias_list.nr; i++) { + size_t len = strlen(alias_list.items[i].string); + if (longest < len) + longest = len; + } + if (alias_list.nr) { printf("\n%s\n", _("Command aliases")); ALLOC_ARRAY(aliases, alias_list.nr + 1); From a92ec7efe0ad25f1c2047230c0324dcb54ce1cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 11 Dec 2018 16:35:01 +0100 Subject: [PATCH 4/8] parse-options: fix SunCC compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compiler reports this because show_gitcomp() never actually returns a value: "parse-options.c", line 520: warning: Function has no return statement : show_gitcomp We could shut the compiler up. But instead let's not bury exit() too deep. Do the same as internal -h handling, return a special error code and handle the exit() in parse_options() (and other parse_options_step() callers) instead. Reported-by: Ævar Arnfjörð Bjarmason Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/blame.c | 2 ++ builtin/shortlog.c | 2 ++ builtin/update-index.c | 2 ++ parse-options.c | 4 +++- parse-options.h | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/builtin/blame.c b/builtin/blame.c index 5a0388aaef..7e880392a6 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -844,6 +844,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) case PARSE_OPT_HELP: case PARSE_OPT_ERROR: exit(129); + case PARSE_OPT_COMPLETE: + exit(0); case PARSE_OPT_DONE: if (ctx.argv[0]) dashdash_pos = ctx.cpidx; diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 608d6ba77b..e9c12bd392 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -286,6 +286,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) case PARSE_OPT_HELP: case PARSE_OPT_ERROR: exit(129); + case PARSE_OPT_COMPLETE: + exit(0); case PARSE_OPT_DONE: goto parse_done; } diff --git a/builtin/update-index.c b/builtin/update-index.c index a8709a26ec..9d41ba0ad4 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -1071,6 +1071,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) case PARSE_OPT_HELP: case PARSE_OPT_ERROR: exit(129); + case PARSE_OPT_COMPLETE: + exit(0); case PARSE_OPT_NON_OPTION: case PARSE_OPT_DONE: { diff --git a/parse-options.c b/parse-options.c index 7db84227ab..92e4099449 100644 --- a/parse-options.c +++ b/parse-options.c @@ -516,7 +516,7 @@ static int show_gitcomp(struct parse_opt_ctx_t *ctx, show_negated_gitcomp(original_opts, -1); show_negated_gitcomp(original_opts, nr_noopts); fputc('\n', stdout); - exit(0); + return PARSE_OPT_COMPLETE; } static int usage_with_options_internal(struct parse_opt_ctx_t *, @@ -638,6 +638,8 @@ int parse_options(int argc, const char **argv, const char *prefix, case PARSE_OPT_HELP: case PARSE_OPT_ERROR: exit(129); + case PARSE_OPT_COMPLETE: + exit(0); case PARSE_OPT_NON_OPTION: case PARSE_OPT_DONE: break; diff --git a/parse-options.h b/parse-options.h index dd14911a29..c433c42828 100644 --- a/parse-options.h +++ b/parse-options.h @@ -197,6 +197,7 @@ extern int opterror(const struct option *opt, const char *reason, int flags); /*----- incremental advanced APIs -----*/ enum { + PARSE_OPT_COMPLETE = -2, PARSE_OPT_HELP = -1, PARSE_OPT_DONE, PARSE_OPT_NON_OPTION, From 98f2d930d19c86c3c3d51176616558a73fd3d1de Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 12 Dec 2018 10:14:54 -0800 Subject: [PATCH 5/8] t4256: mark support files as LF-only The test t4256-am-format-flowed.sh requires carefully applying a patch after ignoring padding whitespace. This breaks if the file is munged to include CRLF line endings instead of LF. Signed-off-by: Johannes Schindelin Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- t/.gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/t/.gitattributes b/t/.gitattributes index 3bd959ae52..af5ce637b7 100644 --- a/t/.gitattributes +++ b/t/.gitattributes @@ -14,6 +14,7 @@ t[0-9][0-9][0-9][0-9]/* -whitespace /t4135/* eol=lf /t4211/* eol=lf /t4252/* eol=lf +/t4256/1/* eol=lf /t5100/* eol=lf /t5515/* eol=lf /t556x_common eol=lf From 0365b9ec59f5fbe6a1a638bdb006d0ebcbd53a99 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 13 Dec 2018 06:04:19 -0800 Subject: [PATCH 6/8] t9902: 'send-email' test case requires PERL The oneline notwithstanding, 13374987dd (completion: use _gitcompbuiltin for format-patch, 2018-11-03) changed also the way send-email options are completed, by asking the git send-email command itself what options it offers. Necessarily, this must fail when built with NO_PERL because send-email itself is a Perl script. Which means that we need the PERL prerequisite for the send-email test case in t9902. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t9902-completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index d01ad8eb25..137fdc9bd5 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1539,7 +1539,7 @@ test_expect_success 'complete tree filename with metacharacters' ' EOF ' -test_expect_success 'send-email' ' +test_expect_success PERL 'send-email' ' test_completion "git send-email --cov" "--cover-letter " && test_completion "git send-email ma" "master " ' From fc767afe77ee0e1bca50d86c8ec1277ea473b1bc Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 11 Dec 2018 12:35:46 -0800 Subject: [PATCH 7/8] .gitattributes: ensure t/oid-info/* has eol=lf The new test_oid machinery in the test library requires reading some information from t/oid-info/hash-info and t/oid-info/oid. The logic to read from these files in shell uses built-in "read" command, which leaves CR at the end of these text files when they are checked out with CRLF line endings, at least when run with bash shipped with Git for Windows. This results in an unexpected value in the variable these lines are read into, leading the tests to fail. Mark them to be checked out always with the LF line endings. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 1bdc91e282..4a9e869f02 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,3 +9,4 @@ /command-list.txt eol=lf /GIT-VERSION-GEN eol=lf /mergetools/* eol=lf +/t/oid-info/* eol=lf From 0d0ac3826a3bbb9247e39e12623bbcfdd722f24c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 15 Dec 2018 12:31:34 +0900 Subject: [PATCH 8/8] Git 2.20.1 Signed-off-by: Junio C Hamano --- Documentation/RelNotes/2.20.1.txt | 20 ++++++++++++++++++++ GIT-VERSION-GEN | 2 +- RelNotes | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Documentation/RelNotes/2.20.1.txt diff --git a/Documentation/RelNotes/2.20.1.txt b/Documentation/RelNotes/2.20.1.txt new file mode 100644 index 0000000000..dcba888dba --- /dev/null +++ b/Documentation/RelNotes/2.20.1.txt @@ -0,0 +1,20 @@ +Git v2.20.1 Release Notes +========================= + +This release is primarily to fix brown-paper-bag breakages in the +2.20.0 release. + +Fixes since v2.20 +----------------- + + * A few newly added tests were not portable and caused minority + platforms to report false breakages, which have been fixed. + + * Portability fix for a recent update to parse-options API. + + * "git help -a" did not work well when an overly long alias is + defined, which has been corrected. + + * A recent update accidentally squelched an error message when the + run_command API failed to run a missing command, which has been + corrected. diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 216beefc50..d1a2814ec7 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v2.20.0 +DEF_VER=v2.20.1 LF=' ' diff --git a/RelNotes b/RelNotes index 8d0b1654d2..463a237c65 120000 --- a/RelNotes +++ b/RelNotes @@ -1 +1 @@ -Documentation/RelNotes/2.20.0.txt \ No newline at end of file +Documentation/RelNotes/2.20.1.txt \ No newline at end of file