keybase / client

Keybase Go Library, Client, Service, OS X, iOS, Android, Electron
BSD 3-Clause "New" or "Revised" License
8.89k stars 1.23k forks source link

Repeated pushes from a mirrored clone deletes HEAD #22520

Open jasonkarns opened 4 years ago

jasonkarns commented 4 years ago

Keybase version: Version 5.2.0-20200130011203+cf82db8320 (5.2.0-20200130011203+cf82db8320) MacOS Catalina 10.15.3 git version 2.25.0 keybase log id: bf8317f6c36a1094efe2941c

I have a handful of repos on github that I want to mirror in keybase.

1. Pushing to keybase via URL

Initial setup works as desired:

$ git clone --mirror git@github.com:jasonkarns/repo.git
Cloning into bare repository 'repo.git'...
remote: Enumerating objects: 236, done.
remote: Counting objects: 100% (236/236), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 236 (delta 89), reused 234 (delta 87), pack-reused 0
Receiving objects: 100% (236/236), 613.98 KiB | 2.84 MiB/s, done.
Resolving deltas: 100% (89/89), done.
$ cd repo.git
$ git push --mirror keybase://private/jasonkarns/repo
Initializing Keybase... done.
Syncing with Keybase... done.
Syncing encrypted data to Keybase: (100.00%) 5.97/5.97 KB... done.
Counting objects: 621.48 KB... done.
Preparing and encrypting objects: (100.00%) 621.48/621.48 KB... done.
Counting refs: done.
Preparing and encrypting refs: done.
Counting packed refs: 305 bytes... done.
Preparing and encrypting packed refs: (100.00%) 305/305 bytes... done.
To keybase://private/jasonkarns/tempy
 * [new branch]      master -> master
 * [new tag]         v1.0.0 -> v1.0.0
 * [new tag]         v2.0.0 -> v2.0.0

But running the same push command a second time deletes HEAD from the keybase remote.

$ git push --mirror keybase://private/jasonkarns/repo
Initializing Keybase... done.
Syncing with Keybase... done.
To keybase://private/jasonkarns/repo
 - [deleted]         HEAD

2. Pushing to keybase via named remote

Also, setting up the clone with a named remote for keybase works fine on the initial push:

$ git clone --mirror git@github.com:jasonkarns/repo.git
Cloning into bare repository 'repo.git'...
remote: Enumerating objects: 236, done.
remote: Counting objects: 100% (236/236), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 236 (delta 89), reused 234 (delta 87), pack-reused 0
Receiving objects: 100% (236/236), 613.98 KiB | 2.84 MiB/s, done.
Resolving deltas: 100% (89/89), done.
$ cd repo.git
$ git remote add --mirror=push keybase keybase://private/jasonkarns/repo
$ git push keybase
Initializing Keybase... done.
Syncing with Keybase... done.
Syncing encrypted data to Keybase: (100.00%) 5.97/5.97 KB... done.
Counting objects: 621.48 KB... done.
Preparing and encrypting objects: (100.00%) 621.48/621.48 KB... done.
Counting refs: done.
Preparing and encrypting refs: done.
Counting packed refs: 305 bytes... done.
Preparing and encrypting packed refs: (100.00%) 305/305 bytes... done.
To keybase://private/jasonkarns/repo
 * [new branch]      master -> master
 * [new tag]         v1.0.0 -> v1.0.0
 * [new tag]         v2.0.0 -> v2.0.0

But yet again, any subsequent push deletes HEAD.

$ git push keybase
Initializing Keybase... done.
Syncing with Keybase... done.
To keybase://private/jasonkarns/repo
 - [deleted]         HEAD

In both cases, after getting the "deleted HEAD" message, the Keybase app then shows "This folder is empty." when viewing files for that repo.

This issue does not manifest when pushing from a non-mirror clone.

jasonkarns commented 4 years ago

(FWIW, the examples I used above use different repo names than what might appear in my keybase logs. If that causes confusion, I'd be happy to reproduce or converse out-of-band)

3. Pushing to github via URL

I should also mention that I repeated the steps above using a brand new repo on github, and the repeated push (still from the --mirror clone) worked as expected:

$ git push --mirror git@github.com:jasonkarns/literate-telegram.git
Enumerating objects: 236, done.
Counting objects: 100% (236/236), done.
Delta compression using up to 8 threads
Compressing objects: 100% (121/121), done.
Writing objects: 100% (236/236), 613.98 KiB | 27.91 MiB/s, done.
Total 236 (delta 89), reused 236 (delta 89)
remote: Resolving deltas: 100% (89/89), done.
To github.com:jasonkarns/literate-telegram.git
 * [new branch]      master -> master
 * [new tag]         v1.0.0 -> v1.0.0
 * [new tag]         v2.0.0 -> v2.0.0
$ git push --mirror git@github.com:jasonkarns/literate-telegram.git
Everything up-to-date

4. Pushing to github via named remote

and with a named remote:

$ git remote add --mirror=push lt git@github.com:jasonkarns/literate-telegram.git
$ git push lt
Everything up-to-date
strib commented 4 years ago

Your first command output has this line in it:

Cloning into bare repository 'repo.git'...

Your third output is different; it's missing that line and missing some "remote:" prefixes. Is that just a copy-paste editing error, or is that really the output in both cases? Haven't tested it personally yet, just confused about that.

jasonkarns commented 4 years ago

Your third output is different;

The third one being the one in this comment? I didn't perform a clone in that example because I was pushing to github from one of the existing clones.

I just added some headings for the different setups. I assume the third example you're referring to is the one now titled: Pushing to github via URL which was done from an existing clone so I didn't perform the clone step.

strib commented 4 years ago

Oh sorry, I misread it. Ok, I'll make a ticket to look into it when there's time. We haven't tested much or at all with mirror pushes, so thanks for bringing it to our attention!

strib commented 4 years ago

Ok I think I have a PR that will fix this: #22725 . It should hopefully make it into the next release. Thanks again for the report!