{"thread":{"id":"6967","subject":"[PATCH] Make \"guilt push\" match \"quilt push\" when the patch doesn't apply","startedAt":"2007-02-26T03:58:09Z","lastAt":"2007-02-26T03:58:09Z","messageCount":1,"participants":["Theodore Ts'o"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"35489","messageId":"E1HLX7O-0004bu-Qx@candygram.thunk.org","threadId":"6967","inReplyTo":null,"subject":"[PATCH] Make \"guilt push\" match \"quilt push\" when the patch doesn't apply","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2007-02-26T03:58:09Z","receivedAt":"2007-02-26T03:58:09Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"Sometimes the reason why the patch doesn't apply is because it has\nalready been applied in mainline when rebasing a patch series.  It is\ntherefore more convenient if \"guilt push\" leaves the working tree\nuntouched if the patch fails to apply unless explicitly asked to force\napply a failing patch using the -f option.\n\nThis behavior matches how \"quilt push\" and \"hg qpush\" works, so it\nalso avoids unpleasant surprises for developers used to other patch\nseries tools.\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\n---\n guilt      |   14 ++++++++++++--\n guilt-push |   16 +++++++++++++---\n 2 files changed, 25 insertions(+), 5 deletions(-)\n\ndiff --git a/guilt b/guilt\nindex 284f9fb..f5a55ff 100755\n--- a/guilt\n+++ b/guilt\n@@ -259,8 +259,10 @@ function push_patch\n {\n \tlocal p=\"$GUILT_DIR/$branch/$1\"\n \tlocal pname=\"$1\"\n+\tlocal bail_action=\"$2\"\n \n \tlocal bail=0\n+\tlocal reject=\"--reject\"\n \n \tassert_head_check\n \n@@ -268,11 +270,19 @@ function push_patch\n \n \t# apply the patch if and only if there is something to apply\n \tif [ `git-apply --numstat $p | wc -l` -gt 0 ]; then\n+\t\tif [ \"$bail_action\" = abort ]; then\n+\t\t    reject=\"\"\n+\t\tfi\n \t\tgit-apply -C$guilt_push_diff_context \\\n-\t\t\t--reject $p > /dev/null 2> /tmp/guilt.log.$$\n+\t\t\t$reject $p > /dev/null 2> /tmp/guilt.log.$$\n \t\tbail=$?\n \n-\t\t[ $bail -ne 0 ] && cat /tmp/guilt.log.$$ >&2\n+\t\tif [ $bail -ne 0 ]; then\n+\t\t\tcat /tmp/guilt.log.$$ >&2\n+\t\t\tif [ \"$bail_action\" = abort ]; then\n+\t\t\t\treturn $bail\n+\t\t\tfi\n+\t\tfi\n \n \t\t# FIXME: Path munging is being done, we need to convince\n \t\t# git-apply to just give us list of files with \\0 as a\ndiff --git a/guilt-push b/guilt-push\nindex 4fb89e2..85b4122 100755\n--- a/guilt-push\n+++ b/guilt-push\n@@ -5,7 +5,14 @@\n \n source \"`dirname $0`/guilt\"\n \n-USAGE=\"$USAGE [-a | --all | <patchname>]\"\n+abort_flag=\"abort\"\n+\n+USAGE=\"$USAGE [ -f ] [-a | --all | <patchname>]\"\n+\n+if [ \"$1\" == \"-f\" ]; then\n+\tabort_flag=\"\"\n+\tshift\n+fi\n \n if [ $# -gt 1 ]; then\n \tprint_usage\n@@ -61,14 +68,17 @@ for p in `get_series`; do\n \t\texit 1\n \tfi\n \n-\tpush_patch $p\n+\tpush_patch $p $abort_flag\n \n \t# bail if necessary\n \tif [ $? -eq 0 ]; then\n \t\techo \"Patch applied.\"\n-\telse\n+\telif [ -z \"$abort_flag\" ]; then\n \t\techo \"Patch applied with rejects. Fix it up, and refresh.\" >&2\n \t\texit 1\n+\telse\n+\t\techo \"To force apply this patch, use 'guilt push -f'\" >&2\n+\t\texit 1\n \tfi\n done\n \n-- \n1.5.0.1.74.g2470\n"}]}