]> granicus.if.org Git - llvm/commitdiff
[git-llvm] Do not reinvent `@{upstream}`
authorDavid Zarzycki <dave@znu.io>
Sat, 7 Sep 2019 06:44:52 +0000 (06:44 +0000)
committerDavid Zarzycki <dave@znu.io>
Sat, 7 Sep 2019 06:44:52 +0000 (06:44 +0000)
Make `git-llvm` more robust when used with a nontrivial repository.

https://reviews.llvm.org/D67262

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371290 91177308-0d34-0410-b5e6-96231b3b80d8

utils/git-svn/git-llvm

index 549a45558dd4920d50680d0a0a7ec91eac1ee7e6..e03479a6df1a4f791abb1cbb265f1a460037eade 100755 (executable)
@@ -190,16 +190,8 @@ def program_exists(cmd):
 
 
 def get_default_rev_range():
-    # Get the branch tracked by the current branch, as set by
-    # git branch --set-upstream-to  See http://serverfault.com/a/352236/38694.
-    cur_branch = git('rev-parse', '--symbolic-full-name', 'HEAD')
-    upstream_branch = git('for-each-ref', '--format=%(upstream:short)',
-                          cur_branch)
-    if not upstream_branch:
-        upstream_branch = 'origin/master'
-
     # Get the newest common ancestor between HEAD and our upstream branch.
-    upstream_rev = git('merge-base', 'HEAD', upstream_branch)
+    upstream_rev = git('merge-base', 'HEAD', '@{upstream}')
     return '%s..' % upstream_rev
 
 
@@ -637,9 +629,7 @@ if __name__ == '__main__':
         metavar='GIT_REVS',
         type=str,
         nargs='?',
-        help="revs to push (default: everything not in the branch's "
-        'upstream, or not in origin/master if the branch lacks '
-        'an explicit upstream)')
+        help="revs to push (default: everything not in the upstream branch).")
     parser_push.set_defaults(func=cmd_push)
 
     parser_revert = subcommands.add_parser(