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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 28 Jun 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@xxxxxx> 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@xxxxxx>

---

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;
 }
 
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]