Releases: carlfriedrich/forgit
Releases · carlfriedrich/forgit
25.01.0
Changes since 24.12.0:
- chore: rename default branch (#410)
- fix: fix edit file key binding (alt-e) in diff and add (#415)
The key binding for editing a file in diff and add was not working
properly on recent versions of fzf. As its documentation suggests, we
should replace `execute-silent` with `execute` since we need to switch
to a new screen and handle both input and output.fzf switches to the alternate screen when executing a command.
However, if the command is expected to complete quickly, and you are
not interested in its output, you might want to use execute-silent
instead, which silently executes the command without the switching.
24.11.0
Changes since 23.11.0:
- Remove extraneous PATH export (#329)
- README tweak: decrease level of headers (#337)
- README: Add more explicit instructions for brew, fix headers for AUR, Fig (#339)
Added more explicit instructions, now that I know how our brew installation process works.
While I was there, I moved AUR and Fig to be subheaders of Installation - Add new workflow to update homebrew formula on release (#342)
- fix: keep the script compatible with Busybox applets (#345)
Use short flags for sort command
Remove -n flag for nl command. The numbers in the selection list won't be aligned anymore, but no information is lost.
The current arguments are only presented in GNU's coreutils. - fix: avoid polluting the global namespace (#347)
- feat(completions): add completion for fish (#344)
fish's builtin git completion automatically registers git-forgit completions as completions for forgit subcommand of git. Therefore this PR provides completions for both formats git-forgit and git forgit.
Simple subcommands get the completion list from __fish_git_* functions, while others requiring more than 1 __fish_git_* completion sources reuse the completion items from the corresponding git commands. - fix(fish): clean up variables (#350)
* use `status dirname` builtin to save 1 dirname call
* use builtin test function instead of [ command
* use local scoping for INSTALL_DIR variable (and make it lowercase to
indicate such change)
Ref: https://fishshell.com/docs/current/cmds/test.html -
Consolidate zsh completions in one file (#340)
Co-authored-by: sandr01d [email protected]
Moved the completion definitions for zsh that previously were in completions/git-forgit.zsh and had to be sourced manually on shell startup into completions/_git-forgit, where they are automatically handled by compinit on shell startup. Sourcing a file to get completions is no longer necessary for zsh users.
If you're having issues after updating, and completions for commands such as `forgit::add` or aliases like `ga` aren't working, remove your completions cache (~/.zcompdump) and restart your shell.
Simplified _git-forgit to allow it to be called from within the completion script on the first run of a session. - chore(gha): Update actions/checkout from v3 to v4 (#351)
Resolve deprecation warnings for GitHub actions, see https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/ - [Fix diff preview and edit for files with a ']' character in their name (wfxr#354)](07f7e43)
Our sed command for removing the short status (e.g. [M]) from gits
output to extract the file name with _forgit_diff matched until the
last ']' character in the line due to sed being greedy. This created
issues with file names that contain a ']' character.
To fix this, I made sure that only the short status is removed by sed,
independently of the file name. - Fix homebrew update action to run on tag push (#356)
- feat(fish): use abbr instead of alias (#348)
Switch from aliases to abbreviations, as I suggested in
feat(completions): add completion for fish wfxr#344 (comment)
string collect returns 1 on empty argument, so it's used here to avoid repeating if else end blocks. Another benefit is that the output of string collect is ensured to be a single string. From string --help:
string collect collects its input into a single output argument, without splitting the output when used in a command substitution. This is useful when trying to collect multiline output from another
command into a variable. Exit status: 0 if any output argument is non-empty, or 1 otherwise.
This PR is marked as breaking change, since abbr behaves differently from alias. It can only be used in the interactive command line (so putting exec glo into your scripts won't work). - Delete brew workflow (#360)
- Fix issue where diff preview was broken on mac (#365)
Closes wfxr#362 - Refactor: Parse environment variables into arrays
Forgit allows specifying git options in environment variables that are passed along to the individual git commands. We currently treat those as strings. This commit adds a _forgit_parse_array function and uses it to parse all such environment variables into arrays instead. This will allow us to get rid of deferred code, since we can pass the parsed arrays directly to the git commands and don't have to rely on eval. - Refactor: Replace deferred code used for fzf preview with functions
Removes the deferred code that is used for creating the fzf preview functions and replaces it with _forgit_*_preview functions instead. These functions are exposed as forgit commands so they can be invoked from the fzf subshell. We split the exposed commands into public_commands and private_commands. The only difference between them is that public_commands are mentioned in the help text.
This commit changes the flags variable in _forgit_blame from a string to an array. This is necessary to allow the flags to be passed to _forgit_blame_preview as individual arguments. - Refactor: Move git commands from deferred code into functions
We often used deferred code to encapsulate git commands and make them
reusable.
This change removes deferred code for git commands and replaces it with
functions instead.
Some of the deferred code was used with xargs, which executes it on a
subshell. To avoid having to expose the new git functions the same way
we do with the preview functions, the usage of xargs in these cases is
replaced with either a loop or a single command when possible. - Refactor: Replace _forgit_emojify deferred code variable with a function
We used to have a variable that was either undefined or contained a
piece of deferred code that piped input through emojify when present
on the system. To remove the deferred code here, this commit
replaces the _forgit_emojify variable with a function that either pipes
the input through emojify or through cat, depending on whether emojify
is present. - Refactor: Replace deferred git commands with regular git commands
We were using deferred code in git commands in some places without any
reason. Each of these deferred code snippets was only executed a
single time, so we can replace them with regular git commands.
This commit changes how we handle the FORGIT_LOG_GRAPH_ENABLE
environment variable. We previously used a variable that stored the
--graph flag as a string and unset it, when FORGIT_LOG_GRAPH_ENABLE
was set to anything other than true. We now create an empty array and
add the --graph flag to it when FORGIT_LOG_GRAPH_ENABLE is unset or true.
Doing it this way allows us to build a command line without having to use
eval. The outcome is the same as before. - Refactor: Replace deferred code in enter commands with functions
In _forgit_log and _forgit_enter it is possible to diff a single
commit/file by pressing enter. We used to store the code that executes
the diffs in variables and passed it to fzf as deferred code. This
refactor reduces the amount of deferred code by using functions instead
of variables. - Refactor: Replace deferred code in edit commands with functions
_forgit_diff and _forgit_add allow editing the currently previewed file
in the EDITOR. This used to be handled entirely using deferred code.
This commit replaces the deferred code and binds the commands to functions
instead. - Refactor: Replace deferred code in yank commands with functions
Many commands allow copying the commit hash or stash name of the current
selection to the clipboard. We previously used deferred code to do so.
This commit replaces the deferred code and binds these commands to
functions instead. - [Refactor: Replace _forgit_extract_sha variable with function](htt...
23.11.0
Changes since 23.09.0:
- checkout_branch: support "-" argument (#322)
git natively supports `-` as an argument to `git switch` and `git
checkout`. It is shorthand for `@{-1}`, which is a way to refer to the
last branch you were on.
forgit used to interpret `-` as a branch name, detect that it does not
exist yet and create a new one with this name, which does not work.
Add a check whether `-` is passed on the command line and do not create
a new branch in this case - Fixed opening files in the editor when a path contains spaces or a file was renamed (#323)
Fixed two issues that occurred when trying to open files in the editor (ctrl+e). In both cases the wrong files were opened.- Files that have spaces in their path. I fixed this by properly escaping the variables used in _forgit_diff() and forgit_add().
- When a tracked file was renamed and added, trying to open it in the editor from the diff view, would open a file with a name that consists of both, the old and the new name. I added a separate sed command that can handle this special case.
23.09.0
Changes since 23.07.0:
- Added completions for zsh (#310)
-
feat: add a keybind to open current file in editor (#313)
Co-authored-by: sandr01d [email protected]
* feat: add a keybind to open current file in default editor - Add AUR release action (#315)
- Make gclean parameters consistent (#317)
- docs: example of using config vars to sort git branch (#319)
- Do not hide error messages when trying to return early (#318)
Most of forgits functions allow to invoke git directly when arguments were passed. In most of these functions we only return early when the git command that is executed returns successfully. This hides error messages from the user. As discussed with @carlfriedrich in wfxr#316, I've modified this behavior to also return early when the git command was not successful, so we're transparent about gits error messages and return values. This also fixes an infinite loop printing an error message when invalid arguments were passed to gsp. Because gbl and gclean allow passing arguments to the git command that is invoked when we don't return early, I've modified their behavior to only invoke git directly (and return early) in the case that non flag arguments were passed.
I've also modified gclean to use the -q flag instead of piping it's output to /dev/null. - Removed the note about using forgit as a git subcommand from the 'tips' section (#321)
The note was redundant because it is explained in more detail in the 'git integration' section. - Trigger AUR action on workflow_run instead of release (#320)
Turns out that GitHub actions do not trigger other actions by default. Using workflow_run instead of release as a trigger should solve this.
23.07.0
Changes since 23.06.0:
- Use correct IFS store/restore mechanism (#306)
The previous implementation had the problem that if IFS was not set
before, it was set to an empty string after restoring, which is not the
same as being unset. This broke grc / git forgit revert_commit, since
"git revert" was being interpreted as the command name instead of
command and argument.
The correct way is to check whether IFS is unset and, if so, unset it
again afterwards.
See for reference:
https://unix.stackexchange.com/a/264947/317320 - Allow configuration of checkout_branch branch cmd (#307)
- Restore support for appending FORGIT_INSTALL_DIR to path (#308)
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. - Allow passing parameters to forgit::reset::head (#309)
- Allow passing parameters to branch_delete and stash_show (#312)
23.06.0
Changes since 23.05.0:
- Fix wrong documentation of tab toggle direction (#299)
See junegunn/fzf#3256 for reference.
Fixes wfxr#298 - README: add
brew
instructions (#302) - Fix grc / forgit revert_commit (#305)
This was accidentally broken since 450615d due to a wrong git call.
23.05.0
Changes since 23.02.0:
- fix: glo can not match files (#249)
Fixed "glo -- " behavior to show specified files only instead of
showing all changed files. - 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. - Fix empty diff preview on renames (#282)
This had been fixed before in wfxr#189, but obviously the patch broke
support for whitespaces in file names. That was fixed in wfxr#204, which
in turn broke support for renames again.
Prepare the list of file names with the null-character \0 as a delimiter,
so that we can use "xargs -0" to read it. This makes renames as well
as filenames with spaces work correctly. - Detect unexported variables in fish correctly (#290)
Fixes wfxr#289 - Only show available cherry picks in preview (#293)
This is a follow-up to wfxr#266, which already switched to showing only
available commits during cherry-picking. This patch does the same for
the branch preview in _forgit_cherry_pick_from_branch. - Fix broken cherry picking (#294)
With the changes of wfxr#261 and wfxr#266 we accidentally broke the return value
of `_forgit_cherry_pick`, which led to the loop in
`_forgit_cherry_pick_from_branch` being terminated in the wrong cases.
Fix this by moving all the post processing after fzf to a later call.
Also simplify the array population using a single line instead of a
loop.
This should also fix wfxr#286 ("fatal: bad revision ''"). - Add git options for each forgit command (#292)
The git behavior within forgit can now be customized with a dedicated
variable for each forgit command, e.g. `FORGIT_ADD_GIT_OPTS` is passed
to the `git add` call within `ga`.
Also renaming `FORGIT_STASH_PUSH_OPTS` to `FORGIT_STASH_PUSH_FZF_OPTS`
and `FORGIT_REVERT_COMMIT_OPTS` to `FORGIT_REVERT_COMMIT_FZF_OPTS`
for consistency. - Fix git options (#296)
Adding options to a command in a quoted variable as introduced in wfxr#292
causes problems in several cases unfortunately (e.g. git rebase
interpreting an empty string argument as a remote, which leads to an
error "unknown upstream ''").
Change the implementation in a way that each git command is stored in a
shell variable, including the options, which is then evaluated.
This also makes the code more DRY because each git options variable is
evaluated only once.
Furthermore, fix temporary IFS settings. When setting the IFS for a
certain command only, the command must not be an assignment, otherwise
both assignments are evaluated permanently
(see https://unix.stackexchange.com/a/458901/317320). - Fix temporary IFS settings (#297)
When setting the IFS for a certain command only, the command must not be
an assignment, otherwise both assignments are evaluated permanently
(see https://unix.stackexchange.com/a/458901/317320). - Add keybinding ctrl+y for copying stash ID in gss (#295)
23.02.0
Changes since 23.01.0:
- Provide an input branch with gcp again (#252)
Noticed there was a change recently that broke the ability to pass in an input branch to gcp.
This change is the following:
Fix faulty logic that just led to a git checkout -b being called when you pass in an argument to gcp
If an argument was passed in, check if it is a valid branch, if so, set the input_branch var
If input_branch is set, use it to do the cherry pick, as opposed to the first FZF selection. - 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. - Do not hardcode $SHELL path for bash (#260)
Some systems do not have /bin/bash. e.g., Alpine and NixOS. This change reads
the path dynamically via `which`. It solves the error `fork/exec /bin/bash`. - Ensure that
grc
andgcp
always have the correct ordering, regardless of how they were input (#261) (#253)
Closes wfxr#253. Essentially the idea is this:
When cherry picking a group of commits, most of the time you want to cherry pick oldest to newest. This means you have the lowest chance of having a conflict or error
when reverting a commit. You most often want to revert from newest to oldest. Similarly prevents errors
This commit does that, based on the wonderful suggestion on how to do that from @carlfriedrich in the linked ticket (wfxr#253). - Adding the ability to grh from a subdirectory (#262)
grh didn't work if you were in a subdirectory. See wfxr#254 for more details - Fish: assume forgit in vendor_conf.d in case it can not be found in conf.d (#272)
In the fish wrapper, assume forgit-git to be in vendor_conf.d/bin in case it can not be found in conf.d/bin. This fixes forgit not working with fish when located in /usr/share/fish/vendor_conf.d, as is the case with the forgit and forgit-git AUR packages. The location at conf.d is kept (and stays the default), so forgit does not break compatibility with fish plugin managers, such as fisher.
Closes wfxr#270 - Add alias gbl for forgit::blame in fish (#273)
Added the alias gbl for forgit::blame to the fish wrapper, so the behavior in fish is the same as in bash/zsh. I've also deleted an empty line where there were two in a row. - Fixed: Untracked files with spaces in the path do not show a preview in 'ga' (#271)
- Fix command list in help output (#274)
'rebase' and 'fixup' were accidentally displayed on the same line. - Add bash completions for git-forgit (#235)
When using forgit as a subcommand of git, put 'git-forgit.bash' in one
of the following places and it will be loaded automatically on tab
completion of 'git forgit' or any configured git aliases of it:- /usr/share/bash-completion/completions
- ~/.local/share/bash-completion/completions
- Only show available cherry picks (#266)
Only shows changes that are eligible for cherry-pick to the branch, not every commit. Also adds nice color to the output - Add alias gct for forgit::checkout::tag in fish (#278)
Noticed there was another alias missing for fish. This is the last one :) - Modify multiple files at once in ga & gcf (#279)
Checkout/Add files in a single command in _forgit_add and _forgit_checkout_file() instead of processing each file individually with xargs. This has the following benefits:
It's faster
Prevents git from spamming "Updated 1 path from the index" for each file when checking out files
23.01.0
Changes since 22.12.0:
- Adding a wraps to get fish to autopopulate branches (#255)
- Fix forgit diff displaying renames on MacOS (#250)
MacOS's 'sed' variant obviously does not parse '\t' as a tabstop per
default. Replacing it with a literal tabstop to make this work. - fix: compatibility check not working in bash (#258)
Fix: backwards compatibility check not working reliably in bash
22.10.0
Initial release