# [PATCH 1/2] push: add '--delete' flag to synopsis

7 messages from 2015-12-14 to 2015-12-16. Participants: Patrick Steinhardt, Junio C Hamano, Jeff King.
Thread: https://gitlist.dev/t/40990

## Patrick Steinhardt, 2015-12-14 15:23

Subject: [PATCH 1/2] push: add '--delete' flag to synopsis
Message-ID: <1450106584-22313-1-git-send-email-ps@pks.im>
URL: https://gitlist.dev/e/1450106584-22313-1-git-send-email-ps%40pks.im

```
The delete flag is not mentioned in the synopsis of `git-push`.
Add the flag to make it more discoverable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/git-push.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 85a4d7d..e830c08 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
-	   [--repo=<repository>] [-f | --force] [--prune] [-v | --verbose]
+	   [--repo=<repository>] [-f | --force] [--delete] [--prune] [-v | --verbose]
 	   [-u | --set-upstream]
 	   [--[no-]signed|--sign=(true|false|if-asked)]
 	   [--force-with-lease[=<refname>[:<expect>]]]
-- 
2.6.4

```

## Patrick Steinhardt, 2015-12-14 15:23

Subject: [PATCH 2/2] push: add '-d' as shorthand for '--delete'
Message-ID: <1450106584-22313-2-git-send-email-ps@pks.im>
URL: https://gitlist.dev/e/1450106584-22313-2-git-send-email-ps%40pks.im
In-Reply-To: <1450106584-22313-1-git-send-email-ps@pks.im>

```
It is only possible to delete branches on remotes by specifying
the long '--delete' flag. The `git-branch` command, which can be
used to delete local branches with the same '--delete' flag, also
accepts the shorthand '-d'. This may cause confusion for users
which are frequently using the shorthand form of deleting local
branches and subsequently try to use the same shorthand for
`git-push`, which will fail.

Fix this usability issue by adding the '-d' shorthand to
`git-push` and document it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/git-push.txt | 2 +-
 builtin/push.c             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index e830c08..6f5d98c 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
-	   [--repo=<repository>] [-f | --force] [--delete] [--prune] [-v | --verbose]
+	   [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]
 	   [-u | --set-upstream]
 	   [--[no-]signed|--sign=(true|false|if-asked)]
 	   [--force-with-lease[=<refname>[:<expect>]]]
diff --git a/builtin/push.c b/builtin/push.c
index 3bda430..093011d 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -540,7 +540,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		OPT_BIT( 0 , "all", &flags, N_("push all refs"), TRANSPORT_PUSH_ALL),
 		OPT_BIT( 0 , "mirror", &flags, N_("mirror all refs"),
 			    (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
-		OPT_BOOL( 0, "delete", &deleterefs, N_("delete refs")),
+		OPT_BOOL('d', "delete", &deleterefs, N_("delete refs")),
 		OPT_BOOL( 0 , "tags", &tags, N_("push tags (can't be used with --all or --mirror)")),
 		OPT_BIT('n' , "dry-run", &flags, N_("dry run"), TRANSPORT_PUSH_DRY_RUN),
 		OPT_BIT( 0,  "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN),
-- 
2.6.4

```

## Junio C Hamano, 2015-12-14 19:18

Subject: Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'
Message-ID: <xmqqegeokfet.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqegeokfet.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <1450106584-22313-2-git-send-email-ps@pks.im>

```
Patrick Steinhardt <ps@pks.im> writes:

> It is only possible to delete branches on remotes by specifying
> the long '--delete' flag.

Not really.  "git push origin :unnecessary-branch" should just work
with out "--delete" or "-d".

```

## Jeff King, 2015-12-14 21:18

Subject: Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'
Message-ID: <20151214211856.GF14788@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20151214211856.GF14788%40sigill.intra.peff.net
In-Reply-To: <1450106584-22313-2-git-send-email-ps@pks.im>

```
On Mon, Dec 14, 2015 at 04:23:04PM +0100, Patrick Steinhardt wrote:

> It is only possible to delete branches on remotes by specifying
> the long '--delete' flag. The `git-branch` command, which can be
> used to delete local branches with the same '--delete' flag, also
> accepts the shorthand '-d'. This may cause confusion for users
> which are frequently using the shorthand form of deleting local
> branches and subsequently try to use the same shorthand for
> `git-push`, which will fail.
> 
> Fix this usability issue by adding the '-d' shorthand to
> `git-push` and document it.

I think we didn't give it "-d" originally, because we usually avoid
allocating short-options (which are a limited resource) until an option
has proven itself.

At this point, it seems that "--delete" is useful, and nothing else has
been proposed for "-d" in the intervening years. It seems like a
reasonable use of the flag to me.

I have been bitten by this myself. I know about "git push origin
:ref-to-delete", of course, but my brain would much rather type "-d"
(and it's also easier when piping to xargs).

-Peff

```

## Patrick Steinhardt, 2015-12-15 09:22

Subject: Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'
Message-ID: <20151215092206.GA1209@pks-xps.elego.de>
URL: https://gitlist.dev/e/20151215092206.GA1209%40pks-xps.elego.de
In-Reply-To: <xmqqegeokfet.fsf@gitster.mtv.corp.google.com>

```
On Mon, Dec 14, 2015 at 11:18:18AM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > It is only possible to delete branches on remotes by specifying
> > the long '--delete' flag.
> 
> Not really.  "git push origin :unnecessary-branch" should just work
> with out "--delete" or "-d".

Well, sure, didn't think about this when phrasing the commit
message. Still I think my point stands that it is more convenient
for users to also have the '-d' shorthand, as is also in use for
branch deletion in `git-branch`. I'll resend this patch with a
corrected message.

Patrick

```

## Junio C Hamano, 2015-12-16 20:29

Subject: Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'
Message-ID: <xmqqr3imcf2l.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqr3imcf2l.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20151214211856.GF14788@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> At this point, it seems that "--delete" is useful, and nothing else has
> been proposed for "-d" in the intervening years. It seems like a
> reasonable use of the flag to me.

I think there were two (and a half) reasons why we didn't let
"--delete" use a short-and-sweet "-d", and I agree that "something
else that is more useful did not come" removes one of them.

The other reason was to avoid the chance of fat-fingering, because
deleting is destructive, and it is even harder to recover from if
the damage is done remotely (and the remaining one-half is that
deleting is a rare event).

Even though I do not think the need for the "safety" has been
reduced over time to warrant this change, a similarity with "branch"
that has "-d/--delete" would be a good enough argument to support
this change.

Thanks.

```

## Jeff King, 2015-12-16 21:52

Subject: Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'
Message-ID: <20151216215252.GA11615@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20151216215252.GA11615%40sigill.intra.peff.net
In-Reply-To: <xmqqr3imcf2l.fsf@gitster.mtv.corp.google.com>

```
On Wed, Dec 16, 2015 at 12:29:38PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > At this point, it seems that "--delete" is useful, and nothing else has
> > been proposed for "-d" in the intervening years. It seems like a
> > reasonable use of the flag to me.
> 
> I think there were two (and a half) reasons why we didn't let
> "--delete" use a short-and-sweet "-d", and I agree that "something
> else that is more useful did not come" removes one of them.
> 
> The other reason was to avoid the chance of fat-fingering, because
> deleting is destructive, and it is even harder to recover from if
> the damage is done remotely (and the remaining one-half is that
> deleting is a rare event).
> 
> Even though I do not think the need for the "safety" has been
> reduced over time to warrant this change, a similarity with "branch"
> that has "-d/--delete" would be a good enough argument to support
> this change.

Thanks for the input, I hadn't considered "safety" at all. We do have
safety measures on "git branch -d" that we don't have here. I guess we
could implement something similar (e.g., see if the to-be-deleted branch
is merged elsewhere; of course we might not have the objects locally at
all). On the other hand, you can already screw yourself pretty badly
with "push -f".

So I think it's probably OK to add "-d".

-Peff

```
