Re: [PATCH] qf: Make qf_pull -f forcibly clean

2018-03-13 Thread Rodrigo Vivi
On Mon, Mar 12, 2018 at 04:55:26PM -0700, Lucas De Marchi wrote:
> On Mon, Mar 12, 2018 at 04:08:41PM -0700, Rodrigo Vivi wrote:
> > 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 
> > Cc: Michel Thierry 
> > Cc: James Ausmus 
> > Cc: Lucas De Marchi 
> > Signed-off-by: Rodrigo Vivi 
> > ---
> >  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
> 
> qf_fetch already fetches from remote, so you can remove it from here.
> 
> > +   git reset --hard $(git rev-parse --abbrev-ref @{u})
> 
> There are also the cases in which the user changed the branch so
> `git rev-parse --abbrev-ref @{u}` may point to the wrong upstream or
> point nowhere:
> 
> $ cd patches
> $ git checkout -b bla
> $ git rev-parse --abbrev-ref @{u}
> fatal: no upstream configured for branch 'bla'
> $ git checkout --detach
> $ git rev-parse --abbrev-ref @{u}
> fatal: HEAD does not point to a branch
> 
> But then there would be other places to fix, like in qf_export.
> I'm not sure if it's worth the trouble to fix it, so with the removal of
> git fetch above,

hm... :(
yeap let's fix this later if we need.
For now let's focus on the current case we need here
where we don't change the branches

> 
> Reviewed-by: Lucas De Marchi 

pushed, thanks.

> 
> > +   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
dim-tools@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dim-tools


Re: [PATCH] qf: Make qf_pull -f forcibly clean

2018-03-12 Thread Lucas De Marchi
On Mon, Mar 12, 2018 at 04:08:41PM -0700, Rodrigo Vivi wrote:
> 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 
> Cc: Michel Thierry 
> Cc: James Ausmus 
> Cc: Lucas De Marchi 
> Signed-off-by: Rodrigo Vivi 
> ---
>  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

qf_fetch already fetches from remote, so you can remove it from here.

> + git reset --hard $(git rev-parse --abbrev-ref @{u})

There are also the cases in which the user changed the branch so
`git rev-parse --abbrev-ref @{u}` may point to the wrong upstream or
point nowhere:

$ cd patches
$ git checkout -b bla
$ git rev-parse --abbrev-ref @{u}
fatal: no upstream configured for branch 'bla'
$ git checkout --detach
$ git rev-parse --abbrev-ref @{u}
fatal: HEAD does not point to a branch

But then there would be other places to fix, like in qf_export.
I'm not sure if it's worth the trouble to fix it, so with the removal of
git fetch above,

Reviewed-by: Lucas De Marchi 

> + 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
dim-tools@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dim-tools