From: Johannes Sixt <j.sixt@viscovery.net>
To: Brandon Casey <casey@nrlssc.navy.mil>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: git-branch -m interprets first argument differently when two are supplied
Date: Thu, 14 Feb 2008 08:37:40 +0100 [thread overview]
Message-ID: <47B3EFC4.1020808@viscovery.net> (raw)
In-Reply-To: <47B3497A.9050703@nrlssc.navy.mil>
Brandon Casey schrieb:
> The first non-option argument is interpreted differently depending on
> whether one argument or two arguments have been supplied.
>
> git-branch -m [<oldbranch>] <newbranch>
>
> Has anyone considered whether this is inconsistent with how other
> commands operate?
Funny, I fell into this trap just yesterday and accidentally renamed
my master branch to something else. IMO git-branch -m should take two
arguments. Full stop.
Something like this.
-- >8 --
From: Johannes Sixt <johannes.sixt@telecom.at>
Subject: [PATCH] git-branch: Deprecate -m with only one argument.
"git branch -m" can be invoked with only one argument, in which case
it renames the current branch to the new name. This is inconsistent since
the first argument is either a source or destination depending on whether
a second argument follows. Furthermore, it is surprising that a rename
command that is given only one argument succeeds at all.
Let's aim for removing this feature.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
Documentation/git-branch.txt | 4 ++--
builtin-branch.c | 9 ++++++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 7e8874a..56bea06 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -12,7 +12,7 @@ SYNOPSIS
[-v [--abbrev=<length> | --no-abbrev]]
[--contains <commit>]
'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
-'git-branch' (-m | -M) [<oldbranch>] <newbranch>
+'git-branch' (-m | -M) <oldbranch> <newbranch>
'git-branch' (-d | -D) [-r] <branchname>...
DESCRIPTION
@@ -136,7 +136,7 @@ OPTIONS
<newbranch>::
The new name for an existing branch. The same restrictions as for
- <branchname> applies.
+ <branchname> apply.
Examples
diff --git a/builtin-branch.c b/builtin-branch.c
index e414c88..14df594 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -17,7 +17,7 @@ static const char * const builtin_branch_usage[] = {
"git-branch [options] [-r | -a]",
"git-branch [options] [-l] [-f] <branchname> [<start-point>]",
"git-branch [options] [-r] (-d | -D) <branchname>",
- "git-branch [options] (-m | -M) [<oldbranch>] <newbranch>",
+ "git-branch [options] (-m | -M) <oldbranch> <newbranch>",
NULL
};
@@ -609,9 +609,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
return delete_branches(argc, argv, delete > 1, kinds);
else if (argc == 0)
print_ref_list(kinds, detached, verbose, abbrev, with_commit);
- else if (rename && (argc == 1))
+ else if (rename && (argc == 1)) {
+ fprintf(stderr, "'git branch -m' with only one parameter is deprecated.\n"
+ "Will continue, assuming that you meant\n"
+ " git branch -m %s %s\n", head, argv[0]);
rename_branch(head, argv[0], rename > 1);
- else if (rename && (argc == 2))
+ } else if (rename && (argc == 2))
rename_branch(argv[0], argv[1], rename > 1);
else if (argc <= 2)
create_branch(argv[0], (argc == 2) ? argv[1] : head,
--
1.5.4.1.104.g84d88
next prev parent reply other threads:[~2008-02-14 7:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-13 19:48 git-branch -m interprets first argument differently when two are supplied Brandon Casey
2008-02-14 7:37 ` Johannes Sixt [this message]
2008-02-14 16:30 ` Brandon Casey
2008-02-14 16:49 ` Johannes Schindelin
2008-02-14 17:17 ` Brandon Casey
2008-02-14 17:50 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47B3EFC4.1020808@viscovery.net \
--to=j.sixt@viscovery.net \
--cc=casey@nrlssc.navy.mil \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).