@@ -10,6 +10,7 @@ function Get-GitVersion {
1010 return $null
1111 }
1212
13+ # Execute 'git --version' and capture output
1314 $gitVersion = & $gitExecutable -- version 2> $null
1415
1516 if ($gitVersion -match ' git version\s+(\S+)' ) {
@@ -28,11 +29,13 @@ function Get-GitShimPath {
2829 [Parameter (Mandatory = $true )]
2930 [string ]$GitPath
3031 )
32+ # Check if there is a shim file - if yes, read the actual executable path
33+ # See: github.com/ScoopInstaller/Shim
3134
3235 $shimFile = Join-Path $GitPath " git.shim"
3336 if (Test-Path $shimFile ) {
3437 $shimContent = Get-Content $shimFile - Raw
35- if ($shimContent -match ' path\s*=\s*(.+)' ) {
38+ if ($shimContent -match ' ^\s* path\s*=\s*(.+)\s*$ ' ) {
3639 $GitPath = $Matches [1 ].Trim().Replace(' \git.exe' , ' ' )
3740 }
3841 }
@@ -123,6 +126,13 @@ function Set-GitPath {
123126 [string ]$GitPathUser
124127 )
125128
129+ # Proposed Behavior
130+
131+ # Modify the path if we are using VENDORED Git, do nothing if using USER Git.
132+ # If User Git is installed but is older, match its path config adding paths
133+ # in the same path positions allowing a user to configure Cmder Git path
134+ # using locally installed Git Path Config.
135+
126136 if ($GitType -ne ' VENDOR' ) {
127137 return $env: Path
128138 }
@@ -134,19 +144,24 @@ function Set-GitPath {
134144 Write-Verbose " Cmder 'profile.ps1': Replacing older user Git path '$GitPathUser ' with newer vendored Git path '$GitRoot ' in the system path..."
135145 $newPath = $newPath -ireplace [regex ]::Escape($GitPathUser ), $GitRoot
136146 } else {
137- # Add Git cmd directory
147+ # Add Git cmd directory to the path
138148 $gitCmd = Join-Path $GitRoot " cmd"
139149 if (-not ($newPath -match [regex ]::Escape($gitCmd ))) {
140150 Write-Debug " Adding $gitCmd to the path"
141151 $newPath = " $gitCmd ;$newPath "
142152 }
143153
154+ <<<<<<< HEAD
155+ # Add mingw[32|64]\bin directories to the path, if they exist and not already present
156+ foreach ($mingw in @ (' mingw64' , ' mingw32' )) {
157+ =======
144158 # Add mingw bin directory
145159 # Prefer mingw64 on 64-bit systems, mingw32 on 32-bit systems
146160 $is64Bit = [Environment ]::Is64BitOperatingSystem
147161 $mingwDirs = if ($is64Bit ) { @ (' mingw64' , ' mingw32' ) } else { @ (' mingw32' ) }
148162
149163 foreach ($mingw in $mingwDirs ) {
164+ >>>>>>> a1def7195e8050d0f964f292d51c695e0e07dbef
150165 $mingwBin = Join-Path $GitRoot " $mingw \bin"
151166 if ((Test-Path $mingwBin ) -and -not ($newPath -match [regex ]::Escape($mingwBin ))) {
152167 Write-Debug " Adding $mingwBin to the path"
@@ -155,7 +170,7 @@ function Set-GitPath {
155170 }
156171 }
157172
158- # Add usr bin directory
173+ # Add usr\ bin directory to the path
159174 $usrBin = Join-Path $GitRoot " usr\bin"
160175 if ((Test-Path $usrBin ) -and -not ($newPath -match [regex ]::Escape($usrBin ))) {
161176 Write-Debug " Adding $usrBin to the path"
0 commit comments