adding mv_gitfile
This commit is contained in:
parent
2ce6e1769b
commit
22c24220e5
1 changed files with 35 additions and 0 deletions
35
shell/mv_gitfile.sh
Executable file
35
shell/mv_gitfile.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Given a file in a repo, create a series of git patches to import into
|
||||
# another repo
|
||||
#
|
||||
# $1 == name of file (no leading path -- will be checked ./<file>)
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
RSRC=$1
|
||||
PDIR=/tmp/gitmrg
|
||||
|
||||
if [ ! -d "${PDIR}" ]; then
|
||||
echo "Creating ${PDIR} ..."
|
||||
mkdir -p "${PDIR}"
|
||||
else
|
||||
echo "Cleaning ${PDIR} ..."
|
||||
rm -i "${PDIR}"/*
|
||||
fi
|
||||
|
||||
if [ ! -f "./${RSRC}" ]; then
|
||||
echo "Bad input - must be in the git directory and name the file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_INIT=$(git rev-list --parents HEAD "${RSRC}" | grep -E "^[a-f0-9]{40}$")
|
||||
git format-patch -1 -o "${PDIR}" --start-number 0 "${_INIT}" "${RSRC}"
|
||||
git format-patch -o "${PDIR}" --start-number 1 "${_INIT}"..HEAD "${RSRC}"
|
||||
|
||||
echo "Next steps:"
|
||||
echo " cd /destination/repo"
|
||||
echo " git am ${PDIR}/*.patch"
|
||||
echo " git push"
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue