--- oslo-series-v2/v2-0012-guilt-header-more-robust-header-selection.patch +++ oslo-series-v3/v3-0012-guilt-header-more-robust-header-selection.patch @@ -1,7 +1,7 @@ -From 26406f63cfcb080e49dcb8df6c8f00ecc5cb16ba Mon Sep 17 00:00:00 2001 +From 6c0d77de544d182d58ec2c092791cd9e9620f143 Mon Sep 17 00:00:00 2001 From: Per Cederqvist -Date: Tue, 13 May 2014 21:03:50 +0200 -Subject: [GUILT v2 12/29] "guilt header": more robust header selection. +Date: Fri, 16 May 2014 11:53:25 +0200 +Subject: [GUILT v3 12/31] "guilt header": more robust header selection. To: Jeff Sipek Cc: git@vger.kernel.org @@ -21,6 +21,6 @@ Signed-off-by: Per Cederqvist --- - guilt-header | 28 +++++++++++++++++++++++++--- - 1 file changed, 25 insertions(+), 3 deletions(-) + guilt-header | 29 ++++++++++++++++++++++++++--- + 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/guilt-header b/guilt-header index 41e00cc..4701b31 100755 --- a/guilt-header +++ b/guilt-header - @@ -45,10 +45,32 @@ esac + @@ -45,10 +45,33 @@ esac [ -z "$patch" ] && die "No patches applied." # check that patch exists in the series -ret=`get_full_series | grep -e "^$patch\$" | wc -l` -if [ $ret -eq 0 ]; then - die "Patch $patch is not in the series" - +full_series=`get_tmp_file series` - +get_full_series > "$full_series" + +TMP_FULL_SERIES=`get_tmp_file series` + +get_full_series > "$TMP_FULL_SERIES" +found_patch= +while read x; do + if [ "$x" = "$patch" ]; then + found_patch="$patch" + break + fi - +done < "$full_series" + +done < "$TMP_FULL_SERIES" +if [ -z "$found_patch" ]; then + TMP_MATCHES=`get_tmp_file series` - + grep "$patch" < "$full_series" > "$TMP_MATCHES" + + grep "$patch" < "$TMP_FULL_SERIES" > "$TMP_MATCHES" + nr=`wc -l < $TMP_MATCHES` + if [ $nr -gt 1 ]; then + echo "$patch does not uniquely identify a patch. Did you mean any of these?" >&2 + sed 's/^/ /' "$TMP_MATCHES" >&2 - + rm -f "$TMP_MATCHES" + + rm -f "$TMP_MATCHES" "$TMP_FULL_SERIES" + exit 1 + elif [ $nr -eq 0 ]; then - + rm -f "$TMP_MATCHES" + + rm -f "$TMP_MATCHES" "$TMP_FULL_SERIES" + die "Patch $patch is not in the series" + fi + found_patch=`cat $TMP_MATCHES` + rm -f "$TMP_MATCHES" fi + +rm -f "$TMP_FULL_SERIES" +patch="$found_patch" # FIXME: warn if we're editing an applied patch --