|
# This function is a wrapper for the 'git' command, providing additional functionality for the 'clone' and 'add' operations. |
|
# |
|
|
|
# git <command> [<args>...] |
|
# |
|
|
|
# <command> - The git command to execute (e.g., clone, pull, push, add, etc.). |
|
# [<args>...] - The arguments to pass to the git command. |
|
# |
|
|
|
# - If the first argument is 'clone', the function executes 'git clone' with the '--recurse-submodules' option. |
|
# This ensures that all submodules are cloned along with the main repository. |
|
# - If the first argument is 'add', the function checks if the current directory is inside '~/datasets'. |
|
# If it is, it checks for the existence of a '.gitattributes' file and runs 'git lfs track "*.jxl"' before executing 'git add'. |
|
# - For any other git command, the function simply passes all arguments to the 'git' command as-is. |
|
# |
|
|
|
# git clone https://github.com/user/repo.git |
|
# This will execute 'git clone --recurse-submodules https://github.com/user/repo.git', cloning the repository along with its submodules. |
|
# |
|
|
|
# This will check if the current directory is inside '~/datasets', check for a '.gitattributes' file, and run 'git lfs track "*.jxl"' if the file exists, then execute 'git add .'. |
|
# |
|
|
|
# This will execute 'git pull origin main', pulling the latest changes from the 'main' branch. |
|
# |
|
|
|
# - This function uses 'command' to bypass any other shell functions or aliases named 'git', ensuring that the actual git command is executed. |
|
# - The use of "${@:2}" in the 'clone' case ensures that all arguments after 'clone' are passed to the 'git clone' command. |
|
# - The use of "${@:2}" in the 'add' case ensures that all arguments after 'add' are passed to the 'git add' command. |
|
# - The function checks if the current directory is inside '~/datasets' by comparing the current directory path with the '~/datasets' path. |
|
function git() { |
|
if [[ "$1" == "clone" ]]; then |
|
command git clone --recurse-submodules "${@:2}" |
|
elif [[ "$1" == "add" ]]; then |
|
if [[ "$(pwd)" == ~/datasets* ]]; then |
|
if [[ -f .gitattributes ]]; then |
|
command git lfs track "*.jxl" |
|
fi |
|
fi |
|
command git add "${@:2}" |
|
else |
|
command git "$@" |
|
fi |
|
} |
|
|
|
|