Introducing `show` as a new subcommand of `forgit`, an interactive
version of `git show`. The configured default alias is `gso`.
Alt-T can be used to toggle between showing the diff and the commit
message in the fzf preview window.
The new command in used instead of `forgit diff` when pressing enter
in `forgit log`. This fixes the display of diffs for merge commits.
**Note**: we have a requirement for the `fzf` version now. The minimum
required `fzf` version is 0.49.0. If the installed version is lower,
forgit will exit with an error message.
Fixes#416.
It seems somewhere along the line FORGIT_INSTALL_DIR stopped getting exported. According to the README you can append it to your path to get access to git forgit ... commands however this seems to no longer work - this is an attempt to restore this functionality.
When using forgit via the shell plugin, source 'git-forgit.bash'
explicitly after 'forgit.plugin.zsh' to enable tab completion for forgit
shell functions and aliases.
A message can be passed via named argument (-m or --message). All other
arguments (e.g. file paths) will cause git stash push to be run directly without
invoking fzf.
Before forgit became a standalone script, users defined their FORGIT
variables (e.g. FORGIT_FZF_DEFAULT_OPTS) in the shell environment before
sourcing the forgit shell plugin. This worked because the forgit code
was executed within the currently running shell.
With forgit being an executable script, these variables are only
available to forgit when being exported. This patch adds an automatism
for this so that users do not have to change their configuration.
A warning is issued in this case so that users get notified to update
their configuration.
Previously we had two different forgit implementations: one for zsh/bash
and one for fish. In this commit we move the bash implementation of the
forgit functions to the git-forgit script in order to have them in the
form of an executable script. This makes using forgit possible without
any shell plugin at all and furthermore removes the need to maintain a
separate implementation for the fish shell.
The simplest way of using forgit from now on is to put git-forgit
somewhere in your PATH and call it via "git forgit", without the need
for any other files.
We keep the shell plugins, though, and maintain backwards compatibility
by retaining the plugin functions as simple wrappers around the
git-forgit script, making the plugins mainly a collection of aliases
only.
fzf has the following exit codes:
0 Normal exit
1 No match
2 Error
130 Interrupted with CTRL-C or ESC
The forgit functions "log", "diff" and "stash show" are designed to
display information, not to perform any action. Hence the fzf exit code
130 should not be interpreted as an error, it is normal exit behavior.
Exclude this error value and return 0 in this case.
When we want to perform a cherry pick, we had to pass the target branch
as an argument to gcp. Forgit, however, aims to make git selections
interactive where possible. Hence it seems natural to select the target
branch interactively as well.
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.
The pager used on fzf enter key binding commands was hardcoded to
"LESS='-r' less". Transfer this to a variable in order to reduce code
duplication and make it configurable.
The git rebase command needs to be passed the parent commit of the one
you want to edit. When selecting a commit interactively via fzf, it
makes sense to automatically pass the parent commit of the selected one.
Within fzf it's otherwise quite hard to find the parent commit by hand
if you have found your commit via an fzf search string.
This reduces code duplication. We cannot implement this as a function,
because fish and zsh do not support exporting functions, but we need it
in subshells (see https://github.com/fish-shell/fish-shell/issues/6961).
Implement it as a variable in all shells instead.
The preview on cherry pick was accidentally broken since we included the
+/- information in the commit list. Fix this by using the correct string
index.
Git log displays the newest commits on top of the list, while git cherry
pick displays the newest commits at the bottom. Reverse the order of
git cherry pick so that it has the same order like git log.
The output of 'git cherry' which is used to build the fzf input list for
forgit::cherry::pick usually prefixes every line with a '-' for commits
that have an equivalent in the target branch, and a '+' for commits that
do not.
Previously forgit removed this information from the list. However, for
the actual cherry-picking process this information is relevant, so we
should keep it.
When using a fzf find string which maches multiple lines, the commits
could appear in a wrong order. Add "--tiebreak=index" to ensure that the
correct commit order is preserved.
The gcp (git cherry pick) command was the only command which did not
have a variable to set command-specific fzf options. Add the according
variable to source code and documentation.
* Adding support for git branch delete method in fish
* Add new doc to README
* Added options like gcb
* refactor: remove `--all` flag from gbd
* feat: sync forgit::branch::delete to bash and zsh
Co-authored-by: Wenxuan Zhang <wenxuangm@gmail.com>
Use LC_ALL=C to avoid potential ordering issues related to the user's
locale configuration. Additionally, add the --stable option to ensure
that just the range defined with --key is used.
Arguments to fzf are passed via the FZF_DEFAULT_OPTS environment
variable, which can be overridden by a dedicated FORGIT_<cmd>_FZF_OPTS
variable for each command separately. The '--preview' argument, however,
was excluded from this mechanism and hard-coded to the fzf call, so that
there was no chance overriding it.
This patch moves the passing of this argument to the FZF_DEFAULT_OPTS
variable for all commands, so that it can be overridden as well.
Fixes#185