Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread Junio C Hamano
David Michael writes: >> Huh? I am confused. Since when is it legal to give NULL as statbuf >> to (l)stat(2)? >> >> Wouldn't something like this be sufficient and necessary? >> >> int rc = stat(path, buf); >> if (rc) >> return rc; >> >> That is, let the underlyin

Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread David Michael
On Mon, Dec 1, 2014 at 12:57 PM, Junio C Hamano wrote: > David Michael writes: > >> On Mon, Dec 1, 2014 at 9:44 AM, Duy Nguyen wrote: >>> On Sun, Nov 30, 2014 at 9:41 AM, David Michael wrote: +int git_stat(const char *path, struct stat *buf) +{ + int rc; + rc = s

Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread Junio C Hamano
David Michael writes: > On Mon, Dec 1, 2014 at 9:44 AM, Duy Nguyen wrote: >> On Sun, Nov 30, 2014 at 9:41 AM, David Michael wrote: >>> +int git_stat(const char *path, struct stat *buf) >>> +{ >>> + int rc; >>> + rc = stat(path, buf); >>> + if (buf != NULL) >> >> It's a minor t

Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread David Michael
On Mon, Dec 1, 2014 at 9:44 AM, Duy Nguyen wrote: > On Sun, Nov 30, 2014 at 9:41 AM, David Michael wrote: >> +int git_stat(const char *path, struct stat *buf) >> +{ >> + int rc; >> + rc = stat(path, buf); >> + if (buf != NULL) > > It's a minor thing, but maybe test "!rc" instead

Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread David Michael
On Mon, Dec 1, 2014 at 7:48 AM, David Michael wrote: > On Mon, Dec 1, 2014 at 12:55 AM, Torsten Bögershausen wrote: >> On 12/01/2014 04:40 AM, David Michael wrote: >>> >>> On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen >>> wrote: >>> [snip] Could the code be more human-readable

Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread Duy Nguyen
On Sun, Nov 30, 2014 at 9:41 AM, David Michael wrote: > +int git_stat(const char *path, struct stat *buf) > +{ > + int rc; > + rc = stat(path, buf); > + if (buf != NULL) It's a minor thing, but maybe test "!rc" instead of "buf != NULL"? > + buf->st_mode = mode_nat

Re: [PATCH] compat: convert modes to use portable file type values

2014-12-01 Thread David Michael
On Mon, Dec 1, 2014 at 12:55 AM, Torsten Bögershausen wrote: > On 12/01/2014 04:40 AM, David Michael wrote: >> >> On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen >> wrote: >> [snip] >>> >>> Could the code be more human-readable ? >>> static inline mode_t mode_native_to_git(mode_t native_mod

Re: [PATCH] compat: convert modes to use portable file type values

2014-11-30 Thread Torsten Bögershausen
On 12/01/2014 04:40 AM, David Michael wrote: On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen wrote: [snip] Could the code be more human-readable ? static inline mode_t mode_native_to_git(mode_t native_mode) { int perm_bits = native_mode & 0; if (S_ISREG(native_mode))

Re: [PATCH] compat: convert modes to use portable file type values

2014-11-30 Thread David Michael
On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen wrote: [snip] > Could the code be more human-readable ? > static inline mode_t mode_native_to_git(mode_t native_mode) > { > int perm_bits = native_mode & 0; > if (S_ISREG(native_mode)) > return 010 | perm

Re: [PATCH] compat: convert modes to use portable file type values

2014-11-30 Thread Junio C Hamano
David Michael writes: > This is my most recent attempt at solving the problem of z/OS using > different file type values than every other OS. I believe it should be > safe as long as the file type bits don't ever need to be converted back > to their native values (and I didn't see any instances

Re: [PATCH] compat: convert modes to use portable file type values

2014-11-30 Thread Torsten Bögershausen
On 2014-11-30 03.41, David Michael wrote: Some minor comments: > +static inline mode_t mode_native_to_git(mode_t native_mode) > +{ > + if (S_ISREG(native_mode)) > + return 010 | (native_mode & 0); > + else if (S_ISDIR(native_mode)) > + return 004 | (nativ

[PATCH] compat: convert modes to use portable file type values

2014-11-29 Thread David Michael
This adds simple wrapper functions around calls to stat(), fstat(), and lstat() that translate the operating system's native file type bits to those used by most operating systems. It also rewrites the S_IF* macros to the common values, so all file type processing is performed using the translated