mirror of
https://github.com/git/git
synced 2024-08-26 19:19:18 +00:00
subtree: prefix die messages with 'fatal'
Just as was done in 0008d12284
(submodule: prefix die messages with
'fatal', 2021-07-10) for 'git-submodule.sh', make the 'die' messages
outputed by 'git-subtree.sh' more in line with the rest of the code base
by prefixing them with "fatal: ", and do not capitalize their first
letter.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2e94339fdc
commit
5626a9e2a9
|
@ -98,7 +98,7 @@ progress () {
|
||||||
assert () {
|
assert () {
|
||||||
if ! "$@"
|
if ! "$@"
|
||||||
then
|
then
|
||||||
die "assertion failed: $*"
|
die "fatal: assertion failed: $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ die_incompatible_opt () {
|
||||||
assert test "$#" = 2
|
assert test "$#" = 2
|
||||||
opt="$1"
|
opt="$1"
|
||||||
arg_command="$2"
|
arg_command="$2"
|
||||||
die "The '$opt' flag does not make sense with 'git subtree $arg_command'."
|
die "fatal: the '$opt' flag does not make sense with 'git subtree $arg_command'."
|
||||||
}
|
}
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
|
@ -155,7 +155,7 @@ main () {
|
||||||
allow_addmerge=$arg_split_rejoin
|
allow_addmerge=$arg_split_rejoin
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
die "Unknown command '$arg_command'"
|
die "fatal: unknown command '$arg_command'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# Reset the arguments array for "real" flag parsing.
|
# Reset the arguments array for "real" flag parsing.
|
||||||
|
@ -244,7 +244,7 @@ main () {
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
die "Unexpected option: $opt"
|
die "fatal: unexpected option: $opt"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -252,17 +252,17 @@ main () {
|
||||||
|
|
||||||
if test -z "$arg_prefix"
|
if test -z "$arg_prefix"
|
||||||
then
|
then
|
||||||
die "You must provide the --prefix option."
|
die "fatal: you must provide the --prefix option."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$arg_command" in
|
case "$arg_command" in
|
||||||
add)
|
add)
|
||||||
test -e "$arg_prefix" &&
|
test -e "$arg_prefix" &&
|
||||||
die "prefix '$arg_prefix' already exists."
|
die "fatal: prefix '$arg_prefix' already exists."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
test -e "$arg_prefix" ||
|
test -e "$arg_prefix" ||
|
||||||
die "'$arg_prefix' does not exist; use 'git subtree add'"
|
die "fatal: '$arg_prefix' does not exist; use 'git subtree add'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -282,11 +282,11 @@ cache_setup () {
|
||||||
assert test $# = 0
|
assert test $# = 0
|
||||||
cachedir="$GIT_DIR/subtree-cache/$$"
|
cachedir="$GIT_DIR/subtree-cache/$$"
|
||||||
rm -rf "$cachedir" ||
|
rm -rf "$cachedir" ||
|
||||||
die "Can't delete old cachedir: $cachedir"
|
die "fatal: can't delete old cachedir: $cachedir"
|
||||||
mkdir -p "$cachedir" ||
|
mkdir -p "$cachedir" ||
|
||||||
die "Can't create new cachedir: $cachedir"
|
die "fatal: can't create new cachedir: $cachedir"
|
||||||
mkdir -p "$cachedir/notree" ||
|
mkdir -p "$cachedir/notree" ||
|
||||||
die "Can't create new cachedir: $cachedir/notree"
|
die "fatal: can't create new cachedir: $cachedir/notree"
|
||||||
debug "Using cachedir: $cachedir" >&2
|
debug "Using cachedir: $cachedir" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ cache_set () {
|
||||||
test "$oldrev" != "latest_new" &&
|
test "$oldrev" != "latest_new" &&
|
||||||
test -e "$cachedir/$oldrev"
|
test -e "$cachedir/$oldrev"
|
||||||
then
|
then
|
||||||
die "cache for $oldrev already exists!"
|
die "fatal: cache for $oldrev already exists!"
|
||||||
fi
|
fi
|
||||||
echo "$newrev" >"$cachedir/$oldrev"
|
echo "$newrev" >"$cachedir/$oldrev"
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ find_latest_squash () {
|
||||||
;;
|
;;
|
||||||
git-subtree-split:)
|
git-subtree-split:)
|
||||||
sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
|
sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
|
||||||
die "could not rev-parse split hash $b from commit $sq"
|
die "fatal: could not rev-parse split hash $b from commit $sq"
|
||||||
;;
|
;;
|
||||||
END)
|
END)
|
||||||
if test -n "$sub"
|
if test -n "$sub"
|
||||||
|
@ -448,7 +448,7 @@ find_existing_splits () {
|
||||||
;;
|
;;
|
||||||
git-subtree-split:)
|
git-subtree-split:)
|
||||||
sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
|
sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
|
||||||
die "could not rev-parse split hash $b from commit $sq"
|
die "fatal: could not rev-parse split hash $b from commit $sq"
|
||||||
;;
|
;;
|
||||||
END)
|
END)
|
||||||
debug "Main is: '$main'"
|
debug "Main is: '$main'"
|
||||||
|
@ -498,7 +498,7 @@ copy_commit () {
|
||||||
cat
|
cat
|
||||||
) |
|
) |
|
||||||
git commit-tree "$2" $3 # reads the rest of stdin
|
git commit-tree "$2" $3 # reads the rest of stdin
|
||||||
) || die "Can't copy commit $1"
|
) || die "fatal: can't copy commit $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: add_msg DIR LATEST_OLD LATEST_NEW
|
# Usage: add_msg DIR LATEST_OLD LATEST_NEW
|
||||||
|
@ -726,11 +726,11 @@ ensure_clean () {
|
||||||
assert test $# = 0
|
assert test $# = 0
|
||||||
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 "fatal: working tree has modifications. Cannot add."
|
||||||
fi
|
fi
|
||||||
if ! git diff-index --cached HEAD --exit-code --quiet 2>&1
|
if ! git diff-index --cached HEAD --exit-code --quiet 2>&1
|
||||||
then
|
then
|
||||||
die "Index has modifications. Cannot add."
|
die "fatal: index has modifications. Cannot add."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,7 +738,7 @@ ensure_clean () {
|
||||||
ensure_valid_ref_format () {
|
ensure_valid_ref_format () {
|
||||||
assert test $# = 1
|
assert test $# = 1
|
||||||
git check-ref-format "refs/heads/$1" ||
|
git check-ref-format "refs/heads/$1" ||
|
||||||
die "'$1' does not look like a ref"
|
die "fatal: '$1' does not look like a ref"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: process_split_commit REV PARENTS
|
# Usage: process_split_commit REV PARENTS
|
||||||
|
@ -804,7 +804,7 @@ cmd_add () {
|
||||||
if test $# -eq 1
|
if test $# -eq 1
|
||||||
then
|
then
|
||||||
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
|
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
|
||||||
die "'$1' does not refer to a commit"
|
die "fatal: '$1' does not refer to a commit"
|
||||||
|
|
||||||
cmd_add_commit "$@"
|
cmd_add_commit "$@"
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ cmd_add () {
|
||||||
|
|
||||||
cmd_add_repository "$@"
|
cmd_add_repository "$@"
|
||||||
else
|
else
|
||||||
say >&2 "error: parameters were '$*'"
|
say >&2 "fatal: parameters were '$*'"
|
||||||
die "Provide either a commit or a repository and commit."
|
die "Provide either a commit or a repository and commit."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -882,9 +882,9 @@ cmd_split () {
|
||||||
elif test $# -eq 1
|
elif test $# -eq 1
|
||||||
then
|
then
|
||||||
rev=$(git rev-parse -q --verify "$1^{commit}") ||
|
rev=$(git rev-parse -q --verify "$1^{commit}") ||
|
||||||
die "'$1' does not refer to a commit"
|
die "fatal: '$1' does not refer to a commit"
|
||||||
else
|
else
|
||||||
die "You must provide exactly one revision. Got: '$*'"
|
die "fatal: you must provide exactly one revision. Got: '$*'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$arg_split_rejoin"
|
if test -n "$arg_split_rejoin"
|
||||||
|
@ -927,7 +927,7 @@ cmd_split () {
|
||||||
latest_new=$(cache_get latest_new) || exit $?
|
latest_new=$(cache_get latest_new) || exit $?
|
||||||
if test -z "$latest_new"
|
if test -z "$latest_new"
|
||||||
then
|
then
|
||||||
die "No new revisions were found"
|
die "fatal: no new revisions were found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$arg_split_rejoin"
|
if test -n "$arg_split_rejoin"
|
||||||
|
@ -948,7 +948,7 @@ cmd_split () {
|
||||||
then
|
then
|
||||||
if ! git merge-base --is-ancestor "$arg_split_branch" "$latest_new"
|
if ! git merge-base --is-ancestor "$arg_split_branch" "$latest_new"
|
||||||
then
|
then
|
||||||
die "Branch '$arg_split_branch' is not an ancestor of commit '$latest_new'."
|
die "fatal: branch '$arg_split_branch' is not an ancestor of commit '$latest_new'."
|
||||||
fi
|
fi
|
||||||
action='Updated'
|
action='Updated'
|
||||||
else
|
else
|
||||||
|
@ -965,9 +965,9 @@ cmd_split () {
|
||||||
# Usage: cmd_merge REV
|
# Usage: cmd_merge REV
|
||||||
cmd_merge () {
|
cmd_merge () {
|
||||||
test $# -eq 1 ||
|
test $# -eq 1 ||
|
||||||
die "You must provide exactly one revision. Got: '$*'"
|
die "fatal: you must provide exactly one revision. Got: '$*'"
|
||||||
rev=$(git rev-parse -q --verify "$1^{commit}") ||
|
rev=$(git rev-parse -q --verify "$1^{commit}") ||
|
||||||
die "'$1' does not refer to a commit"
|
die "fatal: '$1' does not refer to a commit"
|
||||||
ensure_clean
|
ensure_clean
|
||||||
|
|
||||||
if test -n "$arg_addmerge_squash"
|
if test -n "$arg_addmerge_squash"
|
||||||
|
@ -975,7 +975,7 @@ cmd_merge () {
|
||||||
first_split="$(find_latest_squash "$dir")" || exit $?
|
first_split="$(find_latest_squash "$dir")" || exit $?
|
||||||
if test -z "$first_split"
|
if test -z "$first_split"
|
||||||
then
|
then
|
||||||
die "Can't squash-merge: '$dir' was never added."
|
die "fatal: can't squash-merge: '$dir' was never added."
|
||||||
fi
|
fi
|
||||||
set $first_split
|
set $first_split
|
||||||
old=$1
|
old=$1
|
||||||
|
@ -1003,7 +1003,7 @@ cmd_merge () {
|
||||||
cmd_pull () {
|
cmd_pull () {
|
||||||
if test $# -ne 2
|
if test $# -ne 2
|
||||||
then
|
then
|
||||||
die "You must provide <repository> <ref>"
|
die "fatal: you must provide <repository> <ref>"
|
||||||
fi
|
fi
|
||||||
ensure_clean
|
ensure_clean
|
||||||
ensure_valid_ref_format "$2"
|
ensure_valid_ref_format "$2"
|
||||||
|
@ -1015,7 +1015,7 @@ cmd_pull () {
|
||||||
cmd_push () {
|
cmd_push () {
|
||||||
if test $# -ne 2
|
if test $# -ne 2
|
||||||
then
|
then
|
||||||
die "You must provide <repository> <refspec>"
|
die "fatal: you must provide <repository> <refspec>"
|
||||||
fi
|
fi
|
||||||
if test -e "$dir"
|
if test -e "$dir"
|
||||||
then
|
then
|
||||||
|
@ -1030,13 +1030,13 @@ cmd_push () {
|
||||||
fi
|
fi
|
||||||
ensure_valid_ref_format "$remoteref"
|
ensure_valid_ref_format "$remoteref"
|
||||||
localrev_presplit=$(git rev-parse -q --verify "$localrevname_presplit^{commit}") ||
|
localrev_presplit=$(git rev-parse -q --verify "$localrevname_presplit^{commit}") ||
|
||||||
die "'$localrevname_presplit' does not refer to a commit"
|
die "fatal: '$localrevname_presplit' does not refer to a commit"
|
||||||
|
|
||||||
echo "git push using: " "$repository" "$refspec"
|
echo "git push using: " "$repository" "$refspec"
|
||||||
localrev=$(cmd_split "$localrev_presplit") || die
|
localrev=$(cmd_split "$localrev_presplit") || die
|
||||||
git push "$repository" "$localrev":"refs/heads/$remoteref"
|
git push "$repository" "$localrev":"refs/heads/$remoteref"
|
||||||
else
|
else
|
||||||
die "'$dir' must already exist. Try 'git subtree add'."
|
die "fatal: '$dir' must already exist. Try 'git subtree add'."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ test_expect_success 'split requires option --prefix' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
||||||
echo "You must provide the --prefix option." >expected &&
|
echo "fatal: you must provide the --prefix option." >expected &&
|
||||||
test_must_fail git subtree split >actual 2>&1 &&
|
test_must_fail git subtree split >actual 2>&1 &&
|
||||||
test_debug "printf '"expected: "'" &&
|
test_debug "printf '"expected: "'" &&
|
||||||
test_debug "cat expected" &&
|
test_debug "cat expected" &&
|
||||||
|
@ -296,7 +296,7 @@ test_expect_success 'split requires path given by option --prefix must exist' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
||||||
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
echo "fatal: '\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
||||||
test_must_fail git subtree split --prefix=non-existent-directory >actual 2>&1 &&
|
test_must_fail git subtree split --prefix=non-existent-directory >actual 2>&1 &&
|
||||||
test_debug "printf '"expected: "'" &&
|
test_debug "printf '"expected: "'" &&
|
||||||
test_debug "cat expected" &&
|
test_debug "cat expected" &&
|
||||||
|
@ -570,7 +570,7 @@ test_expect_success 'pull requires option --prefix' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
test_must_fail git subtree pull ./"sub proj" HEAD >out 2>err &&
|
test_must_fail git subtree pull ./"sub proj" HEAD >out 2>err &&
|
||||||
|
|
||||||
echo "You must provide the --prefix option." >expected &&
|
echo "fatal: you must provide the --prefix option." >expected &&
|
||||||
test_must_be_empty out &&
|
test_must_be_empty out &&
|
||||||
test_cmp expected err
|
test_cmp expected err
|
||||||
)
|
)
|
||||||
|
@ -584,7 +584,7 @@ test_expect_success 'pull requires path given by option --prefix must exist' '
|
||||||
(
|
(
|
||||||
test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD >out 2>err &&
|
test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD >out 2>err &&
|
||||||
|
|
||||||
echo "'\''sub dir'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
echo "fatal: '\''sub dir'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
||||||
test_must_be_empty out &&
|
test_must_be_empty out &&
|
||||||
test_cmp expected err
|
test_cmp expected err
|
||||||
)
|
)
|
||||||
|
@ -643,7 +643,7 @@ test_expect_success 'push requires option --prefix' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
||||||
echo "You must provide the --prefix option." >expected &&
|
echo "fatal: you must provide the --prefix option." >expected &&
|
||||||
test_must_fail git subtree push "./sub proj" from-mainline >actual 2>&1 &&
|
test_must_fail git subtree push "./sub proj" from-mainline >actual 2>&1 &&
|
||||||
test_debug "printf '"expected: "'" &&
|
test_debug "printf '"expected: "'" &&
|
||||||
test_debug "cat expected" &&
|
test_debug "cat expected" &&
|
||||||
|
@ -662,7 +662,7 @@ test_expect_success 'push requires path given by option --prefix must exist' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
||||||
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
echo "fatal: '\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
||||||
test_must_fail git subtree push --prefix=non-existent-directory "./sub proj" from-mainline >actual 2>&1 &&
|
test_must_fail git subtree push --prefix=non-existent-directory "./sub proj" from-mainline >actual 2>&1 &&
|
||||||
test_debug "printf '"expected: "'" &&
|
test_debug "printf '"expected: "'" &&
|
||||||
test_debug "cat expected" &&
|
test_debug "cat expected" &&
|
||||||
|
|
Loading…
Reference in a new issue