-
Notifications
You must be signed in to change notification settings - Fork 350
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
Bookmark Refs Reset After Push Due to Mismatch in .git/config Fetch Setting #5115
Comments
Yes, the current Git integration assumes that the remote refs are moved accordingly. Maybe there would be some way to force libgit2 do the default thing. |
Note that it is very easy to run into the described situation when people clone a shallow repo: $ git clone --depth=1 [email protected]:martinvonz/jj.git shallow-jj
Cloning into 'shallow-jj'...
remote: Enumerating objects: 499, done.
remote: Counting objects: 100% (499/499), done.
remote: Compressing objects: 100% (441/441), done.
remote: Total 499 (delta 89), reused 188 (delta 44), pack-reused 0 (from 0)
Receiving objects: 100% (499/499), 1.79 MiB | 4.76 MiB/s, done.
Resolving deltas: 100% (89/89), done. $ cat shallow-jj/.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:martinvonz/jj.git
fetch = +refs/heads/main:refs/remotes/origin/main
[branch "main"]
remote = origin
merge = refs/heads/main |
- fetch = +refs/heads/main:refs/remotes/origin/main
+ fetch = +refs/heads/*:refs/remotes/origin/* fixed the issue |
I looked a bit through the libgit2 code but I couldn't find a way to tell the push code to use a specified fetch refspec. I filed libgit2/libgit2#6969 to add support for it. It's possible I missed it and it's already supported. I suppose they'll let us know in that case. |
Description
I'm seeing an issue where a bookmark ref is being reset to a previous commit after a push. This behavior seems to be related to the
.git/config
file's fetch settings. Specifically, when the fetch setting is not+refs/heads/*:refs/remotes/origin/*
, the updated remote ref is not immediately fetched after push, causing the nextjj status
to reset it.Steps to Reproduce the Problem
jj
.git/config
file has a fetch setting that is not+refs/heads/*:refs/remotes/origin/*
. For example:jj status
after the push.Expected Behavior
The bookmark ref should not be reset at jj status after push.
The updated remote ref should be immediately fetched and reflected in the local state.
Actual Behavior
The bookmark ref is not fetched after push, which can be proven by looking at the local git refs.
This cannot be reproduced if the
.git/config
file contains+refs/heads/*:refs/remotes/origin/*
Additional Information
According to the documentation, the fetch setting in
.git/config
is ignored bylibgit2
and thereforejj
. However, this is not the case, and the fetch setting seems to affect the push behavior.Logs:
Notice the difference between .git/refs/remotes/origin/tim-janik/push-rtpllwlqomtn and .git/refs/heads/tim-janik/push-rtpllwlqomtn right after push.
The suggested fix is to ensure that pushed bookmarks are properly fetched as part of push, regardless of any fetch settings in the Git configuration.
Specifications
The text was updated successfully, but these errors were encountered: