Skip to content

Commit cab5398

Browse files
avargitster
authored andcommitted
remote.c: add braces in anticipation of a follow-up change
The CodingGuidelines say "When there are multiple arms to a conditional and some of them require braces, enclose even a single line block in braces for consistency.". Fix the code in match_explicit() to conform. While I'm at it change the if/else if/else in guess_ref() to use braces. This is not currently needed, but a follow-up change will add a new multi-line condition to that logic. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d166e6a commit cab5398

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

remote.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,12 +968,13 @@ static char *guess_ref(const char *name, struct ref *peer)
968968
if (!r)
969969
return NULL;
970970

971-
if (starts_with(r, "refs/heads/"))
971+
if (starts_with(r, "refs/heads/")) {
972972
strbuf_addstr(&buf, "refs/heads/");
973-
else if (starts_with(r, "refs/tags/"))
973+
} else if (starts_with(r, "refs/tags/")) {
974974
strbuf_addstr(&buf, "refs/tags/");
975-
else
975+
} else {
976976
return NULL;
977+
}
977978

978979
strbuf_addstr(&buf, name);
979980
return strbuf_detach(&buf, NULL);
@@ -1038,21 +1039,22 @@ static int match_explicit(struct ref *src, struct ref *dst,
10381039
case 1:
10391040
break;
10401041
case 0:
1041-
if (starts_with(dst_value, "refs/"))
1042+
if (starts_with(dst_value, "refs/")) {
10421043
matched_dst = make_linked_ref(dst_value, dst_tail);
1043-
else if (is_null_oid(&matched_src->new_oid))
1044+
} else if (is_null_oid(&matched_src->new_oid)) {
10441045
error("unable to delete '%s': remote ref does not exist",
10451046
dst_value);
1046-
else if ((dst_guess = guess_ref(dst_value, matched_src))) {
1047+
} else if ((dst_guess = guess_ref(dst_value, matched_src))) {
10471048
matched_dst = make_linked_ref(dst_guess, dst_tail);
10481049
free(dst_guess);
1049-
} else
1050+
} else {
10501051
error("unable to push to unqualified destination: %s\n"
10511052
"The destination refspec neither matches an "
10521053
"existing ref on the remote nor\n"
10531054
"begins with refs/, and we are unable to "
10541055
"guess a prefix based on the source ref.",
10551056
dst_value);
1057+
}
10561058
break;
10571059
default:
10581060
matched_dst = NULL;

0 commit comments

Comments
 (0)