[llvm] r359939 - Make the git-llvm script work on older git versions that don't support git rev-parse --git-common-dir.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 15:03:30 PDT 2019


Author: ctopper
Date: Fri May  3 15:03:29 2019
New Revision: 359939

URL: http://llvm.org/viewvc/llvm-project?rev=359939&view=rev
Log:
Make the git-llvm script work on older git versions that don't support git rev-parse --git-common-dir.

Not all versions of git support git rev-parse --git-common-dir. Rather than erorr or print any kind of
useful error, they just print back '--git-common-dir' instead of a directory. The git-llvm script
ends up taking this '--git-common-dir' as a diretory name to use.

Not sure exactly what happens after that, but the end result is that the 'git llvm push' ends up
looking like it pushed your commits, but really did nothing.

This patch makes the script detect the bogus directory name for --git-common-dir and falls back to using --git-dir instead.

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=359939&r1=359938&r2=359939&view=diff
==============================================================================
--- llvm/trunk/utils/git-svn/git-llvm (original)
+++ llvm/trunk/utils/git-svn/git-llvm Fri May  3 15:03:29 2019
@@ -392,6 +392,11 @@ def cmd_push(args):
 
     # We need a staging area for SVN, let's hide it in the .git directory.
     dot_git_dir = git('rev-parse', '--git-common-dir')
+    # Not all versions of git support --git-common-dir and just print the
+    # unknown command back. If this happens, fall back to --git-dir
+    if dot_git_dir == '--git-common-dir':
+      dot_git_dir = git('rev-parse', '--git-dir')
+
     svn_root = os.path.join(dot_git_dir, 'llvm-upstream-svn')
     svn_init(svn_root)
 




More information about the llvm-commits mailing list