Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

:Gina commit fails in repo with multiple remotes #202

Closed
ulidtko opened this issue Apr 25, 2019 · 3 comments
Closed

:Gina commit fails in repo with multiple remotes #202

ulidtko opened this issue Apr 25, 2019 · 3 comments
Labels

Comments

@ulidtko
Copy link

ulidtko commented Apr 25, 2019

Hi! First of all, nice plugin, enjoying it, thanks a lot.

Now, the "usual" simple commit works just fine for me from Gina. However I've just needed to do funny stuff with git remotes, and consequently get this on :Gina commit:

[gina] ['.git/hooks/prepare-commit-msg', '.git/COMMIT_EDITMSG', 'message']                                                                                                      
[gina] /bin/sh: 2: local-main2/master-4.4..snmp-agent: not found
[gina] Traceback (most recent call last):
[gina]   File ".git/hooks/commit-msg", line 37, in <module>
[gina]     shell=True).decode('utf-8').split()
[gina]   File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
[gina]     **kwargs).stdout
[gina]   File "/usr/lib/python3.6/subprocess.py", line 418, in run
[gina]     output=stdout, stderr=stderr)
[gina] subprocess.CalledProcessError: Command 'git rev-list --no-merges gitlab
[gina] local-main2/master-4.4..snmp-agent
[gina] ' returned non-zero exit status 127.
Press ENTER or type command to continue

It looks to me as if the git rev-list cmdline has got embedded newlines in it.

I'll explain the "funny stuff" with git remotes next — assuming that the reader understands the basic concepts of git remotes.

TL;DR: if my repo has two remotes — :Gina commit doesn't work.


We use a private GitLab instance. It has a repository called main. I also have two local clones on my machine, ~/src/main and ~/src/main2. Both of them have the default post-clone remote renamed origingitlab. An example of a remote branch is then gitlab/master-4.4; with this I can do things like git rebase gitlab/master-4.4. So far so good.

Now, I'm not a huge fan of keeping two separate clones around, but sometimes that comes as a real time-saver. Long story short, I ended up with commits in main2 repo which I needed to pull into main. Those commits are the branch snmp-agent.

Git is perfectly capable to treat a "neighbour" clone as a remote (that's what the file:// remote URIs essentially are). So I did:

$ cd ~/src/main
[main]$ git remote add local-main2 ../main2
[main]$ git fetch local-main2

If you follow me, this output would appear just as expected:

[main]$ git remote -v
gitlab	[email protected]:ipmp/main.git (fetch)
gitlab	[email protected]:ipmp/main.git (push)
local-main2	../ipmp-main2 (fetch)
local-main2	../ipmp-main2 (push)

Two remotes, alright? One gitlab, one local-main2.


Next, I get to pinpoint my work made in repo main2 as a branch snmp-agent in repo main:

[main]$ git checkout -b snmp-agent local-main2/snmp-agent
[main]$ git branch -u gitlab/master-4.6
[main]$ git status
On branch snmp-agent
Your branch and 'gitlab/master-4.6' have diverged,
and have 41 and 495 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

It's been a while, so I replay the changes on top of the updated gitlab/master-4.6, just as I always do.

[main]$ git pull --rebase
[...]
[main]$ git status
On branch snmp-agent
Your branch is ahead of 'gitlab/master-4.6' by 41 commits.
  (use "git push" to publish your local commits)

Great! Here, the "funny git stuff" ends. So I went back into vim, made some changes, invoked :Gina status, staged the changes and proceeded with :Gina commit, again as usual. Upon filling out the commit message, however I see the traceback as above (and no commit happens, and the long long commit message is lost):

[gina] ['.git/hooks/prepare-commit-msg', '.git/COMMIT_EDITMSG', 'message']                                                                                                     
[gina] /bin/sh: 2: local-main2/master-4.4..snmp-agent: not found
[gina] Traceback (most recent call last):
[gina]   File ".git/hooks/commit-msg", line 37, in <module>
[gina]     shell=True).decode('utf-8').split()
[gina]   File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
[gina]     **kwargs).stdout
[gina]   File "/usr/lib/python3.6/subprocess.py", line 418, in run
[gina]     output=stdout, stderr=stderr)
[gina] subprocess.CalledProcessError: Command 'git rev-list --no-merges gitlab
[gina] local-main2/master-4.4..snmp-agent
[gina] ' returned non-zero exit status 127.

That local-main2/master-4.4 looks really weird in the traceback. It shouldn't appear there at all — as I've definitely switched the upstream of snmp-agent to gitlab/master-4.6. The git rev-list invokation is totally borked. From the /bin/sh: ...: not found stderr, I deduce that the last three lines are not wrapping artifact, but two newlines embedded in git rev-list cmdline.


I hope, you can already guess what's wrong with Gina source 😃

:Gina commit works again as soon as I do git remote remove local-main2.

@lambdalisue
Copy link
Owner

Thank you for the detail 👍 It sounds a bug and I'll check 👍

@lambdalisue lambdalisue pinned this issue Apr 30, 2019
@lambdalisue
Copy link
Owner

Hum... I tried to reproduce but it's too complicated. Could you make the minimum case?

@ulidtko
Copy link
Author

ulidtko commented May 6, 2019

Ohhh... I'm sorry!

I tried minimizing the test, and quickly found out that Gina has nothing to do with this -- it was a local commit hook (.git/hooks/commit-msg) failing, in one specific repo. I just misinterpreted the origin of that stacktrace 😄

Thanks again; closing.

@ulidtko ulidtko closed this as completed May 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants