Added an alias for 'git add -p'
This commit is contained in:
@@ -29,6 +29,7 @@ git_alias="g"
|
|||||||
# 1. 'SCM Breeze' functions
|
# 1. 'SCM Breeze' functions
|
||||||
git_status_shortcuts_alias="gs"
|
git_status_shortcuts_alias="gs"
|
||||||
git_add_shortcuts_alias="ga"
|
git_add_shortcuts_alias="ga"
|
||||||
|
git_add_patch_shortcuts_alias="gap"
|
||||||
git_show_files_alias="gsf"
|
git_show_files_alias="gsf"
|
||||||
exec_git_expand_args_alias="ge"
|
exec_git_expand_args_alias="ge"
|
||||||
# 2. Commands that handle paths (with shortcut args expanded)
|
# 2. Commands that handle paths (with shortcut args expanded)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ _alias $git_alias='git'
|
|||||||
# SCM Breeze functions
|
# SCM Breeze functions
|
||||||
_alias $git_status_shortcuts_alias="git_status_shortcuts"
|
_alias $git_status_shortcuts_alias="git_status_shortcuts"
|
||||||
_alias $git_add_shortcuts_alias="git_add_shortcuts"
|
_alias $git_add_shortcuts_alias="git_add_shortcuts"
|
||||||
|
_alias $git_add_patch_shortcuts_alias="git_add_patch_shortcuts"
|
||||||
_alias $exec_git_expand_args_alias="exec_git_expand_args"
|
_alias $exec_git_expand_args_alias="exec_git_expand_args"
|
||||||
_alias $git_show_files_alias="git_show_affected_files"
|
_alias $git_show_files_alias="git_show_affected_files"
|
||||||
_alias $git_commit_all_alias='git_commit_all'
|
_alias $git_commit_all_alias='git_commit_all'
|
||||||
|
|||||||
@@ -89,6 +89,33 @@ git_silent_add_shortcuts() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 'git add -p' wrapper
|
||||||
|
# This shortcut means 'stage my selection of patchs for the file'
|
||||||
|
# Should be used in conjunction with the git_status_shortcuts() function for 'git status'.
|
||||||
|
# -------------------------------------------------------------------------------
|
||||||
|
git_add_patch_shortcuts() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: gap <file> => git add -p <file>"
|
||||||
|
echo " gap 1 => git add -p \$e1"
|
||||||
|
echo " gap 2..4 => git add -p \$e2 \$e3 \$e4"
|
||||||
|
echo " gap 2 5..7 => git add -p \$e2 \$e5 \$e6 \$e7"
|
||||||
|
else
|
||||||
|
git_silent_add_patch_shortcuts "$@"
|
||||||
|
# Makes sense to run 'git status' after this command.
|
||||||
|
git_status_shortcuts
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# Does nothing if no args are given.
|
||||||
|
git_silent_add_patch_shortcuts() {
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
# Expand args and process resulting set of files.
|
||||||
|
for file in $(git_expand_args "$@"); do
|
||||||
|
git add -p $file
|
||||||
|
echo -e "# add '$file'"
|
||||||
|
done
|
||||||
|
echo "#"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Prints a list of all files affected by a given SHA1,
|
# Prints a list of all files affected by a given SHA1,
|
||||||
# and exports numbered environment variables for each file.
|
# and exports numbered environment variables for each file.
|
||||||
|
|||||||
Reference in New Issue
Block a user