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

git bug user: unable to adopt identity, delete existing identity #1003

Open
vitalyster opened this issue Jan 19, 2023 · 13 comments
Open

git bug user: unable to adopt identity, delete existing identity #1003

vitalyster opened this issue Jan 19, 2023 · 13 comments
Labels
bug Something isn't working
Milestone

Comments

@vitalyster
Copy link

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?

@MichaelMure MichaelMure added the bug Something isn't working label Feb 1, 2023
@MichaelMure
Copy link
Owner

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.

@MichaelMure
Copy link
Owner

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).

@MichaelMure
Copy link
Owner

That is:

@sudoforge
Copy link

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

@taylorh140
Copy link

taylorh140 commented Oct 9, 2023

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
Copy link

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.

@taylorh140
Copy link

taylorh140 commented Oct 9, 2023

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
Copy link

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.

@taylorh140
Copy link

taylorh140 commented Oct 9, 2023

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
Copy link

sudoforge commented Oct 9, 2023

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.

@isosphere
Copy link

isosphere commented Mar 4, 2024

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 1212f75 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
Copy link

sudoforge commented Mar 10, 2024

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

As a way to accomplish the same goal at 1212f75, 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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants