Re: [PATCH v4 24/27] prune: strategies for linked checkouts
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 2, 2014, 00:01 UTC
- Message-ID
- <CACsJy8CbE0VH_2bAH3weokuHVMUor9es7bgT7rWFi28fJjZ36w@mail.gmail.com>
- In-Reply-To
- <5312151B.6080605@web.de>
On Sun, Mar 2, 2014 at 12:12 AM, Torsten Bögershausen <tboegi@web.de> wrote:
Show 14 quoted lines
> On 2014-03-01 13.13, Nguyễn Thái Ngọc Duy wrote:
> []
>>
>> +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 (is_windows())
>> + buf.st_dev = toupper(real_path(path)[0]);
>> + return buf.st_dev;
>
> Is this only related to Windows ?Yes. At least the treatment is Windows specific. If st_dev == 0 in other cases, then we have to deal with them case-by-case.
> Do we have other file systems, which return st_dev == 0 ? > Should we check that path[0] != '/', or better !is_dir_sep(path[0]) ? > Do we need has_dos_drive_prefix() ?
real_path() returns an absolute path, so we're guaranteed its first character is the drive letter, right? (I tried to confirm this by reading read_path_internal, but it's a bit complex, and I don't have Windows machine to quickly test it out)
Show 7 quoted lines
> > As a first suggestion, would this be better: > >> + if (!buf.st_dev) >> + buf.st_dev = toupper(real_path(path)[0]); > > (End of loose thinking)
-- Duy