builtin/branch.c: adjust error messages to coding guidelines

As per the CodingGuidelines document, it is recommended that error messages such as die(), error() and warning(), should start with a lowercase letter and should not end with a period. This patch adjusts tests to match updated messages. Signed-off-by: Isoken June Ibizugbe <isokenjune@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Isoken June Ibizugbe committed Oct 23, 2023 at 17:06 UTC 12b99928c8fc85a2500f34ef4f492b427b13f088
4 files changed +47 -47
builtin/branch.c
+33 -33
@@ -173,11 +173,11 @@ static int branch_merged(int kind, const char *name,
173 (head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) {
174 if (merged)
175 warning(_("deleting branch '%s' that has been merged to\n"
176 - " '%s', but not yet merged to HEAD."),
176 + " '%s', but not yet merged to HEAD"),
177 name, reference_name);
178 else
179 warning(_("not deleting branch '%s' that is not yet merged to\n"
180 - " '%s', even though it is merged to HEAD."),
180 + " '%s', even though it is merged to HEAD"),
181 name, reference_name);
182 }
183 free(reference_name_to_free);
@@ -190,13 +190,13 @@ static int check_branch_commit(const char *branchname, const char *refname,
190 {
191 struct commit *rev = lookup_commit_reference(the_repository, oid);
192 if (!force && !rev) {
193 - error(_("Couldn't look up commit object for '%s'"), refname);
193 + error(_("couldn't look up commit object for '%s'"), refname);
194 return -1;
195 }
196 if (!force && !branch_merged(kinds, branchname, rev, head_rev)) {
197 - error(_("The branch '%s' is not fully merged.\n"
197 + error(_("the branch '%s' is not fully merged.\n"
198 "If you are sure you want to delete it, "
199 - "run 'git branch -D %s'."), branchname, branchname);
199 + "run 'git branch -D %s'"), branchname, branchname);
200 return -1;
201 }
202 return 0;
@@ -207,7 +207,7 @@ static void delete_branch_config(const char *branchname)
207 struct strbuf buf = STRBUF_INIT;
208 strbuf_addf(&buf, "branch.%s", branchname);
209 if (git_config_rename_section(buf.buf, NULL) < 0)
210 - warning(_("Update of config-file failed"));
210 + warning(_("update of config-file failed"));
211 strbuf_release(&buf);
212 }
213
@@ -260,7 +260,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
260 if (kinds == FILTER_REFS_BRANCHES) {
261 const char *path;
262 if ((path = branch_checked_out(name))) {
263 - error(_("Cannot delete branch '%s' "
263 + error(_("cannot delete branch '%s' "
264 "used by worktree at '%s'"),
265 bname.buf, path);
266 ret = 1;
@@ -275,7 +275,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
275 &oid, &flags);
276 if (!target) {
277 if (remote_branch) {
278 - error(_("remote-tracking branch '%s' not found."), bname.buf);
278 + error(_("remote-tracking branch '%s' not found"), bname.buf);
279 } else {
280 char *virtual_name = mkpathdup(fmt_remotes, bname.buf);
281 char *virtual_target = resolve_refdup(virtual_name,
@@ -290,7 +290,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
290 "Did you forget --remote?"),
291 bname.buf);
292 else
293 - error(_("branch '%s' not found."), bname.buf);
293 + error(_("branch '%s' not found"), bname.buf);
294 FREE_AND_NULL(virtual_target);
295 }
296 ret = 1;
@@ -518,11 +518,11 @@ static void reject_rebase_or_bisect_branch(struct worktree **worktrees,
518 continue;
519
520 if (is_worktree_being_rebased(wt, target))
521 - die(_("Branch %s is being rebased at %s"),
521 + die(_("branch %s is being rebased at %s"),
522 target, wt->path);
523
524 if (is_worktree_being_bisected(wt, target))
525 - die(_("Branch %s is being bisected at %s"),
525 + die(_("branch %s is being bisected at %s"),
526 target, wt->path);
527 }
528 }
@@ -578,7 +578,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
578 if (ref_exists(oldref.buf))
579 recovery = 1;
580 else
581 - die(_("Invalid branch name: '%s'"), oldname);
581 + die(_("invalid branch name: '%s'"), oldname);
582 }
583
584 for (int i = 0; worktrees[i]; i++) {
@@ -594,9 +594,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
594
595 if ((copy || !(oldref_usage & IS_HEAD)) && !ref_exists(oldref.buf)) {
596 if (oldref_usage & IS_HEAD)
597 - die(_("No commit on branch '%s' yet."), oldname);
597 + die(_("no commit on branch '%s' yet"), oldname);
598 else
599 - die(_("No branch named '%s'."), oldname);
599 + die(_("no branch named '%s'"), oldname);
600 }
601
602 /*
@@ -624,32 +624,32 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
624
625 if (!copy && !(oldref_usage & IS_ORPHAN) &&
626 rename_ref(oldref.buf, newref.buf, logmsg.buf))
627 - die(_("Branch rename failed"));
627 + die(_("branch rename failed"));
628 if (copy && copy_existing_ref(oldref.buf, newref.buf, logmsg.buf))
629 - die(_("Branch copy failed"));
629 + die(_("branch copy failed"));
630
631 if (recovery) {
632 if (copy)
633 - warning(_("Created a copy of a misnamed branch '%s'"),
633 + warning(_("created a copy of a misnamed branch '%s'"),
634 interpreted_oldname);
635 else
636 - warning(_("Renamed a misnamed branch '%s' away"),
636 + warning(_("renamed a misnamed branch '%s' away"),
637 interpreted_oldname);
638 }
639
640 if (!copy && (oldref_usage & IS_HEAD) &&
641 replace_each_worktree_head_symref(worktrees, oldref.buf, newref.buf,
642 logmsg.buf))
643 - die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
643 + die(_("branch renamed to %s, but HEAD is not updated"), newname);
644
645 strbuf_release(&logmsg);
646
647 strbuf_addf(&oldsection, "branch.%s", interpreted_oldname);
648 strbuf_addf(&newsection, "branch.%s", interpreted_newname);
649 if (!copy && git_config_rename_section(oldsection.buf, newsection.buf) < 0)
650 - die(_("Branch is renamed, but update of config-file failed"));
650 + die(_("branch is renamed, but update of config-file failed"));
651 if (copy && strcmp(interpreted_oldname, interpreted_newname) && git_config_copy_section(oldsection.buf, newsection.buf) < 0)
652 - die(_("Branch is copied, but update of config-file failed"));
652 + die(_("branch is copied, but update of config-file failed"));
653 strbuf_release(&oldref);
654 strbuf_release(&newref);
655 strbuf_release(&oldsection);
@@ -773,7 +773,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
773
774 head = resolve_refdup("HEAD", 0, &head_oid, NULL);
775 if (!head)
776 - die(_("Failed to resolve HEAD as a valid ref."));
776 + die(_("failed to resolve HEAD as a valid ref"));
777 if (!strcmp(head, "HEAD"))
778 filter.detached = 1;
779 else if (!skip_prefix(head, "refs/heads/", &head))
@@ -866,7 +866,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
866
867 if (!argc) {
868 if (filter.detached)
869 - die(_("Cannot give description to detached HEAD"));
869 + die(_("cannot give description to detached HEAD"));
870 branch_name = head;
871 } else if (argc == 1) {
872 strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
@@ -878,8 +878,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
878 strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
879 if (!ref_exists(branch_ref.buf))
880 error((!argc || branch_checked_out(branch_ref.buf))
881 - ? _("No commit on branch '%s' yet.")
882 - : _("No branch named '%s'."),
881 + ? _("no commit on branch '%s' yet")
882 + : _("no branch named '%s'"),
883 branch_name);
884 else if (!edit_branch_description(branch_name))
885 ret = 0; /* happy */
@@ -892,8 +892,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
892 if (!argc)
893 die(_("branch name required"));
894 else if ((argc == 1) && filter.detached)
895 - die(copy? _("cannot copy the current branch while not on any.")
896 - : _("cannot rename the current branch while not on any."));
895 + die(copy? _("cannot copy the current branch while not on any")
896 + : _("cannot rename the current branch while not on any"));
897 else if (argc == 1)
898 copy_or_rename_branch(head, argv[0], copy, copy + rename > 1);
899 else if (argc == 2)
@@ -916,14 +916,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
916 if (!branch) {
917 if (!argc || !strcmp(argv[0], "HEAD"))
918 die(_("could not set upstream of HEAD to %s when "
919 - "it does not point to any branch."),
919 + "it does not point to any branch"),
920 new_upstream);
921 die(_("no such branch '%s'"), argv[0]);
922 }
923
924 if (!ref_exists(branch->refname)) {
925 if (!argc || branch_checked_out(branch->refname))
926 - die(_("No commit on branch '%s' yet."), branch->name);
926 + die(_("no commit on branch '%s' yet"), branch->name);
927 die(_("branch '%s' does not exist"), branch->name);
928 }
929
@@ -946,12 +946,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
946 if (!branch) {
947 if (!argc || !strcmp(argv[0], "HEAD"))
948 die(_("could not unset upstream of HEAD when "
949 - "it does not point to any branch."));
949 + "it does not point to any branch"));
950 die(_("no such branch '%s'"), argv[0]);
951 }
952
953 if (!branch_has_merge_config(branch))
954 - die(_("Branch '%s' has no upstream information"), branch->name);
954 + die(_("branch '%s' has no upstream information"), branch->name);
955
956 strbuf_reset(&buf);
957 strbuf_addf(&buf, "branch.%s.remote", branch->name);
@@ -965,11 +965,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
965 const char *start_name = argc == 2 ? argv[1] : head;
966
967 if (filter.kind != FILTER_REFS_BRANCHES)
968 - die(_("The -a, and -r, options to 'git branch' do not take a branch name.\n"
968 + die(_("the -a, and -r, options to 'git branch' do not take a branch name.\n"
969 "Did you mean to use: -a|-r --list <pattern>?"));
970
971 if (track == BRANCH_TRACK_OVERRIDE)
972 - die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead."));
972 + die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead"));
973
974 if (recurse_submodules) {
975 create_branches_recursively(the_repository, branch_name,
t/t2407-worktree-heads.sh
+1 -1
@@ -45,7 +45,7 @@ test_expect_success 'refuse to overwrite: checked out in worktree' '
45 grep "cannot force update the branch" err &&
46
47 test_must_fail git branch -D wt-$i 2>err &&
48 - grep "Cannot delete branch" err || return 1
48 + grep "cannot delete branch" err || return 1
49 done
50 '
51
t/t3200-branch.sh
+8 -8
@@ -291,10 +291,10 @@ test_expect_success 'git branch -M topic topic should work when main is checked
291 test_expect_success 'git branch -M and -C fail on detached HEAD' '
292 git checkout HEAD^{} &&
293 test_when_finished git checkout - &&
294 - echo "fatal: cannot rename the current branch while not on any." >expect &&
294 + echo "fatal: cannot rename the current branch while not on any" >expect &&
295 test_must_fail git branch -M must-fail 2>err &&
296 test_cmp expect err &&
297 - echo "fatal: cannot copy the current branch while not on any." >expect &&
297 + echo "fatal: cannot copy the current branch while not on any" >expect &&
298 test_must_fail git branch -C must-fail 2>err &&
299 test_cmp expect err
300 '
@@ -943,7 +943,7 @@ test_expect_success 'deleting currently checked out branch fails' '
943 git worktree add -b my7 my7 &&
944 test_must_fail git -C my7 branch -d my7 &&
945 test_must_fail git branch -d my7 2>actual &&
946 - grep "^error: Cannot delete branch .my7. used by worktree at " actual &&
946 + grep "^error: cannot delete branch .my7. used by worktree at " actual &&
947 rm -r my7 &&
948 git worktree prune
949 '
@@ -954,7 +954,7 @@ test_expect_success 'deleting in-use branch fails' '
954 git -C my7 bisect start HEAD HEAD~2 &&
955 test_must_fail git -C my7 branch -d my7 &&
956 test_must_fail git branch -d my7 2>actual &&
957 - grep "^error: Cannot delete branch .my7. used by worktree at " actual &&
957 + grep "^error: cannot delete branch .my7. used by worktree at " actual &&
958 rm -r my7 &&
959 git worktree prune
960 '
@@ -1024,7 +1024,7 @@ test_expect_success '--set-upstream-to fails on multiple branches' '
1024 test_expect_success '--set-upstream-to fails on detached HEAD' '
1025 git checkout HEAD^{} &&
1026 test_when_finished git checkout - &&
1027 - echo "fatal: could not set upstream of HEAD to main when it does not point to any branch." >expect &&
1027 + echo "fatal: could not set upstream of HEAD to main when it does not point to any branch" >expect &&
1028 test_must_fail git branch --set-upstream-to main 2>err &&
1029 test_cmp expect err
1030 '
@@ -1072,7 +1072,7 @@ test_expect_success 'use --set-upstream-to modify a particular branch' '
1072 '
1073
1074 test_expect_success '--unset-upstream should fail if given a non-existent branch' '
1075 - echo "fatal: Branch '"'"'i-dont-exist'"'"' has no upstream information" >expect &&
1075 + echo "fatal: branch '"'"'i-dont-exist'"'"' has no upstream information" >expect &&
1076 test_must_fail git branch --unset-upstream i-dont-exist 2>err &&
1077 test_cmp expect err
1078 '
@@ -1094,7 +1094,7 @@ test_expect_success 'test --unset-upstream on HEAD' '
1094 test_must_fail git config branch.main.remote &&
1095 test_must_fail git config branch.main.merge &&
1096 # fail for a branch without upstream set
1097 - echo "fatal: Branch '"'"'main'"'"' has no upstream information" >expect &&
1097 + echo "fatal: branch '"'"'main'"'"' has no upstream information" >expect &&
1098 test_must_fail git branch --unset-upstream 2>err &&
1099 test_cmp expect err
1100 '
@@ -1108,7 +1108,7 @@ test_expect_success '--unset-upstream should fail on multiple branches' '
1108 test_expect_success '--unset-upstream should fail on detached HEAD' '
1109 git checkout HEAD^{} &&
1110 test_when_finished git checkout - &&
1111 - echo "fatal: could not unset upstream of HEAD when it does not point to any branch." >expect &&
1111 + echo "fatal: could not unset upstream of HEAD when it does not point to any branch" >expect &&
1112 test_must_fail git branch --unset-upstream 2>err &&
1113 test_cmp expect err
1114 '
t/t3202-show-branch.sh
+5 -5
@@ -10,7 +10,7 @@ GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
10 test_expect_success 'error descriptions on empty repository' '
11 current=$(git branch --show-current) &&
12 cat >expect <<-EOF &&
13 - error: No commit on branch '\''$current'\'' yet.
13 + error: no commit on branch '\''$current'\'' yet
14 EOF
15 test_must_fail git branch --edit-description 2>actual &&
16 test_cmp expect actual &&
@@ -21,7 +21,7 @@ test_expect_success 'error descriptions on empty repository' '
21 test_expect_success 'fatal descriptions on empty repository' '
22 current=$(git branch --show-current) &&
23 cat >expect <<-EOF &&
24 - fatal: No commit on branch '\''$current'\'' yet.
24 + fatal: no commit on branch '\''$current'\'' yet
25 EOF
26 test_must_fail git branch --set-upstream-to=non-existent 2>actual &&
27 test_cmp expect actual &&
@@ -224,7 +224,7 @@ done
224
225 test_expect_success 'error descriptions on non-existent branch' '
226 cat >expect <<-EOF &&
227 - error: No branch named '\''non-existent'\'.'
227 + error: no branch named '\''non-existent'\''
228 EOF
229 test_must_fail git branch --edit-description non-existent 2>actual &&
230 test_cmp expect actual
@@ -238,7 +238,7 @@ test_expect_success 'fatal descriptions on non-existent branch' '
238 test_cmp expect actual &&
239
240 cat >expect <<-EOF &&
241 - fatal: No branch named '\''non-existent'\''.
241 + fatal: no branch named '\''non-existent'\''
242 EOF
243 test_must_fail git branch -c non-existent new-branch 2>actual &&
244 test_cmp expect actual &&
@@ -253,7 +253,7 @@ test_expect_success 'error descriptions on orphan branch' '
253 test_branch_op_in_wt() {
254 test_orphan_error() {
255 test_must_fail git $* 2>actual &&
256 - test_i18ngrep "No commit on branch .orphan-branch. yet.$" actual
256 + test_i18ngrep "no commit on branch .orphan-branch. yet$" actual
257 } &&
258 test_orphan_error -C wt branch $1 $2 && # implicit branch
259 test_orphan_error -C wt branch $1 orphan-branch $2 && # explicit branch