Permalink
Browse files

Adding git-tracks -d (defaults to origin/master).

  • Loading branch information...
1 parent 6f87e94 commit 5a498f79071dda1229594a24acbe12a33da5f4dd @jlebar committed Jul 17, 2012
Showing with 23 additions and 10 deletions.
  1. +1 −1 git-edit-files
  2. +3 −3 git-push-to-hg
  3. +1 −1 git-qapplied
  4. +5 −2 git-qparent
  5. +13 −3 git-tracks
View
@@ -8,7 +8,7 @@ If no revision is given, invoke \$EDITOR on the files modified in the current br
fi
if [[ "$1" == "" ]]; then
- revs="$(git merge-base $(git-tracks) HEAD)..HEAD"
+ revs="$(git merge-base $(git-tracks -d) HEAD)..HEAD"
else
if ! echo "$1" | grep -q '\.\.'; then
revs="$1^..$1"
View
@@ -6,7 +6,7 @@ set -e
#
# If no commit range is specified, we push
#
-# $(git merge-base $(git-tracks) HEAD)..HEAD.
+# $(git merge-base $(git-tracks -d) HEAD)..HEAD.
#
# Otherwise, we push the commit(s) given.
@@ -45,7 +45,7 @@ fi
revs="$2"
if [[ "$revs" == "" ]]; then
- revs="$(git merge-base HEAD $(git tracks))..HEAD"
+ revs="$(git merge-base HEAD $(git tracks -d))..HEAD"
fi
# If revs doesn't contain "..", add "$revs^.." to the beginning.
@@ -72,7 +72,7 @@ function hg_cmd() {
}
first_rev=$(echo "$revs" | sed -e 's/\.\..*//')
-git_parent_rev=$(git merge-base $first_rev $(git tracks))
+git_parent_rev=$(git merge-base $first_rev $(git tracks -d))
# Run git-to-hg-commit, and only run hg pull if it fails.
if [[ "$push_to_tip" == "0" ]]; then
View
@@ -6,5 +6,5 @@
set -e
PATH="$(dirname $0):$PATH"
-echo "On branch $(git branch | grep '^\*' | sed 's/^\* //')."
+echo "On branch $(git branch | grep '^\*' | sed 's/^\* //') (downstream from $(git tracks -d))"
git log --reverse --date-order --pretty=oneline --abbrev-commit $(git qparent)..HEAD
View
@@ -1,6 +1,9 @@
#!/bin/bash
-# Like |hg qparent|, gives last common revision between HEAD and upstream.
+# Like |hg qparent|, gives last common revision between HEAD and upstream
+#
+# The upstream branch is set via git branch --set-upstream <branch> <upstream>.
+# If no upstream branch has been explicitly set, we use origin/master.
PATH="$(dirname $0):$PATH"
-git merge-base HEAD $(git tracks)
+git merge-base HEAD $(git tracks -d)
View
@@ -1,15 +1,25 @@
#!/bin/bash
#
+# Get the upstream branch for the current branch. If -d/--default is passed,
+# outputs origin/master if there's no upstream branch.
+#
+# To set <branch>'s upstream branch, run
+#
+# $ git branch --set-upstream <branch> <upstream>
+#
+#
# Based on http://serverfault.com/a/352236/38694
branch=$(git symbolic-ref HEAD) || exit $?
branch=${branch##refs/heads/}
-remote=$(git config "branch.${branch}.remote") || exit $?
-remoteBranch=$(git config "branch.${branch}.merge") || exit $?
+remote=$(git config "branch.${branch}.remote" || echo '.')
+remoteBranch=$(git config "branch.${branch}.merge" || echo '')
remoteBranch=${remoteBranch##refs/heads/}
if [[ "$remote" != "." ]]; then
echo "${remote:?}/${remoteBranch:?}"
-else
+elif [[ "$remoteBranch" != "" ]]; then
echo "${remoteBranch:?}"
+elif [[ "$1" == '-d' || "$1" == '--default' ]]; then
+ echo "origin/master"
fi

0 comments on commit 5a498f7

Please sign in to comment.