Re: [PATCH v2] Allow git mv FileA fILEa on case ignore file systems
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Mar 19, 2011, 18:20 UTC
- Message-ID
- <AANLkTimfk8bb-V8Br+KKpoLbA3G3y9HxyfjA=NrsgR0v@mail.gmail.com>
- In-Reply-To
- <201103191528.34646.tboegi@web.de>
2011/3/19 Torsten Bögershausen <tboegi@web.de>:
Show 10 quoted lines
> diff --git a/compat/win32/same-file.c b/compat/win32/same-file.c > new file mode 100644 > index 0000000..bb1a791 > --- /dev/null > +++ b/compat/win32/same-file.c > @@ -0,0 +1,26 @@ > +#include "../../git-compat-util.h" > +#include "../win32.h" > + > +int win_is_same_file(const char *a, const char *b)
The compat/win32-folder is usually used to provide implementations of POSIX APIs lacking on Windows. I don't think this is appropriate functionality to be put there...
Show 10 quoted lines
> +{
> + BY_HANDLE_FILE_INFORMATION hia, hib;
> + HANDLE h;
> +
> + h = CreateFile(a, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
> + if (INVALID_HANDLE_VALUE == h)
> + return 0;
> + if (!(GetFileInformationByHandle(h,&hia)))
> + return 0;
> + CloseHandle(h);Indentation-slip?
Show 8 quoted lines
> + > + h = CreateFile(b, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); > + if (INVALID_HANDLE_VALUE == h) > + return 0; > + if (!(GetFileInformationByHandle(h,&hib))) > + return 0; > + CloseHandle(h); > +
Same as above...?
Show 14 quoted lines
> +#if defined (WIN32) || defined(__CYGWIN__)
> +/* MinGW or MSVC or cygwin */
> +int win_is_same_file(const char *a, const char *b);
> +#define is_same_file(a,b) win_is_same_file((a),(b))
> +#else
> +static inline int is_same_file(const char *a, const char *b)
> +{
> + struct stat sta, stb;
> + if (lstat(a, &sta) ||
> + lstat(b, &stb))
> + return 0;
> + return sta.st_ino && sta.st_dev == stb.st_dev && sta.st_ino == stb.st_ino;
> +}
> +#endifThis isn't how we usually do things like this. We usually define stuff in compat/mingw.h (which should really be called compat/win32.h instead, since it's used by our MSVC builds as well. But that's a different discussion), and check if it's defined near the bottom of git-compat-util.h.