Re: [PATCH 1/2] Fixes _is_git

2015-02-03 Thread Rémi Rampin
2015-02-02 12:24 UTC-05:00, Remi Rampin remiram...@gmail.com:
  proc _is_git {path} {
 +   if {[file isfile $path]} {
 +   set fp [open $path r]
 +   gets $fp line
 +   close $fp
 +   if {[regexp ^gitdir: (.+)$ $line line link_target]} {

2015-02-03 3:44 UTC-05:00, Chris Packham judge.pack...@gmail.com:
 It might be simpler to use one of the 'string' commands e.g. string
 wordend gitdir:  I also suspect the string functions would be faster
 than regexp but that probably doesn't matter.

I want to check that the file actually begins with gitdir:  and then
extract the path, so I'm not sure if using string functions is that
simple/fast.

 +   return [_is_git [file join [file dirname $path] 
 $link_target]]

 Do we want to avoid pathological cases of infinite recursion? Someone
 would have to maliciously create such a situation.

Limiting the recursion is very simple, but I'm not sure people are
supposed to stumble on that. More importantly this probably calls for a
different error message, thus a new error result that I am not ready to
implement. But it could be another patch.
But I suppose I can add a simple return 0 limit to the recursion if
needed, let me know.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] Makes _do_open2 set _gitdir to actual path

2015-02-03 Thread Rémi Rampin
2015-02-02 12:24 UTC-05:00, Remi Rampin remiram...@gmail.com:
 -   return [_is_git [file join [file dirname $path] 
 $link_target]]
 +   set link_target_abs [file join [file dirname $path] 
 $link_target]

2015-02-03 3:51 UTC-05:00, Chris Packham judge.pack...@gmail.com:
 At this point link_target_abs is something like
 sub/../.git/modules/sub. It might be nice to normalize this with 'git
 rev-parse --git-dir' or even just (cd $link_target_abs  pwd). I'm
 not sure if tcl has anything built in that could do this kind of
 normalization.

There is 'file normalize' according to the docs. I can update the patch
if needed.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [git-gui] bug report: Open existing repository dialog fails on submodules

2015-02-02 Thread Rémi Rampin
2015-02-02 3:41 UTC-05:00, Chris Packham judge.pack...@gmail.com:
 [...]
 But it actually looks like git rev-parse --resolve-git-dir $path needs
 to be run inside a git repository _any_ git repository, which seems a
 bit backwards to me.
 [...]

Indeed, looking at git-rev-parse(1), the correct option might be
--show-toplevel, which will print the cwd if it is the top-level of a
non-bare repository:

cd $candidate  test $(git rev-parse --show-toplevel) = $candidate

or

test $(git --git-dir=$candidate rev-parse --show-toplevel) = $candidate

Of course Git will resolve symlinks at this point, so $candidate has
to be resolved first for the equality to make sense.

Other solution is to parse the gitdir: ... format and recurse, which
is not exactly hard (provided you speak Tcl).
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[git-gui] bug report: Open existing repository dialog fails on submodules

2015-01-30 Thread Rémi Rampin
Hi,

This bug report concerns git-gui. Apologies if this is not the right
mailing-list.

By submodule I mean a repository for which .git is not a regular Git
directory, but rather a gitdir: ... file.
While running git gui from such a directory will work fine, trying
to open it from the choose_repository window will fail with Not a Git
repository. This is because of the simplistic implementation of proc
_is_git in lib/choose_repository.tcl.

I suggest fixing that function, or using Git directly to perform that
check, for instance checking git rev-parse --show-toplevel. I'd
attempt a patch but my tcl-fu is weak.

Best
-- 
Rémi Rampin
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html