LMSouq
moodle-core Open

Git: How can I find a commit that most closely matches a directory?

CO
Community Contributor
1 month ago
3 views
Problem Description
Someone took a version (unknown to me) of Moodle, applied many changes within a directory, and released it ([tree here][1]). **How can I determine which commit of the original project was most likely edited to form this tree?** this would allow me to form a branch at the appropriate commit with this patch. Surely it came from either the [1.8][2] or [1.9][3] branches, probably from a release tag, but diffing between particular commits doesn't help me much. **Postmortem Update:** [knittl's answer][4] got me as close as I'm going to get. I first added my patch repo as the remote "foreign" (no commits in common, that's OK), then did diffs in loops with a couple format options. The first used the `--shortstat` format: for REV in $(git rev-list v1.9.0^..v1.9.5); do git diff --shortstat "$REV" f7f7ad53c8839b8ea4e7 -- mod/assignment >> ~/rdiffs.txt; echo "$REV" >> ~/rdiffs.txt; done; The second just counted the line changes in a unified diff with no context: for REV in $(git rev-list v1.9.0^..v1.9.5); do git diff -U0 "$REV" f7f7ad53c8839b8ea4e7 -- mod/assignment | wc -l >> ~/rdiffs2.txt; echo "$REV" >> ~/rdiffs2.txt; done; There were thousands of commits to dig through, but [this one][5] seems to be the closest match. [1]: https://github.com/mrclay/moodle-rubric-1.9/tree/5ed4c9409f76a250fb56d74a527fe7894a676c5c/mod/assignment [2]: https://github.com/moodle/moodle/tree/MOODLE_18_STABLE/mod/assignment [3]: https://github.com/moodle/moodle/tree/MOODLE_19_STABLE/mod/assignment [4]: https://stackoverflow.com/questions/6388283/git-how-can-i-find-a-commit-that-most-closely-matches-a-directory/6388694#6388694 [5]: https://github.com/moodle/moodle/commit/b54847edc3e213e280dc8e0f0648be2c13bf35f2

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base