Skip to content

Commit 994b1a2

Browse files
committed
feat: add resolve cmd
1 parent 967e339 commit 994b1a2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

bin/git-resolve

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -eufo pipefail
3+
IFS=$' \t'
4+
5+
# try to manually resolve merge conflicts (if any)
6+
# in unmerged ("both modified" `status`) files;
7+
# works with any WD inside work-tree;
8+
9+
#shellcheck disable=SC2046
10+
# ignore files outside WD, to avoid overload
11+
git diff --name-only --diff-filter=U --relative -z |
12+
while IFS= read -r -d '' f; do
13+
if ! git diff --check -- "$f"; then
14+
printf '%s\0' "$f"
15+
fi
16+
done |
17+
xargs -0r $(git var GIT_EDITOR)
18+
19+
# user might have removed other conflict-markers,
20+
# so check full WT
21+
git diff --name-only --diff-filter=U -z |
22+
while IFS= read -r -d '' f; do
23+
# WARN: `f` is relative to repo root!
24+
# this might be broken
25+
if git diff --check -- "$f"; then
26+
git add -- "$f"
27+
fi
28+
done
29+
30+
git continue

0 commit comments

Comments
 (0)