bisect--helper: change `retval` to `res`
Let's rename variable retval to res, so that variable names in bisect--helper.c are more consistent. After this change, there are 110 occurrences of res in the file and zero of retval, while there were 26 instances of retval before. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com> Signed-off-by: Miriam Rubio <mirucam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tanushree Tumane committed
Feb 17, 2020 at 09:40 UTC
292731c4c24bce5c9e3bdc7a246cfbc565ab93a1
1 file changed
+26
-26
builtin/bisect--helper.c
+26
-26
@@ -206,31 +206,31 @@ static int bisect_write(const char *state, const char *rev,
206
struct object_id oid;
207
struct commit *commit;
208
FILE *fp = NULL;
209
- int retval = 0;
209
+ int res = 0;
210
211
if (!strcmp(state, terms->term_bad)) {
212
strbuf_addf(&tag, "refs/bisect/%s", state);
213
} else if (one_of(state, terms->term_good, "skip", NULL)) {
214
strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev);
215
} else {
216
- retval = error(_("Bad bisect_write argument: %s"), state);
216
+ res = error(_("Bad bisect_write argument: %s"), state);
217
goto finish;
218
}
219
220
if (get_oid(rev, &oid)) {
221
- retval = error(_("couldn't get the oid of the rev '%s'"), rev);
221
+ res = error(_("couldn't get the oid of the rev '%s'"), rev);
222
goto finish;
223
}
224
225
if (update_ref(NULL, tag.buf, &oid, NULL, 0,
226
UPDATE_REFS_MSG_ON_ERR)) {
227
- retval = -1;
227
+ res = -1;
228
goto finish;
229
}
230
231
fp = fopen(git_path_bisect_log(), "a");
232
if (!fp) {
233
- retval = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log());
233
+ res = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log());
234
goto finish;
235
}
236
@@ -244,7 +244,7 @@ finish:
244
if (fp)
245
fclose(fp);
246
strbuf_release(&tag);
247
- return retval;
247
+ return res;
248
}
249
250
static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
@@ -294,7 +294,7 @@ static const char need_bisect_start_warning[] =
294
static int bisect_next_check(const struct bisect_terms *terms,
295
const char *current_term)
296
{
297
- int missing_good = 1, missing_bad = 1, retval = 0;
297
+ int missing_good = 1, missing_bad = 1, res = 0;
298
const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
299
const char *good_glob = xstrfmt("%s-*", terms->term_good);
300
@@ -308,7 +308,7 @@ static int bisect_next_check(const struct bisect_terms *terms,
308
goto finish;
309
310
if (!current_term) {
311
- retval = -1;
311
+ res = -1;
312
goto finish;
313
}
314
@@ -329,21 +329,21 @@ static int bisect_next_check(const struct bisect_terms *terms,
329
*/
330
yesno = git_prompt(_("Are you sure [Y/n]? "), PROMPT_ECHO);
331
if (starts_with(yesno, "N") || starts_with(yesno, "n"))
332
- retval = -1;
332
+ res = -1;
333
goto finish;
334
}
335
if (!is_empty_or_missing_file(git_path_bisect_start())) {
336
- retval = error(_(need_bad_and_good_revision_warning),
336
+ res = error(_(need_bad_and_good_revision_warning),
337
vocab_bad, vocab_good, vocab_bad, vocab_good);
338
} else {
339
- retval = error(_(need_bisect_start_warning),
339
+ res = error(_(need_bisect_start_warning),
340
vocab_good, vocab_bad, vocab_good, vocab_bad);
341
}
342
343
finish:
344
free((void *) good_glob);
345
free((void *) bad_ref);
346
- return retval;
346
+ return res;
347
}
348
349
static int get_terms(struct bisect_terms *terms)
@@ -397,7 +397,7 @@ static int bisect_terms(struct bisect_terms *terms, const char *option)
397
398
static int bisect_append_log_quoted(const char **argv)
399
{
400
- int retval = 0;
400
+ int res = 0;
401
FILE *fp = fopen(git_path_bisect_log(), "a");
402
struct strbuf orig_args = STRBUF_INIT;
403
@@ -405,25 +405,25 @@ static int bisect_append_log_quoted(const char **argv)
405
return -1;
406
407
if (fprintf(fp, "git bisect start") < 1) {
408
- retval = -1;
408
+ res = -1;
409
goto finish;
410
}
411
412
sq_quote_argv(&orig_args, argv);
413
if (fprintf(fp, "%s\n", orig_args.buf) < 1)
414
- retval = -1;
414
+ res = -1;
415
416
finish:
417
fclose(fp);
418
strbuf_release(&orig_args);
419
- return retval;
419
+ return res;
420
}
421
422
static int bisect_start(struct bisect_terms *terms, int no_checkout,
423
const char **argv, int argc)
424
{
425
int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
426
- int flags, pathspec_pos, retval = 0;
426
+ int flags, pathspec_pos, res = 0;
427
struct string_list revs = STRING_LIST_INIT_DUP;
428
struct string_list states = STRING_LIST_INIT_DUP;
429
struct strbuf start_head = STRBUF_INIT;
@@ -524,7 +524,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
524
argv_array_pushl(&argv, "checkout", start_head.buf,
525
"--", NULL);
526
if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
527
- retval = error(_("checking out '%s' failed."
527
+ res = error(_("checking out '%s' failed."
528
" Try 'git bisect start "
529
"<valid-branch>'."),
530
start_head.buf);
@@ -572,12 +572,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
572
573
if (no_checkout) {
574
if (get_oid(start_head.buf, &oid) < 0) {
575
- retval = error(_("invalid ref: '%s'"), start_head.buf);
575
+ res = error(_("invalid ref: '%s'"), start_head.buf);
576
goto finish;
577
}
578
if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
579
UPDATE_REFS_MSG_ON_ERR)) {
580
- retval = -1;
580
+ res = -1;
581
goto finish;
582
}
583
}
@@ -589,26 +589,26 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
589
for (i = 0; i < states.nr; i++)
590
if (bisect_write(states.items[i].string,
591
revs.items[i].string, terms, 1)) {
592
- retval = -1;
592
+ res = -1;
593
goto finish;
594
}
595
596
if (must_write_terms && write_terms(terms->term_bad,
597
terms->term_good)) {
598
- retval = -1;
598
+ res = -1;
599
goto finish;
600
}
601
602
- retval = bisect_append_log_quoted(argv);
603
- if (retval)
604
- retval = -1;
602
+ res = bisect_append_log_quoted(argv);
603
+ if (res)
604
+ res = -1;
605
606
finish:
607
string_list_clear(&revs, 0);
608
string_list_clear(&states, 0);
609
strbuf_release(&start_head);
610
strbuf_release(&bisect_names);
611
- return retval;
611
+ return res;
612
}
613
614
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)