On 08/15/2012 12:41 AM, David C. Rankin wrote:
Guys,
I have a local tree that I converted to 3.5.13-sru. However, not all of the
modules switched to sru -- how did that happen? When I try a 'git pull' and
'git
submodule init' I get:
Module: 'applications/abakus' - current local branch is already
'v3.5.13-sru'
U admin
U cmake
U src/CMakeLists.txt
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
Skipping unmerged submodule admin
Skipping unmerged submodule cmake
I think I have it sorted. Before making a switch from master -> v3.5.13-sru,
your GIT tree must be fully updated to not miss a commit that is relevant to the
new branch. I first converted the problem branch a week or two ago before many
of the v3.5.13-sru branch was created for several packages. Then when attempting
to switch and update all modules today, I hit that situation and git failed to
see a v3.5.13-sru branch available and refused the git pull. Adding the following:
## get remote branches available and parse for branch name
gitremotebranches
if [[ ! "${remba[@]}" =~ "$branch" ]]; then
gitresetHEAD master
gitremotebranches
fi
uses git branch -r to getremotebranches to fill the $remba array and tests it
against the substring "$branch" (v3.5.13-sru) to see if the branch is available
remotely. If not, it then does a full reset of the package back to the current
master with 'gitresetHEAD master'. It then again obtains the remote branches
available and proceed to switch to v3.5.13-sru if it is contained in the new
remote branch array. Seems to have worked nicely.
The gitresetHEAD() function is shown below for completeness.
## function - reset current module to HEAD and update
gitresetHEAD() {
## normal reset to head, discard local edits and update
git reset --hard HEAD
git clean -dxf
git pull
git reset --hard HEAD
git clean -dxf
sed -i "s/system@/${gituser}@/g" .gitmodules
git submodule init
git submodule update --recursive
git submodule foreach --recursive "git checkout "$1""
git submodule foreach --recursive "git pull"
git checkout -- .gitmodules
}
--
David C. Rankin, J.D.,P.E.