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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Nov 13, 2018 at 19:52 UTC
cab53989f619abb08268a149b137567e8442a3ed
1 file changed
+9
-7
remote.c
+9
-7
@@ -968,12 +968,13 @@ static char *guess_ref(const char *name, struct ref *peer)
968
if (!r)
969
return NULL;
970
971
- if (starts_with(r, "refs/heads/"))
971
+ if (starts_with(r, "refs/heads/")) {
972
strbuf_addstr(&buf, "refs/heads/");
973
- else if (starts_with(r, "refs/tags/"))
973
+ } else if (starts_with(r, "refs/tags/")) {
974
strbuf_addstr(&buf, "refs/tags/");
975
- else
975
+ } else {
976
return NULL;
977
+ }
978
979
strbuf_addstr(&buf, name);
980
return strbuf_detach(&buf, NULL);
@@ -1038,21 +1039,22 @@ static int match_explicit(struct ref *src, struct ref *dst,
1039
case 1:
1040
break;
1041
case 0:
1041
- if (starts_with(dst_value, "refs/"))
1042
+ if (starts_with(dst_value, "refs/")) {
1043
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)) {
1045
error("unable to delete '%s': remote ref does not exist",
1046
dst_value);
1046
- else if ((dst_guess = guess_ref(dst_value, matched_src))) {
1047
+ } else if ((dst_guess = guess_ref(dst_value, matched_src))) {
1048
matched_dst = make_linked_ref(dst_guess, dst_tail);
1049
free(dst_guess);
1049
- } else
1050
+ } else {
1051
error("unable to push to unqualified destination: %s\n"
1052
"The destination refspec neither matches an "
1053
"existing ref on the remote nor\n"
1054
"begins with refs/, and we are unable to "
1055
"guess a prefix based on the source ref.",
1056
dst_value);
1057
+ }
1058
break;
1059
default:
1060
matched_dst = NULL;