Skip to content

Commit

Permalink
Fix git pfor when branch is passed with no push option
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Dec 13, 2024
1 parent 30e90c2 commit b240728
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions home/dot_gitconfig.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ rr = "!f() { \

pfor = "!f() { \
set -ex; \
branch="$(echo "${1}" | cut -d'%' -f1)"; \
if echo "${1}" | grep -q %; then \
branch="$(echo "${1}" | cut -d'%' -f1)"; \
push_opts="$(echo "${1}" | cut -d'%' -f2-)"; \
else \
branch="${1}"; \
push_opts=""; \
fi; \
branch="${branch:-"$(git current-branch)"}"; \
push_opts="$(echo "${1}" | cut -d'%' -f2-)"; \
push_opts="${push_opts:+"%${push_opts}"}"; \
remote="$(git remote-for-branch "${branch}")"; \
git push "${remote}" "HEAD:refs/for/${branch}${push_opts}"; \
Expand Down

0 comments on commit b240728

Please sign in to comment.