Subject: Re: [PATCH v3 5/5] submodule: error out if gitdir name is too long

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 21 Oct 2025 10:06:07 +0200

On Mon, Oct 06, 2025 at 02:25:18PM +0300, Adrian Ratiu wrote:
> diff --git a/compat/posix.h b/compat/posix.h
> index 067a00f33b..aa050fd58c 100644
> --- a/compat/posix.h
> +++ b/compat/posix.h
> @@ -250,6 +250,14 @@ char *gitdirname(char *);
>  #define NAME_MAX 255
>  #endif
>  
> +#ifdef NO_PATHCONF
> +#ifndef _PC_NAME_MAX
> +#define _PC_NAME_MAX 1 /* dummy value, only used for git_pathconf */

Are there platforms that have pathconf(3) but not _PC_NAME_MAX?

> +#endif
> +#define pathconf(a,b) git_pathconf(a,b)
> +long git_pathconf(const char *path, int name);
> +#endif
> +
>  typedef uintmax_t timestamp_t;
>  #define PRItime PRIuMAX
>  #define parse_timestamp strtoumax

Let's adapt this to our coding guidelines to make this easier to parse:

 - Nested C preprocessor directives are indented after the hash by one
   space per nesting level.

	#if FOO
	# include <foo.h>
	# if BAR
	#  include <bar.h>
	# endif
	#endif

Patrick