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

Re: [PATCH 1/3] mergetool-lib: use $XDG_CURRENT_DESKTOP to check GNOME

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Aug 5, 2020, 20:58 UTC
Message-ID
<CAPig+cR_04fL85nH1tJnbWYbwk3Bn5fRqzr2JReB2xXu9iUGAQ@mail.gmail.com>
In-Reply-To
<66a026ae678341fe7e93a89e22f76e24282cebaa.1596634463.git.gitgitgadget@gmail.com>

On Wed, Aug 5, 2020 at 3:51 PM Marco Trevisan (Treviño) via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 17 quoted lines
> To list merge tool candidates we used to use a private GNOME env
> variable (GNOME_DESKTOP_SESSION_ID) that has been deprecated for long time ago
> and removed as part of GNOME 3.30.0 release [1].
>
> So, git should instead check the XDG_CURRENT_DESKTOP env variable, that
> is supported by all the desktop environments.
>
> Since the variable is actually a colon-separated list of names that the current
> desktop is known as, we need to go through all the values to ensure
> we're using GNOME.
>
> Signed-off-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
> ---
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> @@ -266,6 +266,19 @@ run_merge_cmd () {
> +is_desktop () {
> +       IFS=':'

We usually want to restore the value of IFS after we're done with it. For instance:

    OLDIFS=$IFS
    IFS=:
and then restore it before returning:
    IFS=$OLDIFS
Show 10 quoted lines
> +       for desktop in ${XDG_CURRENT_DESKTOP}
> +       do
> +               if test "$desktop" = "$1"
> +               then
> +                       return 0
> +               fi
> +       done
> +
> +       return 1
> +}
Rather than looping and mucking with IFS, even easier would be:
is_desktop () {
    case ":$XDG_CURRENT_DESKTOP:" in
    *:$1:*) return 0 ;;
    *) return 1 ;;
    esac
}
But perhaps that's too magical for people?
> @@ -275,7 +288,7 @@ list_merge_tool_candidates () {
> -               if test -n "$GNOME_DESKTOP_SESSION_ID"
> +               if is_desktop "GNOME"

Why do we need to retire the $GNOME_DESKTOP_SESSION_ID check here, thus penalizing people who might still be on an old version of GNOME? It doesn't seem like it would be a maintenance burden to continue checking it while also taking advantage of $XDG_CURRENT_DESKTOP:

    if test -n "$GNOME_DESKTOP_SESSION_ID" || is_desktop GNOME
Previous: Marco Trevisan (Treviño) via GitGitGadgetNext: Junio C Hamano
Message 3 of 17 in “mergetool-lib: Don't use deprecated variable to detect GNOME”
  1. 0/3 mergetool-lib: Don't use deprecated variable to detect GNOMEMarco Trevisan via GitGitGadget, Aug 5, 2020
  2. 1/3 mergetool-lib: use $XDG_CURRENT_DESKTOP to check GNOMEMarco Trevisan (Treviño) via GitGitGadget, Aug 5, 2020
  3. Eric SunshineAug 5, 2020
  4. Junio C HamanoAug 5, 2020
  5. Marco Trevisan (Treviño)Aug 6, 2020
  6. 2/3 mergetool-lib: keep a list of cross desktop merge toolsMarco Trevisan (Treviño) via GitGitGadget, Aug 5, 2020
  7. Eric SunshineAug 5, 2020
  8. Johannes SixtAug 6, 2020
  9. Marco Trevisan (Treviño)Aug 6, 2020
  10. Marco Trevisan (Treviño)Aug 6, 2020
  11. 3/3 mergetool-lib: give kdiff3 prioirty in KDE environmentsMarco Trevisan (Treviño) via GitGitGadget, Aug 5, 2020
  12. Eric SunshineAug 5, 2020
  13. Marco Trevisan (Treviño)Aug 6, 2020
  14. Eric SunshineAug 6, 2020
  15. 0/2 mergetool-lib: Don't use deprecated variable to detect GNOMEMarco Trevisan via GitGitGadget, Aug 6, 2020
  16. 1/2 mergetool-lib: use $XDG_CURRENT_DESKTOP to check GNOMEMarco Trevisan (Treviño) via GitGitGadget, Aug 6, 2020
  17. 2/2 mergetool-lib: give kdiff3 priority in KDE environmentsMarco Trevisan (Treviño) via GitGitGadget, Aug 6, 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.