bash - Git branches to be merged in shell script variable -
bash - Git branches to be merged in shell script variable -
i'm creating script merge branches defined in shell script variable. here part of script
# here how setting variable 'branches' all_branches=`git ls-remote . | cutting -d $'\t' -f 2` # include folder prefix includepattern= if [[ -n "$include_pattern" ]] ; export ifs="," pattern in $include_pattern; includepattern="$includepattern -e $remote_folder$pattern" done fi branches=`echo "$all_branches" | eval "grep $includepattern"` echo "b = $branches" echo "c = git merge -q --no-edit $branches" git merge -q --no-edit $branches
this output
b = refs/remotes/origin/xxx refs/remotes/origin/xxy c = git merge -q --no-edit refs/remotes/origin/xxx refs/remotes/origin/xxy merge: refs/remotes/origin/xxx refs/remotes/origin/xxy - not can merge
why not working?
info: when copy&paste of command (printed echo "c = ..."
works expected
more info: when run eval "git merge -q --no-edit $branches"
got error
/usr/lib/git-core/git-merge-octopus: 1: eval: bad substitution merge strategy octopus failed.
when set export ifs=,
, line
git merge -q --no-edit $branches
no longer passes 2 separate branch references git merge
, because whitespace no longer used word-splitting. it's if typed
git merge -q --no-edit "refs/remotes/origin/xxx refs/remotes/origin/xxy"
i think quickest way prepare restore original value of ifs
after done setting include_pattern
:
if [[ -n "$include_pattern" ]] ; old_ifs=$ifs export ifs="," pattern in $include_pattern; includepattern="$includepattern -e $remote_folder$pattern" done ifs=$old_ifs fi
this might work better:
# using here-doc instead of here string # avoid bug nowadays prior bash 4.3 ifs=, read -a patterns <<eof $include_pattern eof pattern in "${patterns[@]}"; includepattern+=" -e $remote_folder$pattern" done
git bash shell git-merge
Comments
Post a Comment