diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-04-20 03:00:59 -0700 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-04-20 03:02:45 -0700 |
commit | bfa81b86af0a20ffbc7ddb32c9c65a2d2fa50b03 (patch) | |
tree | 7932fa267f9a95735e44ef07e3e5a8c0e3ac6af3 /sh | |
parent | b9b8557efdbe21dcfb2ccd5ae16d90bc18830b17 (diff) |
ccp read multi branch input separate with space
Diffstat (limited to 'sh')
-rwxr-xr-x | sh/ccp | 28 |
1 files changed, 9 insertions, 19 deletions
@@ -7,7 +7,7 @@ cd "$HOME/programs/config_local_arch" || exit 1 # https://www.shellcheck.net/wiki/SC2095 # ssh may swallow stdin, use read need file descriptor workaround or ssh disable stdin -# I choose to use for ... in ... alternative instead +# so I choose to use for instead of `... | while read ...` for branch in $(git branch | awk '{print ($1=="*")?$2:$1}'); do if [ "$branch" != master ]; then echo "sshing to server $branch..." @@ -23,28 +23,18 @@ done git checkout master for commit in $(git rev-list --reverse "$picked..HEAD"); do git show "$commit" - printf 'Enter branch name to cherry pick this commit: (a for all, enter to skip)\n' + printf 'Enter branch names to cherry pick this commit: +(a for all, space to seperate multiple branches, enter to skip)\n' read -r branch_pick if [ "$branch_pick" = a ]; then # !/master/ to not cherry pick to master branch - git branch | awk '!/master/{print ($1=="*")?$2:$1}' | while read -r branch; do - git checkout "$branch" - git cherry-pick "$commit" - git status - # wait to check if git status if good or need manual intervention - #echo 'Enter to continue.' - # place holder var a because POSIX read no var is undefined - #read a - done - elif [ "$branch_pick" ]; then - while [ "$branch_pick" ]; do - git checkout "$branch_pick" - git cherry-pick "$commit" - git status - echo 'Enter branch name to cherry pick this commit: (enter to skip)' - read -r branch_pick - done + branch_pick="$(git branch | awk '!/master/{print ($1=="*")?$2:$1}')" fi + for branch in $branch_pick; do + git checkout "$branch" + git cherry-pick "$commit" + git status + done done cp "$XDG_DATA_HOME/mydata/cfgl_cherry_picked" "$XDG_DATA_HOME/mydata/cfgl_cherry_picked.bak" |