After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 536551 - vc/git.py to identify a git directory by the environment variable GIT_DIR being set
vc/git.py to identify a git directory by the environment variable GIT_DIR bei...
Status: RESOLVED FIXED
Product: meld
Classification: Other
Component: general
git master
Other All
: Normal enhancement
: ---
Assigned To: Stephen Kennedy
Stephen Kennedy
Depends on:
Blocks:
 
 
Reported: 2008-06-04 07:14 UTC by Pierre Marc Dumuid
Modified: 2009-04-03 18:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Here is a simple hack, (I don't know python very well, so it may be wrong!) (525 bytes, patch)
2008-06-04 07:16 UTC, Pierre Marc Dumuid
none Details | Review
Updated patch (493 bytes, patch)
2008-06-04 22:42 UTC, Stephen Kennedy
none Details | Review
new patch (487 bytes, patch)
2008-06-19 23:23 UTC, Stephen Kennedy
committed Details | Review

Description Pierre Marc Dumuid 2008-06-04 07:14:12 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.
Comment 1 Pierre Marc Dumuid 2008-06-04 07:16:08 UTC
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.
Comment 2 Stephen Kennedy 2008-06-04 08:37:57 UTC
What is wrong with checking for .git? Please explain the problem you are trying to solve.
Comment 3 Pierre Marc Dumuid 2008-06-04 08:50:41 UTC
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
Comment 4 Pierre Marc Dumuid 2008-06-04 09:00:20 UTC
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.
Comment 5 Stephen Kennedy 2008-06-04 22:42:02 UTC
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.
Comment 6 Pierre Marc Dumuid 2008-06-05 00:36:01 UTC
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
Comment 7 Pierre Marc Dumuid 2008-06-05 00:41:28 UTC
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..



Comment 8 Pierre Marc Dumuid 2008-06-08 11:50:39 UTC
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
Comment 9 Stephen Kennedy 2008-06-19 23:23:09 UTC
Created attachment 113083 [details] [review]
new patch
Comment 10 Stephen Kennedy 2008-06-19 23:24:15 UTC
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.
Comment 11 Stephen Kennedy 2008-09-25 21:53:31 UTC
Does this new patch work?
Comment 12 Tobias Mueller 2009-04-03 18:42:22 UTC
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.