From: Yves Orton Date: Thu, 1 Jan 2009 16:37:52 +0000 (+0100) Subject: prepare for refactoring to perl X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ed12dca5306d03e0105857d74b40a6d40ecbe60;p=p5sagit%2Fp5-mst-13.2.git prepare for refactoring to perl --- diff --git a/make_patchnum.pl b/make_patchnum.pl new file mode 100644 index 0000000..7eb6515 --- /dev/null +++ b/make_patchnum.pl @@ -0,0 +1,97 @@ +#!/bin/sh + +# this script is used to regenerate a number of special build files +# based on either information contained in a file called .patch or +# directly from git. +# The files involved are: +# .patchnum # information about the current checkout +# lib/Config_git.pl # holds some special configure settings related to git +# unpushed.h # header file used by patchlevel.h to store unpushed commits + +existing_patchnum=$(cat .patchnum 2>/dev/null) +existing_config=$(cat lib/Config_git.pl 2>/dev/null) +existing_unpushed=$(cat unpushed.h 2>/dev/null) + +unpushed_commits='/*no-op*/' +if [ -s ".patch" ] ; then + # this is the minimal expectation for the + read branch snapshot_created commit_id describe < .patch + changed="" + extra_info="git_snapshot_date='$snapshot_created'" + commit_title='Snapshot of:' +elif [ -d ".git" ]; then + branch=$(git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }') + test -n "$branch" && remote=$(git config branch.$branch.remote) + commit_id=$(git rev-parse HEAD) + changed=$(git diff-index --name-only HEAD) + describe=$(git describe --tags) + commit_created=$(git log -1 --pretty='format:%ci') + extra_info="git_commit_date='$commit_created'" + if [ -n "$branch" ] && [ -n "$remote" ]; then + unpushed_commit_list=$(git cherry $remote/$branch | awk 'BEGIN{ORS=","} /+/ {print $2}' | sed -e 's/,$//') + unpushed_commits=$(git cherry $remote/$branch | awk 'BEGIN{ORS="\t\\\n"} /+/ {print ",\"" $2 "\""}') + + if [ -n "$unpushed_commits" ]; then + commit_title="Local Commit:" + ancestor=`git rev-parse $remote/$branch` + extra_info="$extra_info +git_ancestor='$ancestor' +git_unpushed='$unpushed_commit_list'" + fi + + fi +else + cat < .patchnum + echo "$new_config" > lib/Config_git.pl + echo "$new_unpushed" > unpushed.h +else + echo "Reusing .patchnum and lib/Config_git.pl" +fi +