Pushing to empty repository on Github fails

Create issue
Issue #93 closed
Oliver created an issue

Hi,

I am using hg-git revision 631 (711baa274f78) with the dulwich version that comes with Mercurial 2.8.1 included in TortoiseHg 2.10.1 (not sure how to find the exact dulwich version there, though).

So I have already exported the Mercurial repository windirstat/windirstat here on Bitbucket using hg-git+dulwich and there appears to be no failure to that point.

I then created an empty repository on Github to push the changes to. The whole process runs quite a long time and then fails with the following error message:

% hg --repository D:\projects\WinDirStat\windirstat-current push git+ssh://git@github.com/windirstat/windirstat.git
pushing to git+ssh://git@github.com/windirstat/windirstat.git
searching for changes
adding objects
abort: git remote error: refs/tags/release-1-1-1, refs/tags/Release-1_1_0, refs/heads/1540811b1fafb79fbc3f6092b7fd83c565442e0e, refs/tags/remove_obsolete, refs/tags/Release_1_0_1, refs/tags/Release_1_0_0, refs/tags/Release_1_1_2, refs/heads/master failed to update
[command returned code 255 Sun Feb 02 02:46:17 2014]
windirstat-current% 

Does anybody have an idea what could be wrong? The bookmarks for master and 1540811b1fafb79fbc3f6092b7fd83c565442e0e are on revision 458 (1540811b1faf) of the windirstat/windirstat repo.

Any insight would be appreciated. I am not sure how else I can interact with the Git repo on the other end.

Thanks,

// Oliver

PS: please let me know if anything is missing and I'll try to supply it ASAP.

Comments (18)

  1. Oliver reporter

    I am getting a similar error when trying to push to an empty repository (also via SSH) to a local VM.

    % hg --repository D:\projects\WinDirStat\windirstat-current push git+ssh://oliver@192.168.52.128:wds-latest-github/
    pushing to git+ssh://oliver@192.168.52.128:wds-latest-github/
    searching for changes
    adding objects
    abort: git remote error: refs/heads/master failed to update
    [command returned code 255 Sun Feb 02 03:11:04 2014]
    windirstat-current% 
    
  2. Oliver reporter

    Btw, just tried ... Git itself is able to push to the bare remote repository. So what I did was change into the .hg folder, rename git to .git temporarily and then simply

    $ git remote add origin git@github.com:windirstat/windirstat.git
    $ git push -u origin master
    
    $ git push -u origin master                                                                                                                                        
    Counting objects: 5690, done.                                                                                                                                                                                                                  
    Delta compression using up to 2 threads.
    Compressing objects: 100% (5573/5573), done.
    Writing objects: 100% (5690/5690), 5.86 MiB | 117 KiB/s, done.
    Total 5690 (delta 4130), reused 0 (delta 0)
    To git@github.com:windirstat/windirstat.git
     * [new branch]      master -> master                                                                                                                                                                                                          
    Branch master set up to track remote branch master from origin.
    

    However, what I end up with is unfortunately only a part of the complete repository.

    Because when I ask Mercurial what it would push to the remote Github repo, it gives me this:

    > hg outgoing github|findstr ^changeset
    changeset:   167:cbb7ca1a6de2
    changeset:   168:b37abb93e647
    changeset:   439:0c234b404f7d
    changeset:   442:75fc280ea9c6
    changeset:   443:5f518006ee4b
    changeset:   444:9d17c86de2fa
    changeset:   445:12d1a69c02ad
    changeset:   446:bc3848d1695d
    changeset:   447:5a68b496e8f2
    changeset:   448:cab3a6bbbd18
    changeset:   451:813372ee129d
    changeset:   452:7a09ccfd7eed
    changeset:   453:e2b411dae86f
    changeset:   454:a36620010833
    changeset:   456:75e237fd162b
    changeset:   457:4c2112dfdd76
    

    which, when I confirm it leads to the same as in the initial report:

    pushing to git+ssh://git@github.com:windirstat/windirstat.git
    ["git-receive-pack 'windirstat/windirstat.git'"]
    searching for changes
    adding objects
    abort: git remote error: refs/tags/release-1-1-1, refs/tags/Release-1_1_0, refs/heads/1540811b1fafb79fbc3f6092b7fd83c565442e0e, refs/tags/remove_obsolete, refs/tags/Release_1_0_1, refs/tags/Release_1_0_0, refs/tags/Release_1_1_2 failed to update
    
  3. Oliver reporter

    Actually, when I come to think of it, the git push worked without a flaw. So the fault seems to lie with the gexport. If I ask Git to tell me more about the repo:

    $ git tag -l
    error: refs/tags/Release-1_1_0 does not point to a valid object!
    error: refs/tags/Release_1_0_0 does not point to a valid object!
    error: refs/tags/Release_1_0_1 does not point to a valid object!
    error: refs/tags/Release_1_1_2 does not point to a valid object!
    error: refs/tags/release-1-1-1 does not point to a valid object!
    error: refs/tags/remove_obsolete does not point to a valid object!
    $ git branch -l
      1540811b1fafb79fbc3f6092b7fd83c565442e0e
    * master
    $ git log
    fatal: bad object HEAD
    

    I've done the gexport routine a few times but there is no error message. Is it possible that it fails silently?

  4. cbrandt

    I was able to push to new github repository using a local hg repository(1) with hg-git without any trouble. If a change is made to that same local hg repository(1) I used for the initial push, committed, and then I try to push that change set back up to the same github repository, the error occurs.

    hg push
    pushing to git+ssh://git@github.com:charlesbrandt/templates.git
    ["git-receive-pack 'charlesbrandt/templates.git'"]
    searching for changes
    adding objects
    abort: git remote error: refs/heads/fdd2810a3a46bbeba78cff7695964069400cbc41, refs/heads/master failed to update
    

    If I clone the repository(2) from github using hg-git, then make the change locally(2), I can commit locally(2) and the push the change back up to github without any trouble.

    If I use mercurial to clone the previously locally cloned(2) repository from github to a new local mercurial repository(3), make a change there, then try to push that back up to github, it says there are no changes (but no error otherwise).

    hg push git+ssh://git@github.com:charlesbrandt/templates.git
    pushing to git+ssh://git@github.com:charlesbrandt/templates.git
    ["git-receive-pack 'charlesbrandt/templates.git'"]
    searching for changes
    no changes found
    

    After that I can push back to the original locally cloned repo(2) from local(3). It sees the changes, and then from repo(2) I can push up to github where the changes are seen.

    Seems like something fishy is going on with the way changes are pushed, but for now I'm going to make a point to re-clone directly from github.

  5. Jakub Urban

    Hi, I actually have the same issue I think. For me the scenario was:

    1. Started from a Hg repo (local + Bitbucket) with several commits
    2. Created a Github repo
    3. First push to Github ok
    4. Commited and pushed to local + Bitbucket repositories
    5. hg push to Github fails
     abort: git remote error: refs/heads/7342b246ee14442455da018fccc1cff694cb0707, refs/heads/master failed to update
    
  6. Gideon Sireling

    I'm not able to clone the empty GitHub repo either.

    ** Unknown exception encountered with possibly-broken third-party extension hggit
    ** which supports versions 3.1 of Mercurial.
    ** Please disable hggit and try your action again.
    ** If that fixes the bug please report it to https://bitbucket.org/durin42/hg-git/issues
    ** Python 2.7.8 (default, Oct 18 2014, 12:50:18) [GCC 4.9.1]
    ** Mercurial Distributed SCM (version 3.1.2)
    ** Extensions loaded: color, progress, rebase, histedit, shelve, strip, pager, hggit
    Traceback (most recent call last):
      File "/usr/bin/hg", line 43, in <module>
        mercurial.dispatch.run()
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 28, in run
        sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 69, in dispatch
        ret = _runcatch(req)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 138, in _runcatch
        return _dispatch(req)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 839, in _dispatch
        cmdpats, cmdoptions)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 600, in runcommand
        ret = _runcommand(ui, options, cmd, d)
      File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 196, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/hgext/pager.py", line 158, in pagecmd
        return orig(ui, options, cmd, cmdfunc)
      File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 196, in wrap
        return wrapper(origfn, *args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/hgext/color.py", line 433, in colorcmd
        return orig(ui_, opts, cmd, cmdfunc)
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 930, in _runcommand
        return checkargs()
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 901, in checkargs
        return cmdfunc()
      File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 836, in <lambda>
        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
      File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 550, in check
        return func(*args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 1331, in clone
        branch=opts.get('branch'))
      File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 402, in clone
        destpeer.local().clone(srcpeer, heads=revs, stream=stream)
      File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1730, in clone
        return self.pull(remote, heads)
      File "/home/***/hg-git/hggit/util.py", line 42, in inner
        return f(*args, **kwargs)
      File "/home/***/hg-git/hggit/hgrepo.py", line 18, in pull
        return self.githandler.fetch(remote.path, heads)
      File "/home/***/hg-git/hggit/git_handler.py", line 231, in fetch
        refs = self.fetch_pack(remote, heads)
      File "/home/***/hg-git/hggit/git_handler.py", line 1052, in fetch_pack
        ret = client.fetch_pack(path, determine_wants, graphwalker, f.write, progress.progress)
      File "/usr/lib/python2.7/dist-packages/dulwich/client.py", line 1041, in fetch_pack
        wants = determine_wants(refs)
      File "/home/***/hg-git/hggit/git_handler.py", line 1046, in determine_wants
        filteredrefs = self.filter_refs(refs, heads)
      File "/home/***/hg-git/hggit/git_handler.py", line 1095, in filter_refs
        for ref, sha in refs.iteritems():
    AttributeError: 'NoneType' object has no attribute 'iteritems'
    
  7. ederag

    Same issue trying to push an existing mercurial repo with hg-git:

    create a new repo on github

    set up .hg/hgrc with

    [paths]
    # (Mind the switch from colon to slash after the host!)
    default = git+ssh://git@github.com/ederag/Qt_combined_move.git
    

    Then hg push yields

    pushing to git+ssh://git@github.com/ederag/Qt_combined_move.git
    exporting hg objects to git
    converting revision 1579771853e57b15c1cdccac47e2ae53af3c65bc
    converting revision a22fc9efade6919c27db43d8323cfceb81320e66
    converting revision 3ea6a83b171e73740e71a802f9c4870401a78745
    converting revision 2fff4c29cad9b4cbb2417ea320a2bda3f190b445
    converting revision 55433e5ca63eadbb6c36ffd754122ee09b2ca34d
    converting revision 27f8a6195e0018450b30898347433542778dce90
    converting revision 1f947a68c55560981fdc41e0db014dc13abaea94
    converting revision 217d4416ac36dba50d7be6422b65242cb42f1a8c
    converting revision e3da19e970456a827ca29220086d19ac9e00798d
    converting revision 3bb3bc2c9a9070b56147cbfba95c3662035085d6
    converting revision 2792b1b51c58ed1ec31b6300a2f99b6dc74e68a3
    converting revision a9d33c2e8e0ec097bbf465a5c26f278471a51ca2
    converting revision 5ff23abd73ef969ff0cc6354357a51ad50c8198e
    converting revision c7c2bce13cf0fe520bc18b1810aca5787dda4804
    converting revision f49e31c7128d861528ee79bd1db12bb92e6722be
    converting revision 8f1701120d7a99aecf87835cf7b8fb24161707b6
    converting revision 57d20c0dd7d72d66021c0dfd6a3b5f08d97ad1d9
    converting revision 90ecccdb51d982c4739c5736489ec62059d60d79
    converting revision 1aa7a0c53808f9bb030213f779efd99d39c905fe
    converting revision 8e1853363e16815c40d158f0396125335b1b854e
    converting revision 5d519049de0dfa7ab745ffb321410fcebc579629
    converting revision 693a3bdef66afc58aad527abfc2a67192762e49d
    searching for changes
    22 commits found
    adding objects
    abort: git remote error: refs/heads/8e1853363e16815c40d158f0396125335b1b854e, refs/heads/master failed to update
    

    pushing to a local repo created with git init --bare works fine. So I assume the problem comes either from the git+ssh protocol or something on github:

    mkdir ../gh
    cd ../gh
    git init --bare
    cd -
    hg push ../gh
    

    yields

    pushing to ../gh
    searching for changes
    22 commits found
    adding objects
    added 22 commits with 22 trees and 25 blobs
    

    hg-git was installed with sudo pip2.7 install hg-git :

    Downloading/unpacking hg-git
      Downloading hg-git-0.8.0.tar.gz (46kB): 46kB downloaded
      Running setup.py (path:/tmp/pip_build_root/hg-git/setup.py) egg_info for package hg-git
    
    Requirement already satisfied (use --upgrade to upgrade): dulwich>=0.9.7 in /usr/lib/python2.7/site-packages/dulwich-0.9.8-py2.7-linux-x86_64.egg (from hg-git)
    Installing collected packages: hg-git
      Running setup.py install for hg-git
    
    Successfully installed hg-git
    Cleaning up...
    

    Mercurial version:

    Mercurial Distributed SCM (version 3.1.2)
    (see http://mercurial.selenic.com for more information)
    
    Copyright (C) 2005-2014 Matt Mackall and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    Enabled extensions:
    
      graphlog    
      extdiff     
      record      
      color       
      hgattic     
      strip       
      mq          
      largefiles  
      hgk         
      histedit    
      hggit
    
  8. anatoly techtonik

    Seems to hang to push to empty repo on GitHub with "adding objects" as last message. Dulwich 0.10.0 and hg-git 0.8.0 on hg 3.0 (Fedora).

  9. Özgür Akgün

    I have done the exact same thing as @urbanj and it failed in the same way.

    The first push was successful, the second one wasn't.

  10. Augie Fackler repo owner

    Is this still a problem? If so, please let me know here.

    I'm sort of planning to write a bug-reaping bot for bitbucket, so if there's no activity the bug will probably get closed after a while.

  11. ederag

    Yes, problem still there, even after sudo pip2.7 install --upgrade hg-git, which installed dulwich-0.11.2.tar.gz.

  12. Zoltán Lehóczky

    It indeed seems to be fixed, haven't seen this in a long time despite using empty repos routinely.

  13. Log in to comment