|
|
@ -22,13 +22,20 @@ function usage() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
search_commits=""
|
|
|
|
search_commits=""
|
|
|
|
|
|
|
|
reset_option="--mixed"
|
|
|
|
|
|
|
|
|
|
|
|
while getopts ":hc" opt
|
|
|
|
while getopts ":hcSH" opt
|
|
|
|
do
|
|
|
|
do
|
|
|
|
case "$opt" in
|
|
|
|
case "$opt" in
|
|
|
|
c)
|
|
|
|
c)
|
|
|
|
search_commits="1"
|
|
|
|
search_commits="1"
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
|
|
|
|
S)
|
|
|
|
|
|
|
|
reset_option="--soft"
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
H)
|
|
|
|
|
|
|
|
reset_option="--hard"
|
|
|
|
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
@ -44,7 +51,10 @@ done
|
|
|
|
if [[ -n "${search_commits}" ]]; then
|
|
|
|
if [[ -n "${search_commits}" ]]; then
|
|
|
|
selected_commites=$(/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" log --oneline --color=always --decorate=short | \
|
|
|
|
selected_commites=$(/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" log --oneline --color=always --decorate=short | \
|
|
|
|
fzf --header='select which commit to reset' --preview "echo {} | awk '{print \$1}' | \
|
|
|
|
fzf --header='select which commit to reset' --preview "echo {} | awk '{print \$1}' | \
|
|
|
|
xargs -I __ /usr/bin/git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} show --color=always __")
|
|
|
|
xargs -I __ /usr/bin/git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} show --color=always __" | \
|
|
|
|
|
|
|
|
awk '{print $1}')
|
|
|
|
|
|
|
|
[[ -z "${selected_commites}" ]] && exit 0
|
|
|
|
|
|
|
|
/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" reset "${selected_commites}" "${reset_option}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
selected_files=$(/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" diff --name-status --cached | \
|
|
|
|
selected_files=$(/usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" diff --name-status --cached | \
|
|
|
|
awk '{print "\033[32m" $1 " " $2}' | fzf --header='select files to unstage' --multi --preview "echo {} | awk '{print \$2}' | \
|
|
|
|
awk '{print "\033[32m" $1 " " $2}' | fzf --header='select files to unstage' --multi --preview "echo {} | awk '{print \$2}' | \
|
|
|
|