My regular updates to apple/swift caused a conflict!

I regularly run "utils/update-checkout" for my copy of Apple's Swift compiler repo, and it got a conflict on itself. I have not altered any code.

It's on the last five lines (183 - 188) of "test/api-digester/Outputs/stability-stdlib-abi.swift.expected"

<<<<<<< HEAD
Func Sequence.count(where:) has been removed
=======
Constructor _Pointer.init(_:) has been removed
>>>>>>> Remove overly-permissive UnsafePointer init

Using "git status" on the "swift" directory gave me:

rebase in progress; onto 26bf98f2ec
You are currently rebasing branch 'master' on '26bf98f2ec'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   stdlib/public/core/Pointer.swift
	modified:   stdlib/public/core/StringBreadcrumbs.swift
	modified:   validation-test/compiler_crashers_2_fixed/0060-sr2702.swift

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

	both modified:   test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Since it's your own code on both sides of the conflict, I have no idea how to fix it. I can't work on my own changes until this is fixed.

Not sure why this happened... but if you stop the rebase and pass reset to remote to update checkout, it will do a hard reset avoiding whatever weird thing happened. Keep in mind you will lose any local changes.

OK, I'm running:

git rebase --abort

then:

git fetch upstream master

where "upstream" is Apple's copy, with results:

remote: Enumerating objects: 223, done.
remote: Counting objects: 100% (223/223), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 295 (delta 219), reused 220 (delta 219), pack-reused 72
Receiving objects: 100% (295/295), 107.93 KiB | 326.00 KiB/s, done.
Resolving deltas: 100% (241/241), completed with 93 local objects.
From https://github.com/apple/swift
 * branch                  master     -> FETCH_HEAD
   ab3589651f..b6517c50a1  master     -> upstream/master

Then:

git pull upstream master

with results:

From https://github.com/apple/swift
 * branch                  master     -> FETCH_HEAD
Updating ab3589651f..b6517c50a1
Fast-forward
 include/swift/AST/GenericSignatureBuilder.h        |  35 +-
 include/swift/AST/Types.h                          |  28 +-
 include/swift/SIL/SILBuilder.h                     |   8 +-
 include/swift/SIL/SILModule.h                      |   7 -
 include/swift/SIL/TypeLowering.h                   |  58 +-
 lib/AST/ASTContext.cpp                             | 101 +--
 lib/AST/GenericSignatureBuilder.cpp                |  29 +-
 lib/IRGen/GenCall.cpp                              |  33 +-
 lib/IRGen/GenKeyPath.cpp                           |   2 +-
 lib/IRGen/GenType.cpp                              |   8 +-
 lib/IRGen/IRGen.cpp                                | 135 +++-
 lib/SIL/SILFunctionType.cpp                        |  18 +-
 lib/SIL/SILType.cpp                                |  13 +-
 lib/SIL/SILVerifier.cpp                            |  14 +-
 lib/SIL/TypeLowering.cpp                           | 120 +--
 lib/SILGen/SILGen.cpp                              |  11 +-
 lib/SILGen/SILGen.h                                |   5 -
 lib/SILGen/SILGenApply.cpp                         |   3 +-
 lib/SILGen/SILGenExpr.cpp                          |  47 +-
 lib/SILOptimizer/Analysis/ArraySemantic.cpp        |   4 +-
 lib/SILOptimizer/IPO/CapturePromotion.cpp          |  11 +-
 lib/SILOptimizer/Mandatory/AddressLowering.cpp     |   2 +-
 lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp   |   4 +-
 lib/SILOptimizer/Transforms/AllocBoxToStack.cpp    |   4 +-
 .../Transforms/SILLowerAggregateInstrs.cpp         |  12 +-
 lib/SILOptimizer/Transforms/SILMem2Reg.cpp         |   3 +-
 lib/SILOptimizer/Utils/CastOptimizer.cpp           |   4 +-
 lib/Sema/CSSimplify.cpp                            |  39 +-
 lib/Sema/CSSolver.cpp                              | 175 +++--
 lib/Sema/ConstraintSystem.cpp                      |  92 ---
 lib/Sema/ConstraintSystem.h                        |  44 +-
 stdlib/public/core/CMakeLists.txt                  |   2 +
 stdlib/public/core/CollectionDifference.swift      | 401 ++++++++++
 stdlib/public/core/Diffing.swift                   | 806 +++++++++++++++++++++
 stdlib/public/core/GroupInfo.json                  |   2 +
 test/Constraints/common_type_objc.swift            |  22 +
 test/IRGen/Inputs/noreturn.h                       |  19 +
 test/IRGen/noreturn.swift                          |  31 +
 test/Interpreter/bridged_casts_folding.swift       | 641 ++++++++++++++++
 test/SILOptimizer/bridged_casts_folding.swift      |   1 -
 test/stdlib/Diffing.swift                          | 666 +++++++++++++++++
 utils/build-presets.ini                            |   5 +
 42 files changed, 3154 insertions(+), 511 deletions(-)
 create mode 100644 stdlib/public/core/CollectionDifference.swift
 create mode 100644 stdlib/public/core/Diffing.swift
 create mode 100644 test/Constraints/common_type_objc.swift
 create mode 100644 test/IRGen/Inputs/noreturn.h
 create mode 100644 test/IRGen/noreturn.swift
 create mode 100644 test/Interpreter/bridged_casts_folding.swift
 create mode 100644 test/stdlib/Diffing.swift

Now I call:

./utils/update-checkout --reset-to-remote

and get this error:

update-checkout usage error: --reset-to-remote must specify --scheme=foo

What scheme do I put here?

--scheme=master

Starting again with:

./utils/update-checkout --reset-to-remote --scheme=master

got (really long):

Running ``update_single_repository`` with up to 8 processes.
Updating '/Volumes/ExtremeSSD/swift-source/compiler-rt'
Updating '/Volumes/ExtremeSSD/swift-source/sourcekit-lsp'
Updating '/Volumes/ExtremeSSD/swift-source/llvm'
Updating '/Volumes/ExtremeSSD/swift-source/swift-xcode-playground-support'
Updating '/Volumes/ExtremeSSD/swift-source/libcxx'
Updating '/Volumes/ExtremeSSD/swift-source/indexstore-db'
Updating '/Volumes/ExtremeSSD/swift-source/swift-stress-tester'
Updating '/Volumes/ExtremeSSD/swift-source/clang'
/Volumes/ExtremeSSD/swift-source/sourcekit-lsp
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/indexstore-db
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swift-stress-tester
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swift-xcode-playground-support
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/compiler-rt
+ git checkout stable
Your branch is up to date with 'origin/stable'.
Already on 'stable'

/Volumes/ExtremeSSD/swift-source/sourcekit-lsp
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/sourcekit-lsp
   079057f..dbd474e  master     -> origin/master

+ git tag -l master
/Volumes/ExtremeSSD/swift-source/indexstore-db
+ git fetch --recurse-submodules=yes --tags

+ git tag -l master
+ git branch --list master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/sourcekit-lsp
+ git reset --hard origin/master
HEAD is now at dbd474e Merge pull request #90 from benlangmuir/perf-slow

Updating '/Volumes/ExtremeSSD/swift-source/llbuild'
/Volumes/ExtremeSSD/swift-source/indexstore-db
+ git reset --hard origin/master
HEAD is now at 0921902 Merge pull request #9 from benlangmuir/14

Updating '/Volumes/ExtremeSSD/swift-source/cmark'
/Volumes/ExtremeSSD/swift-source/swift-stress-tester
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-stress-tester
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/cmark
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swift-stress-tester
+ git reset --hard origin/master
HEAD is now at 20648a4 Merge pull request #42 from akyrtzi/endposition

Updating '/Volumes/ExtremeSSD/swift-source/lldb'
/Volumes/ExtremeSSD/swift-source/libcxx
+ git checkout stable
Your branch is up to date with 'origin/stable'.
Already on 'stable'

/Volumes/ExtremeSSD/swift-source/llbuild
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swift-xcode-playground-support
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-xcode-playground-support
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/swift-xcode-playground-support
+ git reset --hard origin/master
HEAD is now at 6c112c2 Merge pull request #31 from cwakamo/migrate-to-swift-4.2

Updating '/Volumes/ExtremeSSD/swift-source/swift-syntax'
/Volumes/ExtremeSSD/swift-source/cmark
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-cmark
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/swift-syntax
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/cmark
+ git reset --hard origin/master
HEAD is now at 32fa496 Merge pull request #8 from nkcsgexi/update-branch

Updating '/Volumes/ExtremeSSD/swift-source/swift-corelibs-xctest'
/Volumes/ExtremeSSD/swift-source/compiler-rt
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-compiler-rt
   466854425..681372b5f  upstream-with-swift -> origin/upstream-with-swift
 * [new tag]             swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l stable
+ git branch --list stable
/Volumes/ExtremeSSD/swift-source/swift-corelibs-xctest
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/libcxx
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-libcxx
   1f820d84e..526bce48c  upstream-with-swift -> origin/upstream-with-swift

+ git tag -l stable
+ git branch --list stable
/Volumes/ExtremeSSD/swift-source/llbuild
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-llbuild
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/lldb
+ git checkout stable
Your branch is up to date with 'origin/stable'.
Already on 'stable'

/Volumes/ExtremeSSD/swift-source/llbuild
+ git reset --hard origin/master
HEAD is now at ed7a4a1 Merge pull request #439 from dmbryson/dbcmd-additions

Updating '/Volumes/ExtremeSSD/swift-source/ninja'
/Volumes/ExtremeSSD/swift-source/swift-syntax
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-syntax
   4e09ab4..f650fa3  master     -> origin/master

+ git tag -l master
/Volumes/ExtremeSSD/swift-source/clang
+ git checkout stable
Your branch is up to date with 'origin/stable'.
Already on 'stable'

+ git branch --list master
/Volumes/ExtremeSSD/swift-source/ninja
+ git checkout release
Your branch is up to date with 'origin/release'.
Already on 'release'

/Volumes/ExtremeSSD/swift-source/swift-syntax
+ git reset --hard origin/master
HEAD is now at f650fa3 Remove some leftover semicolons, NFC

Updating '/Volumes/ExtremeSSD/swift-source/swift-corelibs-foundation'
/Volumes/ExtremeSSD/swift-source/compiler-rt
+ git reset --hard origin/stable
HEAD is now at cea585843 Merge pull request #35 from apple/stable-next

Updating '/Volumes/ExtremeSSD/swift-source/swift-integration-tests'
/Volumes/ExtremeSSD/swift-source/swift-integration-tests
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swift-corelibs-foundation
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/ninja
+ git fetch --recurse-submodules=yes --tags

+ git tag -l release
+ git branch --list release
/Volumes/ExtremeSSD/swift-source/ninja
+ git reset --hard origin/release
HEAD is now at b25c08b v1.9.0

Updating '/Volumes/ExtremeSSD/swift-source/clang-tools-extra'
/Volumes/ExtremeSSD/swift-source/swift-corelibs-xctest
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-corelibs-xctest
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/clang-tools-extra
+ git checkout stable
Your branch is up to date with 'origin/stable'.
Already on 'stable'

/Volumes/ExtremeSSD/swift-source/swift-corelibs-xctest
+ git reset --hard origin/master
HEAD is now at 10140f4 Merge pull request #250 from compnerd/synchrony

Updating '/Volumes/ExtremeSSD/swift-source/swiftpm'
/Volumes/ExtremeSSD/swift-source/swiftpm
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/llvm
+ git checkout stable
Your branch is up to date with 'origin/stable'.
Already on 'stable'

/Volumes/ExtremeSSD/swift-source/libcxx
+ git reset --hard origin/stable
HEAD is now at f32ea9d89 Merge pull request #1 from apple/stable-next

Updating '/Volumes/ExtremeSSD/swift-source/swift'
/Volumes/ExtremeSSD/swift-source/clang-tools-extra
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-clang-tools-extra
   8502584b..9b3867bf  upstream-with-swift -> origin/upstream-with-swift

+ git tag -l stable
+ git branch --list stable
/Volumes/ExtremeSSD/swift-source/clang-tools-extra
+ git reset --hard origin/stable
HEAD is now at 20fb30b5 Merge pull request #2 from apple/stable-next

Updating '/Volumes/ExtremeSSD/swift-source/swift-corelibs-libdispatch'
/Volumes/ExtremeSSD/swift-source/swift-integration-tests
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-integration-tests
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/swift-corelibs-libdispatch
+ git checkout master
Your branch is up to date with 'origin/master'.
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swift-integration-tests
+ git reset --hard origin/master
HEAD is now at ed01cfb Merge pull request #53 from apple/update-swift-package-tests-again

/Volumes/ExtremeSSD/swift-source/swift-corelibs-foundation
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-corelibs-foundation
   aef7b676..b3e3f3d6  master           -> origin/master
   f41bd302..684bb665  swift-4.2-branch -> origin/swift-4.2-branch
 * [new tag]           swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/swift-corelibs-foundation
+ git reset --hard origin/master
HEAD is now at b3e3f3d6 Merge pull request #1968 from compnerd/FSR

/Volumes/ExtremeSSD/swift-source/swift-corelibs-libdispatch
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-corelibs-libdispatch
 * [new tag]         swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/swift-corelibs-libdispatch
+ git reset --hard origin/master
HEAD is now at bc00e13 Merge pull request #446 from compnerd/sometimes-code-is-ugly

/Volumes/ExtremeSSD/swift-source/swift
+ git checkout master
Your branch is ahead of 'origin/master' by 1172 commits.
  (use "git push" to publish your local commits)
Already on 'master'

/Volumes/ExtremeSSD/swift-source/swiftpm
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-package-manager
 * [new tag]           swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/swiftpm
+ git reset --hard origin/master
HEAD is now at e4f1dc41 [PackageLoading] Create cache dir on init

/Volumes/ExtremeSSD/swift-source/clang
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-clang
   ef9c7aec5e..452ea818bb  stable              -> origin/stable
   48e9374d47..67f5cd0c40  swift-5.1-branch    -> origin/swift-5.1-branch
   41102c502a..9eabe3ead2  upstream-with-swift -> origin/upstream-with-swift
 * [new tag]               swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l stable
+ git branch --list stable
/Volumes/ExtremeSSD/swift-source/lldb
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-lldb
   1c11f2f7c2..5e988b2636  stable              -> origin/stable
   bb2867c22e..4108ff1016  swift-5.1-branch    -> origin/swift-5.1-branch
   6b947d3515..69b0ea462f  upstream            -> origin/upstream
   733ba319dd..05bc596ddb  upstream-with-swift -> origin/upstream-with-swift
 * [new tag]               swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l stable
+ git branch --list stable
/Volumes/ExtremeSSD/swift-source/swift
+ git fetch --recurse-submodules=yes --tags

+ git tag -l master
+ git branch --list master
/Volumes/ExtremeSSD/swift-source/lldb
+ git reset --hard origin/stable
HEAD is now at 5e988b2636 Merge remote-tracking branch 'origin/swift-5.1-branch' into stable

/Volumes/ExtremeSSD/swift-source/clang
+ git reset --hard origin/stable
HEAD is now at 452ea818bb Merge remote-tracking branch 'origin/swift-5.1-branch' into stable

/Volumes/ExtremeSSD/swift-source/swift
+ git reset --hard origin/master
HEAD is now at 26bf98f2ec Merge pull request #22457 from nkcsgexi/hash-imple-syntax-nodes
Checking out files: 100% (1163/1163), done.

/Volumes/ExtremeSSD/swift-source/llvm
+ git fetch --recurse-submodules=yes --tags
From https://github.com/apple/swift-llvm
   42009dbeeb1..33abafd3f84  upstream-with-swift -> origin/upstream-with-swift
 * [new tag]                 swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a -> swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

+ git tag -l stable
+ git branch --list stable
/Volumes/ExtremeSSD/swift-source/llvm
+ git reset --hard origin/stable
HEAD is now at 94d957ca75c Merge remote-tracking branch 'origin/swift-5.1-branch' into stable

update-checkout succeeded

Do I have to do this resetting-variant procedure when I want to update again? Or can I do the regular update procedure?

I did an experiment, and it failed. So I can't use "git fetch upstream master" then "git pull upstream master" to update my copy of the repo (where "upstream" is Apple's Swift repo)? I can only use the "update-checkout" script?

  • git pull upstream master will fetch and merge into your current branch.

  • git pull --rebase upstream master will fetch and rebase into your current branch.

  • ./utils/update-checkout --skip-repository swift will update the other repositories.

If you look at what the update-checkout script (swift/update_checkout.py at main · apple/swift · GitHub) actually does, it clones / pulls dependencies from additional git repositories, which may in turn contain submodules.

There is a config file here: swift/update-checkout-config.json at main · apple/swift · GitHub that specifies, for a given swift repository branch, what repositories and branches to clone.

This works fine, even though it is a bit opaque. It would be interesting to hear the reason that git submodules are not used natively (so that after pulling from upstream master, updating the dependencies would basically consist in: git submodule update --init --recursive)

  • git pull upstream master (since origin is a public fork)
  • ./utils/update-checkout --skip-repository swift

Seemed to have worked. Do I have to "--skip-repository swift" from now on? Or can I go back to a plain update-checkout?

If you run git checkout master first, then the plain ./utils/update-checkout should always succeed (as a fast-forward merge). This assumes that you commit your own changes to new branches (i.e. other than master).

If you want to update your own branch, then git pull --rebase upstream master and ./utils/update-checkout --skip-repository swift might be better. Someone with more experience than me could give you better advice.

GitWorkflows.rst recommends git config branch.autoSetupRebase always, so that new branches use the --rebase option by default.

@CTMacUser this is a known issue with update-checkout today. Changing update-checkout such that it automagically supports this (with a preferred remote for ones self) makes sense. Additionally it would ensure that origin is updated such that ones remote has /dev/null as the --push to prevent accidental pushes to origin.