[PATCH rdma-core] Fix kernel-headers/update to work with 'git rebase -i' exec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The expected workflow for this script is to be used as part of interactive
rebase where the 'Update kernel headers' commit is dropped and replaced
with something like

  exec kernel-headers/update ../linux e818e255a58d64e86c8c93e3aa52498b1a3d1760

However, some versions of git invoke git base with GIT_DIR set in the
environment which prevents the script from reading data from the kerenl
git.

Clear harmful git environment variables before changing git repos.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
 kernel-headers/update | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/kernel-headers/update b/kernel-headers/update
index 7824993ebb7326..6bdf73be696df6 100755
--- a/kernel-headers/update
+++ b/kernel-headers/update
@@ -33,11 +33,20 @@ def in_directory(dir):
     """Context manager that chdirs into a directory and restores the original
     directory when closed."""
     cdir = os.getcwd();
+    old_env = {};
     try:
+        # git rebase invokes its exec with a bunch of git variables set that
+        # prevent us from invoking git in another tree, blow them away.
+        for k in list(os.environ.keys()):
+            if k.startswith("GIT"):
+                old_env[k] = os.environ[k];
+                del os.environ[k];
+
         os.chdir(dir);
         yield True;
     finally:
         os.chdir(cdir);
+        os.environ.update(old_env);
 
 def copy_objects(args):
     """Copy the uapi header objects from the kernel repo at the commit indicated
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux