]> de.git.xonotic.org Git - xonotic/xonotic.git/commitdiff
Merge branch 'master' of ssh://git.xonotic.org/xonotic
authorRudolf Polzer <divVerent@alientrap.org>
Fri, 20 Aug 2010 12:23:07 +0000 (14:23 +0200)
committerRudolf Polzer <divVerent@alientrap.org>
Fri, 20 Aug 2010 12:23:07 +0000 (14:23 +0200)
all
misc/tools/cached-converter.sh
misc/tools/git-pk3-import [new file with mode: 0755]
misc/tools/git-pk3-merge [new file with mode: 0755]
misc/tools/normalmap.sh [new file with mode: 0755]

diff --git a/all b/all
index a24b92af4c19e22c96559d568f4081cf0c10bd9f..3e120e5b86d489f26a2d9a6c31836ab091141c5d 100755 (executable)
--- a/all
+++ b/all
@@ -792,7 +792,7 @@ case "$cmd" in
                                        elif yesno "Branch \"$ref\" may want to get merged. Do it?" '{ echo "$logdata"; echo "$diffdata"; } | less -r'; then
                                                git checkout "$realbase"
                                                org=`git rev-parse HEAD`
-                                               if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1   ' >/dev/null; }; then
+                                               if ! git merge --no-ff "$ref" 2>&1 | tee "$t" && ! { git ls-files -u | grep ' 1 ' >/dev/null; }; then
                                                        git reset --hard "$org"
                                                        GIT_NOTES_REF=refs/notes/admin-merge git notes edit -m "Merge failed:$LF`cat "$t"`" "$ref"
                                                        reportdo4 cat "$t"
index d6fd4424230037993a8e0dea1db41fd6747f806d..72f427c71d89bf150ac23dd4a4a40ba36431c74f 100755 (executable)
@@ -177,6 +177,7 @@ for F in "$@"; do
        will_jpeg=$do_jpeg
        will_dds=$do_dds
        case "$f" in
+               *_bump) will_dds=false ;;
                ./models/player/*) will_dds=false ;;
                ./textures/*) ;;
                ./models/*) ;;
diff --git a/misc/tools/git-pk3-import b/misc/tools/git-pk3-import
new file mode 100755 (executable)
index 0000000..ee081d4
--- /dev/null
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+# git-pk3-import: Import a PK3 into a branch of a bare Git repo.
+
+set -x
+
+# Helpers
+
+die()
+{
+    echo "$(basename "$0"): error: $*" >&2
+    exit 1
+}
+
+usage()
+{
+    cat <<EOF
+Usage:
+
+  # mandatory
+  export GIT_DIR=/path/to/xonotic-maps.pk3dir.git # absolute path
+  export GIT_WORK_TREE=/tmp/worktree # pk3 is extracted here
+  # optional
+  export GIT_AUTHOR_NAME="Some Guy"
+  export GIT_AUTHOR_EMAIL="someguy@example.com"
+
+  $(basename $0) nick branch map.pk3 [changes.txt]
+
+EOF
+}
+
+# Check usage
+
+[ $# -ge 3 -a $# -le 4 ] || {
+    usage
+    die "wrong number of arguments"
+}
+
+[ -z "$GIT_DIR" ] && {
+    usage
+    die "GIT_DIR not set"
+}
+
+[ -z "$GIT_WORK_TREE" ] && {
+    usage
+    die "GIT_WORK_TREE not set"
+}
+
+[ -z "$(ls -A "$GIT_WORK_TREE")" ] ||
+die "GIT_WORK_TREE is not empty"
+
+nick="$1"
+branch=$(git check-ref-format --print "$nick/$2") ||
+die "malformed branch name '$nick/$2'"
+pk3path="$3"
+pk3name="$(basename "$pk3path")"
+changes="$4"
+
+# Set up commit info
+
+[ -z "$GIT_AUTHOR_NAME" ] && export GIT_AUTHOR_NAME="$nick"
+[ -z "$GIT_AUTHOR_EMAIL" ] && export GIT_AUTHOR_EMAIL="${nick}@example.com"
+
+message()
+{
+    echo -e "Import $pk3name\n" | cat - "$changes" 2> /dev/null
+}
+
+# Clean up on exit
+
+cleanup_index=
+cleanup_worktree=
+
+cleanup()
+{
+    [ "$cleanup_index" ] && rm -f "$GIT_INDEX_FILE"
+    [ "$cleanup_worktree" ] && find "$GIT_WORK_TREE" -mindepth 1 -delete
+}
+
+trap cleanup EXIT
+
+# Set up index file, makes testing easier
+[ -z "$GIT_INDEX_FILE" ] && {
+    export GIT_INDEX_FILE="$GIT_DIR/pk3-import-index"
+    cleanup_index=t
+}
+
+# Extract the PK3 (the -n suppresses prompting in an edge case)
+unzip -n -qq "$pk3path" -d "$GIT_WORK_TREE" ||
+die "couldn't extract PK3 contents"
+cleanup_worktree=t
+
+# Note the refs and the common ancestor
+master=refs/heads/master
+ref=refs/heads/$branch
+base=$(git merge-base $master $ref 2> /dev/null) ||
+base=$master
+
+# Figure out the parent commit
+parent=\
+$(git rev-parse --verify -q $ref || git rev-parse --verify -q $base) ||
+die "couldn't determine parent commit"
+
+# Read the tree at base into index
+git read-tree $base ||
+die "couldn't initialize index"
+
+# Reject any modified files, the mapper should create a branch instead
+[ -z "$(git diff-files --diff-filter=M)" ] ||
+die "found changes to files in master"
+
+# Force reading of .gitignore files from cache, not the work tree
+git ls-files --cached -z |
+grep -z '\.gitignore$' |
+git update-index --skip-worktree -z --stdin ||
+die "couldn't set up exclude patterns from index"
+
+# Add untracked files; to filter out generated files such as BSP, add
+# them to .gitignore and push, --exclude-standard (and the above hack)
+# takes care of the rest
+git ls-files --exclude-standard -o -z |
+git update-index --add -z --stdin ||
+die "couldn't add files to index"
+
+# Check if the index contains changes against parent
+git diff-index --cached --quiet $parent &&
+die "found no changes to commit"
+
+# Commit the index and point the ref to the new commit
+tree=$(git write-tree) &&
+commit=$(message | git commit-tree $tree -p $parent) &&
+git update-ref -m "pk3-import: $pk3name" $ref $commit ||
+die "couldn't commit changes"
diff --git a/misc/tools/git-pk3-merge b/misc/tools/git-pk3-merge
new file mode 100755 (executable)
index 0000000..69e8298
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+# git-pk3-merge: Attempt a trivial merge of master in a bare repo.
+
+set -x
+
+# Helpers
+
+die()
+{
+    echo "$(basename "$0"): error: $*" >&2
+    exit 1
+}
+
+usage()
+{
+    cat <<EOF
+Usage:
+
+  # mandatory
+  export GIT_DIR=/path/to/xonotic-maps.pk3dir.git # absolute path
+  # optional
+  export GIT_AUTHOR_NAME="Some Guy"
+  export GIT_AUTHOR_EMAIL="someguy@example.com"
+
+  $(basename $0) nick branch
+
+EOF
+}
+
+# Check usage
+
+[ $# -eq 2 ] || {
+    usage
+    die "wrong number of arguments"
+}
+
+[ -z "$GIT_DIR" ] && {
+    usage
+    die "GIT_DIR not set"
+}
+
+nick="$1"
+branch=$(git check-ref-format --print "$nick/$2") ||
+die "malformed branch name '$nick/$2'"
+
+# Set up commit info
+
+[ -z "$GIT_AUTHOR_NAME" ] && export GIT_AUTHOR_NAME="$nick"
+[ -z "$GIT_AUTHOR_EMAIL" ] && export GIT_AUTHOR_EMAIL="${nick}@example.com"
+
+message()
+{
+    echo "Merge branch 'master'"
+}
+
+# Clean up on exit
+
+cleanup_index=
+
+cleanup()
+{
+    [ "$cleanup_index" ] && rm -f "$GIT_INDEX_FILE"
+}
+
+trap cleanup EXIT
+
+# Set up index file, makes testing easier
+[ -z "$GIT_INDEX_FILE" ] && {
+    export GIT_INDEX_FILE="$GIT_DIR/pk3-merge-index"
+    cleanup_index=t
+}
+
+# Note the refs and the common ancestor
+master=refs/heads/master
+ref=refs/heads/$branch
+base=$(git merge-base $master $ref 2> /dev/null) ||
+die "couldn't determine the common ancestor"
+
+# Figure out the parent commits
+parent1=$(git rev-parse --verify -q $ref) &&
+parent2=$(git rev-parse --verify -q $master) ||
+die "couldn't determine parent commits"
+
+# Attempt a trivial merge
+git read-tree -i -m --aggressive --trivial $base $ref $master ||
+die "couldn't do a trivial merge"
+
+# Check if the index contains changes against parent
+git diff-index --cached --quiet $parent1 &&
+die "found no changes to commit"
+
+# Commit the index and point the ref to the new commit
+tree=$(git write-tree) &&
+commit=$(message | git commit-tree $tree -p $parent1 -p $parent2) &&
+git update-ref -m "pk3-merge" $ref $commit ||
+die "couldn't commit merge"
diff --git a/misc/tools/normalmap.sh b/misc/tools/normalmap.sh
new file mode 100755 (executable)
index 0000000..08ca0fa
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# usage: ./bump2norm.sh foo_bump.tga foo_norm.tga
+# NOTE: unfortunately requires X-server (otherwise file-tga-save won't work... no joke)
+
+in=$1
+out=$2
+
+# env variables you can set:
+# filter:
+#   Filter type (0 = 4 sample, 1 = sobel 3x3, 2 = sobel 5x5, 3 = prewitt 3x3, 4 = prewitt 5x5, 5-8 = 3x3,5x5,7x7,9x9)
+# minz:
+#   Minimun Z (0 to 1)
+# scale:
+#   Scale (>0)
+# heightsource:
+#   Height source (0 = average RGB, 1 = alpha channel)
+# conv:
+#   Conversion (0 = none, 1 = Biased RGB, 2 = Red, 3 = Green, 4 = Blue, 5 = Max RGB, 6 = Min RGB, 7 = Colorspace)
+: ${filter:=0}
+: ${minz:=0}
+: ${scale:=1}
+: ${heightsource:=0}
+: ${conv:=0}
+
+gimp -i -b - <<EOF
+
+(let*(
+               (img (car (gimp-file-load RUN-NONINTERACTIVE "$in" "$in")))
+               (drawable (car (gimp-image-active-drawable img)))
+               (layer (car (gimp-image-get-active-layer img)))
+       )
+       (gimp-layer-add-alpha layer)
+       (plug-in-normalmap RUN-NONINTERACTIVE img drawable $filter $minz $scale 1 $heightsource 1 $conv 0 0 1 0 1 layer)
+       (file-tga-save RUN-NONINTERACTIVE img drawable "$out" "$out" 1 1)
+       (gimp-quit 0)
+)
+
+EOF