git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: Mike Rappazzo <rappazzo@gmail.com>
Cc: Git List <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] git-rebase--interactive.sh: add config option for custom instruction format
Date: Thu, 11 Jun 2015 16:40:35 +0200	[thread overview]
Message-ID: <fc77a32f3e571e012591f992ba37bf5a@www.dscho.org> (raw)
In-Reply-To: <CANoM8SW13UYazBQgXn6BSDa-rz+jqj19CO3b0K82CV5Ab6HmKw@mail.gmail.com>

Hi Mike,

On 2015-06-11 16:02, Mike Rappazzo wrote:
> On Thu, Jun 11, 2015 at 9:40 AM, Johannes Schindelin
> <johannes.schindelin@gmx.de> wrote:
>>
>> On 2015-06-11 03:30, Michael Rappazzo wrote:
>>
>>> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
>>> index dc3133f..6d14315 100644
>>> --- a/git-rebase--interactive.sh
>>> +++ b/git-rebase--interactive.sh
>>> @@ -740,10 +740,19 @@ collapse_todo_ids() {
>>>  # "pick sha1 fixup!/squash! msg" appears in it so that the latter
>>>  # comes immediately after the former, and change "pick" to
>>>  # "fixup"/"squash".
>>> +#
>>> +# Note that if the config has specified a custom instruction format
>>> +# each log message will be re-retrieved in order to normalize the
>>> +# autosquash arrangement
>>>  rearrange_squash () {
>>>       # extract fixup!/squash! lines and resolve any referenced sha1's
>>> -     while read -r pick sha1 message
>>> +     while read -r pick sha1 todo_message
>>>       do
>>> +             message=${todo_message}
>>
>> Why not just leave the `read -r pick sha1 message` as-is and simply write
>>
>>                 # For "autosquash":
>>                 test -z "$format" ||
>>                 message="$(git log -n 1 --format="%s" $sha1)"
>>
>> here?
> 
> I did notice that I am not using '$todo_message' in the first loop at
> all, so I will adjust it.  In the second loop, I do use both the
> original and the reformatted.  I will apply your suggestion there if
> applicable.

It might make sense to use

                 if test -z "$format"
                 then
                         oneline="$message"
                 else
                         oneline="$(git log -n 1 --format="%s" $sha1)"
                 fi

in the instances where you need to compare against the original oneline, and then only adjust the "message" variable name in places that require the original oneline.

>> [The two test functions are] copied almost verbatim, except for the commit message. The code would be easier to maintain if it did not repeat so much code e.g. by refactoring out a function that takes the commit message as a parameter.
> 
> Makes sense.  I'll implement that.

Thank you,
Johannes

      reply	other threads:[~2015-06-11 14:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11  1:30 [PATCH v3] git-rebase--interactive.sh: add config option for custom instruction format Michael Rappazzo
2015-06-11  1:30 ` [PATCH] " Michael Rappazzo
2015-06-11 13:40   ` Johannes Schindelin
2015-06-11 14:02     ` Mike Rappazzo
2015-06-11 14:40       ` Johannes Schindelin [this message]

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=fc77a32f3e571e012591f992ba37bf5a@www.dscho.org \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rappazzo@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.
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 NNTP newsgroup(s).