Hi,
On Sat, 1 Dec 2007, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
quoted
I only eyeball-tested it and looks Okay, but that does not assure us
much ;-). Is this change easy to test using local transport?
Seems like it breaks down with git-shell. But then, I think that we just
have to fix execv_git_cmd() to call builtins via "git" instead.
So in execv_git_cmd(), instead of doing the strbuf_addf(), we do
something like this (and drop your patch)?
You know what is really funny? I have this in my stash:
-- snip --
exec_cmd.c | 30 ++++++++++++------------------
t/t0020-crlf.sh | 2 +-
2 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/exec_cmd.c b/exec_cmd.c
index 2d0a758..7d022a2 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -65,31 +65,25 @@ void setup_path(const char *cmd_path)
int execv_git_cmd(const char **argv)
{
- struct strbuf cmd;
- const char *tmp;
+ int i;
+ char **new_argv;
- strbuf_init(&cmd, 0);
- strbuf_addf(&cmd, "git-%s", argv[0]);
+ for (i = 0; argv[i]; i++)
+ ; /* do nothing */
+ new_argv = xmalloc((i + 2) * sizeof(*new_argv));
+ new_argv[0] = "git";
+ for (i = 0; argv[i]; i++)
+ new_argv[i + 1] = (char *)argv[i];
+ new_argv[i] = NULL;
- /*
- * argv[0] must be the git command, but the argv array
- * belongs to the caller, and may be reused in
- * subsequent loop iterations. Save argv[0] and
- * restore it on error.
- */
- tmp = argv[0];
- argv[0] = cmd.buf;
-
- trace_argv_printf(argv, -1, "trace: exec:");
+ trace_argv_printf((const char **)new_argv, -1, "trace: exec:");
/* execvp() can only ever return if it fails */
- execvp(cmd.buf, (char **)argv);
+ execvp(new_argv[0], new_argv);
trace_printf("trace: exec failed: %s\n", strerror(errno));
- argv[0] = tmp;
-
- strbuf_release(&cmd);
+ free(new_argv);
return -1;
}diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 62bc4bb..275379d 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -36,7 +36,7 @@ test_expect_success setup '
for w in Some extra lines here; do echo $w; done >>one &&
git diff >patch.file &&
- patched=`git hash-object --stdin <one` &&
+ patched=`GIT_TRACE=2 git hash-object --stdin <one` &&
git read-tree --reset -u HEAD &&
echo happy.
-- snap --
Which looks awfully like your patch (except that I called it new_argv, I
think).
Now you might ask why there is such a funny patch to t0020? Well, the
patch does not work as-is.
Will investigate right now,
Dscho