summaryrefslogtreecommitdiff
path: root/compat/mingw.c
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder@ira.uka.de>2010-07-12 23:42:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-13 00:34:46 (GMT)
commitded2d47668c8e865465a7ad69665696f9b56f24b (patch)
tree5afefec6bafa9941d0186a57d1cc0087baada22e /compat/mingw.c
parenta1463920565c67646507dc573d3f5280fa4cdcf3 (diff)
downloadgit-ded2d47668c8e865465a7ad69665696f9b56f24b.zip
git-ded2d47668c8e865465a7ad69665696f9b56f24b.tar.gz
git-ded2d47668c8e865465a7ad69665696f9b56f24b.tar.bz2
mingw_utime(): handle NULL times parameter
POSIX sayeth: "If times is a null pointer, the access and modification times of the file shall be set to the current time." Let's do so. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/mingw.c')
-rw-r--r--compat/mingw.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 9a8e336..24333cb 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -304,8 +304,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
goto revert_attrs;
}
- time_t_to_filetime(times->modtime, &mft);
- time_t_to_filetime(times->actime, &aft);
+ if (times) {
+ time_t_to_filetime(times->modtime, &mft);
+ time_t_to_filetime(times->actime, &aft);
+ } else {
+ GetSystemTimeAsFileTime(&mft);
+ aft = mft;
+ }
if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) {
errno = EINVAL;
rc = -1;