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

Re: [PATCH] branch: add support for --dry-run option

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jan 22, 2015, 10:17 UTC
Message-ID
<54C0CE24.9040908@drmicha.warpmail.net>
In-Reply-To
<20150122013723.GA3795@odin.ulthar.us>
Scott Schmit schrieb am 22.01.2015 um 02:37:
Show 48 quoted lines
> On Mon, Jan 19, 2015 at 03:20:51PM +0100, Michael J Gruber wrote:
>> Alexander Kuleshov schrieb am 17.01.2015 um 08:35:
>>> This patch adds support -d/--dry-run option for branch(es) deletion.
>>> If -d/--dry-run option passed to git branch -d branch..., branch(es)
>>> will not be removed, instead just print list of branches that are
>>> to be removed.
>>>
>>> For example:
>>>
>>>     $ git branch
>>>     a
>>>     b
>>>     c
>>>     * master
>>>
>>>     $ git branch -d -n a b c
>>>     delete branch 'a' (261c0d1)
>>>     delete branch 'b' (261c0d1)
>>>     delete branch 'c' (261c0d1)
>>
>> Is there a case where deleting "a b c" would not delete "a b c"?
> 
> Sure:
> $ cd /tmp/
> $ git init foo
> Initialized empty Git repository in /tmp/foo/.git/
> $ cd foo/
> $ touch .gitignore
> $ git add .gitignore 
> $ git commit -m init
> [master (root-commit) fde5138] init
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 .gitignore
> $ git checkout -b a
> Switched to a new branch 'a'
> $ git branch -d a
> error: Cannot delete the branch 'a' which you are currently on.
> $ touch file
> $ git add file
> $ git commit -m 'add file'
> [a e2c2ece] add file
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 file
> $ git checkout -b b master
> Switched to a new branch 'b'
> $ git branch -d a
> error: The branch 'a' is not fully merged.
> If you are sure you want to delete it, run 'git branch -D a'.

Yes, and that is something that should go into the commit message. "Why do you want to add --dry-run? Because -d deletes only fully merged branches."

It should have been there in the 1st place, rather than forcing us to ask the question that always needs to answered for a patch: What is the intention? What is it good for?

In this case, we have other means to accomplish the same (--list -v), and they are more natural if you want get information about the state of the branches ("list verbose") than doing "delete dry-run".

Michael
Previous: Scott Schmit
Message 5 of 5 in “branch: add support for --dry-run option”
  1. branch: add support for --dry-run optionAlexander Kuleshov, Jan 17, 2015
  2. Philip OakleyJan 17, 2015
  3. Michael J GruberJan 19, 2015
  4. Scott SchmitJan 22, 2015
  5. Michael J GruberJan 22, 2015

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.