]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wrapper.c
p4 unshelve: fix "Not a valid object name HEAD0" on Windows
[thirdparty/git.git] / wrapper.c
index e4fa9d84cd076770306114ff4f284155a5cdd2a1..ea3cf64d4c399ae84c156b850002459a8ffde72c 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -690,3 +690,16 @@ int xgethostname(char *buf, size_t len)
                buf[len - 1] = 0;
        return ret;
 }
+
+int is_empty_or_missing_file(const char *filename)
+{
+       struct stat st;
+
+       if (stat(filename, &st) < 0) {
+               if (errno == ENOENT)
+                       return 1;
+               die_errno(_("could not stat %s"), filename);
+       }
+
+       return !st.st_size;
+}