Commit graph

181 commits

Author SHA1 Message Date
Tim aa85792ec4
Add bash completions for forgit functions and aliases (#275)
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.
2023-01-30 17:46:52 +01:00
sandr01d f8c0edfc17
Added git stash push selector 'gsp' (#251)
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.
2022-12-14 15:53:52 +01:00
Markus Meier bfea8cf485
fix: compatibility check not working in bash (#258)
Fix: backwards compatibility check not working reliably in bash
2022-12-09 09:54:58 +01:00
carlfriedrich 372239fd37 Export user-defined FORGIT variables for backwards compatibility
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.
2022-11-17 10:19:32 +01:00
carlfriedrich 0820811862 Add variable for forgit binary 2022-11-14 17:53:00 +01:00
carlfriedrich b2d24138df zsh plugin: exit with an error if bin path cannot be determined 2022-11-14 17:53:00 +01:00
carlfriedrich 9471f292bb zsh plugin: use standardized $0 handling
See https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#zero-handling
2022-11-14 17:53:00 +01:00
carlfriedrich 4995c614e4 Move implementation to standalone forgit
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.
2022-11-14 17:52:58 +01:00
Tim 49579b2d1f
Do not return an error in log, diff and stash show (#236)
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.
2022-09-17 18:16:30 +02:00
Tim e0ca1f4045
Add ability to checkout existing branch with gcb (#234)
Port @cjappl 's changes of #232 / d4b4ce3 to zsh/bash.

gcb can now be called with an existing branch as an argument.
2022-09-13 07:38:32 -07:00
Wenxuan 2a96f287a9
Merge pull request #228 from carlfriedrich/interactively-select-branch-in-gcp
Interactively select branch in gcp
2022-09-13 10:32:18 +08:00
Wenxuan 85bc57a15c
Merge pull request #226 from carlfriedrich/support-stashes-in-gd
Support stashes in forgit::diff
2022-08-15 10:13:34 +08:00
Wenxuan e78562250f
Merge pull request #225 from carlfriedrich/add-forgit-enter-pager
Add variable FORGIT_ENTER_PAGER
2022-08-15 10:06:43 +08:00
ccoVeille f6040b21a0
fix typo in comments and README files (#230) 2022-08-09 19:07:59 -07:00
carlfriedrich b9c0e7b58f gcp: interactively select target branch
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.
2022-08-06 19:30:49 +02:00
carlfriedrich 1e080b0e72 Introduce variable "forgit_log_preview_options"
This reduces code duplication.
2022-08-03 18:08:55 +02:00
carlfriedrich c167918098 Support stashes in forgit::diff
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.
2022-08-03 09:24:25 +02:00
carlfriedrich 25e1a2e277 Add variable FORGIT_ENTER_PAGER
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.
2022-08-01 13:39:47 +02:00
zhangwenxuan.917 85ccdd3f80 fix: make linter happy 2022-07-28 16:29:49 +08:00
carlfriedrich 126772f08c Add function forgit::previous_commit 2022-07-28 10:16:22 +02:00
carlfriedrich d343300625 grb: rebase on parent of the selected commit
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.
2022-07-28 10:14:37 +02:00
carlfriedrich 7b1ebff09f Add variable "forgit_extract_sha"
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.
2022-07-26 09:21:42 +02:00
carlfriedrich 8d3ecb6ccf Add variables for diff context
Introduce FORGIT_DIFF_CONTEXT for the diff context when viewing a diff
and FORGIT_PREVIEW_CONTEXT for the diff context in the preview window.
2022-07-22 14:26:08 +02:00
carlfriedrich bb4514a359 Improve forgit::diff
* Show additional context on enter compared to preview
* Show selected diff range in fzf prompt
2022-07-17 16:42:11 +02:00
Tim fdd5632b17
Fix cherry pick preview (#218)
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.
2022-07-14 09:24:56 -07:00
carlfriedrich fe5c4d9881 Reverse order on cherry pick
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.
2022-07-13 12:33:55 +02:00
carlfriedrich 1b7db0fb6e Preserve +/- information on cherry pick
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.
2022-07-12 16:42:18 +02:00
carlfriedrich 52d79009d1 Preserve commit order on cherry pick
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.
2022-07-12 16:35:54 +02:00
carlfriedrich 53d0ea2f38 Add FORGIT_CHERRY_PICK_FZF_OPTS
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.
2022-07-12 16:35:54 +02:00
sandroid f8b1fc8545
Changed alias for forgit::blame to gbl 2022-06-16 22:34:13 +02:00
sandroid 2d3dd568bb
gb: handle untracked files 2022-06-03 23:24:40 +02:00
sandroid 958e26add5
Added gb 2022-06-02 23:22:41 +02:00
Wenxuan 6385f85360
fix: gd show empty preview when path has spaces in zsh/bash (#204) 2022-05-28 17:04:23 -07:00
Wenxuan Zhang 544cf86bc4
docs: update comment 2022-05-20 17:44:51 +08:00
Chris Apple 75e9d12bac
Adding support for git branch delete method (#200)
* 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>
2022-05-11 09:41:21 -07:00
Wenxuan 0c4a3069ba
Merge pull request #199 from max-ae/fix/gd-spaces
fix: `forgit::diff` not working if repo path contains spaces
2022-05-10 10:02:04 +08:00
Max Eisner 25bb8aee24 fix: forgit::diff not working if repo path contains spaces 2022-05-10 10:00:57 +08:00
Pablo M. Bermudo Garay 4dd2ca2271 Fix gcb sort
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.
2022-04-06 15:48:49 +02:00
Pablo M. Bermudo Garay d32e3c282b Fix gcb verbose output
Delete the verbose option of git checkout, so just the branch names are
displayed.
2022-04-06 15:47:06 +02:00
sandroid 6a9c0e3f82
Refactored grc 2022-04-01 23:41:00 +02:00
sandroid e4874bf763
Replaced eval in grc 2022-04-01 22:01:37 +02:00
sandroid 1f90f50d26
Fixed: grc fails when commit is preceded by anything else than '* ' 2022-03-27 19:18:32 +02:00
carlfriedrich 76663aaf19 Make fzf '--preview' argument overridable in environment
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
2022-03-21 10:04:12 +01:00
Wenxuan c9185dda1a
Merge pull request #190 from sandr01d/grc
Implemented git revert commit
2022-03-21 08:43:56 +08:00
Wenxuan fca195a925
Merge pull request #189 from carlfriedrich/improve-forgit-diff
Improve forgit diff
2022-03-21 08:29:04 +08:00
sandroid 45cab4df9b
Added grc 2022-03-19 20:11:58 +01:00
carlfriedrich 2e5f06e789 gd: improve visualization for move/rename
Show an arrow instead of just blank spaces when a file has been moved
or renamed:

[R100]  foo.txt  ->  bar.txt

The arrow is added as a replacement for the second tabspace of the "git
diff --name-status" command. For the preview command it is replaced by a
single space again.
2022-03-11 19:18:13 +01:00
carlfriedrich 5093c18532 gd: support git move/rename
For "git diff" to display a move/rename action correctly, it has to be
passed both the old and the new file name. Change the gd preview command
accordingly: instead of constructing a path out of the repo directory
and the file name (which would not work with multiple file names), cd to
the repo directory and use the file names as direct arguments to "git
diff" instead.

Change the regex used to parse the "git diff --name-status" output so
that it supports the "Rxxx" syntax for moved/renamed files.

Use tabs instead of hardcoded number of spaces along with "expand" to
have file names horizontally aligned.

Fixes wfxr/forgit#188
2022-03-11 18:37:30 +01:00
carlfriedrich 7d43115881 gd: support passing two revisions
Fixes wfxr/forgit#187
2022-03-10 11:35:54 +01:00
wallace 2aaa8fb6af Add missing support for FORGIT_GLO_FORMAT 2022-02-23 20:58:59 +02:00