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

RE: [PATCH v7 0/5] making pull advice not to trigger when unneeded

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Dec 15, 2020, 06:30 UTC
Message-ID
<5fd85811c3a6_d7c48208aa@natae.notmuch>
In-Reply-To
<20201214202647.3340193-1-gitster@pobox.com>
Junio C Hamano wrote:
Show 18 quoted lines
> Just to show what was pushed out on 'seen' while I was cutting the
> preview release...
> 
> This is based on Felipe's v6 (which was mislabled as v5 but sent on
> a different day from the true v5), with two clean-up commits
> inserted between Felipe's second step (now 2/5) and the third step
> (now 5/5, with necessary adjustments).
> 
> Even with the "correct condition" clean-up, I am not quite happy
> with the clarity of the logic around there.
> 
> I think !opt_ff does not exactly belong to the condition, if we
> consider that the eventual endgame should be to stop non-ff
> operation without merge or rebase by default with an error, and that
> should happen in this block.  The error message there should say
> "unable to fast-forward; must merge or rebase", which should equally
> apply to those who gave "--ff-only" explicitly, even though they may
> not need the advice message.

Agreed. Additionally it doesn't make sense that --ff skips the warning entirely, even though the user has not specified a merge or a rebase (as you yourself noted in a review of the test cases).

Show 10 quoted lines
> To avoid the ugly-looking "strcmp()" in the above, we may need to
> adjust "--ff" (fast-forward without creating an extra merge commit)
> and "--no-ff" (create an extra merge commit when the history could
> be fast-forwarded) to imply "merge", though.  It would automatically
> make rebase_unspecified would become false.  With such a tweak, we
> can then simplify it further to
> 
> -	if (rebase_unspecified && !can_ff &&
> -	    (!opt_ff || !strcmp("--ff-only", opt_ff))) {
> +	if (rebase_unspecified && !can_ff) {
Currently this is a rebase:
  git pull --rebase --ff

With your proposed change it would be an implied merge. I think it makes sense, but it's still a change in behavior.

This patch should do the trick:
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -973,6 +973,11 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
        if (opt_rebase < 0)
                opt_rebase = config_get_rebase(&rebase_unspecified);
 
+       if (opt_ff && (!strcmp(opt_ff, "--ff") || !strcmp(opt_ff, "--no-ff"))) {
+               opt_rebase = 0;
+               rebase_unspecified = 0;
+       }
+
        if (read_cache_unmerged())
                die_resolve_conflict("pull");
 
Or do you mean --ff doesn't override --rebase? Therefore it's more of an
internal conceptual change.
-- 
Felipe Contreras
Previous: Felipe ContrerasNext: Junio C Hamano
Message 16 of 21 in “making pull advice not to trigger when unneeded”
  1. 0/5 making pull advice not to trigger when unneededJunio C Hamano, Dec 14, 2020
  2. 2/5 pull: give the advice for choosing rebase/merge much laterJunio C Hamano, Dec 14, 2020
  3. 3/5 pull: get rid of unnecessary global variableJunio C Hamano, Dec 14, 2020
  4. Felipe ContrerasDec 14, 2020
  5. Junio C HamanoDec 14, 2020
  6. Felipe ContrerasDec 15, 2020
  7. 4/5 pull: correct condition to trigger non-ff adviceJunio C Hamano, Dec 14, 2020
  8. Felipe ContrerasDec 14, 2020
  9. Junio C HamanoDec 14, 2020
  10. Felipe ContrerasDec 15, 2020
  11. 1/5 pull: refactor fast-forward checkJunio C Hamano, Dec 14, 2020
  12. 5/5 pull: display default warning only when non-ffJunio C Hamano, Dec 14, 2020
  13. Felipe ContrerasDec 14, 2020
  14. Junio C HamanoDec 14, 2020
  15. Felipe ContrerasDec 15, 2020
  16. Felipe ContrerasDec 15, 2020
  17. Junio C HamanoDec 15, 2020
  18. Felipe ContrerasDec 15, 2020
  19. Felipe ContrerasDec 18, 2020
  20. Junio C HamanoDec 23, 2020
  21. Felipe ContrerasDec 23, 2020

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.