From: Charvi Mendiratta <charvi077@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>,
Christian Couder <christian.couder@gmail.com>,
Phillip Wood <phillip.wood123@gmail.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH v4 6/9] rebase -i: add fixup [-C | -c] command
Date: Tue, 2 Feb 2021 20:59:12 +0530 [thread overview]
Message-ID: <CAPSFM5fZHZDnmRD2GzwPVKwBjogKD=GJbC7e=6aQSbu_iXBdNw@mail.gmail.com> (raw)
In-Reply-To: <CAPig+cQeBE7m8wf1e_soVrpvL3==u50MPyb90NwWLnFiUz1Byw@mail.gmail.com>
Hi Eric,
On Tue, 2 Feb 2021 at 06:17, Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Fri, Jan 29, 2021 at 1:24 PM Charvi Mendiratta <charvi077@gmail.com> wrote:
> > Add options to `fixup` command to fixup both the commit contents and
> > message. `fixup -C` command is used to replace the original commit
> > message and `fixup -c`, additionally allows to edit the commit message.
>
> In the cover letter for this series, you had this additional information:
>
> This convention is similar to the existing `merge` command in the
> interactive rebase, that also supports `-c` and `-C` options with
> similar meanings.
>
> which helps to explain the choice of -c and -C. It might be nice to
> include that explanation in this commit message, as well (but not
> itself worth a re-roll).
>
Agree, I will include this in the commit message.
> > Signed-off-by: Charvi Mendiratta <charvi077@gmail.com>
> > ---
> > diff --git a/rebase-interactive.c b/rebase-interactive.c
> > @@ -44,7 +44,9 @@ void append_todo_help(int command_count,
> > "s, squash <commit> = use commit, but meld into previous commit\n"
> > -"f, fixup <commit> = like \"squash\", but discard this commit's log message\n"
> > +"f, fixup [-C | -c] <commit> = like \"squash\", but discard this\n"
> > +" commit's log message. Use -C to replace with this\n"
> > +" commit message or -c to edit the commit message\n"
>
> This change jarringly introduces the first and only use of a period
> and capitalized word in the to-do help text. Perhaps instead say:
>
> ... like \"squash\", but discard this
> commit's log message; use -C to replace with this
> commit message or -c to edit the commit message
>
Okay, I will change it.
> When `-c` says "edit the commit message" it's not clear what will be
> edited. The original's commit message? The replacement's message? A
> combination of the two? If you can come up with a succinct way to word
> it such that it states more precisely what exactly will be edited, it
> would be nice, but not necessarily worth a re-roll.
>
Here the editor shows the commented out commit message of original commit and
the replacement commit message (of fixup -c commit) is not commented out.
So maybe s/edit the commit message/edit this commit message is better.
> > diff --git a/sequencer.c b/sequencer.c
> > @@ -1718,6 +1718,12 @@ static int is_pick_or_similar(enum todo_command command)
> > +enum todo_item_flags {
> > + TODO_EDIT_MERGE_MSG = (1 << 0),
> > + TODO_REPLACE_FIXUP_MSG = (1 << 1),
> > + TODO_EDIT_FIXUP_MSG = (1 << 2),
> > +};
>
> I'm confused. These enumeration items are defined as bit flags,
> implying that they may be combined, however...
>
> > @@ -1734,32 +1740,176 @@ static size_t subject_length(const char *body)
> > +static int check_fixup_flag(enum todo_command command,
> > + enum todo_item_flags flag)
>
> ...here and elsewhere, you declare the argument as a strict
> `todo_item_flags` enum item rather than `unsigned` which is the
> typical declaration when combining bit flag values. So, the picture
> thus far is confusing. Are the `todo_item_flags` values distinct
> unique values which will never be combined, or are they meant to be
> combined?
>
> > +{
> > + return command == TODO_FIXUP && ((flag & TODO_REPLACE_FIXUP_MSG) ||
> > + (flag & TODO_EDIT_FIXUP_MSG));
> > +}
>
> This code adds to the confusion. In the function argument list, `flag`
> has been declared as a single enum item, yet this code is treating
> `flag` as if it is a combination of bits. So, it's not clear what the
> intention is here. Is `flag` always going to be a specific enum item
> in this context or is it going to be a combination of bits? If it is
> only ever going to be a distinct enum item, then one would expect this
> code to be written like this:
>
> return command == TODO_FIXUP &&
> (flag == TODO_REPLACE_FIXUP_MSG ||
> flag == TODO_EDIT_FIXUP_MSG);
>
> Otherwise, if `flag` will actually be a bag of bits, then the argument
> should be declared as such:
>
> static int check_fixup_flag(enum todo_command command,
> unsigned flag)
>
I admit it resulted in a bit of confusion. Here, its true that flag is always
going to be specific enum item( as command can be merge -c, fixup -c, or
fixup -C ) and I combined the bag of bits to denote
the specific enum item. So, maybe we can go with the first method?
> By the way, the function name check_fixup_flag() doesn't necessarily
> do a good job conveying the purpose of this function. Based upon the
> implementation, I gather that it is checking whether the command is a
> "fixup" command, so perhaps the name could reflect that. Perhaps
> is_fixup() or something?
>
Agree, here it's checking if the command is fixup and the flag value (
which implies either user has given command fixup -c or fixup -C )
So, I wonder if we can write is_fixup_flag() ?
> > +static int append_squash_message(struct strbuf *buf, const char *body,
> > + enum todo_command command, struct replay_opts *opts,
> > + enum todo_item_flags flag)
> > +{
> > + /*
> > + * amend is non-interactive and not normally used with fixup!
> > + * or squash! commits, so only comment out those subjects when
> > + * squashing commit messages.
> > + */
> > + if (starts_with(body, "amend!") ||
> > + ((command == TODO_SQUASH || seen_squash(opts)) &&
> > + (starts_with(body, "squash!") || starts_with(body, "fixup!"))))
> > commented_len = subject_length(body);
>
> I understand from the cover letter that "amend!" is being added by
> this series, however, no patch up to this point, nor this patch
> itself, adds "amend!" functionality, so it's surprising to see it
> being tested here. As a reader, I would expect code/comments related
> to "amend!" to be added in the patch which actually introduces
> "amend!" rather than doing it here.
>
This patch series does not include the implementation of amend! commit.
I think to avoid the confusion I will remove this part from this patch series
and add it in the next patch series for amend! commit.
> > + /* fixup -C after squash behaves like squash */
> > + if (check_fixup_flag(command, flag) && !seen_squash(opts)) {
> > + if (opts->signoff)
> > + append_signoff(buf, 0, 0);
> > +
> > + if ((command == TODO_FIXUP) &&
> > + (flag & TODO_REPLACE_FIXUP_MSG) &&
> > + (file_exists(rebase_path_fixup_msg()) ||
> > + !file_exists(rebase_path_squash_msg()))) {
>
> Is the expression `command == TODO_FIXUP` redundant here considering
> that the only way we got this far is if check_fixup_flag() returned
> true, in which case we know that command is TODO_FIXUP? Or am I
> missing something?
Yes, it implies the same.
>
> > @@ -2281,6 +2436,18 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
> > + if (item->command == TODO_FIXUP) {
> > + if (skip_prefix(bol, "-C", &bol) &&
> > + (*bol == ' ' || *bol == '\t')) {
> > + bol += strspn(bol, " \t");
> > + item->flags |= TODO_REPLACE_FIXUP_MSG;
> > + } else if (skip_prefix(bol, "-c", &bol) &&
> > + (*bol == ' ' || *bol == '\t')) {
> > + bol += strspn(bol, " \t");
> > + item->flags |= TODO_EDIT_FIXUP_MSG;
> > + }
> > + }
>
> I was wondering if the above could be rephrased like this to avoid the
> repetition:
>
> if (bol[0] == '-' && tolower(bol[1]) == 'c' &&
> (bol[2] == ' ' || bol[2] == '\t') {
> item->flags |= bol[1] == 'C' ?
> TODO_REPLACE_FIXUP_MSG :
> TODO_EDIT_FIXUP_MSG;
> bol += 2 + strspn(bol + 2, " \t");
> }
>
> but perhaps it's too magical and ugly.
I agree, this [tolower(bol[1]) == 'c'] is actually doing all the
magic, but I am not
sure if we should change it or not ? As in the source code just after
this code we
are checking in a similar way for the 'merge' command. So, maybe implementing
in a similar way is easier to read ?
Thanks and Regards,
Charvi
next prev parent reply other threads:[~2021-02-02 15:36 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 9:23 [RFC PATCH 0/9][Outreachy] rebase -i: add options to fixup command Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 1/9] rebase -i: only write fixup-message when it's needed Charvi Mendiratta
2021-01-13 18:43 ` Taylor Blau
2021-01-14 8:12 ` Charvi Mendiratta
2021-01-14 10:46 ` Phillip Wood
2021-01-15 8:38 ` Charvi Mendiratta
2021-01-15 17:22 ` Junio C Hamano
2021-01-16 4:49 ` Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 2/9] sequencer: factor out code to append squash message Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 3/9] rebase -i: comment out squash!/fixup! subjects from " Charvi Mendiratta
2021-01-13 19:01 ` Taylor Blau
2021-01-14 8:27 ` Charvi Mendiratta
2021-01-14 10:29 ` Phillip Wood
2021-01-15 8:35 ` Charvi Mendiratta
2021-01-15 8:44 ` Christian Couder
2021-01-15 11:12 ` Charvi Mendiratta
2021-01-17 3:39 ` Charvi Mendiratta
2021-01-18 18:29 ` Phillip Wood
2021-01-19 4:08 ` Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 4/9] sequencer: pass todo_item to do_pick_commit() Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 5/9] sequencer: use const variable for commit message comments Charvi Mendiratta
2021-01-13 19:14 ` Taylor Blau
2021-01-13 20:37 ` Junio C Hamano
2021-01-14 7:40 ` Christian Couder
2021-01-14 8:57 ` Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 6/9] rebase -i: add fixup [-C | -c] command Charvi Mendiratta
2021-01-14 9:23 ` Christian Couder
2021-01-14 9:45 ` Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 7/9] t3437: test script for fixup [-C|-c] options in interactive rebase Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 8/9] rebase -i: teach --autosquash to work with amend! Charvi Mendiratta
2021-01-08 9:23 ` [RFC PATCH 9/9] doc/git-rebase: add documentation for fixup [-C|-c] options Charvi Mendiratta
2021-01-19 7:40 ` [PATCH v2 0/9][Outreachy] rebase -i: add options to fixup command Charvi Mendiratta
2021-01-24 17:03 ` [PATCH v3 " Charvi Mendiratta
2021-01-24 17:03 ` [PATCH v3 1/9] rebase -i: only write fixup-message when it's needed Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 2/9] sequencer: factor out code to append squash message Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 3/9] rebase -i: comment out squash!/fixup! subjects from " Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 4/9] sequencer: pass todo_item to do_pick_commit() Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 5/9] sequencer: use const variable for commit message comments Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 6/9] rebase -i: add fixup [-C | -c] command Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 7/9] t3437: test script for fixup [-C|-c] options in interactive rebase Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 8/9] rebase -i: teach --autosquash to work with amend! Charvi Mendiratta
2021-01-24 17:04 ` [PATCH v3 9/9] doc/git-rebase: add documentation for fixup [-C|-c] options Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 0/9][Outreachy] rebase -i: add options to fixup command Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 1/9] rebase -i: only write fixup-message when it's needed Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 2/9] sequencer: factor out code to append squash message Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 3/9] rebase -i: comment out squash!/fixup! subjects from " Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 4/9] sequencer: pass todo_item to do_pick_commit() Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 5/9] sequencer: use const variable for commit message comments Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 6/9] rebase -i: add fixup [-C | -c] command Charvi Mendiratta
2021-02-02 0:47 ` Eric Sunshine
2021-02-02 15:29 ` Charvi Mendiratta [this message]
2021-02-03 5:05 ` Eric Sunshine
2021-02-04 0:00 ` Charvi Mendiratta
2021-02-04 0:14 ` Eric Sunshine
2021-01-29 18:20 ` [PATCH v4 7/9] t3437: test script for fixup [-C|-c] options in interactive rebase Charvi Mendiratta
2021-02-02 2:01 ` Eric Sunshine
2021-02-02 10:02 ` Christian Couder
2021-02-02 15:31 ` Charvi Mendiratta
2021-02-03 5:44 ` Eric Sunshine
2021-02-04 0:01 ` Charvi Mendiratta
2021-02-04 10:46 ` Phillip Wood
2021-02-04 16:14 ` Eric Sunshine
2021-02-04 19:12 ` Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 8/9] rebase -i: teach --autosquash to work with amend! Charvi Mendiratta
2021-02-02 3:20 ` Eric Sunshine
2021-02-02 15:29 ` Charvi Mendiratta
2021-01-29 18:20 ` [PATCH v4 9/9] doc/git-rebase: add documentation for fixup [-C|-c] options Charvi Mendiratta
2021-02-02 3:23 ` Eric Sunshine
2021-02-02 14:12 ` Marc Branchaud
2021-02-02 15:30 ` Charvi Mendiratta
2021-02-04 19:04 ` [PATCH v5 0/8][Outreachy] rebase -i: add options to fixup command Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 1/8] rebase -i: only write fixup-message when it's needed Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 2/8] sequencer: factor out code to append squash message Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 3/8] rebase -i: comment out squash!/fixup! subjects from " Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 4/8] sequencer: pass todo_item to do_pick_commit() Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 5/8] sequencer: use const variable for commit message comments Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 6/8] rebase -i: add fixup [-C | -c] command Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 7/8] t3437: test script for fixup [-C|-c] options in interactive rebase Charvi Mendiratta
2021-02-04 19:05 ` [PATCH v5 8/8] doc/git-rebase: add documentation for fixup [-C|-c] options Charvi Mendiratta
2021-02-05 7:30 ` [PATCH v5 0/8][Outreachy] rebase -i: add options to fixup command Eric Sunshine
2021-02-05 9:42 ` Charvi Mendiratta
2021-02-05 18:25 ` Christian Couder
2021-02-05 18:56 ` Eric Sunshine
2021-02-06 5:36 ` Charvi Mendiratta
2021-02-05 19:13 ` Junio C Hamano
2021-02-06 5:37 ` Charvi Mendiratta
2021-01-19 7:40 ` [PATCH v2 1/9] rebase -i: only write fixup-message when it's needed Charvi Mendiratta
2021-01-19 7:40 ` [PATCH v2 2/9] sequencer: factor out code to append squash message Charvi Mendiratta
2021-01-19 7:40 ` [PATCH v2 3/9] rebase -i: comment out squash!/fixup! subjects from " Charvi Mendiratta
2021-01-21 1:38 ` Junio C Hamano
2021-01-21 14:02 ` Charvi Mendiratta
2021-01-21 15:21 ` Christian Couder
2021-01-21 16:58 ` Phillip Wood
2021-01-21 20:56 ` Junio C Hamano
2021-01-22 19:41 ` Charvi Mendiratta
2021-01-22 19:41 ` Charvi Mendiratta
2021-01-19 7:40 ` [PATCH v2 4/9] sequencer: pass todo_item to do_pick_commit() Charvi Mendiratta
2021-01-19 7:41 ` [PATCH v2 5/9] sequencer: use const variable for commit message comments Charvi Mendiratta
2021-01-19 7:41 ` [PATCH v2 6/9] rebase -i: add fixup [-C | -c] command Charvi Mendiratta
2021-01-19 7:41 ` [PATCH v2 7/9] t3437: test script for fixup [-C|-c] options in interactive rebase Charvi Mendiratta
2021-01-19 7:41 ` [PATCH v2 8/9] rebase -i: teach --autosquash to work with amend! Charvi Mendiratta
2021-01-19 7:41 ` [PATCH v2 9/9] doc/git-rebase: add documentation for fixup [-C|-c] options Charvi Mendiratta
2021-01-19 14:37 ` Marc Branchaud
2021-01-19 17:13 ` Charvi Mendiratta
2021-01-19 22:05 ` Marc Branchaud
2021-01-20 7:10 ` Charvi Mendiratta
2021-01-20 11:04 ` Phillip Wood
2021-01-20 12:31 ` Charvi Mendiratta
2021-01-20 14:29 ` Phillip Wood
2021-01-20 16:09 ` Charvi Mendiratta
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='CAPSFM5fZHZDnmRD2GzwPVKwBjogKD=GJbC7e=6aQSbu_iXBdNw@mail.gmail.com' \
--to=charvi077@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood123@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=sunshine@sunshineco.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).