do_for_each_reflog(): return early on error

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2012-04-25 00:45:13 +02:00 committed by Junio C Hamano
parent 9f2fb4a373
commit 93c603fcb7

14
refs.c
View File

@ -2246,12 +2246,15 @@ static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
{
DIR *d = opendir(git_path("logs/%s", base));
int retval = 0;
if (d) {
struct dirent *de;
int baselen = strlen(base);
char *log = xmalloc(baselen + 257);
int baselen;
char *log;
if (!d)
return *base ? errno : 0;
baselen = strlen(base);
log = xmalloc(baselen + 257);
memcpy(log, base, baselen);
if (baselen && base[baselen-1] != '/')
log[baselen++] = '/';
@ -2284,9 +2287,6 @@ static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
}
free(log);
closedir(d);
}
else if (*base)
return errno;
return retval;
}