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

Re: [PATCH/RFC] branch: add tests for new copy branch feature

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 13, 2017, 17:55 UTC
Message-ID
<20170613175501.GH133952@aiede.mtv.corp.google.com>
In-Reply-To
<CACBZZX6LcTzFKTe0fENj95Vm7GrxT5HHs3pzrqajG0XApN-rbw@mail.gmail.com>
Hi,
Ævar Arnfjörð Bjarmason wrote:
Show 27 quoted lines
> So the reason we have this for -m is:
>
>     commit 3f59481e33
>     Author: Jonathan Nieder <jrnieder@gmail.com>
>     Date:   Fri Nov 25 20:30:02 2011 -0600
>
>     branch: allow a no-op "branch -M <current-branch> HEAD"
>
>     Overwriting the current branch with a different commit is forbidden, as it
>     will make the status recorded in the index and the working tree out of
>     sync with respect to the HEAD. There however is no reason to forbid it if
>     the current branch is renamed to itself, which admittedly is something
>     only an insane user would do, but is handy for scripts.
>
> My understanding of that last part is that Jonathan/someone (see
> reported-by in that patch) had some script which was renaming
> branches, and it was easier for whatever reason to just make it no-op
> if the rename would have yielded the same result as doing nothing at
> all.
>
> Most likely your implementation will consist of just re-using the
> logic in rename_branch() (and renaming it to e.g.
> copy_or_rename_branch() ...) so you could just re-use the no-op
> behavior we use for -m, or if there's some reason not to no-op and
> error instead for -c we could just do that, but in any case this case
> of `git branch -c master master` or `git branch -c currentbranch`
> should be tested for.

I may be missing some context, but notice that the above mentioned commit is about -M, not -m.

Thanks and hope that helps, Jonathan

Previous: Sahil DuaNext: Ævar Arnfjörð Bjarmason
Message 6 of 10 in “branch: add tests for new copy branch feature”
  1. branch: add tests for new copy branch featureSahil Dua, May 28, 2017
  2. Ævar Arnfjörð BjarmasonMay 28, 2017
  3. Sahil DuaMay 29, 2017
  4. Ævar Arnfjörð BjarmasonMay 29, 2017
  5. Sahil DuaMay 29, 2017
  6. Jonathan NiederJun 13, 2017
  7. Ævar Arnfjörð BjarmasonJun 13, 2017
  8. Jonathan NiederJun 13, 2017
  9. Junio C HamanoMay 29, 2017
  10. Sahil DuaMay 29, 2017

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.