git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
David Michael <fedora.dm0@gmail.com>
Date
Dec 1, 2014, 03:40 UTC
Message-ID
<CAEvUa7=R7Bm7e=HCuw7QnMPwhunjJ4LUYv4LzMHMugh-iUkt8A@mail.gmail.com>
In-Reply-To
<547B7B27.90204@web.de>

On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen <tboegi@web.de> wrote: [snip]

Show 20 quoted lines
> Could the code be more human-readable ?
> static inline mode_t mode_native_to_git(mode_t native_mode)
> {
>         int perm_bits = native_mode & 07777;
>         if (S_ISREG(native_mode))
>                 return 0100000 | perm_bits;
>         if (S_ISDIR(native_mode))
>                 return 0040000 | perm_bits;
>         if (S_ISLNK(native_mode))
>                 return 0120000 | perm_bits;
>         if (S_ISBLK(native_mode))
>                 return 0060000 | perm_bits;
>         if (S_ISCHR(native_mode))
>                 return 0020000 | perm_bits;
>         if (S_ISFIFO(native_mode))
>                 return 0010000 | perm_bits;
>         /* Non-standard type bits were given. */
>         /* Shouldn't we die() here ?? */
>                 return perm_bits;
> }
Sure, I can send an updated patch with the new variable and without the "else"s.

Regarding the question in the last comment: I was assuming if this case was ever reached, Git would handle the returned mode the same way as if it encountered an unknown/non-standard file type on a normal operating system, which could die() if needed in the function that called stat().

Should I send an updated patch that die()s there?
David
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 3 of 12 in “compat: convert modes to use portable file type values”
  1. compat: convert modes to use portable file type valuesDavid Michael, Nov 30, 2014
  2. Torsten BögershausenNov 30, 2014
  3. David MichaelDec 1, 2014
  4. Torsten BögershausenDec 1, 2014
  5. David MichaelDec 1, 2014
  6. David MichaelDec 1, 2014
  7. Junio C HamanoDec 1, 2014
  8. Duy NguyenDec 1, 2014
  9. David MichaelDec 1, 2014
  10. Junio C HamanoDec 1, 2014
  11. David MichaelDec 1, 2014
  12. Junio C HamanoDec 1, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.