Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support traversal of git folders below the castle root #94

Open
andsens opened this issue Apr 21, 2014 · 10 comments
Open

Support traversal of git folders below the castle root #94

andsens opened this issue Apr 21, 2014 · 10 comments

Comments

@andsens
Copy link
Owner

andsens commented Apr 21, 2014

As discussed in #93 it can be very useful at times to fiddle with .git repos by using homeshick. To do that homeshick needs to stop skipping files and folders named .git when linking.

However, some things still need to be skipped:

  • The .git folder in the root of a castle, since that is a folder managed by git and not the user
  • The .git files in submodules of a repo
  • The .git folders in submodules of a repo for older git versions (if I remember correctly git switched to just managing all submodules in the .git folder of the root repository, so we need the git version where that changed)
@andsens
Copy link
Owner Author

andsens commented Apr 21, 2014

The tests for this addition need to be very thorough since a bug in the handling of this could screw things up in all kinds of ways. To put it differently: The detection of when a .git folder is something that was created by the user and when it was created by git must be 100% accurate.

@andsens
Copy link
Owner Author

andsens commented Apr 21, 2014

Hold on, this is actually really simple.

  • The root folder won't ever be traversed because it's not in home/
  • To exclude .git files only the find command should be changed to find . -mindepth 1 -name .git -a -type f -prune -o -print
  • For git versions that still use the .git folder in submodules we simply fall back to the old find command, anything else would just be too complicated

The questions remaining are:

  • In what git version where those .git folders replaced with files pointing at the root?
  • Does the existence of those .git folders depend on the current git version or the git version the repo was created with?

@squaresurf
Copy link
Contributor

Off the top of my head I think that .git folders for submodules were moved to the parent .git folder in git 1.7.8. I could be wrong though. https://jira.atlassian.com/browse/SRCTREE-837

I will keep searching though.

@squaresurf
Copy link
Contributor

It does seem like it is 1.7.8:

The one thing that I see in the release notes though is that it seems that this behavior only applies to submodules added with 1.7.8 or greater. If I read that correctly that means that a repo created with a version less than 1.7.8 while using a version of git 1.7.8 or greater could indeed have the .git directories within the submodules. Am I reading that incorrectly?

@andsens
Copy link
Owner Author

andsens commented Apr 21, 2014

Oh boy, yup I get to the same conclusion. I don't think there's a way to figure out with which version a git submodule was added. As far as I can see the only way to get around this, is to filter out all the submodule .git folder paths.

EDIT: p.s. good job on finding the version :-)

@andsens
Copy link
Owner Author

andsens commented Apr 22, 2014

Come to think of it, this might actually be related to another feature I have been thinking of and may make things easier.
gitignored files should not be symlinked. .git files and folders (that is, the ones created by git) are ignored by git. A simple git check-ignore on the path that we are trying to link (like we do in track) would resolve all our problems!

@squaresurf
Copy link
Contributor

Thats a great idea. Do you want that feature to be its own github issue and we'll link from it here? Or should we just implement that tied to this issue?

@andsens
Copy link
Owner Author

andsens commented Apr 22, 2014

I created a new issue for it (#95). It's always better to track individual changes like this, so we can reference them in the future, should there be any problems with the feature or extensions to it.

@squaresurf
Copy link
Contributor

I agree that this change is larger than this issue. Thank you for creating issue #95.

@absorber
Copy link

If I understand this correctly, this feature will enable homeshick to track git project folders as well? That sounds great.

Personally I have 2 git working dirs in ~/.tmux/plugins/, which will get ignored when I start to homeshick track ~/.tmux/.

So if the main issue seems git's inability to track git working dirs inside git working dirs, then isn't this a solution? - http://stackoverflow.com/questions/4659549/maintain-git-repo-inside-another-git-repo
Especially that part about 'fake submodules' appears to be interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants