Felipe Contreras <felipe.contreras@xxxxxxxxx> writes: > This is *not* meant a serious proposal, it's just an exploration of an > idea. It is easy to explain and understand the benefit of keeping a separate pointer to the bottom [*] of the branch on top of which the history leading to the commit at the tip of the branch has been built, but the devil is in the details of how such a bottom pointer will be maintained. side note: below, I use "bottom" because for me it is the most natural term to refer to the starting end of the range of commits. In the context of this topic, readers can replace any "bottom" they see with "tail", if they prefer. In a sense, this is very similar to the idea of "notes". It is easy to explain and understand that a bag of objects, in which additional data can be associated with an object name, can be used to keep track of extra data on commits (and other objects) after they are created without invalidating their object name. As long as they are copied/moved when a commit is used to create another copy of it. The "notes" are automatically copied across "rebasing", which is one of the many details that makes the "notes" usable, but cherry-pick that does not honor notes.rewriteRef sometimes leads to frustration. Creation of a new branch with "git branch" would be an obvious point to add such a bottom pointer, and "git rebase" is a good point to update such a bottom pointer. But there are many other ways that people update their branches, depending on the workflow, and guessing when to update the bottom pointer and trying to be complete with the heuristics will lead to the same "no, we do not know all users' workflows" that made approaches based on reflog parsing etc. fail to solve the "where did the branch start?" puzzle. And I think what is sketched in these RFC patches can be a good starting point for a solution that strikes a good balance. "git rebase", which is the most common way to mangle branches, is taught to update the bottom pointer automatically. Giving users an explicit way to set the bottom when manipulating branches would help those who mangle their branches with something other than "git rebase" in the most trivial form. I suspect that is still missing in this RFC? Of course other things on the consuming side may be missing, like send-email or format-patch, but they are a lot more trivial to add and will be useful. As long as the bottom pointer is properly maintained, that is. A few of the things that I often do to mangle my branches are listed. Some of them are not application of "git rebase" in the trivial form: * I have a patch series (single strand of pearls). I update on top of the updated upstream: $ git rebase -i --onto master @{bottom} $ git range-diff @{bottom}@{1}..@{1} @{bottom}..HEAD No, this is not what "I often do" yet, but I hope to see become doable. Rebase the current branch from its bottom on top of the master, and then take the range diff between the old branch (i.e. @{bottom} refers to the bottom pointer, but because it is implemented as a ref, its reflog knows what the previous value of it was---@{bottom}@{1}..@{1} would be the range of commits on the branch before I did the above rebase) and the new one. * I have 7 patch series (single strand of pearls). I only need to touch the top 3. $ git rebase -i HEAD~3 $ git range-diff @{1}... In this case, I am not updating the bottom to HEAD~3 and reducing the branch into 3-patch series. I am keeping the bottom of the branch, and the commits that happen to be updated are only the topmost 3. * In the same situation, but the top 3 in the original are so bad that I am better off redoing them from scratch, taking advantage of new features in 'master'. $ git checkout --detach master ... work on detached HEAD ... ... first pick the bottom commits ... $ git cherry-pick master..@{-1}~3 ... still working on detached HEAD ... ... redo the topmost commits from scratch ... $ git range-diff master..@{-1} master.. $ git checkout -B @{-1} I do not mind "checkout -B" *not* learning any trick to automatically update the bottom pointer for the branch to 'master' in this case, but I should be able to manually update the bottom of the branch easily. Something like "git checkout -B @{-1} --set-bottom=master" might be acceptable here. * I have an existing series, and want to replace it. To keep the reflog of these branches useful, I apply patches, fix author's mistakes, etc., on detached HEAD and update the original branch after everything is done. $ git checkout --detach master... # This could be "git checkout --detach @{bottom}" $ git am -s mbox $ git range-diff @{-1}... $ git checkout -B @{-1} In this case, the bottom of the branch should stay the same. * I tried to do the above, but failed at "git am" step, because new iteration requires to be on updated master. $ git checkout --detach master... # This could be "git checkout --detach @{bottom}" $ git am -s mbox $ git am --abort $ git reset --hard master $ git am -s mbox $ git range-diff master..@{-1} master.. $ git checkout -B @{-1} # or "git branch -f @{-1}" In this case, I should be able to manually update the bottom of the branch, and making it easy (e.g. "git checkout -B @{-1} --set-bottom=master") is much easier and more robust than teaching "checkout -B" to guess my intention. IOW, I do not mind if maintenance of the bottom of the branch is not always automatic (and prone to heuristic making an incorrect guess). But I think we should make sure it is easy for the user to assist the tool to maintain it correctly [*]. Side note: and that is what I find "frustrating" in the "notes" world. "notes" can be copied after cherry-pick manually, but that is a very tedious process, and at some point, being "merely possible" stops to have much value, unless it is "easily doable". There are of course other things people do to their branches, and I do not think we need to teach all the tools used in these workflows to update the bottom pointer automatically (even though the more we can do automatically would make it easier for users, as long as the automation never makes any mistakes). Again, I think the key to the success for this "we record the fork point of a branch" idea is to make it easy and simple for users to help the tools to maintain it correctly. Thanks.