]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wrapper.c
Revert "t5562: replace /dev/zero with a pipe from generate_zero_bytes"
[thirdparty/git.git] / wrapper.c
index 1fd5e33ea8f5c8cb4e6720b0bec74acf09232e3c..ea3cf64d4c399ae84c156b850002459a8ffde72c 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -643,9 +643,9 @@ int xsnprintf(char *dst, size_t max, const char *fmt, ...)
        va_end(ap);
 
        if (len < 0)
-               die("BUG: your snprintf is broken");
+               BUG("your snprintf is broken");
        if (len >= max)
-               die("BUG: attempt to snprintf into too-small buffer");
+               BUG("attempt to snprintf into too-small buffer");
        return len;
 }
 
@@ -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;
+}