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

Re: [BUG] git_path() returns relative paths

From
Duy Nguyen <pclouds@gmail.com>
Date
Jul 28, 2013, 05:00 UTC
Message-ID
<20130728050009.GA10844@lanh>
In-Reply-To
<CALkWK0=xuNGM54=Kodfi9L8_yUOaXrWvqiMHbx2SRTH1CmZxLA@mail.gmail.com>
On Sat, Jul 27, 2013 at 09:35:40PM +0530, Ramkumar Ramachandra wrote:
Show 27 quoted lines
> Duy Nguyen wrote:
> > I was involved with this code (the gitdir setup code, not submodule)
> > and am interested to know what's going on too. Could you produce a
> > small script to reproduce it?
> 
> Here's your reduced testcase. Just point mygit to a HEAD build.
> 
>   #!/bin/sh
> 
>   mygit=~/src/git/git
>   cd /tmp
>   $mygit clone https://github.com/artagnon/clayoven
>   cd clayoven
>   $mygit submodule add https://github.com/lewang/flx .elisp/flx
>   $mygit commit -a -m "Added submodule"
>   cd /tmp
>   ln -s clayoven/.elisp
>   cd .elisp/flx
>   EDITOR="emacs -Q" git commit --amend
>   # buffer-file-name = "/tmp/.git/modules/.elisp/flx/COMMIT_EDITMSG"
> 
> Note that this is emacs 24.3. I used -Q to make sure that none of my
> init magic (magit etc.) was responsible for changing directories or
> doing something equally stupid. However, considering that it's
> impossible to reproduce the problem with either cat or vim as the
> EDITOR, you might be inclined to classify this as an Emacs bug. In
> that case, why can't I reproduce it without submodules?
How about something like this as a workaround for emacs?
-- 8< --
diff --git a/editor.c b/editor.c
index 27bdecd..fda3e41 100644
--- a/editor.c
+++ b/editor.c
@@ -37,7 +37,8 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 		return error("Terminal is dumb, but EDITOR unset");
 
 	if (strcmp(editor, ":")) {
-		const char *args[] = { editor, path, NULL };
+		char *rpath = realpath(path, NULL);
+		const char *args[] = { editor, rpath, NULL };
 		struct child_process p;
 		int ret, sig;
 
@@ -51,6 +52,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 		sigchain_push(SIGINT, SIG_IGN);
 		sigchain_push(SIGQUIT, SIG_IGN);
 		ret = finish_command(&p);
+		free(rpath);
 		sig = ret - 128;
 		sigchain_pop(SIGINT);
 		sigchain_pop(SIGQUIT);
-- 8< --

> 
> I'm going off to eat cake before I tear my hair out in frustration.
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 15 of 18 in “[BUG] git_path() returns relative paths”
  1. Ramkumar RamachandraJul 27, 2013
  2. Duy NguyenJul 27, 2013
  3. Ramkumar RamachandraJul 27, 2013
  4. Ramkumar RamachandraJul 27, 2013
  5. Duy NguyenJul 27, 2013
  6. Ramkumar RamachandraJul 27, 2013
  7. Duy NguyenJul 27, 2013
  8. Ramkumar RamachandraJul 27, 2013
  9. Jiang XinJul 27, 2013
  10. Ramkumar RamachandraJul 28, 2013
  11. Duy NguyenJul 28, 2013
  12. Ramkumar RamachandraJul 28, 2013
  13. Duy NguyenJul 28, 2013
  14. Ramkumar RamachandraJul 28, 2013
  15. Duy NguyenJul 28, 2013
  16. Ramkumar RamachandraJul 28, 2013
  17. Fredrik GustafssonJul 27, 2013
  18. Ramkumar RamachandraJul 27, 2013

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.