public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip
@ 2016-11-24 15:32 Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 2/7] dim: fix references to anything "nightly" in dim and documentation Jani Nikula
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Keep update-branches as an alias.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim     | 5 +++--
 dim.rst | 7 +++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dim b/dim
index 0c48e1e404f7..0acfb59a3fc2 100755
--- a/dim
+++ b/dim
@@ -376,7 +376,8 @@ function dim_revert_rerere
 	rm `rr_cache_dir`/* -Rf
 }
 
-function dim_rebuild_nightly
+dim_alias_rebuild_nightly=rebuild-tip
+function dim_rebuild_tip
 {
 	local integration_branch=drm-tip
 	local specfile=`mktemp`
@@ -514,7 +515,7 @@ function dim_push_branch
 	update_linux_next $branch drm-intel-next-queued drm-intel-next-fixes drm-intel-fixes
 	update_linux_next $branch drm-misc-next drm-misc-next-fixes drm-misc-fixes
 
-	dim_rebuild_nightly
+	dim_rebuild_tip
 }
 
 dim_alias_pq=push-queued
diff --git a/dim.rst b/dim.rst
index bde160056023..bc8cb160bf1f 100644
--- a/dim.rst
+++ b/dim.rst
@@ -85,10 +85,9 @@ always maintained from the same machine, even if different branches are
 maintained on different machines (by different maintainers), there's no need to
 run this command.
 
-rebuild-nightly
----------------
-Rebuilds the nightly branch. Useful when ad-hoc trees are
-included in -nightly.
+rebuild-tip
+-----------
+Rebuild and push the integration tree.
 
 revert-rerere *rerere-cache-commit-ish*
 ---------------------------------------
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [dim PATCH v2 2/7] dim: fix references to anything "nightly" in dim and documentation
  2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
@ 2016-11-24 15:32 ` Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 3/7] dim: do not do local variable assignments in declaration Jani Nikula
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Reference drm-tip, use $integration_config, or just drop old/stale
comments.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim           | 18 ++++++++----------
 dim.rst       | 13 ++++---------
 drm-intel.rst |  6 +++---
 3 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/dim b/dim
index 0acfb59a3fc2..d450474dc8f4 100755
--- a/dim
+++ b/dim
@@ -344,7 +344,7 @@ function check_conflicts # tree
 		# 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 "See the section \"Resolving Conflicts when Rebuilding drm-tip\""
 		echoerr "in the drm-intel.rst documentation for how to handle this situation."
 		exit 1
 	fi
@@ -466,10 +466,10 @@ function dim_rebuild_tip
 	git commit --quiet -m "$integration_branch: $time integration manifest"
 	echo "Done."
 
-	local nightly_remote=`url_to_remote $drm_tip_ssh`
+	local tip_remote=`url_to_remote $drm_tip_ssh`
 
 	echo -n "Pushing $integration_branch... "
-	git push $DRY_RUN $nightly_remote +HEAD >& /dev/null && echo "Done."
+	git push $DRY_RUN $tip_remote +HEAD >& /dev/null && echo "Done."
 
 	echo -n "Updating rerere cache... "
 	cd $rerere
@@ -494,7 +494,7 @@ function dim_rebuild_tip
 		exit 1
 	fi
 }
-# push branch $1, rebuild nightly. the rest of the arguments are passed to git
+# push branch $1, rebuild drm-tip. the rest of the arguments are passed to git
 # push.
 function dim_push_branch
 {
@@ -602,7 +602,6 @@ function dim_cherry_pick
 	sha=`git rev-parse $1`
 	sha_short=${sha:0:8}
 
-	# need latest -nightly
 	git fetch -q $remote || true
 	echo Possible fixup patches for your cherry-pick:
 	git log --grep=$sha_short --pretty=oneline $sha..$remote/drm-tip
@@ -772,7 +771,7 @@ function dim_remove_branch
 	local repo=`branch_to_repo $branch`
 
 	if [[ $repo == "" ]] ; then
-		echoerr "$branch not found in nightly.conf"
+		echoerr "$branch not found in $integration_config"
 		exit 1
 	fi
 
@@ -819,7 +818,7 @@ function dim_checkout
 		fi
 
 		if [[ $repo == "" ]] ; then
-			echoerr "$branch not found in nightly.conf"
+			echoerr "$branch not found in $integration_config"
 			exit 1
 		fi
 
@@ -1056,7 +1055,7 @@ function dim_update_next_continue
 	$DRY git tag -f -a $tag $DIM_DRM_INTEL_REMOTE/drm-intel-next
 	git push $DRY_RUN -f $DIM_DRM_INTEL_REMOTE $tag
 
-	echo "Updating -testing to latest -nightly"
+	echo "Updating drm-intel-testing to latest drm-tip"
 	git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$remote/drm-tip:drm-intel-testing
 	$DRY git tag -f drm-intel-testing-$today $DIM_DRM_INTEL_REMOTE/drm-intel-testing
 	$DRY git push -f $DIM_DRM_INTEL_REMOTE drm-intel-testing-$today
@@ -1211,8 +1210,7 @@ function dim_update_branches
 	done
 	dim_checkout drm-intel-next
 	$DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next
-	# TODO: Restore -nightly merge state from the rerere-cache
-	# branch
+
 	update_rerere_cache
 }
 
diff --git a/dim.rst b/dim.rst
index bc8cb160bf1f..9a045a43e7b7 100644
--- a/dim.rst
+++ b/dim.rst
@@ -72,11 +72,6 @@ setup *prefix*
 --------------
 Setup git maintainer branches in the given prefix.
 
-nightly-forget
---------------
-Forget git rerere solutions for nightly merges in case they
-contain a bogus merge resolution.
-
 update-branches
 ---------------
 Updates all maintainer branches. Only needs to be run to synchronize branches
@@ -96,13 +91,13 @@ When a stored conflict resolution in the integration tree is wrong, this command
 can be used to fix up the mess. First figure out which commit in the
 *rerere-cache* branch contains the bogus conflict resolution, then revert it
 using this command. This ensures the resolution is also purged from any local
-caches, to make sure it doesn't get resurrected. Then run *rebuild-nightly* to
+caches, to make sure it doesn't get resurrected. Then run *rebuild-tip* to
 redo the merges, correctly.
 
 cat-to-fixup
 ------------
 
-Pipes stdin into the fixup patch file for the current -nightly merge.
+Pipes stdin into the fixup patch file for the current drm-tip merge.
 
 push-branch branch [*git push arguments*]
 -----------------------------------------
@@ -245,12 +240,12 @@ goes wrong.
 update-next
 -----------
 Pushes out the latest dinq to drm-intel-next and tags it. Also
-pushes out the latest nightly to drm-intel-testing. For an
+pushes out the latest drm-tip to drm-intel-testing. For an
 overview a gitk view of the currently unmerged feature pile is
 opened.
 
 Also checks that the drm-intel-fixes|-next-queued are fully
-merged into -nightly to avoid operator error.
+merged into drm-tip to avoid operator error.
 
 tag-next
 --------
diff --git a/drm-intel.rst b/drm-intel.rst
index e9cf240c4048..79db1cf64bcb 100644
--- a/drm-intel.rst
+++ b/drm-intel.rst
@@ -241,9 +241,9 @@ when it's tricky or something fails in the below procedure.
 1. First check that drm-intel-next-queued was indeed pushed correctly and that
    your local and remote branches match.
 
-2. Then re-run the -nightly generation just to confirm: ::
+2. Then rebuild the integration branch just to confirm: ::
 
-        $ dim rebuild-nightly
+        $ dim rebuild-tip
 
    It's handy to keep the log output for context so that you know which branch
    caused the conflicts, and which branches are already included.
@@ -268,7 +268,7 @@ when it's tricky or something fails in the below procedure.
    match up your resolution with the conflict for odd reasons) and to make sure
    there's no other conflict in later merges: ::
 
-        $ dim rebuild-nightly
+        $ dim rebuild-tip
 
    This will also push the stored conflict resolution to the drm-intel-rerere
    branch and therefore publishes your resolution. Everything before this step
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [dim PATCH v2 3/7] dim: do not do local variable assignments in declaration
  2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 2/7] dim: fix references to anything "nightly" in dim and documentation Jani Nikula
@ 2016-11-24 15:32 ` Jani Nikula
  2016-11-24 15:37   ` Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 4/7] dim: return exit status instead of actually exiting from url_to_remote Jani Nikula
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

We rely on 'set -e' to bail out on errors. We also do a lot of local
variable assignments with command substitution like this:

	local foo=$(bar)

However, that masks the return value of the command, failing to bail out
on errors. Split up local variable declarations from assignments to
avoid the problems.

There are no issues with literal assignments like

	local foo="bar"

but split those out too for more uniform code, preferring to have local
declarations in the beginning of functions or nested blocks.

Details at
http://stackoverflow.com/questions/4421257/why-does-local-sweep-the-return-code-of-a-command

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 202 +++++++++++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 129 insertions(+), 73 deletions(-)

diff --git a/dim b/dim
index d450474dc8f4..1d52d509450d 100755
--- a/dim
+++ b/dim
@@ -199,14 +199,16 @@ fi
 
 function url_to_remote # url
 {
-	local url="$1"
+	local url remote
+
+	url="$1"
 
 	if [[ -z "$url" ]]; then
 		echoerr "$0 without url"
 		exit 1
 	fi
 
-	local remote=$(git remote -v | grep -m 1 "$url" | cut -f 1)
+	remote=$(git remote -v | grep -m 1 "$url" | cut -f 1)
 
 	if [[ -z "$remote" ]]; then
 		echoerr "No git remote for url $url found in $(pwd)"
@@ -221,7 +223,9 @@ function url_to_remote # url
 
 function branch_to_remote # branch
 {
-	local remote=`git rev-parse --abbrev-ref --symbolic-full-name $1@{upstream}`
+	local remote
+
+	remote=`git rev-parse --abbrev-ref --symbolic-full-name $1@{upstream}`
 	remote=${remote%%/*}
 
 	echo $remote
@@ -248,7 +252,9 @@ function branch_to_repo # branch
 
 function dim_uptodate
 {
-	local using="${BASH_SOURCE[0]}"
+	local using
+
+	using="${BASH_SOURCE[0]}"
 
 	if [[ ! -e "$using" ]]; then
 		echoerr "could not figure out the version being used ($using)."
@@ -300,19 +306,21 @@ function dim_commit_add_tag
 # update for-linux-next and for-linux-next-fixes branches
 function update_linux_next # branch next next-fixes fixes
 {
+	local branch linux_next linux_next_fixes linux_fixes repo remote
+
 	cd $DIM_PREFIX/drm-tip
-	local branch=$1
-	local linux_next=$2
-	local linux_next_fixes=$3
-	local linux_fixes=$4
+	branch=$1
+	linux_next=$2
+	linux_next_fixes=$3
+	linux_fixes=$4
 
-	local repo=`branch_to_repo $branch`
+	repo=`branch_to_repo $branch`
 
 	if [[ $repo != `branch_to_repo $linux_next` ]] ; then
 		return
 	fi
 
-	local remote=`repo_to_remote $repo`
+	remote=`repo_to_remote $repo`
 
 	git fetch -q $remote || true
 
@@ -379,12 +387,14 @@ function dim_revert_rerere
 dim_alias_rebuild_nightly=rebuild-tip
 function dim_rebuild_tip
 {
-	local integration_branch=drm-tip
-	local specfile=`mktemp`
-	local time="`date --utc +%Yy-%mm-%dd-%Hh-%Mm-%Ss` UTC"
-	local first=1
+	local integration_branch specfile time first rerere repo url remote
 
-	local rerere=$DIM_PREFIX/drm-rerere
+	integration_branch=drm-tip
+	specfile=`mktemp`
+	time="`date --utc +%Yy-%mm-%dd-%Hh-%Mm-%Ss` UTC"
+	first=1
+
+	rerere=$DIM_PREFIX/drm-rerere
 
 	cd $rerere
 	if [[ `git status --porcelain | grep -v "^[ ?][ ?]" | wc -l` -gt 0 ]]; then
@@ -406,8 +416,8 @@ function dim_rebuild_tip
 	fi
 
 	for repo in "${!drm_tip_repos[@]}"; do
-		local url=${drm_tip_repos[$repo]}
-		local remote=$(url_to_remote $url)
+		url=${drm_tip_repos[$repo]}
+		remote=$(url_to_remote $url)
 		echo -n "Fetching $repo (as $remote) ... "
 		# git fetch returns 128 if there's nothing to be fetched
 		git fetch -q $remote || true
@@ -416,11 +426,12 @@ function dim_rebuild_tip
 
 	# merge -fixes
 	for conf in "${drm_tip_config[@]}"; do
-		local repo branch override
+		local branch override sha1 fixup_file
+
 		read repo branch override <<< $conf
-		local url=${drm_tip_repos[$repo]}
-		local remote=$(url_to_remote $url)
-		local sha1=$remote/$branch
+		url=${drm_tip_repos[$repo]}
+		remote=$(url_to_remote $url)
+		sha1=$remote/$branch
 
 		echo -n "Merging $repo (local remote $remote) $branch... "
 
@@ -438,7 +449,7 @@ function dim_rebuild_tip
 			echo "Fast-forward. Done."
 			true
 		else
-			local fixup_file=$rerere/$repo-${branch//\//-}-fixup.patch
+			fixup_file=$rerere/$repo-${branch//\//-}-fixup.patch
 			echo $fixup_file > .fixup_file_path
 
 			git merge --rerere-autoupdate --no-commit $sha1 >& /dev/null || true
@@ -466,15 +477,15 @@ function dim_rebuild_tip
 	git commit --quiet -m "$integration_branch: $time integration manifest"
 	echo "Done."
 
-	local tip_remote=`url_to_remote $drm_tip_ssh`
+	remote=`url_to_remote $drm_tip_ssh`
 
 	echo -n "Pushing $integration_branch... "
-	git push $DRY_RUN $tip_remote +HEAD >& /dev/null && echo "Done."
+	git push $DRY_RUN $remote +HEAD >& /dev/null && echo "Done."
 
 	echo -n "Updating rerere cache... "
 	cd $rerere
 	if git branch --list rerere-cache | grep -q '\*' ; then
-		local rerere_remote=`branch_to_remote rerere-cache`
+		remote=`branch_to_remote rerere-cache`
 
 		git pull >& /dev/null
 		rm `rr_cache_dir`/rr-cache -Rf &> /dev/null || true
@@ -488,7 +499,7 @@ function dim_rebuild_tip
 			echo -n "Nothing changed. "
 		fi
 		echo -n "Pushing rerere cache... "
-		git push $DRY_RUN $rerere_remote HEAD >& /dev/null && echo "Done."
+		git push $DRY_RUN $remote HEAD >& /dev/null && echo "Done."
 	else
 		echo "Fail: Branch setup for the rerere-cache is borked."
 		exit 1
@@ -498,17 +509,19 @@ function dim_rebuild_tip
 # push.
 function dim_push_branch
 {
+	local branch remote
+
 	if [[ "x$1" = "x" ]]; then
 		echo "usage: $dim $subcommand branch"
 		exit 1
 	fi
 
-	local branch=$1
+	branch=$1
 	shift
 
 	assert_branch $branch
 
-	local remote=`branch_to_remote $branch`
+	remote=`branch_to_remote $branch`
 
 	git push $DRY_RUN $remote $branch "$@"
 
@@ -542,20 +555,21 @@ dim_alias_ab=apply-branch
 dim_alias_sob=apply-branch
 function dim_apply_branch
 {
-	local branch=$1
+	local branch file message_id commiter_email patch_from sob
+
+	branch=$1
 	shift
-	local file=`mktemp`
+	file=`mktemp`
 
 	assert_branch $branch
 	assert_repo_clean
 
 	cat > $file
 
-	local message_id=$(message_get_id $file)
+	message_id=$(message_get_id $file)
 
-	local commiter_email=$(git config --get user.email)
-	local patch_from=$(grep "From:" "$file" | head -1)
-	local sob
+	commiter_email=$(git config --get user.email)
+	patch_from=$(grep "From:" "$file" | head -1)
 	if [[ "$patch_from" != *"$commiter_email"* ]] ; then
 		sob=-s
 	fi
@@ -593,7 +607,9 @@ function dim_apply_next_fixes
 
 function dim_cherry_pick
 {
-	local remote=`url_to_remote $drm_tip_ssh`
+	local remote sha sha_short
+
+	remote=`url_to_remote $drm_tip_ssh`
 
 	if [[ "x$1" = "x" ]]; then
 		echo "usage: $dim $subcommand commit-ish"
@@ -694,11 +710,13 @@ function dim_apply_igt
 dim_alias_mp=magic-patch
 function dim_magic_patch
 {
+	local conflict_files
+
 	if [[ "$1" = "-a" ]]; then
 		cd `cat ~/.dim-last-path`
 	fi
 
-	local conflict_files=`patch -p1 | grep "saving rejects" | sed -e "s/.*saving rejects to file \(.*\)/\1/"`
+	conflict_files=`patch -p1 | grep "saving rejects" | sed -e "s/.*saving rejects to file \(.*\)/\1/"`
 
 	if [[ $conflict_files != "" ]] ; then
 		echo conflicts found!
@@ -714,12 +732,14 @@ function dim_magic_patch
 
 function dim_create_branch
 {
+	local branch repo remote
+
 	if [[ "x$1" = "x" ]]; then
 		echo "usage: $dim $subcommand branch [commit-ish]"
 		exit 1
 	fi
-	local branch=$1
-	local repo="drm-intel"
+	branch=$1
+	repo="drm-intel"
 
 	if [[ "x$2" = "x" ]]; then
 		start=HEAD
@@ -734,7 +754,7 @@ function dim_create_branch
 		branch=${branch#*/}
 	fi
 
-	local remote=`repo_to_remote $repo`
+	remote=`repo_to_remote $repo`
 
 	$DRY git branch $branch $start
 	git push $DRY_RUN $remote +$branch --set-upstream
@@ -748,11 +768,13 @@ function dim_create_branch
 
 function dim_remove_branch
 {
+	local branch repo remote
+
 	if [[ "x$1" = "x" ]]; then
 		echo "usage: $dim $subcommand branch"
 		exit 1
 	fi
-	local branch=$1
+	branch=$1
 
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
 
@@ -768,14 +790,14 @@ function dim_remove_branch
 
 	cd $DIM_PREFIX/drm-tip
 
-	local repo=`branch_to_repo $branch`
+	repo=`branch_to_repo $branch`
 
 	if [[ $repo == "" ]] ; then
 		echoerr "$branch not found in $integration_config"
 		exit 1
 	fi
 
-	local remote=`repo_to_remote $repo`
+	remote=`repo_to_remote $repo`
 
 	git push $DRY_RUN $remote --delete $branch
 	$DRY git fetch $remote --prune
@@ -803,15 +825,17 @@ function dim_cd
 dim_alias_co=checkout
 function dim_checkout
 {
+	local branch repo remote
+
 	if [[ "x$1" = "x" ]]; then
 		echo "usage: $dim $subcommand branch"
 		exit 1
 	fi
-	local branch=$1
+	branch=$1
 
 	dim_cd $branch
 	if [[ `git branch --list $branch` ==  "" ]] ; then
-		local repo=`branch_to_repo $branch`
+		repo=`branch_to_repo $branch`
 
 		if [[ $branch == "drm-intel-next" ]] ; then
 			repo="drm-intel"
@@ -822,7 +846,7 @@ function dim_checkout
 			exit 1
 		fi
 
-		local remote=`repo_to_remote $repo`
+		remote=`repo_to_remote $repo`
 
 		if [ "$remote" == "" ] ; then
 			exit 1
@@ -852,18 +876,24 @@ function dim_conf
 # $1 is the git sha1 to check
 function checkpatch_commit
 {
-	local commit=$1
-	local cmd="git show --pretty=email $commit"
+	local commit cmd bug_lines non_i915_files
+
+	commit=$1
+	cmd="git show --pretty=email $commit"
 
 	git --no-pager log --oneline -1 $commit
 	$cmd | scripts/checkpatch.pl -q --emacs --strict - || true
 
+	# FIXME: this relies on local assignment not failing on command
+	# substitution failures
 	local bug_lines=$($cmd | grep -m 1 -B 1 '^\+.*\WBUG' | grep -c '^[+-].*\WBUG')
 	if test "$bug_lines" -eq 1; then
 		warn_or_fail "New BUG macro added"
 	fi
 
         if [ "$branch" = "drm-intel-next-queued" ]; then
+		# FIXME: this relies on local assignment not failing on command
+		# substitution failures
 		local non_i915_files=$(git diff-tree --no-commit-id --name-only -r $commit | \
 			grep -v "^\(drivers/gpu/drm/i915/\|include/drm/i915\|include/uapi/drm/i915\)")
 
@@ -891,7 +921,9 @@ dim_alias_check_patch=checkpatch
 dim_alias_cp=checkpatch
 function dim_checkpatch
 {
-	local range=$(rangeish "$1")
+	local range
+
+	range=$(rangeish "$1")
 
 	for commit in $(git rev-list --reverse $range); do
 		checkpatch_commit $commit || true
@@ -900,7 +932,9 @@ function dim_checkpatch
 
 function dim_sparse
 {
-	local range=$(rangeish "$1")
+	local range
+
+	range=$(rangeish "$1")
 
 	make $DIM_MAKE_OPTIONS
 	touch --no-create `git diff --name-only $range` `git diff --name-only`
@@ -943,11 +977,13 @@ function prep_pull_mail_signature
 # without tags, print a reminder
 function prep_pull_mail_overview
 {
+	local obj
+
 	if [ "$#" = "0" ]; then
 		echo "*** insert pull request overview here ***"
 	else
 		for tag in $@ ; do
-			local obj=`git rev-parse $tag`
+			obj=`git rev-parse $tag`
 			if [[ `git cat-file -t $obj` == "tag" ]] ; then
 				echo $tag:
 				git cat-file -p $obj | tail -n+6
@@ -967,9 +1003,10 @@ function prep_pull_mail
 
 function dim_create_workdir
 {
-	cd $DIM_PREFIX
 	local branches
 
+	cd $DIM_PREFIX
+
 	if [[ "x$1" = "x" ]]; then
 		echo "usage: $dim $subcommand branch|all"
 		exit 1
@@ -1013,9 +1050,11 @@ function dim_for_each_workdirs
 
 function dim_update_next
 {
+	local remote
+
 	assert_branch drm-intel-next-queued
 
-	local remote=`url_to_remote $drm_tip_ssh`
+	remote=`url_to_remote $drm_tip_ssh`
 
 	git pull --ff-only
 
@@ -1046,9 +1085,11 @@ function dim_update_next
 
 function dim_update_next_continue
 {
+	local remote
+
 	assert_branch drm-intel-next-queued
 
-	local remote=`url_to_remote $drm_tip_ssh`
+	remote=`url_to_remote $drm_tip_ssh`
 
 	git push $DRY_RUN -f $DIM_DRM_INTEL_REMOTE drm-intel-next-queued:drm-intel-next
 	tag=drm-intel-next-$today
@@ -1107,14 +1148,16 @@ function dim_tag_next
 # dim_pull_request branch upstream
 function dim_pull_request
 {
+	local branch upstream remote repo url git_url
+
 	if [[ "x$1" = "x" || "x$2" = "x" ]]; then
 		echo "usage: $dim $subcommand branch upstream"
 		exit 1
 	fi
 
-	local branch=$1
-	local upstream=$2
-	local remote=`branch_to_remote $branch`
+	branch=$1
+	upstream=$2
+	remote=`branch_to_remote $branch`
 
 	if [ "$branch" != "drm-intel-next" ]; then
 		assert_branch $branch
@@ -1131,18 +1174,18 @@ function dim_pull_request
 		prep_pull_mail $drm_intel_next_tags
 		tag=`git describe --all --exact $branch@{upstream}`
 
-		local repo="drm-intel"
+		repo="drm-intel"
 	else
 		tag=$branch-$today
 		$DRY git tag -f $tag $branch@{upstream}
 		$DRY git push -f $remote $tag
 		prep_pull_mail
 
-		local repo=`branch_to_repo $branch`
+		repo=`branch_to_repo $branch`
 	fi
 
-	local url=${drm_tip_repos[$repo]}
-	local git_url=`echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/'`
+	url=${drm_tip_repos[$repo]}
+	git_url=`echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/'`
 
 	git request-pull $upstream $git_url $tag >> ~/tmp/dim-pull-request
 	$DRY $DIM_MUA -s "[PULL] $branch" \
@@ -1175,7 +1218,9 @@ function dim_pull_request_next_fixes
 # Note: used by bash completion
 function dim_list_upstreams
 {
-	local dim_drm_upstream_remote=`url_to_remote $drm_upstream_git`
+	local dim_drm_upstream_remote
+
+	dim_drm_upstream_remote=`url_to_remote $drm_upstream_git`
 	echo origin/master
 	echo $dim_drm_upstream_remote/drm-next
 	echo $dim_drm_upstream_remote/drm-fixes
@@ -1190,6 +1235,8 @@ function dim_list_branches
 dim_alias_ub=update-branches
 function dim_update_branches
 {
+	local repo remote
+
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
 	for remote in $DIM_DRM_INTEL_REMOTE `url_to_remote $drm_upstream_git` origin; do
 		git fetch -q $remote || true
@@ -1199,8 +1246,8 @@ function dim_update_branches
 
 	for branch in $dim_branches ; do
 		dim_checkout $branch
-		local repo=`branch_to_repo $branch`
-		local remote=`repo_to_remote $repo`
+		repo=`branch_to_repo $branch`
+		remote=`repo_to_remote $repo`
 
 		if git diff --quiet $remote/$branch; then
 			$DRY git rebase
@@ -1216,10 +1263,11 @@ function dim_update_branches
 
 function setup_aux_checkout # name url directory
 {
-	local name=$1
-	local url=$2
-	local dir=$3
-	local remote
+	local name url dir remote
+
+	name=$1
+	url=$2
+	dir=$3
 
 	echo "Setting up $dir ..."
 
@@ -1299,7 +1347,9 @@ function dim_setup
 
 function assert_branch
 {
-	local branch=$1
+	local branch
+
+	branch=$1
 
 	dim_cd $branch
 
@@ -1341,12 +1391,14 @@ function dim_cat_to_fixup
 
 function dim_tc
 {
+	local tag dim_drm_upstream_remote
+
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
-	local tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1)
+	tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1)
 	if [[ -n "$tag" ]]; then
 		echo "$tag"
 	else
-		local dim_drm_upstream_remote=`url_to_remote $drm_upstream_git`
+		dim_drm_upstream_remote=`url_to_remote $drm_upstream_git`
 		# not in a tagged release, show upstream branches
 		git branch -r --contains $1 \
 		    $DIM_DRM_INTEL_REMOTE/* \
@@ -1358,7 +1410,9 @@ function dim_tc
 
 function dim_cite
 {
-	local sha1=$1
+	local sha1
+
+	sha1=$1
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
 
 	git log -1 $sha1 "--pretty=format:%H (\"%s\")%n" | \
@@ -1367,8 +1421,10 @@ function dim_cite
 
 function dim_fixes
 {
+	local sha1 tag
+
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
-	local sha1=$1
+	sha1=$1
 
 	echo "Fixes: $(dim_cite $sha1)"
 
@@ -1379,7 +1435,7 @@ function dim_fixes
 		git show $sha1 | scripts/get_maintainer.pl  --email --norolestats --pattern-depth 1 | sed -e "s/^/Cc: /"
 	) | awk '!x[$0]++'
 
-	local tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1)
+	tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1)
 	if [[ -n "$tag" ]]; then
 		if echo "$tag" | grep -q -e "-rc" ; then
 			echo "Cc: <drm-intel-fixes@lists.freedesktop.org> # ${tag}+"
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [dim PATCH v2 4/7] dim: return exit status instead of actually exiting from url_to_remote
  2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 2/7] dim: fix references to anything "nightly" in dim and documentation Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 3/7] dim: do not do local variable assignments in declaration Jani Nikula
@ 2016-11-24 15:32 ` Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 5/7] dim: fix list-upstreams when not in a git repo or with a drm upstream in place Jani Nikula
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

This lets us handle url_to_remote failures gracefully where they're not
fatal. Our use of 'set -e' guarantees this will bail out otherwise.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dim b/dim
index 1d52d509450d..3c7b6fc1343b 100755
--- a/dim
+++ b/dim
@@ -205,7 +205,7 @@ function url_to_remote # url
 
 	if [[ -z "$url" ]]; then
 		echoerr "$0 without url"
-		exit 1
+		return 1
 	fi
 
 	remote=$(git remote -v | grep -m 1 "$url" | cut -f 1)
@@ -215,10 +215,12 @@ function url_to_remote # url
 		echoerr "Please set it up using:"
 		echoerr "    $ git remote add <name> $url"
 		echoerr "with a name of your choice."
-		exit 1
+		return 1
 	fi
 
 	echo $remote
+
+	return 0
 }
 
 function branch_to_remote # branch
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [dim PATCH v2 5/7] dim: fix list-upstreams when not in a git repo or with a drm upstream in place
  2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
                   ` (2 preceding siblings ...)
  2016-11-24 15:32 ` [dim PATCH v2 4/7] dim: return exit status instead of actually exiting from url_to_remote Jani Nikula
@ 2016-11-24 15:32 ` Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 6/7] dim: check positional parameter on dim fixes and cite Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 7/7] dim: unify rebuild fetch/merge messages Jani Nikula
  5 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

'dim list-upstreams' is needed by bash completion and is used outside of
git repos, also within git repos without drm upstream, so don't fail if
it can be avoided.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dim b/dim
index 3c7b6fc1343b..76e129de873d 100755
--- a/dim
+++ b/dim
@@ -1222,7 +1222,11 @@ function dim_list_upstreams
 {
 	local dim_drm_upstream_remote
 
-	dim_drm_upstream_remote=`url_to_remote $drm_upstream_git`
+	# Handle failures gracefully
+	if ! dim_drm_upstream_remote=$(url_to_remote $drm_upstream_git 2>/dev/null); then
+		return 0
+	fi
+
 	echo origin/master
 	echo $dim_drm_upstream_remote/drm-next
 	echo $dim_drm_upstream_remote/drm-fixes
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [dim PATCH v2 6/7] dim: check positional parameter on dim fixes and cite
  2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
                   ` (3 preceding siblings ...)
  2016-11-24 15:32 ` [dim PATCH v2 5/7] dim: fix list-upstreams when not in a git repo or with a drm upstream in place Jani Nikula
@ 2016-11-24 15:32 ` Jani Nikula
  2016-11-24 15:32 ` [dim PATCH v2 7/7] dim: unify rebuild fetch/merge messages Jani Nikula
  5 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/dim b/dim
index 76e129de873d..69c22f6206f0 100755
--- a/dim
+++ b/dim
@@ -1419,6 +1419,11 @@ function dim_cite
 	local sha1
 
 	sha1=$1
+	if [[ -z "$sha1" ]]; then
+		echoerr "usage: $dim $subcommand <commit-ish>"
+		return 1
+	fi
+
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
 
 	git log -1 $sha1 "--pretty=format:%H (\"%s\")%n" | \
@@ -1429,9 +1434,13 @@ function dim_fixes
 {
 	local sha1 tag
 
-	cd $DIM_PREFIX/$DIM_DRM_INTEL
 	sha1=$1
+	if [[ -z "$sha1" ]]; then
+		echoerr "usage: $dim $subcommand <commit-ish>"
+		return 1
+	fi
 
+	cd $DIM_PREFIX/$DIM_DRM_INTEL
 	echo "Fixes: $(dim_cite $sha1)"
 
 	(
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [dim PATCH v2 7/7] dim: unify rebuild fetch/merge messages
  2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
                   ` (4 preceding siblings ...)
  2016-11-24 15:32 ` [dim PATCH v2 6/7] dim: check positional parameter on dim fixes and cite Jani Nikula
@ 2016-11-24 15:32 ` Jani Nikula
  5 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dim b/dim
index 69c22f6206f0..2b58a0cd7ddc 100755
--- a/dim
+++ b/dim
@@ -420,7 +420,7 @@ function dim_rebuild_tip
 	for repo in "${!drm_tip_repos[@]}"; do
 		url=${drm_tip_repos[$repo]}
 		remote=$(url_to_remote $url)
-		echo -n "Fetching $repo (as $remote) ... "
+		echo -n "Fetching $repo (local remote $remote)... "
 		# git fetch returns 128 if there's nothing to be fetched
 		git fetch -q $remote || true
 		echo "Done."
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [dim PATCH v2 3/7] dim: do not do local variable assignments in declaration
  2016-11-24 15:32 ` [dim PATCH v2 3/7] dim: do not do local variable assignments in declaration Jani Nikula
@ 2016-11-24 15:37   ` Jani Nikula
  0 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2016-11-24 15:37 UTC (permalink / raw)
  To: intel-gfx

On Thu, 24 Nov 2016, Jani Nikula <jani.nikula@intel.com> wrote:
> @@ -852,18 +876,24 @@ function dim_conf
>  # $1 is the git sha1 to check
>  function checkpatch_commit
>  {
> -	local commit=$1
> -	local cmd="git show --pretty=email $commit"
> +	local commit cmd bug_lines non_i915_files
> +
> +	commit=$1
> +	cmd="git show --pretty=email $commit"
>  
>  	git --no-pager log --oneline -1 $commit
>  	$cmd | scripts/checkpatch.pl -q --emacs --strict - || true
>  
> +	# FIXME: this relies on local assignment not failing on command
> +	# substitution failures
>  	local bug_lines=$($cmd | grep -m 1 -B 1 '^\+.*\WBUG' | grep -c '^[+-].*\WBUG')
>  	if test "$bug_lines" -eq 1; then
>  		warn_or_fail "New BUG macro added"
>  	fi
>  
>          if [ "$branch" = "drm-intel-next-queued" ]; then
> +		# FIXME: this relies on local assignment not failing on command
> +		# substitution failures

v2 here was just a straightforward rebase except for these two fixmes
for when we actually (probably accidentally) rely on this behaviour.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-24 15:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24 15:32 [dim PATCH v2 1/7] dim: rename rebuild-nightly to rebuild-tip Jani Nikula
2016-11-24 15:32 ` [dim PATCH v2 2/7] dim: fix references to anything "nightly" in dim and documentation Jani Nikula
2016-11-24 15:32 ` [dim PATCH v2 3/7] dim: do not do local variable assignments in declaration Jani Nikula
2016-11-24 15:37   ` Jani Nikula
2016-11-24 15:32 ` [dim PATCH v2 4/7] dim: return exit status instead of actually exiting from url_to_remote Jani Nikula
2016-11-24 15:32 ` [dim PATCH v2 5/7] dim: fix list-upstreams when not in a git repo or with a drm upstream in place Jani Nikula
2016-11-24 15:32 ` [dim PATCH v2 6/7] dim: check positional parameter on dim fixes and cite Jani Nikula
2016-11-24 15:32 ` [dim PATCH v2 7/7] dim: unify rebuild fetch/merge messages Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox