[llvm] r372070 - [git-llvm] Do not reinvent `@{upstream}` (take 2)

David Zarzycki via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 21:44:13 PDT 2019


Author: davezarzycki
Date: Mon Sep 16 21:44:13 2019
New Revision: 372070

URL: http://llvm.org/viewvc/llvm-project?rev=372070&view=rev
Log:
[git-llvm] Do not reinvent `@{upstream}` (take 2)

This makes git-llvm more of a thin wrapper around git while temporarily
maintaining backwards compatibility with past git-llvm behavior.

Using @{upstream} makes git-llvm more robust when used with a nontrivial
local repository.

https://reviews.llvm.org/D67389

Modified:
    llvm/trunk/utils/git-svn/git-llvm

Modified: llvm/trunk/utils/git-svn/git-llvm
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/git-svn/git-llvm?rev=372070&r1=372069&r2=372070&view=diff
==============================================================================
--- llvm/trunk/utils/git-svn/git-llvm (original)
+++ llvm/trunk/utils/git-svn/git-llvm Mon Sep 16 21:44:13 2019
@@ -191,16 +191,16 @@ 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}', ignore_errors=True)
+    if not upstream_rev:
+        eprint("Warning: git-llvm assumes that origin/master is the upstream "
+               "branch but git does not.")
+        eprint("To make this warning go away: git branch -u origin/master")
+        eprint("To avoid this warning when creating branches: "
+               "git checkout -b MyBranchName origin/master")
+        upstream_rev = git('merge-base', 'HEAD', 'origin/master')
+
     return '%s..' % upstream_rev
 
 




More information about the llvm-commits mailing list