sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
273 stars 14 forks source link

Conditional Include Not Working on Windows(?) #1314

Open beeequeue opened 2 years ago

beeequeue commented 2 years ago

Version info

Description

I'm using conditional git configs for my work directories, but it seems like they aren't working at all.

I found the other issue (#502) and trying their reproduction does not work for me.

Steps to reproduce

Steps to reproduce the behavior:

  1. Remove any user info from global git config
  2. Add a conditional include for an adjacent file e.g. C:\Users\user\.gitconfig
    [includeif "gitdir/ig:C:/Users/user/work/"]
    path = C:/Users/user/work/.gitconfig
  3. Add user info into said gitconfig
    [user]
    name = User Name
    email = an@email.com
  4. Confirm config works by running git --list --show-origin in a git repo inside work
  5. See new config not reflected in Merge for opened repos in the work folder

Expected behavior

Merge to resolve the same user settings as git does

Extras

git config --list --show-origin ``` ... file:C:/Users/bq/.gitconfig include.path=C:/Users/bq/.gitconfig.default file:C:/Users/bq/.gitconfig.default user.name=Adam file:C:/Users/bq/.gitconfig.default user.email=adam@haglund.dev file:C:/Users/bq/.gitconfig includeif.gitdir:C:/dev/izettle/.path=C:/dev/izettle/.gitconfig file:C:/dev/izettle/.gitconfig user.name=Adam Haglund file:C:/dev/izettle/.gitconfig user.email=ahaglund@paypal.com ... ```

image

retifrav commented 2 years ago

I have this problem too.

Versions:

Conditional configs are set like this:

[includeIf "gitdir/i:d:/code/"]
    path = .gitconfig-retif
[includeIf "gitdir/i:d:/work/"]
    path = .gitconfig-work

Where all the configs are located:

c:\Documents and Settings\retif\.gitconfig
c:\Documents and Settings\retif\.gitconfig-work
c:\Documents and Settings\retif\.gitconfig-retif

And git config --list --show-origin executed inside a repository does report that correct [user] credentials are fetched from the corresponding conditional config.

Sadly, Sublime Merge doesn't get those:

sm-author

willz1200 commented 1 year ago

I'm also seeing this exact same issue under Windows on Sublime Merge 2079 It looks like other configs such as [http] are functioning correctly. But perhaps that's just because they're picked up directly by git. I too see the expected name/email from the conditional config when using git config --list --show-origin. But when I try to commit in Sublime Merge I get the Edit User dialog box.

willz1200 commented 1 year ago

I've been doing some experimenting and have identified a work around. Adding a dummy name and password before the conditional statements keeps Sublime Merge happy and it will let you commit. When the commit is carried out by git, the correct name and email are obtained using the conditional statements. When drafting your commit it will say - <-> but once its committed the correct details will be down for the Author.

[user]
    email = -
    name = -
[includeIf "gitdir/i:C:/git/personal/"]
    path = C:/git/.gitconfig-personal
[includeIf "gitdir/i:C:/git/work/"]
    path = C:/git/.gitconfig-work