qf_checkout implies that you need to have that baseline
on your local repository, what it is not good for a distributed
maintenance.

Let's make qf pull -f useful for the case we want to start
a clean rebase from anywhere.

v2: Remove dubious comments and use -f.
v3: Avoid git pull --ff-only breaking force so force with fetch
    and hard reset

Cc: Paulo Zanoni <[email protected]>
Cc: Michel Thierry <[email protected]>
Cc: James Ausmus <[email protected]>
Cc: Lucas De Marchi <[email protected]>
Signed-off-by: Rodrigo Vivi <[email protected]>
---
 qf | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/qf b/qf
index 270bcf53000a..ad37064902b4 100755
--- a/qf
+++ b/qf
@@ -404,11 +404,18 @@ function qf_pull
 {
        cd_toplevel
 
-       qf fetch
+       qf_fetch
        cd patches
-       git pull --ff-only
 
-       qf co
+       if [[ $FORCE ]]; then
+               git fetch
+               git reset --hard $(git rev-parse --abbrev-ref @{u})
+       else
+               git pull --ff-only
+               qf_co
+       fi
+
+       cd ..
 }
 
 function qf_stage
@@ -587,6 +594,19 @@ function qf_usage
        echo "See '$qf help' for more information."
 }
 
+FORCE=
+while getopts f opt; do
+       case "$opt" in
+               f)
+                       FORCE=1
+                       ;;
+               *)
+                       echo "See '$qf help' for more information."
+                       exit
+       esac
+done
+shift $((OPTIND - 1))
+
 # qf subcommand aliases (with bash 4.3+)
 if ! declare -n subcmd=qf_alias_${subcommand//-/_} &> /dev/null || \
                test -z "${subcmd:-}"; then
-- 
2.13.6

_______________________________________________
dim-tools mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dim-tools

Reply via email to