git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Are --first-parent and --ancestry-path compatible rev-list options?

From
Philip Oakley <philipoakley@iee.org>
Date
Aug 26, 2016, 21:23 UTC
Message-ID
<2FA1998250474E76A386B82AD635E56A@PhilipOakley>

While trying to answer a Stack Overflow question I thought I could contribute to, I've found a scenario that I don't understand that may be a bug.

In http://stackoverflow.com/questions/39144006/identify-merge-into-master MvG asked how to find the point at which a commit on a feature branch was later merged into the main-line.

After some discussion it appeared that
    `git log --oneline  --first-parent --merges --reverse  --ancestry-path 
:/j..  | head -1`
should find the point that 'j' was merged into master (when on master), 
however it appears that --first-parent and --ancestry-path interact badly to 
produce no output in the example, but if either is dropped, the expected 
commit is shown.

What am I missing? -- Philip

The commit graph. We are looking for F based on knowing J.

. A - B - C - D -- E -- F -- G - H <-first parent, --merges (C,F,H) . \ | / \ / / . ----Z | / / . | | | / . \ \ / / . I -[J]- K - L - M <-since J, children of J . \ / . N - O - P

# Steps to reproduce the extended example from # http://stackoverflow.com/q/39144006/1468366

git init . echo a > txt git add txt git commit -m a echo a > txt; git commit -a -m a echo b > txt; git commit -a -m b git checkout -b side :/a echo z > txt; git commit -a -m z git checkout master git merge :/z; echo c > txt; git add -u; git commit -m c

#echo c > txt; git commit -a -m c echo d > txt; git commit -a -m d echo e > txt; git commit -a -m e git checkout -b 2nd :/b echo i > txt; git commit -a -m i echo j > txt; git commit -a -m j git merge :/d; echo k > txt; git add -u; git commit -m k git checkout -b 3rd :/i echo n > txt; git commit -a -m n echo o > txt; git commit -a -m o echo p > txt; git commit -a -m p git checkout 2nd git merge :/p; echo l > txt; git add -u; git commit -m l echo m > txt; git commit -a -m m git checkout master git merge :/l; echo f > txt; git add -u; git commit -m f git merge :/m; echo g > txt; git add -u; git commit -m g echo h > txt; git commit -a -m h

git log --oneline  --first-parent --merges --reverse  --ancestry-path :/j.. 
| head -5
# why does this not work --ancestry-path and --first-parent appear to clash.

code available as https://gist.github.com/PhilipOakley/58f344f910e50b72f5a8a2bd55b6c175

Next: Junio C Hamano
Message 1 of 6 in “Are --first-parent and --ancestry-path compatible rev-list options?”
  1. Philip OakleyAug 26, 2016
  2. Junio C HamanoAug 26, 2016
  3. Philip OakleyAug 27, 2016
  4. Junio C HamanoSep 1, 2016
  5. Philip OakleySep 1, 2016
  6. Junio C HamanoSep 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.