git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv4 1/4] commit: --fixup option for use with rebase --autosquash

From
Pat Notz <patnotz@gmail.com>
Date
Sep 23, 2010, 18:27 UTC
Message-ID
<AANLkTikUonhDU-_mq+ON2nRvHEnJszR5jW7siyeXDFLn@mail.gmail.com>
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:
Show 25 quoted lines
> "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.

Show 14 quoted lines
>  (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.
>
Previous: Junio C HamanoNext: Pat Notz
Message 4 of 9 in “[PATCHv4 0/4] Add commit message options for rebase --autosquash”
  1. Pat NotzSep 23, 2010
  2. 1/4 commit: --fixup option for use with rebase --autosquashPat Notz, Sep 23, 2010
  3. Junio C HamanoSep 23, 2010
  4. Pat NotzSep 23, 2010
  5. 2/4 t7500: add tests of commit --fixupPat Notz, Sep 23, 2010
  6. Junio C HamanoSep 23, 2010
  7. 3/4 commit: --squash option for use with rebase --autosquashPat Notz, Sep 23, 2010
  8. Junio C HamanoSep 23, 2010
  9. 4/4 t7500: add tests of commit --squashPat Notz, Sep 23, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.