Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wfxr/forgit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1bd66bb9bb3c394247994b06de252259f943f5df
Choose a base ref
..
head repository: wfxr/forgit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 26c8ebb757de627b087b108c1ed140782ded149b
Choose a head ref
Showing with 76 additions and 83 deletions.
  1. +3 −5 .github/workflows/brew.yaml
  2. +1 −1 .github/workflows/ci.yaml
  3. +1 −1 .github/workflows/release.yaml
  4. +1 −1 .github/workflows/tag.yaml
  5. +8 −2 README.md
  6. +2 −2 bin/git-forgit
  7. +54 −33 completions/_git-forgit
  8. +0 −34 completions/git-forgit.zsh
  9. +6 −4 conf.d/forgit.plugin.fish
8 changes: 3 additions & 5 deletions .github/workflows/brew.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Homebrew

on:
workflow_run:
workflows:
- "Release"
types:
- completed
push:
tags:
- '*'

jobs:
brew:
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Runs a single command using the runners shell
- name: Install prerequisites
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

2 changes: 1 addition & 1 deletion .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# The COMMIT_KEY secret contains a private SSH key. The associated public key
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -355,8 +355,14 @@ export FORGIT_LOG_FZF_OPTS='

## Zsh

- Put [`completions/_git-forgit`](completions/_git-forgit) in a directory in your `$fpath` (e.g. `/usr/share/zsh/site-functions`) to have zsh tab completion for `git forgit` and configured git aliases.
- Source [`completions/git-forgit.zsh`](completions/git-forgit.zsh) to have zsh tab completion for forgit shell functions and aliases (e.g. `gcb <tab>` completes branches).
- Put [`completions/_git-forgit`](completions/_git-forgit) in a directory in your `$fpath` (e.g. `/usr/share/zsh/site-functions`) to have zsh tab completion for `git forgit` and configured git aliases, as well as shell command aliases, such as `forgit::add` and `ga`

If you're having issues after updating, and commands such as `forgit::add` or aliases `ga` aren't working, remove your completions cache and restart your shell.

```zsh
> rm ~/.zcompdump
> zsh
```

# 💡 Tips

4 changes: 2 additions & 2 deletions bin/git-forgit
Original file line number Diff line number Diff line change
@@ -137,10 +137,10 @@ _forgit_diff() {
# oldfile\0
# We have to do a two-step sed -> tr pipe because OSX's sed implementation does
# not support the null-character directly.
get_files="echo {} | sed 's/.*] *//' | sed 's/ -> /\\\n/' | tr '\\\n' '\\\0'"
get_files="echo {} | sed 's/\\\\s*\\\\[.]\\\\s*//' | sed 's/ -> /\\\n/' | tr '\\\n' '\\\0'"
# Similar to the line above, but only gets a single file from a single line
# Gets the new name of renamed files
get_file="echo {} | sed 's/.*] *//' | sed 's/.*-> //'"
get_file="echo {} | sed 's/\\\\s*\\\\[.]\\\\s*//' | sed 's/.*-> //'"
# Git stashes are named "stash@{x}", which contains the fzf placeholder "{x}".
# In order to support passing stashes as arguments to _forgit_diff, we have to
# prevent fzf from interpreting this substring by escaping the opening bracket.
87 changes: 54 additions & 33 deletions completions/_git-forgit
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#compdef git-forgit
#compdef git-forgit -p forgit::*
#description Utility tool for using git interactively
#
# forgit completions for zsh
#
# Place this file in your $fpath (e.g. /usr/share/zsh/site-functions) to enable
# tab completions for forgit as a git subcommmand. When using forgit as a shell
# plugin, additionally source completions/git-forgit.zsh after
# forgit.plugin.zsh to enable tab completion for shell functions and aliases.
# tab completions for forgit.

_git-branches() {
_alternative "branches:branchname:($(git branch -a --format '%(refname:short)'))"
@@ -38,21 +36,19 @@ _git-staged() {
}

_git-forgit() {
local subcommand cword cmd
local subcommand cmd
subcommand="${words[1]}"
if [[ "$subcommand" != "forgit" ]]; then
if [[ "$subcommand" != "forgit"* ]]; then
# Forgit is obviously called via a git alias. Get the original
# aliased subcommand and proceed as if it was the previous word.
cmd=$(git config --get "alias.$subcommand" | cut -d ' ' -f 2)
cword=$((CURRENT + 1))
else
cword=$CURRENT
cmd=${words[2]}
# The last word is the relevant command
cmd=${words[(( ${#words} - 1 ))]}
fi

case ${cword} in
1) ;;
2)

case ${cmd} in
forgit)
local -a subcommands
subcommands=(
'add:git add selector'
@@ -77,25 +73,50 @@ _git-forgit() {
)
_describe -t commands 'git forgit' subcommands
;;
*)
case ${cmd} in
add) _git-add ;;
branch_delete) _git-branches ;;
checkout_branch) _git-branches ;;
checkout_commit) __git_recent_commits ;;
checkout_file) _git-checkout-file ;;
checkout_tag) __git_tags ;;
cherry_pick) _git-cherry-pick ;;
cherry_pick_from_branch) _git-branches ;;
clean) _git-clean ;;
diff) _git-forgit-diff ;;
fixup) __git_branch_names ;;
log) _git-log ;;
rebase) _git-rebase ;;
reset_head) _git-staged ;;
revert_commit) __git_recent_commits ;;
stash_show) _git-stash-show ;;
esac
;;
add) _git-add ;;
branch_delete) _git-branches ;;
checkout_branch) _git-branches ;;
checkout_commit) __git_recent_commits ;;
checkout_file) _git-checkout-file ;;
checkout_tag) __git_tags ;;
cherry_pick) _git-cherry-pick ;;
cherry_pick_from_branch) _git-branches ;;
clean) _git-clean ;;
diff) _git-forgit-diff ;;
fixup) __git_branch_names ;;
log) _git-log ;;
rebase) _git-rebase ;;
reset_head) _git-staged ;;
revert_commit) __git_recent_commits ;;
stash_show) _git-stash-show ;;
esac
}

# We're reusing existing completion functions, so load those first
# if not already loaded and check if completion function exists afterwards.
(( $+functions[_git-add] )) || _git
(( $+functions[_git-add] )) || return 1
# Completions for forgit plugin shell functions (also works for aliases)
compdef _git-add forgit::add
compdef _git-branches forgit::branch::delete
compdef _git-branches forgit::checkout::branch
compdef __git_recent_commits forgit::checkout::commit
compdef _git-checkout-file forgit::checkout::file
compdef __git_tags forgit::checkout::tag
compdef _git-cherry-pick forgit::cherry::pick
compdef _git-branches forgit::cherry::pick::from::branch
compdef _git-clean forgit::clean
compdef _git-forgit-diff forgit::diff
compdef __git_branch_names forgit::fixup
compdef _git-log forgit::log
compdef _git-rebase forgit::rebase
compdef _git-staged forgit::reset::head
compdef __git_recent_commits forgit::revert::commit
compdef _git-stash-show forgit::stash::show

# this is the case of calling the command and pressing tab
# the very first time of a shell session, we have to manually
# call the dispatch function
if [[ $funcstack[1] == "_git-forgit" ]]; then
_git-forgit "$@"
fi
34 changes: 0 additions & 34 deletions completions/git-forgit.zsh

This file was deleted.

10 changes: 6 additions & 4 deletions conf.d/forgit.plugin.fish
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# MIT (c) Chris Apple

set INSTALL_DIR (dirname (dirname (status -f)))
set -x FORGIT_INSTALL_DIR "$INSTALL_DIR/conf.d"
if [ ! -e "$FORGIT_INSTALL_DIR/bin/git-forgit" ]
set -x FORGIT_INSTALL_DIR "$INSTALL_DIR/vendor_conf.d"
set -l install_dir (dirname (status dirname))
set -x FORGIT_INSTALL_DIR "$install_dir/conf.d"
set -x FORGIT "$FORGIT_INSTALL_DIR/bin/git-forgit"
if not test -e "$FORGIT"
set -x FORGIT_INSTALL_DIR "$install_dir/vendor_conf.d"
set -x FORGIT "$FORGIT_INSTALL_DIR/bin/git-forgit"
end

function forgit::warn