From 0a5b5572b98bffc5c0ad255a7964a3ff8ea37c31 Mon Sep 17 00:00:00 2001 From: Tinh Vo - dv59huli Date: Tue, 8 Apr 2025 21:57:47 +0200 Subject: [PATCH] my changed state --- bin/git-forgit | 56 +++++++++++++++++++++++++++++++++++-- completions/git-forgit.bash | 4 +++ forgit.plugin.zsh | 6 ++++ 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/bin/git-forgit b/bin/git-forgit index 4aebe59..3d6c72b 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -323,7 +323,7 @@ _forgit_diff() { $FORGIT_FZF_DEFAULT_OPTS +m -0 --bind=\"enter:execute($FORGIT diff_enter {} $escaped_commits | $FORGIT pager enter)\" --preview=\"$FORGIT diff_view {} '$_forgit_preview_context' $escaped_commits\" - --bind=\"alt-e:execute-silent($FORGIT edit_diffed_file {})+refresh-preview\" + --bind=\"alt-e:execute($FORGIT edit_diffed_file {})+refresh-preview\" $FORGIT_DIFF_FZF_OPTS --prompt=\"${commits[*]} > \" " @@ -348,12 +348,29 @@ _forgit_add_preview() { fi } +_forgit_unstage_preview() { + file=$(echo "$1" | _forgit_get_single_file_from_add_line) + if (git status -s -- "$file" | grep '^??') &>/dev/null; then # diff with /dev/null for untracked files + git diff --color=always --no-index -- /dev/null "$file" | _forgit_pager diff | sed '2 s/added:/untracked:/' + else + git diff --color=always -- "$file" | _forgit_pager diff + fi +} + _forgit_git_add() { _forgit_add_git_opts=() _forgit_parse_array _forgit_add_git_opts "$FORGIT_ADD_GIT_OPTS" git add "${_forgit_add_git_opts[@]}" "$@" } +_forgit_git_unstage() { # TODO! TBD new core + _forgit_add_git_opts=() + _forgit_parse_array _forgit_add_git_opts "$FORGIT_ADD_GIT_OPTS" + # alternative: git rm --cached "$@" + git reset "${_forgit_add_git_opts[@]}" -q HEAD -- "$@" bla + +} + _forgit_get_single_file_from_add_line() { # NOTE: paths listed by 'git status -su' mixed with quoted and unquoted style # remove indicators | remove original path for rename case | remove surrounding quotes @@ -365,7 +382,7 @@ _forgit_get_single_file_from_add_line() { _forgit_edit_add_file() { local input_line=$1 filename=$(echo "$input_line" | _forgit_get_single_file_from_add_line) - $EDITOR "$filename" >/dev/tty /dev/tty