repo sync 命令的替代方案是什么?
What will be the alternative for repo sync command?
我是 git 的新手,我想在执行 repo init
之后手动执行清单文件,而不是执行 repo sync
。测量不同情况下正常git命令和repo sync
命令之间的时间差异。但我不确定 repo 使用哪个 git 命令。
我知道 repo
只是 git 大型代码库的包装器。
我只想知道如果我有以下变量,git clone
的确切命令是什么。
- 姓名
- 小路
- 修订
- 上游
- 远程
我知道如何为 git 克隆形成 url,但不确定修订版和上游。
这是一个示例清单 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 存储库
mkdir local_manifest
cd local_manifest
git init
# Create the default.xml file
git add default.xml
git commit -m "Local Manifest"
cd ..
Download 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
)
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 }' > trim1 < temp
awk -F 'trace: built-in:' '{print }' > trim2 < temp
paste -d' ' trim1 trim2 > filtered_log
过滤后的日志显示正在执行的 git 个命令的顺序
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 下载存储库)。
根据用户 ElpieKay 的建议,对于上述清单文件,git 命令的近似值是:
git clone https://android.googlesource.com/platform/tools/motodev -b master -- tools/motodev
cd tools/motodev
git checkout 69989786cefbde82527960a1e100ec9afba46a98
要比较 repo
工具和 git 的性能,您可以这样做:
# 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命令的总执行时间
time -p sh -c 'git clone $remote -b $upstream -- $path ; cd $path ; git checkout $revision'
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 中使用的 Debugging Variables 的更多信息:
GIT_TRACE_PERFORMANCE
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.
我是 git 的新手,我想在执行 repo init
之后手动执行清单文件,而不是执行 repo sync
。测量不同情况下正常git命令和repo sync
命令之间的时间差异。但我不确定 repo 使用哪个 git 命令。
我知道 repo
只是 git 大型代码库的包装器。
我只想知道如果我有以下变量,git clone
的确切命令是什么。
- 姓名 - 小路 - 修订 - 上游 - 远程
我知道如何为 git 克隆形成 url,但不确定修订版和上游。
这是一个示例清单 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 存储库
mkdir local_manifest
cd local_manifest
git init
# Create the default.xml file
git add default.xml
git commit -m "Local Manifest"
cd ..
Download 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
)
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 }' > trim1 < temp
awk -F 'trace: built-in:' '{print }' > trim2 < temp
paste -d' ' trim1 trim2 > filtered_log
过滤后的日志显示正在执行的 git 个命令的顺序
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 下载存储库)。
根据用户 ElpieKay 的建议,对于上述清单文件,git 命令的近似值是:
git clone https://android.googlesource.com/platform/tools/motodev -b master -- tools/motodev
cd tools/motodev
git checkout 69989786cefbde82527960a1e100ec9afba46a98
要比较 repo
工具和 git 的性能,您可以这样做:
# 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命令的总执行时间
time -p sh -c 'git clone $remote -b $upstream -- $path ; cd $path ; git checkout $revision'
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 中使用的 Debugging Variables 的更多信息:
GIT_TRACE_PERFORMANCE
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.