diff options
author | Jean Delvare <jdelvare@suse.de> | 2014-01-20 12:04:02 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2014-01-20 12:04:02 +0100 |
commit | c68e1c1e5c05dace9ec0274f8b8ae389bacf0f4e (patch) | |
tree | 2c30c1475e4802b9eadd6b765b39ff87b09105de | |
parent | 2709005d413030f5a0b888ba20b40ae134959e87 (diff) | |
download | quilt-c68e1c1e5c05dace9ec0274f8b8ae389bacf0f4e.tar.gz |
Swap negated if/else constructs
Constructs of the form:
if ! [ ... ]
then
...
else
...
fi
can be swapped to avoid the negation. It makes the code easier to read
and slightly faster to run.
-rw-r--r-- | quilt/new.in | 8 | ||||
-rw-r--r-- | quilt/scripts/patchfns.in | 26 |
2 files changed, 17 insertions, 17 deletions
diff --git a/quilt/new.in b/quilt/new.in index 92fe28a..2cc5297 100644 --- a/quilt/new.in +++ b/quilt/new.in @@ -102,13 +102,13 @@ create_db rm -rf "$QUILT_PC/$patch" mkdir -p "$QUILT_PC/$patch" -if ! insert_in_series $patch ${opt_strip_level:+-p$opt_strip_level} || \ - ! add_to_db $patch +if insert_in_series $patch ${opt_strip_level:+-p$opt_strip_level} && \ + add_to_db $patch then + printf $"Patch %s is now on top\n" "$(print_patch $patch)" +else printf $"Failed to create patch %s\n" "$(print_patch $patch)" >&2 exit 1 -else - printf $"Patch %s is now on top\n" "$(print_patch $patch)" fi ### Local Variables: ### mode: shell-script diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index f1b1dea..8ea9a24 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -199,11 +199,11 @@ patch_in_series() { local patch=$1 - if ! [ -e $SERIES ] + if [ -e $SERIES ] then - return 1 - else grep -q "^$(quote_bre $patch)\([ \t]\|$\)" $SERIES + else + return 1 fi } @@ -725,29 +725,29 @@ diff_file() fi index=$new_hdr - if ! [ -s "$old_file" ] + if [ -s "$old_file" ] then + [ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \ + || old_date=$'\t'$(date +'%Y-%m-%d %H:%M:%S.%N %z' \ + -r "$old_file") + else old_file=/dev/null old_hdr=/dev/null [ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \ || old_date=$'\t'"1970-01-01 00:00:00.000000000 +0000" - else - [ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \ - || old_date=$'\t'$(date +'%Y-%m-%d %H:%M:%S.%N %z' \ - -r "$old_file") fi - if ! [ -e "$new_file" ] + if [ -e "$new_file" ] then + [ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \ + || new_date=$'\t'$(date +'%Y-%m-%d %H:%M:%S.%N %z' \ + -r "$new_file") + else [ $opt_strip_level = 0 ] \ && old_hdr=$new_hdr new_file=/dev/null new_hdr=/dev/null [ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \ || new_date=$'\t'"1970-01-01 00:00:00.000000000 +0000" - else - [ -n "$QUILT_NO_DIFF_TIMESTAMPS" ] \ - || new_date=$'\t'$(date +'%Y-%m-%d %H:%M:%S.%N %z' \ - -r "$new_file") fi diff $QUILT_DIFF_OPTS \ |