git_status_shortcuts: don't clobber $IFS
This commit is contained in:
@@ -34,7 +34,7 @@ design() {
|
|||||||
local project=`basename $(pwd)`
|
local project=`basename $(pwd)`
|
||||||
local all_project_dirs="$design_base_dirs $design_av_dirs"
|
local all_project_dirs="$design_base_dirs $design_av_dirs"
|
||||||
# Ensure design dir contains all subdirectories
|
# Ensure design dir contains all subdirectories
|
||||||
IFS=$' \t\n'
|
local IFS=$' \t\n'
|
||||||
# Create root design dirs
|
# Create root design dirs
|
||||||
for dir in $design_ext_dirs; do mkdir -p "$root_design_dir/$dir"; done
|
for dir in $design_ext_dirs; do mkdir -p "$root_design_dir/$dir"; done
|
||||||
# Create project design dirs
|
# Create project design dirs
|
||||||
@@ -102,6 +102,5 @@ design() {
|
|||||||
printf "Invalid command.\n\n"
|
printf "Invalid command.\n\n"
|
||||||
design
|
design
|
||||||
fi
|
fi
|
||||||
unset IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,12 @@ EOF
|
|||||||
)"
|
)"
|
||||||
|
|
||||||
# Set numbered file shortcut in variable
|
# Set numbered file shortcut in variable
|
||||||
local e=1
|
local e=1 IFS=$'\n'
|
||||||
IFS=$'\n'
|
|
||||||
for branch in $($_git_cmd branch "$@" | sed "s/^[* ]\{2\}//"); do
|
for branch in $($_git_cmd branch "$@" | sed "s/^[* ]\{2\}//"); do
|
||||||
export $git_env_char$e="$branch"
|
export $git_env_char$e="$branch"
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
||||||
let e++
|
let e++
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_alias "$git_branch_alias" "_scmb_git_branch_shortcuts" ""
|
__git_alias "$git_branch_alias" "_scmb_git_branch_shortcuts" ""
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
git_status_shortcuts() {
|
git_status_shortcuts() {
|
||||||
zsh_compat # Ensure shwordsplit is on for zsh
|
zsh_compat # Ensure shwordsplit is on for zsh
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local git_status="$(git status --porcelain 2> /dev/null)"
|
local git_status="$(git status --porcelain 2> /dev/null)"
|
||||||
local i
|
local i
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ git_status_shortcuts() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
IFS=" "
|
local IFS=" "
|
||||||
grp_num=1
|
grp_num=1
|
||||||
for heading in 'Changes to be committed' 'Unmerged paths' 'Changes not staged for commit' 'Untracked files'; do
|
for heading in 'Changes to be committed' 'Unmerged paths' 'Changes not staged for commit' 'Untracked files'; do
|
||||||
# If no group specified as param, or specified group is current group
|
# If no group specified as param, or specified group is current group
|
||||||
@@ -114,7 +114,6 @@ git_status_shortcuts() {
|
|||||||
# so just use plain 'git status'
|
# so just use plain 'git status'
|
||||||
git status
|
git status
|
||||||
fi
|
fi
|
||||||
unset IFS
|
|
||||||
zsh_reset # Reset zsh environment to default
|
zsh_reset # Reset zsh environment to default
|
||||||
}
|
}
|
||||||
# Template function for 'git_status_shortcuts'.
|
# Template function for 'git_status_shortcuts'.
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
|
|
||||||
function git_index() {
|
function git_index() {
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
# Just change to $GIT_REPO_DIR if no params given.
|
# Just change to $GIT_REPO_DIR if no params given.
|
||||||
"cd" $GIT_REPO_DIR
|
"cd" $GIT_REPO_DIR
|
||||||
@@ -103,7 +103,7 @@ function git_index() {
|
|||||||
# --------------------
|
# --------------------
|
||||||
# Go to our base path
|
# Go to our base path
|
||||||
if [ -n "$base_path" ]; then
|
if [ -n "$base_path" ]; then
|
||||||
IFS=$' \t\n'
|
local IFS=$' \t\n'
|
||||||
# evaluate ~ if necessary
|
# evaluate ~ if necessary
|
||||||
if [[ "$base_path" == "~"* ]]; then
|
if [[ "$base_path" == "~"* ]]; then
|
||||||
base_path=$(eval echo ${base_path%%/*})/${base_path#*/}
|
base_path=$(eval echo ${base_path%%/*})/${base_path#*/}
|
||||||
@@ -116,7 +116,6 @@ function git_index() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
unset IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_git_index_dirs_without_home() {
|
_git_index_dirs_without_home() {
|
||||||
@@ -126,12 +125,11 @@ _git_index_dirs_without_home() {
|
|||||||
# Recursively searches for git repos in $GIT_REPO_DIR
|
# Recursively searches for git repos in $GIT_REPO_DIR
|
||||||
function _find_git_repos() {
|
function _find_git_repos() {
|
||||||
# Find all unarchived projects
|
# Find all unarchived projects
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for repo in $(find -L "$GIT_REPO_DIR" -maxdepth 5 -name ".git" -type d \! -wholename '*/archive/*'); do
|
for repo in $(find -L "$GIT_REPO_DIR" -maxdepth 5 -name ".git" -type d \! -wholename '*/archive/*'); do
|
||||||
echo ${repo%/.git} # Return project folder, with trailing ':'
|
echo ${repo%/.git} # Return project folder, with trailing ':'
|
||||||
_find_git_submodules $repo # Detect any submodules
|
_find_git_submodules $repo # Detect any submodules
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# List all submodules for a git repo, if any.
|
# List all submodules for a git repo, if any.
|
||||||
@@ -146,11 +144,10 @@ function _find_git_submodules() {
|
|||||||
function _rebuild_git_index() {
|
function _rebuild_git_index() {
|
||||||
if [ "$1" != "--silent" ]; then echo -e "== Scanning $GIT_REPO_DIR for git repos & submodules..."; fi
|
if [ "$1" != "--silent" ]; then echo -e "== Scanning $GIT_REPO_DIR for git repos & submodules..."; fi
|
||||||
# Get repos from src dir and custom dirs, then sort by basename
|
# Get repos from src dir and custom dirs, then sort by basename
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do
|
for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do
|
||||||
echo $(basename $repo | sed "s/ /_/g"):$repo
|
echo $(basename $repo | sed "s/ /_/g"):$repo
|
||||||
done | sort -t ":" -k1,1 | cut -d ":" -f2- >| "$GIT_REPO_DIR/.git_index"
|
done | sort -t ":" -k1,1 | cut -d ":" -f2- >| "$GIT_REPO_DIR/.git_index"
|
||||||
unset IFS
|
|
||||||
|
|
||||||
if [ "$1" != "--silent" ]; then
|
if [ "$1" != "--silent" ]; then
|
||||||
echo -e "===== Indexed $_bld_col$(_git_index_count)$_txt_col repos in $GIT_REPO_DIR/.git_index"
|
echo -e "===== Indexed $_bld_col$(_git_index_count)$_txt_col repos in $GIT_REPO_DIR/.git_index"
|
||||||
@@ -207,7 +204,7 @@ _git_index_update_all_branches() {
|
|||||||
|
|
||||||
local remotes merges branches
|
local remotes merges branches
|
||||||
# Get branch configuration from .git/config
|
# Get branch configuration from .git/config
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for branch in $($GIT_BINARY branch 2> /dev/null | sed -e 's/.\{2\}\(.*\)/\1/'); do
|
for branch in $($GIT_BINARY branch 2> /dev/null | sed -e 's/.\{2\}\(.*\)/\1/'); do
|
||||||
# Skip '(no branch)'
|
# Skip '(no branch)'
|
||||||
if [[ "$branch" = "(no branch)" ]]; then continue; fi
|
if [[ "$branch" = "(no branch)" ]]; then continue; fi
|
||||||
@@ -225,7 +222,6 @@ _git_index_update_all_branches() {
|
|||||||
echo "=== Skipping $branch: remote and merge refs are not configured."
|
echo "=== Skipping $branch: remote and merge refs are not configured."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
|
|
||||||
# Update all remotes if there are any branches to update
|
# Update all remotes if there are any branches to update
|
||||||
if [ -n "${branches[*]}" ]; then git fetch --all 2> /dev/null; fi
|
if [ -n "${branches[*]}" ]; then git fetch --all 2> /dev/null; fi
|
||||||
@@ -268,7 +264,7 @@ function _git_index_batch_cmd() {
|
|||||||
cwd="$PWD"
|
cwd="$PWD"
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n"
|
echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n"
|
||||||
unset IFS
|
local IFS=$'\n'
|
||||||
local base_path
|
local base_path
|
||||||
for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | \grep . | sort); do
|
for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | \grep . | sort); do
|
||||||
builtin cd "$base_path"
|
builtin cd "$base_path"
|
||||||
@@ -285,8 +281,7 @@ if [ $shell = 'bash' ]; then
|
|||||||
# Bash tab completion function for git_index()
|
# Bash tab completion function for git_index()
|
||||||
function _git_index_tab_completion() {
|
function _git_index_tab_completion() {
|
||||||
_check_git_index
|
_check_git_index
|
||||||
local curw
|
local curw IFS=$'\n'
|
||||||
IFS=$'\n'
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
curw=${COMP_WORDS[COMP_CWORD]}
|
curw=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
@@ -313,10 +308,9 @@ if [ $shell = 'bash' ]; then
|
|||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W '$(sed -e "s:.*/::" -e "s:$:/:" "$GIT_REPO_DIR/.git_index" | sort)' -- $curw))
|
COMPREPLY=($(compgen -W '$(sed -e "s:.*/::" -e "s:$:/:" "$GIT_REPO_DIR/.git_index" | sort)' -- $curw))
|
||||||
fi
|
fi
|
||||||
unset IFS
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
else
|
else # Zsh tab completion function for git_index()
|
||||||
function _git_index_tab_completion() {
|
function _git_index_tab_completion() {
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
local state state_descr context line
|
local state state_descr context line
|
||||||
|
|||||||
@@ -125,11 +125,10 @@ if [ "$shell_ls_aliases_enabled" = "true" ] && which ruby > /dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Parse path from args
|
# Parse path from args
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ -d "$arg" ]; then local rel_path="${arg%/}"; fi
|
if [ -d "$arg" ]; then local rel_path="${arg%/}"; fi
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
|
|
||||||
# Replace user/group with user symbol, if defined at ~/.user_sym
|
# Replace user/group with user symbol, if defined at ~/.user_sym
|
||||||
# Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh
|
# Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh
|
||||||
@@ -175,14 +174,13 @@ EOF
|
|||||||
ll_files="$(\ls "$@")"
|
ll_files="$(\ls "$@")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for file in $ll_files; do
|
for file in $ll_files; do
|
||||||
if [ -n "$rel_path" ]; then file="$rel_path/$file"; fi
|
if [ -n "$rel_path" ]; then file="$rel_path/$file"; fi
|
||||||
export $git_env_char$e="$(eval $_abs_path_command \"${file//\"/\\\"}\")"
|
export $git_env_char$e="$(eval $_abs_path_command \"${file//\"/\\\"}\")"
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
||||||
let e++
|
let e++
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
|
|
||||||
# Turn off shwordsplit unless it was on previously
|
# Turn off shwordsplit unless it was on previously
|
||||||
if [[ $shell == "zsh" ]] && [ -z "$SHWORDSPLIT_ON" ]; then unsetopt shwordsplit; fi
|
if [[ $shell == "zsh" ]] && [ -z "$SHWORDSPLIT_ON" ]; then unsetopt shwordsplit; fi
|
||||||
|
|||||||
@@ -36,14 +36,13 @@ git_status_shortcuts() {
|
|||||||
files="$(echo "$cmd_output" | \grep '@@filelist@@::' | sed 's%@@filelist@@::%%g')"
|
files="$(echo "$cmd_output" | \grep '@@filelist@@::' | sed 's%@@filelist@@::%%g')"
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "filelist => $files"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "filelist => $files"; fi
|
||||||
# Export numbered env variables for each file
|
# Export numbered env variables for each file
|
||||||
IFS="|"
|
local IFS="|"
|
||||||
local e=1
|
local e=1
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
export $git_env_char$e="$file"
|
export $git_env_char$e="$file"
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
||||||
let e++
|
let e++
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
|
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "------------------------"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "------------------------"; fi
|
||||||
# Print status
|
# Print status
|
||||||
|
|||||||
@@ -68,13 +68,12 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Setup some custom repos outside the main repo dir
|
# Setup some custom repos outside the main repo dir
|
||||||
IFS=":"
|
local IFS=":"
|
||||||
for dir in $GIT_REPOS; do
|
for dir in $GIT_REPOS; do
|
||||||
mkdir -p $dir
|
mkdir -p $dir
|
||||||
cd $dir
|
cd $dir
|
||||||
git init
|
git init
|
||||||
done
|
done
|
||||||
unset IFS
|
|
||||||
|
|
||||||
verboseGitCommands
|
verboseGitCommands
|
||||||
|
|
||||||
@@ -83,9 +82,8 @@ EOF
|
|||||||
|
|
||||||
oneTimeTearDown() {
|
oneTimeTearDown() {
|
||||||
rm -rf "${GIT_REPO_DIR}"
|
rm -rf "${GIT_REPO_DIR}"
|
||||||
IFS=":"
|
local IFS=":"
|
||||||
for dir in $GIT_REPOS; do rm -rf $dir; done
|
for dir in $GIT_REPOS; do rm -rf $dir; done
|
||||||
unset IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureIndex() {
|
ensureIndex() {
|
||||||
|
|||||||
Reference in New Issue
Block a user