@@ -1860,6 +1860,8 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1860
1860
set newArgs ($increment (newArgs )) = command
1861
1861
1862
1862
set syncIrisWithDiff = 0 // whether IRIS needs to be synced with repo file changes using diff output
1863
+ set syncIrisWithDiffAfterGit = 0 // whether to sync using diff output after the git command is performed
1864
+ set syncIrisWithDiffVerbose = 1 // whether to use verbose output when syncing using diff output
1863
1865
set syncIrisWithCommand = 0 // // whether IRIS needs to be synced with repo file changes using command output
1864
1866
set diffBase = " "
1865
1867
set diffCompare = " "
@@ -1888,16 +1890,26 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1888
1890
1889
1891
if (command = " checkout" ) {
1890
1892
set syncIrisWithDiff = 1
1893
+ // Sync using diff output after the checkout has been performed
1894
+ // Allows syncing remote branches as the diff will otherwise fail prior
1895
+ set syncIrisWithDiffAfterGit = 1
1891
1896
if hasFileList {
1892
1897
set invert = 1
1893
1898
} elseif $data (args ) && $data (args (args ),diffCompare ) {
1894
- // no-op
1899
+ // Record the current branch to diff against after the checkout
1900
+ set diffBase = ..GetCurrentBranch ()
1895
1901
}
1896
1902
} elseif (command = " restore" ) {
1897
1903
// Leave diffCompare empty, this actually does the right thing.
1898
1904
set syncIrisWithDiff = 1
1899
1905
} elseif (command = " pull" ) {
1900
1906
set syncIrisWithDiff = 1
1907
+ // If performing a pull don't perform a diff until after the pull has occured.
1908
+ // This is to avoid a double fetch, as pull performs one for us and also to avoid a potential
1909
+ // race condition if the remote changes between now and the pull actually being performed.
1910
+ set syncIrisWithDiffAfterGit = 1
1911
+ // Verbose output should not be required as pull already outputs a summary
1912
+ set syncIrisWithDiffVerbose = 0
1901
1913
// The current revision, prior to the pull, will be compared against
1902
1914
set diffCompare = ..GetCurrentRevision ()
1903
1915
} elseif (command = " merge" ) || (command = " rebase" ) {
@@ -1927,12 +1939,18 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1927
1939
set newArgs ($increment (newArgs )) = args (i )
1928
1940
if (args (i ) = " checkout" ) {
1929
1941
set syncIrisWithDiff = 1
1942
+ // Sync using diff output after the checkout has been performed
1943
+ // Allows syncing remote branches as the diff will otherwise fail prior
1944
+ set syncIrisWithDiffAfterGit = 1
1930
1945
if hasFileList {
1931
1946
set invert = 1
1932
1947
} else {
1933
1948
set diffCompare = args (i + 1 )
1934
1949
if args = (i + 2 ) {
1935
1950
set diffBase = args (i + 2 )
1951
+ } else {
1952
+ // Record the current branch to diff against after the checkout
1953
+ set diffBase = ..GetCurrentBranch ()
1936
1954
}
1937
1955
}
1938
1956
} elseif (args (i ) = " restore" ) {
@@ -1964,18 +1982,16 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1964
1982
set syncIrisWithCommand = 0
1965
1983
}
1966
1984
1967
- // If performing a pull don't perform a diff until after the pull has occured.
1968
- // This is to avoid a double fetch, as pull performs one for us and also to avoid a potential
1969
- // race condition if the remote changes between now and the pull actually being performed.
1970
- if syncIrisWithDiff && (command '= " pull" ) {
1985
+ // If syncing with diff output before the git command
1986
+ if syncIrisWithDiff && 'syncIrisWithDiffAfterGit {
1971
1987
if diffBase = " " {
1972
1988
set diffBase = ..GetCurrentBranch ()
1973
1989
}
1974
1990
1975
1991
do ..RunGitCommand (" fetch" , .errorStream , .outputStream ," --prune" )
1976
1992
kill errorStream , outputStream
1977
1993
do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" diff" ,,.errorStream ,.outputStream , diffBase _$Case (diffCompare ," " :" " ,:" .." )_diffCompare , " --name-status" )
1978
- do ..ParseDiffStream (outputStream ,,.files )
1994
+ do ..ParseDiffStream (outputStream ,syncIrisWithDiffVerbose ,.files )
1979
1995
}
1980
1996
1981
1997
set outLog = ##class (%Library.File ).TempFilename ()
@@ -1998,11 +2014,10 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1998
2014
}
1999
2015
}
2000
2016
2001
- // If performing a pull then do a diff now after the pull has occured.
2002
- if syncIrisWithDiff && (command = " pull" ) {
2003
- do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" diff" ,,.errorStream ,.outputStream , diffCompare , " --name-status" )
2004
- // Verbose output should not be required as pull already outputs a summary
2005
- do ..ParseDiffStream (outputStream ,0 ,.files )
2017
+ // If syncing with diff output after the git command
2018
+ if syncIrisWithDiff && syncIrisWithDiffAfterGit {
2019
+ do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" diff" ,,.errorStream ,.outputStream , diffBase _$Case (diffCompare ," " :" " ,:" .." )_diffCompare , " --name-status" )
2020
+ do ..ParseDiffStream (outputStream ,syncIrisWithDiffVerbose ,.files )
2006
2021
}
2007
2022
2008
2023
set errStream = ##class (%Stream.FileCharacter ).%OpenId (errLog ,,.sc )
0 commit comments