On 05/11/2012 11:51 AM, Jean-Marc Lasgouttes wrote:
Grr! I only intended to push the first commit, which only changes the repository.

I've taken to doing:
    git push -n
before doing the actual push. This shows you what is about to happen. Better yet, if you put the attached script somewhere, make it executable, and do:
    git config --global alias.pushto !git-pushto
then you can instead do:
    git pushto
and it will (a) show you what you are about to push and (b) ask you if you wish to proceed.

The script also allows things like:
    git pushto master
which allows you to push (say) a bug-fixing branch directly to master, without merging it first.

Richard, I can revert the other patches (which a really backpots) if you prefer.

If we keep them, I will add status entries.

I'll leave this to your judgement. I've seen most of these patches, and they look OK.

Richard

#!/bin/bash

REMOTE="origin";
RBRANCH="$1";

BRANCH=$(git br | grep '^\*' | cut -d' ' -f2);

if [ -z "$RBRANCH" ]; then
        RBRANCH="$BRANCH";
        if [ "$RBRANCH" != "master" -a "$RBRANCH" != "2.0.x" ]; then
                echo "Do you want to push to $RBRANCH?";
                select answer in Yes No; do
                        if [ "$answer" != "Yes" ]; then
                                echo "Aborting push.";
                                exit 1;
                                break;
                        else 
                                break;
                        fi
                done
        fi
fi

COMMITS=$(git push -n $REMOTE $BRANCH:$RBRANCH 2>&1 | tail -n 1 | grep -v 
"Everything" | sed -e 's/^ *//' -e 's/ .*//');

if [ -z "$COMMITS" ]; then
        echo "Everything up to date";
        exit 0;
fi

git log $COMMITS;

#Do we want to go ahead?
echo
echo "Do you want to push these commits to $RBRANCH?"
select answer in Yes No; do
        if [ "$answer" != "Yes" ]; then
                exit 0;
                break;
        else 
                break;
        fi
done

git push $REMOTE $BRANCH:$RBRANCH

Reply via email to