From ee40969d05dcfe75501ae037e9410fd7b4fc6cb6 Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Thu, 28 Dec 2006 18:36:24 -0500 Subject: [PATCH] Check for outstanding changes before pushing/poping a patch Signed-off-by: Josef 'Jeff' Sipek --- gq-pop | 8 +++----- gq-push | 6 ++++++ gq.lib | 5 +++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gq-pop b/gq-pop index d021b49..decaa86 100755 --- a/gq-pop +++ b/gq-pop @@ -15,14 +15,12 @@ applied="$GQ_DIR/$branch/status" # FIXME: ... [ $# -ne 0 ] && echo "Poping only top most patch..arguments ignored" -git-status > /dev/null - -if [ $? -ne 1 ]; then - echo "Uncommited changes, refresh first" +# make sure that there are no unapplied changes +if ! must_commit_first; then + echo "Uncommited changes detected. Refresh first." exit 1 fi -refresh_patch HEAD `get_top` git reset --hard HEAD^ echo "Poping `get_top`..." diff --git a/gq-push b/gq-push index eecc1f5..7bdec8e 100755 --- a/gq-push +++ b/gq-push @@ -39,6 +39,12 @@ else fi fi +# make sure that there are no unapplied changes +if ! must_commit_first; then + echo "Uncommited changes detected. Refresh first." + exit 1 +fi + # now, find the starting patch sidx=`wc -l < $applied` sidx=`expr $sidx + 1` diff --git a/gq.lib b/gq.lib index 9c80dda..e5ae281 100644 --- a/gq.lib +++ b/gq.lib @@ -117,3 +117,8 @@ function push_patch return $bail } +function must_commit_first +{ + [ `git-diff-files | wc -l` -eq 0 ] + return $? +} -- 2.11.4.GIT