From: Miriam Rubio <mirucam@gmail.com>
To: git@vger.kernel.org
Cc: Tanushree Tumane <tanushreetumane@gmail.com>,
Christian Couder <chriscool@tuxfamily.org>,
Miriam Rubio <mirucam@gmail.com>
Subject: [PATCH v3 02/13] bisect--helper: change `retval` to `res`
Date: Sat, 8 Feb 2020 10:06:53 +0100 [thread overview]
Message-ID: <20200208090704.26506-3-mirucam@gmail.com> (raw)
In-Reply-To: <20200208090704.26506-1-mirucam@gmail.com>
From: Tanushree Tumane <tanushreetumane@gmail.com>
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>
---
builtin/bisect--helper.c | 52 ++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 36c09b7238..21de5c096c 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -206,31 +206,31 @@ static int bisect_write(const char *state, const char *rev,
struct object_id oid;
struct commit *commit;
FILE *fp = NULL;
- int retval = 0;
+ int res = 0;
if (!strcmp(state, terms->term_bad)) {
strbuf_addf(&tag, "refs/bisect/%s", state);
} else if (one_of(state, terms->term_good, "skip", NULL)) {
strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev);
} else {
- retval = error(_("Bad bisect_write argument: %s"), state);
+ res = error(_("Bad bisect_write argument: %s"), state);
goto finish;
}
if (get_oid(rev, &oid)) {
- retval = error(_("couldn't get the oid of the rev '%s'"), rev);
+ res = error(_("couldn't get the oid of the rev '%s'"), rev);
goto finish;
}
if (update_ref(NULL, tag.buf, &oid, NULL, 0,
UPDATE_REFS_MSG_ON_ERR)) {
- retval = -1;
+ res = -1;
goto finish;
}
fp = fopen(git_path_bisect_log(), "a");
if (!fp) {
- retval = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log());
+ res = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log());
goto finish;
}
@@ -244,7 +244,7 @@ static int bisect_write(const char *state, const char *rev,
if (fp)
fclose(fp);
strbuf_release(&tag);
- return retval;
+ return res;
}
static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
@@ -294,7 +294,7 @@ static const char need_bisect_start_warning[] =
static int bisect_next_check(const struct bisect_terms *terms,
const char *current_term)
{
- int missing_good = 1, missing_bad = 1, retval = 0;
+ int missing_good = 1, missing_bad = 1, res = 0;
const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad);
const char *good_glob = xstrfmt("%s-*", terms->term_good);
@@ -308,7 +308,7 @@ static int bisect_next_check(const struct bisect_terms *terms,
goto finish;
if (!current_term) {
- retval = -1;
+ res = -1;
goto finish;
}
@@ -329,21 +329,21 @@ static int bisect_next_check(const struct bisect_terms *terms,
*/
yesno = git_prompt(_("Are you sure [Y/n]? "), PROMPT_ECHO);
if (starts_with(yesno, "N") || starts_with(yesno, "n"))
- retval = -1;
+ res = -1;
goto finish;
}
if (!is_empty_or_missing_file(git_path_bisect_start())) {
- retval = error(_(need_bad_and_good_revision_warning),
+ res = error(_(need_bad_and_good_revision_warning),
vocab_bad, vocab_good, vocab_bad, vocab_good);
} else {
- retval = error(_(need_bisect_start_warning),
+ res = error(_(need_bisect_start_warning),
vocab_good, vocab_bad, vocab_good, vocab_bad);
}
finish:
free((void *) good_glob);
free((void *) bad_ref);
- return retval;
+ return res;
}
static int get_terms(struct bisect_terms *terms)
@@ -397,7 +397,7 @@ static int bisect_terms(struct bisect_terms *terms, const char *option)
static int bisect_append_log_quoted(const char **argv)
{
- int retval = 0;
+ int res = 0;
FILE *fp = fopen(git_path_bisect_log(), "a");
struct strbuf orig_args = STRBUF_INIT;
@@ -405,25 +405,25 @@ static int bisect_append_log_quoted(const char **argv)
return -1;
if (fprintf(fp, "git bisect start") < 1) {
- retval = -1;
+ res = -1;
goto finish;
}
sq_quote_argv(&orig_args, argv);
if (fprintf(fp, "%s\n", orig_args.buf) < 1)
- retval = -1;
+ res = -1;
finish:
fclose(fp);
strbuf_release(&orig_args);
- return retval;
+ return res;
}
static int bisect_start(struct bisect_terms *terms, int no_checkout,
const char **argv, int argc)
{
int i, has_double_dash = 0, must_write_terms = 0, bad_seen = 0;
- int flags, pathspec_pos, retval = 0;
+ int flags, pathspec_pos, res = 0;
struct string_list revs = STRING_LIST_INIT_DUP;
struct string_list states = STRING_LIST_INIT_DUP;
struct strbuf start_head = STRBUF_INIT;
@@ -524,7 +524,7 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
argv_array_pushl(&argv, "checkout", start_head.buf,
"--", NULL);
if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
- retval = error(_("checking out '%s' failed."
+ res = error(_("checking out '%s' failed."
" Try 'git bisect start "
"<valid-branch>'."),
start_head.buf);
@@ -572,12 +572,12 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
if (no_checkout) {
if (get_oid(start_head.buf, &oid) < 0) {
- retval = error(_("invalid ref: '%s'"), start_head.buf);
+ res = error(_("invalid ref: '%s'"), start_head.buf);
goto finish;
}
if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
UPDATE_REFS_MSG_ON_ERR)) {
- retval = -1;
+ res = -1;
goto finish;
}
}
@@ -589,26 +589,26 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
for (i = 0; i < states.nr; i++)
if (bisect_write(states.items[i].string,
revs.items[i].string, terms, 1)) {
- retval = -1;
+ res = -1;
goto finish;
}
if (must_write_terms && write_terms(terms->term_bad,
terms->term_good)) {
- retval = -1;
+ res = -1;
goto finish;
}
- retval = bisect_append_log_quoted(argv);
- if (retval)
- retval = -1;
+ res = bisect_append_log_quoted(argv);
+ if (res)
+ res = -1;
finish:
string_list_clear(&revs, 0);
string_list_clear(&states, 0);
strbuf_release(&start_head);
strbuf_release(&bisect_names);
- return retval;
+ return res;
}
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
--
2.25.0
next prev parent reply other threads:[~2020-02-08 9:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-08 9:06 [Outreachy] [PATCH v3 00/13] Finish converting git bisect to C part 1 Miriam Rubio
2020-02-08 9:06 ` [PATCH v3 01/13] bisect--helper: convert `vocab_*` char pointers to char arrays Miriam Rubio
2020-02-08 9:06 ` Miriam Rubio [this message]
2020-02-08 9:06 ` [PATCH v3 03/13] bisect: use the standard 'if (!var)' way to check for 0 Miriam Rubio
2020-02-08 9:06 ` [PATCH v3 04/13] run-command: make `exists_in_PATH()` non-static Miriam Rubio
2020-02-08 10:55 ` René Scharfe
2020-02-09 9:59 ` Miriam R.
[not found] ` <CAN7CjDC46xTHBxvkbWvYfUt91Z6sdPP1tT3rJBoc4x6QCrv+2A@mail.gmail.com>
[not found] ` <47b51655-6373-0d5f-1397-8cbbb73d6661@web.de>
2020-02-10 16:05 ` Miriam R.
2020-02-09 23:16 ` Taylor Blau
2020-02-08 9:06 ` [PATCH v3 05/13] bisect--helper: introduce new `decide_next()` function Miriam Rubio
2020-02-08 9:06 ` [PATCH v3 06/13] bisect: add enum to represent bisect returning codes Miriam Rubio
2020-02-08 9:06 ` [PATCH v3 07/13] bisect--helper: return error codes from `cmd_bisect__helper()` Miriam Rubio
2020-02-08 9:06 ` [PATCH v3 08/13] bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependents Miriam Rubio
2020-02-08 9:07 ` [PATCH v3 09/13] bisect: libify `bisect_checkout` Miriam Rubio
2020-02-08 9:07 ` [PATCH v3 10/13] bisect: libify `check_merge_bases` and its dependents Miriam Rubio
2020-02-08 9:07 ` [PATCH v3 11/13] bisect: libify `check_good_are_ancestors_of_bad` " Miriam Rubio
2020-02-08 9:07 ` [PATCH v3 12/13] bisect: libify `handle_bad_merge_base` " Miriam Rubio
2020-02-08 9:07 ` [PATCH v3 13/13] bisect: libify `bisect_next_all` Miriam Rubio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200208090704.26506-3-mirucam@gmail.com \
--to=mirucam@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=tanushreetumane@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).