Commit 56b1d837 authored by jeremiejig's avatar jeremiejig

changing to git -C to git --git-dir work-tree

parent 5cdde263
...@@ -58,13 +58,13 @@ omf_install() { ...@@ -58,13 +58,13 @@ omf_install() {
die "Could not clone the repository → ${OMF_PATH}:${OMF_REPO_BRANCH}" die "Could not clone the repository → ${OMF_PATH}:${OMF_REPO_BRANCH}"
fi fi
local git_rev=$(git -C ${OMF_PATH} rev-parse HEAD) >/dev/null 2>&1 local git_rev=$(git --git-dir ${OMF_PATH}/.git --work-tree ${OMF_PATH} rev-parse HEAD) >/dev/null 2>&1
local git_upstream=$(git -C ${OMF_PATH} config remote.upstream.url) local git_upstream=$(git --git-dir ${OMF_PATH}/.git --work-tree ${OMF_PATH} config remote.upstream.url)
if [ -z "${git_upstream}" ]; then if [ -z "${git_upstream}" ]; then
git -C ${OMF_PATH} remote add upstream ${git_uri} git --git-dir ${OMF_PATH}/.git --work-tree ${OMF_PATH} remote add upstream ${git_uri}
else else
git -C ${OMF_PATH} remote set-url upstream ${git_uri} git --git-dir ${OMF_PATH}/.git --work-tree ${OMF_PATH} remote set-url upstream ${git_uri}
fi fi
echo "Oh My Fish revision id → ${git_rev}" echo "Oh My Fish revision id → ${git_rev}"
......
...@@ -3,46 +3,46 @@ function omf.repo.pull ...@@ -3,46 +3,46 @@ function omf.repo.pull
echo (omf::err)"Argument of omf.repo.pull is the repo path."(omf::off) echo (omf::err)"Argument of omf.repo.pull is the repo path."(omf::off)
return $OMF_MISSING_ARG return $OMF_MISSING_ARG
end end
set -l git_dir $argv[1] set -l repo_dir $argv[1]
if test (command git -C "$git_dir" config --get remote.upstream.url) if test (command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" config --get remote.upstream.url)
set repository upstream set repository upstream
else else
set repository origin set repository origin
end end
set initial_branch (command git -C "$git_dir" symbolic-ref -q --short HEAD); or return $OMF_UNKNOWN_ERR set initial_branch (command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" symbolic-ref -q --short HEAD); or return $OMF_UNKNOWN_ERR
set initial_revision (command git -C "$git_dir" rev-parse -q --verify HEAD); or return $OMF_UNKNOWN_ERR set initial_revision (command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" rev-parse -q --verify HEAD); or return $OMF_UNKNOWN_ERR
if not command git -C "$git_dir" diff --quiet if not command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" diff --quiet
echo (omf::em)"Stashing your changes:"(omf::off) echo (omf::em)"Stashing your changes:"(omf::off)
command git -C "$git_dir" status --short --untracked-files command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" status --short --untracked-files
command git -C "$git_dir" stash save --include-untracked --quiet command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" stash save --include-untracked --quiet
set stashed true set stashed true
end end
if test "$initial_branch" != master if test "$initial_branch" != master
command git -C "$git_dir" checkout master --quiet command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" checkout master --quiet
end end
# the refspec ensures that '$repository/master' gets updated # the refspec ensures that '$repository/master' gets updated
command git -C "$git_dir" pull --rebase --quiet $repository "refs/heads/master:refs/remotes/$repository/master" command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" pull --rebase --quiet $repository "refs/heads/master:refs/remotes/$repository/master"
if test $status -eq 2 #SIGINT if test $status -eq 2 #SIGINT
command git -C "$git_dir" checkout $initial_branch command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" checkout $initial_branch
command git -C "$git_dir" reset --hard $initial_revision command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" reset --hard $initial_revision
test "$stashed" = true; and command git -C "$git_dir" stash pop test "$stashed" = true; and command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" stash pop
end end
if test "$initial_branch" != master if test "$initial_branch" != master
command git -C "$git_dir" checkout $initial_branch --quiet command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" checkout $initial_branch --quiet
end end
if test "$stashed" = true if test "$stashed" = true
command git -C "$git_dir" stash pop --quiet command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" stash pop --quiet
echo (omf::em)"Restored your changes:"(omf::off) echo (omf::em)"Restored your changes:"(omf::off)
command git -C "$git_dir" status --short --untracked-files command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" status --short --untracked-files
end end
return 0 return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment