diff options
-rwxr-xr-x | users/sterni/git-only-push/git-only-push.sh | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/users/sterni/git-only-push/git-only-push.sh b/users/sterni/git-only-push/git-only-push.sh index e9f9e2dfc079..d425db27191e 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 <rev>] -r <remote> -t <refspec> [--] <commit>..." \ + "git only-push [-n] [-x] [-b <rev>] -r <remote> -t <refspec> [--] <commit>..." \ >&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 <remote>\tRemote to push to. \t-t <refspec>\tTarget ref to push to. \t-b <rev>\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 |