repo sync命令的替代方法是什么? [英] What will be the alternative for repo sync command?
问题描述
我是git的新手,我想在执行repo init
之后手动执行清单文件,而不是执行repo sync
.在不同情况下测量普通git命令和repo sync
之间的时间差.但是我不确定要使用哪个git命令来回购.
I am new to git and I want to execute manifest file manually after doing repo init
, instead of doing repo sync
. To measure the time difference between normal git commands and repo sync
in different cases. But I am not sure which git command to does repo uses.
我知道repo
只是大型代码库的git包装.
I know that repo
is just an wrapper for git for large codebase.
如果我具有以下变量,我只想知道git clone
的确切命令是什么.
I just want to know what will be the exact command for git clone
If I have the following Variables.
-名称 - 小路 - 修订 - 上游 -远程
- name - path - revision - upstream - remote
我知道如何为git clone形成一个url,但是不确定版本和上游.
I know how to form a url for git clone but not sure about revision and upstream.
推荐答案
以下是示例清单default.xml
:
<manifest>
<remote name="aosp"
fetch="https://android.googlesource.com/"/>
<remote name="test"
fetch="https://github.com/test/"/>
<default revision="master"
remote="test"
sync-j="4" />
<project name="platform/tools/motodev" path="tools/motodev" revision="69989786cefbde82527960a1e100ec9afba46a98" upstream="master" remote="aosp"/>
</manifest>
创建用于测试的父目录
mkdir repotest
cd repotest
为清单创建git存储库
Create a git repository for the manifest
mkdir local_manifest
cd local_manifest
git init
# Create the default.xml file
git add default.xml
git commit -m "Local Manifest"
cd ..
下载 repo
工具
mkdir -p .bin
PATH="${HOME}/repotest/.bin:${PATH}"
curl https://storage.googleapis.com/git-repo-downloads/repo > .bin/repo
chmod a+rx .bin/repo
基于本地清单的初始化
mkdir test
cd test
repo init -u ~/repotest/local_manifest/
修改repo
的源代码以获取更多调试输出(除了--trace
和GIT_TRACE=1
之外)
Modify source code of repo
to get more debugging output (in addition to --trace
and GIT_TRACE=1
)
nano .repo/repo/git_command.py
# Remove stderr argument from the subprocess.Popen call (line no: ~292)
# Also comment the line at line no: ~331 which includes the use of the above removed argument stderr
# Save the file and exit
同步
export GIT_TRACE=1
repo --trace sync &> ../log
cd ..
过滤日志
grep "built-in:\|curl\|export" < log > temp
awk -F '[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]+ git.c:' '{print $1}' > trim1 < temp
awk -F 'trace: built-in:' '{print $2}' > trim2 < temp
paste -d' ' trim1 trim2 > filtered_log
过滤日志显示正在执行的git命令的顺序
Filtered Log shows the sequence of git commands being executed
git version
git describe HEAD
git config --file /home/test/repotest/test/.repo/manifests.git/config --null --list
git config --file /home/test/repotest/test/.repo/repo/.git/config --null --list
: export GIT_DIR=/home/test/repotest/test/.repo/manifests.git
git fetch origin --tags '+refs/tags/*:refs/tags/*' '+refs/heads/*:refs/remotes/origin/*' +refs/heads/master:refs/remotes/origin/master
git upload-pack /home/test/repotest/local_manifest/
git rev-list --objects --stdin --not --all --quiet --alternate-refs
git gc --auto
git symbolic-ref -m 'manifest set to refs/heads/master' refs/remotes/m/master refs/remotes/origin/master
: export GIT_DIR=/home/test/repotest/test/.repo/project-objects/platform/tools/motodev.git
git init
git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --null --list
git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all filter.lfs.smudge 'git-lfs smudge --skip -- %f'
git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all filter.lfs.process 'git-lfs filter-process --skip'
git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --unset-all core.bare
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
git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.projectname platform/tools/motodev
git config --file /home/test/repotest/test/.repo/projects/tools/motodev.git/config --replace-all remote.aosp.fetch '+refs/heads/*:refs/remotes/aosp/*'
curl --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
: export GIT_DIR=/home/test/repotest/test/.repo/projects/tools/motodev.git
git fetch /home/test/repotest/test/.repo/projects/tools/motodev.git/clone.bundle '+refs/heads/*:refs/remotes/aosp/*' '+refs/tags/*:refs/tags/*'
git index-pack --fix-thin --stdin
git rev-list --objects --stdin --not --all --quiet --alternate-refs
git gc --auto
git fetch aosp --tags '+refs/tags/*:refs/tags/*' '+refs/heads/*:refs/remotes/aosp/*' +refs/heads/master:refs/remotes/aosp/master
git fetch-pack --stateless-rpc --stdin --lock-pack --thin --no-progress https://android.googlesource.com/platform/tools/motodev/
git unpack-objects -q --pack_header=2,2
git rev-list --objects --stdin --not --all --quiet --alternate-refs
git gc --auto
git update-ref -m 'manifest set to 69989786cefbde82527960a1e100ec9afba46a98' --no-deref refs/remotes/m/master 69989786cefbde82527960a1e100ec9afba46a98^0
git gc --auto
git read-tree --reset -u -v HEAD
现在有很多命令. (观察:repo
使用curl下载存储库.)
Now that's a lot of commands. (Observation: repo
uses curl to download the repositories).
根据用户 ElpieKay 的建议,对于上述清单文件,git命令的近似值为:
As suggested by User ElpieKay, for the above manifest file, an approximation of git commands would be:
git clone https://android.googlesource.com/platform/tools/motodev -b master -- tools/motodev
cd tools/motodev
git checkout 69989786cefbde82527960a1e100ec9afba46a98
要比较repo
工具和git的性能,可以执行以下操作:
To compare the performance of the repo
tool and git, you can do :
# For repo tool
repo --time sync
# For git commands
export GIT_TRACE_PERFORMANCE=1
git clone $remote -b $upstream -- $path
cd $path
git checkout $revision
或使用 time 命令获得全部执行git命令的时间
or using time command to get the total execution time of the git commands
time -p sh -c 'git clone $remote -b $upstream -- $path ; cd $path ; git checkout $revision'
注意:远程具有fetch属性,其值是服务器的url前缀.前缀和名称构成了远程存储库的实际URL-用户 ElpieKay
Note: remote has an attribute fetch whose value is the url prefix of the server. The prefix and name form the actual url to the remote repository - User ElpieKay
有关调试变量的更多信息, git:
More on the Debugging Variables used in git:
GIT_TRACE_PERFORMANCE
控制性能数据的记录.输出 显示每个特定的git调用需要多长时间.
controls logging of performance data. The output shows how long each particular git invocation takes.
GIT_TRACE
控制常规迹线,这些迹线不属于任何特定类别. 这包括扩展别名,以及将其委托给其他人. 子程序.
controls general traces, which don’t fit into any specific category. This includes the expansion of aliases, and delegation to other sub-programs.
这篇关于repo sync命令的替代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!