"Konstantin Pereiaslov via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > From: Konstantin Pereiaslov <perk11@xxxxxxxxxxx> > > Added a description of what the offered options will do and for pull > also offered a 3rd option during a pull - a hard reset. > This option should be helpful for the new users that accidentally > committed into the wrong branch which is a scenario I saw very > often. cf. Documentation/SubmittingPatches:[[describe-changes]] > The resulting tooltip looks like this for pull: > > hint: Diverging branches can't be fast-forwarded. > Consider the following options: We do not give "hint:" prefix to this line??? > hint: > hint: To merge remote changes into your branch: > hint: git merge --no-ff > hint: > hint: To apply your changes on top of remote changes: > hint: git rebase Hmph, "apply" -> "replay" perhaps? > hint: To discard your local changes and apply the remote changes: Here "apply" is definitely a misnomer. Nothing is applied; you just discard your work and adopt (or "accept") the state of the remote as a whole. > hint: git reset --hard refs/remotes/upstream/branch-name > hint: > hint: Disable this message with "git config advice.diverging false" OK. Overall, "... looks like this" should be shown a bit indented so that the example stands out from the text that explains the example. > There is some danger because it's semi-destructive, but so are > other options offered if user doesn't know the commands to > revert back. Sorry, but I do not quite understand what you want to say here. > @@ -1112,8 +1126,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix) > > /* ff-only takes precedence over rebase */ > if (opt_ff && !strcmp(opt_ff, "--ff-only")) { > - if (divergent) > - die_ff_impossible(); > + if (divergent) { > + const char* pull_branch_spec = get_pull_branch(repo, *refspecs); In this codebase, asterisk sticks to the variable/function identifier, not types. But more importantly, what guarantees your recomputation using '*refspecs' here will match the result of the logic that computed 'divergent', which certainly would have already known what commit we tried to fast-forward our branch to, and where that commit came from? We shouldn't be computing the same thing twice, and in different ways; that is a sure way to introduce inconsistent results. > + die_ff_impossible_during_pull(pull_branch_spec); > + } > opt_rebase = REBASE_FALSE; > } > /* If no action specified and we can't fast forward, then warn. */ > > base-commit: d814540bb75bbd2257f9a6bf59661a84fe8cf3cf Thanks.