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

Re: Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work?

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2012, 21:45 UTC
Message-ID
<CAPc5daWN_a0d2o37CkRk5n9bc4dy5_Zan22dN81waT=-+b7pVA@mail.gmail.com>
In-Reply-To
<CANiSa6hcDHTpZnAXR3zxdv-H4r-yRjuSx_kgE5V1rSFk_pNhOA@mail.gmail.com>
> 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).

Previous: Martin von ZweigbergkNext: Michael Haggerty
Message 6 of 7 in “[RFC/FR] Should "git checkout (-B|-b) branch master...branch" work?”
  1. Junio C HamanoDec 21, 2012
  2. Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work?Martin von Zweigbergk, Dec 21, 2012
  3. Junio C HamanoDec 21, 2012
  4. Michael HaggertyDec 21, 2012
  5. Martin von ZweigbergkDec 21, 2012
  6. Junio C HamanoDec 21, 2012
  7. Michael HaggertyDec 21, 2012

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.