Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
git-am: refactor 'cleaning up and aborting'
author
Giuseppe Bilotta
<giuseppe.bilotta@gmail.com>
Wed, 27 May 2009 09:25:19 +0000
(11:25 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 14 Jun 2009 00:30:38 +0000
(17:30 -0700)
Introduce a clean_abort function that echoes an optional error message
to standard error, removes the dotest directory and exits with status 1.
Use it when patch format detection or patch splitting fails early.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-am.sh
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
c574e68
)
diff --git
a/git-am.sh
b/git-am.sh
index 0ff1f577a33ccc96adfbb14fa35adfeee9e309f5..327807ddcb5fbe3d08c459887c472ed564210570 100755
(executable)
--- a/
git-am.sh
+++ b/
git-am.sh
@@
-134,6
+134,12
@@
It does not apply to blobs recorded in its index."
unset GITHEAD_$his_tree
}
unset GITHEAD_$his_tree
}
+clean_abort () {
+ test $# = 0 || echo >&2 "$@"
+ rm -fr "$dotest"
+ exit 1
+}
+
patch_format=
check_patch_format () {
patch_format=
check_patch_format () {
@@
-180,22
+186,19
@@
check_patch_format () {
esac
;;
esac
esac
;;
esac
- } < "$1"
+ } < "$1"
|| clean_abort
}
split_patches () {
case "$patch_format" in
mbox)
}
split_patches () {
case "$patch_format" in
mbox)
- git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
- rm -fr "$dotest"
- exit 1
- }
+ git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||
+ clean_abort
;;
stgit-series)
if test $# -ne 1
then
;;
stgit-series)
if test $# -ne 1
then
- echo "Only one StGIT patch series can be applied at once"
- exit 1
+ clean_abort "Only one StGIT patch series can be applied at once"
fi
series_dir=`dirname "$1"`
series_file="$1"
fi
series_dir=`dirname "$1"`
series_file="$1"
@@
-210,7
+213,7
@@
split_patches () {
shift
# remove the arg coming from the first-line comment
shift
shift
# remove the arg coming from the first-line comment
shift
- } < "$series_file"
+ } < "$series_file"
|| clean_abort
# set the patch format appropriately
patch_format=stgit
# now handle the actual StGIT patches
# set the patch format appropriately
patch_format=stgit
# now handle the actual StGIT patches
@@
-239,18
+242,14
@@
split_patches () {
print "Subject: ", $_ ;
$subject = 1;
}
print "Subject: ", $_ ;
$subject = 1;
}
- ' < "$stgit" > "$dotest/$msgnum" || {
- echo "Failed to import $patch_format patch $stgit"
- exit 1
- }
+ ' < "$stgit" > "$dotest/$msgnum" || clean_abort
done
echo "$this" > "$dotest/last"
this=
msgnum=
;;
*)
done
echo "$this" > "$dotest/last"
this=
msgnum=
;;
*)
- echo "Patch format $patch_format is not supported."
- exit 1
+ clean_abort "Patch format $patch_format is not supported."
;;
esac
}
;;
esac
}