fix: work around trailing newlines in headers
ugh
This commit is contained in:
parent
4c668b6c04
commit
aeae707886
1 changed files with 6 additions and 2 deletions
8
apatch
8
apatch
|
@ -67,7 +67,8 @@ if [ -f "$patchpath" ]; then
|
|||
msg "patch exists, trying to extract existing message"
|
||||
# try to extract the original header from the patch
|
||||
patch_start=$(grep -En '^(diff --git|--- )' "$patchpath" | cut -d: -f1 | head -n 1)
|
||||
header="$(head -n $(( patch_start - 1 )) "$patchpath"; echo)"
|
||||
header_file="$(mktemp -t apatch.XXXXXX)"
|
||||
head -n $(( patch_start - 1 )) "$patchpath" > "$header_file"
|
||||
fi
|
||||
|
||||
(
|
||||
|
@ -103,7 +104,10 @@ fi
|
|||
git add .
|
||||
|
||||
msg "saving patch $1"
|
||||
echo -n "$header" > "$patchpath"
|
||||
echo -n > "$patchpath" # empty the file first
|
||||
if [ -n "$header_file" ]; then
|
||||
mv "$header_file" "$patchpath"
|
||||
fi
|
||||
git diff --cached >> "$patchpath"
|
||||
|
||||
if [ ! -s "$patchpath" ]; then
|
||||
|
|
Loading…
Reference in a new issue