Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Jaka Kranjc (890891f2580f3cbe27c1950b3ad1add9bc5c01f0)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Jaka Kranjc (890891f2580f3cbe27c1950b3ad1add9bc5c01f0)
  • Date: Fri, 14 Mar 2008 15:06:09 -0500

GIT changes to master grimoire by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

smgl/guru-tools/DETAILS | 5 +
smgl/guru-tools/HISTORY | 3 +
smgl/guru-tools/INSTALL | 1
smgl/guru-tools/smgl-cherry-pick | 104
+++++++++++++++++++++++++++++++++++++++
4 files changed, 112 insertions(+), 1 deletion(-)

New commits:
commit 890891f2580f3cbe27c1950b3ad1add9bc5c01f0
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

guru-tools: 1.10 - added smgl-cherry-pick
(cherry picked from commit 9d03f6b5e250663879aee43098e761ac1a006271)

diff --git a/smgl/guru-tools/DETAILS b/smgl/guru-tools/DETAILS
index f95d16c..ca3e415 100755
--- a/smgl/guru-tools/DETAILS
+++ b/smgl/guru-tools/DETAILS
@@ -1,5 +1,5 @@
SPELL=guru-tools
- VERSION=1.9
+ VERSION=1.10
SOURCE=$SPELL-$VERSION.tar.bz2
SOURCE_DIRECTORY=$BUILD_DIRECTORY/${SPELL}-${VERSION}
SOURCE_URL[0]=http://download.sourcemage.org/distro/misc/$SOURCE
@@ -72,6 +72,9 @@ urlwatch - checks a list of urls for changes
inside html page.
receive notifications for changed urls by email...
See urlwatch --help for help. (by M.L.).

+smgl-cherry-pick - a wrapper around git-cherry-pick, which enables
+ good "merging" of HISTORY, ChangeLog and binary
files
+
If you have more to contribute, mail to maintainer.

EOF
diff --git a/smgl/guru-tools/HISTORY b/smgl/guru-tools/HISTORY
index 45eedfb..05653cc 100644
--- a/smgl/guru-tools/HISTORY
+++ b/smgl/guru-tools/HISTORY
@@ -1,3 +1,6 @@
+2008-03-14 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * DETAILS: updated spell to 1.10 - added smgl-cherry-pick
+
2007-04-12 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* DETAILS: updated spell to 1.9
fixed long description wrap, manually deleted the redundant
descriptions
diff --git a/smgl/guru-tools/INSTALL b/smgl/guru-tools/INSTALL
index c43a42e..2d68691 100755
--- a/smgl/guru-tools/INSTALL
+++ b/smgl/guru-tools/INSTALL
@@ -1,6 +1,7 @@
rm -rf $SOURCE_DIRECTORY/old.libraries || true
#prepare install likes to leave $SCRIPT_DIRECTORY/old.libraries around
#this breaks the cp line below
+cp $SPELL_DIRECTORY/smgl-cherry-pick SOURCE_DIRECTORY/ &&
chmod 755 $SOURCE_DIRECTORY/* &&
# omit the old.binaries dir
for file in $SOURCE_DIRECTORY/*; do
diff --git a/smgl/guru-tools/smgl-cherry-pick
b/smgl/guru-tools/smgl-cherry-pick
new file mode 100755
index 0000000..7a3d1a0
--- /dev/null
+++ b/smgl/guru-tools/smgl-cherry-pick
@@ -0,0 +1,104 @@
+#!/bin/bash
+#
+# This script is a wrapper around git-cherry-pick, which enables
+# good "merging" of HISTORY, ChangeLog and binary files.
+# Conflicts in those files are now rare, but the script has
+# room for improvement.
+rc=0
+commit=$1
+[[ -z $commit ]] && echo no commit specified && exit 100
+
+# check if commit diff does not contain a HISTORY/ChangeLog header
+# it also must contain diff changes (this enables merging of bins)
+if ! git show $commit | grep -q "^+++.*\(HISTORY\|ChangeLog\)" && git show
$commit | grep -q "^+++"; then
+ # just do it
+ git-cherry-pick $commit
+ exit 0
+else
+ git reset -q --hard # you need a clean checkout for gcp anyway
+ # split the diff into parts
+ git show $commit | csplit -s -n5 - '/^diff --git/' '{*}'
+
+ rm xx00000 # commit info
+ # extract history/cl or apply directly
+ for diff in xx*; do
+ if ! grep -q "+++.*\(HISTORY\|ChangeLog\)" $diff; then
+ if ! grep -q "^Binary file" $diff; then
+ patch -p1 < $diff
+ new_rc=$?
+ [[ $rc == 0 ]] && rc=$new_rc
+ else
+ file=$(sed -n '/^diff --git/ { s,^[^/]*/,,; s, .*$,,p} ' $diff)
+ if grep -q "^deleted file" $diff; then
+ git-rm "$file" ||
+ echo "Warning, nonexsitent file: $file"
+ else # new or updated file
+ git show $commit:"$file" > "$file"
+ fi
+ fi
+ echo
+ else
+ file=$(sed -n '/^+++ / s,^[^/]*/,,p' $diff)
+
+ # maybe we're lucky and it will apply cleanly
+ patch --dry-run -p1 -s < $diff &>/dev/null &&
+ patch -p1 < $diff &&
+ echo luckily patched $file &&
+ echo &&
+ continue
+
+ echo Handling diff $diff for $file specially
+ # does it have more than one chunk?
+ if [[ $(grep -c "@@.*@@" $diff) != 1 ]]; then
+ echo multiple history chunks - not supported
+ rm -f xx*
+ exit 111
+ fi
+
+ # check if it removes any lines
+ if grep -q "^- " $diff; then
+ echo this diff removes lines too - not supported
+ rm -f xx*
+ exit 112
+ fi
+
+ # numb the diff into what will be cat into the file
+ # we want only the lines with +
+ sed -i -e '/^+/!d' -e '/^+++/d' -e 's/^+//' $diff
+
+ # add a date header if it is missing (multiple changes in the same day)
+ # or remove it and readd it so it is in the right spot:
+ # changes in the same day with individual titles can result in diff
+ # picking up the old one as the new - the title would be on the last
line
+ #FIXME multiple titles per commit aren't supported: should delete only
the first title
+ sed -i '/^20/d' $diff
+ CDATE=$(git show $commit --pretty=format:%ai | sed -n '1 s/ .*$//p')
+ TITLE="$CDATE $(git show $commit | sed -n 's/^Author: //p')"
+ sed -i "1 s,^,$TITLE\n," $diff
+
+ # make sure the addition contains a blank last line
+ sed -i "$ s,^..*$,&\n," $diff
+
+ cat $diff $file > $file.new
+ mv $file.new $file
+ echo
+ fi
+ done
+fi
+if [[ $rc == 0 ]]; then
+ git show $commit --pretty=format:"%s%n%b%n(cherry-picked from commit %H)"
| sed '/^diff --git/,$ d' |
+ git commit -a -F -
+else
+cat << KUKU
+##########################################################################
+A chunk failed! Resolve the conflict manually and then commit the result.
+Use this:
+git show $commit \\
+ --pretty=format:"%s%n%b%n(cherry-picked from commit %H)" |
+sed '/^diff --git/,$ d' |
+git commit -a -F -
+KUKU
+fi
+rm -f xx*
+exit $rc
+




Archive powered by MHonArc 2.6.24.

Top of Page