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>

Philippe Blain committed Oct 21, 2022 at 15:13 UTC 5626a9e2a93e4dd0ce13005a7fc1d74c2c3e4fd2
2 files changed +36 -36
contrib/subtree/git-subtree.sh
+30 -30
@@ -98,7 +98,7 @@ progress () {
98 assert () {
99 if ! "$@"
100 then
101 - die "assertion failed: $*"
101 + die "fatal: assertion failed: $*"
102 fi
103 }
104
@@ -107,7 +107,7 @@ die_incompatible_opt () {
107 assert test "$#" = 2
108 opt="$1"
109 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'."
111 }
112
113 main () {
@@ -155,7 +155,7 @@ main () {
155 allow_addmerge=$arg_split_rejoin
156 ;;
157 *)
158 - die "Unknown command '$arg_command'"
158 + die "fatal: unknown command '$arg_command'"
159 ;;
160 esac
161 # Reset the arguments array for "real" flag parsing.
@@ -244,7 +244,7 @@ main () {
244 break
245 ;;
246 *)
247 - die "Unexpected option: $opt"
247 + die "fatal: unexpected option: $opt"
248 ;;
249 esac
250 done
@@ -252,17 +252,17 @@ main () {
252
253 if test -z "$arg_prefix"
254 then
255 - die "You must provide the --prefix option."
255 + die "fatal: you must provide the --prefix option."
256 fi
257
258 case "$arg_command" in
259 add)
260 test -e "$arg_prefix" &&
261 - die "prefix '$arg_prefix' already exists."
261 + die "fatal: prefix '$arg_prefix' already exists."
262 ;;
263 *)
264 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'"
266 ;;
267 esac
268
@@ -282,11 +282,11 @@ cache_setup () {
282 assert test $# = 0
283 cachedir="$GIT_DIR/subtree-cache/$$"
284 rm -rf "$cachedir" ||
285 - die "Can't delete old cachedir: $cachedir"
285 + die "fatal: can't delete old cachedir: $cachedir"
286 mkdir -p "$cachedir" ||
287 - die "Can't create new cachedir: $cachedir"
287 + die "fatal: can't create new cachedir: $cachedir"
288 mkdir -p "$cachedir/notree" ||
289 - die "Can't create new cachedir: $cachedir/notree"
289 + die "fatal: can't create new cachedir: $cachedir/notree"
290 debug "Using cachedir: $cachedir" >&2
291 }
292
@@ -342,7 +342,7 @@ cache_set () {
342 test "$oldrev" != "latest_new" &&
343 test -e "$cachedir/$oldrev"
344 then
345 - die "cache for $oldrev already exists!"
345 + die "fatal: cache for $oldrev already exists!"
346 fi
347 echo "$newrev" >"$cachedir/$oldrev"
348 }
@@ -396,7 +396,7 @@ find_latest_squash () {
396 ;;
397 git-subtree-split:)
398 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"
400 ;;
401 END)
402 if test -n "$sub"
@@ -448,7 +448,7 @@ find_existing_splits () {
448 ;;
449 git-subtree-split:)
450 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"
452 ;;
453 END)
454 debug "Main is: '$main'"
@@ -498,7 +498,7 @@ copy_commit () {
498 cat
499 ) |
500 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"
502 }
503
504 # Usage: add_msg DIR LATEST_OLD LATEST_NEW
@@ -726,11 +726,11 @@ ensure_clean () {
726 assert test $# = 0
727 if ! git diff-index HEAD --exit-code --quiet 2>&1
728 then
729 - die "Working tree has modifications. Cannot add."
729 + die "fatal: working tree has modifications. Cannot add."
730 fi
731 if ! git diff-index --cached HEAD --exit-code --quiet 2>&1
732 then
733 - die "Index has modifications. Cannot add."
733 + die "fatal: index has modifications. Cannot add."
734 fi
735 }
736
@@ -738,7 +738,7 @@ ensure_clean () {
738 ensure_valid_ref_format () {
739 assert test $# = 1
740 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"
742 }
743
744 # Usage: process_split_commit REV PARENTS
@@ -804,7 +804,7 @@ cmd_add () {
804 if test $# -eq 1
805 then
806 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"
808
809 cmd_add_commit "$@"
810
@@ -819,7 +819,7 @@ cmd_add () {
819
820 cmd_add_repository "$@"
821 else
822 - say >&2 "error: parameters were '$*'"
822 + say >&2 "fatal: parameters were '$*'"
823 die "Provide either a commit or a repository and commit."
824 fi
825 }
@@ -882,9 +882,9 @@ cmd_split () {
882 elif test $# -eq 1
883 then
884 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"
886 else
887 - die "You must provide exactly one revision. Got: '$*'"
887 + die "fatal: you must provide exactly one revision. Got: '$*'"
888 fi
889
890 if test -n "$arg_split_rejoin"
@@ -927,7 +927,7 @@ cmd_split () {
927 latest_new=$(cache_get latest_new) || exit $?
928 if test -z "$latest_new"
929 then
930 - die "No new revisions were found"
930 + die "fatal: no new revisions were found"
931 fi
932
933 if test -n "$arg_split_rejoin"
@@ -948,7 +948,7 @@ cmd_split () {
948 then
949 if ! git merge-base --is-ancestor "$arg_split_branch" "$latest_new"
950 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'."
952 fi
953 action='Updated'
954 else
@@ -965,9 +965,9 @@ cmd_split () {
965 # Usage: cmd_merge REV
966 cmd_merge () {
967 test $# -eq 1 ||
968 - die "You must provide exactly one revision. Got: '$*'"
968 + die "fatal: you must provide exactly one revision. Got: '$*'"
969 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"
971 ensure_clean
972
973 if test -n "$arg_addmerge_squash"
@@ -975,7 +975,7 @@ cmd_merge () {
975 first_split="$(find_latest_squash "$dir")" || exit $?
976 if test -z "$first_split"
977 then
978 - die "Can't squash-merge: '$dir' was never added."
978 + die "fatal: can't squash-merge: '$dir' was never added."
979 fi
980 set $first_split
981 old=$1
@@ -1003,7 +1003,7 @@ cmd_merge () {
1003 cmd_pull () {
1004 if test $# -ne 2
1005 then
1006 - die "You must provide <repository> <ref>"
1006 + die "fatal: you must provide <repository> <ref>"
1007 fi
1008 ensure_clean
1009 ensure_valid_ref_format "$2"
@@ -1015,7 +1015,7 @@ cmd_pull () {
1015 cmd_push () {
1016 if test $# -ne 2
1017 then
1018 - die "You must provide <repository> <refspec>"
1018 + die "fatal: you must provide <repository> <refspec>"
1019 fi
1020 if test -e "$dir"
1021 then
@@ -1030,13 +1030,13 @@ cmd_push () {
1030 fi
1031 ensure_valid_ref_format "$remoteref"
1032 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"
1034
1035 echo "git push using: " "$repository" "$refspec"
1036 localrev=$(cmd_split "$localrev_presplit") || die
1037 git push "$repository" "$localrev":"refs/heads/$remoteref"
1038 else
1039 - die "'$dir' must already exist. Try 'git subtree add'."
1039 + die "fatal: '$dir' must already exist. Try 'git subtree add'."
1040 fi
1041 }
1042
contrib/subtree/t/t7900-subtree.sh
+6 -6
@@ -277,7 +277,7 @@ test_expect_success 'split requires option --prefix' '
277 cd "$test_count" &&
278 git fetch ./"sub proj" HEAD &&
279 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 &&
281 test_must_fail git subtree split >actual 2>&1 &&
282 test_debug "printf '"expected: "'" &&
283 test_debug "cat expected" &&
@@ -296,7 +296,7 @@ test_expect_success 'split requires path given by option --prefix must exist' '
296 cd "$test_count" &&
297 git fetch ./"sub proj" HEAD &&
298 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 &&
300 test_must_fail git subtree split --prefix=non-existent-directory >actual 2>&1 &&
301 test_debug "printf '"expected: "'" &&
302 test_debug "cat expected" &&
@@ -570,7 +570,7 @@ test_expect_success 'pull requires option --prefix' '
570 cd "$test_count" &&
571 test_must_fail git subtree pull ./"sub proj" HEAD >out 2>err &&
572
573 - echo "You must provide the --prefix option." >expected &&
573 + echo "fatal: you must provide the --prefix option." >expected &&
574 test_must_be_empty out &&
575 test_cmp expected err
576 )
@@ -584,7 +584,7 @@ test_expect_success 'pull requires path given by option --prefix must exist' '
584 (
585 test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD >out 2>err &&
586
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 &&
588 test_must_be_empty out &&
589 test_cmp expected err
590 )
@@ -643,7 +643,7 @@ test_expect_success 'push requires option --prefix' '
643 cd "$test_count" &&
644 git fetch ./"sub proj" HEAD &&
645 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 &&
647 test_must_fail git subtree push "./sub proj" from-mainline >actual 2>&1 &&
648 test_debug "printf '"expected: "'" &&
649 test_debug "cat expected" &&
@@ -662,7 +662,7 @@ test_expect_success 'push requires path given by option --prefix must exist' '
662 cd "$test_count" &&
663 git fetch ./"sub proj" HEAD &&
664 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 &&
666 test_must_fail git subtree push --prefix=non-existent-directory "./sub proj" from-mainline >actual 2>&1 &&
667 test_debug "printf '"expected: "'" &&
668 test_debug "cat expected" &&