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

Re: [PATCH 14/14] pull --rebase: error on no merge candidate cases

From
Stefan Beller <sbeller@google.com>
Date
May 19, 2015, 00:12 UTC
Message-ID
<CAGZ79kbhA2+AJ1Vtz6khX5uEBCCUBUuXhpBezZApZsC_txhewA@mail.gmail.com>
In-Reply-To
<1431961571-20370-15-git-send-email-pyokagan@gmail.com>
On Mon, May 18, 2015 at 8:06 AM, Paul Tan <pyokagan@gmail.com> wrote:
Show 23 quoted lines
> Tweak the error messages printed by die_no_merge_candidates() to take
> into account that we may be "rebasing against" rather than "merging
> with".
>
> Signed-off-by: Paul Tan <pyokagan@gmail.com>
> ---
>  builtin/pull.c | 42 +++++++++++++++++++++++++-----------------
>  1 file changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/builtin/pull.c b/builtin/pull.c
> index c8d673d..15b65a0 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -474,10 +474,12 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs
>         const char *remote = curr_branch ? curr_branch->remote_name : NULL;
>
>         if (*refspecs) {
> -               fprintf(stderr,
> -                       _("There are no candidates for merging among the refs that you just fetched.\n"
> -                       "Generally this means that you provided a wildcard refspec which had no\n"
> -                       "matches on the remote end.\n"));
> +               if (opt_rebase)
> +                       fputs(_("There is no candidate for rebasing against among the refs that you just fetched."), stderr);

Is there a reason you switch to fputs, instead of fprintf? $grep -I -r fputs|wc -l 123 $ grep -I -r fprintf|wc -l 689

fputs seems to be used already, though I never came across these parts of the code myself, so I wondered if we had fputs in the code base already.

My next guess would have been personal preference, though there seem to be actual reasons[1] why to use fputs.

Maybe mention the switch in the commit message (As the formatting is unnecessary, switch to the lighter fputs function)?

[1] http://stackoverflow.com/questions/5690979/fputs-vs-fprintf
Show 57 quoted lines
> +               else
> +                       fputs(_("There are no candidates for merging among the refs that you just fetched."), stderr);
> +               fputs(_("Generally this means that you provided a wildcard refspec which had no\n"
> +                       "matches on the remote end."), stderr);
>         } else if (repo && curr_branch && (!remote || strcmp(repo, remote))) {
>                 fprintf(stderr,
>                         _("You asked to pull from the remote '%s', but did not specify\n"
> @@ -485,12 +487,15 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs
>                         "for your current branch, you must specify a branch on the command line.\n"),
>                         repo);
>         } else if (!curr_branch) {
> -               fprintf(stderr,
> -                       _("You are not currently on a branch. Please specify which\n"
> -                       "branch you want to merge with. See git-pull(1) for details.\n"
> -                       "\n"
> -                       "    git pull <remote> <branch>\n"
> -                       "\n"));
> +               fputs(_("You are not currently on a branch."), stderr);
> +               if (opt_rebase)
> +                       fputs(_("Please specify which branch you want to rebase against."), stderr);
> +               else
> +                       fputs(_("Please specify which branch you want to merge with."), stderr);
> +               fputs(_("See git-pull(1) for details."), stderr);
> +               fputs("", stderr);
> +               fputs("    git pull <remote> <branch>", stderr);
> +               fputs("", stderr);
>         } else if (!curr_branch->merge_nr) {
>                 struct known_remote *remotes = NULL;
>                 const char *remote_name = "<remote>";
> @@ -499,14 +504,17 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs
>                 if (remotes && !remotes->next)
>                         remote_name = remotes->remote->name;
>
> +               fputs(_("There is no tracking information for the current branch."), stderr);
> +               if (opt_rebase)
> +                       fputs(_("Please specify which branch you want to rebase against."), stderr);
> +               else
> +                       fputs(_("Please specify which branch you want to merge with."), stderr);
> +               fputs(_("See git-pull(1) for details."), stderr);
> +               fputs("", stderr);
> +               fputs("    git pull <remote> <branch>", stderr);
> +               fputs("", stderr);
>                 fprintf(stderr,
> -                       _("There is no tracking information for the current branch.\n"
> -                       "Please specify which branch you want to merge with.\n"
> -                       "See git-pull(1) for details.\n"
> -                       "\n"
> -                       "    git pull <remote> <branch>\n"
> -                       "\n"
> -                       "If you wish to set tracking information for this branch you can do so with:\n"
> +                       _("If you wish to set tracking information for this branch you can do so with:\n"
>                         "\n"
>                         "    git branch --set-upstream-to=%s/<branch> %s\n"
>                         "\n"),
> --
> 2.1.4
>
Previous: Paul TanNext: Johannes Schindelin
Message 34 of 43 in “Make git-pull a builtin”
  1. 00/14 Make git-pull a builtinPaul Tan, May 18, 2015
  2. 01/14 pull: implement fetch + mergePaul Tan, May 18, 2015
  3. Johannes SchindelinMay 18, 2015
  4. 02/14 pull: pass verbosity, --progress flags to fetch and mergePaul Tan, May 18, 2015
  5. Johannes SchindelinMay 18, 2015
  6. Paul TanMay 21, 2015
  7. Johannes SchindelinMay 21, 2015
  8. Paul TanMay 22, 2015
  9. 03/14 pull: pass git-merge's options to git-mergePaul Tan, May 18, 2015
  10. 04/14 pull: pass git-fetch's options to git-fetchPaul Tan, May 18, 2015
  11. 05/14 pull: error on no merge candidatesPaul Tan, May 18, 2015
  12. Johannes SchindelinMay 18, 2015
  13. 06/14 pull: support pull.ff configPaul Tan, May 18, 2015
  14. Johannes SchindelinMay 18, 2015
  15. Paul TanMay 21, 2015
  16. 07/14 pull: check if in unresolved merge statePaul Tan, May 18, 2015
  17. Johannes SchindelinMay 18, 2015
  18. 08/14 pull: fast-forward working tree if head is updatedPaul Tan, May 18, 2015
  19. Johannes SchindelinMay 18, 2015
  20. 09/14 pull: implement pulling into an unborn branchPaul Tan, May 18, 2015
  21. 10/14 pull: set reflog messagePaul Tan, May 18, 2015
  22. Johannes SchindelinMay 18, 2015
  23. Junio C HamanoMay 18, 2015
  24. Paul TanMay 21, 2015
  25. 11/14 pull: teach git pull about --rebasePaul Tan, May 18, 2015
  26. Stefan BellerMay 18, 2015
  27. Johannes SchindelinMay 19, 2015
  28. Paul TanMay 31, 2015
  29. Paul TanJun 2, 2015
  30. 12/14 pull: configure --rebase via branch.<name>.rebase or pull.rebasePaul Tan, May 18, 2015
  31. Stefan BellerMay 18, 2015
  32. 13/14 pull --rebase: exit early when the working directory is dirtyPaul Tan, May 18, 2015
  33. 14/14 pull --rebase: error on no merge candidate casesPaul Tan, May 18, 2015
  34. Stefan BellerMay 19, 2015
  35. Johannes SchindelinMay 19, 2015
  36. Junio C HamanoMay 19, 2015
  37. Paul TanMay 22, 2015
  38. Johannes SchindelinMay 22, 2015
  39. Stefan BellerMay 22, 2015
  40. Junio C HamanoMay 18, 2015
  41. Paul TanMay 30, 2015
  42. Paul TanMay 30, 2015
  43. Johannes SchindelinMay 18, 2015

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.