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

Re: [BUG] `git reset --hard` fails with `update = none` submodules

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 16, 2021, 01:25 UTC
Message-ID
<YMlS+1F9IND7vxNI@camp.crustytoothpaste.net>
In-Reply-To
<CAKjYmsEHWShuKEOFWnCyU1x5rM7kFrcaN78D7KhhUay8kCvA2g@mail.gmail.com>
On 2021-06-16 at 01:03:40, Rose Kunkel wrote:
Show 5 quoted lines
> Potentially relevant: `git config --global --list` shows
> ```
> status.showstash=true
> status.submodulesummary=true
> submodule.recurse=true

Thanks for this additional information. This line is the critical piece. Now I get this:

  $ git reset --hard
  fatal: not a git repository: ../../.git/modules/repos/agda
  fatal: could not reset submodule index

Predictably, "git -c submodules.recurse=true reset --hard" also results in the same thing.

The --recurse-submodules option for git reset says this (emphasis mine):
  When the working tree is updated, using --recurse-submodules will also
  recursively reset the working tree of all *active* submodules
  according to the commit recorded in the superproject, also setting the
  submodules' HEAD to be detached at that commit.
On my system, .git/config has this:
  [submodule]
          active = .

So these submodules are active, but they probably should not be, since we haven't checked anything out (or, for that matter, cloned any data) and it wouldn't make sense to try to operate on them automatically with submodules.recurse or --recurse-submodules.

My gut tells me that we should probably mark submodules with update=none set on a clone as inactive. Of course, this is a tricky area that I'm not super familiar with, so opinions or thoughts are welcome.

If folks think this is a good way forward, I'll look into writing a patch, probably tomorrow evening since it's starting to get late here.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Previous: Rose KunkelNext: Rose Kunkel
Message 6 of 18 in “[BUG] `git reset --hard` fails with `update = none` submodules”
  1. Rose KunkelJun 16, 2021
  2. brian m. carlsonJun 16, 2021
  3. Rose KunkelJun 16, 2021
  4. Rose KunkelJun 16, 2021
  5. Rose KunkelJun 16, 2021
  6. brian m. carlsonJun 16, 2021
  7. Rose KunkelJun 16, 2021
  8. Rose KunkelJun 16, 2021
  9. Junio C HamanoJun 16, 2021
  10. Philippe BlainJun 16, 2021
  11. brian m. carlsonJun 17, 2021
  12. submodule: mark submodules with update=none as inactivebrian m. carlson, Jun 19, 2021
  13. Philippe BlainJun 22, 2021
  14. brian m. carlsonJun 25, 2021
  15. Philippe BlainJun 26, 2021
  16. submodule: mark submodules with update=none as inactivebrian m. carlson, Jul 1, 2021
  17. Philippe BlainJul 9, 2021
  18. brian m. carlsonJul 11, 2021

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.