Skip to content

Commit

Permalink
Adding git-tracks -d (defaults to origin/master).
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebar committed Jul 17, 2012
1 parent 6f87e94 commit 5a498f7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion git-edit-files
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions git-push-to-hg
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion git-qapplied
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions git-qparent
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 13 additions & 3 deletions git-tracks
Original file line number Diff line number Diff line change
@@ -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.