-
Notifications
You must be signed in to change notification settings - Fork 871
Description
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 next jj status to reset it.
Steps to Reproduce the Problem
- Clone a colocated repository, e.g.
jj - Ensure the
.git/configfile has a fetch setting that is not+refs/heads/*:refs/remotes/origin/*. For example:[remote "origin"] url = [email protected]:martinvonz/jj.git fetch = +refs/heads/main:refs/remotes/origin/main
- Set a bookmark to a new commit.
- Push the new bookmark to the remote.
- Run
jj statusafter the push. - Observe that the bookmark ref is reset to a previous commit.
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 by libgit2 and therefore jj. However, this is not the case, and the fetch setting seems to affect the push behavior.
Logs:
$ jj git push -b tim-janik/push-rtpllwlqomtn
Changes to push to origin:
Move sideways bookmark tim-janik/push-rtpllwlqomtn from ba9a6eeb584d to 28a06d5a9151
$ find . -name \*rtpllwl*
./.git/refs/remotes/origin/tim-janik/push-rtpllwlqomtn
./.git/refs/heads/tim-janik/push-rtpllwlqomtn
./.git/logs/refs/remotes/origin/tim-janik/push-rtpllwlqomtn
./.git/logs/refs/heads/tim-janik/push-rtpllwlqomtn
$ tail ./.git/refs/remotes/origin/tim-janik/push-rtpllwlqomtn ./.git/refs/heads/tim-janik/push-rtpllwlqomtn ./.git/logs/refs/remotes/origin/tim-janik/push-rtpllwlqomtn ./.git/logs/refs/heads/tim-janik/push-rtpllwlqomtn
==> ./.git/refs/remotes/origin/tim-janik/push-rtpllwlqomtn <==
ba9a6eeb584dc8390433b130e3d0342fcf30e671
==> ./.git/refs/heads/tim-janik/push-rtpllwlqomtn <==
28a06d5a915118c9178d2ae52da16515b0c4db86
==> ./.git/logs/refs/remotes/origin/tim-janik/push-rtpllwlqomtn <==
0000000000000000000000000000000000000000 c26b7ce8bc0635462ce4a4b4157e7ed8e80b4908 unknown <unknown> 1734377420 +0100
c26b7ce8bc0635462ce4a4b4157e7ed8e80b4908 ba9a6eeb584dc8390433b130e3d0342fcf30e671 unknown <unknown> 1734378979 +0100
==> ./.git/logs/refs/heads/tim-janik/push-rtpllwlqomtn <==
0000000000000000000000000000000000000000 c26b7ce8bc0635462ce4a4b4157e7ed8e80b4908 Tim Janik <[email protected]> 1734377536 +0100 export from jj
c26b7ce8bc0635462ce4a4b4157e7ed8e80b4908 f50bcf4b2c3f30edce6002b40161b5cb56fb1f99 Tim Janik <[email protected]> 1734377863 +0100 export from jj
f50bcf4b2c3f30edce6002b40161b5cb56fb1f99 ba9a6eeb584dc8390433b130e3d0342fcf30e671 Tim Janik <[email protected]> 1734377874 +0100 export from jj
ba9a6eeb584dc8390433b130e3d0342fcf30e671 c26b7ce8bc0635462ce4a4b4157e7ed8e80b4908 Tim Janik <[email protected]> 1734377975 +0100 export from jj
c26b7ce8bc0635462ce4a4b4157e7ed8e80b4908 ba9a6eeb584dc8390433b130e3d0342fcf30e671 Tim Janik <[email protected]> 1734378979 +0100 export from jj
ba9a6eeb584dc8390433b130e3d0342fcf30e671 28a06d5a915118c9178d2ae52da16515b0c4db86 Tim Janik <[email protected]> 1734379059 +0100 export from jj
$ jj st
Abandoned 1 commits that are no longer reachable.
Done importing changes from the underlying Git repo.
The working copy is clean
Working copy : oyvkwkkn 8ca8f018 (empty) (no description set)
Parent commit: ryxozuxo fca92f1e cli: add --config-file=PATH argumentNotice 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
- Platform: Linux
- Version: jj-0.24.0 + a few upstream commits, I am pretty sure I have seen this with 0.23.0 as well.