Skip to content

Commit cbb6f31

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

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

bin/git-resolve

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

0 commit comments

Comments
 (0)