Murmele / Gittyup

Understand your Git history!
https://murmele.github.io/Gittyup
MIT License
1.37k stars 107 forks source link

#612 happening again in different form despite PR #614 #731

Closed ysalmon closed 2 months ago

ysalmon commented 3 months ago

My previous issue #612 was about repos not being properly managed when the work tree is out of the git dir.

I submitted a PR #614 to address this, which was merged, albeit with some modifications, eg. https://github.com/Murmele/Gittyup/pull/614/commits/0fd2d5506aee802291acf139bffb434cac8df775, which changes the logic I proposed to determine the name of a repo to avoid infinite loops (which I did not experience, but I admit I did not test extensively).

However, this seems to lead to a resurgence of the initial problem.

With the situation of #612, namely

cd /tmp
mkdir a b
git --git-dir a --work-tree b init
touch b/test

opening a in Gittyup gives a title of tmp (in #612 that was b). It actually gets registered as /tmp in Gittyup.conf.

Moreover, in my actual use case of a git repo in $HOME/Documents/Enseignement/publication-tex.git/ having a config set to worktree = $HOME/Documents/Enseignement/somewhere/Chato-Info/etc/chato, I stumble back on the unwanted behaviour that opening that repo (from its git repo dir) works but lists the repo as Enseignement and writes an inconsistent state in Gittyup.conf, with lastpath being, correctly, $HOME/Documents/Enseignement/publication-tex.git, but the repo appearing as $HOME/Documents/Enseignement in the recent list. Therefore, the repo also gets listed as Enseignement in the recent list of the GUI, and trying to open the repo from that list leads to an error.

ysalmon commented 3 months ago

I think the culprit is around here https://github.com/Murmele/Gittyup/blame/ec9980f6991795545bec149bd773ae2206133b51/src/git/Repository.cpp#L155 : I do not really understand why there are assert here ; it is not an error for a gitdir to be not be named .git, however if that is not the case, we do not want to remove the last part of the path (if that is what dir.cdUp() does).