diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-11-23 11:53:51 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-11-23 11:53:51 -0200 |
commit | 77323523c9aed412bf119bf7b827ce7f53350c77 (patch) | |
tree | 67f7ec6f5d7f823638b8e94fdc7997aef1b70d74 /git-submodule-checkout-branch | |
parent | db8aaf5f8f0886c8aad9abfc504685e49e70b39c (diff) | |
download | utils-git-77323523c9aed412bf119bf7b827ce7f53350c77.tar.gz utils-git-77323523c9aed412bf119bf7b827ce7f53350c77.tar.bz2 |
Refactor checkout branch scripts
Diffstat (limited to 'git-submodule-checkout-branch')
-rwxr-xr-x | git-submodule-checkout-branch | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/git-submodule-checkout-branch b/git-submodule-checkout-branch deleted file mode 100755 index 6613bf4..0000000 --- a/git-submodule-checkout-branch +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# Checkout branche a submodule. -# - -# Parameters -BASENAME="`basename $0`" - -# Checkout the branch containing a commit -function checkout_branch { - # Check if we are in a detached HEAD - if git branch | grep -q '* (HEAD detached'; then - # Determine the commit we're in - local commit="`git log -n 1 | head -1 | cut -d ' ' -f 2`" - - # Get the first remote branch that contains our commit - # - # In the future some criteria might be stablished to determine how to decide - # if the comment is present in more than one branch. Which one to prioritize? - # A topic branch in the form of "feature/"? The "develop" branch? - local branch="`git branch -r --contains $commit 2> /dev/null | grep -v 'HEAD' | head -1 | sed -e 's|^[^/]*/||'`" - - # Checkout to the given commit - if [ ! -z "$branch" ]; then - git checkout $branch - else - echo "$BASENAME: no such branch containing dangling commit $commit" - fi - fi -} - -# Dispatch -checkout_branch |