Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,38 @@ _Grep behaviour_: filter on added, updated or removed code (log content: `-G` op
- `<CR>` opens a diff for the current file with the selected commit
- `<C-o>` opens the selected commit in the browser

### 6. checkout_reflog
### 6. changed_on_branch

Opens a Telescope window with a list of changed files on the current branch (including staged files).
The fork point of the current branch is determined with the following command:

```sh
git show-branch | \
sed "s/].*//" | \
grep "*" | \
grep -v "$(git rev-parse --abbrev-ref HEAD)" | \
head -n1 | \
sed "s/^.*\\[//"
```

Note: this only works if there is already a commit on the current branch, otherwise the base branch can not be detected.

_Grep behaviour_: filter on filename.

#### _Keymaps_

- `<CR>` opens the selected file.
- `<C-e>` opens diff of the selected file with base branch.

### 7. checkout_reflog

Opens a Telescope window with all reflog entries

#### _Keymaps_

- `<CR>` checkout the reflog entry

### 7. show_custom_functions
### 8. show_custom_functions

A telescope picker for all functions above.

Expand Down
10 changes: 10 additions & 0 deletions lua/advanced_git_search/git_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ M.base_branch = function()
return output
end

M.current_branch = function()
local command = "git branch --show-current"
local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

output = string.gsub(output, "\n", "")
return output
end

M.determine_historic_file_name = determine_historic_file_name

return M
Loading