git-repo-merge.sh: Combines patches of two git repositories with a new branch.
Warning, cannot access the index:
_darcs/index: opening of '_darcs/index' failed: permission denied (Permission denied)
diff -rN -u old-bii_scripts/Makefile new-bii_scripts/Makefile
--- old-bii_scripts/Makefile 2022-09-26 05:13:08.714170138 +0200
+++ new-bii_scripts/Makefile 2022-09-26 05:13:08.714170138 +0200
@@ -310,6 +310,7 @@
# scripts with no embedded documentation
# create online help by executing "(script.sh -h 2>&1; true)
PLAINTXT_H_SH_SCRIPT_LIST= \
+ git-repo-merge.sh \
repo-mirror.sh
# scripts with no embedded documentation
diff -rN -u old-bii_scripts/bin/git-repo-merge.sh new-bii_scripts/bin/git-repo-merge.sh
--- old-bii_scripts/bin/git-repo-merge.sh 1970-01-01 01:00:00.000000000 +0100
+++ new-bii_scripts/bin/git-repo-merge.sh 2022-09-26 05:13:08.714170138 +0200
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+SCRIPT_FULL_NAME=$(readlink -e $0)
+MYDIR=$(dirname $SCRIPT_FULL_NAME)
+MYNAME=$(basename $SCRIPT_FULL_NAME)
+
+if [ "$1" == "-h" -o "$1" == "--help" -o -z "$1" ]; then
+ echo "Usage: $MYNAME MYREPO OTHERREPO BRANCHNAME"
+ echo
+ echo "Puts all commits from OTHERREPO that are not part of MYREPO"
+ echo "into MYREPO at a new branch BRANCHNAME"
+ echo
+ echo "Note: MYREPO *must be* a working tree repository, not a bare repository."
+ exit 1
+fi
+
+MYREPO="$1"
+OTHERREPO="$2"
+BRANCHNAME="$3"
+if [ -z "$BRANCHNAME" ]; then
+ echo "error, too few parameters"
+fi
+
+if [ ! -d "$MYREPO" ]; then
+ echo "error, $MYREPO doesn't exist"
+fi
+if [ ! -d "$OTHERREPO" ]; then
+ echo "error, $OTHERREPO doesn't exist"
+fi
+
+OTHERREPO=$(readlink -e $OTHERREPO)
+
+# get the last common commit hash of the two repos:
+COMMIT=$(comm --nocheck-order -12 <(git -C "$MYREPO" log --reverse --pretty=format:"%H") <(git -C "$OTHERREPO" log --reverse --pretty=format:"%H") | tail -n 1)
+
+cd $MYREPO
+# go to last common commit:
+git checkout $COMMIT
+
+# add OTHERREPO under name "other":
+git remote add other $OTHERREPO
+
+# create branch BRANCHNAME:
+git checkout -b $BRANCHNAME
+
+# fetch all commits from OTHERREPO:
+git fetch other
+
+# now set branch BRANCHNAME to track branch "master" from OTHERREPO:
+git branch --set-upstream-to=other/master $BRANCHNAME
+
+# pull all commits to new branch BRANCHNAME:
+git pull
+
+# remove entry "other", this is no longer needed:
+git remote remove other
+
+# go back to "master":
+git checkout master
+
+# garbage collection:
+git gc
+
diff -rN -u old-bii_scripts/doc/txt/CONTENTS.rst new-bii_scripts/doc/txt/CONTENTS.rst
--- old-bii_scripts/doc/txt/CONTENTS.rst 2022-09-26 05:13:08.714170138 +0200
+++ new-bii_scripts/doc/txt/CONTENTS.rst 2022-09-26 05:13:08.714170138 +0200
@@ -323,6 +323,9 @@
**git-meld**
| compares all files of two git versions with meld.
+**git-repo-merge.sh**
+ | Combines patches of two git repositories by creating a new git branch.
+
**grab_xkeys.pl**
| a little X11 utility that displays scan codes of pressed keys.
patch c2cd974ad72585c0f440a8705f85070363b1a2cf
Author: Goetz.Pfeiffer@helmholtz-berlin.de
Date: Sat May 28 11:59:16 CEST 2022
* git-repo-merge.sh: Combines patches of two git repositories with a new branch