@ -1,12 +1,8 @@
function omf.repo.pull
function omf.repo.pull -a repo_dir branch
if test -z " $branch "
if test ( count $argv ) -eq 0
set branch "master"
echo ( omf ::err) "omf.repo.pull takes a repository path as an argument." ( omf ::off) > & 2
return $OMF_MISSING_ARG
end
end
set -l repo_dir $argv [ 1 ]
function __omf.repo.git -V repo_dir
function __omf.repo.git -V repo_dir
command git -C " $repo_dir " $argv
command git -C " $repo_dir " $argv
end
end
@ -21,12 +17,12 @@ function omf.repo.pull
set initial_revision ( __omf .repo.git rev-parse -q --verify HEAD) ;
set initial_revision ( __omf .repo.git rev-parse -q --verify HEAD) ;
or return 1
or return 1
# the refspec ensures that '$remote/ master ' gets updated
# the refspec ensures that '$remote/ $branch ' gets updated
set -l refspec " refs/heads/ master:refs/remotes/$remote /master "
set -l refspec " refs/heads/ $branch :refs/remotes/ $remote / $branch "
__omf .repo.git fetch --quiet $remote $refspec ;
__omf .repo.git fetch --quiet $remote $refspec ;
or return 1
or return 1
if test ( __omf .repo.git rev-list --count master ...FETCH_HEAD) -eq 0
if test ( __omf .repo.git rev-list --count " $branch " ...FETCH_HEAD) -eq 0
return 2
return 2
end
end
@ -37,8 +33,8 @@ function omf.repo.pull
and set stashed
and set stashed
end
end
if test " $initial_branch " != master
if test " $initial_branch " != " $branch "
__omf .repo.git checkout master --quiet
__omf .repo.git checkout " $branch " --quiet
end
end
if not __omf.repo.git merge --ff-only --quiet FETCH_HEAD
if not __omf.repo.git merge --ff-only --quiet FETCH_HEAD
@ -48,7 +44,7 @@ function omf.repo.pull
return 1
return 1
end
end
if test " $initial_branch " != master
if test " $initial_branch " != " $branch "
__omf .repo.git checkout $initial_branch --quiet
__omf .repo.git checkout $initial_branch --quiet
end
end