@@ -447,8 +447,7 @@ ClassMethod MergeDefaultRemoteBranch(Output alert As %String = "") As %Boolean
447
447
do ..RunGitWithArgs (.errStream , .outStream , " fetch" , " origin" , defaultMergeBranch _" :" _defaultMergeBranch )
448
448
do ..PrintStreams (errStream , outStream )
449
449
450
- do ..RunGitWithArgs (,.outStream , " rev-parse" , " HEAD" )
451
- set startSha = outStream .ReadLine ()
450
+ set startSha = ..GetCurrentRevision ()
452
451
453
452
// Start a transaction so code changes can be rolled back
454
453
set initTLevel = $TLevel
@@ -556,6 +555,13 @@ ClassMethod GetCurrentBranch() As %String
556
555
quit branchName
557
556
}
558
557
558
+ ClassMethod GetCurrentRevision () As %String
559
+ {
560
+ do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" rev-parse" ,,.errStream ,.outStream ," HEAD" )
561
+ set revision = outStream .ReadLine (outStream .Size )
562
+ quit revision
563
+ }
564
+
559
565
ClassMethod Pull (remote As %String = " origin" ) As %Status
560
566
{
561
567
New %gitSCOutputFlag
@@ -1731,7 +1737,11 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1731
1737
} elseif (command = " restore" ) {
1732
1738
// Leave diffCompare empty, this actually does the right thing.
1733
1739
set syncIrisWithDiff = 1
1734
- } elseif (command = " merge" ) || (command = " rebase" ) || (command = " pull" ) {
1740
+ } elseif (command = " pull" ) {
1741
+ set syncIrisWithDiff = 1
1742
+ // The current revision, prior to the pull, will be compared against
1743
+ set diffCompare = ..GetCurrentRevision ()
1744
+ } elseif (command = " merge" ) || (command = " rebase" ) {
1735
1745
set syncIrisWithCommand = 1
1736
1746
if $data (args ) && $data (args (args ),diffCompare ) {
1737
1747
// no-op
@@ -1795,7 +1805,10 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1795
1805
set syncIrisWithCommand = 0
1796
1806
}
1797
1807
1798
- if syncIrisWithDiff {
1808
+ // If performing a pull don't perform a diff until after the pull has occured.
1809
+ // This is to avoid a double fetch, as pull performs one for us and also to avoid a potential
1810
+ // race condition if the remote changes between now and the pull actually being performed.
1811
+ if syncIrisWithDiff && (command '= " pull" ) {
1799
1812
if diffBase = " " {
1800
1813
set diffBase = ..GetCurrentBranch ()
1801
1814
}
@@ -1809,23 +1822,30 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1809
1822
set outLog = ##class (%Library.File ).TempFilename ()
1810
1823
set errLog = ##class (%Library.File ).TempFilename ()
1811
1824
1812
- set command = $extract (..GitBinPath (),2 ,*-1 )
1825
+ set gitCommand = $extract (..GitBinPath (),2 ,*-1 )
1813
1826
1814
1827
set baseArgs = " /STDOUT=" _$$$QUOTE(outLog )_" /STDERR=" _$$$QUOTE(errLog )_$case (inFile , " " :" " , :" /STDIN=" _$$$QUOTE(inFile ))
1815
1828
try {
1816
1829
// Inject instance manager directory as global git config home directory
1817
1830
// On Linux, this avoids trying to use /root/.config/git/attributes for global git config
1818
1831
set env (" XDG_CONFIG_HOME" ) = ##class (%File ).ManagerDirectory ()
1819
- set returnCode = $zf (-100 ," /ENV=env... " _baseArgs ,command ,newArgs ...)
1832
+ set returnCode = $zf (-100 ," /ENV=env... " _baseArgs ,gitCommand ,newArgs ...)
1820
1833
} catch e {
1821
1834
if $$$isWINDOWS {
1822
- set returnCode = $zf (-100 ,baseArgs ,command ,newArgs ...)
1835
+ set returnCode = $zf (-100 ,baseArgs ,gitCommand ,newArgs ...)
1823
1836
} else {
1824
1837
// If can't inject XDG_CONFIG_HOME (older IRIS version), need /SHELL on Linux to avoid permissions errors trying to use root's config
1825
- set returnCode = $zf (-100 ," /SHELL " _baseArgs ,command ,newArgs ...)
1838
+ set returnCode = $zf (-100 ," /SHELL " _baseArgs ,gitCommand ,newArgs ...)
1826
1839
}
1827
1840
}
1828
1841
1842
+ // If performing a pull then do a diff now after the pull has occured.
1843
+ if syncIrisWithDiff && (command = " pull" ) {
1844
+ do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" diff" ,,.errorStream ,.outputStream , diffCompare , " --name-status" )
1845
+ // Verbose output should not be required as pull already outputs a summary
1846
+ do ..ParseDiffStream (outputStream ,0 ,.files )
1847
+ }
1848
+
1829
1849
set errStream = ##class (%Stream.FileCharacter ).%OpenId (errLog ,,.sc )
1830
1850
set outStream = ##class (%Stream.FileCharacter ).%OpenId (outLog ,,.sc )
1831
1851
set outStream .TranslateTable =" UTF8"
0 commit comments