Skip to content

Commit d7fd792

Browse files
davvidgitster
authored andcommitted
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>
1 parent 6ae6a23 commit d7fd792

File tree

1 file changed

+34
-68
lines changed

1 file changed

+34
-68
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,28 @@ squash=
4949
message=
5050
prefix=
5151

52-
debug()
53-
{
52+
debug () {
5453
if test -n "$debug"
5554
then
5655
printf "%s\n" "$*" >&2
5756
fi
5857
}
5958

60-
say()
61-
{
59+
say () {
6260
if test -z "$quiet"
6361
then
6462
printf "%s\n" "$*" >&2
6563
fi
6664
}
6765

68-
progress()
69-
{
66+
progress () {
7067
if test -z "$quiet"
7168
then
7269
printf "%s\r" "$*" >&2
7370
fi
7471
}
7572

76-
assert()
77-
{
73+
assert () {
7874
if ! "$@"
7975
then
8076
die "assertion failed: " "$@"
@@ -202,8 +198,7 @@ debug "dir: {$dir}"
202198
debug "opts: {$*}"
203199
debug
204200

205-
cache_setup()
206-
{
201+
cache_setup () {
207202
cachedir="$GIT_DIR/subtree-cache/$$"
208203
rm -rf "$cachedir" ||
209204
die "Can't delete old cachedir: $cachedir"
@@ -214,8 +209,7 @@ cache_setup()
214209
debug "Using cachedir: $cachedir" >&2
215210
}
216211

217-
cache_get()
218-
{
212+
cache_get () {
219213
for oldrev in "$@"
220214
do
221215
if test -r "$cachedir/$oldrev"
@@ -226,8 +220,7 @@ cache_get()
226220
done
227221
}
228222

229-
cache_miss()
230-
{
223+
cache_miss () {
231224
for oldrev in "$@"
232225
do
233226
if ! test -r "$cachedir/$oldrev"
@@ -237,8 +230,7 @@ cache_miss()
237230
done
238231
}
239232

240-
check_parents()
241-
{
233+
check_parents () {
242234
missed=$(cache_miss "$@")
243235
for miss in $missed
244236
do
@@ -249,13 +241,11 @@ check_parents()
249241
done
250242
}
251243

252-
set_notree()
253-
{
244+
set_notree () {
254245
echo "1" > "$cachedir/notree/$1"
255246
}
256247

257-
cache_set()
258-
{
248+
cache_set () {
259249
oldrev="$1"
260250
newrev="$2"
261251
if test "$oldrev" != "latest_old" &&
@@ -267,8 +257,7 @@ cache_set()
267257
echo "$newrev" >"$cachedir/$oldrev"
268258
}
269259

270-
rev_exists()
271-
{
260+
rev_exists () {
272261
if git rev-parse "$1" >/dev/null 2>&1
273262
then
274263
return 0
@@ -277,8 +266,7 @@ rev_exists()
277266
fi
278267
}
279268

280-
rev_is_descendant_of_branch()
281-
{
269+
rev_is_descendant_of_branch () {
282270
newrev="$1"
283271
branch="$2"
284272
branch_hash=$(git rev-parse "$branch")
@@ -295,16 +283,14 @@ rev_is_descendant_of_branch()
295283
# if a commit doesn't have a parent, this might not work. But we only want
296284
# to remove the parent from the rev-list, and since it doesn't exist, it won't
297285
# be there anyway, so do nothing in that case.
298-
try_remove_previous()
299-
{
286+
try_remove_previous () {
300287
if rev_exists "$1^"
301288
then
302289
echo "^$1^"
303290
fi
304291
}
305292

306-
find_latest_squash()
307-
{
293+
find_latest_squash () {
308294
debug "Looking for latest squash ($dir)..."
309295
dir="$1"
310296
sq=
@@ -348,8 +334,7 @@ find_latest_squash()
348334
done
349335
}
350336

351-
find_existing_splits()
352-
{
337+
find_existing_splits () {
353338
debug "Looking for prior splits..."
354339
dir="$1"
355340
revs="$2"
@@ -393,8 +378,7 @@ find_existing_splits()
393378
done
394379
}
395380

396-
copy_commit()
397-
{
381+
copy_commit () {
398382
# We're going to set some environment vars here, so
399383
# do it in a subshell to get rid of them safely later
400384
debug copy_commit "{$1}" "{$2}" "{$3}"
@@ -420,8 +404,7 @@ copy_commit()
420404
) || die "Can't copy commit $1"
421405
}
422406

423-
add_msg()
424-
{
407+
add_msg () {
425408
dir="$1"
426409
latest_old="$2"
427410
latest_new="$3"
@@ -440,8 +423,7 @@ add_msg()
440423
EOF
441424
}
442425

443-
add_squashed_msg()
444-
{
426+
add_squashed_msg () {
445427
if test -n "$message"
446428
then
447429
echo "$message"
@@ -450,8 +432,7 @@ add_squashed_msg()
450432
fi
451433
}
452434

453-
rejoin_msg()
454-
{
435+
rejoin_msg () {
455436
dir="$1"
456437
latest_old="$2"
457438
latest_new="$3"
@@ -470,8 +451,7 @@ rejoin_msg()
470451
EOF
471452
}
472453

473-
squash_msg()
474-
{
454+
squash_msg () {
475455
dir="$1"
476456
oldsub="$2"
477457
newsub="$3"
@@ -493,14 +473,12 @@ squash_msg()
493473
echo "git-subtree-split: $newsub"
494474
}
495475

496-
toptree_for_commit()
497-
{
476+
toptree_for_commit () {
498477
commit="$1"
499478
git log -1 --pretty=format:'%T' "$commit" -- || exit $?
500479
}
501480

502-
subtree_for_commit()
503-
{
481+
subtree_for_commit () {
504482
commit="$1"
505483
dir="$2"
506484
git ls-tree "$commit" -- "$dir" |
@@ -514,8 +492,7 @@ subtree_for_commit()
514492
done
515493
}
516494

517-
tree_changed()
518-
{
495+
tree_changed () {
519496
tree=$1
520497
shift
521498
if test $# -ne 1
@@ -532,8 +509,7 @@ tree_changed()
532509
fi
533510
}
534511

535-
new_squash_commit()
536-
{
512+
new_squash_commit () {
537513
old="$1"
538514
oldsub="$2"
539515
newsub="$3"
@@ -548,8 +524,7 @@ new_squash_commit()
548524
fi
549525
}
550526

551-
copy_or_skip()
552-
{
527+
copy_or_skip () {
553528
rev="$1"
554529
tree="$2"
555530
newparents="$3"
@@ -607,8 +582,7 @@ copy_or_skip()
607582
fi
608583
}
609584

610-
ensure_clean()
611-
{
585+
ensure_clean () {
612586
if ! git diff-index HEAD --exit-code --quiet 2>&1
613587
then
614588
die "Working tree has modifications. Cannot add."
@@ -619,14 +593,12 @@ ensure_clean()
619593
fi
620594
}
621595

622-
ensure_valid_ref_format()
623-
{
596+
ensure_valid_ref_format () {
624597
git check-ref-format "refs/heads/$1" ||
625598
die "'$1' does not look like a ref"
626599
}
627600

628-
cmd_add()
629-
{
601+
cmd_add () {
630602
if test -e "$dir"
631603
then
632604
die "'$dir' already exists. Cannot add."
@@ -657,8 +629,7 @@ cmd_add()
657629
fi
658630
}
659631

660-
cmd_add_repository()
661-
{
632+
cmd_add_repository () {
662633
echo "git fetch" "$@"
663634
repository=$1
664635
refspec=$2
@@ -668,8 +639,7 @@ cmd_add_repository()
668639
cmd_add_commit "$@"
669640
}
670641

671-
cmd_add_commit()
672-
{
642+
cmd_add_commit () {
673643
revs=$(git rev-parse $default --revs-only "$@") || exit $?
674644
set -- $revs
675645
rev="$1"
@@ -702,8 +672,7 @@ cmd_add_commit()
702672
say "Added dir '$dir'"
703673
}
704674

705-
cmd_split()
706-
{
675+
cmd_split () {
707676
debug "Splitting $dir..."
708677
cache_setup || exit $?
709678

@@ -810,8 +779,7 @@ cmd_split()
810779
exit 0
811780
}
812781

813-
cmd_merge()
814-
{
782+
cmd_merge () {
815783
revs=$(git rev-parse $default --revs-only "$@") || exit $?
816784
ensure_clean
817785

@@ -862,8 +830,7 @@ cmd_merge()
862830
fi
863831
}
864832

865-
cmd_pull()
866-
{
833+
cmd_pull () {
867834
if test $# -ne 2
868835
then
869836
die "You must provide <repository> <ref>"
@@ -876,8 +843,7 @@ cmd_pull()
876843
cmd_merge "$@"
877844
}
878845

879-
cmd_push()
880-
{
846+
cmd_push () {
881847
if test $# -ne 2
882848
then
883849
die "You must provide <repository> <ref>"

0 commit comments

Comments
 (0)