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
Junio C Hamano <gitster@pobox.com>
Date
Sep 23, 2010, 17:56 UTC
Message-ID
<7vsk10qr7p.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1285262076-20134-2-git-send-email-patnotz@gmail.com>
"Pat Notz" <patnotz@gmail.com> writes:
Show 11 quoted lines
> +	} 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?
 (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;
 (2) We probably want to re-encode to the log output encoding the string
     we receive from format_commit_message() in this codepath.
 (3) No need yet.
Previous: Pat NotzNext: Pat Notz
Message 3 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.