Re: [Intel-gfx] [PATCH 04/10] dim: autodetect remotes, first part for dim_setup
On Tue, 18 Oct 2016, Ville Syrjälä wrote: > On Tue, Oct 18, 2016 at 04:27:05PM +0300, Jani Nikula wrote: >> On Tue, 18 Oct 2016, Daniel Vetter wrote: >> > The goals here are multiple: >> > - simpler configuration through autodetection >> > - allows seamless upgrading to git worktree for the aux checkouts >> > - eventually I want to split up drm-misc into a separate remote ... >> > >> > And yes this is just a start. >> > >> > v2: Print errors to stderr, otherwise they can't be seen when directly >> > assigning the result of get_remote_name to a variable. >> > >> > Signed-off-by: Daniel Vetter >> > --- >> > dim | 112 >> > +++- >> > 1 file changed, 58 insertions(+), 54 deletions(-) >> > >> > diff --git a/dim b/dim >> > index 2601bb7dbbad..90eb553c6575 100755 >> > --- a/dim >> > +++ b/dim >> > @@ -192,6 +192,24 @@ if [[ "$((`date +%s` % 100))" -eq "0" ]] ; then >> > dim_uptodate >> > fi >> > >> > +function get_remote_name >> > +{ >> > + local remote_url=$1 >> > + >> > + local remote=`git remote -v | grep $remote_url | \ >> > + head -n1 | sed -e 's/^\(.*\)\t.*/\1/'` >> >> 'cut -f 1' seems cleaner than the sed. > > Or just replace the lot with awk? Then I'd have to refresh my awk-fu, but awk is not trendy anymore... J. > >> >> > + >> > + if [[ $remote == "" ]] ; then >> >> I'd prefer >> >> if [[ -z "$remote" ]]; then >> >> > + echoerr No git remote for $remote_url found in `pwd`. >> > + echoerr Please set it up using >> > + echoerr $ git remote add '' $remote_url >> > + echoerr with a name of your choice. >> >> I'm fond of wrapping the strings in double quotes. Gives me nicer >> highlighting in the editor. ;) >> >> Otherwise seems nice. >> >> BR, >> Jani. >> >> > + exit 1 >> > + fi >> > + >> > + echo $remote >> > +} >> > + >> > # get message id from file >> > # $1 = file >> > message_get_id () >> > @@ -1044,8 +1062,36 @@ function dim_update_branches >> >update_rerere_cache >> > } >> > >> > +function setup_aux_checkout # name remote >> > +{ >> > + local name=$1 >> > + local remote_url=$2 >> > + local dir=$3 >> > + local remote >> > + >> > + echo "Setting up $dir ..." >> > + >> > + if [ ! -d $dir ]; then >> > + git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git >> > $remote_url $dir >> > + cd $dir >> > + git config remote.origin.url $remote_url >> > + echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > >> > .git/objects/info/alternates >> > + git repack -a -d -l >> > + remote=origin >> > + else >> > + cd $dir >> > + remote=`get_remote_name $drm_intel_ssh` >> > + fi >> > + if ! git branch | grep $name > /dev/null ; then >> > + git checkout -t $remote/$name >> > + fi >> > + cd .. >> > +} >> > + >> > function dim_setup >> > { >> > + local remote >> > + >> >if [ ! -d $DIM_PREFIX ]; then >> >echo "please set up your repository directory with:" >> >echo "mkdir -p $DIM_PREFIX" >> > @@ -1062,76 +1108,34 @@ function dim_setup >> >exit 1 >> >fi >> >cd $DIM_DRM_INTEL >> > - if ! git remote -v | grep "^origin[[:space:]]" | grep >> > $linux_upstream_git > /dev/null; then >> > - echo "please set up remote origin for $linux_upstream_git" >> > - exit 1 >> > - fi >> > - if ! git remote -v | grep "^$DIM_DRM_INTEL_REMOTE[[:space:]]" | grep >> > $drm_intel_ssh > /dev/null; then >> > - echo "please set up remote $DIM_DRM_INTEL_REMOTE for >> > $drm_intel_ssh with:" >> > - echo "git remote add $DIM_DRM_INTEL_REMOTE $drm_intel_ssh" >> > - echo "or update your configuration." >> > - exit 1 >> > - fi >> > - if ! git remote -v | grep "^$DIM_DRM_UPSTREAM_REMOTE[[:space:]]" | grep >> > $drm_upstream_git > /dev/null; then >> > - echo "please set up remote $DIM_DRM_UPSTREAM_REMOTE for >> > $drm_upstream_git with:" >> > - echo "git remote add $DIM_DRM_UPSTREAM_REMOTE >> > $drm_upstream_git" >> > - echo "or update your configuration." >> > - exit 1 >> > - fi >> > - cd .. >> > >> > - echo "Setting up maintainer-tools ..." >> > - if [ ! -d maintainer-tools ]; then >> > - git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git >> > $drm_intel_ssh maintainer-tools >> > - fi >> > - cd maintainer-tools >> > - git config remote.origin.url $drm_intel_ssh >> > - echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > >> > .git/objects/info/alternates >> > - git repack -a -d -l >> > - if ! git branch | grep maintainer-tools > /dev/null ; then >> > - git checkout -t origin/maintainer-tools >> > - fi >> > - cd .. >> > + # check remote configuration >> > + remote=`get_remote_name $linux_upstream_git` >> > + remote=`get_remote_name $drm_intel_ssh` >> > + remote=`get_remote_name $drm_upstream_git` >> > >> >
Re: [Intel-gfx] [PATCH 04/10] dim: autodetect remotes, first part for dim_setup
On Tue, Oct 18, 2016 at 04:27:05PM +0300, Jani Nikula wrote: > On Tue, 18 Oct 2016, Daniel Vetter wrote: > > The goals here are multiple: > > - simpler configuration through autodetection > > - allows seamless upgrading to git worktree for the aux checkouts > > - eventually I want to split up drm-misc into a separate remote ... > > > > And yes this is just a start. > > > > v2: Print errors to stderr, otherwise they can't be seen when directly > > assigning the result of get_remote_name to a variable. > > > > Signed-off-by: Daniel Vetter > > --- > > dim | 112 > > +++- > > 1 file changed, 58 insertions(+), 54 deletions(-) > > > > diff --git a/dim b/dim > > index 2601bb7dbbad..90eb553c6575 100755 > > --- a/dim > > +++ b/dim > > @@ -192,6 +192,24 @@ if [[ "$((`date +%s` % 100))" -eq "0" ]] ; then > > dim_uptodate > > fi > > > > +function get_remote_name > > +{ > > + local remote_url=$1 > > + > > + local remote=`git remote -v | grep $remote_url | \ > > + head -n1 | sed -e 's/^\(.*\)\t.*/\1/'` > > 'cut -f 1' seems cleaner than the sed. Or just replace the lot with awk? > > > + > > + if [[ $remote == "" ]] ; then > > I'd prefer > > if [[ -z "$remote" ]]; then > > > + echoerr No git remote for $remote_url found in `pwd`. > > + echoerr Please set it up using > > + echoerr $ git remote add '' $remote_url > > + echoerr with a name of your choice. > > I'm fond of wrapping the strings in double quotes. Gives me nicer > highlighting in the editor. ;) > > Otherwise seems nice. > > BR, > Jani. > > > + exit 1 > > + fi > > + > > + echo $remote > > +} > > + > > # get message id from file > > # $1 = file > > message_get_id () > > @@ -1044,8 +1062,36 @@ function dim_update_branches > > update_rerere_cache > > } > > > > +function setup_aux_checkout # name remote > > +{ > > + local name=$1 > > + local remote_url=$2 > > + local dir=$3 > > + local remote > > + > > + echo "Setting up $dir ..." > > + > > + if [ ! -d $dir ]; then > > + git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git > > $remote_url $dir > > + cd $dir > > + git config remote.origin.url $remote_url > > + echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > > > .git/objects/info/alternates > > + git repack -a -d -l > > + remote=origin > > + else > > + cd $dir > > + remote=`get_remote_name $drm_intel_ssh` > > + fi > > + if ! git branch | grep $name > /dev/null ; then > > + git checkout -t $remote/$name > > + fi > > + cd .. > > +} > > + > > function dim_setup > > { > > + local remote > > + > > if [ ! -d $DIM_PREFIX ]; then > > echo "please set up your repository directory with:" > > echo "mkdir -p $DIM_PREFIX" > > @@ -1062,76 +1108,34 @@ function dim_setup > > exit 1 > > fi > > cd $DIM_DRM_INTEL > > - if ! git remote -v | grep "^origin[[:space:]]" | grep > > $linux_upstream_git > /dev/null; then > > - echo "please set up remote origin for $linux_upstream_git" > > - exit 1 > > - fi > > - if ! git remote -v | grep "^$DIM_DRM_INTEL_REMOTE[[:space:]]" | grep > > $drm_intel_ssh > /dev/null; then > > - echo "please set up remote $DIM_DRM_INTEL_REMOTE for > > $drm_intel_ssh with:" > > - echo "git remote add $DIM_DRM_INTEL_REMOTE $drm_intel_ssh" > > - echo "or update your configuration." > > - exit 1 > > - fi > > - if ! git remote -v | grep "^$DIM_DRM_UPSTREAM_REMOTE[[:space:]]" | grep > > $drm_upstream_git > /dev/null; then > > - echo "please set up remote $DIM_DRM_UPSTREAM_REMOTE for > > $drm_upstream_git with:" > > - echo "git remote add $DIM_DRM_UPSTREAM_REMOTE > > $drm_upstream_git" > > - echo "or update your configuration." > > - exit 1 > > - fi > > - cd .. > > > > - echo "Setting up maintainer-tools ..." > > - if [ ! -d maintainer-tools ]; then > > - git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git > > $drm_intel_ssh maintainer-tools > > - fi > > - cd maintainer-tools > > - git config remote.origin.url $drm_intel_ssh > > - echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > > > .git/objects/info/alternates > > - git repack -a -d -l > > - if ! git branch | grep maintainer-tools > /dev/null ; then > > - git checkout -t origin/maintainer-tools > > - fi > > - cd .. > > + # check remote configuration > > + remote=`get_remote_name $linux_upstream_git` > > + remote=`get_remote_name $drm_intel_ssh` > > + remote=`get_remote_name $drm_upstream_git` > > > > - echo "Setting up drm-intel-rerere ..." > > - if [ ! -d drm-intel-rerere ]; then > > - git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git > > $drm_intel_ssh drm-intel-rerere > > - f
Re: [Intel-gfx] [PATCH 04/10] dim: autodetect remotes, first part for dim_setup
On Tue, 18 Oct 2016, Daniel Vetter wrote: > The goals here are multiple: > - simpler configuration through autodetection > - allows seamless upgrading to git worktree for the aux checkouts > - eventually I want to split up drm-misc into a separate remote ... > > And yes this is just a start. > > v2: Print errors to stderr, otherwise they can't be seen when directly > assigning the result of get_remote_name to a variable. > > Signed-off-by: Daniel Vetter > --- > dim | 112 > +++- > 1 file changed, 58 insertions(+), 54 deletions(-) > > diff --git a/dim b/dim > index 2601bb7dbbad..90eb553c6575 100755 > --- a/dim > +++ b/dim > @@ -192,6 +192,24 @@ if [[ "$((`date +%s` % 100))" -eq "0" ]] ; then > dim_uptodate > fi > > +function get_remote_name > +{ > + local remote_url=$1 > + > + local remote=`git remote -v | grep $remote_url | \ > + head -n1 | sed -e 's/^\(.*\)\t.*/\1/'` 'cut -f 1' seems cleaner than the sed. > + > + if [[ $remote == "" ]] ; then I'd prefer if [[ -z "$remote" ]]; then > + echoerr No git remote for $remote_url found in `pwd`. > + echoerr Please set it up using > + echoerr $ git remote add '' $remote_url > + echoerr with a name of your choice. I'm fond of wrapping the strings in double quotes. Gives me nicer highlighting in the editor. ;) Otherwise seems nice. BR, Jani. > + exit 1 > + fi > + > + echo $remote > +} > + > # get message id from file > # $1 = file > message_get_id () > @@ -1044,8 +1062,36 @@ function dim_update_branches > update_rerere_cache > } > > +function setup_aux_checkout # name remote > +{ > + local name=$1 > + local remote_url=$2 > + local dir=$3 > + local remote > + > + echo "Setting up $dir ..." > + > + if [ ! -d $dir ]; then > + git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git > $remote_url $dir > + cd $dir > + git config remote.origin.url $remote_url > + echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > > .git/objects/info/alternates > + git repack -a -d -l > + remote=origin > + else > + cd $dir > + remote=`get_remote_name $drm_intel_ssh` > + fi > + if ! git branch | grep $name > /dev/null ; then > + git checkout -t $remote/$name > + fi > + cd .. > +} > + > function dim_setup > { > + local remote > + > if [ ! -d $DIM_PREFIX ]; then > echo "please set up your repository directory with:" > echo "mkdir -p $DIM_PREFIX" > @@ -1062,76 +1108,34 @@ function dim_setup > exit 1 > fi > cd $DIM_DRM_INTEL > - if ! git remote -v | grep "^origin[[:space:]]" | grep > $linux_upstream_git > /dev/null; then > - echo "please set up remote origin for $linux_upstream_git" > - exit 1 > - fi > - if ! git remote -v | grep "^$DIM_DRM_INTEL_REMOTE[[:space:]]" | grep > $drm_intel_ssh > /dev/null; then > - echo "please set up remote $DIM_DRM_INTEL_REMOTE for > $drm_intel_ssh with:" > - echo "git remote add $DIM_DRM_INTEL_REMOTE $drm_intel_ssh" > - echo "or update your configuration." > - exit 1 > - fi > - if ! git remote -v | grep "^$DIM_DRM_UPSTREAM_REMOTE[[:space:]]" | grep > $drm_upstream_git > /dev/null; then > - echo "please set up remote $DIM_DRM_UPSTREAM_REMOTE for > $drm_upstream_git with:" > - echo "git remote add $DIM_DRM_UPSTREAM_REMOTE > $drm_upstream_git" > - echo "or update your configuration." > - exit 1 > - fi > - cd .. > > - echo "Setting up maintainer-tools ..." > - if [ ! -d maintainer-tools ]; then > - git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git > $drm_intel_ssh maintainer-tools > - fi > - cd maintainer-tools > - git config remote.origin.url $drm_intel_ssh > - echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > > .git/objects/info/alternates > - git repack -a -d -l > - if ! git branch | grep maintainer-tools > /dev/null ; then > - git checkout -t origin/maintainer-tools > - fi > - cd .. > + # check remote configuration > + remote=`get_remote_name $linux_upstream_git` > + remote=`get_remote_name $drm_intel_ssh` > + remote=`get_remote_name $drm_upstream_git` > > - echo "Setting up drm-intel-rerere ..." > - if [ ! -d drm-intel-rerere ]; then > - git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git > $drm_intel_ssh drm-intel-rerere > - fi > - cd drm-intel-rerere > - git config remote.origin.url $drm_intel_ssh > - echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > > .git/objects/info/alternates > - git repack -a -d -l > - if ! git branch | grep rerere-cache > /dev/n