title: howto find out which git submodule current directory belongs to
body: <h1>setup</h1>
  <p>i have a <code>git</code> repo located in <code>/home/v/git_repo</code>, in which i have a submodule localted in subdirectory <code>./a/b/c</code>.</p>
  <pre><code>$ cat /home/v/git_repo/.gitmodules
  [submodule &quot;foo/bar&quot;]
      path = a/b/c
      url = git@github.com:username/repo.git
  </code></pre>
  <p>having the full path or only the in-repository subpath (that i have implemented in helper script <code>git-where-in-repo-am-i-currently</code>)</p>
  <pre><code>$ pwd
  /home/v/git_repo/a/b/c/something
  
  $ git where-in-repo-am-i-currently
  a/b/c/something
  </code></pre>
  <h1>question</h1>
  <p>i want to find out (preferably in <code>fish</code>) which submodule this path belongs to: e.g</p>
  <pre><code>$ git which-submodule (pwd)
  foo/bar
  </code></pre>
  <p>to later use it to query that submodules status like</p>
  <pre><code>$ git -C (git rev-parse --git-dir)/modules/(git which-submodule) status
  on branch master
  Your branch is up to date with 'origin/master'
  </code></pre>
  <p>and ultimately display this information in my prompt (that part is already implemented)</p>
  <h1>what i tried</h1>
  <p>parsing the output of</p>
  <pre><code>$ git -C (git rev-parse --show-toplevel) config --file=.gitmodules --get-regexp &quot;path&quot;`
  submodule.foo/bar.path a/b/c
  </code></pre>
  <p>and comparing my sub-directory path to that of a submodule, but it was rather a mess, with splitting pathes into arrays and all kinds of hacks</p>