Someday ImageMagick will finally break for good and we'll have a long period of scrambling as we try to reassemble civilization from the rubble. explainxkcd
Just read the (very short) Wikipedia article.
Fork it here!
You may use vendor branching to do that :-J
You copied artefacts from a fancy place to your favourite VCS, tweaked it and now you discover that meanwhile the fancy place updated their code. What now? Artefacts can be source code, data files, PDF files, supporting documentation...
This document is the zillionth attempt at explaining the vendor branching mechanism. Despite the Internet abound with how-to's, developers keep falling in the trap.
There is more: this is related to the concept of the software supply chain.
In short: copy-pasting artefacts is a seemingly easy way to get things imported in a project. The problem is the maintainance effort that will follow. Do not assume the data is "written in stone" and will never change any more (be it inside your project or externally). Instead, every time you import anything from outside your project, be it code or data, do not bluntly copy-paste; don't just create a "fork" of foreign artefacts unless there really is no other way.
Unless you want to produce a hostile fork...
Sometimes this problem is then solved by manual labor: porting the external changes in Stellarium, a laborous approach prone to bugs. Extremely instructive use cases are presented on Wikipedia.
Usually references of some form are added to the source code, e.g. ftp, snail mail, http, ... The problem is that these references might disappear at some point in the future. This happens all the time with personal pages. An example can be found in this comment: you will get a 404: the pages are gone. Those pages should somehow have been imported as vendor data.
The approach looks daunting, but that is only appearance.
The external (source) version of such artifacts will often continue to evolve, but these modifications obviously will not be magically reflected in the project repository, thus sometimes, if not often leading to artifacts slowly getting totally outdated (hence the term "code rot").
- tudat-team/tudat-resources#11
- the "npm left-pad incident" demonstrates what can go wrong when one doesn't vendor:
- https://en.wikipedia.org/wiki/Npm_left-pad_incident
- https://www.theregister.com/2016/03/23/npm_left_pad_chaos/
- https://qz.com/646467/how-one-programmer-broke-the-internet-by-deleting-a-tiny-piece-of-code
- https://arstechnica.com/information-technology/2016/03/rage-quit-coder-unpublished-17-lines-of-javascript-and-broke-the-internet/
- or what happens when one trusts external vendors:
First, there are cases that I'm personally interested in, and are discussed separately:
Don't take it personally: the issue is widespread and totally forgiveable, as the pattern is seldom taken into consideration when a solution is needed for this typical problem.
- copy-paste issues in Stellarium started the whole "vendor branching" project after an interesting discussion
- the SGP4 copy-pasting is a specific example inside Stellarium. I never thought it would become such an expanding oil spill
- a subdirectory of the C47 project drew my attention: it imports and then patches the vendor rejig
More examples can be found here.
A solution: package managers
Sometimes this can be solved by using package managers that automate the importing and updating of external "stuff" (typically code) and - important - allow to fine tune which version is to be imported. But package managers do not allow to modify the imported code out of the box and benefit from external updates. Also, package managers are not always the easiest way to deal with vendors, sometimes due to a lack of experience of contributing C++ developers. Vendor branching is far easier to work with than configuring package managers, as all the required knowledge resides in how to deal with branching.
Python's pip -e is a great example of this. Modifying the vendor code is less great.
Artefacts that can be managed by package managers are not discussed here. An inconvenience of package managers might be that local modifications might be more difficult to manage. This is precisely what vendor branching has been designed for.
And sometimes there will be no package manager provided with the artefact. Often, the artefacts will live in zip or PDF files or HTML pages...
Package managers do not allow to modify the imported code out of the box and benefit from external updates. Also, package managers are not always the easiest way to deal with vendors, sometimes due to a lack of experience of contributing developers that often are volunteers - that come and go.
The idea is not to import the vendor artefacts, but create (and store in the repo) patches that patch the vendor at compile/make/... whatever time.
An advanced solution might be Not-forking.
Prior note: it is obvious that the problem is widespread, and it is unlikely that the affected projects will change the chosen path (don't fix what isn't broken?)... So this whole discussion is mainly oriented to those who are still fresh in the discipline... And especially towards devs that are about to commit a "copy-paste offence".
Vendor branching is far easier to work with than working with package managers, as all the required knowledge resides in how to work with branching (and merging).
The concept already exists:
- in the venerable CVS, branch 1.1.1 is the branch that holds vendor code. The "Cederqvist" PDF is delicious lecture.
- And SVN (under "Vendor Branches - Chapter 4. Branching and Merging") is almost a reference.
- FreeBSD also explains the Vendor Branch concept (BTW - it uses
git subtree).
Importing external artifacts requires a specific (and in this case a simple - believe me, it is not rocket science - as well as generic) and approach: the Vendor Branch approach. The proposed approach is KISS: simple to apply to novice programmers. By the way, the approach is valid in any VCS, such as SVN, Git, Mercurial, ClearCase, Fossil, TFS, CVS (where it already exists), you name it.
Importing external artefacts in vendor branches will also provide insight in what changed in those artefacts, just by inspecting the "diff" between successive vendor versions. Normally such changes should also be announced by the vendor.
This is in fact an important version control pattern.
- Track external changes in vendor branches by successive imports and vendor tags
- Do not modify anything in vendor branches
- Updates in successive vendor artefact versions can be detected via diffs
- ... and merged to local branches (and finally end up in your project's
mainbranch) - ... where changes can be applied.
- A local file (or script) tracks metadata about the vendor artefacts so that the vendor artefacts can always be found (until they vanish).
- Feel for contributing to the vendor code? Branch off the vendor branch, send the patch and merge locally. (Remember that the next vendor drop might generate conflicts)
- All this needs basic VCS mastery.
See the page systems for the more detailed steps using various VCS.
Interestingly, one could also use the same concept when "subcontracting" your code as vendor code to an outside contractor company.
- You create a vendor branch from (a subset of) your own code and send that to the external party. That branch might sometimes need some tweaks so that you prevent things from reaching the external party. That branch serves as a reference.
- When changes come back you merge those changes in that vendor branch (without changing them); maybe revert some things your removed earlier in the branch;
- and finally merge to your own
main.
- Advantages
- easier for the average developer
- no manual patching, no need for separate patch scripts
- no dependency on the vendor (or even a network connection)
- Inconveniences
- the vendor creation might much more space than needed if the vendor drop is huge
- the repo will grow a bit larger
- for example, one simple test shows that (using Git and Fossil as a case)
- a bare Fossil repo (=SQLite format) file (e.g. rejig) is about ~6Mb (2026-11)
fossil openinflates to 17M- a
.git/vendor drop of that repo takes 5.1M (8.3M but then cleaned bygit gc) - git can further reduce disk space with a sparse checkout
- for example, one simple test shows that (using Git and Fossil as a case)
- What barely changes
- a vendor drop ingests diffs on a branch first prior to the merge
- clone the vendor into a separate repository
- inconvenience is that each developer has to do a clone
- git submodules do this
- the monorepo approach
- The NOTES page
- https://stackoverflow.com/questions/tagged/vendor-branch?sort=votes
- https://stackoverflow.com/questions/769786/vendor-branches-in-git
- https://en.wikipedia.org/wiki/Branching_%28version_control%29#Motivations_for_branching
- https://blog.bigsmoke.us/2009/07/20/svn-vendor-branches
- https://portal.perforce.com/s/article/3374
- https://stackoverflow.com/questions/1710027/arguments-for-and-against-including-3rd-party-libraries-in-version-control/1710050
- new topic: https://github.com/topics/vendor-branching
- other topics that might or might not be related to Vendor Branching and might benefit from switching to the
vendor-branchingtopic: - https://github.com/stars/axd1967/lists/vendor-branching
- https://en.wikipedia.org/wiki/Software_rot
- https://en.wikipedia.org/wiki/Copypasta#Technology
- "copy-paste is evil"
- https://www.cisa.gov/resources-tools/resources/product-security-bad-practices: "Cache copies of all open-source dependencies within the manufacturer’s own build systems and do not update products or customer systems directly from unverified public sources." (Dead link, see instead cisagov/bad-practices#101)
- https://en.wikipedia.org/wiki/Software_supply_chain
- https://en.wikipedia.org/wiki/Supply_chain_attack
- https://en.wikipedia.org/wiki/Dependency_hell
- https://shearer.org/articles/not-forking/
- https://lumosql.org/src/not-forking/
- https://reproducible-builds.org/docs/volatile-inputs/
- https://reproducible-builds.org/
- https://medium.com/@larsxschneider/talk-dont-fork-743a1253b8d
You say no human would reply to a forum thread about Tom Bombadil by writing and editing hundreds of words of text, complete with formatting, fancy punctuation, and two separate uses of the word 'delve'. Unfortunately for both of us, you are wrong. explainxkcd

