Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master guru-tools by Jaka Kranjc (afec348aa78f1f73864e1eb4352470a4d3abaa66)

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 guru-tools by Jaka Kranjc (afec348aa78f1f73864e1eb4352470a4d3abaa66)
  • Date: Thu, 22 Jan 2009 16:27:04 -0600

GIT changes to master guru-tools by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

smgl-cherry-pick | 117
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 117 insertions(+)

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

smgl-cherry-pick: fix for newer git naming/access

commit be25502c816a3adc36edeca18a4daa24231e6216
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

smgl-cherry-pick: make the (new) files executable, except HISTORY

commit cf1053747beff057785e301b254ec9904f42f3b6
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

(re)added smgl-cherry-pick

diff --git a/smgl-cherry-pick b/smgl-cherry-pick
new file mode 100755
index 0000000..629e120
--- /dev/null
+++ b/smgl-cherry-pick
@@ -0,0 +1,117 @@
+#!/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
+[[ -f ChangeLog ]] || { echo run me from the top dir; exit 99; }
+
+make_exec() {
+ [[ $1 == HISTORY ]] && return
+ chmod +x "$1"
+}
+
+# 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
+ file=$(sed -n '/^+++ / s,^[^/]*/,,p' $diff)
+ patch -p1 < $diff
+ new_rc=$?
+ make_exec "$file"
+ git add "$file"
+ [[ $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"
+ make_exec "$file"
+ git add "$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
+ make_exec "$file"
+ git add $file # needed when cherrypicking new spells
+ 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
+



  • [SM-Commit] GIT changes to master guru-tools by Jaka Kranjc (afec348aa78f1f73864e1eb4352470a4d3abaa66), Jaka Kranjc, 01/22/2009

Archive powered by MHonArc 2.6.24.

Top of Page