`git bug user`: unable to adopt identity

Labels: area/identity kind/bug priority/important-soon triage/accepted

Timeline

vitalyster (vitalyster) opened

I have pushed git-bug bugs and identities to some remote. Now I want to pull that remote on another machine and I got merge error: No identity is set. I'm able to create new identity only, it is not possible to adopt existing one because it is not merged. Now I have 2 identities and it is not possible to merge them/delete one. Am I miss something, or this is expected issue?

Michael Muré (MichaelMure) added label kind/bug

Michael Muré (MichaelMure) commented

I think this is a valid thing we need to fix, or at least check. I think at the moment git-bug requires having an identity to pull, as it might be required to make a merge commit. That doesn't sit well with your scenario. I think we need to make having a user optional there, and only error when we do need to make a merge.

Michael Muré (MichaelMure) commented

Copy/paste my other comment:

This is more of less a dup of #1003. The solution is not to have a new command, but to make pull fail later, only when we do need to have an identity (to merge data) instead of a hard requirement to do any pull. This would cover your scenario as you would pull data without having to do any merge (you don't have data locally yet, nothing to merge).

sudoforge commented

Adopting an identity is possible by manually fetching the refs/identities namespace, initiating the identity and bug cache, and then adopting an existing identity. Here's an example below, with any hash and user randomized:

➜ git init
Initialized empty Git repository in /tmp/tmp.4m5LR4TcGG/.git/


➜ git remote add origin git@github.com:example/repo.git


➜ git fetch origin +refs/identities/\*:refs/identities/\*
remote: Enumerating objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), 306 bytes | 306.00 KiB/s, done.
From ssh://github.com/example/repo
 * [new ref]         refs/identities/mbeaik8jm9onmu6xifh2fa2du53vgo4utzu9hspvapdjbdv51v087599nqmstg09 -> refs/identities/mbeaik8jm9onmu6xifh2fa2du53vgo4utzu9hspvapdjbdv51v087599nqmstg09


➜ git bug ls
Building identity cache... Done.
Building bug cache... Done.


➜ git bug user adopt mbeaik8
Your identity is now: someuser


➜ git bug user ls
mbeaik8 someuser

Taylor Hillegeist (taylorh140) commented (edited)

Adopting an identity is possible by manually fetching the refs/identities namespace, initiating the identity and bug cache, and then adopting an existing identity. Here's an example below, with any hash and user randomized:

➜ git init
Initialized empty Git repository in /tmp/tmp.4m5LR4TcGG/.git/


➜ git remote add origin git@github.com:example/repo.git


➜ git fetch origin +refs/identities/\*:refs/identities/\*
remote: Enumerating objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), 306 bytes | 306.00 KiB/s, done.
From ssh://github.com/example/repo
 * [new ref]         refs/identities/mbeaik8jm9onmu6xifh2fa2du53vgo4utzu9hspvapdjbdv51v087599nqmstg09 -> refs/identities/mbeaik8jm9onmu6xifh2fa2du53vgo4utzu9hspvapdjbdv51v087599nqmstg09


➜ git bug ls
Building identity cache... Done.
Building bug cache... Done.


➜ git bug user adopt mbeaik8
Your identity is now: someuser


➜ git bug user ls
mbeaik8 someuser

I just get fatal: invalid refspec '+refs/identities/\*:refs/identities/\*'

sudoforge commented

I just get fatal: invalid refspec '+refs/identities/\*:refs/identities/\*'

This would appear to indicate that you are quoting the refspec, as in:

git fetch origin '+refs/identities/\*:refs/identities/\*'

In the command line I provided, I did not quote the refspec, and used \ to escape the asterisk (*) to avoid shell expansion. If you want to quote the refspec, remove the backslash characters preceding each asterisk. Alternatively, don't quote it, and type it exactly as I provided it.

Taylor Hillegeist (taylorh140) commented (edited)

git fetch origin +refs/identities/*:refs/identities/* Thanks!

image

I am using windows cmd so maybe that causes weirdness. if I type in the individual file it can copy it over, but that's a bit much.

im using git v2.41.0

sudoforge commented

did you try removing the backslash and quoting it? i don't use Command Prompt (or windows at all), so i'm unable to be immediately helpful here in debugging how to translate a POSIX-compliant command line into something for Command Prompt.

Taylor Hillegeist (taylorh140) commented (edited)

So i think i got it from start to end working: A. order is important so the git bug ls needs to happen after the fetch.

A. clone git clone D:\origin altstart

B. copy refs git fetch origin refs/identities/*:refs/identities/* //I have no idea why it's particular about earlier command in windos land

C. initialize git bug git bug ls

sudoforge commented (edited)

A. order is important so the git bug ls needs to happen after the fetch

Yes, this is how the instructions in my earlier comment are structured.

Matthew Scheffel (isosphere) commented (edited)

I'm having some trouble with this; I have an existing repo that I'd like to use git-bug with, and I develop for it on two machines.

I made a user on one machine, and I made a bug. I have pushed the changes.

I ran git fetch origin +refs/identities/\*:refs/identities/\* on the other machine, which proceeded without error. I'm not sure how to do the "initialize git bug" step - as of 1212f755a0 there is no git bug ls command, and git bug user ls returns nothing.

In my mind I should be adopting the existing user I made rather than making a new one. I guess I could make one user per computer, but they'll all be me 🤷‍♂️


e:

I ended up making a new user, pulling, and then adopting the existing user; leaving me with a dangling orphan user. I don't love it, but it works.

sudoforge commented (edited)

@isosphere my previous instructions are still valid for the latest (very old) release, 0.8.0.

As a way to accomplish the same goal at 1212f755a0df22f69e201912390ea9f710ccbf1f, follow these instructions (i have a repository that can serve as a functional example you can use):

➜ git bug version
git-bug version: dev-1212f755a0

clone the repository

➜ git clone https://github.com/sudoforge/git-bug-example.git .
Cloning into '.'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

fetch the identity refs

➜ git fetch origin +refs/identities/\*:refs/identities/\*
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 297 bytes | 297.00 KiB/s, done.
From https://github.com/sudoforge/git-bug-example
 * [new ref]         refs/identities/57b660f812bc1b0212b1bd961cbae4cac62bec487d2a71efc3d52e9f9a86a858 -> refs/identities/57b660f812bc1b0212b1bd961cbae4cac62bec487d2a71efc3d52e9f9a86a858

build the identity cache

➜ git bug user ls
Building cache... 
57b660f demo-user

adopt the identity

➜ git bug user adopt 57b660f
Your identity is now: demo-user

sudoforge commented

I ended up making a new user, pulling, and then adopting the existing user; leaving me with a dangling orphan user. I don't love it, but it works.

You can delete the identity from the remote:

git push origin :refs/identities/...

disclaimer: i don't know what impact this may have on git-bug. you may need to delete the identity cache and rebuild it.

sudoforge added label area/identity

sudoforge added label priority/important-soon

sudoforge added label triage/accepted

Milan Hauth (milahu450) commented (edited)

unable to delete existing identiy

still an issue with git-bug version d499b6e9d3333334614924669b74640a2d0b5485

expected ux

$ git bug user
1d56dab Milan Hauth

$ git bug user show
1d56dab Milan Hauth

$ git bug user rm 1d56dab

git bug wipe is not a workaround

sudoforge added label lifecycle/active

sudoforge removed label lifecycle/active

sudoforge changed the title from `git bug user`: unable to adopt identity to `git bug user`: unable to adopt identity

sudoforge commented

i split the feature request for deleting an identity out into #1393 so that it can be tracked separately from the bug in adopting an identity that leads to the need for that feature.

github-actions (github-actions) added label lifecycle/pinned

sudoforge removed label lifecycle/pinned

sudoforge commented (edited)

WORKAROUND FOR ADOPTING A REMOTE IDENTITY AS OF 0.8.1

TESTED WITH:

- 0.8.1
- 0.9.0
- 0.10.0
- 0.10.1

---

it should work with every future version as well,
so don't worry if there's a newer release, i likely
just forgot to update this comment

this is very similar to before, but the cli was changed in 0.8.1; i'm just posting it for whoever finds it useful.


WHEN TO USE THIS

  • You have created an identity and pushed it to the remote, and
  • You are in a new or cleaned environment, and want to adopt that identity

Clone your repository as normal.

git clone ...

Fetch the identities from the remote

git fetch origin +refs/identities/\*:refs/identities/\*

Initialize git-bug's identity cache

git bug user

This should display a list of your identities, like so:

➜ git bug user                                           
Building cache... 
ed12343 albert-einstein

Adopt the identity you want

git bug user adopt ed12343

You should see output confirming that you adopted the identity, like so:

Your identity is now: albert-einstein

Dan Passaro (dan-passaro) commented

These instructions didn't work for me using 0.10.1. Even after fetching the refs, git bug user had no effect. I had to create a new bogus user, then I was able to git bug pull and adopt my existing user.

sudoforge commented

Are you sure there was an identity on the remote? This works from a new repository set up with the bare minimum to meet the expected criteria specified under the when to use this header.

Did you receive any error message?

Dan Passaro (dan-passaro) commented (edited)

Yes, as I mentioned I was able to git bug pull and get my existing user after creating the new user. Here's my shell session:

$ git fetch origin +refs/identities/\*:refs/identities/\*
From github.com:dan-passaro/fitlog
 * [new ref]         refs/identities/3ee5f055d53e9348d91fec4662a4ae7a64ed917d944c83603b02147daad19db5 -> refs/identities/3ee5f055d53e9348d91fec4662a4ae7a64ed917d944c83603b02147daad19db5
 * [new ref]         refs/identities/990edb610155ef59ce82fc77c6c468f31bae07967cc0e36afc67d083c16780fb -> refs/identities/990edb610155ef59ce82fc77c6c468f31bae07967cc0e36afc67d083c16780fb
 * [new ref]         refs/identities/b0a2227dffb5c951e0387fe8d2db9328e2af91e661f1efc64dccb8a9ba09757a -> refs/identities/b0a2227dffb5c951e0387fe8d2db9328e2af91e661f1efc64dccb8a9ba09757a
$ git bug user
$ 

But what looks relevant here is that I didn't create my repo via git clone, but jj git clone --colocate. When trying in a new directory made with git clone, the instructions work perfectly.

Unfortunately I'm not an expert on jj, just a casual user, so I have no idea why the .git directory created by it would cause this to break. I know jj can leave git in "detached HEAD" state, but even after checking out a branch with git checkout I'm still unable to get git bug user to work. But as mentioned before, if I create a new user then do git bug pull I get all existing users and can adopt the existing identity.

EDIT: But even though git bug user doesn't work to refresh the cache and list users, I am still able to use git bug user adopt b0a2227 (my bogus user), then run git bug pull and get git bug in a working state. So I can just add the git bug user adopt b0a2227 step to my README as a workaround until this issue gets fixed 🙂