diff --git a/users/sterni/git-only-push/git-only-push.sh b/users/sterni/git-only-push/git-only-push.sh index e9f9e2dfc..d425db271 100755 --- a/users/sterni/git-only-push/git-only-push.sh +++ b/users/sterni/git-only-push/git-only-push.sh @@ -25,7 +25,7 @@ die() { usage() { printf '%s\n' \ - "git only-push [-n] [-b ] -r -t [--] ..." \ + "git only-push [-n] [-x] [-b ] -r -t [--] ..." \ >&2 } @@ -33,7 +33,7 @@ base=refs/remotes/origin/HEAD dry=false # TODO(sterni): non-interactive mode, e.g. clean up also on cherry-pick failure -while getopts "b:r:t:nh" opt; do +while getopts "b:r:t:nxh" opt; do case $opt in # TODO(sterni): it is probably too close to --branch? b) @@ -48,13 +48,18 @@ while getopts "b:r:t:nh" opt; do n) dry=true ;; + x) + cherry_pick_x=true + ;; h|?) usage # TODO(sterni): add man page + # shellcheck disable=SC2016 [ "$opt" = "h" ] && printf ' \t-r \tRemote to push to. \t-t \tTarget ref to push to. \t-b \tOptional: Base revision to cherry-pick commits onto. Defaults to refs/remotes/origin/HEAD. +\t-x\t\tUse `git cherry-pick -x` for creating cherry-picks. \t-n\t\tDry run. ' [ "$opt" = "h" ] && exit 0 || exit 100 @@ -106,7 +111,7 @@ for rev in $revs; do printf 'Would cherry pick %s\n' "$rev" >&2 else no_cherry_pick=false - git cherry-pick "$rev" || no_cherry_pick=true + git cherry-pick ${cherry_pick_x:+-x} "$rev" || no_cherry_pick=true if $no_cherry_pick; then tmp="$worktree" # Prevent cleanup from removing the worktree