From a5fb53cd8e08091a8658f884d1209f9be024a935 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 12 Dec 2024 03:43:00 +0100 Subject: [PATCH 1/3] Makefile: check-deps: check dependencies before installing Signed-off-by: Tim Janik --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a185d2e..4f57057 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,11 @@ Q ::= $(if $(findstring 1, $(V)),, @) all: check -install: jj-fzf - $(INSTALL) -t "$(bindir)" $< - +check-deps: jj-fzf + $Q jj-fzf --version + $Q jj-fzf --help >/dev/null # check-deps +install: check-deps + $(INSTALL) -t "$(bindir)" jj-fzf uninstall: $(RM) "$(bindir)/jj-fzf" @@ -23,4 +25,4 @@ shellcheck-error: shellcheck -W 3 -S error jj-fzf tests-basics.sh: $Q tests/basics.sh -check: jj-fzf shellcheck-error tests-basics.sh +check: check-deps shellcheck-error tests-basics.sh From c41695df7c083203e4506c43e79dfcf5beee1683 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 12 Dec 2024 04:56:01 +0100 Subject: [PATCH 2/3] Makefile: check for gsed uses throughout Signed-off-by: Tim Janik --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f57057..37178fe 100644 --- a/Makefile +++ b/Makefile @@ -25,4 +25,8 @@ shellcheck-error: shellcheck -W 3 -S error jj-fzf tests-basics.sh: $Q tests/basics.sh -check: check-deps shellcheck-error tests-basics.sh +check-gsed: jj-fzf + $Q ! grep --color=auto -E '[^\\]\bsed ' jj-fzf \ + || { echo "ERROR: use gsed" >&2 ; false; } + $Q echo ' OK gsed uses' +check: check-deps shellcheck-error check-gsed tests-basics.sh From 812ef488eade893216aa26e8858122580a34e70f Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 12 Dec 2024 04:56:01 +0100 Subject: [PATCH 3/3] jj-fzf: fix all gsed uses Signed-off-by: Tim Janik --- jj-fzf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jj-fzf b/jj-fzf index 2218044..c345f96 100755 --- a/jj-fzf +++ b/jj-fzf @@ -78,7 +78,7 @@ versionge "$(bash --version)" 5.1.16 || die "failed to find 'bash' version 5.1.1 [[ `set -o` =~ emacs ]] || die "the 'bash' executable lacks interactive readline support" versionge "$(jj --version --ignore-working-copy)" 0.24 || die "failed to find 'jj' version 0.24.0 in \$PATH" versionge "$(fzf --version)" 0.43 || die "failed to find 'fzf' version 0.43.0 in \$PATH" # 0.43.0 supports offset-up -sed --version 2>/dev/null | grep -Fq 'GNU sed' && gsed() { sed "$@"; } && export -f gsed || +sed --version 2>/dev/null | grep -Fq 'GNU sed' && gsed() { \sed "$@"; } && export -f gsed || gsed --version | grep -Fq 'GNU sed' || die "failed to find 'gsed' in \$PATH (GNU sed)" command -v column >/dev/null || column() { cat; } @@ -507,7 +507,7 @@ bookmark() R="$(xrev_or_commit "${1:-@}")" #echo "# Existing Bookmarks:" && jj --no-pager --ignore-working-copy bookmark list readarray -t BOOKMARKS < <(jj --no-pager --ignore-working-copy bookmark list -T 'self.name()++"\n"' | sort | uniq) - readarray -t NEAREST < <(jj --no-pager --ignore-working-copy log --no-graph -r "::$R|$R+" -T 'bookmarks++"\n"' | sed -r 's/\b \b/\n/g; s/\*$//; s/\b@.*//; /^$/d') + readarray -t NEAREST < <(jj --no-pager --ignore-working-copy log --no-graph -r "::$R|$R+" -T 'bookmarks++"\n"' | gsed -r 's/\b \b/\n/g; s/\*$//; s/\b@.*//; /^$/d') [[ ${#NEAREST[@]} -ge 1 ]] && INIT="${NEAREST[0]}" || INIT="" PROMPT='Bookmark Name: ' echo "# Assign Bookmark to:" @@ -566,7 +566,7 @@ delete-refs() ( R="$(xrev_or_commit "${1:-@}")" # find first local bookmark in $R, use as query arg - readarray -t NEAREST < <(jj --no-pager --ignore-working-copy log --no-graph -r "$R" -T 'local_bookmarks++"\n"' | sed -r 's/\b \b/\n/g; s/\*$//; s/\b@.*//; /^$/d') + readarray -t NEAREST < <(jj --no-pager --ignore-working-copy log --no-graph -r "$R" -T 'local_bookmarks++"\n"' | gsed -r 's/\b \b/\n/g; s/\*$//; s/\b@.*//; /^$/d') [[ ${#NEAREST[@]} -ge 1 ]] && B=(-q "${NEAREST[0]}") || B=() require_git_dir # exports GIT_DIR # select bookmark or tag @@ -579,7 +579,7 @@ delete-refs() "${B[@]}" \ < <( # list local bookmarks - jj --ignore-working-copy bookmark list | # sed reorders conflicted + jj --ignore-working-copy bookmark list | # gsed reorders conflicted gsed -r ':0; /^\s/!s/ \(conflicted\):/: (conflicted)/; N; $!b0; s/\n\s+/ /g' | while read MARK rest ; do printf "%-32s [bookmark] %s\n" "${MARK%:}" "$rest" @@ -931,7 +931,7 @@ op_log_oneline() if LAST_OPID=$(jj --no-pager --ignore-working-copy config get jj-fzf.last-undo 2>/dev/null) && jj --no-pager --ignore-working-copy op log -n1 --no-graph -T "$OP_LOG_FIRSTLINE" | grep -qF ": undo operation $LAST_OPID" ; then jj --no-pager --ignore-working-copy op log --color=always -T "$JJ_FZF_OP_LOG_ONELINE16" | - sed -r "1,/${LAST_OPID:0:16}\b/s/([@○])/⋯/" # ⮌ ⋯ ⤺↶ + gsed -r "1,/${LAST_OPID:0:16}\b/s/([@○])/⋯/" # ⮌ ⋯ ⤺↶ else jj --no-pager --ignore-working-copy op log --color=always -T "$JJ_FZF_OP_LOG_ONELINE16" fi @@ -1567,7 +1567,7 @@ list_key_bindings() } SHOW_KEYS="$(jj --ignore-working-copy config get 'jj-fzf.show-keys' 2>/dev/null || echo true)" [[ "$*" =~ --key-toggle ]] && { - SHOW_KEYS="$(echo "$SHOW_KEYS" | sed 's/^false/x/; s/^true/false/; s/^x/true/')" + SHOW_KEYS="$(echo "$SHOW_KEYS" | gsed 's/^false/x/; s/^true/false/; s/^x/true/')" jj --ignore-working-copy config set --user 'jj-fzf.show-keys' "$SHOW_KEYS" } $SHOW_KEYS || {