git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Merge problems with git-mingw
@ 2007-10-08 11:06 Peter Karlsson
  2007-10-08 12:00 ` Lars Hjemli
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Karlsson @ 2007-10-08 11:06 UTC (permalink / raw)
  To: git

Hi!

I am running the mingw port of Git from a Cygwin environment, because I
had problems with the Cygwin version (not sure what the problem was,
probably a CRLF issue). Everything works fine, except for merging:

  $ git merge master
  usage: git-var [-l | <variable>]
  $

Does anyone have any idea on what could cause that? (I've checked that
git-var is indeed the mingw version and not the Cygwin version).

  $ git --version
  git version 1.5.3.mingw.1

I'm running on top of another version control system, so I need to
switch back to master and update the sources from upstream using that
system's tools, and then merge it back into my branch. Without "git
merge" working, that is a bit problematic, to say the least... :-)

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 11:06 Merge problems with git-mingw Peter Karlsson
@ 2007-10-08 12:00 ` Lars Hjemli
  2007-10-08 12:33   ` Peter Karlsson
  0 siblings, 1 reply; 17+ messages in thread
From: Lars Hjemli @ 2007-10-08 12:00 UTC (permalink / raw)
  To: Peter Karlsson; +Cc: git

On 10/8/07, Peter Karlsson <peter@softwolves.pp.se> wrote:
>   $ git merge master
>   usage: git-var [-l | <variable>]
>   $

What does this command return?

  $ git var GIT_COMMITTER_IDENT

--
larsh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 12:00 ` Lars Hjemli
@ 2007-10-08 12:33   ` Peter Karlsson
  2007-10-08 13:10     ` Lars Hjemli
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Karlsson @ 2007-10-08 12:33 UTC (permalink / raw)
  Cc: git

> What does this command return?
> 
>   $ git var GIT_COMMITTER_IDENT

Doesn't seem to work:

  $ git var GIT_COMMITTER_IDENT
  usage: git-var [-l | <variable>]

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 12:33   ` Peter Karlsson
@ 2007-10-08 13:10     ` Lars Hjemli
  2007-10-08 14:56       ` Peter Karlsson
  0 siblings, 1 reply; 17+ messages in thread
From: Lars Hjemli @ 2007-10-08 13:10 UTC (permalink / raw)
  To: Peter Karlsson; +Cc: git

On 10/8/07, Peter Karlsson <peter@softwolves.pp.se> wrote:
> > What does this command return?
> >
> >   $ git var GIT_COMMITTER_IDENT
>
> Doesn't seem to work:
>
>   $ git var GIT_COMMITTER_IDENT
>   usage: git-var [-l | <variable>]

Something is weird with your setup and/or the mingw port, but you can
probably work around the issue by doing this:

$ git config user.name "your name"
$ git config user.email "your email"

Optionally, you can add the --global flag to both commands to make the
config visible in all of your repos.

--
larsh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 13:10     ` Lars Hjemli
@ 2007-10-08 14:56       ` Peter Karlsson
  2007-10-08 19:59         ` Lars Hjemli
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Karlsson @ 2007-10-08 14:56 UTC (permalink / raw)
  Cc: git

Hi!

> Something is weird with your setup and/or the mingw port, but you can
> probably work around the issue by doing this:
> 
> $ git config user.name "your name"
> $ git config user.email "your email"

Both of those are configured properly, but even after configuring them
locally for the repository only, I get the same error with "git var".
Weird.

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 14:56       ` Peter Karlsson
@ 2007-10-08 19:59         ` Lars Hjemli
  2007-10-09  6:10           ` Johannes Sixt
  2007-10-09  7:06           ` Peter Karlsson
  0 siblings, 2 replies; 17+ messages in thread
From: Lars Hjemli @ 2007-10-08 19:59 UTC (permalink / raw)
  To: Peter Karlsson; +Cc: git, Johannes Sixt

[Johannes CC'ed as the mingw.git maintainer]

On 10/8/07, Peter Karlsson <peter@softwolves.pp.se> wrote:
> $ git var GIT_COMMITTER_IDENT
> usage: git-var [-l | <variable>]

Does 'git var -l' work as expected? Also, could you try the latest
git-package provided by the cygwin installer? If CRLF-handling was
your problem, take a look at the description of core.autocrlf with
'git help config'.

[This does look like an issue with running mingw.git under Cygwin.
Johannes, is this even supposed to work?]

--
larsh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 19:59         ` Lars Hjemli
@ 2007-10-09  6:10           ` Johannes Sixt
  2007-10-09  7:06           ` Peter Karlsson
  1 sibling, 0 replies; 17+ messages in thread
From: Johannes Sixt @ 2007-10-09  6:10 UTC (permalink / raw)
  To: Lars Hjemli; +Cc: Peter Karlsson, git

Lars Hjemli schrieb:
> On 10/8/07, Peter Karlsson <peter@softwolves.pp.se> wrote:
>> $ git var GIT_COMMITTER_IDENT
>> usage: git-var [-l | <variable>]
> 
> Does 'git var -l' work as expected? Also, could you try the latest
> git-package provided by the cygwin installer? If CRLF-handling was
> your problem, take a look at the description of core.autocrlf with
> 'git help config'.
> 
> [This does look like an issue with running mingw.git under Cygwin.
> Johannes, is this even supposed to work?]

Sure, why not? Cygwin's settings as well as core.autocrlf should be 
completely irrelevant. I've no clue what could be wrong here.

-- Hannes

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-08 19:59         ` Lars Hjemli
  2007-10-09  6:10           ` Johannes Sixt
@ 2007-10-09  7:06           ` Peter Karlsson
  2007-10-09  7:36             ` Johannes Sixt
  1 sibling, 1 reply; 17+ messages in thread
From: Peter Karlsson @ 2007-10-09  7:06 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt

HI!

> Does 'git var -l' work as expected?

Hmm, it also gives an error message:

$ git var -l
usage: git-var [-l | <variable>]

> Also, could you try the latest git-package provided by the cygwin
> installer? If CRLF-handling was your problem, take a look at the
> description of core.autocrlf with 'git help config'.

I tried it with Git 1.5.3.2 from Cygwin, and the problem I'm having is
not with the CRLF handling in the checked out files, but rather in the
repository database itself. Cloning a repository with Cygwin-Git
produced various errors about the object database being corrupt.
Mingw-Git does not produce those errors.

> [This does look like an issue with running mingw.git under Cygwin.
> Johannes, is this even supposed to work?]

I get the same error running mingw-git from a regular cmd.exe prompt,
so it doesn't seem to be related to Cygwin at all.

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-09  7:06           ` Peter Karlsson
@ 2007-10-09  7:36             ` Johannes Sixt
  2007-10-09  8:56               ` Peter Karlsson
  0 siblings, 1 reply; 17+ messages in thread
From: Johannes Sixt @ 2007-10-09  7:36 UTC (permalink / raw)
  To: Peter Karlsson; +Cc: git

Peter Karlsson schrieb:
> I get the same error running mingw-git from a regular cmd.exe prompt,
> so it doesn't seem to be related to Cygwin at all.

What if you run 'git var -l' outside a repository? From CMD?
Have you tried 'git-var -l' (note the dash)? From CMD?
Are you sure you have only one version of git in the PATH?
What's in your .git/config?

-- Hannes

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-09  7:36             ` Johannes Sixt
@ 2007-10-09  8:56               ` Peter Karlsson
  2007-10-09  9:03                 ` Johannes Sixt
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Karlsson @ 2007-10-09  8:56 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

Hi!

> What if you run 'git var -l' outside a repository? From CMD?
> Have you tried 'git-var -l' (note the dash)? From CMD?

C:\Program Files\Git\bin>git var -l
usage: git-var [-l | <variable>]

C:\Program Files\Git\bin>git-var -l
fatal: Not a git repository

C:\Program Files\Git\bin>git --version
git version 1.5.3.mingw.1

> Are you sure you have only one version of git in the PATH?

Yes.

> What's in your .git/config?

This is the .git/config file for one of the repositories where it
fails:

  [core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        pager = less -x3 -r

  [instaweb]
        local = true
        httpd = c:/cygwin/usr/sbin/lighttpd.exe -f
        port = 4321
        browser = c:/progra~1/opera/opera.exe
        modulepath = c:/cygwin/usr/lib/apache
  [diff]
        renames = copies
        external = C:/Program Files/tkdiff/tkdiff.exe
  [user]
        name = Peter Karlsson
        email = peter.karlsson@tandbergdata.com

This is my global $HOME/.gitconfig:

  [user]
  name = Peter Karlsson
  email = peter@softwolves.pp.se
  [core]
          editor = c:/cygwin/bin/joe.exe
          pager = less -x3 -r
  [color]
  [color]
          pager = true

-- 
\\// Peter - http://www.softwolves.pp.se/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-09  8:56               ` Peter Karlsson
@ 2007-10-09  9:03                 ` Johannes Sixt
  2007-10-09 16:33                   ` Steffen Prohaska
  0 siblings, 1 reply; 17+ messages in thread
From: Johannes Sixt @ 2007-10-09  9:03 UTC (permalink / raw)
  To: Peter Karlsson; +Cc: git

Peter Karlsson schrieb:
> C:\Program Files\Git\bin>git var -l
> usage: git-var [-l | <variable>]
> 
> C:\Program Files\Git\bin>git-var -l
> fatal: Not a git repository
> 
> C:\Program Files\Git\bin>git --version
> git version 1.5.3.mingw.1

For the time being, install this beast in a path without blanks.

This needs fixing, appearently. :(

-- Hannes

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-09  9:03                 ` Johannes Sixt
@ 2007-10-09 16:33                   ` Steffen Prohaska
  2007-10-09 17:03                     ` Johannes Sixt
  0 siblings, 1 reply; 17+ messages in thread
From: Steffen Prohaska @ 2007-10-09 16:33 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Peter Karlsson, Git Mailing List, Johannes Schindelin


On Oct 9, 2007, at 11:03 AM, Johannes Sixt wrote:

> Peter Karlsson schrieb:
>> C:\Program Files\Git\bin>git var -l
>> usage: git-var [-l | <variable>]
>> C:\Program Files\Git\bin>git-var -l
>> fatal: Not a git repository
>> C:\Program Files\Git\bin>git --version
>> git version 1.5.3.mingw.1
>
> For the time being, install this beast in a path without blanks.
>
> This needs fixing, appearently. :(

I have the printf 'callstack' below from the v1.5.3.mingw.1 version  
(9c792c5)
Apparently spawnve, which is called in compat/mingw.c, corrupts argv.

I have no idea how to continue debugging. Maybe some one else can  
take over.

	Steffen


$ git var GIT_COMMITTER_IDENT

argv at git.c:429
3
C:\Program Files (x86)\Git\bin\git.exe
var
C:/Program Files (x86)/Git/bin/git-var
GIT_COMMITTER_IDENT

argv at compat/mingw.c:301
C:/Program Files (x86)/Git/bin/git-var
GIT_COMMITTER_IDENT
(null)

argv at var.c:54
4
C:/Program
Files
(x86)/Git/bin/git-var
GIT_COMMITTER_IDENT
usage: git-var [-l | <variable>]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-09 16:33                   ` Steffen Prohaska
@ 2007-10-09 17:03                     ` Johannes Sixt
  2007-10-09 18:09                       ` Linus Torvalds
  2007-10-09 21:39                       ` [PATCH] exec_git_cmd: fix executing commands if path contains spaces Steffen Prohaska
  0 siblings, 2 replies; 17+ messages in thread
From: Johannes Sixt @ 2007-10-09 17:03 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: Peter Karlsson, Git Mailing List, Johannes Schindelin

Steffen Prohaska schrieb:
> 
> On Oct 9, 2007, at 11:03 AM, Johannes Sixt wrote:
> 
>> Peter Karlsson schrieb:
>>> C:\Program Files\Git\bin>git var -l
>>> usage: git-var [-l | <variable>]
>>> C:\Program Files\Git\bin>git-var -l
>>> fatal: Not a git repository
>>> C:\Program Files\Git\bin>git --version
>>> git version 1.5.3.mingw.1
>>
>> For the time being, install this beast in a path without blanks.
>>
>> This needs fixing, appearently. :(
> 
> I have the printf 'callstack' below from the v1.5.3.mingw.1 version 
> (9c792c5)
> Apparently spawnve, which is called in compat/mingw.c, corrupts argv.

Thank you. Here is a quick-fix.

-- Hannes

diff --git a/compat/mingw.c b/compat/mingw.c
index 8bb0dba..361216f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -303,7 +303,7 @@ void openlog(const char *ident, int option,
  {
  }

-static const char *quote_arg(const char *arg)
+const char *quote_arg(const char *arg)
  {
  	/* count chars to quote */
  	int len = 0, n = 0;
diff --git a/exec_cmd.c b/exec_cmd.c
index bad4843..7ab5a0f 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -129,7 +129,8 @@ int execv_git_cmd(const char **argv)
  		 */

  		tmp = argv[0];
-		argv[0] = git_command;
+		extern const char *quote_arg(const char *arg);
+		argv[0] = quote_arg(git_command);

  		trace_argv_printf(argv, -1, "trace: exec:");

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: Merge problems with git-mingw
  2007-10-09 17:03                     ` Johannes Sixt
@ 2007-10-09 18:09                       ` Linus Torvalds
  2007-10-09 21:39                       ` [PATCH] exec_git_cmd: fix executing commands if path contains spaces Steffen Prohaska
  1 sibling, 0 replies; 17+ messages in thread
From: Linus Torvalds @ 2007-10-09 18:09 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: Steffen Prohaska, Peter Karlsson, Git Mailing List,
	Johannes Schindelin



On Tue, 9 Oct 2007, Johannes Sixt wrote:
>
> +		extern const char *quote_arg(const char *arg);
> +		argv[0] = quote_arg(git_command);

Extern declarations inside a local scope will not work on more modern gcc 
versions. Don't do it. Do proper prototyping in proper scope.

		Linus

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] exec_git_cmd: fix executing commands if path contains spaces
  2007-10-09 17:03                     ` Johannes Sixt
  2007-10-09 18:09                       ` Linus Torvalds
@ 2007-10-09 21:39                       ` Steffen Prohaska
  2007-10-10  6:16                         ` Johannes Sixt
  1 sibling, 1 reply; 17+ messages in thread
From: Steffen Prohaska @ 2007-10-09 21:39 UTC (permalink / raw)
  To: j.sixt; +Cc: Johannes.Schindelin, git, Steffen Prohaska

This patch fixed executing of non-builtins if installation
dir contains spaces. That is 'git var' works now.

The original patch is by Johannes Sixt <j.sixt@viscovery.net>.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 compat/mingw.c    |    2 +-
 exec_cmd.c        |    2 +-
 git-compat-util.h |    1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

Ok, this is what I created from the quick-fix. It works for
me in msysgit. 

Should the patch be polished that it can be applied to git.git
or will we only apply it to 4msysgit?

If it should be polished, what would be the right way?
ifdef in exec_cmd.c?

	Steffen


diff --git a/compat/mingw.c b/compat/mingw.c
index 6632192..0dd0cb0 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -196,7 +196,7 @@ void openlog(const char *ident, int option, int facility)
 {
 }
 
-static const char *quote_arg(const char *arg)
+const char *quote_arg(const char *arg)
 {
 	/* count chars to quote */
 	int len = 0, n = 0;
diff --git a/exec_cmd.c b/exec_cmd.c
index 2a8e48b..4c7c7ca 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -132,7 +132,7 @@ int execv_git_cmd(const char **argv)
 		 */
 
 		tmp = argv[0];
-		argv[0] = git_command;
+		argv[0] = quote_arg(git_command);
 
 		trace_argv_printf(argv, -1, "trace: exec:");
 
diff --git a/git-compat-util.h b/git-compat-util.h
index ba5a1a1..5276221 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -482,6 +482,7 @@ int mingw_socket(int domain, int type, int protocol);
 #define fsync(x) 0
 
 extern void quote_argv(const char **dst, const char **src);
+extern const char *quote_arg(const char *arg);
 extern const char *parse_interpreter(const char *cmd);
 
 extern __attribute__((noreturn)) int git_exit(int code);
-- 
1.5.3.mingw.1.13.g70ed-dirty

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] exec_git_cmd: fix executing commands if path contains spaces
  2007-10-09 21:39                       ` [PATCH] exec_git_cmd: fix executing commands if path contains spaces Steffen Prohaska
@ 2007-10-10  6:16                         ` Johannes Sixt
  2007-10-10  7:00                           ` [PATCH] Fix invocation of external git commands with arguments with spaces Johannes Sixt
  0 siblings, 1 reply; 17+ messages in thread
From: Johannes Sixt @ 2007-10-10  6:16 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: Johannes.Schindelin, git

Steffen Prohaska schrieb:
> Ok, this is what I created from the quick-fix. It works for
> me in msysgit. 
> 
> Should the patch be polished that it can be applied to git.git
> or will we only apply it to 4msysgit?

I'll apply it to mingw.git, and as long as you don't rebase or pull from 
there, you'd also have to apply it to 4msysgit.

git.git is a no-go at this time - compat/mingw.c doesn't exist, yet.

> If it should be polished, what would be the right way?
> ifdef in exec_cmd.c?

This area needs more polishing, and it will be among the *last* mingw 
patches that flow upstream.

BTW, I think the fix is incomplete anyway: We quote only argv[0], but 
actually all of argv should be quoted. Will test.

-- Hannes

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] Fix invocation of external git commands with arguments with spaces.
  2007-10-10  6:16                         ` Johannes Sixt
@ 2007-10-10  7:00                           ` Johannes Sixt
  0 siblings, 0 replies; 17+ messages in thread
From: Johannes Sixt @ 2007-10-10  7:00 UTC (permalink / raw)
  Cc: Johannes.Schindelin, git

If an external git command (not a shell script) was invoked with arguments
that contain spaces, these arguments would be split into separate
arguments. They must be quoted. This also affected installations where
$prefix contained a space, as in "C:\Program Files\GIT". Both errors can
be triggered by invoking

     git hash-object "a b"

where "a b" is an existing file.
---
Johannes Sixt schrieb:
> BTW, I think the fix is incomplete anyway: We quote only argv[0], but 
> actually all of argv should be quoted. Will test.

Here is the proper fix.

Yes, this leaks memory on the error path. We can clean that up later...

-- Hannes

  compat/mingw.c |    7 ++++++-
  1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index 8bb0dba..2554f19 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -405,7 +405,12 @@ void mingw_execve()
  {
  	/* check if git_command is a shell script */
  	if (!try_shell_exec(cmd, argv, env)) {
-		int ret = spawnve(_P_WAIT, cmd, argv, env);
+		const char **qargv;
+		int n;
+		for (n = 0; argv[n];) n++;
+		qargv = xmalloc((n+1)*sizeof(char*));
+		quote_argv(qargv, argv);
+		int ret = spawnve(_P_WAIT, cmd, qargv, env);
  		if (ret != -1)
  			exit(ret);
  	}
-- 
1.5.3.717.g01fc-dirty

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2007-10-10  7:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-08 11:06 Merge problems with git-mingw Peter Karlsson
2007-10-08 12:00 ` Lars Hjemli
2007-10-08 12:33   ` Peter Karlsson
2007-10-08 13:10     ` Lars Hjemli
2007-10-08 14:56       ` Peter Karlsson
2007-10-08 19:59         ` Lars Hjemli
2007-10-09  6:10           ` Johannes Sixt
2007-10-09  7:06           ` Peter Karlsson
2007-10-09  7:36             ` Johannes Sixt
2007-10-09  8:56               ` Peter Karlsson
2007-10-09  9:03                 ` Johannes Sixt
2007-10-09 16:33                   ` Steffen Prohaska
2007-10-09 17:03                     ` Johannes Sixt
2007-10-09 18:09                       ` Linus Torvalds
2007-10-09 21:39                       ` [PATCH] exec_git_cmd: fix executing commands if path contains spaces Steffen Prohaska
2007-10-10  6:16                         ` Johannes Sixt
2007-10-10  7:00                           ` [PATCH] Fix invocation of external git commands with arguments with spaces Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).