Skip to content

Commit 5626a9e

Browse files
phil-blaingitster
authored andcommitted
subtree: prefix die messages with 'fatal'
Just as was done in 0008d12 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e94339 commit 5626a9e

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ progress () {
9898
assert () {
9999
if ! "$@"
100100
then
101-
die "assertion failed: $*"
101+
die "fatal: assertion failed: $*"
102102
fi
103103
}
104104

@@ -107,7 +107,7 @@ die_incompatible_opt () {
107107
assert test "$#" = 2
108108
opt="$1"
109109
arg_command="$2"
110-
die "The '$opt' flag does not make sense with 'git subtree $arg_command'."
110+
die "fatal: the '$opt' flag does not make sense with 'git subtree $arg_command'."
111111
}
112112

113113
main () {
@@ -155,7 +155,7 @@ main () {
155155
allow_addmerge=$arg_split_rejoin
156156
;;
157157
*)
158-
die "Unknown command '$arg_command'"
158+
die "fatal: unknown command '$arg_command'"
159159
;;
160160
esac
161161
# Reset the arguments array for "real" flag parsing.
@@ -244,25 +244,25 @@ main () {
244244
break
245245
;;
246246
*)
247-
die "Unexpected option: $opt"
247+
die "fatal: unexpected option: $opt"
248248
;;
249249
esac
250250
done
251251
shift
252252

253253
if test -z "$arg_prefix"
254254
then
255-
die "You must provide the --prefix option."
255+
die "fatal: you must provide the --prefix option."
256256
fi
257257

258258
case "$arg_command" in
259259
add)
260260
test -e "$arg_prefix" &&
261-
die "prefix '$arg_prefix' already exists."
261+
die "fatal: prefix '$arg_prefix' already exists."
262262
;;
263263
*)
264264
test -e "$arg_prefix" ||
265-
die "'$arg_prefix' does not exist; use 'git subtree add'"
265+
die "fatal: '$arg_prefix' does not exist; use 'git subtree add'"
266266
;;
267267
esac
268268

@@ -282,11 +282,11 @@ cache_setup () {
282282
assert test $# = 0
283283
cachedir="$GIT_DIR/subtree-cache/$$"
284284
rm -rf "$cachedir" ||
285-
die "Can't delete old cachedir: $cachedir"
285+
die "fatal: can't delete old cachedir: $cachedir"
286286
mkdir -p "$cachedir" ||
287-
die "Can't create new cachedir: $cachedir"
287+
die "fatal: can't create new cachedir: $cachedir"
288288
mkdir -p "$cachedir/notree" ||
289-
die "Can't create new cachedir: $cachedir/notree"
289+
die "fatal: can't create new cachedir: $cachedir/notree"
290290
debug "Using cachedir: $cachedir" >&2
291291
}
292292

@@ -342,7 +342,7 @@ cache_set () {
342342
test "$oldrev" != "latest_new" &&
343343
test -e "$cachedir/$oldrev"
344344
then
345-
die "cache for $oldrev already exists!"
345+
die "fatal: cache for $oldrev already exists!"
346346
fi
347347
echo "$newrev" >"$cachedir/$oldrev"
348348
}
@@ -396,7 +396,7 @@ find_latest_squash () {
396396
;;
397397
git-subtree-split:)
398398
sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
399-
die "could not rev-parse split hash $b from commit $sq"
399+
die "fatal: could not rev-parse split hash $b from commit $sq"
400400
;;
401401
END)
402402
if test -n "$sub"
@@ -448,7 +448,7 @@ find_existing_splits () {
448448
;;
449449
git-subtree-split:)
450450
sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
451-
die "could not rev-parse split hash $b from commit $sq"
451+
die "fatal: could not rev-parse split hash $b from commit $sq"
452452
;;
453453
END)
454454
debug "Main is: '$main'"
@@ -498,7 +498,7 @@ copy_commit () {
498498
cat
499499
) |
500500
git commit-tree "$2" $3 # reads the rest of stdin
501-
) || die "Can't copy commit $1"
501+
) || die "fatal: can't copy commit $1"
502502
}
503503

504504
# Usage: add_msg DIR LATEST_OLD LATEST_NEW
@@ -726,19 +726,19 @@ ensure_clean () {
726726
assert test $# = 0
727727
if ! git diff-index HEAD --exit-code --quiet 2>&1
728728
then
729-
die "Working tree has modifications. Cannot add."
729+
die "fatal: working tree has modifications. Cannot add."
730730
fi
731731
if ! git diff-index --cached HEAD --exit-code --quiet 2>&1
732732
then
733-
die "Index has modifications. Cannot add."
733+
die "fatal: index has modifications. Cannot add."
734734
fi
735735
}
736736

737737
# Usage: ensure_valid_ref_format REF
738738
ensure_valid_ref_format () {
739739
assert test $# = 1
740740
git check-ref-format "refs/heads/$1" ||
741-
die "'$1' does not look like a ref"
741+
die "fatal: '$1' does not look like a ref"
742742
}
743743

744744
# Usage: process_split_commit REV PARENTS
@@ -804,7 +804,7 @@ cmd_add () {
804804
if test $# -eq 1
805805
then
806806
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
807-
die "'$1' does not refer to a commit"
807+
die "fatal: '$1' does not refer to a commit"
808808

809809
cmd_add_commit "$@"
810810

@@ -819,7 +819,7 @@ cmd_add () {
819819

820820
cmd_add_repository "$@"
821821
else
822-
say >&2 "error: parameters were '$*'"
822+
say >&2 "fatal: parameters were '$*'"
823823
die "Provide either a commit or a repository and commit."
824824
fi
825825
}
@@ -882,9 +882,9 @@ cmd_split () {
882882
elif test $# -eq 1
883883
then
884884
rev=$(git rev-parse -q --verify "$1^{commit}") ||
885-
die "'$1' does not refer to a commit"
885+
die "fatal: '$1' does not refer to a commit"
886886
else
887-
die "You must provide exactly one revision. Got: '$*'"
887+
die "fatal: you must provide exactly one revision. Got: '$*'"
888888
fi
889889

890890
if test -n "$arg_split_rejoin"
@@ -927,7 +927,7 @@ cmd_split () {
927927
latest_new=$(cache_get latest_new) || exit $?
928928
if test -z "$latest_new"
929929
then
930-
die "No new revisions were found"
930+
die "fatal: no new revisions were found"
931931
fi
932932

933933
if test -n "$arg_split_rejoin"
@@ -948,7 +948,7 @@ cmd_split () {
948948
then
949949
if ! git merge-base --is-ancestor "$arg_split_branch" "$latest_new"
950950
then
951-
die "Branch '$arg_split_branch' is not an ancestor of commit '$latest_new'."
951+
die "fatal: branch '$arg_split_branch' is not an ancestor of commit '$latest_new'."
952952
fi
953953
action='Updated'
954954
else
@@ -965,17 +965,17 @@ cmd_split () {
965965
# Usage: cmd_merge REV
966966
cmd_merge () {
967967
test $# -eq 1 ||
968-
die "You must provide exactly one revision. Got: '$*'"
968+
die "fatal: you must provide exactly one revision. Got: '$*'"
969969
rev=$(git rev-parse -q --verify "$1^{commit}") ||
970-
die "'$1' does not refer to a commit"
970+
die "fatal: '$1' does not refer to a commit"
971971
ensure_clean
972972

973973
if test -n "$arg_addmerge_squash"
974974
then
975975
first_split="$(find_latest_squash "$dir")" || exit $?
976976
if test -z "$first_split"
977977
then
978-
die "Can't squash-merge: '$dir' was never added."
978+
die "fatal: can't squash-merge: '$dir' was never added."
979979
fi
980980
set $first_split
981981
old=$1
@@ -1003,7 +1003,7 @@ cmd_merge () {
10031003
cmd_pull () {
10041004
if test $# -ne 2
10051005
then
1006-
die "You must provide <repository> <ref>"
1006+
die "fatal: you must provide <repository> <ref>"
10071007
fi
10081008
ensure_clean
10091009
ensure_valid_ref_format "$2"
@@ -1015,7 +1015,7 @@ cmd_pull () {
10151015
cmd_push () {
10161016
if test $# -ne 2
10171017
then
1018-
die "You must provide <repository> <refspec>"
1018+
die "fatal: you must provide <repository> <refspec>"
10191019
fi
10201020
if test -e "$dir"
10211021
then
@@ -1030,13 +1030,13 @@ cmd_push () {
10301030
fi
10311031
ensure_valid_ref_format "$remoteref"
10321032
localrev_presplit=$(git rev-parse -q --verify "$localrevname_presplit^{commit}") ||
1033-
die "'$localrevname_presplit' does not refer to a commit"
1033+
die "fatal: '$localrevname_presplit' does not refer to a commit"
10341034

10351035
echo "git push using: " "$repository" "$refspec"
10361036
localrev=$(cmd_split "$localrev_presplit") || die
10371037
git push "$repository" "$localrev":"refs/heads/$remoteref"
10381038
else
1039-
die "'$dir' must already exist. Try 'git subtree add'."
1039+
die "fatal: '$dir' must already exist. Try 'git subtree add'."
10401040
fi
10411041
}
10421042

contrib/subtree/t/t7900-subtree.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ test_expect_success 'split requires option --prefix' '
277277
cd "$test_count" &&
278278
git fetch ./"sub proj" HEAD &&
279279
git subtree add --prefix="sub dir" FETCH_HEAD &&
280-
echo "You must provide the --prefix option." >expected &&
280+
echo "fatal: you must provide the --prefix option." >expected &&
281281
test_must_fail git subtree split >actual 2>&1 &&
282282
test_debug "printf '"expected: "'" &&
283283
test_debug "cat expected" &&
@@ -296,7 +296,7 @@ test_expect_success 'split requires path given by option --prefix must exist' '
296296
cd "$test_count" &&
297297
git fetch ./"sub proj" HEAD &&
298298
git subtree add --prefix="sub dir" FETCH_HEAD &&
299-
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
299+
echo "fatal: '\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
300300
test_must_fail git subtree split --prefix=non-existent-directory >actual 2>&1 &&
301301
test_debug "printf '"expected: "'" &&
302302
test_debug "cat expected" &&
@@ -570,7 +570,7 @@ test_expect_success 'pull requires option --prefix' '
570570
cd "$test_count" &&
571571
test_must_fail git subtree pull ./"sub proj" HEAD >out 2>err &&
572572
573-
echo "You must provide the --prefix option." >expected &&
573+
echo "fatal: you must provide the --prefix option." >expected &&
574574
test_must_be_empty out &&
575575
test_cmp expected err
576576
)
@@ -584,7 +584,7 @@ test_expect_success 'pull requires path given by option --prefix must exist' '
584584
(
585585
test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD >out 2>err &&
586586
587-
echo "'\''sub dir'\'' does not exist; use '\''git subtree add'\''" >expected &&
587+
echo "fatal: '\''sub dir'\'' does not exist; use '\''git subtree add'\''" >expected &&
588588
test_must_be_empty out &&
589589
test_cmp expected err
590590
)
@@ -643,7 +643,7 @@ test_expect_success 'push requires option --prefix' '
643643
cd "$test_count" &&
644644
git fetch ./"sub proj" HEAD &&
645645
git subtree add --prefix="sub dir" FETCH_HEAD &&
646-
echo "You must provide the --prefix option." >expected &&
646+
echo "fatal: you must provide the --prefix option." >expected &&
647647
test_must_fail git subtree push "./sub proj" from-mainline >actual 2>&1 &&
648648
test_debug "printf '"expected: "'" &&
649649
test_debug "cat expected" &&
@@ -662,7 +662,7 @@ test_expect_success 'push requires path given by option --prefix must exist' '
662662
cd "$test_count" &&
663663
git fetch ./"sub proj" HEAD &&
664664
git subtree add --prefix="sub dir" FETCH_HEAD &&
665-
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
665+
echo "fatal: '\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
666666
test_must_fail git subtree push --prefix=non-existent-directory "./sub proj" from-mainline >actual 2>&1 &&
667667
test_debug "printf '"expected: "'" &&
668668
test_debug "cat expected" &&

0 commit comments

Comments
 (0)