[GUILT v3 17/31] "guilt graph" no longer loops when no patches are applied.
- From
Per Cederqvist <cederp@opera.com>
- Date
- May 16, 2014, 14:46 UTC
- Message-ID
- <1400251578-17221-18-git-send-email-cederp@opera.com>
- In-Reply-To
- <1400251578-17221-1-git-send-email-cederp@opera.com>
Give an error message if no patches are applied. Added a test case that never terminates unless this fix is applied.
Signed-off-by: Per Cederqvist <cederp@opera.com> Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net> --- guilt-graph | 9 +++++++-- regression/t-033.out | 3 +++ regression/t-033.sh | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 regression/t-033.out create mode 100755 regression/t-033.sh
diff --git a/guilt-graph b/guilt-graph index b3469dc..56d0e77 100755 --- a/guilt-graph +++ b/guilt-graph @@ -17,8 +17,13 @@ fi patchname="$1" -bottom=`git rev-parse refs/patches/$branch/$(head_n 1 < "$applied")` -base=`git rev-parse $bottom^` +bottompatch=$(head_n 1 < "$applied") +if [ -z "$bottompatch" ]; then + echo "No patch applied." >&2 + exit 1 +fi + +base=`git rev-parse "refs/patches/${branch}/${bottompatch}^"` if [ -z "$patchname" ]; then top=`git rev-parse HEAD` diff --git a/regression/t-033.out b/regression/t-033.out new file mode 100644 index 0000000..76613f9 --- /dev/null +++ b/regression/t-033.out @@ -0,0 +1,3 @@ +% setup_repo +% guilt graph +No patch applied. diff --git a/regression/t-033.sh b/regression/t-033.sh new file mode 100755 index 0000000..a3a8981 --- /dev/null +++ b/regression/t-033.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Test the graph code +# + +source "$REG_DIR/scaffold" + +cmd setup_repo + +# Check that "guilt graph" gives a proper "No patch applied" error +# message when no patches are applied. (An older version of guilt +# used to enter an endless loop in this situation.) +shouldfail guilt graph
-- 1.8.3.1