Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Git Bash pinnable #263

Closed
dscho opened this issue Aug 7, 2015 · 17 comments
Closed

Make Git Bash pinnable #263

dscho opened this issue Aug 7, 2015 · 17 comments
Assignees

Comments

@dscho
Copy link
Member

dscho commented Aug 7, 2015

After starting Git Bash, the context menu in the Task Bar icon allows to pin the program. However, starting Git Bash that way does not start the same program but instead launches mintty.exe (and bash.exe is launched in there, but without the --login flag and without the MSYSTEM environment variable set appropriately).

Investigate whether this is fixed by setting the System.AppUserModel.RelaunchCommand property from the Git wrapper might help (as hinted in this blog). (I hinted at that already here but that information was ignored there.)

@dscho
Copy link
Member Author

dscho commented Aug 14, 2015

Hmm. It seems that I fail to set the RelaunchCommand property in mintty's properties from another process (namely the Git wrapper process that launched mintty): Windows always comes back with the answer "The system could not find the environment option that was entered."

It looks as if a hacked up mintty would be able to set the RelaunchCommand property correctly. My current thinking: add two command line options for the RelaunchCommand and the RelaunchDisplayNameResource property. Probably similar to the ID property handled [here](https://github.com/mintty/mintty/blob/98110239312416152b1339faf8772f33790520d2/src/config.c#L213 and here.

@nalla
Copy link

nalla commented Aug 14, 2015

Wait a minute. I think it should be enough to set an app id for the git-wrapper. You can just provide the app id that mintty is using. Just call mintty -o AppID=test

@nalla
Copy link

nalla commented Aug 14, 2015

You can confirm this theory following the steps outlined below.

first, change your registry so that you edit the System.AppUserModel.ID in the properties of the shortcut.

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\.lnk\ShellEx\{00021500-0000-0000-C000-000000000046}]

[HKEY_CLASSES_ROOT\lnkfile]
"InfoTip"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"ConflictPrompt"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"ContentViewModeForBrowse"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"ContentViewModeForSearch"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"ContentViewModeLayoutPatternForBrowse"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"ContentViewModeLayoutPatternForSearch"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"ExtendedTileInfo"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"PreviewDetails"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"PreviewTitle"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"QuickTip"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"SetDefaultsFor"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"TileInfo"="prop:System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay"
"FullDetails"="prop:System.PropGroup.Description;System.ItemTypeText;System.Comment;System.Link.TargetParsingPath;System.AppUserModel.ID;System.ItemFolderPathDisplay;prop:System.PropGroup.FileSystem;System.ItemNameDisplay;System.Size;System.DateCreated;System.DateModified;System.FileAttributes;*System.OfflineAvailability;*System.OfflineStatus;*System.SharedWith;*System.FileOwner;*System.ComputerName"
"FileOperationPrompt"="prop:System.ItemTypeText;System.FileOwner;System.Author;System.Title;System.Subject;System.Comment;System.DateModified;System.Link.TargetParsingPath"

Now open the Git for windows shortcut in the taskbar and set the id in the details pane to test.

Then add the following to your /etc/minttyrc file: AppID=test

And viola: it just works.

@nalla
Copy link

nalla commented Aug 14, 2015

So I think we can avoid patching mintty by simply calling SetCurrentProcessExplicitAppUserModelID in git-wrapper.c and then call mintty -o AppID=git-wrappers-id

@dscho
Copy link
Member Author

dscho commented Aug 14, 2015

Nice!

This would not really help with portable Git, though, correct?

@nalla
Copy link

nalla commented Aug 14, 2015

Sure. Why not? If git-bash sets an appid per Windows API and then calls mintty -o AppID= with that id?

@dscho
Copy link
Member Author

dscho commented Aug 14, 2015

Oh, wait, the registry entry is not even required if we set the AppID in the Git wrapper as well as the Git Bash... I get it now!

@nalla
Copy link

nalla commented Aug 14, 2015

Right its just a way to set an id for a shortcut ig the exe provides none.

@dscho
Copy link
Member Author

dscho commented Aug 14, 2015

I really like the idea. I'm on it.

@dscho
Copy link
Member Author

dscho commented Aug 15, 2015

Sadly, it is not as easy 😞... In my tests, setting the app ID via SetCurrentProcessExplicitAppUserModelID() in the Git wrapper and passing -o AppID=... to mintty.exe did not work. The pinned icon still launched just mintty.

I then continued to work on implementing support for the RelaunchCommand property and the RelaunchDisplayNameResource property.

Unfortunately, it also did not work at first (even if it had worked in some tests I did yesterday). Hours later, turns out that the reason is well explained in the MSDN page:

This property is used only if a window has an explicit Application User Model ID (AppUserModelID) (System.AppUserModel.ID, set through SHGetPropertyStoreForWindow). If the window does not have an explicit AppUserModelID, this property is ignored and the window is grouped and pinned as if it were part of the process that owns it.

So the only way to get it to work was by setting the combination of ID, RelaunchCommand and RelaunchDisplayNameResource together. The important part is that I have to set an ID explicitly. Otherwise, the display name is respected but not the relaunch command.

This got me curious, though, and I tested whether things start to work properly if I tell mintty to set the System.AppUserModel.ID property explicitly, i.e. in addition to calling SetCurrentProcessExplicitAppUserModelID() (which mintty does when the -o AppID=... option is used), but not set the RelaunchCommand at all.

Alas, this works! Restarting the Git Bash from a pinned icon works if mintty's window handle has an app ID associated with it explicitly, but not when it is done only implicitly via the process.

(It might be a quirk just of Windows Server 2012 R2, on which I do all my testing and development, meaning that we have to patch mintty in any case...)

So at the moment, I have patches for mintty and a topic branch for our MSYS2-packages that I still need to rebase to upstream.

@dscho
Copy link
Member Author

dscho commented Aug 15, 2015

See git-for-windows/MSYS2-packages@master...dscho:pinning-mintty for the current state of things. Still needs serious testing.

@nalla
Copy link

nalla commented Aug 15, 2015

The mintty -o solution seems only to work if the shortcut is already targeting git-bash. :-(

@dscho
Copy link
Member Author

dscho commented Aug 16, 2015

@nalla thanks for confirming! FYI I opened a PR for mintty: mintty/mintty#471

@dscho
Copy link
Member Author

dscho commented Aug 16, 2015

Update: I now have topic branches in three (!) repositories that work together to address this ticket:

  • in MSYS2-packages, to teach mintty to support pinning to the task bar better (more on that below)
  • in git, to support setting the application ID of the Git wrapper, and
  • in `MINGW-packages, to make use of the previous two change sets in Git Bash.

The changes for mintty were implemented as a patch series, applied on top of mintty's official sources, to allow setting the application ID, the display name and the relaunch command explicitly for the mintty window. I also submitted this patch series as Pull Request to the mintty project: mintty/mintty#471

Long day.

dscho added a commit to git-for-windows/MSYS2-packages that referenced this issue Aug 17, 2015
Part 1/3 of fixing git-for-windows/git#263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 17, 2015
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to git-for-windows/MINGW-packages that referenced this issue Aug 17, 2015
Part 3/3 of fixing git-for-windows/git#263

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Member Author

dscho commented Aug 17, 2015

With these three merges, this ticket is finally addressed.

@dscho dscho closed this as completed Aug 17, 2015
@ciaranj
Copy link

ciaranj commented Aug 19, 2015

Did this (awesome!) work make the 2.5.0 release? I've updated and I still appear to have the 'jumbled' stacks issue (for git-bash.exe incidentally, git-cmd.exe appears to work as 'expected')

@dscho
Copy link
Member Author

dscho commented Aug 19, 2015

It made it into the release. You most likely have a stale Git Bash.lnk file somewhere in the $HOME\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\ directory structure, most likely in the funny-named subdirectory of ImplicitAppShortcuts.

Once you unpin, delete that .lnk file and re-pin, it should work (that is what fixed it here).

dscho added a commit to dscho/git that referenced this issue Aug 30, 2015
Part 2/3 of fixing git-for-windows#263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Sep 10, 2015
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/git that referenced this issue Sep 18, 2015
Part 2/3 of fixing git-for-windows#263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 15, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 15, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 20, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 20, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 22, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 22, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 22, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 25, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 25, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 25, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 26, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 26, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho pushed a commit that referenced this issue Aug 27, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 28, 2016
Part 2/3 of fixing #263

Signed-off-by: Johannes Schindelin <[email protected]>
jeffhostetler pushed a commit to jeffhostetler/git that referenced this issue Apr 20, 2020
We found a user who had set "core.gvfs = false" in their global
config. This should not have been necessary, but it also should not
have caused a problem. However, it did.

The reason is that gvfs_load_config_value() is called from config.c
when reading config key/value pairs from all the config files. The
local config should override the global config, and this is done by
config.c reading the global config first then reading the local
config. However, our logic only allowed writing the core_gvfs
variable once.

Put the guards against multiple assignments of core_gvfs into
gvfs_config_is_set() instead, because that will fix the problem
_and_ keep multiple calls to gvfs_config_is_set() from slowing down.
jeffhostetler pushed a commit to jeffhostetler/git that referenced this issue Jun 3, 2020
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	git-for-windows#85
	git-for-windows#89
	git-for-windows#91
	git-for-windows#98
	git-for-windows#243
	git-for-windows#263

Signed-off-by: Derrick Stolee <[email protected]>
jeffhostetler pushed a commit to jeffhostetler/git that referenced this issue May 14, 2021
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	git-for-windows#85
	git-for-windows#89
	git-for-windows#91
	git-for-windows#98
	git-for-windows#243
	git-for-windows#263

Signed-off-by: Derrick Stolee <[email protected]>
jeffhostetler pushed a commit to jeffhostetler/git that referenced this issue Jun 21, 2021
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	git-for-windows#85
	git-for-windows#89
	git-for-windows#91
	git-for-windows#98
	git-for-windows#243
	git-for-windows#263

Signed-off-by: Derrick Stolee <[email protected]>
jeffhostetler pushed a commit to jeffhostetler/git that referenced this issue Aug 18, 2021
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	git-for-windows#85
	git-for-windows#89
	git-for-windows#91
	git-for-windows#98
	git-for-windows#243
	git-for-windows#263

Signed-off-by: Derrick Stolee <[email protected]>
mjcheetham pushed a commit to mjcheetham/git that referenced this issue Jun 16, 2022
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	git-for-windows#85
	git-for-windows#89
	git-for-windows#91
	git-for-windows#98
	git-for-windows#243
	git-for-windows#263

Signed-off-by: Derrick Stolee <[email protected]>
mjcheetham pushed a commit to mjcheetham/git that referenced this issue Jul 23, 2024
Most of these were done in private before microsoft/git. However,
the following pull requests modified the core feature:

	git-for-windows#85
	git-for-windows#89
	git-for-windows#91
	git-for-windows#98
	git-for-windows#243
	git-for-windows#263

Signed-off-by: Derrick Stolee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants