5 ms·
Could you maybe specify better how this is implemented in hg so that I can understand why it would be better than: git branch --contains <commit>
by nickez 10y ago
Could you maybe specify better how this is implemented in hg so that I can understand why it would be better than:
git branch --contains <commit>
- rcthompson 10y agoWhen you make the commit, hg records in the commit which branch you were on when you made it. It becomes a permanent part of the commit. Regardless of whether you later merge or even delete that branch, the association between that branch and that commit is still there. I personally don't understand the use case, and prefer git's way of handling things, but I don't rule out that other people find it useful.
- aidenn0 10y agoOne use case is given branch X, tell me what the branch looked like N commits in the past. Git cannot tell you this because all parent commits are equal. DVCS workflows tend towards lots of short-lived branches where it is less useful (which is why hg has bookmarks). It can also just simplify certain things. I can tell by checking if a commit is reachable from e.g. the v1.2 bugfix branch but not from master that the commit was post the 1.2.0 release to fix a bug. With hg branches you can just see that the commit was made the the v1.2 bugfix branch. This is very minor, but my experience with hg is that there are dozens of these minor niceties that are why a lot of hg users are still around despite git having clearly won the popularity contest.
- justinlaster 10y ago>One use case is given branch X, tell me what the branch looked like N commits in the past. What am I not understanding here? You definitely can go N commits in the past on each branch, and even any commit. And if you rewrite history you can even use the reflog to really tell what the branch was like (as long as it hasn't been cleaned out).
- stevelosh 10y ago┌─────┐◀──────── master │Merge│◀──────── bugfix └▲───▲┘ │ │ │ │ │ ┌─┐ │ │B│ │ └▲┘ ┌─┐ │ │A│ │ └▲┘ │ └───┤ │ ┌────────┐ │Ancestor│ └────────┘ Which branch was commit `B` made on? What did the `bugfix` branch look like one commit ago?
- grzm 10y agoNice use of Unicode! Do you have a tool to help you construct a diagram like this?
- deleted 10y ago[deleted]
- sampo 10y agoIf you were in master when you merged bugfix in ("git merge bugfix"), then you can git cat-file -p master and see which commit, A or B, is listed as the first parent. This belongs to the master.
- justinlaster 10y ago> Which branch was commit `B` made on You can do some basic heuristics to figure it out, but I'm not sure what the point of knowing this is. >What did the `bugfix` branch look like one commit ago? `git checkout bugfix; git log bugfix^1`
- zck 10y agoIn the case of merges, how would you tell which parent to look at? Branches might have been deleted, moved, or merged. > And if you rewrite history you can even use the reflog to really tell what the branch was like (as long as it hasn't been cleaned out). The reflog is not moved across remotes, is it? If I make a fresh clone of a repository, that doesn't tell me what the branch was like a year ago.
- justinlaster 10y ago