mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Merge 3537c25fce into 4cf28ec559
This commit is contained in:
commit
83b100b940
11
Commands.md
11
Commands.md
|
|
@ -59,6 +59,7 @@
|
|||
- [`git rename-remote`](#git-rename-remote)
|
||||
- [`git repl`](#git-repl)
|
||||
- [`git reset-file`](#git-reset-file)
|
||||
- [`git resolve`](#git-resolve)
|
||||
- [`git root`](#git-root)
|
||||
- [`git rscp`](#git-scp)
|
||||
- [`git scp`](#git-scp)
|
||||
|
|
@ -1426,6 +1427,16 @@ or reset one file to certain commit
|
|||
$ git reset-file .htaccess dc82b19
|
||||
```
|
||||
|
||||
## git resolve
|
||||
|
||||
On default text-editor, open unmerged ("both modified" `status`) files in working-directory that have errors (e.g. conflict-markers),
|
||||
then auto-stage all (in full work-tree) unmerged files without errors,
|
||||
and finally [`continue`](#git-continue) (if possible).
|
||||
|
||||
```bash
|
||||
$ git resolve
|
||||
```
|
||||
|
||||
## git mr
|
||||
|
||||
Checks out a merge request from GitLab, or a pull request from Forgejo/Codeberg.
|
||||
|
|
|
|||
29
bin/git-resolve
Executable file
29
bin/git-resolve
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eufo pipefail
|
||||
IFS=$' \t'
|
||||
|
||||
#shellcheck disable=SC2046
|
||||
# ignore files outside WD, to avoid overload
|
||||
git diff --name-only --diff-filter=U --relative -z |
|
||||
while IFS= read -r -d '' f; do
|
||||
# `--quiet` implies `--exit-code` which is incompatible with `--check`;
|
||||
# however, it could be special-cased internally, so it could work
|
||||
# (untested)
|
||||
if ! git -c core.whitespace='' diff --check -- "$f" &>/dev/null; then
|
||||
printf '%s\0' "$f"
|
||||
fi
|
||||
done |
|
||||
# WARN: `-r` is too new
|
||||
# https://github.com/tj/git-extras/pull/1233#issuecomment-3957233996
|
||||
xargs -0r $(git var GIT_EDITOR)
|
||||
|
||||
# user might have removed other conflict-markers,
|
||||
# so check full WT
|
||||
git diff --name-only --diff-filter=U -z |
|
||||
while IFS= read -r -d '' f; do
|
||||
# WARN: `f` is relative to repo root!
|
||||
# this might be broken
|
||||
if git -c core.whitespace='' diff --check -- "$f"; then
|
||||
git add -- "$f"
|
||||
fi
|
||||
done
|
||||
Loading…
Reference in a new issue