diff --git a/functions/_tide_internal_vcs_jj.fish b/functions/_tide_internal_vcs_jj.fish index b7f9ce0..48cd677 100644 --- a/functions/_tide_internal_vcs_jj.fish +++ b/functions/_tide_internal_vcs_jj.fish @@ -118,6 +118,11 @@ if(self.contained_in("::trunk() & ~::@"), set -l ancestor_bm_limit 0 string match -qr '^\d+$' -- "$tide_jj_ancestor_bookmark_limit" && set ancestor_bm_limit $tide_jj_ancestor_bookmark_limit + # jj keeps an empty, undescribed @ on top of your work as scratch space. + # Counting it would make a clean checkout of trunk read ↑1, so such an @ + # is left out of ↑ and of ancestor bookmark depths. + set -l skipped_wc 0 + set -l info "" set -l has_conflict 0 set -l has_immutable 0 @@ -168,6 +173,10 @@ if(self.contained_in("::trunk() & ~::@"), if test "$parts[7]" = true set has_immutable 1 end + if test "$st" = "(empty)"; and test "$parts[8]" = "(no desc)" + set skipped_wc 1 + set ahead (math $ahead - 1) + end # Bookmarks at @ set -l at_bookmarks "" @@ -250,11 +259,14 @@ if(self.contained_in("::trunk() & ~::@"), set ancestor_depth_forks (math $ancestor_depth_forks + 1) set -l depth_commits (jj log --no-pager --no-graph --ignore-working-copy --color=never \ -r "$cid::@ ~ $cid" -T '".\n"' 2>/dev/null) - set depth (count $depth_commits) + set depth (math (count $depth_commits) - $skipped_wc) end else + # $ahead already leaves out a skipped @ set depth (math $ahead - 1) end + # A bookmark right below a skipped @ is where you are, so no suffix + test "$depth" = 0 && set depth "" for bookmark in (string split ',' -- $parts[2]) set bookmark (string trim -- $bookmark) if test $ancestor_bm_limit -gt 0; and test (count $display_bookmarks) -ge $ancestor_bm_limit diff --git a/tests/_tide_item_vcs.test.fish b/tests/_tide_item_vcs.test.fish index ed72b21..b3d540d 100644 --- a/tests/_tide_item_vcs.test.fish +++ b/tests/_tide_item_vcs.test.fish @@ -170,6 +170,25 @@ printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "defau cd $dir/jj-merge-repo _vcs_item # CHECK: (@ xyz999 def999 * desc feature↑3 ↑3) +# -------- jj empty working copy -------- +# An empty, undescribed @ is jj's scratch space, so it doesn't count toward +# ↑ or toward ancestor bookmark depths. A described one still counts. +mkdir -p $dir/jj-emptywc-repo/.jj +cd $dir/jj-emptywc-repo +printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "default\\n" ;;\n *"log"*) printf "xyz999\\t.\\t.\\tdefault\\tdef999\\t(empty)\\tfalse\\t(no desc)\\n" ;;\n *) exit 0 ;;\nesac\n' >$dir/bin/jj +_vcs_item # CHECK: (@ xyz999 def999 (empty) (no desc)) +printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "default\\n" ;;\n *"log"*) printf "xyz999\\t.\\t.\\tdefault\\tdef999\\t(empty)\\tfalse\\tplanned\\n" ;;\n *) exit 0 ;;\nesac\n' >$dir/bin/jj +_vcs_item # CHECK: (@ xyz999 def999 (empty) planned ↑1) +# Fast path: the bookmark right below @ gets no depth suffix. Show every +# ancestor bookmark, since new installs (and CI) only show the nearest one. +printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "default\\n" ;;\n *"::@ ~"*) exit 1 ;;\n *"log"*) printf "xyz999\\t.\\t.\\tdefault\\tdef999\\t(empty)\\tfalse\\t(no desc)\\nanc123\\tfeature\\n\\nanc456\\tbase\\n" ;;\n *) exit 0 ;;\nesac\n' >$dir/bin/jj +set -g tide_jj_ancestor_bookmark_limit 0 +_vcs_item # CHECK: (@ xyz999 def999 (empty) (no desc) feature base↑2 ↑3) +set -e -g tide_jj_ancestor_bookmark_limit +# Merge fallback: the per-bookmark count includes @, so it drops by one +printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "default\\n" ;;\n *"::@ ~"*) printf ".\\n.\\n.\\n" ;;\n *"log"*) printf "M\\nxyz999\\t.\\t.\\tdefault\\tdef999\\t(empty)\\tfalse\\t(no desc)\\nanc123\\tfeature\\n\\n" ;;\n *) exit 0 ;;\nesac\n' >$dir/bin/jj +_vcs_item # CHECK: (@ xyz999 def999 (empty) (no desc) feature↑2 ↑2) + # -------- jj bookmark truncation -------- # Long bookmark names (both at @ and on ancestors) are capped at # tide_jj_bookmark_length characters, defaulting to 24; 0 disables it.