-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpullup
More file actions
executable file
·62 lines (47 loc) · 1.82 KB
/
Copy pathpullup
File metadata and controls
executable file
·62 lines (47 loc) · 1.82 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# author: daniel rode
# created: 25 apr 2026
# updated: 16 jun 2026
REMOTE_ADDR=USER@PATCHED_REMOTE # Linux host's IP address and user name
REMOTE_NAME=GIT_REMOTE_NAME # Name of git remote according to local repo
set -e
set -x
REMOTE_ADDR="$(git remote get-url "$1" | sed -e 's,^ssh://,,' -e 's,:/..*$,,')"
REMOTE_NAME="$1"
# On remove, create temp branch with new changes, minus local-specific patches
ssh "$REMOTE_ADDR" bash <<'EOF'
git -C ~/code checkout b_patch
git -C ~/code branch tmp_new_sans_patch
git -C ~/code worktree add ../tmp_git_wt tmp_new_sans_patch
git -C ~/tmp_git_wt revert t_patch
EOF
# Fetch remote changes
cd ~/code
git fetch "$REMOTE_NAME"
# Screen fetch for potential shenanigans (ideally, this will output nothing)
{
# Scan git repo guts
grep -rP '\x1b' .git/ --exclude-dir=objects --exclude=index && exit 1
# Scan checked out branch file contents
# grep --exclude-dir=.git -rP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' && exit 1
# Scan (of branch to merge) commit messages and commit metadata
git log --format='%s%n%b%n%ae' "$REMOTE_NAME"/tmp_new_sans_patch \
| grep -P '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' && exit 1
# Scan (of branch to merge) filenames
git ls-tree -zr --name-only "$REMOTE_NAME"/b_patch \
| grep -P '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' && exit 1
# Scan (of branch to merge) file contents
git ls-tree -r "$REMOTE_NAME"/tmp_new_sans_patch | awk '{print $3}' \
| while read hash; do
git cat-file blob "$hash" \
| grep -P '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' && exit 1
done
} | /usr/bin/cat -v
# Merge changes from remote
git merge mesa/tmp_new_sans_patch --squash
git commit -m merge
# Clean-up
ssh "$REMOTE_ADDR" bash <<'EOF'
git -C ~/code worktree remove ../tmp_git_wt
git -C ~/code branch -D tmp_new_sans_patch
EOF