From 35b2764e273022ccc7e965c30ecd3d3b2c3e56b9 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Sat, 21 Jun 2025 13:57:19 +1000 Subject: [PATCH] Update `on-load` example in documentation (#2016) --- doc.md | 6 +++++- doc.txt | 6 +++++- lf.1 | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc.md b/doc.md index 1ab08d9a..fb3e4cc7 100644 --- a/doc.md +++ b/doc.md @@ -1729,11 +1729,15 @@ The following example can be used to display git indicators in the info column: cmd on-load &{{ cd "$(dirname "$1")" || exit 1 - git rev-parse >/dev/null 2>&1 || exit 0 + [ "$(git rev-parse --is-inside-git-dir 2>/dev/null)" = false ] || exit 0 cmds="" for file in "$@"; do + case "$file" in + */.git|*/.git/*) continue;; + esac + status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1) if [ -n "$status" ]; then diff --git a/doc.txt b/doc.txt index 7a2a8478..3a8e530b 100644 --- a/doc.txt +++ b/doc.txt @@ -1949,11 +1949,15 @@ column: cmd on-load &{{ cd "$(dirname "$1")" || exit 1 - git rev-parse >/dev/null 2>&1 || exit 0 + [ "$(git rev-parse --is-inside-git-dir 2>/dev/null)" = false ] || exit 0 cmds="" for file in "$@"; do + case "$file" in + */.git|*/.git/*) continue;; + esac + status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1) if [ -n "$status" ]; then diff --git a/lf.1 b/lf.1 index b484f808..fdc51705 100644 --- a/lf.1 +++ b/lf.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 2.11.4 .\" -.TH "LF" "1" "2025-06-20" "" "DOCUMENTATION" +.TH "LF" "1" "2025-06-21" "" "DOCUMENTATION" .hy .SH NAME .PP @@ -2225,11 +2225,15 @@ column: \f[C] cmd on-load &{{ cd \[dq]$(dirname \[dq]$1\[dq])\[dq] || exit 1 - git rev-parse >/dev/null 2>&1 || exit 0 + [ \[dq]$(git rev-parse --is-inside-git-dir 2>/dev/null)\[dq] = false ] || exit 0 cmds=\[dq]\[dq] for file in \[dq]$\[at]\[dq]; do + case \[dq]$file\[dq] in + */.git|*/.git/*) continue;; + esac + status=$(git status --porcelain --ignored -- \[dq]$file\[dq] | cut -c1-2 | head -n1) if [ -n \[dq]$status\[dq] ]; then