allow reset commit

pull/3/head
kevin zhuang 4 years ago
parent e9f3b849f9
commit a5c7caca18

@ -22,13 +22,20 @@ function usage() {
}
search_commits=""
reset_option="--mixed"
while getopts ":hc" opt
while getopts ":hcSH" opt
do
case "$opt" in
c)
search_commits="1"
;;
S)
reset_option="--soft"
;;
H)
reset_option="--hard"
;;
h)
usage
exit 0
@ -44,7 +51,10 @@ done
if [[ -n "${search_commits}" ]]; then
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}' | \
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
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}' | \

Loading…
Cancel
Save