diff --git a/Makefile b/Makefile index 2fea115..b35e4ff 100644 --- a/Makefile +++ b/Makefile @@ -469,6 +469,10 @@ ifeq ($(uname_S),IRIX64) # for now, build 32-bit version BASIC_LDFLAGS += -L/usr/lib32 endif +ifeq ($(uname_S),GNU) + # GNU stands for GNU/Hurd + NO_STRLCPY=YesPlease +endif ifneq (,$(findstring arm,$(uname_M))) ARM_SHA1 = YesPlease endif diff --git a/builtin-add.c b/builtin-add.c index 5e6748f..3add380 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -74,7 +74,8 @@ static void fill_directory(struct dir_st path = git_path("info/exclude"); if (!access(path, R_OK)) add_excludes_from_file(dir, path); - if (!access(excludes_file, R_OK)) + if (excludes_file != NULL + && !access(excludes_file, R_OK)) add_excludes_from_file(dir, excludes_file); /* diff --git a/refs.c b/refs.c index 89876bf..1fa8830 100644 --- a/refs.c +++ b/refs.c @@ -662,7 +662,12 @@ static struct ref_lock *verify_lock(stru static int remove_empty_dir_recursive(char *path, int len) { + fprintf (stderr, "%s: p=%s;l=%d.\n", __PRETTY_FUNCTION__, + path, len); + DIR *dir = opendir(path); + fprintf (stderr, "%s: dir=%x.\n", __PRETTY_FUNCTION__, + dir); struct dirent *e; int ret = 0; @@ -670,17 +675,29 @@ static int remove_empty_dir_recursive(ch return -1; if (path[len-1] != '/') path[len++] = '/'; + + fprintf (stderr, "%s-2: p=%s,l=%d.\n", __PRETTY_FUNCTION__, path, len); + while ((e = readdir(dir)) != NULL) { struct stat st; int namlen; + + fprintf (stderr, "%s-2: e=%s.\n", __PRETTY_FUNCTION__, e->d_name); + if ((e->d_name[0] == '.') && ((e->d_name[1] == 0) || ((e->d_name[1] == '.') && e->d_name[2] == 0))) continue; /* "." and ".." */ namlen = strlen(e->d_name); + + fprintf (stderr, "%s-2: n=%d,l+n=%d.\n", __PRETTY_FUNCTION__, namlen, len + namlen); + if ((len + namlen < PATH_MAX) && strcpy(path + len, e->d_name) && + + (fprintf (stderr, "%s-2: p=%s.\n", __PRETTY_FUNCTION__, path), 1) && + !lstat(path, &st) && S_ISDIR(st.st_mode) && !remove_empty_dir_recursive(path, len + namlen)) @@ -710,6 +727,10 @@ static int remove_empty_directories(char if (len >= PATH_MAX) /* path too long ;-) */ return -1; strcpy(path, file); + + fprintf (stderr, "%s: f=%s;p=%s;l=%d < %d.\n", __PRETTY_FUNCTION__, + file, path, len, PATH_MAX); + return remove_empty_dir_recursive(path, len); }