diff options
author | 2013-09-04 14:47:26 +0200 | |
---|---|---|
committer | 2013-09-04 14:47:26 +0200 | |
commit | 20fefd213dead9ec0d760b0473288d3ed5d34d4e (patch) | |
tree | 24dcb8e87a6fa5a15ab22b86975723e5addc8187 /files | |
parent | files/shlib/functions: add EX_GIT_* error codes (diff) | |
download | R_overlay-20fefd213dead9ec0d760b0473288d3ed5d34d4e.tar.gz R_overlay-20fefd213dead9ec0d760b0473288d3ed5d34d4e.tar.bz2 R_overlay-20fefd213dead9ec0d760b0473288d3ed5d34d4e.zip |
files/shlib/git: git_update_config()
Diffstat (limited to 'files')
-rw-r--r-- | files/shlib/git.sh | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/files/shlib/git.sh b/files/shlib/git.sh index e68b74e..3a143d3 100644 --- a/files/shlib/git.sh +++ b/files/shlib/git.sh @@ -8,7 +8,9 @@ # # --- functions provided by this file --- # -# int git_has_changes ( [*files] ), raises die() +# int git_has_changes ( [*files] ), raises die() +# void git_update_config ( config_key, [user_value], [fallback_value] ), +# raises die() # # # --- variables provided by this file --- @@ -74,4 +76,22 @@ git_has_changes() { return ${has_changes} } +# void git_update_config ( +# config_key, [user_value], [fallback_value] +# ), raises die() +# +# Sets config_key to user_value (if defined), else sets it to fallback_value +# if config_key's value is empty/does not exist. +# +# +git_update_config() { + if [ -n "${2-}" ]; then + autodie ${GIT} config "${1}" "${2}" + elif [ -z "${3-}" ] || ${GIT} config --get "${1}" | grep -q .; then + true + else + autodie ${GIT} config "${1}" "${3?}" + fi +} + fi # __HAVE_GIT_FUNCTIONS__ |