dim: Fixup remove-branch for working-trees
PATCH 1/5 dim: Fixup remove-branch for working-trees
When there's a working-tree checkout we need to remove that first, before removing the branch. git complains otherwise. Not sure, but this might be a recently added more strict test for the git worktree support, at least I believe the "branch still checkout out in $dir" warning is new-ish.
v2: Move to the front, also include the git worktree prune call to clean up the potential mess.
--- dim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
dim +6 -4
@@ -673,12 +673,14 @@ function dim_remove_branch cd $DIM_PREFIX/$DIM_DRM_INTEL - if ! $DRY git branch -d $branch ; then - warn_or_fail "Can't remove $branch in working repo" - fi - if [[ -d $DIM_PREFIX/$branch ]] ; then rm -R $DIM_PREFIX/$branch + git worktree prune &> /dev/null || true + fi + + if [[ `git branch --list $branch` != "" ]] && + ! $DRY git branch -d $branch ; then + warn_or_fail "Can't remove $branch in working repo" fi cd $DIM_PREFIX/drm-intel-nightly
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/5 dim: autodetect remotes, first part for dim_setup
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.
v3: Rebased to pull the cleanup patches ahead of the dim rework.
v4: Rebase to put the dim rework at the end of the series.
v5: s/get_remote_name/url_to_remote/ to align with Jani.
--- dim | 94 +++++++++++++++++++++++++++++---------------------------------------- 1 file changed, 40 insertions(+), 54 deletions(-)
dim +40 -54
@@ -1095,8 +1095,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=`url_to_remote $remote_url` + fi + if [[ `git branch --list $name` == "" ]] ; then + git checkout -t $remote/$name + fi + cd .. +} + function dim_setup { + local remote + if [ ! -d $DIM_PREFIX ]; then echoerr "Directory $DIM_PREFIX doesn't exist." echoerr "Please set up your repository directory with"
@@ -1115,76 +1143,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 --list maintainer-tools` == "" ]] > /dev/null ; then - git checkout -t origin/maintainer-tools - fi - cd .. + # check remote configuration + remote=`url_to_remote $linux_upstream_git` + remote=`url_to_remote $drm_intel_ssh` + remote=`url_to_remote $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 --list rerere-cache` == "" ]] ; 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 --list drm-intel-nightly` == "" ]] ; 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=`url_to_remote $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=`url_to_remote $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=`url_to_remote $driver_core_upstream_git` fi echo "dim setup successfully completed!"
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/5 dim: support git worktree for aux checkouts
In reply to Daniel VetterIf available by default. This saves quite a pile of disk-space that imo making it the default is justified.
Note that this will break the rebuild-nightly script for now, follow-up patches will fix that.
v2: Rebase to put the dim rework at the end of the series.
--- dim | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-)
dim +27 -9
@@ -294,11 +294,20 @@ function check_conflicts true } +function rr_cache_dir +{ + if [ -d $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ ] ; then + echo $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ + else + echo $DIM_PREFIX/$DIM_DRM_INTEL/.git/rr-cache/ + fi +} + function update_rerere_cache { cd $DIM_PREFIX/drm-intel-rerere/ git pull - cp rr-cache/* $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -r + cp rr-cache/* `rr_cache_dir` -r cd - }
@@ -306,7 +315,7 @@ function dim_revert_rerere { cd $DIM_PREFIX/drm-intel-rerere/ git revert $1 - rm $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -Rf + rm `rr_cache_dir`/* -Rf } function dim_rebuild_nightly
@@ -403,7 +412,7 @@ function dim_rebuild_nightly cd $rerere if git branch --list rerere-cache | grep '\*' >& /dev/null ; then git pull >& /dev/null - cp $DIM_PREFIX/$integration_branch/.git/rr-cache/* rr-cache -r + cp `rr_cache_dir`/* rr-cache -r git add *.patch >& /dev/null || true git add rr-cache/* > /dev/null if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
@@ -1105,12 +1114,21 @@ function setup_aux_checkout # name 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 + if git help worktree &> /dev/null ; then + cd $DIM_PREFIX/$DIM_DRM_INTEL + remote=`url_to_remote $remote_url` + if [[ `git branch --list $name` == "" ]] ; then + git branch --track $name $remote/$name + fi + git worktree add ../$dir $name + else + 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 + fi else cd $dir remote=`url_to_remote $remote_url`
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/5 dim: autodetect branches in rebuild-nightly
In reply to Daniel VetterNeeds new url-mapping information in nightly.conf to work properly. Only leftover bit from my original patch after rebasing is to abstract away the remote for the integration tree.
v2:
- Fix typo when calling rr_cache_dir. Oops.
- Use cut -f 1 instead of sed/regex horrors (jani).
v3: Fix bug that resulted in nesting rr-cache directories.
v4: Rebasing.
v5: Resurrect $repo (as $remote) printing when fetching branches, originally from my patch.
v6: Use remote instead of origin local variables, to be more consistent. Picked up from Jani.
--- dim | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
dim +14 -9
@@ -261,16 +261,18 @@ function update_linux_next { cd $DIM_PREFIX/drm-intel-nightly + local remote=${drm_tip_repos[drm-intel]} + # always update drm-intel-fixes echo -n "Pushing drm-intel-fixes to for-linux-next-fixes... " - git push $DRY_RUN origin +origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null + git push $DRY_RUN $remote +$remote/drm-intel-fixes:for-linux-next-fixes >& /dev/null echo "Done." - if git merge-base --is-ancestor origin/drm-intel-next-fixes origin/drm-intel-fixes ; then + if git merge-base --is-ancestor $remote/drm-intel-next-fixes $remote/drm-intel-fixes ; then # -fixes has caught up to dinf, i.e. we're out of the merge # window. Push the next queue. echo -n "Out of merge window. Pushing drm-intel-next-queued to for-linux-next... " - git push $DRY_RUN origin +origin/drm-intel-next-queued:for-linux-next >& /dev/null + git push $DRY_RUN $remote +$remote/drm-intel-next-queued:for-linux-next >& /dev/null echo "Done." else # dinf is ahead of -fixes, i.e. drm-next has already closed for
@@ -278,7 +280,7 @@ function update_linux_next # for the current -next cycle. Push dinf echo -n "Pushing drm-intel-next-fixes to for-linux-next... " - git push $DRY_RUN origin +origin/drm-intel-next-fixes:for-linux-next >& /dev/null + git push $DRY_RUN $remote +$remote/drm-intel-next-fixes:for-linux-next >& /dev/null echo "Done." fi }
@@ -346,9 +348,10 @@ function dim_rebuild_nightly exit 1 fi - for url in "${drm_tip_repos[@]}"; do + for repo in "${!drm_tip_repos[@]}"; do + local url=${drm_tip_repos[$repo]} local remote=$(url_to_remote $url) - echo -n "Fetching $remote... " + echo -n "Fetching $repo (as $remote) ... " # git fetch returns 128 if there's nothing to be fetched git fetch $remote >& /dev/null || true echo "Done."
@@ -369,8 +372,8 @@ function dim_rebuild_nightly fi if [ $first == 1 ] ; then + git reset --hard $sha1 &> /dev/null echo "Reset. Done." - git reset --hard $sha1 >& /dev/null first=0 elif git merge --rerere-autoupdate --ff-only $sha1 >& /dev/null ; then # nothing to do if just fast-forward
@@ -405,8 +408,10 @@ function dim_rebuild_nightly git commit --quiet -m "$integration_branch: $time integration manifest" echo "Done." + local nightly_remote=${drm_tip_repos[drm-intel]} + echo -n "Pushing $integration_branch... " - git push $DRY_RUN origin +HEAD >& /dev/null && echo "Done." + git push $DRY_RUN $nightly_remote +HEAD >& /dev/null && echo "Done." echo -n "Updating rerere cache... " cd $rerere
@@ -421,7 +426,7 @@ function dim_rebuild_nightly echo -n "Nothing changed. " fi echo -n "Pushing rerere cache... " - git push $DRY_RUN origin HEAD >& /dev/null && echo "Done." + git push $DRY_RUN $nightly_remote HEAD >& /dev/null && echo "Done." else echo "Fail: Branch setup for the rerere-cache is borked." exit 1
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/5 dim: Improve the error output when rebuild-nightly fails
In reply to Daniel VetterJoonas rightly complained that the current output is useless and just confuses.
v2: Bikeshed stuff some more.
--- dim | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
dim +16 -14
@@ -261,18 +261,18 @@ function update_linux_next { cd $DIM_PREFIX/drm-intel-nightly - local remote=${drm_tip_repos[drm-intel]} + local nightly_origin=${drm_tip_repos[drm-intel]} # always update drm-intel-fixes echo -n "Pushing drm-intel-fixes to for-linux-next-fixes... " - git push $DRY_RUN $remote +$remote/drm-intel-fixes:for-linux-next-fixes >& /dev/null + git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null echo "Done." - if git merge-base --is-ancestor $remote/drm-intel-next-fixes $remote/drm-intel-fixes ; then + if git merge-base --is-ancestor $nightly_origin/drm-intel-next-fixes $nightly_origin/drm-intel-fixes ; then # -fixes has caught up to dinf, i.e. we're out of the merge # window. Push the next queue. echo -n "Out of merge window. Pushing drm-intel-next-queued to for-linux-next... " - git push $DRY_RUN $remote +$remote/drm-intel-next-queued:for-linux-next >& /dev/null + git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-queued:for-linux-next >& /dev/null echo "Done." else # dinf is ahead of -fixes, i.e. drm-next has already closed for
@@ -280,17 +280,19 @@ function update_linux_next # for the current -next cycle. Push dinf echo -n "Pushing drm-intel-next-fixes to for-linux-next... " - git push $DRY_RUN $remote +$remote/drm-intel-next-fixes:for-linux-next >& /dev/null + git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-fixes:for-linux-next >& /dev/null echo "Done." fi } -function check_conflicts +function check_conflicts # tree { - if git diff | grep '\(<<<<<<<\|=======\|>>>>>>>\||||||||\)' ; then - if [ -n "$1" ]; then - echo $* - fi + if git diff | grep '\(<<<<<<<\|=======\|>>>>>>>\||||||||\)' &> /dev/null ; then + # we need an empty line to make it look pretty + echoerr "" + echoerr "FAILURE: Could not merge $1" + echoerr "See the section \"Resolving Conflicts when Rebuilding drm-intel-nightly\"" + echoerr "in the drm-intel.rst documentation for how to handle this situation." exit 1 fi true
@@ -388,7 +390,7 @@ function dim_rebuild_nightly echo -n "Applying manual fixup patch for $integration_branch merge... " patch -p1 -i $fixup_file fi - check_conflicts "Fail: conflict merging $tree" + check_conflicts "$repo/$branch" git add -u # because we filter out fast-forward merges there will
@@ -408,10 +410,10 @@ function dim_rebuild_nightly git commit --quiet -m "$integration_branch: $time integration manifest" echo "Done." - local nightly_remote=${drm_tip_repos[drm-intel]} + local nightly_origin=${drm_tip_repos[drm-intel]} echo -n "Pushing $integration_branch... " - git push $DRY_RUN $nightly_remote +HEAD >& /dev/null && echo "Done." + git push $DRY_RUN $nightly_origin +HEAD >& /dev/null && echo "Done." echo -n "Updating rerere cache... " cd $rerere
@@ -426,7 +428,7 @@ function dim_rebuild_nightly echo -n "Nothing changed. " fi echo -n "Pushing rerere cache... " - git push $DRY_RUN $nightly_remote HEAD >& /dev/null && echo "Done." + git push $DRY_RUN $nightly_origin HEAD >& /dev/null && echo "Done." else echo "Fail: Branch setup for the rerere-cache is borked." exit 1
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx