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>
This commit is contained in:

committed by
Junio C Hamano

parent
6ae6a23318
commit
d7fd792e1b
@ -49,32 +49,28 @@ squash=
|
|||||||
message=
|
message=
|
||||||
prefix=
|
prefix=
|
||||||
|
|
||||||
debug()
|
debug () {
|
||||||
{
|
|
||||||
if test -n "$debug"
|
if test -n "$debug"
|
||||||
then
|
then
|
||||||
printf "%s\n" "$*" >&2
|
printf "%s\n" "$*" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
say()
|
say () {
|
||||||
{
|
|
||||||
if test -z "$quiet"
|
if test -z "$quiet"
|
||||||
then
|
then
|
||||||
printf "%s\n" "$*" >&2
|
printf "%s\n" "$*" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
progress()
|
progress () {
|
||||||
{
|
|
||||||
if test -z "$quiet"
|
if test -z "$quiet"
|
||||||
then
|
then
|
||||||
printf "%s\r" "$*" >&2
|
printf "%s\r" "$*" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
assert()
|
assert () {
|
||||||
{
|
|
||||||
if ! "$@"
|
if ! "$@"
|
||||||
then
|
then
|
||||||
die "assertion failed: " "$@"
|
die "assertion failed: " "$@"
|
||||||
@ -202,8 +198,7 @@ debug "dir: {$dir}"
|
|||||||
debug "opts: {$*}"
|
debug "opts: {$*}"
|
||||||
debug
|
debug
|
||||||
|
|
||||||
cache_setup()
|
cache_setup () {
|
||||||
{
|
|
||||||
cachedir="$GIT_DIR/subtree-cache/$$"
|
cachedir="$GIT_DIR/subtree-cache/$$"
|
||||||
rm -rf "$cachedir" ||
|
rm -rf "$cachedir" ||
|
||||||
die "Can't delete old cachedir: $cachedir"
|
die "Can't delete old cachedir: $cachedir"
|
||||||
@ -214,8 +209,7 @@ cache_setup()
|
|||||||
debug "Using cachedir: $cachedir" >&2
|
debug "Using cachedir: $cachedir" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_get()
|
cache_get () {
|
||||||
{
|
|
||||||
for oldrev in "$@"
|
for oldrev in "$@"
|
||||||
do
|
do
|
||||||
if test -r "$cachedir/$oldrev"
|
if test -r "$cachedir/$oldrev"
|
||||||
@ -226,8 +220,7 @@ cache_get()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_miss()
|
cache_miss () {
|
||||||
{
|
|
||||||
for oldrev in "$@"
|
for oldrev in "$@"
|
||||||
do
|
do
|
||||||
if ! test -r "$cachedir/$oldrev"
|
if ! test -r "$cachedir/$oldrev"
|
||||||
@ -237,8 +230,7 @@ cache_miss()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
check_parents()
|
check_parents () {
|
||||||
{
|
|
||||||
missed=$(cache_miss "$@")
|
missed=$(cache_miss "$@")
|
||||||
for miss in $missed
|
for miss in $missed
|
||||||
do
|
do
|
||||||
@ -249,13 +241,11 @@ check_parents()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
set_notree()
|
set_notree () {
|
||||||
{
|
|
||||||
echo "1" > "$cachedir/notree/$1"
|
echo "1" > "$cachedir/notree/$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_set()
|
cache_set () {
|
||||||
{
|
|
||||||
oldrev="$1"
|
oldrev="$1"
|
||||||
newrev="$2"
|
newrev="$2"
|
||||||
if test "$oldrev" != "latest_old" &&
|
if test "$oldrev" != "latest_old" &&
|
||||||
@ -267,8 +257,7 @@ cache_set()
|
|||||||
echo "$newrev" >"$cachedir/$oldrev"
|
echo "$newrev" >"$cachedir/$oldrev"
|
||||||
}
|
}
|
||||||
|
|
||||||
rev_exists()
|
rev_exists () {
|
||||||
{
|
|
||||||
if git rev-parse "$1" >/dev/null 2>&1
|
if git rev-parse "$1" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
@ -277,8 +266,7 @@ rev_exists()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
rev_is_descendant_of_branch()
|
rev_is_descendant_of_branch () {
|
||||||
{
|
|
||||||
newrev="$1"
|
newrev="$1"
|
||||||
branch="$2"
|
branch="$2"
|
||||||
branch_hash=$(git rev-parse "$branch")
|
branch_hash=$(git rev-parse "$branch")
|
||||||
@ -295,16 +283,14 @@ rev_is_descendant_of_branch()
|
|||||||
# if a commit doesn't have a parent, this might not work. But we only want
|
# if a commit doesn't have a parent, this might not work. But we only want
|
||||||
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
# to remove the parent from the rev-list, and since it doesn't exist, it won't
|
||||||
# be there anyway, so do nothing in that case.
|
# be there anyway, so do nothing in that case.
|
||||||
try_remove_previous()
|
try_remove_previous () {
|
||||||
{
|
|
||||||
if rev_exists "$1^"
|
if rev_exists "$1^"
|
||||||
then
|
then
|
||||||
echo "^$1^"
|
echo "^$1^"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
find_latest_squash()
|
find_latest_squash () {
|
||||||
{
|
|
||||||
debug "Looking for latest squash ($dir)..."
|
debug "Looking for latest squash ($dir)..."
|
||||||
dir="$1"
|
dir="$1"
|
||||||
sq=
|
sq=
|
||||||
@ -348,8 +334,7 @@ find_latest_squash()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
find_existing_splits()
|
find_existing_splits () {
|
||||||
{
|
|
||||||
debug "Looking for prior splits..."
|
debug "Looking for prior splits..."
|
||||||
dir="$1"
|
dir="$1"
|
||||||
revs="$2"
|
revs="$2"
|
||||||
@ -393,8 +378,7 @@ find_existing_splits()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_commit()
|
copy_commit () {
|
||||||
{
|
|
||||||
# We're going to set some environment vars here, so
|
# We're going to set some environment vars here, so
|
||||||
# do it in a subshell to get rid of them safely later
|
# do it in a subshell to get rid of them safely later
|
||||||
debug copy_commit "{$1}" "{$2}" "{$3}"
|
debug copy_commit "{$1}" "{$2}" "{$3}"
|
||||||
@ -420,8 +404,7 @@ copy_commit()
|
|||||||
) || die "Can't copy commit $1"
|
) || die "Can't copy commit $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
add_msg()
|
add_msg () {
|
||||||
{
|
|
||||||
dir="$1"
|
dir="$1"
|
||||||
latest_old="$2"
|
latest_old="$2"
|
||||||
latest_new="$3"
|
latest_new="$3"
|
||||||
@ -440,8 +423,7 @@ add_msg()
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
add_squashed_msg()
|
add_squashed_msg () {
|
||||||
{
|
|
||||||
if test -n "$message"
|
if test -n "$message"
|
||||||
then
|
then
|
||||||
echo "$message"
|
echo "$message"
|
||||||
@ -450,8 +432,7 @@ add_squashed_msg()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
rejoin_msg()
|
rejoin_msg () {
|
||||||
{
|
|
||||||
dir="$1"
|
dir="$1"
|
||||||
latest_old="$2"
|
latest_old="$2"
|
||||||
latest_new="$3"
|
latest_new="$3"
|
||||||
@ -470,8 +451,7 @@ rejoin_msg()
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
squash_msg()
|
squash_msg () {
|
||||||
{
|
|
||||||
dir="$1"
|
dir="$1"
|
||||||
oldsub="$2"
|
oldsub="$2"
|
||||||
newsub="$3"
|
newsub="$3"
|
||||||
@ -493,14 +473,12 @@ squash_msg()
|
|||||||
echo "git-subtree-split: $newsub"
|
echo "git-subtree-split: $newsub"
|
||||||
}
|
}
|
||||||
|
|
||||||
toptree_for_commit()
|
toptree_for_commit () {
|
||||||
{
|
|
||||||
commit="$1"
|
commit="$1"
|
||||||
git log -1 --pretty=format:'%T' "$commit" -- || exit $?
|
git log -1 --pretty=format:'%T' "$commit" -- || exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
subtree_for_commit()
|
subtree_for_commit () {
|
||||||
{
|
|
||||||
commit="$1"
|
commit="$1"
|
||||||
dir="$2"
|
dir="$2"
|
||||||
git ls-tree "$commit" -- "$dir" |
|
git ls-tree "$commit" -- "$dir" |
|
||||||
@ -514,8 +492,7 @@ subtree_for_commit()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
tree_changed()
|
tree_changed () {
|
||||||
{
|
|
||||||
tree=$1
|
tree=$1
|
||||||
shift
|
shift
|
||||||
if test $# -ne 1
|
if test $# -ne 1
|
||||||
@ -532,8 +509,7 @@ tree_changed()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
new_squash_commit()
|
new_squash_commit () {
|
||||||
{
|
|
||||||
old="$1"
|
old="$1"
|
||||||
oldsub="$2"
|
oldsub="$2"
|
||||||
newsub="$3"
|
newsub="$3"
|
||||||
@ -548,8 +524,7 @@ new_squash_commit()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_or_skip()
|
copy_or_skip () {
|
||||||
{
|
|
||||||
rev="$1"
|
rev="$1"
|
||||||
tree="$2"
|
tree="$2"
|
||||||
newparents="$3"
|
newparents="$3"
|
||||||
@ -607,8 +582,7 @@ copy_or_skip()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_clean()
|
ensure_clean () {
|
||||||
{
|
|
||||||
if ! git diff-index HEAD --exit-code --quiet 2>&1
|
if ! git diff-index HEAD --exit-code --quiet 2>&1
|
||||||
then
|
then
|
||||||
die "Working tree has modifications. Cannot add."
|
die "Working tree has modifications. Cannot add."
|
||||||
@ -619,14 +593,12 @@ ensure_clean()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_valid_ref_format()
|
ensure_valid_ref_format () {
|
||||||
{
|
|
||||||
git check-ref-format "refs/heads/$1" ||
|
git check-ref-format "refs/heads/$1" ||
|
||||||
die "'$1' does not look like a ref"
|
die "'$1' does not look like a ref"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_add()
|
cmd_add () {
|
||||||
{
|
|
||||||
if test -e "$dir"
|
if test -e "$dir"
|
||||||
then
|
then
|
||||||
die "'$dir' already exists. Cannot add."
|
die "'$dir' already exists. Cannot add."
|
||||||
@ -657,8 +629,7 @@ cmd_add()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_add_repository()
|
cmd_add_repository () {
|
||||||
{
|
|
||||||
echo "git fetch" "$@"
|
echo "git fetch" "$@"
|
||||||
repository=$1
|
repository=$1
|
||||||
refspec=$2
|
refspec=$2
|
||||||
@ -668,8 +639,7 @@ cmd_add_repository()
|
|||||||
cmd_add_commit "$@"
|
cmd_add_commit "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_add_commit()
|
cmd_add_commit () {
|
||||||
{
|
|
||||||
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
||||||
set -- $revs
|
set -- $revs
|
||||||
rev="$1"
|
rev="$1"
|
||||||
@ -702,8 +672,7 @@ cmd_add_commit()
|
|||||||
say "Added dir '$dir'"
|
say "Added dir '$dir'"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_split()
|
cmd_split () {
|
||||||
{
|
|
||||||
debug "Splitting $dir..."
|
debug "Splitting $dir..."
|
||||||
cache_setup || exit $?
|
cache_setup || exit $?
|
||||||
|
|
||||||
@ -810,8 +779,7 @@ cmd_split()
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_merge()
|
cmd_merge () {
|
||||||
{
|
|
||||||
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
revs=$(git rev-parse $default --revs-only "$@") || exit $?
|
||||||
ensure_clean
|
ensure_clean
|
||||||
|
|
||||||
@ -862,8 +830,7 @@ cmd_merge()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_pull()
|
cmd_pull () {
|
||||||
{
|
|
||||||
if test $# -ne 2
|
if test $# -ne 2
|
||||||
then
|
then
|
||||||
die "You must provide <repository> <ref>"
|
die "You must provide <repository> <ref>"
|
||||||
@ -876,8 +843,7 @@ cmd_pull()
|
|||||||
cmd_merge "$@"
|
cmd_merge "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_push()
|
cmd_push () {
|
||||||
{
|
|
||||||
if test $# -ne 2
|
if test $# -ne 2
|
||||||
then
|
then
|
||||||
die "You must provide <repository> <ref>"
|
die "You must provide <repository> <ref>"
|
||||||
|
Reference in New Issue
Block a user