From: Jay Soffian <jaysoffian@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [RFC/PATCH 2/2] Teach commit to handle CHERRY_HEAD automatically
Date: Tue, 15 Feb 2011 18:21:54 -0500 [thread overview]
Message-ID: <AANLkTinZ0ewJy01rV66xMMCKLon=7qz=hoJ3DbtXmtXL@mail.gmail.com> (raw)
In-Reply-To: <20110215230015.GA17812@elie>
On Tue, Feb 15, 2011 at 6:00 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> - "git commit --amend" to say "I'm done fixing the broken thing".
>
> - "git commit --fixup=HEAD/--squash=HEAD" to say "done fixing;
> let's look at this again later and squash it when I am less
> confused".
>
> Both are mistakes if HEAD is the previous and good commit rather than
> the broken one. Maybe there is some simple safety that could protect
> against them?
As you see below, this is already protected against.
>> --reset-author::
>> - When used with -C/-c/--amend options, declare that the
>> - authorship of the resulting commit now belongs of the committer.
>> - This also renews the author timestamp.
>> + When used with -C/-c/--amend options, or when committing after a
>> + a conflicting cherry-pick,
>
> or when committing after a conflicted merge, no?
No. The person committing a merge is already the author of the merge,
why would they use --reset-author?
>
>> declare that the authorship of the
>> + resulting commit now belongs of the committer. This also renews
>> + the author timestamp.
>
> How does it interact with --author?
No change from before, --author forces the author of the new commit.
>> +++ b/builtin/commit.c
> [...]
>> @@ -609,7 +609,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>> die_errno("could not read log file '%s'",
>> logfile);
>> hook_arg1 = "message";
>> - } else if (use_message) {
>> + } else if (use_message && !cherry_pick) {
>
> Wouldn't this make
>
> git commit -C foo
>
> after a failed cherry-pick use MERGE_MSG instead of the message the
> user requested?
No, because the -C will force the cherry_pick flag to 0 in
parse_and_validate_options:
/* Let message-specifying options override CHERRY_HEAD */
I'll make this logic clearer though as I need to address Junio's
earlier message.
>> + if (cherry_pick)
>> + fprintf(fp,
>> + "#\n"
>> + "# It looks like you may be committing a cherry-pick.\n"
>
> Aside: shouldn't we suggest some porcelain-ish command (git merge
> --clear? git commit --no-merge?) to remove .git/MERGE_HEAD instead of
> asking the committer to do it?
We have git merge --reset as an alias for reset --merge. Since reset
--merge takes care of this case too (I think, I'll check) we can
suggest that for both.
> This section is used to give a preview and sanity check for the
> commit.
>
> - if we are on the wrong branch, that might be a mistake.
> - if the author is someone else, that might be a mistake.
> - if there are multiple parents, that might be a mistake.
> - if there are changes included, some might be mistakes.
> - if there are changes excluded, some might be mistakes,
> - if there are untracked files, some might be mistakes.
>
> Where does committing a cherry-pick fall into that picture? Maybe
>
> # Author: A U Thor <author@example.com>
> # Date: Tue Beb 9 01:23:45 1911 -0500
> #
> # If this is not correct, please try again using the
> # --author and --date or --reset-author options.
Okay.
>> @@ -898,6 +907,7 @@ static void handle_untracked_files_arg(struct wt_status *s)
>> die("Invalid untracked files mode '%s'", untracked_files_arg);
>> }
>>
>> +
>
> Stray whitespace change?
Indeed.
> How can I get out of this state if I really do want to amend?
git reset, same as it ever was?
>> @@ -943,11 +955,19 @@ static int parse_and_validate_options(int argc, const char *argv[],
>> die("Only one of -c/-C/-F/--fixup can be used.");
>> if (message.len && f > 0)
>> die("Option -m cannot be combined with -c/-C/-F/--fixup.");
>> + if (cherry_pick) {
>> + /* Let message-specifying options override CHERRY_HEAD */
>> + if (f > 0 || message.len)
>> + cherry_pick = 0;
>> + else
>> + /* used for authorship side-effect only */
>> + use_message = "CHERRY_HEAD";
>> + }
>
> Hmm, what if I have commits F and F' and after trying to cherry-pick F
> I decide I want the message from F'?
I don't think I understand. commit -c F', or just commit (w/o options)
and you get MERGE_MSG generated by cherry-pick.
>> @@ -1118,6 +1138,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
>> gitmodules_config();
>> git_config(git_status_config, &s);
>> in_merge = file_exists(git_path("MERGE_HEAD"));
>> + cherry_pick = file_exists(git_path("CHERRY_HEAD"));
>
> Is it possible to be both in_merge and cherry_pick?
No, I need to rework this into an enum, maybe enum { CONFLICT_NONE,
CONFLICT_MERGE, CONFLICT_CHERRY_PICK } conflict_type.
>> - reflog_msg = "commit";
>> + reflog_msg = cherry_pick ? "commit (cherry-pick)"
>> + : "commit";
>
> Nice. Probably worth mentioning in the commit message.
>
>> + elif [ -f "$g/CHERRY_HEAD" ]; then
>> + r="|CHERRY-PICKING"
>
> Likewise.
Right.
Thanks for the feedback!
j.
next prev parent reply other threads:[~2011-02-15 23:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 21:23 [RFC/PATCH 0/2] CHERRY_HEAD Jay Soffian
2011-02-15 21:23 ` [RFC/PATCH 1/2] Introduce CHERRY_HEAD Jay Soffian
2011-02-15 22:13 ` Junio C Hamano
2011-02-15 22:18 ` Jonathan Nieder
2011-02-15 22:59 ` Junio C Hamano
2011-02-15 23:02 ` Bert Wesarg
2011-02-15 23:10 ` Junio C Hamano
2011-02-15 23:42 ` Bert Wesarg
2011-02-15 23:07 ` Jay Soffian
2011-02-15 23:08 ` Jonathan Nieder
2011-02-15 21:23 ` [RFC/PATCH 2/2] Teach commit to handle CHERRY_HEAD automatically Jay Soffian
2011-02-15 22:16 ` Jay Soffian
2011-02-15 22:34 ` Junio C Hamano
2011-02-15 23:00 ` Jonathan Nieder
2011-02-15 23:21 ` Jay Soffian [this message]
2011-02-15 23:47 ` Jonathan Nieder
2011-02-16 0:03 ` Jay Soffian
2011-02-16 0:08 ` Jonathan Nieder
2011-02-16 0:05 ` [PATCH] Documentation: clarify interaction of --reset-author with --author Jonathan Nieder
2011-02-16 1:04 ` Junio C Hamano
2011-02-15 21:51 ` [RFC/PATCH 0/2] CHERRY_HEAD Ævar Arnfjörð Bjarmason
2011-02-15 22:10 ` Junio C Hamano
2011-02-15 22:13 ` Jay Soffian
2011-02-15 22:30 ` Ævar Arnfjörð Bjarmason
2011-02-15 22:11 ` Jay Soffian
2011-02-16 1:48 ` Miles Bader
2011-02-17 14:09 ` Christian Couder
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTinZ0ewJy01rV66xMMCKLon=7qz=hoJ3DbtXmtXL@mail.gmail.com' \
--to=jaysoffian@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=jrnieder@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).