git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pat Notz <patnotz@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCHv4 1/4] commit: --fixup option for use with rebase --autosquash
Date: Thu, 23 Sep 2010 12:27:46 -0600	[thread overview]
Message-ID: <AANLkTikUonhDU-_mq+ON2nRvHEnJszR5jW7siyeXDFLn@mail.gmail.com> (raw)
In-Reply-To: <7vsk10qr7p.fsf@alter.siamese.dyndns.org>

On Thu, Sep 23, 2010 at 11:56 AM, Junio C Hamano <gitster@pobox.com> wrote:
> "Pat Notz" <patnotz@gmail.com> writes:
>
>> +     } else if (fixup_message) {
>> +             unsigned char sha1[20];
>> +             struct commit *commit;
>> +             struct pretty_print_context ctx = {0};
>> +             if (get_sha1(fixup_message, sha1))
>> +                     die("could not lookup commit %s", fixup_message);
>> +             commit = lookup_commit_reference(sha1);
>> +             if (!commit || parse_commit(commit))
>> +                     die("could not parse commit %s", fixup_message);
>> +             format_commit_message(commit, "fixup! %s\n\n", &sb, &ctx);
>> +             hook_arg1 = "message";
>
>
> I notice that the above is a half-copy-and-paste from "if (use_message)"
> codepath that handles -c/-C.  A few issues to think about (i.e. not
> complaints; I haven't thought about them myself):
>
>  (1) Is it worth refactoring the original instead of copying;
>
>  (2) What happens/should happen when the original commit is encoded
>     differently from the current commit encoding?  -c/-C codepath takes
>     pains to re-encode.  Should we do so somewhere in this codepath, too?
>

Yes, this was the concern I expressed in the v1 series patch.  I'm
getting more comfortable with the code so I'll look into re-encoding
appropriately.

>  (3) If the answer to (2) is "Yes", notice that format_commit_message()
>     does not re-encode the commit log message ("log" output codepath uses
>     pretty.c::pretty_print_commit(), which reencodes for log output
>     encoding).  Maybe we need an option to tell format_commit_message()
>     to do so?
>
> The last is not exactly an issue this patch alone should address, but I
> thought I'd better mention it anyway.
>
> My knee-jerk answers to the above are:
>
>  (1) The first handful of lines in this new "if (fixup_message)" codeblock
>     up to "die" might want to use a helper function shared with the
>     existing "if (use_message)" codepath;

Agreed.  I'll factor out the duplication.

>
>  (2) We probably want to re-encode to the log output encoding the string
>     we receive from format_commit_message() in this codepath.

Will do.

>
>  (3) No need yet.
>

  reply	other threads:[~2010-09-23 18:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23 17:14 [PATCHv4 0/4] Add commit message options for rebase --autosquash Pat Notz
2010-09-23 17:14 ` [PATCHv4 1/4] commit: --fixup option for use with " Pat Notz
2010-09-23 17:56   ` Junio C Hamano
2010-09-23 18:27     ` Pat Notz [this message]
2010-09-23 17:14 ` [PATCHv4 2/4] t7500: add tests of commit --fixup Pat Notz
2010-09-23 17:42   ` Junio C Hamano
2010-09-23 17:14 ` [PATCHv4 3/4] commit: --squash option for use with rebase --autosquash Pat Notz
2010-09-23 20:39   ` Junio C Hamano
2010-09-23 17:14 ` [PATCHv4 4/4] t7500: add tests of commit --squash Pat Notz

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=AANLkTikUonhDU-_mq+ON2nRvHEnJszR5jW7siyeXDFLn@mail.gmail.com \
    --to=patnotz@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).