git-meta icon indicating copy to clipboard operation
git-meta copied to clipboard

FR: Smart path-based `git meta log` that peeks inside submodules

Open abliss opened this issue 7 years ago • 1 comments

If I have submodules a/z, a/y, b/w, and c/, and I want to see a history of changes that touched certain files inside them, it would be cool if I could run git meta log -- a/z/foo/bar a/y/baz b/ c/. Git-meta would then inspect each path:

  • if it's a submodule, include all commits which touched that submodule.
  • if it's a meta repo path, inlcude all commits which touched submodules under that path.
  • if it has a strict prefix which matches a submodule, then:
    • "half-initialize" the submodule in .git/modules if it isn't already there. (No need to checkout a tree.)
    • for each meta commit which touches the submodule,
      • fetch the starting and ending commits in the submodule and diff their trees*
      • if the diff touches any file matching the path suffix, include it in the log.

(* Note that this would not include any meta commit introducing a series of submodule commits which touched and then reverted the file. For our own case, I think that's correct. One alternative might be, "if the ending commit is a descendant of the starting commit, iterate along the path from start to end, and if any submodule commits touch the given path suffix, include the meta commit in the log.". But sometimes the ending commit will not be a descendant, and then what?)

abliss avatar Jul 27 '18 13:07 abliss

One could argue that "git log" should do this, and that its current behavior is broken (it seems to list any commits touching the submodule prefix, regardless of which files inside the submodule they touched? i.e. "git log a/z/foo" is the same as "git log a/z"). But one could also argue that "git log" itself should never fetch things. Also I'm suddenly getting déjà vu ; have we discussed this before?

abliss avatar Jul 27 '18 13:07 abliss