From 83fcf28da0e114501739e4d4360eb1c101cb954c Mon Sep 17 00:00:00 2001 From: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Tue, 22 May 2018 11:04:10 +0200 Subject: [PATCH] dim: Make branch_to_remote more robust The old version relied on branch@{upstream}, which requires that the branch is checked out. Instead use the indirection through the abstract drm-tip repo. v2: Questions from Jani: - We still need the fallback path for non-managed branches like rerere-cache or drm-intel-next. - Also this change removes some of the implicit validation that the branch has a local tracking branch. I only spotted one place where an assert_branch was missing. Cc: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> --- dim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dim b/dim index 0094494..8eb7a3a 100755 --- a/dim +++ b/dim @@ -248,11 +248,18 @@ function pick_protocol_url # (git|ssh|https|whatever) url [url ...] function branch_to_remote # branch { - local branch remote + local branch remote repo branch=$1 - remote=$(git rev-parse --abbrev-ref --symbolic-full-name "$branch@{upstream}") - remote=${remote%%/*} + repo=$(branch_to_repo $branch) + + if [[ -z "$repo" ]] ; then + # fallback for special branches like rerere-cache + remote=$(git rev-parse --abbrev-ref --symbolic-full-name "$branch@{upstream}") + remote=${remote%%/*} + else + remote=$(repo_to_remote $repo) + fi echo $remote } @@ -1837,6 +1844,7 @@ function dim_tag_branch local branch remote tag branch=$1 + assert_branch $branch remote=$(branch_to_remote $branch) cd $DIM_PREFIX/$DIM_REPO -- GitLab