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

Re: Git push failure in the case of SSH to localhost

From
Ciprian Dorin, Craciun <ciprian.craciun@gmail.com>
Date
Feb 11, 2009, 18:42 UTC
Message-ID
<8e04b5820902111042q138a2e79vc97c533007482e5c@mail.gmail.com>
In-Reply-To
<20090211180559.GC19749@coredump.intra.peff.net>
On Wed, Feb 11, 2009 at 8:05 PM, Jeff King <peff@peff.net> wrote:
Show 20 quoted lines
> On Wed, Feb 11, 2009 at 06:24:29PM +0200, Ciprian Dorin, Craciun wrote:
>
>>    15  git push file:///tmp/r2 master
>> Counting objects: 3, done.
>> Writing objects: 100% (3/3), 197 bytes, done.
>> Total 3 (delta 0), reused 0 (delta 0)
>> error: unpack should have generated
>> ea8c5601f49a4bdeea03db3adb909d590ea730d3, but I can't find it!
>> To file:///tmp/r2
>>  ! [remote rejected] master -> master (bad pack)
>> error: failed to push some refs to 'file:///tmp/r2'
>
> I can't reproduce the problem here. It looks like your receive-pack is
> somehow broken (which should be the only difference between pushing to a
> local repo and a remote one).
>
> Can you try with a vanilla version of git to be sure it is not your
> add-on patch responsible?
>
> -Peff
    Indeed it seems it's from my patch... Because with a vanila
1.6.1.1 it works perfectly... I'll dig into what I've done, although I
couldn't imagine that it was from my patch...
    For now I see that the problem comes from the function
setup_git_directory_gentry which I call inside the setup_path function
in exec_cmd.c
    Can someone help? (My patch is below...)
    Thanks,
    Ciprian Craciun.
--------
diff --git a/exec_cmd.c b/exec_cmd.c
index cdd35f9..1513ee0 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -44,6 +44,44 @@ const char *git_exec_path(void)
 	return system_path(GIT_EXEC_PATH);
 }

+/* Returns the path of the bin folder inside the .git folder. */
+/* (This could be used to store repository specific git programs.) */
+const char *git_repo_exec_path(void)
+{
+	static char path_buffer[PATH_MAX + 1];
+	static char *path = NULL;
+	
+	int non_git;
+	const char *git_dir;
+	char cwd[PATH_MAX + 1];
+	
+	if (!path) {
+		
+		path = path_buffer;
+		path[0] = '\0';
+		
+		if (!getcwd(cwd, PATH_MAX))
+			die("git_repo_exec_path: can not getcwd");
+		
+		setup_git_directory_gently(&non_git);
+		
+		if (!non_git) {
+			
+			git_dir = get_git_dir();
+			strncat(path, git_dir, PATH_MAX);
+			strncat(path, "/", PATH_MAX);
+			strncat(path, "bin", PATH_MAX);
+			
+			strncpy(path, make_absolute_path(path), PATH_MAX);
+			
+			if (chdir(cwd))
+				die("git_repo_exec_path: can not chdir to '%s'", cwd);
+		}
+	}
+	
+	return path;
+}
+
 static void add_path(struct strbuf *out, const char *path)
 {
 	if (path && *path) {
@@ -61,6 +99,7 @@ void setup_path(void)
 	const char *old_path = getenv("PATH");
 	struct strbuf new_path = STRBUF_INIT;

+	add_path(&new_path, git_repo_exec_path());
 	add_path(&new_path, argv_exec_path);
 	add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
 	add_path(&new_path, system_path(GIT_EXEC_PATH));
Previous: Jeff KingNext: Jeff King
Message 3 of 17 in “Git push failure in the case of SSH to localhost”
  1. Ciprian Dorin, CraciunFeb 11, 2009
  2. Jeff KingFeb 11, 2009
  3. Ciprian Dorin, CraciunFeb 11, 2009
  4. Jeff KingFeb 11, 2009
  5. Ciprian Dorin, CraciunFeb 11, 2009
  6. Shawn O. PearceFeb 11, 2009
  7. Ciprian Dorin, CraciunFeb 11, 2009
  8. Jeff KingFeb 11, 2009
  9. Ciprian Dorin, CraciunFeb 11, 2009
  10. Jeff KingFeb 11, 2009
  11. Ciprian Dorin, CraciunFeb 11, 2009
  12. Junio C HamanoFeb 11, 2009
  13. Ciprian Dorin, CraciunFeb 11, 2009
  14. Johannes SchindelinFeb 11, 2009
  15. Junio C HamanoFeb 11, 2009
  16. Ciprian Dorin, CraciunFeb 11, 2009
  17. Junio C HamanoFeb 11, 2009

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.