Skip to content

Commit ece5489

Browse files
committed
Merge branch 'ii/branch-error-messages-update'
Error message update. * ii/branch-error-messages-update: builtin/branch.c: adjust error messages to coding guidelines
2 parents 3130c15 + 12b9992 commit ece5489

File tree

4 files changed

+47
-47
lines changed

4 files changed

+47
-47
lines changed

builtin/branch.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ static int branch_merged(int kind, const char *name,
173173
(head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) {
174174
if (merged)
175175
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"),
177177
name, reference_name);
178178
else
179179
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"),
181181
name, reference_name);
182182
}
183183
free(reference_name_to_free);
@@ -190,13 +190,13 @@ static int check_branch_commit(const char *branchname, const char *refname,
190190
{
191191
struct commit *rev = lookup_commit_reference(the_repository, oid);
192192
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);
194194
return -1;
195195
}
196196
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"
198198
"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);
200200
return -1;
201201
}
202202
return 0;
@@ -207,7 +207,7 @@ static void delete_branch_config(const char *branchname)
207207
struct strbuf buf = STRBUF_INIT;
208208
strbuf_addf(&buf, "branch.%s", branchname);
209209
if (git_config_rename_section(buf.buf, NULL) < 0)
210-
warning(_("Update of config-file failed"));
210+
warning(_("update of config-file failed"));
211211
strbuf_release(&buf);
212212
}
213213

@@ -260,7 +260,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
260260
if (kinds == FILTER_REFS_BRANCHES) {
261261
const char *path;
262262
if ((path = branch_checked_out(name))) {
263-
error(_("Cannot delete branch '%s' "
263+
error(_("cannot delete branch '%s' "
264264
"used by worktree at '%s'"),
265265
bname.buf, path);
266266
ret = 1;
@@ -275,7 +275,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
275275
&oid, &flags);
276276
if (!target) {
277277
if (remote_branch) {
278-
error(_("remote-tracking branch '%s' not found."), bname.buf);
278+
error(_("remote-tracking branch '%s' not found"), bname.buf);
279279
} else {
280280
char *virtual_name = mkpathdup(fmt_remotes, bname.buf);
281281
char *virtual_target = resolve_refdup(virtual_name,
@@ -290,7 +290,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
290290
"Did you forget --remote?"),
291291
bname.buf);
292292
else
293-
error(_("branch '%s' not found."), bname.buf);
293+
error(_("branch '%s' not found"), bname.buf);
294294
FREE_AND_NULL(virtual_target);
295295
}
296296
ret = 1;
@@ -518,11 +518,11 @@ static void reject_rebase_or_bisect_branch(struct worktree **worktrees,
518518
continue;
519519

520520
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"),
522522
target, wt->path);
523523

524524
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"),
526526
target, wt->path);
527527
}
528528
}
@@ -578,7 +578,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
578578
if (ref_exists(oldref.buf))
579579
recovery = 1;
580580
else
581-
die(_("Invalid branch name: '%s'"), oldname);
581+
die(_("invalid branch name: '%s'"), oldname);
582582
}
583583

584584
for (int i = 0; worktrees[i]; i++) {
@@ -594,9 +594,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
594594

595595
if ((copy || !(oldref_usage & IS_HEAD)) && !ref_exists(oldref.buf)) {
596596
if (oldref_usage & IS_HEAD)
597-
die(_("No commit on branch '%s' yet."), oldname);
597+
die(_("no commit on branch '%s' yet"), oldname);
598598
else
599-
die(_("No branch named '%s'."), oldname);
599+
die(_("no branch named '%s'"), oldname);
600600
}
601601

602602
/*
@@ -624,32 +624,32 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
624624

625625
if (!copy && !(oldref_usage & IS_ORPHAN) &&
626626
rename_ref(oldref.buf, newref.buf, logmsg.buf))
627-
die(_("Branch rename failed"));
627+
die(_("branch rename failed"));
628628
if (copy && copy_existing_ref(oldref.buf, newref.buf, logmsg.buf))
629-
die(_("Branch copy failed"));
629+
die(_("branch copy failed"));
630630

631631
if (recovery) {
632632
if (copy)
633-
warning(_("Created a copy of a misnamed branch '%s'"),
633+
warning(_("created a copy of a misnamed branch '%s'"),
634634
interpreted_oldname);
635635
else
636-
warning(_("Renamed a misnamed branch '%s' away"),
636+
warning(_("renamed a misnamed branch '%s' away"),
637637
interpreted_oldname);
638638
}
639639

640640
if (!copy && (oldref_usage & IS_HEAD) &&
641641
replace_each_worktree_head_symref(worktrees, oldref.buf, newref.buf,
642642
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);
644644

645645
strbuf_release(&logmsg);
646646

647647
strbuf_addf(&oldsection, "branch.%s", interpreted_oldname);
648648
strbuf_addf(&newsection, "branch.%s", interpreted_newname);
649649
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"));
651651
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"));
653653
strbuf_release(&oldref);
654654
strbuf_release(&newref);
655655
strbuf_release(&oldsection);
@@ -773,7 +773,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
773773

774774
head = resolve_refdup("HEAD", 0, &head_oid, NULL);
775775
if (!head)
776-
die(_("Failed to resolve HEAD as a valid ref."));
776+
die(_("failed to resolve HEAD as a valid ref"));
777777
if (!strcmp(head, "HEAD"))
778778
filter.detached = 1;
779779
else if (!skip_prefix(head, "refs/heads/", &head))
@@ -866,7 +866,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
866866

867867
if (!argc) {
868868
if (filter.detached)
869-
die(_("Cannot give description to detached HEAD"));
869+
die(_("cannot give description to detached HEAD"));
870870
branch_name = head;
871871
} else if (argc == 1) {
872872
strbuf_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
@@ -878,8 +878,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
878878
strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
879879
if (!ref_exists(branch_ref.buf))
880880
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'"),
883883
branch_name);
884884
else if (!edit_branch_description(branch_name))
885885
ret = 0; /* happy */
@@ -892,8 +892,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
892892
if (!argc)
893893
die(_("branch name required"));
894894
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"));
897897
else if (argc == 1)
898898
copy_or_rename_branch(head, argv[0], copy, copy + rename > 1);
899899
else if (argc == 2)
@@ -916,14 +916,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
916916
if (!branch) {
917917
if (!argc || !strcmp(argv[0], "HEAD"))
918918
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"),
920920
new_upstream);
921921
die(_("no such branch '%s'"), argv[0]);
922922
}
923923

924924
if (!ref_exists(branch->refname)) {
925925
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);
927927
die(_("branch '%s' does not exist"), branch->name);
928928
}
929929

@@ -946,12 +946,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
946946
if (!branch) {
947947
if (!argc || !strcmp(argv[0], "HEAD"))
948948
die(_("could not unset upstream of HEAD when "
949-
"it does not point to any branch."));
949+
"it does not point to any branch"));
950950
die(_("no such branch '%s'"), argv[0]);
951951
}
952952

953953
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);
955955

956956
strbuf_reset(&buf);
957957
strbuf_addf(&buf, "branch.%s.remote", branch->name);
@@ -965,11 +965,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
965965
const char *start_name = argc == 2 ? argv[1] : head;
966966

967967
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"
969969
"Did you mean to use: -a|-r --list <pattern>?"));
970970

971971
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"));
973973

974974
if (recurse_submodules) {
975975
create_branches_recursively(the_repository, branch_name,

t/t2407-worktree-heads.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test_expect_success 'refuse to overwrite: checked out in worktree' '
4545
grep "cannot force update the branch" err &&
4646
4747
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
4949
done
5050
'
5151

t/t3200-branch.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ test_expect_success 'git branch -M topic topic should work when main is checked
291291
test_expect_success 'git branch -M and -C fail on detached HEAD' '
292292
git checkout HEAD^{} &&
293293
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 &&
295295
test_must_fail git branch -M must-fail 2>err &&
296296
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 &&
298298
test_must_fail git branch -C must-fail 2>err &&
299299
test_cmp expect err
300300
'
@@ -943,7 +943,7 @@ test_expect_success 'deleting currently checked out branch fails' '
943943
git worktree add -b my7 my7 &&
944944
test_must_fail git -C my7 branch -d my7 &&
945945
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 &&
947947
rm -r my7 &&
948948
git worktree prune
949949
'
@@ -954,7 +954,7 @@ test_expect_success 'deleting in-use branch fails' '
954954
git -C my7 bisect start HEAD HEAD~2 &&
955955
test_must_fail git -C my7 branch -d my7 &&
956956
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 &&
958958
rm -r my7 &&
959959
git worktree prune
960960
'
@@ -1024,7 +1024,7 @@ test_expect_success '--set-upstream-to fails on multiple branches' '
10241024
test_expect_success '--set-upstream-to fails on detached HEAD' '
10251025
git checkout HEAD^{} &&
10261026
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 &&
10281028
test_must_fail git branch --set-upstream-to main 2>err &&
10291029
test_cmp expect err
10301030
'
@@ -1072,7 +1072,7 @@ test_expect_success 'use --set-upstream-to modify a particular branch' '
10721072
'
10731073

10741074
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 &&
10761076
test_must_fail git branch --unset-upstream i-dont-exist 2>err &&
10771077
test_cmp expect err
10781078
'
@@ -1094,7 +1094,7 @@ test_expect_success 'test --unset-upstream on HEAD' '
10941094
test_must_fail git config branch.main.remote &&
10951095
test_must_fail git config branch.main.merge &&
10961096
# 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 &&
10981098
test_must_fail git branch --unset-upstream 2>err &&
10991099
test_cmp expect err
11001100
'
@@ -1108,7 +1108,7 @@ test_expect_success '--unset-upstream should fail on multiple branches' '
11081108
test_expect_success '--unset-upstream should fail on detached HEAD' '
11091109
git checkout HEAD^{} &&
11101110
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 &&
11121112
test_must_fail git branch --unset-upstream 2>err &&
11131113
test_cmp expect err
11141114
'

t/t3202-show-branch.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
1010
test_expect_success 'error descriptions on empty repository' '
1111
current=$(git branch --show-current) &&
1212
cat >expect <<-EOF &&
13-
error: No commit on branch '\''$current'\'' yet.
13+
error: no commit on branch '\''$current'\'' yet
1414
EOF
1515
test_must_fail git branch --edit-description 2>actual &&
1616
test_cmp expect actual &&
@@ -21,7 +21,7 @@ test_expect_success 'error descriptions on empty repository' '
2121
test_expect_success 'fatal descriptions on empty repository' '
2222
current=$(git branch --show-current) &&
2323
cat >expect <<-EOF &&
24-
fatal: No commit on branch '\''$current'\'' yet.
24+
fatal: no commit on branch '\''$current'\'' yet
2525
EOF
2626
test_must_fail git branch --set-upstream-to=non-existent 2>actual &&
2727
test_cmp expect actual &&
@@ -224,7 +224,7 @@ done
224224

225225
test_expect_success 'error descriptions on non-existent branch' '
226226
cat >expect <<-EOF &&
227-
error: No branch named '\''non-existent'\'.'
227+
error: no branch named '\''non-existent'\''
228228
EOF
229229
test_must_fail git branch --edit-description non-existent 2>actual &&
230230
test_cmp expect actual
@@ -238,7 +238,7 @@ test_expect_success 'fatal descriptions on non-existent branch' '
238238
test_cmp expect actual &&
239239
240240
cat >expect <<-EOF &&
241-
fatal: No branch named '\''non-existent'\''.
241+
fatal: no branch named '\''non-existent'\''
242242
EOF
243243
test_must_fail git branch -c non-existent new-branch 2>actual &&
244244
test_cmp expect actual &&
@@ -253,7 +253,7 @@ test_expect_success 'error descriptions on orphan branch' '
253253
test_branch_op_in_wt() {
254254
test_orphan_error() {
255255
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
257257
} &&
258258
test_orphan_error -C wt branch $1 $2 && # implicit branch
259259
test_orphan_error -C wt branch $1 orphan-branch $2 && # explicit branch

0 commit comments

Comments
 (0)