Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch followed by pull is inefficient #28

Open
vaab opened this issue Apr 10, 2019 · 2 comments
Open

fetch followed by pull is inefficient #28

vaab opened this issue Apr 10, 2019 · 2 comments

Comments

@vaab
Copy link

vaab commented Apr 10, 2019

I noticed while tinkering with gitaggregate 1.6.0 (git version 2.7.4) that it was issuing a fetch followed by pull. As we all know, pull is a shorthand for a fetch followed by a merge. We could think that the second fetch is not so harmful as it won't download anything... but that wrong:

  • the second pull is not garanteed to give the same resut that the first fetch (the target might have changed in between), and this might have some consequence in the code.
  • even in --depth 1 and when the code didn't change, there are still some computation and network exchanges that could be avoided.

Full example:

mkdir /tmp/gita -p &&
cd /tmp/gita &&
cat <<EOF > repos.yaml
./foo:
    defaults:
        depth: 1
    remotes:
        r1: file:///tmp/gita/r1
    target: r1 agg
    merges:
    - r1 t1
EOF

## making remote git repository 'r1'
mkdir -p r1 && cd r1
git init . &&
touch a &&
git add a &&
git commit -am "first commit" &&
git tag t1 &&
cd ..

gitaggregate -c repos.yaml --log-level DEBUG

would output

(D) [17:18:29] git_aggregator.main  foo  main.aggregate_repo():198 <git_aggregator.repo.Repo object at 0x7f2e0fe29d68>
(I) [17:18:29] git_aggregator.repo  foo  repo.aggregate():169 Start aggregation of /tmp/gita/foo
(I) [17:18:29] git_aggregator.repo  foo  repo.init_repository():192 Init empty git repository in /tmp/gita/foo
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'init', '/tmp/gita/foo']
Initialized empty Git repository in /tmp/gita/foo/.git/
(I) [17:18:29] git_aggregator.repo  foo  repo._switch_to_branch():247 Switch to branch agg
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'checkout', '-B', 'agg']
Switched to a new branch 'agg'
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'remote', '-v']
(I) [17:18:29] git_aggregator.repo  foo  repo._set_remote():298 Adding remote r1 <file:///tmp/gita/r1>
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ['git', 'remote', 'add', 'r1', 'file:///tmp/gita/r1']
(I) [17:18:29] git_aggregator.repo  foo  repo.fetch():197 Fetching required remotes
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ('git', 'fetch', '--depth', '1', 'r1', 't1')
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From file:///tmp/gita/r1
 * tag               t1         -> FETCH_HEAD
(I) [17:18:29] git_aggregator.repo  foo  repo._merge():256 Pull r1, t1
(D) [17:18:29] git_aggregator.repo  foo  repo.log_call():158 /tmp/gita/foo> call ('git', 'pull', '--no-edit', '--depth', '1', 'r1', 't1')
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From file:///tmp/gita/r1
 * tag               t1         -> FETCH_HEAD
(I) [17:18:29] git_aggregator.repo  foo  repo._execute_shell_command_after():251 Execute shell after commands
(I) [17:18:29] git_aggregator.repo  foo  repo.aggregate():189 End aggregation of /tmp/gita/foo

Notice the 2 full outputs with obvious computation done twice.

I noted that the second output seems smaller (and quicker?) if depth: 1 is in defaults. And no fetch_all is activated.

I have a PR solving this issue coming soon.

vaab added a commit to 0k/git-aggregator that referenced this issue Apr 10, 2019
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.
@dreispt
Copy link

dreispt commented Jan 21, 2020

Additional issue is that, if the remote requires typing a password, the user will be asked twice for each branch.

@bealdav
Copy link

bealdav commented May 15, 2020

I'm also impacted with this problem

Here stock-logistics-workflow, you can see than after switched to branch 12.0, aggregator fetching all branches

Some repo may have some hundred of branches (in my case Odoo clone).

Even like below if branch 12-dav-ci is specified, the process fetch all branches. Then it lead to huge time (some minutes) while I only need one branch.

fetch

vaab added a commit to 0k/git-aggregator that referenced this issue May 23, 2020
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
vaab added a commit to 0k/git-aggregator that referenced this issue May 23, 2020
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
janverb pushed a commit to janverb/git-aggregator that referenced this issue Dec 23, 2020
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
NL66278 pushed a commit to Therp/git-aggregator that referenced this issue Feb 17, 2023
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
thomaspaulb pushed a commit to sunflowerit/git-aggregator that referenced this issue Jul 18, 2023
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
thomaspaulb added a commit to sunflowerit/git-aggregator that referenced this issue Jul 18, 2023
thomaspaulb added a commit to sunflowerit/git-aggregator that referenced this issue Jul 18, 2023
thomaspaulb added a commit to sunflowerit/git-aggregator that referenced this issue Jul 18, 2023
thomaspaulb pushed a commit to sunflowerit/git-aggregator that referenced this issue Jul 22, 2023
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
thomaspaulb pushed a commit to sunflowerit/git-aggregator that referenced this issue Jul 22, 2023
…csone#28)

Avoids also contacting twice (``fetch`` and then ``pull``) remote before
merging.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants