git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git commit path vs rebase path

From
Junio C Hamano <gitster@pobox.com>
Date
May 7, 2012, 17:27 UTC
Message-ID
<7vaa1j7vg1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAAXzdLU6bQ7ta4_-WfGJVaJgt1R5tX=4PW2sq3SdjAB+F72w+Q@mail.gmail.com>
Steven Penny <svnpenn@gmail.com> writes:
Show 14 quoted lines
> 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
Previous: Steven PennyNext: Johannes Sixt
Message 2 of 32 in “Git commit path vs rebase path”
  1. Steven PennyMay 6, 2012
  2. Junio C HamanoMay 7, 2012
  3. Johannes SixtMay 8, 2012
  4. Steven PennyMay 8, 2012
  5. Johannes SixtMay 8, 2012
  6. Steven PennyMay 8, 2012
  7. Junio C HamanoMay 8, 2012
  8. Junio C HamanoMay 8, 2012
  9. Steven PennyMay 8, 2012
  10. Junio C HamanoMay 9, 2012
  11. Steven PennyMay 9, 2012
  12. Ramsay JonesMay 10, 2012
  13. Steven PennyMay 11, 2012
  14. Ramsay JonesMay 13, 2012
  15. Steven PennyMay 13, 2012
  16. Johannes SixtMay 14, 2012
  17. Ramsay JonesMay 15, 2012
  18. Johannes SixtMay 16, 2012
  19. Ramsay JonesMay 17, 2012
  20. Junio C HamanoMay 17, 2012
  21. 0/2 Re: Git commit path vs rebase pathJunio C Hamano, May 16, 2012
  22. 1/2 git-sh-setup: define workaround wrappers before they are usedJunio C Hamano, May 16, 2012
  23. Ramsay JonesMay 17, 2012
  24. 2/2 git-sh-setup: work around Cygwin path handling gotchasJunio C Hamano, May 16, 2012
  25. Steven PennyMay 16, 2012
  26. Junio C HamanoMay 16, 2012
  27. Ramsay JonesMay 17, 2012
  28. Junio C HamanoMay 18, 2012
  29. Steven PennyMay 19, 2012
  30. Ramsay JonesMay 21, 2012
  31. Junio C HamanoMay 21, 2012
  32. Ramsay JonesMay 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.