subtree: adjust function definitions to match CodingGuidelines
We prefer a space between the function name and the parentheses, and no space inside the parentheses. The opening "{" should also be on the same line. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Aguilar committed
Jul 27, 2016 at 17:16 UTC
d7fd792e1b2cdf4c9584a224dead75ad716ae1d9
1 file changed
+34
-68
contrib/subtree/git-subtree.sh
+34
-68
@@ -49,32 +49,28 @@ squash=
49
message=
50
prefix=
51
52
-debug()
53
-{
52
+debug () {
53
if test -n "$debug"
54
then
55
printf "%s\n" "$*" >&2
56
fi
57
}
58
60
-say()
61
-{
59
+say () {
60
if test -z "$quiet"
61
then
62
printf "%s\n" "$*" >&2
63
fi
64
}
65
68
-progress()
69
-{
66
+progress () {
67
if test -z "$quiet"
68
then
69
printf "%s\r" "$*" >&2
70
fi
71
}
72
76
-assert()
77
-{
73
+assert () {
74
if ! "$@"
75
then
76
die "assertion failed: " "$@"
@@ -202,8 +198,7 @@ debug "dir: {$dir}"
198
debug "opts: {$*}"
199
debug
200
205
-cache_setup()
206
-{
201
+cache_setup () {
202
cachedir="$GIT_DIR/subtree-cache/$$"
203
rm -rf "$cachedir" ||
204
die "Can't delete old cachedir: $cachedir"
@@ -214,8 +209,7 @@ cache_setup()
209
debug "Using cachedir: $cachedir" >&2
210
}
211
217
-cache_get()
218
-{
212
+cache_get () {
213
for oldrev in "$@"
214
do
215
if test -r "$cachedir/$oldrev"
@@ -226,8 +220,7 @@ cache_get()
220
done
221
}
222
229
-cache_miss()
230
-{
223
+cache_miss () {
224
for oldrev in "$@"
225
do
226
if ! test -r "$cachedir/$oldrev"
@@ -237,8 +230,7 @@ cache_miss()
230
done
231
}
232
240
-check_parents()
241
-{
233
+check_parents () {
234
missed=$(cache_miss "$@")
235
for miss in $missed
236
do
@@ -249,13 +241,11 @@ check_parents()
241
done
242
}
243
252
-set_notree()
253
-{
244
+set_notree () {
245
echo "1" > "$cachedir/notree/$1"
246
}
247
257
-cache_set()
258
-{
248
+cache_set () {
249
oldrev="$1"
250
newrev="$2"
251
if test "$oldrev" != "latest_old" &&
@@ -267,8 +257,7 @@ cache_set()
257
echo "$newrev" >"$cachedir/$oldrev"
258
}
259
270
-rev_exists()
271
-{
260
+rev_exists () {
261
if git rev-parse "$1" >/dev/null 2>&1
262
then
263
return 0
@@ -277,8 +266,7 @@ rev_exists()
266
fi
267
}
268
280
-rev_is_descendant_of_branch()
281
-{
269
+rev_is_descendant_of_branch () {
270
newrev="$1"
271
branch="$2"
272
branch_hash=$(git rev-parse "$branch")
@@ -295,16 +283,14 @@ rev_is_descendant_of_branch()
283
# if a commit doesn't have a parent, this might not work. But we only want
284
# to remove the parent from the rev-list, and since it doesn't exist, it won't
285
# be there anyway, so do nothing in that case.
298
-try_remove_previous()
299
-{
286
+try_remove_previous () {
287
if rev_exists "$1^"
288
then
289
echo "^$1^"
290
fi
291
}
292
306
-find_latest_squash()
307
-{
293
+find_latest_squash () {
294
debug "Looking for latest squash ($dir)..."
295
dir="$1"
296
sq=
@@ -348,8 +334,7 @@ find_latest_squash()
334
done
335
}
336
351
-find_existing_splits()
352
-{
337
+find_existing_splits () {
338
debug "Looking for prior splits..."
339
dir="$1"
340
revs="$2"
@@ -393,8 +378,7 @@ find_existing_splits()
378
done
379
}
380
396
-copy_commit()
397
-{
381
+copy_commit () {
382
# We're going to set some environment vars here, so
383
# do it in a subshell to get rid of them safely later
384
debug copy_commit "{$1}" "{$2}" "{$3}"
@@ -420,8 +404,7 @@ copy_commit()
404
) || die "Can't copy commit $1"
405
}
406
423
-add_msg()
424
-{
407
+add_msg () {
408
dir="$1"
409
latest_old="$2"
410
latest_new="$3"
@@ -440,8 +423,7 @@ add_msg()
423
EOF
424
}
425
443
-add_squashed_msg()
444
-{
426
+add_squashed_msg () {
427
if test -n "$message"
428
then
429
echo "$message"
@@ -450,8 +432,7 @@ add_squashed_msg()
432
fi
433
}
434
453
-rejoin_msg()
454
-{
435
+rejoin_msg () {
436
dir="$1"
437
latest_old="$2"
438
latest_new="$3"
@@ -470,8 +451,7 @@ rejoin_msg()
451
EOF
452
}
453
473
-squash_msg()
474
-{
454
+squash_msg () {
455
dir="$1"
456
oldsub="$2"
457
newsub="$3"
@@ -493,14 +473,12 @@ squash_msg()
473
echo "git-subtree-split: $newsub"
474
}
475
496
-toptree_for_commit()
497
-{
476
+toptree_for_commit () {
477
commit="$1"
478
git log -1 --pretty=format:'%T' "$commit" -- || exit $?
479
}
480
502
-subtree_for_commit()
503
-{
481
+subtree_for_commit () {
482
commit="$1"
483
dir="$2"
484
git ls-tree "$commit" -- "$dir" |
@@ -514,8 +492,7 @@ subtree_for_commit()
492
done
493
}
494
517
-tree_changed()
518
-{
495
+tree_changed () {
496
tree=$1
497
shift
498
if test $# -ne 1
@@ -532,8 +509,7 @@ tree_changed()
509
fi
510
}
511
535
-new_squash_commit()
536
-{
512
+new_squash_commit () {
513
old="$1"
514
oldsub="$2"
515
newsub="$3"
@@ -548,8 +524,7 @@ new_squash_commit()
524
fi
525
}
526
551
-copy_or_skip()
552
-{
527
+copy_or_skip () {
528
rev="$1"
529
tree="$2"
530
newparents="$3"
@@ -607,8 +582,7 @@ copy_or_skip()
582
fi
583
}
584
610
-ensure_clean()
611
-{
585
+ensure_clean () {
586
if ! git diff-index HEAD --exit-code --quiet 2>&1
587
then
588
die "Working tree has modifications. Cannot add."
@@ -619,14 +593,12 @@ ensure_clean()
593
fi
594
}
595
622
-ensure_valid_ref_format()
623
-{
596
+ensure_valid_ref_format () {
597
git check-ref-format "refs/heads/$1" ||
598
die "'$1' does not look like a ref"
599
}
600
628
-cmd_add()
629
-{
601
+cmd_add () {
602
if test -e "$dir"
603
then
604
die "'$dir' already exists. Cannot add."
@@ -657,8 +629,7 @@ cmd_add()
629
fi
630
}
631
660
-cmd_add_repository()
661
-{
632
+cmd_add_repository () {
633
echo "git fetch" "$@"
634
repository=$1
635
refspec=$2
@@ -668,8 +639,7 @@ cmd_add_repository()
639
cmd_add_commit "$@"
640
}
641
671
-cmd_add_commit()
672
-{
642
+cmd_add_commit () {
643
revs=$(git rev-parse $default --revs-only "$@") || exit $?
644
set -- $revs
645
rev="$1"
@@ -702,8 +672,7 @@ cmd_add_commit()
672
say "Added dir '$dir'"
673
}
674
705
-cmd_split()
706
-{
675
+cmd_split () {
676
debug "Splitting $dir..."
677
cache_setup || exit $?
678
@@ -810,8 +779,7 @@ cmd_split()
779
exit 0
780
}
781
813
-cmd_merge()
814
-{
782
+cmd_merge () {
783
revs=$(git rev-parse $default --revs-only "$@") || exit $?
784
ensure_clean
785
@@ -862,8 +830,7 @@ cmd_merge()
830
fi
831
}
832
865
-cmd_pull()
866
-{
833
+cmd_pull () {
834
if test $# -ne 2
835
then
836
die "You must provide <repository> <ref>"
@@ -876,8 +843,7 @@ cmd_pull()
843
cmd_merge "$@"
844
}
845
879
-cmd_push()
880
-{
846
+cmd_push () {
847
if test $# -ne 2
848
then
849
die "You must provide <repository> <ref>"