Those new to git have a hard time learning how to delete a remote ref. This makes it easier for them to find out how by providing a flag to git push. Signed-off-by: Sverre Rabbelier <srabbelier@xxxxxxxxx> --- Currently `git push --delete master:master` results in a somewhat cryptic error message. It seems unlikely however, that those new to git would use the 'old:new' notation, so I haven't bothered guarding against it and settled for documenting it. Documentation/git-push.txt | 8 +++++++- builtin-push.c | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index 58d2bd5..1ecc6ca 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git push' [--all | --mirror | --tags] [--dry-run] [--receive-pack=<git-receive-pack>] - [--repo=<repository>] [-f | --force] [-v | --verbose] + [--repo=<repository>] [-f | --force] [-v | --verbose] [-d | --delete] [<repository> <refspec>...] DESCRIPTION @@ -137,6 +137,12 @@ useful if you write an alias or script around 'git-push'. --verbose:: Run verbosely. +-d:: +--delete:: + Delete the specified refs. Prefixes all refs with ':' to tell the + push machinery to delete the specified ref. As such, the refs + that are to be deleted should not contain a ':' specifier. + include::urls-remotes.txt[] OUTPUT diff --git a/builtin-push.c b/builtin-push.c index 67f6d96..b954235 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -10,11 +10,12 @@ #include "parse-options.h" static const char * const push_usage[] = { - "git push [--all | --mirror] [--dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]", + "git push [--all | --mirror] [--dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [-d | --delete] [<repository> <refspec>...]", NULL, }; static int thin; +static int push_delete; static const char *receivepack; static const char **refspec; @@ -44,6 +45,12 @@ static void set_refspecs(const char **refs, int nr) strcat(tag, refs[i]); ref = tag; } + if (push_delete) { + struct strbuf deleted = STRBUF_INIT; + strbuf_addstr(&deleted, ":"); + strbuf_addstr(&deleted, refs[i]); + ref = strbuf_detach(&deleted, NULL); + } add_refspec(ref); } } @@ -188,6 +195,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"), OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"), OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"), + OPT_BOOLEAN('d', "delete", &push_delete, "delete ref"), OPT_END() }; -- 1.6.4.16.g72c66.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html