threads / patch / 40990

patch, 2 partspush: add '--delete' flag to synopsis

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

## tl;dr

7 messages between Dec 14, 2015 and Dec 16, 2015. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Patrick Steinhardt· Dec 14, 2015, 15:23 UTC · lore

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(-)
Show changes to Documentation/git-push.txt +1 −1
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· Dec 14, 2015, 15:23 UTC · re: Patrick Steinhardt · lore

[PATCH 2/2] push: add '-d' as shorthand for '--delete'

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(-)
Show changes to 2 files +2 −2

Documentation/git-push.txt, builtin/push.c

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· Dec 14, 2015, 19:18 UTC · re: Patrick Steinhardt · lore

Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'

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".

Patrick Steinhardt· Dec 15, 2015, 09:22 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'

On Mon, Dec 14, 2015 at 11:18:18AM -0800, Junio C Hamano wrote:
Show 7 quoted lines
> 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
Jeff King· Dec 14, 2015, 21:18 UTC · re: Patrick Steinhardt · lore

Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'

On Mon, Dec 14, 2015 at 04:23:04PM +0100, Patrick Steinhardt wrote:
Show 10 quoted lines
> 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
Junio C Hamano· Dec 16, 2015, 20:29 UTC · re: Jeff King · lore

Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'

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· Dec 16, 2015, 21:52 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] push: add '-d' as shorthand for '--delete'

On Wed, Dec 16, 2015 at 12:29:38PM -0800, Junio C Hamano wrote:
Show 19 quoted lines
> 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

← back to recent threads