On Tue, Feb 15, 2011 at 6:00 PM, Jonathan Nieder <jrnieder@xxxxxxxxx> 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@xxxxxxxxxxx> > Â Â Â Â# 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. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html