On Wed, Feb 19, 2014 at 5:08 PM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > On Tue, Feb 18, 2014 at 8:40 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> 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 (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 */ > >> + return buf.st_dev; Or, if doing this in do_lstat() is too expensive for normal stat() operations (which is likely), then a simple #ifdef might be easier to read; or abstract it into a get_device() function which Windows/MinGW can override, doing buf.st_dev = toupper(real_path(...)), thus also making the code easier to understand. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html