mirror of
https://github.com/git/git.git
synced 2024-11-01 06:47:52 +01:00
c0f19bf3b9
In git versions starting at v1.7.5-rc0~29^2 until v1.7.5-rc3~2 (Revert "run-command: prettify -D_FORTIFY_SOURCE workaround", 2011-04-18) fixed it, the run_command facility would write a truncated error message when the command is present but cannot be executed for some other reason. For example, if I add a 'hello' command to git: $ echo 'echo hello' >git-hello $ chmod +x git-hello $ PATH=.:$PATH git hello hello and make it non-executable, this is what I normally get: $ chmod -x git-hello $ git hello fatal: cannot exec 'git-hello': Permission denied But with the problematic versions, we get disturbing output: $ PATH=.:$PATH git hello fatal: $ Add some tests to make sure it doesn't happen again. The hello-script used in these tests uses cat instead of echo because on Windows the bash spawned by git converts LF to CRLF in text written by echo while the bash running tests does not, causing the test to fail if "echo" is used. Thanks to Hannes for noticing. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Improved-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
37 lines
840 B
C
37 lines
840 B
C
/*
|
|
* test-run-command.c: test run command API.
|
|
*
|
|
* (C) 2009 Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
|
*
|
|
* This code is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include "git-compat-util.h"
|
|
#include "run-command.h"
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct child_process proc;
|
|
|
|
memset(&proc, 0, sizeof(proc));
|
|
|
|
if (argc < 3)
|
|
return 1;
|
|
proc.argv = (const char **)argv+2;
|
|
|
|
if (!strcmp(argv[1], "start-command-ENOENT")) {
|
|
if (start_command(&proc) < 0 && errno == ENOENT)
|
|
return 0;
|
|
fprintf(stderr, "FAIL %s\n", argv[1]);
|
|
return 1;
|
|
}
|
|
if (!strcmp(argv[1], "run-command"))
|
|
exit(run_command(&proc));
|
|
|
|
fprintf(stderr, "check usage\n");
|
|
return 1;
|
|
}
|