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

[BUG] git_path() returns relative paths

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jul 27, 2013, 11:10 UTC
Message-ID
<CALkWK0m-4wtpTAcePPWFLT7iwXdcpp+nOy9oG2iFHLsp9XdKZQ@mail.gmail.com>
Hi,

I noticed a regression in the latest master, and I've been trying to debug it for 30 minutes now. I'm still clueless about the root cause, but I'll list whatever I found so far:

I suddenly noticed that I wasn't able to commit to a certain repository with submodules anymore. This was because git commit was opening a COMMIT_EDITMSG in the wrong path. To reproduce the problem, you need a setup like mine:

  ~/dotfiles is a repository containing submodules
  ~/.elisp is a symbolic link to ~/dotfiles/.elisp, a normal directory
  ~/.elisp/flx is the submodule repository to which I'm trying to commit

The buffer-file-name of COMMIT_EDITMSG comes out as /home/artagnon/.git/modules/flx/.git/COMMIT_EDITMSG, which is completely wrong because ~ does not even contain a .git.

So, I started debugging the issue with this patch:
diff --git a/builtin/commit.c b/builtin/commit.c
index 003bd7d..38a7c77 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -678,6 +678,9 @@ static int prepare_to_commit(const char
                hook_arg2 = "";
        }

+       char *buf = get_current_dir_name();
+       die("DBG: %s | %s", buf, git_path(commit_editmsg));
+
        s->fp = fopen(git_path(commit_editmsg), "w");
        if (s->fp == NULL)
                die_errno(_("could not open '%s'"), git_path(commit_editmsg));

On master, commit returns:

  fatal: DBG: /home/artagnon/.elisp/flx |
../../.git/modules/.elisp/flx/COMMIT_EDITMSG

When backported to v1.8.3.3, commit returns:

  fatal: DBG: /home/artagnon/.elisp/flx |
/home/artagnon/dotfiles/.git/modules/.elisp/flx/COMMIT_EDITMSG

I tried looking through the logs to see what has changed in
path.c/environment.c, but have come up with nothing so far.  I think
I'll have to resort to using a hammer like bisect now.

*scratches head*
Next: Duy Nguyen
Message 1 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.