mob icon indicating copy to clipboard operation
mob copied to clipboard

Does not work with repositories cloned with `git-repo`

Open cpoissonnier opened this issue 3 years ago • 2 comments

Warning I'm not a git expert at all, the following message may be very stupid 😄

I am using git-repo to bootstrap my repositories.

This tool clone all repositories ~~as bare~~, and unfortunately, mob does not seem to work with these repositories.

When I try to do a mob next :

git add --all
ERROR git status --short
ERROR fatal: This operation must be run in a work tree
ERROR exit status 128

Is it possible to make mob work in that context ?

Thanks !

cpoissonnier avatar Aug 29 '22 14:08 cpoissonnier

A bare repo has no working tree. Why would you want to use the mob tool without a work tree? Can you share with me your use case, please?

simonharrer avatar Aug 29 '22 20:08 simonharrer

My bad, these repositories are not bare !

I can commit with the basic git commit/git push commands, but when I use mob next it does not work ...

You can reproduce it by installing repo:

brew install repo
# or
apt install repo

And then :

repo init -u [email protected]:cpoissonnier/manifest-example.git -m example.xml
repo sync
repo start main --all    
cd mob
mob start 
echo "test" > test.txt
mob next

cpoissonnier avatar Aug 31 '22 09:08 cpoissonnier

@cpoissonnier can you please help me understand this better? If its a git repo, but it is not bare, and it has no worktree, what is it then? I am not a git-repo expert.

gregorriegler avatar Sep 22 '22 19:09 gregorriegler

Hello,

The issue is related to the gitRootDir function.

This function does not work when the .git is a symlink to an other directory (which is what git-repo is doing). You should use something like:

func gitRootDir() string {
	return silentgit("rev-parse", "--show-toplevel")
}

to make it work in all situations.

Thanks !

freekk avatar Sep 23 '22 12:09 freekk

Thank you @freekk

gregorriegler avatar Sep 26 '22 19:09 gregorriegler