From: Alex Riesen <raa.lkml@gmail.com>
To: Robert Watson <robert.oo.watson@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <junkio@cox.net>
Subject: Re: minor problems in git.c
Date: Thu, 1 Dec 2005 13:48:35 +0100 [thread overview]
Message-ID: <81b0412b0512010448u7fcdddacnd7de5df217ab3ca@mail.gmail.com> (raw)
In-Reply-To: <72499e3b0512010400i1de76ed2la22cd745f811007f@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 386 bytes --]
On 12/1/05, Robert Watson <robert.oo.watson@gmail.com> wrote:
> There are some minor problems in git.c:
I had the following patches in my tree for some time. Even forgot
about them, sorry.
The second on top of the first.
- Use stderr for error output
- Build git_command more careful
- ENOENT is good enough for check of failed exec to show usage, no
access() check needed
[-- Attachment #2: 0001-used-stderr-for-error-output-and-build-git_command-more-careful.txt --]
[-- Type: text/plain, Size: 984 bytes --]
Use stderr for error output and build git_command more careful
---
git.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
081fc78a8c8e640420ac7e44d93a2a45246f5c2f
diff --git a/git.c b/git.c
index bdd3f8d..9468b58 100644
--- a/git.c
+++ b/git.c
@@ -283,16 +283,15 @@ int main(int argc, char **argv, char **e
len = strlen(git_command);
prepend_to_path(git_command, len);
- strncat(&git_command[len], "/git-", sizeof(git_command) - len);
- len += 5;
- strncat(&git_command[len], argv[i], sizeof(git_command) - len);
+ snprintf(git_command + len, sizeof(git_command) - len, "/git-%s",
+ argv[i]);
if (access(git_command, X_OK))
usage(exec_path, "'%s' is not a git-command", argv[i]);
/* execve() can only ever return if it fails */
execve(git_command, &argv[i], envp);
- printf("Failed to run command '%s': %s\n", git_command, strerror(errno));
+ fprintf(stderr, "git: '%s': %s\n", git_command, strerror(errno));
return 1;
}
--
0.99.9.GIT
[-- Attachment #3: 0002-ENOENT-is-good-enough-no-access-check-needed.txt --]
[-- Type: text/plain, Size: 855 bytes --]
ENOENT is good enough, no access() check needed
---
git.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
ac97adc8152a1e5ac78a03f218a3dab012bf8ba9
diff --git a/git.c b/git.c
index 9468b58..c8c2b4a 100644
--- a/git.c
+++ b/git.c
@@ -286,12 +286,12 @@ int main(int argc, char **argv, char **e
snprintf(git_command + len, sizeof(git_command) - len, "/git-%s",
argv[i]);
- if (access(git_command, X_OK))
- usage(exec_path, "'%s' is not a git-command", argv[i]);
-
/* execve() can only ever return if it fails */
execve(git_command, &argv[i], envp);
- fprintf(stderr, "git: '%s': %s\n", git_command, strerror(errno));
+ if ( ENOENT == errno )
+ usage(exec_path, "'%s' is not a git-command", argv[i]);
+ else
+ fprintf(stderr, "git: '%s': %s\n", git_command, strerror(errno));
return 1;
}
--
0.99.9.GIT
next prev parent reply other threads:[~2005-12-01 12:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-01 12:00 minor problems in git.c Robert Watson
2005-12-01 12:48 ` Alex Riesen [this message]
2005-12-01 13:51 ` Sven Verdoolaege
2005-12-01 14:02 ` Alex Riesen
2005-12-02 1:07 ` Junio C Hamano
2005-12-02 8:12 ` Alex Riesen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81b0412b0512010448u7fcdddacnd7de5df217ab3ca@mail.gmail.com \
--to=raa.lkml@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=robert.oo.watson@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox