From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Git Mailing List" <git@vger.kernel.org>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Elijah Newren" <newren@gmail.com>,
"Duy Nguyen" <pclouds@gmail.com>,
"Alban Gruin" <alban.gruin@gmail.com>,
"Josh Steadmon" <steadmon@google.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Phillip Wood" <phillip.wood@dunelm.org.uk>,
"Jeff Hostetler" <git@jeffhostetler.com>
Subject: Re: [PATCH v1 02/12] rebase: don't translate trace strings
Date: Thu, 25 Apr 2019 18:47:09 +0100 [thread overview]
Message-ID: <41344c53-5b57-3d97-7b64-9128f7cba6af@gmail.com> (raw)
In-Reply-To: <xmqqy346czhj.fsf@gitster-ct.c.googlers.com>
On 19/04/2019 06:53, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>
>> commit b3a5d5a80c ("trace2:data: add subverb for rebase", 2019-02-22)
>> mistakenly marked the subverb names for translation and unnecessarily
>> NULL terminated the array.
>>
>> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
>> ---
>> builtin/rebase.c | 15 +++++++--------
>> 1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/builtin/rebase.c b/builtin/rebase.c
>> index 52114cbf0d..239a54ecfe 100644
>> --- a/builtin/rebase.c
>> +++ b/builtin/rebase.c
>> @@ -1027,14 +1027,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>> ACTION_EDIT_TODO,
>> ACTION_SHOW_CURRENT_PATCH,
>> } action = NO_ACTION;
>> - static const char *action_names[] = { N_("undefined"),
>> - N_("continue"),
>> - N_("skip"),
>> - N_("abort"),
>> - N_("quit"),
>> - N_("edit_todo"),
>> - N_("show_current_patch"),
>> - NULL };
>> + static const char *action_names[] = { "undefined",
>> + "continue",
>> + "skip",
>> + "abort",
>> + "quit",
>> + "edit_todo",
>> + "show_current_patch" };
>
> That's an improvement independent from the rest of the patches.
Yes I only included it as I move the definition later in the series
> Now we've had the C99 designated initialisers weather balloon
> changes for some time in our codebase, perhaps we can ensure that
> these entries match the intended & corresponding "enum action"
> constants? If we can also ensure that the array is large enough so
> that the trace2 call done like so
>
> trace2_cmd_mode(action_names[action])
>
> is safe, that would be good, but that is secondary.
>
> Thanks.
If what's below is ok, I'll send a re-roll, I wasn't sure if it was best
to die if action is larger than the array of names or just use a
default. My worrying with dying is that it wont be caught by tests and
will cause a problem for users who enable tracing. At least with what's
below they can still rebase and hopefully report a bug about unknown
action in their trace output.
Best Wishes
Phillip
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 52114cbf0d..3f56be230e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1027,14 +1027,15 @@ int cmd_rebase(int argc, const char **argv,
const char *prefix)
ACTION_EDIT_TODO,
ACTION_SHOW_CURRENT_PATCH,
} action = NO_ACTION;
- static const char *action_names[] = { N_("undefined"),
- N_("continue"),
- N_("skip"),
- N_("abort"),
- N_("quit"),
- N_("edit_todo"),
- N_("show_current_patch"),
- NULL };
+ static const char *action_names[] = {
+ [NO_ACTION] = "undefined",
+ [ACTION_CONTINUE] = "continue",
+ [ACTION_SKIP] = "skip",
+ [ACTION_ABORT] = "abort",
+ [ACTION_QUIT] = "quit",
+ [ACTION_EDIT_TODO] = "edit_todo",
+ [ACTION_SHOW_CURRENT_PATCH] = "show_current_patch"
+ };
const char *gpg_sign = NULL;
struct string_list exec = STRING_LIST_INIT_NODUP;
const char *rebase_merges = NULL;
@@ -1225,8 +1226,10 @@ int cmd_rebase(int argc, const char **argv, const
char *prefix)
trace2_cmd_mode("interactive");
else if (exec.nr)
trace2_cmd_mode("interactive-exec");
- else
+ else if (action < ARRAY_SIZE(action_names))
trace2_cmd_mode(action_names[action]);
+ else
+ trace2_cmd_mode("unknown rebase action");
}
switch (action) {
next prev parent reply other threads:[~2019-04-25 17:47 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 19:03 [RFC PATCH 00/11] rebase -i run without forking rebase--interactive Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 01/11] sequencer: always discard index after checkout Phillip Wood
2019-03-20 1:50 ` Duy Nguyen
2019-03-21 14:35 ` Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 02/11] rebase: rename write_basic_state() Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 03/11] rebase: use OPT_RERERE_AUTOUPDATE() Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 04/11] rebase -i: combine rebase--interactive.c with rebase.c Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 05/11] rebase -i: remove duplication Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 06/11] rebase -i: use struct commit when parsing options Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 07/11] rebase -i: use struct object_id for squash_onto Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 08/11] rebase -i: use struct rebase_options to parse args Phillip Wood
2019-03-21 4:21 ` Junio C Hamano
2019-03-21 14:59 ` Phillip Wood
2019-03-22 3:34 ` Junio C Hamano
2019-03-21 21:13 ` Alban Gruin
2019-04-10 19:16 ` Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 09/11] rebase -i: use struct rebase_options in do_interactive_rebase() Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 10/11] rebase: use a common action enum Phillip Wood
2019-03-19 20:24 ` Ævar Arnfjörð Bjarmason
2019-03-21 14:43 ` Phillip Wood
2019-03-19 19:03 ` [RFC PATCH 11/11] rebase -i: run without forking rebase--interactive Phillip Wood
2019-03-20 20:50 ` [RFC PATCH 00/11] rebase -i " Josh Steadmon
2019-03-20 23:05 ` Ævar Arnfjörð Bjarmason
2019-03-21 14:40 ` Phillip Wood
2019-03-21 1:44 ` Junio C Hamano
2019-04-17 14:30 ` [PATCH v1 00/12] Run rebase -i " Phillip Wood
2019-04-17 14:30 ` [PATCH v1 01/12] sequencer: always discard index after checkout Phillip Wood
2019-04-17 14:30 ` [PATCH v1 02/12] rebase: don't translate trace strings Phillip Wood
2019-04-19 5:53 ` Junio C Hamano
2019-04-25 17:47 ` Phillip Wood [this message]
2019-04-17 14:30 ` [PATCH v1 03/12] rebase: rename write_basic_state() Phillip Wood
2019-04-17 14:30 ` [PATCH v1 04/12] rebase: use OPT_RERERE_AUTOUPDATE() Phillip Wood
2019-04-17 14:30 ` [PATCH v1 05/12] rebase -i: combine rebase--interactive.c with rebase.c Phillip Wood
2019-04-17 14:30 ` [PATCH v1 06/12] rebase -i: remove duplication Phillip Wood
2019-04-17 14:30 ` [PATCH v1 07/12] rebase -i: use struct commit when parsing options Phillip Wood
2019-04-17 14:30 ` [PATCH v1 08/12] rebase -i: use struct object_id for squash_onto Phillip Wood
2019-04-17 14:30 ` [PATCH v1 09/12] rebase -i: use struct rebase_options to parse args Phillip Wood
2019-04-17 14:30 ` [PATCH v1 10/12] rebase -i: use struct rebase_options in do_interactive_rebase() Phillip Wood
2019-04-17 14:30 ` [PATCH v1 11/12] rebase: use a common action enum Phillip Wood
2019-04-17 14:30 ` [PATCH v1 12/12] rebase -i: run without forking rebase--interactive Phillip Wood
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=41344c53-5b57-3d97-7b64-9128f7cba6af@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=alban.gruin@gmail.com \
--cc=avarab@gmail.com \
--cc=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=pclouds@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=steadmon@google.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).