From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: "Guillaume Pagès" <guillaume.pages@ensimag.grenoble-inp.fr>
Cc: git@vger.kernel.org,
Remi Galan <remi.galan-alfonso@ensimag.grenoble-inp.fr>,
Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>,
Louis-Alexandre Stuber
<louis--alexandre.stuber@ensimag.grenoble-inp.fr>,
Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
Subject: Re: [RFC/PATCH 1/2] status: give more information during rebase -i
Date: Wed, 03 Jun 2015 19:12:17 +0200 [thread overview]
Message-ID: <vpqpp5cbtse.fsf@anie.imag.fr> (raw)
In-Reply-To: <1433320545-14244-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr> ("Guillaume \=\?iso-8859-1\?Q\?Pag\=E8s\=22's\?\= message of "Wed, 3 Jun 2015 10:35:44 +0200")
Hi,
Your code is not C90:
wt-status.c: In function ‘get_two_last_lines’:
wt-status.c:1030:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
struct strbuf buf = STRBUF_INIT;
^
wt-status.c: In function ‘get_two_first_lines’:
wt-status.c:1050:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
struct strbuf buf = STRBUF_INIT;
^
I have this to notice it:
$ cat config.mak
CFLAGS += -Wdeclaration-after-statement -Wall -Werror #-O0 -g
Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:
> +void get_two_last_lines(char *filename,int * numlines, char ** lines)
Space after ,
> +{
> + *numlines=0;
Spaces around =
> + struct strbuf buf = STRBUF_INIT;
> + FILE *fp = fopen(git_path("%s", filename), "r");
> + if (!fp) {
> + strbuf_release(&buf);
> + return;
> + }
> + while (strbuf_getline(&buf, fp, '\n')!=EOF){
Spaces around !=
There are many other space issues, I won't list them all.
> + (*numlines)++;
> + lines[0]=lines[1];
> + lines[1]=strbuf_detach(&buf, NULL);
> + }
> + if (!fclose(fp))
> + strbuf_detach(&buf, NULL);
> + else
> + strbuf_release(&buf);
> +}
> +
> +void get_two_first_lines(char *filename,int * numlines, char ** lines)
Stick the * to the corresponding variable.
Do: int *numlines
Don't: int * numlines, int* numlines
One rationale is that when you write
int *i, j;
it reads "*i is an int, and so is j" (which is right), while
int * i, j;
may read as "both i and j are int *" (which is not right).
> +{
> + *numlines=0;
> + struct strbuf buf = STRBUF_INIT;
> + char *line;
> + FILE *fp = fopen(git_path("%s", filename), "r");
> + if (!fp) {
> + strbuf_release(&buf);
> + return;
> + }
> + while (strbuf_getline(&buf, fp, '\n')!=EOF){
> + stripspace(&buf, 1);
> + line = strbuf_detach(&buf, NULL);
> + if (strcmp(line,"")==0)
> + continue;
> + if (*numlines<2)
> + lines[*numlines] = line;
> + (*numlines)++;
> + }
> + if (!fclose(fp))
> + strbuf_detach(&buf, NULL);
> + else
> + strbuf_release(&buf);
> +}
> +
> +void show_rebase_information(struct wt_status *s,
> + struct wt_status_state *state,
> + const char *color)
static?
> +{
> + if (state->rebase_interactive_in_progress){
> + int i, begin;
> + int numlines =0;
> + char* lines[2];
> + get_two_last_lines("rebase-merge/done", &numlines, lines);
> + if (numlines==0)
> + status_printf_ln(s,color,"No command done.");
> + else{
Space before {. Several instances too.
> + status_printf_ln(s,color,
> + "Last command(s) done (%d command(s) done):",
> + numlines);
> + begin = numlines > 1? 0 : 1;
> + for (i = begin; i < 2; i++){
> + status_printf_ln(s,color," %s",lines[i]);
> + }
> + if (numlines>2 && s->hints )
> + status_printf_ln(s,color,
> + " (see more at .git/rebase-merge/done)");
> + }
> + numlines =0;
> + get_two_first_lines("rebase-merge/git-rebase-todo",
> + &numlines, lines);
> + if (numlines==0)
> + status_printf_ln(s,color,
Space after ,.
> + "No command remaining.");
> + else{
> +
> + status_printf_ln(s,color,
> + "Next command(s) to do (%d remaining command(s)):",
> + numlines);
> + begin = numlines > 1? 0 : 1;
> + for (i = 0; (i < 2 && i < numlines); i++){
> + status_printf(s,color," %s",lines[i]);
> + }
> + if (s->hints )
No space before ).
> + status_printf_ln(s,color,
> + " (use git rebase --edit-todo to view and edit)");
Mark for translation -> _("..."). Many instances above.
> - if (has_unmerged(s)) {
> + show_rebase_information(s,state,color);
> + if (has_unmerged(s) || state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
The show_rebase_information() line does belong to this patch, but the
other change do not IHMO. It would be _much_ easier to review in its own
patch with an explicit title like "status: factor two rebase-related
messages together" or so.
> @@ -1327,7 +1410,10 @@ void wt_status_print(struct wt_status *s)
> else if (!strcmp(branch_name, "HEAD")) {
> branch_status_color = color(WT_STATUS_NOBRANCH, s);
> if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
> - on_what = _("rebase in progress; onto ");
> + if (state.rebase_interactive_in_progress)
> + on_what = _("interactive rebase in progress; onto ");
> + else
> + on_what = _("rebase in progress; onto ");
I wouldn't insist on that, but splitting this one in a separate patch
would make sense to me too. The patch would contain this change, and the
impact on tests.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2015-06-03 17:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 8:35 [RFC/PATCH 1/2] status: give more information during rebase -i Guillaume Pagès
2015-06-03 8:35 ` [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase Guillaume Pagès
2015-06-03 17:42 ` Matthieu Moy
2015-06-03 18:25 ` Junio C Hamano
2015-06-03 19:51 ` Guillaume Pages
2015-06-03 17:12 ` Matthieu Moy [this message]
2015-06-03 17:20 ` [RFC/PATCH 1/2] status: give more information during rebase -i Matthieu Moy
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpqpp5cbtse.fsf@anie.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=antoine.delaite@ensimag.grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=guillaume.pages@ensimag.grenoble-inp.fr \
--cc=louis--alexandre.stuber@ensimag.grenoble-inp.fr \
--cc=remi.galan-alfonso@ensimag.grenoble-inp.fr \
--cc=remi.lespinet@ensimag.grenoble-inp.fr \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.