You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In colocated repo, if you run jj after git checkout (not jj checkout), old HEAD could be abandoned.
This behavior is correct since the HEAD ref is moved externally, and the old HEAD is no longer referenced by git, but it's easy to lose commits by mistake.
I sometimes do git fetch && git checkout FETCH_HEAD as sloppy way of switching branches, and notice my wip commits went away after that.
Steps to Reproduce the Problem
set -e
set -x
#rm -Rf repo
mkdir repo
cd repo
git init
jj init --git-repo .
touch a
jj ci -m 'jj a'
touch b
jj ci -m 'jj b'
jj log --no-pager
# move HEAD ref back without using jj: 'b' -> 'a'
git checkout `jj log -r 'description("jj a")' -T 'commit_id' --no-graph`# git::import_refs() abandons old HEAD 'b'
sleep 1
jj log --no-pager
The current behavior was introduced by 20eb9ec "git: don't abandon
HEAD commit when it loses a branch." While the change made HEAD mutation
behavior more consistent with a plain ref operation, HEAD can also move on
checkout, and checkout shouldn't be considered a history rewriting operation.
I'm not saying the new behavior is always correct, but I think it's safer
than losing old HEAD branch. I also think this change will help if we want
to extract HEAD management function from git::import_refs().
Fixesjj-vcs#1042.
Description
In colocated repo, if you run
jj
aftergit checkout
(notjj checkout
), oldHEAD
could be abandoned.This behavior is correct since the
HEAD
ref is moved externally, and the oldHEAD
is no longer referenced by git, but it's easy to lose commits by mistake.I sometimes do
git fetch && git checkout FETCH_HEAD
as sloppy way of switching branches, and notice my wip commits went away after that.Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: