X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git.c;h=4588a8bac21a12240c84eac4b24d68cb72920d80;hb=f1f523eae99020d58ad6e7a1ef8187569e15c270;hp=7d7f949f0da85ea124f67ead6f68fdd0ddc75d20;hpb=2dc7f40d4424f66e1324a1600de3fcdd115ab07f;p=git.git diff --git a/git.c b/git.c index 7d7f949f0..4588a8bac 100644 --- a/git.c +++ b/git.c @@ -188,10 +188,9 @@ static int handle_alias(int *argcp, const char ***argv) alias_command); new_argv = xrealloc(new_argv, sizeof(char *) * - (count + *argcp + 1)); + (count + *argcp)); /* insert after command name */ memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp); - new_argv[count+*argcp] = NULL; *argv = new_argv; *argcp += count - 1; @@ -200,7 +199,7 @@ static int handle_alias(int *argcp, const char ***argv) } if (subdir && chdir(subdir)) - die("Cannot change to %s: %s", subdir, strerror(errno)); + die_errno("Cannot change to '%s'", subdir); errno = saved_errno; @@ -246,7 +245,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) status = p->fn(argc, argv, prefix); if (status) - return status & 0xff; + return status; /* Somebody closed stdout? */ if (fstat(fileno(stdout), &st)) @@ -257,11 +256,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) /* Check for ENOSPC and EIO errors.. */ if (fflush(stdout)) - die("write failure on standard output: %s", strerror(errno)); + die_errno("write failure on standard output"); if (ferror(stdout)) die("unknown write failure on standard output"); if (fclose(stdout)) - die("close failed on standard output: %s", strerror(errno)); + die_errno("close failed on standard output"); return 0; } @@ -417,13 +416,9 @@ static void execv_dashed_external(const char **argv) * if we fail because the command is not found, it is * OK to return. Otherwise, we just pass along the status code. */ - status = run_command_v_opt(argv, 0); - if (status != -ERR_RUN_COMMAND_EXEC) { - if (IS_RUN_COMMAND_ERR(status)) - die("unable to run '%s'", argv[0]); - exit(-status); - } - errno = ENOENT; /* as if we called execvp */ + status = run_command_v_opt(argv, RUN_SILENT_EXEC_FAILURE); + if (status >= 0 || errno != ENOENT) + exit(status); argv[0] = tmp;