Open tdjastrzebski opened 3 years ago
We do a shallow clone of mbed-os by default, since version 7.3.0. I ran the command to make a new example with verbose logging enabled, so you can see what options it runs with.
$ mbed-tools -vvv new .
Creating a new Mbed program at path '/private/tmp/bob'.
Downloading mbed-os and adding it to the project.
DEBUG: Searching for mbed-os.lib file at path /private/tmp/bob
DEBUG: Searching for mbed-os.lib file at path /private/tmp
DEBUG: Searching for mbed-os.lib file at path /private
DEBUG: No mbed-os.lib file found.
INFO: Creating Mbed program at path '/private/tmp/bob'
INFO: Creating git repository for the Mbed program '/private/tmp/bob'
INFO: Resolving library reference https://github.com/ARMmbed/mbed-os.
INFO: Checking out revision master for library https://github.com/ARMmbed/mbed-os.
DEBUG: Popen(['git', 'version'], cwd=/private/tmp/bob, universal_newlines=False, shell=None, istream=None)
DEBUG: Popen(['git', 'clone', '-v', '--depth=1', '--branch=master', '--progress', 'https://github.com/ARMmbed/mbed-os', '/private/tmp/bob/mbed-os'], cwd=/private/tmp/bob, universal_newlines=True, shell=None, istream=None)
$
It looks like we do: git clone -v --depth=1 --branch=master --progress https://github.com/ARMmbed/mbed-os
I then ran a git log
to see what history was available. Only a single commit was shown, and "grafted" was also displayed.
$ git -C mbed-os log
commit c14396a5b619b185d344ad6dfc25f04cb330f1fc (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: Martin Kojtal <martin.kojtal@arm.com>
Date: Fri Sep 3 15:03:31 2021 +0100
Merge pull request #15045 from LDong-Arm/malloc_newlib_nano
Workaround for a bug in malloc() from newlib-nano 4.1.0 (in GCC 10.3)
I see your suggested command uses latest
instead of master
, which would be for the latest released version. You can do the clone yourself however you'd like using git commands, though. To prevent mbed-tools new
from cloning Mbed OS on its own, pass in the --create-only
option, like mbed-tools new --create-only .
.
$ mbed-tools new --create-only .
Creating a new Mbed program at path '/private/tmp/bob'
$ git clone https://github.com/ARMmbed/mbed-os --branch latest --single-branch --depth 1
Cloning into 'mbed-os'...
remote: Enumerating objects: 19956, done.
remote: Counting objects: 100% (19956/19956), done.
remote: Compressing objects: 100% (14335/14335), done.
Receiving objects: 100% (19956/19956), 62.42 MiB | 8.78 MiB/s, done.
remote: Total 19956 (delta 8992), reused 10380 (delta 4812), pack-reused 0
Resolving deltas: 100% (8992/8992), done.
Updating files: 100% (18430/18430), done.
$ git -C mbed-os log
commit 3377f083b3a6bd7a1b45ed2cea5cf083b9007527 (grafted, HEAD -> latest, tag: mbed-os-6.14.0-rc1, tag: mbed-os-6.14.0, origin/latest)
Author: mbedmain <mbedmain@mbedos-ci-vm.server.eu02.arm.com>
Date: Wed Aug 18 12:44:48 2021 +0100
Update Mbed version block
$ du -sh mbed-os
809M mbed-os
Only the one commit of mbed-os was fetched, from the branch you've requested. This looks to save about 413 MB on disk (809M for single commit, instead of 1.2G for the entire history).
mbed-tools do a shallow copy now, but this has also caveats:
#master
in mbed-os.lib does not update after a mbed-tools deploy
maybe mbed deploy can give a hint for this or can check the deploy command it a shallow copy is used? To unshallow, this can be used (and maybe printed as hint in deploy):
git fetch --unshallow
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
By default,
mbed-tools new .
fetches the entire Git history - that's extra 420MB ! Please allow to limit the fetch to the latest version onlygit clone https://github.com/ARMmbed/mbed-os --branch latest --single-branch --depth 1