Commit graph

34 commits

Author SHA1 Message Date
sandr01d 8547b554c8
Make gclean parameters consistent (#317) 2023-07-06 20:13:03 +02:00
Wenxuan c78c10a028
feat: add a keybind to open current file in editor (#313)
* feat: add a keybind to open current file in default editor

---------

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Co-authored-by: sandr01d <88739791+sandr01d@users.noreply.github.com>
2023-06-19 09:26:07 +08:00
sandr01d 665e3fd215
Allow passing parameters to branch_delete and stash_show (#312) 2023-05-31 22:08:57 +02:00
sandr01d 0bedb80c1f
Allow passing parameters to forgit::reset::head (#309) 2023-05-31 21:18:13 +02:00
Tom f73ae9754e
Allow configuration of checkout_branch branch cmd (#307) 2023-05-16 08:45:18 -07:00
Tim 5642a1a730
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
2023-05-08 09:51:13 -07:00
Tim f74aa93232
Fix grc / forgit revert_commit (#305)
This was accidentally broken since 450615d4 due to a wrong git call.
2023-05-07 11:53:19 +02:00
Tim 3f00348d5c
Add keybinding ctrl+y for copying stash ID in gss (#295) 2023-03-18 16:35:18 +01:00
Tim 2b0cf3c4af
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).
2023-03-18 16:34:24 +01:00
Tim 450615d48f
Fix git options (#296)
Adding options to a command in a quoted variable as introduced in #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).
2023-03-18 16:18:11 +01:00
Tim 2a2ee36d56
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.
2023-03-18 12:25:20 +01:00
Tim f32fd305dc
Fix broken cherry picking (#294)
With the changes of #261 and #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 #286 ("fatal: bad revision ''").
2023-03-18 12:19:39 +01:00
Tim 4b8234a9ff
Only show available cherry picks in preview (#293)
This is a follow-up to #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.
2023-03-18 12:10:26 +01:00
Tim 8012396587
Fix empty diff preview on renames (#282)
This had been fixed before in #189, but obviously the patch broke
support for whitespaces in file names. That was fixed in #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.
2023-02-28 22:57:51 +01:00
ZenLian 8502ae2cc5
fix: glo can not match files (#249)
Fixed "glo -- <files>" behavior to show specified files only instead of
showing all changed files.
2023-01-30 17:43:17 +01:00
sandr01d c098bf2fb1
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
2023-01-20 11:49:55 -08:00
Chris Apple 98637db1b0
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
2023-01-11 10:50:41 -08:00
Tim 548af731f0
Fix command list in help output (#274)
'rebase' and 'fixup' were accidentally displayed on the same line.
2023-01-11 10:22:53 +01:00
sandr01d 329523bd0d
Fixed: Untracked files with spaces in the path do not show a preview in 'ga' (#271) 2023-01-11 08:47:40 +01:00
Chris Apple ffda73bac3
Adding the ability to grh from a subdirectory (#262)
grh didn't work if you were in a subdirectory. See #254 for more details
2022-12-19 10:57:58 -08:00
Chris Apple 5a117b63cd
Ensure that grc and gcp always have the correct ordering, regardless of how they were input (#261) (#253)
Closes #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 (#253).
2022-12-16 06:50:28 -08:00
Changsheng Wu 8ca463b5c6
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`.
2022-12-15 09:34:11 +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
Chris Apple 62cc8abde1
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.
2022-12-13 16:42:07 -07:00
Tim 59dd63be77
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.
2022-12-02 08:33:07 +01:00
Tim 42c8e005fe
glo: use forgit::diff when entering a commit (#219)
When using glo (forgit log) we can press Enter to show the changeset of
the selected commit. The presentation, however, was rendered using the
basic git diff command. We have a much more user friendly diff command
gd (forgit diff) right in forgit, though. Use this instead.
2022-11-26 13:28:25 +01:00
carlfriedrich 785c3f9774 Display useful error message if no or wrong command given 2022-11-21 10:56:58 +01:00
carlfriedrich 26f0f5c1e1 Ensure that fzf preview commands are executed in bash
All preview commands are written in bash now. fzf, however, uses the
shell defined in $SHELL to run the preview commands. We have to force
this to bash within forgit in order to not get any errors on different
default shells.
2022-11-17 10:19:29 +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 089853173e
Do not "set -e" in standalone forgit (#238)
Setting the error option in bash bypasses error handling in the forgit
functions, because the script immediatley exits in case of an error.
Remove the option to make error handling possible.
Bash scripts automatically return the exit code of the last statement,
so standalone forgit will still return useful error codes.
2022-10-08 00:43:47 +02:00
Tim 25789d2198
Fix function call in standalone forgit (#239)
From the standalone forgit command we call the according forgit function
by replacing a '_' with '::'. Since we have more complex function names
like 'forgit::cherry:⛏️:from::branch' we have to replace ALL
instances of '_' instead of just the first one.
2022-10-04 12:47:23 +02:00
Jonathan Wren df36068105 add some comments for clarification 2021-10-17 23:36:16 -07:00
Jonathan Wren 8bcd87af38 change dash to underscore for bin/git-forgit
Using an underscore instead of a dash simplifies the workflow and
documentation by making the commands and environment variables that
forgit uses the same (i.e. `git forgit checkout_file` is the same
command referred to by `forgit_checkout_file`)
2021-10-17 23:33:00 -07:00
Jonathan Wren 896aaa44a4 add handling for standalone version of forgit (for use in git commands) 2021-10-17 22:56:32 -07:00