Re: [PATCH v4 8/9] rebase -i: teach --autosquash to work with amend!
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 2, 2021, 03:20 UTC
- Message-ID
- <CAPig+cTyK_OPixAnJQc_cO4vHzA++hfyfGEA7uZBK3ukCWD0PA@mail.gmail.com>
- In-Reply-To
- <20210129182050.26143-9-charvi077@gmail.com>
On Fri, Jan 29, 2021 at 1:25 PM Charvi Mendiratta <charvi077@gmail.com> wrote:
Show 10 quoted lines
> If the commit subject starts with "amend!" then rearrange it like a > "fixup!" commit and replace `pick` command with `fixup -C` command, > which is used to fixup up the content if any and replaces the original > commit message with amend! commit's message. > > Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> > --- > sequencer.c | 23 ++++++++++++++++------- > t/t3437-rebase-fixup-options.sh | 12 ++++++++++++ > 2 files changed, 28 insertions(+), 7 deletions(-)
Is this new behavior of recognizing "amend!" in the subject documented anywhere? I checked the documentation patch [9/9] but didn't see any mention of it.
Show 7 quoted lines
> diff --git a/sequencer.c b/sequencer.c
> @@ -5662,6 +5662,12 @@ static int subject2item_cmp(const void *fndata,
> +static inline int skip_fixup_amend_squash(const char *subject, const char **p) {
> + return skip_prefix(subject, "fixup! ", p) ||
> + skip_prefix(subject, "amend! ", p) ||
> + skip_prefix(subject, "squash! ", p);
> +}While the function name skip_fixup_amend_squash() may be accurate, it won't scale well. What happens when additional fixup-like prefixes are added in the future? Does the function name get extended to name them, as well? How about choosing a more generic, yet still meaningful, function name which doesn't suffer from this scaling problem. Perhaps skip_fixupish() or fix_squashlike() or something.
Also, making this function `inline` seems like a case of premature optimization.