tus*_*cmc 4 git android-manifest repo
我是 git 新手,我想在执行后手动执行清单文件repo init,而不是执行repo sync。测量正常git命令和repo sync不同情况下的时间差。但我不确定 repo 使用哪个 git 命令。
我知道这repo只是大型代码库的 git 包装器。
我只想知道git clone如果我有以下变量,确切的命令是什么。
- 名称 - 路径 - 修订版 - 上游 - 远程
我知道如何形成 git clone 的 url,但不确定修订版和上游。
这是一个示例清单default.xml:
<manifest>\n <remote name="aosp"\n fetch="https://android.googlesource.com/"/>\n <remote name="test"\n fetch="https://github.com/test/"/>\n <default revision="master"\n remote="test"\n sync-j="4" />\n <project name="platform/tools/motodev" path="tools/motodev" revision="69989786cefbde82527960a1e100ec9afba46a98" upstream="master" remote="aosp"/>\n</manifest>\nRun Code Online (Sandbox Code Playgroud)\n创建父目录用于测试
\nmkdir repotest\ncd repotest\nRun Code Online (Sandbox Code Playgroud)\n为清单创建 git 存储库
\nmkdir local_manifest\ncd local_manifest\ngit init\n# Create the default.xml file\ngit add default.xml\ngit commit -m "Local Manifest"\ncd ..\nRun Code Online (Sandbox Code Playgroud)\n下载工具repo
mkdir -p .bin\nPATH="${HOME}/repotest/.bin:${PATH}"\ncurl https://storage.googleapis.com/git-repo-downloads/repo > .bin/repo\nchmod a+rx .bin/repo\nRun Code Online (Sandbox Code Playgroud)\n根据本地清单进行初始化
\nmkdir test\ncd test\nrepo init -u ~/repotest/local_manifest/\nRun Code Online (Sandbox Code Playgroud)\n修改 的源代码repo以获得更多调试输出(除了--trace和GIT_TRACE=1)
nano .repo/repo/git_command.py\n# Remove stderr argument from the subprocess.Popen call (line no: ~292)\n# Also comment the line at line no: ~331 which includes the use of the above removed argument stderr\n# Save the file and exit\nRun Code Online (Sandbox Code Playgroud)\n同步
\nexport GIT_TRACE=1\nrepo --trace sync &> ../log\ncd ..\nRun Code Online (Sandbox Code Playgroud)\n过滤日志
\ngrep "built-in:\\|curl\\|export" < log > temp\nawk -F \'[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]+ git.c:\' \'{print $1}\' > trim1 < temp\nawk -F \'trace: built-in:\' \'{print $2}\' > trim2 < temp\npaste -d\' \' trim1 trim2 > filtered_log\nRun Code Online (Sandbox Code Playgroud)\n过滤日志显示正在执行的 git 命令的顺序
\n git version\n git describe HEAD\n git config --file /home/test/repotest/test/.repo/manifests.git/config --null --list\n git config --file /home/test/repotest/test/.repo/repo/.git/config --null --list\n: export GIT_DIR=/home/test/repotest/test/.repo/manifests.git \n git fetch origin --tags \'+refs/tags/*:refs/tags/*\' \'+refs/heads/*:refs/remotes/origin/*\' +refs/heads/master:refs/remotes/origin/master\n git upload-pack /home/test/repotest/local_manifest/\n git rev-list --objects --stdin --not --all --quiet --alternate-refs\n git gc --auto\n git symbolic-ref -m \'manifest set to refs/heads/master\' refs/remotes/m/master refs/remotes/origin/master\n: export GIT_DIR=/home/test/repotest/test/.repo/project-objects/platform/tools/motodev.git \n git init\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --null --list\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all filter.lfs.smudge \'git-lfs smudge --skip -- %f\'\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all filter.lfs.process \'git-lfs filter-process --skip\'\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --unset-all core.bare\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.url https://android.googlesource.com/platform/tools/motodev\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.projectname platform/tools/motodev\n git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.fetch \'+refs/heads/*:refs/remotes/aosp/*\'\ncurl --fail --output /home/test/repotest/test/.repo/projects/tools/motodev.git/clone.bundle.tmp --netrc --location https://android.googlesource.com/platform/tools/motodev/clone.bundle \n: export GIT_DIR=/home/test/repotest/test/.repo/projects/tools/motodev.git \n git fetch /home/test/repotest/test/.repo/projects/tools/motodev.git/clone.bundle \'+refs/heads/*:refs/remotes/aosp/*\' \'+refs/tags/*:refs/tags/*\'\n git index-pack --fix-thin --stdin\n git rev-list --objects --stdin --not --all --quiet --alternate-refs\n git gc --auto\n git fetch aosp --tags \'+refs/tags/*:refs/tags/*\' \'+refs/heads/*:refs/remotes/aosp/*\' +refs/heads/master:refs/remotes/aosp/master\n git fetch-pack --stateless-rpc --stdin --lock-pack --thin --no-progress https://android.googlesource.com/platform/tools/motodev/\n git unpack-objects -q --pack_header=2,2\n git rev-list --objects --stdin --not --all --quiet --alternate-refs\n git gc --auto\n git update-ref -m \'manifest set to 69989786cefbde82527960a1e100ec9afba46a98\' --no-deref refs/remotes/m/master 69989786cefbde82527960a1e100ec9afba46a98^0\n git gc --auto\n git read-tree --reset -u -v HEAD\nRun Code Online (Sandbox Code Playgroud)\n现在有很多命令。(观察:repo使用curl 下载存储库)。
正如用户ElpieKay所建议的,对于上述清单文件,git 命令的近似值为:
\ngit clone https://android.googlesource.com/platform/tools/motodev -b master -- tools/motodev \ncd tools/motodev\ngit checkout 69989786cefbde82527960a1e100ec9afba46a98\nRun Code Online (Sandbox Code Playgroud)\n要比较该工具和 git 的性能repo,您可以执行以下操作:
# For repo tool\nrepo --time sync\nRun Code Online (Sandbox Code Playgroud)\n# For git commands\nexport GIT_TRACE_PERFORMANCE=1\ngit clone $remote -b $upstream -- $path \ncd $path \ngit checkout $revision\nRun Code Online (Sandbox Code Playgroud)\n或使用time命令获取 git 命令的总执行时间
\ntime -p sh -c \'git clone $remote -b $upstream -- $path ; cd $path ; git checkout $revision\'\nRun Code Online (Sandbox Code Playgroud)\n\n\n注意: remote有一个属性fetch,其值为服务器的url前缀。前缀和名称构成远程存储库的实际 url - 用户ElpieKay
\n
有关 git 中使用的调试变量的更多信息:
\n\n\nGIT_TRACE_PERFORMANCE
\n控制性能数据的记录。输出\n显示每个特定 git 调用需要多长时间。
\ngit_trace
\n控制一般跟踪,\xe2\x80\x99 不适合任何特定类别。\n这包括别名的扩展以及对其他\n子程序的委托。
\n
| 归档时间: |
|
| 查看次数: |
2505 次 |
| 最近记录: |