git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Subject: [PATCH for submodule ideas wiki] `git commit` to warn about broken submodule states configuration

From
Stefan Beller <sbeller@google.com>
Date
Mar 16, 2016, 21:07 UTC
Message-ID
<1458162423-13768-1-git-send-email-sbeller@google.com>
---
  Hi Jens,
 
  I cannot find the edit button in the wiki[1] any more.
  Please apply this patch documenting another idea.
  
  Thanks,
  Stefan
  
  [1] https://github.com/jlehmann/git-submod-enhancements/wiki
 Home.textile | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/Home.textile b/Home.textile
index 152ad04..3b00496 100644
--- a/Home.textile
+++ b/Home.textile
@@ -47,6 +47,17 @@ h2. Submodule related bugs to fix
 * E.g. @git log <submodule>/@ and @git diff <rev> <submodule>/@ do not produce any output while dropping the '/' at the end makes them work as expected.
 * @git add@ does not honour the submodule.&lt;name&gt;.ignore settings
 * @git submodule add@ messes up paths from nested submodules, see ("thread on mailing list":http://thread.gmane.org/gmane.comp.version-control.git/288130)
+* @git commit@ can be cautious about submodule related commits. That is if a commit contains a change to the .gitmodules file, make sure that the corresponding gitlink is present (either already in the tree or newly added). IIUC Jonathan correctly a submodule which is configured in .gitmodules, but not present as a gitlink is considered broken, which we may want to avoid in the first place. When implementing this, we need to take care of historical mistakes being handled correctly as well as a flag to commit, which overwrites the potential warning. The gitmodules file unlike other in-tree configuration files (.gitignore, .gitattributes, .mailmap) have a 1:1 mapping so the existence of the gitlink is strongly expected. (Counter example with .gitignore: Ignoring *.exe doesn't expect any .ex
 e file to be there). I imagine this to roughly work as:
+
+bc.     $ git add .gitmodules
+    $ git commit -m "add submodule to .gitmodules, but not as gitlink"
+      Warning: Not committing as this would break submodule consistency. Use
+      --force-submodules to commit the broken submodule state.
+    $ echo $?
+      1 # fail
+    $ git commit --force-submodules -m "add submodule to .gitmodules, but not as gitlink"
+    $ echo $?
+      0 # Success
 
 *[[Ideas]]*
 
-- 
2.7.0.rc0.42.g8e9204f.dirty
Next: Jens Lehmann
Message 1 of 2 in “Subject: [PATCH for submodule ideas wiki] `git commit` to warn about broken submodule states configuration”
  1. Stefan BellerMar 16, 2016
  2. Jens LehmannMar 17, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.