Thread (5 messages) flat view 5 messages, 3 authors, 2016-06-15

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help