is_directory(): a generic helper function

A simple "grep -e stat --and -e S_ISDIR" revealed there are many
open-coded implementations of this function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2008-09-09 01:27:07 -07:00
parent 10708a994a
commit 90b4a71c49
6 changed files with 19 additions and 20 deletions

View File

@ -250,7 +250,6 @@ static void read_info_alternates(const char * alternates, int depth);
*/
static int link_alt_odb_entry(const char * entry, int len, const char * relative_base, int depth)
{
struct stat st;
const char *objdir = get_object_directory();
struct alternate_object_database *ent;
struct alternate_object_database *alt;
@ -281,7 +280,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
ent->base[pfxlen] = ent->base[entlen-1] = 0;
/* Detect cases where alternate disappeared */
if (stat(ent->base, &st) || !S_ISDIR(st.st_mode)) {
if (!is_directory(ent->base)) {
error("object directory %s does not exist; "
"check .git/objects/info/alternates.",
ent->base);