Skip to content

Commit 8337259

Browse files
committed
Codestyle churn
Some mostly useless codestyle churn but that happens to reduce the diff towards the version before checkstyle fixes while remaining compliant. * Back to `test` instead of [ ] because I like it * Consistent function "signature" lines
1 parent 56fbec1 commit 8337259

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

git-fixup

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ grok_diff='/^--- .*/p ;
3232
# Produce suggestion of commits by finding the sections of files with changes
3333
# staged (U1 to diff is used to give some context for when adding items to
3434
# lists etc) and looking up the previous commits touching those sections.
35-
function fixup_candidates_lines () {
35+
fixup_candidates_lines () {
3636
git diff --cached -U1 --no-prefix | sed -n "$grok_diff" | (
3737
file=''
3838
while read -r offs len ; do
39-
if [ "$offs" = '---' ] ; then
39+
if test "$offs" = '---'; then
4040
file="$len"
4141
else
42-
if [ "$len" != '0' ] ; then
43-
if [ "$file" != '/dev/null' ] ; then
42+
if test "$len" != '0'; then
43+
if test "$file" != '/dev/null' ; then
4444
git blame -sl -L "$offs,+$len" "$rev_range" -- "$file"
4545
fi
4646
fi
@@ -51,7 +51,7 @@ function fixup_candidates_lines () {
5151

5252
# Produce suggestion of commits by taking the latest commit to each file with
5353
# staged changes
54-
function fixup_candidates_files () {
54+
fixup_candidates_files () {
5555
git diff --cached --name-only | (
5656
while read -r file; do
5757
git rev-list -n 1 -E --invert-grep --grep='^(fixup|squash)' "$rev_range" -- "$file"
@@ -60,24 +60,24 @@ function fixup_candidates_files () {
6060
}
6161

6262
# Produce suggestion of all commits in $rev_range
63-
function fixup_candidates_all_commits () {
63+
fixup_candidates_all_commits () {
6464
git rev-list "$rev_range" | sed 's/^/F /g'
6565
}
6666

6767
# Pretty print details of a commit
68-
function print_sha () {
68+
print_sha () {
6969
local sha=$1
7070
local type=$2
7171

7272
git --no-pager log --format="%H [$type] %s <%ae>" -n 1 "$sha"
7373
}
7474

7575
# Call git commit
76-
function call_commit() {
76+
call_commit () {
7777
local flag=$op
7878
local target=$1
7979

80-
if [ "$op" = "amend" ] ; then
80+
if test "$op" = "amend"; then
8181
flag=fixup
8282
target="amend:$target"
8383
fi
@@ -87,43 +87,43 @@ function call_commit() {
8787
}
8888

8989
# Call git rebase
90-
function call_rebase() {
90+
call_rebase () {
9191
local target=$1
9292

9393
# If our target-commit has a parent, we call a rebase with that
9494
# shellcheck disable=SC1083
95-
if git rev-parse --quiet --verify "$target"~1^{commit} ; then
95+
if git rev-parse --quiet --verify "$target"~1^{commit}; then
9696
git rebase --interactive --autosquash "$target~1"
9797
# If our target-commit exists but has no parents, it must be the very first commit
9898
# the repo. We simply call a rebase with --root
99-
elif git rev-parse --quiet --verify "$target"^{commit} ; then
99+
elif git rev-parse --quiet --verify "$target"^{commit}; then
100100
git rebase --interactive --autosquash --root
101101
fi
102102
}
103103

104104
# Print list of fixup/squash candidates
105-
function print_candidates() {
105+
print_candidates () {
106106
(
107-
if [ "$show_all" = "false" ] ; then
107+
if [ "$show_all" = "false" ]; then
108108
fixup_candidates_lines
109109
fixup_candidates_files
110110
else
111111
fixup_candidates_all_commits
112112
fi
113-
) | sort -uk2 | while read -r type sha; do
114-
if [ -n "$sha" ] ; then
113+
) | sort -uk2 | while read -r type sha; do
114+
if test -n "$sha"; then
115115
print_sha "$sha" "$type"
116116
fi
117117
done
118118
}
119119

120-
function fallback_menu() {
120+
fallback_menu () {
121121
(
122122
IFS=$'\n'
123123
read -d '' -ra options
124124
PS3="Which commit should I $op? "
125125
select line in "${options[@]}"; do
126-
if [ -z "$line" ] ; then
126+
if test -z "$line"; then
127127
declare -a args=("$REPLY")
128128
case ${args[0]} in
129129
quit|q)
@@ -132,7 +132,7 @@ function fallback_menu() {
132132
;;
133133
show|s)
134134
idx=$((args[1] - 1))
135-
if [ "$idx" -ge 0 ] ; then
135+
if test "$idx" -ge 0; then
136136
git show "${options[$idx]%% *}" >&2
137137
fi
138138
;;
@@ -157,7 +157,7 @@ function fallback_menu() {
157157
}
158158

159159
show_menu () {
160-
if [ -n "$fixup_menu" ] ; then
160+
if test -n "$fixup_menu"; then
161161
eval command "$fixup_menu"
162162
else
163163
fallback_menu
@@ -173,7 +173,7 @@ create_commit=${GITFIXUPCOMMIT:-$(git config --default=false --type bool fixup.c
173173
base=${GITFIXUPBASE:-$(git config --default="" fixup.base)}
174174
show_all=false
175175

176-
while [ $# -gt 0 ] ; do
176+
while test $# -gt 0; do
177177
case "$1" in
178178
-s|--squash)
179179
op="squash"
@@ -201,7 +201,7 @@ while [ $# -gt 0 ] ; do
201201
;;
202202
-b|--base)
203203
shift
204-
if [ $# -eq 0 ] ; then
204+
if [ $# -eq 0 ]; then
205205
die "--base requires an argument"
206206
fi
207207
base="$1"
@@ -218,58 +218,58 @@ while [ $# -gt 0 ] ; do
218218
done
219219

220220
target="$1"
221-
if [ $# -gt 1 ] ; then
221+
if test $# -gt 1; then
222222
die "Pass only one ref, please"
223223
fi
224224

225-
if [ -n "$target" ] ; then
225+
if test -n "$target"; then
226226
call_commit "$target"
227-
if [ "$rebase" = "true" ] ; then
227+
if test "$rebase" = "true"; then
228228
call_rebase "$target"
229229
fi
230230
exit
231231
fi
232232

233-
if git diff --cached --quiet ; then
233+
if git diff --cached --quiet; then
234234
die 'No staged changes. Use git add -p to add them.'
235235
fi
236236

237237
cd_to_toplevel
238238

239-
if [ "$base" = "closest" ] ; then
239+
if test "$base" = "closest"; then
240240
base=$(git for-each-ref \
241241
--merged HEAD~1 \
242242
--sort=-committerdate \
243-
refs/heads/ \
244243
--count 1 \
245244
--format='%(objectname)' \
245+
refs/heads/ \
246246
)
247-
if [ -z "$base" ] ; then
247+
if test -z "$base"; then
248248
die "Could not find the ancestor branch"
249249
fi
250250
fi
251251

252-
if [ -z "$base" ] ; then
252+
if test -z "$base"; then
253253
upstream=$(git rev-parse "@{upstream}" 2>/dev/null)
254254
head=$(git rev-parse HEAD 2>/dev/null)
255-
if [ -n "$upstream" ] && [ "$upstream" != "$head" ] ; then
255+
if test -n "$upstream" && test "$upstream" != "$head"; then
256256
base="$upstream"
257257
fi
258258
fi
259259

260-
if [ -n "$base" ] ; then
260+
if test -n "$base"; then
261261
rev_range="$base..HEAD"
262262
else
263263
rev_range="HEAD"
264264
fi
265265

266-
if [ "$create_commit" = "true" ] ; then
266+
if test "$create_commit" = "true"; then
267267
target=$(print_candidates | show_menu)
268-
if [ -z "$target" ] ; then
268+
if test -z "$target"; then
269269
exit
270270
fi
271271
call_commit "${target%% *}"
272-
if [ "$rebase" = "true" ] ; then
272+
if test "$rebase" = "true"; then
273273
call_rebase "${target%% *}"
274274
fi
275275
else

0 commit comments

Comments
 (0)