Skip to content

Does git media push need to be optimized for new branches? #144

Closed

Description

@technoweenie

Noticed this just now...

$ GIT_TRACE=1 g push origin zip -u
15:06:27.305081 git.c:349               trace: built-in: git 'push' 'origin' 'zip' '-u'
15:06:27.305860 run-command.c:341       trace: run_command: 'git-remote-https' 'origin' 'https://github.com/github/git-media-test'
15:06:28.950260 run-command.c:341       trace: run_command: '.git/hooks/pre-push' 'origin' 'https://github.com/github/git-media-test'
15:06:28.954072 git.c:554               trace: exec: 'git-media' 'push' '--stdin' 'origin' 'https://github.com/github/git-media-test'
15:06:28.954444 run-command.c:341       trace: run_command: 'git-media' 'push' '--stdin' 'origin' 'https://github.com/github/git-media-test'
trace media: run_command: 'git' version
trace media: run_command: git rev-list --objects --no-walk 3b3fa196433e75f0427e3836422fa86a1809fcb3
trace media: run_command: git cat-file --batch-check
trace media: run_command: git cat-file --batch
trace media: push_asset: c85d2d9ba03452788dcef6ad1421b886d436d9738d8500193aed57280d75a0a7 mp4/video.mp4 1/3
trace media: run_command: 'git' config -l
trace media: run_command: 'git' config -l -f .gitconfig
trace media: push_asset: 2dc8a4cf9428b26a53394df79108b84da77c7f6dcce65f308b33bd358a3380b3 psd/octicons-bg.psd 2/3
trace media: push_asset: 126e7e611979c6596dfc66695b6750f573e5b6190f81e19804e8bab69e132526 zip/Octocats.zip 3/3

My branch only added zip/Octocats.zip, but it's still pushing the other assets. Now, the server already has them, so they should not have been re-uploaded.

@rubyist: I assume this is because it's comparing the branch HEAD against 0000000. Ideally we should find a common ancestor between the current branch and other branches on the same remote.

Not a blocker at all, but it's worth tracking.

Activity

  1. rubyist commented on Jan 9, 2015

    @rubyist
    Contributor

    Yeah, if I remember right it's because at the points that we can hook into git, that's what the client sends when it starts negotiating with the server. The common ancestor/what does the server already have stuff is figured out by the server and we can't see any of that from the pre-push hook. I think in order to reliably calculate a common ancestor we'll have to make some remote calls.

    Although it's logged as push_asset from the tracer, that happens before the OPTIONS call, so it shouldn't actually push data twice.

  2. mhagger commented on Jan 12, 2015

    @mhagger
    Contributor

    If we are willing to trust that the asset server contains all of the objects whose pointer files are reachable from the remote-tracking branches for the corresponding remote repository, then we could limit ourselves to sending assets in

    git rev-list --objects $BRANCH_NEW_SHA1 --not --remotes=$REMOTE
    

    ; e.g., in your case,

    git rev-list --objects zip --not --remotes=origin
    

    This doesn't require a remote call.

    If we don't want to trust the remote-tracking branches, then I think the best we can do is

    git ls-remote $REMOTE |
        awk '{ print "^" $1}' |
        git rev-list --objects --ignore-missing $BRANCH_NEW_SHA1 --stdin
    

    If the remote has very many remote references, you could limit the number of remote references that have to be transferred while probably get almost as good a result by adding --branches to the git ls-remote invocation.

    In all of these cases, if multiple branches are being pushed, then all of the branches' new SHA-1s should be inserted where $BRANCH_NEW_SHA1 appears, though avoiding command-line-length limitations would probably require the SHA-1s to be passed to stdin in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions