Skip to content

Commit 9a1d8fe

Browse files
committed
Merge branch 'fixes-and-oplog-alt-j'
* Branch commit log: jj-fzf: merging: prefer (master|main|trunk) as UPSTREAM jj-fzf: make sure to use gsed Makefile: check-gsed: show line numbers jj-fzf: op-log: use Alt-J to inject an old working copy as historic commit Breaking: the old keybinding for this was Alt-W Signed-off-by: Tim Janik <timj@gnu.org>
2 parents d70ccbe + c817b0e commit 9a1d8fe

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ shellcheck-error:
2626
tests-basics.sh:
2727
$Q tests/basics.sh
2828
check-gsed: jj-fzf
29-
$Q ! grep --color=auto -E '[^\\]\bsed ' jj-fzf \
29+
$Q ! grep --color=auto -nE '[^\\]\bsed ' jj-fzf /dev/null \
3030
|| { echo "ERROR: use gsed" >&2 ; false; }
3131
$Q echo ' OK gsed uses'
3232
check: check-deps shellcheck-error check-gsed tests-basics.sh

jj-fzf

+8-4
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ echo_commit_msg()
434434
test ${#FILES[@]} -gt 0 &&
435435
printf "%s: \n" "${FILES[@]}" ||
436436
echo ""
437-
{ jj config --no-pager get 'ui.default-description' 2>/dev/null || : ; } | sed '1{/^$/d}'
437+
{ jj config --no-pager get 'ui.default-description' 2>/dev/null || : ; } | gsed '1{/^$/d}'
438438
test ${#FILES[@]} -le 0 ||
439439
echo_signoff
440440
fi
@@ -834,8 +834,10 @@ merging()
834834
cd "$JJROOT" # otherwise, a subdir and $PWD could vanish
835835
temp_dir
836836
# Find tracked upstream revision
837-
[[ $(jj --no-pager --ignore-working-copy log --no-graph -r 'trunk()' -T 'bookmarks') =~ ^([^@\ :]+).* ]] &&
838-
UPSTREAM="${BASH_REMATCH[1]}" || UPSTREAM=
837+
for ups in $(jj --no-pager --ignore-working-copy log --no-graph -r 'trunk()' -T 'bookmarks') ; do
838+
[[ $ups =~ ^(master|main|trunk)(@.*)$ ]] && { UPSTREAM="${BASH_REMATCH[1]}" && break ; }
839+
[[ $ups =~ ^([^@\ :]+).* ]] && UPSTREAM="${BASH_REMATCH[1]}"
840+
done && echo $UPSTREAM
839841
WCA="$(jj log --ignore-working-copy --no-pager --no-graph -r "::@- & $P" -T change_id)" # is $P working copy ancestor?
840842
test -z "$WCA" && WCA=0 || WCA=1
841843
echo $WCA > $TEMPD/wcrebase.toggle
@@ -1015,9 +1017,9 @@ op-log()
10151017
H="$H"$'Ctrl-P: Preview changes in an operation with patch via `jj op show -p <op>`\n'
10161018
H="$H"$'Ctrl-S: Preview "@" at a specific operation via `jj show @`\n'
10171019
H="$H"$'\n'
1020+
H="$H"$'Alt-J: Inject working copy of the selected operation as historic commit before @\n'
10181021
H="$H"$'Alt-K: Kill undo memory (marked `⋯`), to restart undo at the top\n'
10191022
H="$H"$'Alt-R: Restore repository to the selected operation via `jj op restore`\n'
1020-
H="$H"$'Alt-W: Restore working copy of the selected operation into a new commit before @\n'
10211023
H="$H"$'Alt-Y: Undo/redo the selected operation entry\n'
10221024
H="$H"$'Alt-Z: Undo the next operation (not already marked `⋯`)\n'
10231025
echo 'VIEW=preview_oppatch' >> $TEMPD/oplog.env
@@ -1031,6 +1033,7 @@ op-log()
10311033
--bind "ctrl-l:execute-silent( gsed 's/^VIEW=.*/VIEW=preview_oplog/' -i $TEMPD/oplog.env )+refresh-preview" \
10321034
--bind "ctrl-p:execute-silent( gsed 's/^VIEW=.*/VIEW=preview_oppatch/' -i $TEMPD/oplog.env )+refresh-preview" \
10331035
--bind "ctrl-s:execute-silent( gsed 's/^VIEW=.*/VIEW=preview_opshow/' -i $TEMPD/oplog.env )+refresh-preview" \
1036+
--bind "alt-j:execute( $SELF restore-commit {} )+abort" \
10341037
--bind "alt-k:execute( $SELF undo-reset {} )+$RELOAD" \
10351038
--bind "alt-r:execute( $SELF op-restore {} )+abort" \
10361039
--bind "alt-w:execute( $SELF restore-commit {} )+abort" \
@@ -1040,6 +1043,7 @@ op-log()
10401043
--preview-window 'nowrap,right,border-left' \
10411044
--preview "[[ {} =~ $OPPAT ]] || exit; export JJFZF_ATOP=\"\${BASH_REMATCH[1]}\" && . $TEMPD/oplog.env && $SELF \$VIEW {}" \
10421045
--no-tac --no-sort +m
1046+
# TODO: remove alt-w in jj-fzf-0.26
10431047
)
10441048
KEYBINDINGS["Ctrl-O"]="op-log"
10451049

0 commit comments

Comments
 (0)