Skip to content

Commit 47e5c0c

Browse files
dschoJunio C Hamano
authored andcommitted
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>
1 parent f0ef059 commit 47e5c0c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

git.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int split_cmdline(char *cmdline, const char ***argv)
100100

101101
static int handle_alias(int *argcp, const char ***argv)
102102
{
103-
int nongit = 0, ret = 0;
103+
int nongit = 0, ret = 0, saved_errno = errno;
104104
const char *subdir;
105105

106106
subdir = setup_git_directory_gently(&nongit);
@@ -138,6 +138,8 @@ static int handle_alias(int *argcp, const char ***argv)
138138
if (subdir)
139139
chdir(subdir);
140140

141+
errno = saved_errno;
142+
141143
return ret;
142144
}
143145

0 commit comments

Comments
 (0)