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

Re: [PATCH] git.c: Re-introduce sane error messages on missing commands.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 28, 2006, 10:45 UTC
Message-ID
<Pine.LNX.4.63.0606281240480.29667@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vr71938t4.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 28 Jun 2006, Junio C Hamano wrote:
Show 11 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Try this:
> >
> > $ mkdir 5
> > $ cd 5
> > $ git-init-db
> > $ rm .git/config # yes, really.
> > $ git abc
> 
> Thanks for trying to help, but not really.

Okay. Does not happen with 'next' here, too. I have some changes in my private repo (which eventually should culminate in the big mmap()ed sooper config parsing / writing thingie), which make it break. The following patch fixes this (and potentially Andreas' problem, too).

-- cut here --
[PATCH] save errno in handle_alias()

git.c:main() relies on the value of errno being set by the last attempt to execute the command. However, if something goes awry in handle_alias(), that assumption is wrong. So restore errno before returning from handle_alias().

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
diff --git a/git.c b/git.c
index 94e9a4a..7c7106e 100644
--- a/git.c
+++ b/git.c
@@ -99,7 +99,7 @@ static int split_cmdline(char *cmdline, 
 
 static int handle_alias(int *argcp, const char ***argv)
 {
-	int nongit = 0, ret = 0;
+	int nongit = 0, ret = 0, saved_errno = errno;
 	const char *subdir;
 
 	subdir = setup_git_directory_gently(&nongit);
@@ -137,6 +137,8 @@ static int handle_alias(int *argcp, cons
 	if (subdir)
 		chdir(subdir);
 
+	errno = saved_errno;
+
 	return ret;
 }
 
Previous: Junio C HamanoNext: Andreas Ericsson
Message 6 of 9 in “git.c: Re-introduce sane error messages on missing commands.”
  1. git.c: Re-introduce sane error messages on missing commands.Andreas Ericsson, Jun 27, 2006
  2. Junio C HamanoJun 27, 2006
  3. Andreas EricssonJun 28, 2006
  4. Johannes SchindelinJun 28, 2006
  5. Junio C HamanoJun 28, 2006
  6. Johannes SchindelinJun 28, 2006
  7. Andreas EricssonJun 28, 2006
  8. Marco RoelandJun 28, 2006
  9. Christopher FaylorJun 28, 2006

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.