# #11 - .git directory handling #15

Merged
merged 2 commits into from Mar 20, 2012

## Conversation

Projects
None yet
2 participants
Contributor

### ChrisWay commented Mar 19, 2012

 Added handling if the user selects a .git directory and also default to the user's My Documents folder when first choosing "Browse Repository". How should the case be handled if the user selects a non git directory (so monitoring is started), changes to a .git directory and then creates a git repo in the original dir that is being monitored? Currently the graph will switch back the monitored dir, not likely to happen but you never know! Should the monitoring be aborted when choosing an existing git repo or is the current behavior correct?

### ChrisWay added some commits Mar 19, 2012

 #11 - Added handling for when passed a .git directory. Also default d… 
…irectory picker to the user's My Documents folder.
 9fab7d0 
 Made sure the last directory the user selected is remembered and set … 
…to the starting one if they browse for another repository.
 e9b0d75 

### Haacked reviewed Mar 20, 2012

 - var folderName = Path.GetDirectoryName(path) ?? ""; - if (folderName.Equals(".git", StringComparison.OrdinalIgnoreCase)) + //If we are passed a .git directory, just return it straightaway + if (path.EndsWith(".git", StringComparison.OrdinalIgnoreCase))

#### Haacked Mar 20, 2012

Owner

Probably better to use the path methods here. For example, in theory it could get a path with a trailing slash (though not sure if that'll actually happen).

Path.GetFolderName(path)


Or something like that should do the trick. :)

Owner

### Haacked commented Mar 20, 2012

 Apart from the one change I suggested, this looks great. Thanks! I'm going to merge it in now anyways.

### Haacked added a commit that referenced this pull request Mar 20, 2012

 Merge pull request #15 from ChrisWay/GitDirectory 
#11 - .git directory handling
 b413038 

Owner

### Haacked commented Mar 20, 2012

 I forgot to comment on your question. If I understand correctly, the sequence is: Open up c:\foo which does not contain a git repo. Then use the file browser to select c:\bar\ which does have a git directory. Then runs git init in c:\foo and SeeGit starts monitoring c:\foo again? If so, that's definitely a bug. When we use the folder browser to select a folder, we should dispose all previous file monitors.
Contributor

### ChrisWay commented Mar 20, 2012

 Thanks Phil, I'll make that change tonight and that sequence is correct. Presumably to cancel the file monitors you need to hold on to the IDisposable that is returned from Subscribe and then call Dispose?
Owner

### Haacked commented Mar 20, 2012

 Yeah, it looks that way. On Tue, Mar 20, 2012 at 12:08 AM, Chris Way < reply@reply.github.com wrote: Thanks Phil, I'll make that change tonight and that sequence is correct. Presumably to cancel the file monitors you need to hold on to the IDisposable that is returned from Subscribe and then call Dispose? Reply to this email directly or view it on GitHub: #15 (comment)

### ChrisWay added a commit to ChrisWay/SeeGit that referenced this pull request Mar 20, 2012

 Changed the directory handling slightly as mentioned in the comments on 
#15. Using DirectoryInfo as Path doesn't have a simple way of grabbing the last dir in a path.
 224ff70 

### ChrisWay added a commit to ChrisWay/SeeGit that referenced this pull request Mar 20, 2012

 Implemented cancelling of repository watching if the user selects a d… 
…ifferent directory as per discussion in #15.
 a27a817 

Closed