From d3ebad99714ae3054ec18ac6b78dc3d66d34eb70 Mon Sep 17 00:00:00 2001 From: Rudxain <76864299+Rudxain@users.noreply.github.com> Date: Wed, 4 Mar 2026 00:48:05 -0400 Subject: [PATCH 1/3] feat: add `resolve` cmd --- Commands.md | 11 +++++++++++ bin/git-resolve | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 bin/git-resolve diff --git a/Commands.md b/Commands.md index 8aa08b1a..bc1f2b08 100644 --- a/Commands.md +++ b/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) @@ -1439,6 +1440,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. diff --git a/bin/git-resolve b/bin/git-resolve new file mode 100755 index 00000000..5ae251f3 --- /dev/null +++ b/bin/git-resolve @@ -0,0 +1,31 @@ +#!/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 + +git continue From 25e215e6a95d73304d444b62f0368239befc9f85 Mon Sep 17 00:00:00 2001 From: Rudxain <76864299+Rudxain@users.noreply.github.com> Date: Sun, 17 May 2026 12:34:10 -0400 Subject: [PATCH 2/3] fix(resolve): rm `git continue` --- bin/git-resolve | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/git-resolve b/bin/git-resolve index 5ae251f3..a3d15b37 100755 --- a/bin/git-resolve +++ b/bin/git-resolve @@ -27,5 +27,3 @@ git diff --name-only --diff-filter=U -z | git add -- "$f" fi done - -git continue From 0cc6a49ed87f6f0cc67ed859ec671d6cd53f3ee8 Mon Sep 17 00:00:00 2001 From: Rudxain <76864299+Rudxain@users.noreply.github.com> Date: Fri, 2 Oct 2026 19:43:10 -0400 Subject: [PATCH 3/3] fix(resolve): ensure EDITOR always detects TTY GNU Nano 9.1 assumes "Standard input is not a terminal" when invoked via `xargs` --- bin/git-resolve | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/bin/git-resolve b/bin/git-resolve index a3d15b37..b1dca6f9 100755 --- a/bin/git-resolve +++ b/bin/git-resolve @@ -2,20 +2,19 @@ set -eufo pipefail IFS=$' \t' -#shellcheck disable=SC2046 +f_list=() + +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 + f_list+=("$f") + fi # 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) +done < <(git diff --name-only --diff-filter=U --relative -z) + +$(git var GIT_EDITOR) "${f_list[@]}" # user might have removed other conflict-markers, # so check full WT