aboutsummaryrefslogtreecommitdiffstats
path: root/wrapper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-02-06 22:05:22 -0800
committerJunio C Hamano <gitster@pobox.com>2019-02-06 22:05:22 -0800
commit09a9c1f427c110f1281eea55c48596c8c8701a13 (patch)
tree06c8f6685e4ca005aa2367d9b4ae95368d2eb170 /wrapper.c
parent0fa3cc77ee9fb3b6bb53c73688c9b7500f996b83 (diff)
parent06f5608c14e6972748b84649d5b8ffd335bbd209 (diff)
downloadgit-09a9c1f427c110f1281eea55c48596c8c8701a13.tar.gz
Merge branch 'tt/bisect-in-c'
More code in "git bisect" has been rewritten in C. * tt/bisect-in-c: bisect--helper: `bisect_start` shell function partially in C bisect--helper: `get_terms` & `bisect_terms` shell function in C bisect--helper: `bisect_next_check` shell function in C bisect--helper: `check_and_set_terms` shell function in C wrapper: move is_empty_file() and rename it as is_empty_or_missing_file() bisect--helper: `bisect_write` shell function in C bisect--helper: `bisect_reset` shell function in C
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/wrapper.c b/wrapper.c
index e4fa9d84cd..ea3cf64d4c 100644
--- 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;
+}