@matheusbsbs / matheus-bagliano / commits / 47e5c0ca2c
Fork 0

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> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Jun 28, 2006 at 12:45 UTC 47e5c0ca2cabb406518dda5c09432dc996f7ef2b
1 file changed +3 -1
git.c
+3 -1
@@ -100,7 +100,7 @@ static int split_cmdline(char *cmdline, const char ***argv)
100
101 static int handle_alias(int *argcp, const char ***argv)
102 {
103 - int nongit = 0, ret = 0;
103 + int nongit = 0, ret = 0, saved_errno = errno;
104 const char *subdir;
105
106 subdir = setup_git_directory_gently(&nongit);
@@ -138,6 +138,8 @@ static int handle_alias(int *argcp, const char ***argv)
138 if (subdir)
139 chdir(subdir);
140
141 + errno = saved_errno;
142 +
143 return ret;
144 }
145