<commit_before># Version Control Aliases

alias add.="git add ."
alias add="rc_add"
alias addp.="git add --patch ."
alias addp="git add --patch"
alias addu.="git add --update ."
alias addu="git add --update"
alias adu="git add --update"
alias amend="git commit --amend"
alias ap.="git add --patch ."
alias ap="git add --patch"
alias apply="git_stash_apply"
alias au="git add --update"
alias br="rc_branch"
alias branch="rc_branch"
alias branches="rc_branches"
alias checkout="rc_checkout"
alias ci="rc_commit"
alias clone="git clone"
alias cm="rc_commit"
alias co="rc_checkout"
alias commit="rc_commit"
alias d.="git diff ."
alias dcommit="git svn dcommit"
alias default="rc_master"
alias delete_branch="git_delete_branch"
alias df="rc_diff"
alias dfl="git_diff_last"
alias difflast="git_diff_last"
alias difftool="git difftool"
alias drop="git_stash_drop"
alias fetch="git fetch"
alias fetch_tags="rc_fetch_tags"
alias filemode="git config core.filemode false"
alias g="git"
alias gco="grep_checkout"
alias gconf="git_config"
alias gitconfig="git_config"
alias gitignore="git_ignore"
alias gm="grep_merge"
alias list="git_stash_list"
alias log="rc_log"
alias master="rc_master"
alias merge="rc_merge"
alias pop="git stash pop"
alias pul="rc_pull"
alias pull="rc_pull"
alias pull_tags="rc_fetch_tags"
alias pus="rc_push"
alias push="rc_push"
alias shallow_clone="git clone --depth 1"
alias show="git_stash_show"
alias s.="rc_status ."
alias st="rc_status"
alias stash="git_stash"
alias tag="git tag"
alias tags="git tag --list | sort --reverse --version-sort | less -X -F"
alias unshallow="git fetch --unshallow"

git_config() {
    filename=$(cat <<EOF | python -
import os


dirs = os.getcwd().split(os.sep)
for i, _ in enumerate(dirs):
    paths = dirs[:len(dirs) - i]
    paths.append('.git')
    paths.append('config')
    filename = os.path.join(os.sep, *paths)
    try:
        open(filename, 'r')
    except IOError:
        pass
    else:
        print filename
        break
EOF
)
    if [[ -z "${filename}" ]]; then
        echo ".git/config not found"
    else
        v "${filename}"
    fi
}

git_delete_branch() {
    branch_name="$(branches | fzf)"
    branch_name="${branch_name#"${branch_name%%[![:space:]]*}"}"
    if [[ ! -z "${branch_name}" ]]; then
        git branch --delete -- "${branch_name}"
    fi
}

git_diff_last() {
    # Display diff of last commit, optionally with a path.
    clear

    if [[ -z "${1}" ]]; then
        # Display last diff of project when path is not specified.
        git log --max-count=1 --patch<commit_msg>Fix error when using python 3<commit_after># Version Control Aliases

alias add.="git add ."
alias add="rc_add"
alias addp.="git add --patch ."
alias addp="git add --patch"
alias addu.="git add --update ."
alias addu="git add --update"
alias adu="git add --update"
alias amend="git commit --amend"
alias ap.="git add --patch ."
alias ap="git add --patch"
alias apply="git_stash_apply"
alias au="git add --update"
alias br="rc_branch"
alias branch="rc_branch"
alias branches="rc_branches"
alias checkout="rc_checkout"
alias ci="rc_commit"
alias clone="git clone"
alias cm="rc_commit"
alias co="rc_checkout"
alias commit="rc_commit"
alias d.="git diff ."
alias dcommit="git svn dcommit"
alias default="rc_master"
alias delete_branch="git_delete_branch"
alias df="rc_diff"
alias dfl="git_diff_last"
alias difflast="git_diff_last"
alias difftool="git difftool"
alias drop="git_stash_drop"
alias fetch="git fetch"
alias fetch_tags="rc_fetch_tags"
alias filemode="git config core.filemode false"
alias g="git"
alias gco="grep_checkout"
alias gconf="git_config"
alias gitconfig="git_config"
alias gitignore="git_ignore"
alias gm="grep_merge"
alias list="git_stash_list"
alias log="rc_log"
alias master="rc_master"
alias merge="rc_merge"
alias pop="git stash pop"
alias pul="rc_pull"
alias pull="rc_pull"
alias pull_tags="rc_fetch_tags"
alias pus="rc_push"
alias push="rc_push"
alias shallow_clone="git clone --depth 1"
alias show="git_stash_show"
alias s.="rc_status ."
alias st="rc_status"
alias stash="git_stash"
alias tag="git tag"
alias tags="git tag --list | sort --reverse --version-sort | less -X -F"
alias unshallow="git fetch --unshallow"

git_config() {
    filename=$(cat <<EOF | python -
import os


dirs = os.getcwd().split(os.sep)
for i, _ in enumerate(dirs):
    paths = dirs[:len(dirs) - i]
    paths.append('.git')
    paths.append('config')
    filename = os.path.join(os.sep, *paths)
    try:
        open(filename, 'r')
    except IOError:
        pass
    else:
        print(filename)
        break
EOF
)
    if [[ -z "${filename}" ]]; then
        echo ".git/config not found"
    else
        v "${filename}"
    fi
}

git_delete_branch() {
    branch_name="$(branches | fzf)"
    branch_name="${branch_name#"${branch_name%%[![:space:]]*}"}"
    if [[ ! -z "${branch_name}" ]]; then
        git branch --delete -- "${branch_name}"
    fi
}

git_diff_last() {
    # Display diff of last commit, optionally with a path.
    clear

    if [[ -z "${1}" ]]; then
        # Display last diff of project when path is not specified.
        git log --max-count=1 --patch
{'fraction_non_alphanumeric': 0.147442131880957, 'fraction_numerical': 0.0013616028010114763, 'mean_word_length': 4.116417910447761, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '214111', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1759, 'n_words': 497}