1
0
Fork 0
mirror of synced 2024-12-24 15:03:21 -05:00
zimfw/modules/git/functions/git-submodule-remove
Eric Nielsen 0a7451999e [git] Review all functions but ones using git fsck
as there are multiple solutions to list the lost commits and stashes,
but I could not find reliable ones. See
https://stackoverflow.com/q/89332/2654518.
Well, the current `git-commit-lost` and `git-stash-dropped`
implementations don't accurately work at least on the repositories I'm
working with.

The `git-hub` functions where removed at dcc3265, but aliases and docs
remained. Remove these.

Remove line break from `_git_log_oneline_format`, so it really occupies
one line. And change date format in `glG` output from committer date
(`%cd`) to relative author date (`%ar`) to conform with other formats.

Refactor remaining functions. Most of the changes refer to using the
already existing git error messages and return codes, instead of having
code that creates that. (Error messages for 'not in a git repository'
where not even consistent among functions, and there's were I started
this...)
The most drastic changes can be seen in `git-root`, then in `git-dir`
and `git-stash-clear-interactive`.
2018-01-10 10:25:25 -05:00

21 lines
641 B
Bash

# vim:et sts=2 sw=2 ft=zsh
local git_dir
git_dir=$(git-dir) || return 1
if [[ ${PWD} != $(git-root) ]]; then
print "${0}: must be run from the root of the work tree" >&2
return 1
elif ! command git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then
print "${0}: submodule not found: ${1}" >&2
return 1
fi
command git config --file "${git_dir}/config" --remove-section "submodule.${1}" &>/dev/null
command git config --file .gitmodules --remove-section "submodule.${1}" &>/dev/null
command git add .gitmodules
command git rm --cached "${1}" &>/dev/null
rm -rf "${1}"
rm -rf "${git_dir}/modules/${1}"
return 0