Re: [PATCH v3 24/25] prune: strategies for linked checkouts
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 20, 2014, 13:19 UTC
- Message-ID
- <CACsJy8Bxp2sfP0M6htwNg-LP1CcFMpZbhE=sgR6xXJkj-5shcw@mail.gmail.com>
- In-Reply-To
- <CAPig+cQgphSBA6iAYqLJ7RnEwSzBA1dApcLWAydZEXarQRcTKQ@mail.gmail.com>
On Thu, Feb 20, 2014 at 5:08 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 18 quoted lines
>> +static dev_t get_device_or_die(const char *path)
>> +{
>> + struct stat buf;
>> + if (stat(path, &buf))
>> + die_errno("failed to stat '%s'", path);
>> + /* Ah Windows! Make different drives different "partitions" */
>> + if (buf.st_dev == 0 && has_dos_drive_prefix("c:\\"))
>> + buf.st_dev = toupper(real_path(path)[0]);
>
> This invocation of has_dos_drive_prefix() with hardcoded "c:\\" at
> first looks like an error until the reader realizes that it's an
> #ifdef-less check if the platforms is Windows. Would it make more
> sense to encapsulate this anomaly and abstract it away by fixing
> compat/mingw.c:do_lstat() to instead set 'st_dev' automatically like
> you do here? In particular, this line in mingw.c:
>
> buf->st_dev = buf->st_rdev = 0; /* not used by Git */
>I don't want to hide too much magic behind compat curtain, especially when these magic is just about 90% as real, the rest is mysterious corner cases. I guess we could just add an inline function is_windows() that always returns 0 or 1 based on #ifdef.
-- Duy