blob: 4f5ab297dfb36cf6c86c4a8aa624528c97c75a32 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env bash
set -euo pipefail
# @describe Keep your changes or incoming changes during merge/rebase conflicts
# @meta version 1.0.0
# @meta require-tools git
is_rebase() {
[ -d "$(git rev-parse --git-path rebase-merge 2>/dev/null)" ] || [ -d "$(git rev-parse --git-path rebase-apply 2>/dev/null)" ]
}
do_keep() {
local ours="$1" theirs="$2"
shift 2
if is_rebase; then
git checkout --"$theirs" "$@"
else
git checkout --"$ours" "$@"
fi
git add "$@"
}
# @cmd Keep your current branch changes for specified files
mine() {
do_keep "ours" "theirs" "${@:-.}"
}
# @cmd Keep incoming branch changes for specified files
incoming() {
do_keep "theirs" "ours" "${@:-.}"
}
eval "$(argc --argc-eval "$0" "$@")"
|