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 tbo...@web.de wrote: On 12/01/2014 04:40 AM, David Michael wrote: On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen tbo...@web.de wrote: [snip] Could the code be more human-readable ? static inline mode_t mode_native_to_git(mode_t

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 fedora@gmail.com 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

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 fedora@gmail.com wrote: On Mon, Dec 1, 2014 at 12:55 AM, Torsten Bögershausen tbo...@web.de wrote: On 12/01/2014 04:40 AM, David Michael wrote: On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen tbo...@web.de wrote: [snip] Could the code

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 pclo...@gmail.com wrote: On Sun, Nov 30, 2014 at 9:41 AM, David Michael fedora@gmail.com 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

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

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

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 gits...@pobox.com wrote: David Michael fedora@gmail.com writes: On Mon, Dec 1, 2014 at 9:44 AM, Duy Nguyen pclo...@gmail.com wrote: On Sun, Nov 30, 2014 at 9:41 AM, David Michael fedora@gmail.com wrote: +int git_stat(const char *path,

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

2014-12-01 Thread Junio C Hamano
David Michael fedora@gmail.com 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

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 | (native_mode

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

2014-11-30 Thread Junio C Hamano
David Michael fedora@gmail.com 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

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 tbo...@web.de 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

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 tbo...@web.de 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