jtulach commented on code in PR #9754:
URL: https://github.com/apache/netbeans/pull/9754#discussion_r4392076037


##########
ide/git/src/org/netbeans/modules/git/utils/GitUtils.java:
##########
@@ -1112,6 +1115,38 @@ public String getName () {
         return VCSContext.forNodes(nodes);
     }
 
+    /** Reads concent of {@code gitFile} to find location of associated
+     * meta folder directory. When using {@code submodule}s, such a directory
+     * is specified as
+     * <pre>
+     * gitdir: "relative-path-to-actual-git-directory"
+     * </pre>
+     * Git keeps the submodule's actual repository data safely housed inside
+     * the parent project's root {@code .git/modules/} directory
+     *
+     * @param gitFile the file to parse and read
+     * @return {@code null} if no result was found or location of the meta 
folder
+     */
+    @CheckForNull
+    public static File findMetafolder(File gitFile) {

Review Comment:
   When you add or initialize a submodule, its root folder does not contain a 
standard .git/ directory. Instead, it contains a simple regular text file named 
.git that acts as a pointer to the main repository. 
[[1](https://git-scm.com/docs/gitsubmodules)] 
(https://git-scm.com/docs/gitsubmodules), 
[[2](https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)] 
(https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)
   
   ### The Structure
   
   The file contains a single line of text formatted as follows: 
[[1](https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)] 
(https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)
   text
   gitdir: <relative-path-to-actual-git-directory>
   Use code with caution.
   
   ### Direct Example
   
   If your submodule is located at the path libs/my-submodule inside your main 
project, the contents of libs/my-submodule/.git will look like this:
   text
   gitdir: ../../.git/modules/libs/my-submodule
   Use code with caution.
   
   ### Why does Git do this?
   
   Historically, submodules contained full .git/ directories. Git changed this 
behavior to keep the submodule's actual repository data safely housed inside 
the parent project's root .git/modules/ directory. 
[[1](https://git-scm.com/docs/gitsubmodules)] 
(https://git-scm.com/docs/gitsubmodules), 
[[2](https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)] 
(https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)
   This layout provides a major advantage: if you switch between branches in 
your main project—some of which might not include the submodule at all—the 
submodule's working folder can be wiped or overridden without losing the 
submodule's local history, uncommitted changes, or configurations. Everything 
remains safely tucked away in the parent's .git/modules/ path. 
[[1](https://git-scm.com/docs/gitsubmodules)] 
(https://git-scm.com/docs/gitsubmodules), 
[[2](https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)] 
(https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407)
   Are you troubleshooting a broken submodule pointer, or are you writing a 
script/tool that needs to parse and traverse Git repositories? Let me know what 
you're working on so I can provide the best next steps!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to