Skip to content

Commit

Permalink
Save errno in handle_alias()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Jun 28, 2006
1 parent f0ef059 commit 47e5c0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int split_cmdline(char *cmdline, const char ***argv)

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);
Expand Down Expand Up @@ -138,6 +138,8 @@ static int handle_alias(int *argcp, const char ***argv)
if (subdir)
chdir(subdir);

errno = saved_errno;

return ret;
}

Expand Down

0 comments on commit 47e5c0c

Please sign in to comment.