version control - git rev-list HEAD~n does not include first commit in range -


i'm using git rev-list selection of commits repo in 2 different ways:

git rev-list --reverse head~<n>.. 

and git rev-list --reverse ..

having read git rev-list manpage, know .. equivalent ^, , not include in range of commits selected, man page didn't specify if wanted inclusive range of commits (that is, including )

i have same problem with: git rev-list --reverse head~..

here specification of want:

say have 4 commits:

a--b--c--d 

and have script give 2 commits:

myscript --from b --to d 

i want list of commits of size 3:

b, c, d 

or if did:

myscript --last 4 

i'd get:

a, b, c, d 

my proposed solution like:

git rev-list --reverse <tag1>~1..<tag2> 

or git rev-list --reverse head~..

however, doesn't work if n == number of commits, or tag1 first commit.

any appreciated.

so --last n option, found following works quite nicely:

git rev-list --reverse head -n <n>  

unfortunately, solution selecting inclusive range isn't clean:

git rev-list --reverse <tag1>..<tag2> --boundary 

this give want, however put small dash ("-") in front of first commit. can solved bit of string processing though.


Comments