From f094a0062365214d791aba1e8d6942d220ca044d Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 31 May 2026 14:51:16 -0700 Subject: [PATCH] Make tug skip empty @ and target @- instead When @ is a fresh empty scratchpad, tug now moves the closest bookmark to @- so it lands on the actual work instead of the empty change. Driven by a new tug_target() revset. --- jj/config.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jj/config.toml b/jj/config.toml index 9d54ba1..91f8970 100644 --- a/jj/config.toml +++ b/jj/config.toml @@ -27,6 +27,10 @@ fetch = "github" # The bookmark nearest below a given rev — powers `tug`. "closest_bookmark(to)" = "heads(::to & bookmarks())" +# Where `tug` should land the bookmark: @ normally, but @- when @ is an +# empty change (so a fresh scratchpad doesn't drag the bookmark off the work). +"tug_target()" = "(@ ~ empty()) | (@ & empty())-" + [aliases] # Compact log of your open work. wip = ["log", "-r", "open()"] @@ -38,5 +42,5 @@ tips = ["log", "-r", "unbookmarked()"] bks = ["log", "--no-graph", "-r", "bookmarks() | remote_bookmarks()", "-T", "separate(\" \", committer.timestamp().local().format(\"%Y-%m-%d %H:%M\"), separate(\" \", bookmarks, remote_bookmarks)) ++ \"\\n\""] -# Drag the closest bookmark up to @. -tug = ["bookmark", "move", "--from", "closest_bookmark(@)", "--to", "@"] +# Drag the closest bookmark up to @ (or @- when @ is an empty change). +tug = ["bookmark", "move", "--from", "closest_bookmark(tug_target())", "--to", "tug_target()"]