All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: David Michael <fedora.dm0@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] compat: convert modes to use portable file type values
Date: Sun, 30 Nov 2014 19:11:39 -0800	[thread overview]
Message-ID: <xmqq8uisrrmc.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <87vblxl8ah.fsf@gmail.com> (David Michael's message of "Sat, 29 Nov 2014 21:41:10 -0500")

David Michael <fedora.dm0@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 see any instances of that).
>
> I've been testing it by making commits to the same repositories on
> different operating systems and pushing those changes around, and so far
> there have been no issues.
>
> Can anyone foresee any problems with this method?

I cannot offhand comment on the last question above, but the
reliance on exact S_IFxxx bit assignment was identified as a
potential problem from very early days of Git that we have known
about but didn't have need to address on any system that mattered.

This is a long overdue issue and I am happy to see it getting
tackled.  The patch seems to be a sensible implementation of your
design decision to use the one-way conversion.

> diff --git a/compat/stat.c b/compat/stat.c
> new file mode 100644
> index 0000000..0ff1f2f
> --- /dev/null
> +++ b/compat/stat.c
> @@ -0,0 +1,49 @@
> +#define _POSIX_SOURCE
> +#include <stddef.h>    /* NULL         */
> +#include <sys/stat.h>  /* *stat, S_IS* */
> +#include <sys/types.h> /* mode_t       */
> +
> +static inline mode_t mode_native_to_git(mode_t native_mode)
> +{
> +	if (S_ISREG(native_mode))
> +		return 0100000 | (native_mode & 07777);
> +	else if (S_ISDIR(native_mode))
> +		return 0040000 | (native_mode & 07777);
> +	else if (S_ISLNK(native_mode))
> +		return 0120000 | (native_mode & 07777);
> +	else if (S_ISBLK(native_mode))
> +		return 0060000 | (native_mode & 07777);
> +	else if (S_ISCHR(native_mode))
> +		return 0020000 | (native_mode & 07777);
> +	else if (S_ISFIFO(native_mode))
> +		return 0010000 | (native_mode & 07777);
> +	else /* Non-standard type bits were given. */
> +		return native_mode & 07777;
> +}

  parent reply	other threads:[~2014-12-01  3:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-30  2:41 [PATCH] compat: convert modes to use portable file type values David Michael
2014-11-30 20:16 ` Torsten Bögershausen
2014-12-01  3:40   ` David Michael
2014-12-01  5:55     ` Torsten Bögershausen
2014-12-01 12:48       ` David Michael
2014-12-01 17:46         ` David Michael
2014-12-01  3:11 ` Junio C Hamano [this message]
2014-12-01 14:44 ` Duy Nguyen
2014-12-01 17:49   ` David Michael
2014-12-01 17:57     ` Junio C Hamano
2014-12-01 19:10       ` David Michael
2014-12-01 20:09         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8uisrrmc.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=fedora.dm0@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.