mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-25 09:41:40 +08:00
changing to git -C to git --git-dir work-tree
This commit is contained in:
parent
5cdde2639a
commit
56b1d837e0
|
@ -58,13 +58,13 @@ omf_install() {
|
|||
die "Could not clone the repository → ${OMF_PATH}:${OMF_REPO_BRANCH}"
|
||||
fi
|
||||
|
||||
local git_rev=$(git -C ${OMF_PATH} rev-parse HEAD) >/dev/null 2>&1
|
||||
local git_upstream=$(git -C ${OMF_PATH} config remote.upstream.url)
|
||||
local git_rev=$(git --git-dir ${OMF_PATH}/.git --work-tree ${OMF_PATH} rev-parse HEAD) >/dev/null 2>&1
|
||||
local git_upstream=$(git --git-dir ${OMF_PATH}/.git --work-tree ${OMF_PATH} config remote.upstream.url)
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
echo "Oh My Fish revision id → ${git_rev}"
|
||||
|
|
|
@ -3,46 +3,46 @@ function omf.repo.pull
|
|||
echo (omf::err)"Argument of omf.repo.pull is the repo path."(omf::off)
|
||||
return $OMF_MISSING_ARG
|
||||
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
|
||||
else
|
||||
set repository origin
|
||||
end
|
||||
|
||||
set initial_branch (command git -C "$git_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_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 --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)
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
command git -C "$git_dir" checkout $initial_branch
|
||||
command git -C "$git_dir" reset --hard $initial_revision
|
||||
test "$stashed" = true; and command git -C "$git_dir" stash pop
|
||||
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" checkout $initial_branch
|
||||
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" reset --hard $initial_revision
|
||||
test "$stashed" = true; and command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" stash pop
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
return 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user