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.

I know that repo is just an wrapper for git for large codebase.

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

I know how to form a url for git clone but not sure about revision and upstream.

解决方案

Here's a sample manifest default.xml:

fetch="https://android.googlesource.com/"/>

fetch="https://github.com/test/"/>

remote="test"

sync-j="4" />

Create a parent directory for testing

mkdir repotest

cd repotest

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 ..

Download the repo tool

mkdir -p .bin

PATH="${HOME}/repotest/.bin:${PATH}"

curl https://storage.googleapis.com/git-repo-downloads/repo > .bin/repo

chmod a+rx .bin/repo

Init based on the local manifest

mkdir test

cd test

repo init -u ~/repotest/local_manifest/

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

Sync

export GIT_TRACE=1

repo --trace sync &> ../log

cd ..

Filter the log

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

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

Now that's a lot of commands. (Observation: repo uses curl to download the repositories).

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

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

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'

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

More on the Debugging Variables used in git:

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.

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐