meld r1340 - trunk/vc



Author: vincele
Date: Sat Apr 11 22:46:09 2009
New Revision: 1340
URL: http://svn.gnome.org/viewvc/meld?rev=1340&view=rev

Log:
Remove wrong usage of GIT_DIR

According to git documentation:
http://www.kernel.org/pub/software/scm/git/docs/

[...]
GIT_DIR
   If the GIT_DIR environment variable is set then it specifies a
path to use instead of the default .git for the base of the
repository.

GIT_WORK_TREE
   Set the path to the working tree. The value will not be used in
combination with repositories found automatically in a .git directory
(i.e. $GIT_DIR is not set). This can also be controlled by the
--work-tree command line option and the core.worktree configuration
variable.
[...]

and testing with git command line client:

/.../tmp/git$ cd .git
/.../tmp/git/.git$ git status --untracked-files
fatal: This operation must be run in a work tree

the usage we make of GIT_DIR environment variable in git.py is wrong
this environment variable is not pointing to a vc.root directory.

$ cd /tmp
$ mkdir gitrepo
$ mkdir gitwc
$ export GIT_DIR=`pwd`/gitrepo
$ cd gitwc
$ git init
Initialized empty Git repository in /tmp/gitrepo/
$ ls -la
total 8.0K
drwxr-xr-x 2 vince vince 4.0K 2009-04-04 19:43 .
drwxr-xr-x 4 vince vince 4.0K 2009-04-04 19:43 ..
$ ~/dev/svn/meld/trunk/meld .
fatal: This operation must be run in a work tree

Someone motivated could add proper handling of git
environment variable back.

This is where the GIT_DIR code came from:
http://bugzilla.gnome.org/show_bug.cgi?id=536551

GIT_DIR is not a fallback for a wrong location, it is an
alternate path used as the ".git" metadata directory, so
it is not valid as a vc.root, GIT_WORK_TREE would
have been OK instead.

I think an analogy with svn would be:
${GIT_DIR} is equivalent to ${SVNROOT}, i.e. the
server url. (with GIT_DIR being an absolute path)


Modified:
   trunk/vc/git.py

Modified: trunk/vc/git.py
==============================================================================
--- trunk/vc/git.py	(original)
+++ trunk/vc/git.py	Sat Apr 11 22:46:09 2009
@@ -41,14 +41,7 @@
 
     def __init__(self, location):
         self._tree_cache = None
-        try:
-            _vc.Vc.__init__(self, location)
-        except ValueError:
-            gitdir = os.environ.get("GIT_DIR")
-            if gitdir and os.path.isdir(gitdir):
-                self.root = gitdir
-                return
-            raise ValueError()
+        _vc.Vc.__init__(self, location)
 
     def commit_command(self, message):
         return [self.CMD,"commit","-m",message]



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