GNOME Bugzilla – Bug 536551
vc/git.py to identify a git directory by the environment variable GIT_DIR being set
Last modified: 2009-04-03 18:42:22 UTC
It would be nice for meld to recognise a directory as under git version control though the setting of the environment variable, GIT_DIR.
Created attachment 112106 [details] [review] Here is a simple hack, (I don't know python very well, so it may be wrong!) Here is a simple hack, (I don't know python very well, so it may be wrong!) There may be a more elegant way, through a git command to identify the directory is under git control.
What is wrong with checking for .git? Please explain the problem you are trying to solve.
Sometimes you might have a directory that you are using under git revision, but don't want a .git directory in there... A way to store the repository information elsewhere is to set the environment variable GIT_DIR. For example: you have access to a server, and can read /etc/apache.d/ but don't have write permissions, (someone else is maintaining that machine, but you'd liked to review what changes occured since the last time your application worked! :P). you can do: $ cd /etc/apache.d/ $ export GIT_DIR=/home/me/APACHE_GIT_DIR/ $ cg-status .. etc.. $ cg-commit -m 'changes made today' But, there are many more instances where it's handy not to have the .git directory in the location of the files under the repository than I could describe! (in my case I was using eclipse to grep through the files.. it took ages since it was grep-ing through the .git directory!) Pierre
Oh, to *answer your question* there is NOTHING wrong with checking for .git. (and my patch left that bit in there). It's just that meld should ALSO test for the GIT_DIR environment variable being set.
Created attachment 112170 [details] [review] Updated patch What happens if your were to navigate to GIT_DIR instead? Does git know the tracked location and would the git commands work as expected? Environment variables are a bit weird for a gui, though I've updated the patch if you'd like to test.
What happens if your were to navigate to GIT_DIR instead? - Um, now why would you do that? You run git in the directory being tracked! Does git know the tracked location and would the git commands work as expected? - No, git doesn't know the tracked location, except that it assumes that the current directory IS the tracked location. Environment variables are a bit weird for a gui, - I take it you mean for the person who starts everything from non-command line. .. sure but only a fool would globally set GIT_DIR for his system! though I've updated the patch if you'd like to test. - YUP! not problem, it works :D Pierre
Oops! Spoke to soon. Your patch doesn't quite work for me!!! Well, I can't completely confirm it not to work on latest SVN.. I'm actually using git / meld at work, and don't want to mess with the installed version of "meld" on this computer too much too much. I'll review it later tonight..
Ok, I've done a more thorough test, comparing your patch to mine. When I initially used your patch, I thought it was working, but it seems it isn't. To replicate my test, install git/cogito and perform: # -- uninstall system meld, install meld from svn ~ $ mkdir test ~ $ cd test ~/test $ cg-init -m 'a demo repository' #...continue commit in editor... ~/test $ mkdir ../test2 ~/test $ mv .git/ ../test2/ ~/test $ echo "hello" > test ~/test $ echo "there" > test2 ~/test $ cg-add test test2 There is no GIT repository here (.git not found) ~/test $ export GIT_DIR=../test2/.git/ ~/test $ cg-add test test2 Adding file test Adding file test2 ~/test $ cg-commit -m 'Some files' A test A test2 Committed as 385e8546fbcc3df8328c3161da0973f58602493d ~/test $ echo wow >> test ~/test $ meld . # git repo not detected ~/test $ ln -s ../test2/.git ~/test $ meld . # Works fine # -- uninstall meld, apply YOUR patch, re-install ~/test $ unset GIT_DIR ~/test $ meld . # Works fine ~/test $ export GIT_DIR=../test2/.git/ ~/test $ meld . # Works fine ~/test $ rm .git ~/test $ meld . # ERROR!! fatal: Not a git repository: '../test2/.git' Failed to find a valid git directory. # -- uninstall meld, apply MY patch, re-install ~/test $ meld . # Works fine Where "works fine" indicates that both the list of changed files appears, and also double clicking on a file shows the differences.. At work, the changed files appeared, but double clicking did not show the difference. Cheer's, Pierre
Created attachment 113083 [details] [review] new patch
Thanks Pierre, I messed up the last patch - the change should be outside the loop so that it falls back to GIT_DIR only if the regular way fails. Stephen.
Does this new patch work?
If I read the current trunk (http://svn.gnome.org/viewvc/meld/trunk/vc/git.py?annotate=1267) correctly, then the patch has already landed. I am thus marking the patch as committed. I assume that it fixed the issue and I am thus closing the bug.