* [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? @ 2012-12-21 15:58 Junio C Hamano [not found] ` <CANiSa6jP_JN+DpDgYpWA9Aky9REJvFq3aR3Yj0vF3+axWvtmsw@mail.gmail.com> 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2012-12-21 15:58 UTC (permalink / raw) To: git When you want to redo a branch forked from another branch (say 'master'), a handy way to work is to first detach HEAD at the previous fork point: $ git checkout master...branch and build an updated history on top of this state. Once you are done, you can verify your results with commands like: $ git show-branch branch HEAD $ git diff branch HEAD and then finish it off with: $ git checkout -B branch This way, you can keep the history of the previous round on 'branch' until you are done with the new history you build on the detached HEAD state, and if you do not like updated history, you can reset back to branch@{1} easily. But you may not even need to have such an easy access to the old history and just want to restart, with: $ git checkout -B branch <old fork point> Unfortunately, master...branch syntax does not seem to work for specifying the "old fork point" for this purpose, even though we have special case to support the syntax in the "detach at that commit" case (the first command line example in this message). Perhaps we should teach the <start-point> parser this syntax as well? ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CANiSa6jP_JN+DpDgYpWA9Aky9REJvFq3aR3Yj0vF3+axWvtmsw@mail.gmail.com>]
* Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? [not found] ` <CANiSa6jP_JN+DpDgYpWA9Aky9REJvFq3aR3Yj0vF3+axWvtmsw@mail.gmail.com> @ 2012-12-21 16:55 ` Martin von Zweigbergk 2012-12-21 17:12 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Martin von Zweigbergk @ 2012-12-21 16:55 UTC (permalink / raw) To: git, Junio C Hamano Oops, meant for all of you. ---------- Forwarded message ---------- From: Martin von Zweigbergk <martinvonz@gmail.com> Date: Fri, Dec 21, 2012 at 8:45 AM Subject: Re: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? To: Junio C Hamano <gitster@pobox.com> On Fri, Dec 21, 2012 at 7:58 AM, Junio C Hamano <gitster@pobox.com> wrote: > $ git checkout -B branch <old fork point> > > Unfortunately, master...branch syntax does not seem to work for > specifying the "old fork point" for this purpose I have personally always found it confusing to use the same syntax for specifying ranges/sets and single revisions. I keep forgetting what "git diff A..B" does. I know it doesn't do what I expect (i.e. "git diff $(git merge-base A B) B"), but I don't know what it does (maybe same as "git diff A B" (?), but that's besides the point). Having worked a bit on rebase, I know that $onto can also take the "A...B" form. So there is clearly some precedence for the "..." syntax to refer to a revision in some contexts. I would have much preferred if it was possible to make the revision parser generally interpret e.g. "A.^.B" as "the merge base of A and B" (failing if not exactly one). It seems like something that must have come up before. Is there a particular reason this would not be a good idea? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? 2012-12-21 16:55 ` Fwd: " Martin von Zweigbergk @ 2012-12-21 17:12 ` Junio C Hamano 2012-12-21 19:43 ` Michael Haggerty 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2012-12-21 17:12 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: git Martin von Zweigbergk <martinvonz@gmail.com> writes: > I keep forgetting what "git diff A..B" does. "diff" is always about two endpoints, not the path that connects these two endpoints (aka "range"), and when you want to "diff" between two commits, you say "diff A B". "A..B" happens to be accepted as such only by accident (e.g. the old command line parser did not have a reliable way to tell "^A B" and "A..B" apart), not by design. side note: incidentally, now we have rev_cmdline_info support, we could start deprecating "diff A..B" syntax. The special case "git checkout master...branch" is not about specifying a range. The command knows it wants a single point (not two endpoints, nor a range), and A...B as a notation to specify a single point is $(merge-base A B). > I would have much preferred if > it was possible to make the revision parser generally interpret e.g. > "A.^.B" as "the merge base of A and B" (failing if not exactly one). Actually, in many places where the command line parser knows it wants a single point, and never a range, we should be able to apply the "A...B as a notation to specify a single point" rule. Of course you could come up with a symbol other than "..." for that purpose, and migrate the current "git checkout A...B" special case to use that other symbol, but that would be more work and also you would need to retrain existing users. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? 2012-12-21 17:12 ` Junio C Hamano @ 2012-12-21 19:43 ` Michael Haggerty 2012-12-21 21:31 ` Martin von Zweigbergk 0 siblings, 1 reply; 7+ messages in thread From: Michael Haggerty @ 2012-12-21 19:43 UTC (permalink / raw) To: Junio C Hamano; +Cc: Martin von Zweigbergk, git On 12/21/2012 06:12 PM, Junio C Hamano wrote: > "diff" is always about two endpoints, not the path that connects > these two endpoints (aka "range"), and when you want to "diff" > between two commits, you say "diff A B". "A..B" happens to be > accepted as such only by accident (e.g. the old command line parser > did not have a reliable way to tell "^A B" and "A..B" apart), not by > design. > > side note: incidentally, now we have rev_cmdline_info support, > we could start deprecating "diff A..B" syntax. I often find myself using "git diff A..B" syntax when using the command line history because the previous command used "A..B"; e.g., git log A..B git diff A..B It's quick to recall the previous command, edit "log" -> "diff", and press enter; having to remove the dots would require a few extra keypresses. > Actually, in many places where the command line parser knows it > wants a single point, and never a range, we should be able to apply > the "A...B as a notation to specify a single point" rule. > > Of course you could come up with a symbol other than "..." for that > purpose, and migrate the current "git checkout A...B" special case > to use that other symbol, but that would be more work and also you > would need to retrain existing users. OTOH making A...B sometimes mean a range and sometimes a merge-base (depending on context) adds a confusing non-uniformity, and also has the disadvantage of making merge-base shorthand unavailable in contexts that allow a range. OTOOH git already has so many notations that can be used on the command line; inventing yet another one would make it that much more overwhelming. Michael -- Michael Haggerty mhagger@alum.mit.edu http://softwareswirl.blogspot.com/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? 2012-12-21 19:43 ` Michael Haggerty @ 2012-12-21 21:31 ` Martin von Zweigbergk 2012-12-21 21:45 ` Junio C Hamano 2012-12-21 21:59 ` Michael Haggerty 0 siblings, 2 replies; 7+ messages in thread From: Martin von Zweigbergk @ 2012-12-21 21:31 UTC (permalink / raw) To: Michael Haggerty; +Cc: Junio C Hamano, git On Fri, Dec 21, 2012 at 11:43 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote: > On 12/21/2012 06:12 PM, Junio C Hamano wrote: >> "diff" is always about two endpoints, not the path that connects >> these two endpoints (aka "range"), and when you want to "diff" >> between two commits, you say "diff A B". "A..B" happens to be >> accepted as such only by accident (e.g. the old command line parser >> did not have a reliable way to tell "^A B" and "A..B" apart), not by >> design. Off topic: I also find it hard to wrap my head around what diffing against a negative revision would mean. Looking at the result of running it, it seems to be the same as diffing against a positive one. >> >> side note: incidentally, now we have rev_cmdline_info support, >> we could start deprecating "diff A..B" syntax. > > I often find myself using "git diff A..B" syntax when using the command > line history because the previous command used "A..B"; e.g., > > git log A..B > git diff A..B The problem with this, to me, if it wasn't clear, is that "git log A..B" shows you is new _since B branched off from A_, while "git diff A..B" shows you what has changed _between A and B_. >> Actually, in many places where the command line parser knows it >> wants a single point, and never a range, we should be able to apply >> the "A...B as a notation to specify a single point" rule. >> >> Of course you could come up with a symbol other than "..." for that >> purpose, and migrate the current "git checkout A...B" special case >> to use that other symbol, but that would be more work and also you >> would need to retrain existing users. > > OTOH making A...B sometimes mean a range and sometimes a merge-base > (depending on context) adds a confusing non-uniformity, and also has the > disadvantage of making merge-base shorthand unavailable in contexts that > allow a range. And making it unavailable in contexts where the command was not specifically implemented to support it. I'm sure there are many scripts out there that use "git ... $(git merge-base A B) ..." that could be simplified if rev-parse could resolve a merge base. > OTOOH git already has so many notations that can be used on the command > line; inventing yet another one would make it that much more overwhelming. Agreed. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? 2012-12-21 21:31 ` Martin von Zweigbergk @ 2012-12-21 21:45 ` Junio C Hamano 2012-12-21 21:59 ` Michael Haggerty 1 sibling, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2012-12-21 21:45 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: Michael Haggerty, git > Off topic: I also find it hard to wrap my head around what diffing > against a negative revision would mean. Looking at the result of > running it, it seems to be the same as diffing against a positive one. That is not an off-topic at all, but is the crux of "diff A..B" being a hysterical raisins. It is parsed as and converted to "diff ^A B" by the revision command line parser in setup_revisions(), and the caller *guesses* what the command line originally said by inspecting that there are two revs in rev.pending[] array, the first one is negative and the second one is positive, to infer that the user typed "diff A..B" and then finally decides to compare A and B. This was done before we introduced rev.cmdline_info to record what was given from the command line to result in the set of commits in rev.pending array. If we were writing "git diff" UI from scratch today, we wouldn't be looking at rev.pending but would be looking at rev.cmdline_info and we can differenciate between "A B", "^A B", and "A..B" (and reject the latter two as nonsense). ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? 2012-12-21 21:31 ` Martin von Zweigbergk 2012-12-21 21:45 ` Junio C Hamano @ 2012-12-21 21:59 ` Michael Haggerty 1 sibling, 0 replies; 7+ messages in thread From: Michael Haggerty @ 2012-12-21 21:59 UTC (permalink / raw) To: Martin von Zweigbergk; +Cc: Junio C Hamano, git On 12/21/2012 10:31 PM, Martin von Zweigbergk wrote: > On Fri, Dec 21, 2012 at 11:43 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote: >> On 12/21/2012 06:12 PM, Junio C Hamano wrote: >>> side note: incidentally, now we have rev_cmdline_info support, >>> we could start deprecating "diff A..B" syntax. >> >> I often find myself using "git diff A..B" syntax when using the command >> line history because the previous command used "A..B"; e.g., >> >> git log A..B >> git diff A..B > > The problem with this, to me, if it wasn't clear, is that "git log > A..B" shows you is new _since B branched off from A_, while "git diff > A..B" shows you what has changed _between A and B_. You are quite right, of course, though in many useful cases they are the same. But I guess I should just buck myself up for the new orthodoxy :-) Michael -- Michael Haggerty mhagger@alum.mit.edu http://softwareswirl.blogspot.com/ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-12-21 22:00 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-12-21 15:58 [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work? Junio C Hamano [not found] ` <CANiSa6jP_JN+DpDgYpWA9Aky9REJvFq3aR3Yj0vF3+axWvtmsw@mail.gmail.com> 2012-12-21 16:55 ` Fwd: " Martin von Zweigbergk 2012-12-21 17:12 ` Junio C Hamano 2012-12-21 19:43 ` Michael Haggerty 2012-12-21 21:31 ` Martin von Zweigbergk 2012-12-21 21:45 ` Junio C Hamano 2012-12-21 21:59 ` Michael Haggerty
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).