From 09311b858f38ce6c863d0140499cd8021190863c Mon Sep 17 00:00:00 2001 From: Clark Wang Date: Fri, 18 Dec 2020 14:45:34 +0800 Subject: [PATCH] macOS's stat does not support `-c %s', use `-f %z' instead --- guilt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/guilt b/guilt index bf50343..070130d 100755 --- a/guilt +++ b/guilt @@ -722,6 +722,14 @@ must_commit_first() return $? } +stat_file_size() +{ + case `uname -s` in + Darwin) stat -f %z "$1";; + *) stat -c %s "$1";; + esac +} + # usage: fold_patch patchname fold_patch() { @@ -742,7 +750,7 @@ fold_patch() do_get_full_header "$pnext" > "$TMP_NEXT" do_get_patch "$pcur" > "$TMP_DIFF" - case "`stat -c %s \"$TMP_CUR\"`,`stat -c %s \"$TMP_NEXT\"`" in + case "`stat_file_size \"$TMP_CUR\"`,`stat_file_size \"$TMP_NEXT\"`" in *,0) # since the new patch header is empty, we # don't have to do anything