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

Re: [PATCH v2] git-merge: move primary point before parenthetical

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 21, 2021, 23:46 UTC
Message-ID
<CAPig+cT=xeLn9KNHz7hiNWo0QTfc1zZ1X-czJ4n503RRhBA0XQ@mail.gmail.com>
In-Reply-To
<pull.934.v2.git.1619047347605.gitgitgadget@gmail.com>

On Wed, Apr 21, 2021 at 7:22 PM Josh Soref via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 10 quoted lines
> Usually, it is easier to read a message if it makes its primary
> point first, before giving a parenthetical note.
>
> Before:
> ` (nothing to squash)Already up to date.
> `
>
> After:
> `Already up to date (nothing to squash).
> `

Thanks. This makes perfect sense and fixes what clearly seems to be a case of swapped arguments to printf(). While the intent of the patch is quite desirable, I do have some concerns about the actual changes...

Show 17 quoted lines
> Signed-off-by: Josh Soref <jsoref@gmail.com>
> ---
> diff --git a/builtin/merge.c b/builtin/merge.c
> @@ -383,7 +383,7 @@ static void restore_state(const struct object_id *head,
>  static void finish_up_to_date(const char *msg)
>  {
>         if (verbosity >= 0)
> -               printf("%s%s\n", squash ? _(" (nothing to squash)") : "", msg);
> +               printf(msg, squash ? _(" (nothing to squash)") : "");
>         remove_merge_branch_state(the_repository);
>  }
> @@ -1482,7 +1482,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
> -               finish_up_to_date(_("Already up to date."));
> +               finish_up_to_date(_("Already up to date%s.\n"));
> @@ -1566,7 +1566,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
> -                       finish_up_to_date(_("Already up to date. Yeeah!"));
> +                       finish_up_to_date(_("Already up to date%s. Yeeah!\n"));

I see why you changed the calling convention, making it the responsibility of the caller to supply the "%s" so that the "(nothing to squash)" annotation gets inserted before the period at the end of "Already up to date". However, this makes things confusing for people translating the text to other languages since they won't have enough context to understand what gets interpolated in place of "%s".

In fact (not a fault of your patch), this sort of "sentence Lego" was already a bit difficult on translators because they couldn't see the entire context of "Already up to date" and "(nothing to squash)" together, thus could only translate them individually which may have led to inferior translations in some languages.

Ideally, for the sake of translators, we want to give them as much context as possible, such as the entire "Already up to date (nothing to squash)". So, keeping translators and context in mind, and asking if we really need to that rather odd "Yeeah!", an alternative way to resolve this problem would be like this:

    static void finish_up_to_date()
    {
        if (verbosity >= 0) {
            if (squash)
                puts(_("Already up to date (nothing to squash)."));
            else
                puts(_("Already up to date."));
        }
        remove_merge_branch_state(the_repository);
    }
And then the callers reduce simply to:
    finish_up_to_date();
Previous: Josh Soref via GitGitGadgetNext: Josh Soref via GitGitGadget
Message 4 of 19 in “git-merge: move space to between strings”
  1. git-merge: move space to between stringsJosh Soref via GitGitGadget, Apr 18, 2021
  2. Junio C HamanoApr 18, 2021
  3. git-merge: move primary point before parentheticalJosh Soref via GitGitGadget, Apr 21, 2021
  4. Eric SunshineApr 21, 2021
  5. git-merge: rewrite already up to date messageJosh Soref via GitGitGadget, Apr 22, 2021
  6. Eric SunshineApr 22, 2021
  7. Junio C HamanoApr 28, 2021
  8. Junio C HamanoApr 29, 2021
  9. Josh SorefMay 2, 2021
  10. Eric SunshineMay 2, 2021
  11. Junio C HamanoMay 2, 2021
  12. Junio C HamanoMay 2, 2021
  13. Eric SunshineMay 2, 2021
  14. 0/2 normalize & fix merge "up to date" messagesEric Sunshine, May 2, 2021
  15. 2/2 merge: fix swapped "up to date" message componentsEric Sunshine, May 2, 2021
  16. Junio C HamanoMay 3, 2021
  17. Eric SunshineMay 3, 2021
  18. Junio C HamanoMay 3, 2021
  19. 1/2 merge(s): apply consistent punctuation to "up to date" messagesEric Sunshine, May 2, 2021

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.