git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: git@vger.kernel.org
Cc: Paul Mackerras <paulus@ozlabs.org>,
	Evgeny Cherpak <cherpake@me.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH] gitk: fix MacOS 10.14 "Mojave" crash on launch
Date: Tue, 24 Jul 2018 02:51:20 -0400	[thread overview]
Message-ID: <20180724065120.7664-1-sunshine@sunshineco.com> (raw)
In-Reply-To: <CAPig+cTJvJLMe4CFOb-yxqwF4udvs4G-BUiT=Kp-NZcfAWAyiQ@mail.gmail.com>

On MacOS, a "wish" application started from the terminal opens in the
background, thus doesn't match user expectation that a newly-launched
application ought to be placed in the foreground. To address this
shortcoming, both gitk and git-gui use Apple Events to send a message to
"System Events" instructing it to foreground the "wish" application by
PID.

Unfortunately, MacOS 10.14 tightens restrictions on Apple Events,
requiring explicit granting of permission to control applications in
this fashion, and apparently such granting for "Automation" is not
allowed at all[1]. As a consequence gitk crashes outright at launch time
with a "Not authorized to send Apple events to System Events" error,
thus is entirely unusable on "Mojave".

In contrast, git-gui does not crash since it deliberately[2] catches and
ignores Apple Events errors. This does mean that git-gui will not
automatically become the foreground application on "Mojave", which is a
minor inconvenience but far better than crashing outright as gitk does.

Update gitk to catch and ignore Apple Events errors, mirroring git-gui's
behavior, to avoid this crash.

(Finding and implementing an alternate approach to foregrounding the
"wish" application on "Mojave" may be desirable but is outside the scope
of this crash fix.)

[1]: https://public-inbox.org/git/D295145E-7596-4409-9681-D8ADBB9EBB0C@me.com/
[2]: https://public-inbox.org/git/CABNJ2G+h3zh+=wLA0KHjUn8TsfhqUK1Kn-1_=6hnXVRJUPhuuA@mail.gmail.com/

Reported-by: Evgeny Cherpak <cherpake@me.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

Lack of 'catch' in the 'osascript' invocation in gitk was recognized as
a potential problem as far back as June 2013 [3,4]; now it's biting
"Mojave" users, making gitk unusable.

[3]: https://public-inbox.org/git/7vk3m7yukc.fsf@alter.siamese.dyndns.org/
[4]: https://public-inbox.org/git/1l424u5.uk987q18u3oxfM%25lists@haller-berlin.de/

 gitk-git/gitk | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index a14d7a16b2..f13d1807bb 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -12210,11 +12210,13 @@ if {[catch {package require Tk 8.4} err]} {
 
 # on OSX bring the current Wish process window to front
 if {[tk windowingsystem] eq "aqua"} {
-    exec osascript -e [format {
-        tell application "System Events"
-            set frontmost of processes whose unix id is %d to true
-        end tell
-    } [pid] ]
+    catch {
+	exec osascript -e [format {
+	    tell application "System Events"
+		set frontmost of processes whose unix id is %d to true
+	    end tell
+	} [pid] ]
+    }
 }
 
 # Unset GIT_TRACE var if set
-- 
2.18.0.345.g5c9ce644c3


      parent reply	other threads:[~2018-07-24  6:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 18:05 Gitk doesn't work on macOS Mojave Evgeny Cherpak
2018-07-19 19:12 ` Eric Sunshine
2018-07-19 21:11   ` Evgeny Cherpak
2018-07-19 21:49     ` Eric Sunshine
     [not found]       ` <BD1EAEBF-B125-4D3E-A814-F8824E5D2CA8@me.com>
     [not found]         ` <CAPig+cTRdh56VVcOGzeJmUN-L0-v2i+rCdMGxdr1FEUgfUGw4g@mail.gmail.com>
     [not found]           ` <5196A9EF-3967-4E4A-A929-58CD8BE72150@me.com>
     [not found]             ` <CAPig+cRDTMW5O1T20CnK03wWb9W8ev9q34U4P4rRk-3hrnNfGg@mail.gmail.com>
     [not found]               ` <C9089D48-5516-4EF9-9260-BADD62FA3CBD@me.com>
2018-07-20  6:25                 ` Eric Sunshine
2018-07-20  6:26                   ` Evgeny Cherpak
2018-07-24  6:51                   ` Eric Sunshine [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180724065120.7664-1-sunshine@sunshineco.com \
    --to=sunshine@sunshineco.com \
    --cc=cherpake@me.com \
    --cc=git@vger.kernel.org \
    --cc=paulus@ozlabs.org \
    --subject='Re: [PATCH] gitk: fix MacOS 10.14 "Mojave" crash on launch' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).