From patchwork Fri Oct 21 19:36:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9389967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6BEA360780 for ; Fri, 21 Oct 2016 19:38:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5873A2A265 for ; Fri, 21 Oct 2016 19:38:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D6592A276; Fri, 21 Oct 2016 19:38:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E765A2A265 for ; Fri, 21 Oct 2016 19:38:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D60E66EDD4; Fri, 21 Oct 2016 19:37:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id A02896EDB7 for ; Fri, 21 Oct 2016 19:37:21 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id d128so218567wmf.0 for ; Fri, 21 Oct 2016 12:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=evrWQQrG1zMsgPo32S3xVzoQlKOAH0q26RYqGVbZrLk=; b=dhR4LCB2lUnhQs2eF8/r23+D8iHNgaCRhQwxU/qpk+zcwGXBVZNaT1pY7qRgPDneTV dE+gQvTe0iaCDXDJ1iJbn7V3JfPjz1PsuUuROxrMJEVGPRfQf/Nd8lP4/JHioSPnZ0Wg trUwC4VWLRxt/YbFpT7HuKT2gyDi60ZQMQvvA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=evrWQQrG1zMsgPo32S3xVzoQlKOAH0q26RYqGVbZrLk=; b=J1L/Kmfpc/gMd7HyQhY0f66uhuzazM7nXAYPA3REY+Zg254FCJLujycjQlFq9QPA9x TeD4aRGOYX2eJQtFYwFipcN7dtroi7Rn81JGsu0Pl/ygHpkZOfhlVfoH+426KiPKDPnY ygy8XrRTxWjfcD9yc0XhW+FieqXlYUF1EEHw3NZvomq33ioEJ30r7uXo2jDqYxfL3rS6 JElu/6qY98cf7DO1ou2HDe7X3aP3v6CEY1D2Xo/NK3Lggeu51b9CZGs8PBWO2V2xq6+/ XBRhi+by1w1sXgRLiY/VXzWDRq2WE1g9wcWeRe05PJkh9SQRShvYfuz7nTltN8eSYtn7 hRVA== X-Gm-Message-State: ABUngve3JuUMWNevF5Xy3aooiAS7GShrV5JhWpeM1Mm6H0PjIFTJq7oTqkSvDoecptSEvA== X-Received: by 10.194.72.231 with SMTP id g7mr2007167wjv.79.1477078639021; Fri, 21 Oct 2016 12:37:19 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56b5:0:ac27:b86c:7764:9429]) by smtp.gmail.com with ESMTPSA id q134sm5756630wme.3.2016.10.21.12.37.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2016 12:37:18 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 04/18] dim: autodetect remotes, first part for dim_setup Date: Fri, 21 Oct 2016 21:36:46 +0200 Message-Id: <20161021193700.22100-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161021193700.22100-1-daniel.vetter@ffwll.ch> References: <20161021193700.22100-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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/'` + + if [[ $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. + 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/null ; then - git checkout -t origin/rerere-cache - fi cd .. - echo "Setting up drm-intel-nightly ..." - if [ ! -d drm-intel-nightly ]; then - git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git $drm_intel_ssh drm-intel-nightly - fi + setup_aux_checkout maintainer-tools $drm_intel_ssh maintainer-tools + + setup_aux_checkout rerere-cache $drm_intel_ssh drm-intel-rerere + + setup_aux_checkout drm-intel-nightly $drm_intel_ssh drm-intel-nightly cd drm-intel-nightly - mkdir -p .git/rr-cache - 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 drm-intel-nightly > /dev/null ; then - git checkout -t origin/drm-intel-nightly - fi if git remote | grep drm-upstream > /dev/null ; then git config remote.drm-upstream.url $drm_upstream_git else - git remote add drm-upstream $drm_upstream_git + remote=`get_remote_name $drm_upstream_git` fi if git remote | grep sound-upstream > /dev/null ; then git config remote.sound-upstream.url $sound_upstream_git else - git remote add sound-upstream $sound_upstream_git + remote=`get_remote_name $sound_upstream_git` fi if git remote | grep driver-core-upstream > /dev/null ; then git config remote.driver-core-upstream.url $driver_core_upstream_git else - git remote add driver-core-upstream $driver_core_upstream_git + remote=`get_remote_name $driver_core_upstream_git` fi echo "dim setup successfully completed!"