Re: Git commit path vs rebase path

5 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: Git commit path vs rebase path

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:46

Steven Penny [off-list ref] writes:
I have noticed

git commit uses this path

.git/COMMIT_EDITMSG

git rebase uses this path

/home/Steven/jquery/.git/rebase-merge/git-rebase-todo

So git commit is using a relative path while git rebase is using absolute path.

This causes problem in Windows if your editor does not understand linux paths,
e.g. notepad, Notepad2, Notepad++, etc.
Hrm, this is not limited to rebase, though.  All shell scripted Porcelain
command use git-sh-setup that gives GIT_DIR as the full path, primarily so
that the implementation of the Porcelain can safely chdir around without
having to worry about relative paths in GIT_DIR.

Most of the time, the commands that use git-sh-setup do cd_to_toplevel
very early.  For these commands, unless you are using GIT_DIR from your
own environment (i.e. where people set the environment point to a place
totally unrelated to the working tree and/or the current directory), it
might look nicer if GIT_DIR given were .git/rebase-merge/git-rebase-todo,
but that will not be the real solution, as sometimes your editor _must_
deal with the full path anyway.  So the issue is _not_ that the path is
absolute, it is that the path is given as a wrong kind of absolute path.

Which suggests that "$(cd "$GIT_DIR" && pwd)" must give a full path that
is suitable for the platform, and your platform wants it to be something
like "c:\home\steven\jquery\..."?  I do not have any Windows environment
to further my speculation, so I'll leave the rest to Windows experts who
may be lurking on this list.

The relevant code snippet in git-sh-setup.sh is this part.

# Make sure we are in a valid repository of a vintage we understand,
# if we require to be in a git repository.
if test -z "$NONGIT_OK"
then
	GIT_DIR=$(git rev-parse --git-dir) || exit
	if [ -z "$SUBDIRECTORY_OK" ]
	then
		test -z "$(git rev-parse --show-cdup)" || {
			exit=$?
			echo >&2 "You need to run this command from the toplevel of the working tree."
			exit $exit
		}
	fi
	test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
		echo >&2 "Unable to determine absolute path of git directory"
		exit 1
	}
	: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
fi

Re: Git commit path vs rebase path

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:53:46

Am 5/7/2012 19:27, schrieb Junio C Hamano:
Steven Penny [off-list ref] writes:
quoted
I have noticed

git commit uses this path

.git/COMMIT_EDITMSG

git rebase uses this path

/home/Steven/jquery/.git/rebase-merge/git-rebase-todo

So git commit is using a relative path while git rebase is using absolute path.

This causes problem in Windows if your editor does not understand linux paths,
e.g. notepad, Notepad2, Notepad++, etc.
... the issue is _not_ that the path is
absolute, it is that the path is given as a wrong kind of absolute path.

Which suggests that "$(cd "$GIT_DIR" && pwd)" must give a full path that
is suitable for the platform, and your platform wants it to be something
like "c:\home\steven\jquery\..."?
The problem should be mitigated by be39048a7 (git-sh-setup.sh: Add an
pwd() function for MinGW), where the above now returns a Windows-style
absolute path, albeit with forward slashes instead of the backslashes.

I don't know what "/home/..." is in Steven's case, because it should look
more like "/c/home/..." unless it is an MSYS mount point, but even then it
should be reported as Windows-style path with the new pwd function.

IOW, the problem should be fixed in the next release.

-- Hannes

Re: Git commit path vs rebase path

From: Steven Penny <hidden>
Date: 2016-06-15 22:53:46

Johannes Sixt wrote:
The problem should be mitigated by be39048a7 (git-sh-setup.sh: Add an
pwd() function for MinGW), where the above now returns a Windows-style
absolute path, albeit with forward slashes instead of the backslashes.
http://github.com/git/git/commit/be390

This looks like a good solution for MinGW, but cygwin will not support that

$ pwd -W
bash: pwd: -W: invalid option
pwd: usage: pwd [-LP]

Cygwin uses cygpath

$ cygpath -m /c/Windows/System32
C:/Windows/System32

Re: Git commit path vs rebase path

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:53:46

Am 5/8/2012 8:44, schrieb Steven Penny:
Johannes Sixt wrote:
quoted
The problem should be mitigated by be39048a7 (git-sh-setup.sh: Add an
pwd() function for MinGW), where the above now returns a Windows-style
absolute path, albeit with forward slashes instead of the backslashes.
http://github.com/git/git/commit/be390

This looks like a good solution for MinGW, but cygwin will not support that

$ pwd -W
bash: pwd: -W: invalid option
pwd: usage: pwd [-LP]
Are you saying that the new pwd function will also be used on Cygwin? That
would be a bug.

-- Hannes

Re: Git commit path vs rebase path

From: Steven Penny <hidden>
Date: 2016-06-15 22:53:46

Johannes Sixt wrote:
Are you saying that the new pwd function will also be used on Cygwin? That
would be a bug.
The linked patch should fix the problem for _MinGW_ users.

The problem will persist with _Cygwin_ users.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help