#!/bin/bash # # This script takes patches stored in the bundle and places # them into a branch named frombundle for each local repo it # finds. # NYI: report if the required base commit isn't there - they may need to fetch the latest from upstream set -e source ./config.sh rm -rf $GIT_DIR rm -rf $CMP_DIR rm -rf $BUNDLE_DIR rm -f checkpatch.log mkdir -p $BUNDLE_DIR tar xJf bundles.tar.xz -C $BUNDLE_DIR BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$") for entry in ${BUNDLE_FILES[@]}; do if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then SUBDIR=${BASH_REMATCH[1]} GITREPO_COMMIT_ISH=${BASH_REMATCH[2]} else echo "ERROR! BAD BUNDLE CONTENT!" exit fi for (( i=0; i <$REPO_COUNT; i++ )); do if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then PATCH_RANGE_INDEX=$i break fi done LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) if [ -e $LOCAL_REPO ]; then echo "Found local repo $LOCAL_REPO corresponding to archived git bundle" else echo "No local repo $LOCAL_REPO corresponding to archived git bundle" fi git -C $LOCAL_REPO remote remove bundlerepo || true # git won't let you delete this branch if it's the current branch (returns 1) HOW TO HANDLE? # detect this case, and ask user to switch to another branch? or do it for them - switch to master killing any "state" for this branch git -C $LOCAL_REPO branch -D frombundle || true git -C $LOCAL_REPO remote add bundlerepo $BUNDLE_DIR/$entry # in next, the head may be FETCH_HEAD or HEAD depending on how we created: git -C $LOCAL_REPO fetch bundlerepo FETCH_HEAD #git -C $LOCAL_REPO fetch bundlerepo HEAD git -C $LOCAL_REPO branch frombundle FETCH_HEAD git -C $LOCAL_REPO remote remove bundlerepo done echo "For each local repo found a branch named frombundle contains the patches from the bundle." echo "Use this as the starting point for making changes to the $GIT_BRANCH, which gets used as" echo "the source when updating the bundle stored with the package." rm -rf $BUNDLE_DIR