Reputation: 1035
My repo top-level hierarchy looks like this:
/dir1
/dir2
/dir3
I am on HEAD
and git log --oneline --first-parent -5 -- dir1/
gives something like the following:
abcb COMM-25 Fix latest
ba0f COMM-17 Some stuff
cda8 New files
db7c COMM-9 Feature merge
e20a Init smth
There's a lot of cool stuff over the web like git log --oneline --first-parent db7c.. -- dir1/
to get
abcb COMM-25 Fix latest
ba0f COMM-17 Some stuff
cda8 New files
or even git log --oneline --first-parent db7c..ba0f -- dir1/
to limit at both ends
ba0f COMM-17 Some stuff
cda8 New files
But, hell, I can't find anything that could help to output all commits UP TO specific commit id.
I need something like git log --oneline --first-parent ..cda8 -- dir1/
to get
cda8 New files
db7c COMM-9 Feature merge
e20a Init smth
<...>
having just the cda8
hash. The most recent command above is of course a pseudo-code and doesn't provide any output in real life (unfortunately :) ).
So, how can I list all the commits in the specific directory and BEFORE the given commit id (inclusive) without changing HEAD?
I think I can accept modifying the dir1 contents (dir1 ONLY, not touching dir2 and dir3!), however doing git checkout cda8 dir1/
or git reset cda8 dir1/
doesn't have any effect on the consequent git log <...> -- dir1/
output.
Please help, git gurus!
Upvotes: 5
Views: 1669
Reputation: 21908
I think you've tried too hard here and that's what prevented you from seeing the solution hidden in plain sight.
What you ask for is the standard log behaviour when given a refspec. It will log all commit history that is reachable* from that point :
git log --oneline --first-parent cda8 -- dir1/
(notice that I've taken your exact last attempt, omitting the "..
") should output :
cda8 New files
db7c COMM-9 Feature merge
e20a Init smth
...
<follows ALL the rest of commits history (but only those which have modified dir1/)>
* "reachable" in git should be understood as "reachable through a recursive exploration of a given commit's parents"
Upvotes: 5