diff mbox

[core] create-pull-request: Improved the error-handling

Message ID 1399974699-6454-1-git-send-email-Svend.Vedstesen@prevas.dk
State Accepted
Delegated to: Esben Haabendal
Headers show

Commit Message

Svend Aage Vedstesen May 13, 2014, 9:51 a.m. UTC
The error handling is improved to warn the user about errors
in "git format-patch" and in case the user supplied a changeset
without any diffs.
---
 scripts/create-pull-request | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Esben Haabendal May 13, 2014, 12:45 p.m. UTC | #1
Merged to master, thanks.

/Esben
diff mbox

Patch

diff --git a/scripts/create-pull-request b/scripts/create-pull-request
index 8759715..8e82a11 100755
--- a/scripts/create-pull-request
+++ b/scripts/create-pull-request
@@ -178,7 +178,16 @@  mkdir $ODIR
 
 # Generate the patches and cover letter
 git format-patch -M40 --subject-prefix="$PREFIX" -n -o $ODIR --thread=shallow --cover-letter $RELATIVE_TO..$COMMIT_ID > /dev/null
+if [ $? -ne 0 ]; then
+	echo "ERROR: git format-patch reported an error"
+	exit 1
+fi
 
+# Check if for some reason the ODIR is empty (could be the case if there are no diffs)
+if [ "$(ls -A $ODIR)" ==  ""  ]; then
+    echo "ERROR: Empty patch was generated - please check diffs between \"$RELATIVE_TO\" and \"$COMMIT_ID\""
+    exit 1
+fi
 
 # Customize the cover letter
 CL="$ODIR/0000-cover-letter.patch"