cmd: rename with_keep_cwd to keep_cwd
authorDavid Aguilar <davvid@gmail.com>
Mon, 16 Jun 2008 00:03:53 +0000 (17:03 -0700)
committerDavid Aguilar <davvid@gmail.com>
Mon, 16 Jun 2008 00:03:53 +0000 (17:03 -0700)
Having execute() use a different directory is an important piece
of API information so I added more documentation about it and
renamed the flag to just "keep_cwd" since that's shorter and simpler.

Signed-off-by: David Aguilar <davvid@gmail.com>
lib/git/cmd.py

index bd8da4caef5a016424c089b8baa43e43697e61b3..029fcbc90e100c49d4534b9a15609c2d6d930186 100644 (file)
@@ -77,11 +77,11 @@ class Git(MethodMissingMixin):
 
     def execute(self, command,
                 istream=None,
+                keep_cwd=False,
                 with_status=False,
                 with_stderr=False,
                 with_exceptions=False,
                 with_raw_output=False,
-                with_keep_cwd=False,
                 ):
         """
         Handles executing the command on the shell and consumes and returns
@@ -93,6 +93,11 @@ class Git(MethodMissingMixin):
         ``istream``
             Standard input filehandle passed to subprocess.Popen.
 
+        ``keep_cwd``
+            Whether to use the current working directory from os.getcwd().
+            GitPython uses get_work_tree() as its working directory by
+            default and get_git_dir() for bare repositories.
+
         ``with_status``
             Whether to return a (status, str) tuple.
 
@@ -105,9 +110,6 @@ class Git(MethodMissingMixin):
         ``with_raw_output``
             Whether to avoid stripping off trailing whitespace.
 
-        ``with_keep_cwd``
-            Whether to use the current working directory from os.getcwd().
-
         Returns
             str(output)                     # with_status = False (Default)
             tuple(int(status), str(output)) # with_status = True
@@ -124,7 +126,7 @@ class Git(MethodMissingMixin):
             stderr = subprocess.PIPE
 
         # Allow the user to have the command executed in their working dir.
-        if with_keep_cwd:
+        if keep_cwd:
           cwd = os.getcwd()
         else:
           cwd=self._cwd
@@ -214,11 +216,11 @@ class Git(MethodMissingMixin):
         # Handle optional arguments prior to calling transform_kwargs
         # otherwise these'll end up in args, which is bad.
         istream = kwargs.pop("istream", None)
+        keep_cwd = kwargs.pop("keep_cwd", None)
         with_status = kwargs.pop("with_status", None)
         with_stderr = kwargs.pop("with_stderr", None)
         with_exceptions = kwargs.pop("with_exceptions", None)
         with_raw_output = kwargs.pop("with_raw_output", None)
-        with_keep_cwd = kwargs.pop("with_keep_cwd", None)
 
         # Prepare the argument list
         opt_args = self.transform_kwargs(**kwargs)
@@ -230,9 +232,9 @@ class Git(MethodMissingMixin):
 
         return self.execute(call,
                             istream = istream,
+                            keep_cwd = keep_cwd,
                             with_status = with_status,
                             with_stderr = with_stderr,
                             with_exceptions = with_exceptions,
                             with_raw_output = with_raw_output,
-                            with_keep_cwd = with_keep_cwd,
                             )