* 'git -m' dumps core
@ 2011-11-02 14:29 Stefan Näwe
2011-11-02 15:01 ` [PATCH] branch -m: handle no arg properly Tay Ray Chuan
2011-11-02 15:07 ` [PATCH] t3200: add test case for 'branch -m' Stefan Naewe
0 siblings, 2 replies; 6+ messages in thread
From: Stefan Näwe @ 2011-11-02 14:29 UTC (permalink / raw)
To: git@vger.kernel.org; +Cc: Junio C. Hamano
$ /usr/local/git-v1.7.8-rc0/bin/git version
git version 1.7.8.rc0
$ /usr/local/git-v1.7.8-rc0/bin/git branch -m
Speicherzugriffsfehler (core dumped)
$ /usr/local/git-v1.7.8-rc0/bin/git branch --move
Speicherzugriffsfehler (core dumped)
GDB says:
(gdb) bt
#0 0xb74694f3 in strlen () from /lib/i686/cmov/libc.so.6
#1 0x0810f1ad in strbuf_branchname (sb=0xbfb20bbc, name=0x0) at sha1_name.c:873
#2 0x0810f20e in strbuf_check_branch_ref (sb=0xbfb20bbc, name=0x0) at sha1_name.c:882
#3 0x080b516a in validate_new_branchname (name=0x0, ref=0xbfb20bbc, force=0, attr_only=0) at branch.c:142
#4 0x080b550c in create_branch (head=0x94e32ab "master", name=0x0, start_name=0x94e32ab "master", force=0, reflog=0, track=BRANCH_TRACK_REMOTE)
at branch.c:177
#5 0x0805a8fe in cmd_branch (argc=0, argv=0xbfb215f8, prefix=0x0) at builtin/branch.c:729
#6 0x0804ba29 in handle_internal_command (argc=2, argv=0xbfb215f8) at git.c:308
#7 0x0804bc67 in main (argc=2, argv=0xbfb215f8) at git.c:512
Stefan
--
----------------------------------------------------------------
/dev/random says: If ignorance is bliss, you must be ecstatic.
python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')"
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] branch -m: handle no arg properly
2011-11-02 14:29 'git -m' dumps core Stefan Näwe
@ 2011-11-02 15:01 ` Tay Ray Chuan
2011-11-02 15:09 ` Stefan Näwe
2011-11-02 15:07 ` [PATCH] t3200: add test case for 'branch -m' Stefan Naewe
1 sibling, 1 reply; 6+ messages in thread
From: Tay Ray Chuan @ 2011-11-02 15:01 UTC (permalink / raw)
To: git; +Cc: Stefan Näwe, Junio C. Hamano
Modify the option parsing heuristic to handle all -m (rename) cases,
including the no-arg case. Previously, this "fell through" to the argc
<= 2 case.
Add a regression test in t3200-branch.sh while we're at it.
Reported-by: Stefan Näwe <stefan.naewe@atlas-elektronik.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
builtin/branch.c | 13 ++++++++-----
t/t3200-branch.sh | 4 ++++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 009b713..ebda8e7 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -719,11 +719,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
else if (list)
return print_ref_list(kinds, detached, verbose, abbrev,
with_commit, argv);
- else if (rename && (argc == 1))
- rename_branch(head, argv[0], rename > 1);
- else if (rename && (argc == 2))
- rename_branch(argv[0], argv[1], rename > 1);
- else if (argc <= 2) {
+ else if (rename) {
+ if (argc == 1)
+ rename_branch(head, argv[0], rename > 1);
+ else if (argc == 2)
+ rename_branch(argv[0], argv[1], rename > 1);
+ else
+ die(_("new branch not specified for -m|--move"));
+ } else if (argc <= 2) {
if (kinds != REF_LOCAL_BRANCH)
die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 2f5eada..78587fe 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -75,6 +75,10 @@ test_expect_success \
git branch l'
test_expect_success \
+ 'git branch -m with no arg fails' \
+ 'test_must_fail git branch -m'
+
+test_expect_success \
'git branch -m m m/m should work' \
'git branch -l m &&
git branch -m m m/m &&
--
1.7.7.1.599.g03eec
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] t3200: add test case for 'branch -m'
2011-11-02 14:29 'git -m' dumps core Stefan Näwe
2011-11-02 15:01 ` [PATCH] branch -m: handle no arg properly Tay Ray Chuan
@ 2011-11-02 15:07 ` Stefan Naewe
2011-11-02 19:43 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Naewe @ 2011-11-02 15:07 UTC (permalink / raw)
To: git; +Cc: gitster, Stefan Naewe
Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
---
t/t3200-branch.sh | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 2f5eada..3ce31b5 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -75,6 +75,11 @@ test_expect_success \
git branch l'
test_expect_success \
+ 'git branch -m dumps usage' \
+ 'test_expect_code 129 git branch -m 2>err &&
+ grep "[Uu]sage: git branch" err'
+
+test_expect_success \
'git branch -m m m/m should work' \
'git branch -l m &&
git branch -m m m/m &&
--
1.7.8.rc0.1.gb345ae
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] branch -m: handle no arg properly
2011-11-02 15:01 ` [PATCH] branch -m: handle no arg properly Tay Ray Chuan
@ 2011-11-02 15:09 ` Stefan Näwe
2011-11-02 16:17 ` Tay Ray Chuan
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Näwe @ 2011-11-02 15:09 UTC (permalink / raw)
To: Tay Ray Chuan; +Cc: git@vger.kernel.org, Junio C. Hamano
Am 02.11.2011 16:01, schrieb Tay Ray Chuan:
> Modify the option parsing heuristic to handle all -m (rename) cases,
> including the no-arg case. Previously, this "fell through" to the argc
> <= 2 case.
>
> Add a regression test in t3200-branch.sh while we're at it.
Great. I just sent a patch for t3200 as well...
Stefan
--
----------------------------------------------------------------
/dev/random says: If At First You Don't Succeed Ignore The Docs...
python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] branch -m: handle no arg properly
2011-11-02 15:09 ` Stefan Näwe
@ 2011-11-02 16:17 ` Tay Ray Chuan
0 siblings, 0 replies; 6+ messages in thread
From: Tay Ray Chuan @ 2011-11-02 16:17 UTC (permalink / raw)
To: Stefan Näwe; +Cc: git@vger.kernel.org, Junio C. Hamano
On Wed, 02 Nov 2011 16:09:20 +0100
Stefan Näwe <stefan.naewe@atlas-elektronik.com> wrote:
> Am 02.11.2011 16:01, schrieb Tay Ray Chuan:
> > Modify the option parsing heuristic to handle all -m (rename) cases,
> > including the no-arg case. Previously, this "fell through" to the argc
> > <= 2 case.
> >
> > Add a regression test in t3200-branch.sh while we're at it.
>
> Great. I just sent a patch for t3200 as well...
Hmm, yeah, printing usage is a good idea.
Popped my change to t3200 as well, yours looks better. :)
-->8--
Subject: [PATCH] branch -m: handle no arg properly
Modify the option parsing heuristic to handle all -m (rename) cases,
including the no-arg case. Previously, this "fell through" to the argc
<= 2 case.
Reported-by: Stefan Näwe <stefan.naewe@atlas-elektronik.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
builtin/branch.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 009b713..51ca6a0 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -719,11 +719,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
else if (list)
return print_ref_list(kinds, detached, verbose, abbrev,
with_commit, argv);
- else if (rename && (argc == 1))
- rename_branch(head, argv[0], rename > 1);
- else if (rename && (argc == 2))
- rename_branch(argv[0], argv[1], rename > 1);
- else if (argc <= 2) {
+ else if (rename) {
+ if (argc == 1)
+ rename_branch(head, argv[0], rename > 1);
+ else if (argc == 2)
+ rename_branch(argv[0], argv[1], rename > 1);
+ else
+ usage_with_options(builtin_branch_usage, options);
+ } else if (argc <= 2) {
if (kinds != REF_LOCAL_BRANCH)
die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
--
1.7.7.1.599.g03eec
--
Cheers,
Ray Chuan
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] t3200: add test case for 'branch -m'
2011-11-02 15:07 ` [PATCH] t3200: add test case for 'branch -m' Stefan Naewe
@ 2011-11-02 19:43 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2011-11-02 19:43 UTC (permalink / raw)
To: Stefan Naewe; +Cc: git, Tay Ray Chuan
Thanks, both.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-11-02 19:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-02 14:29 'git -m' dumps core Stefan Näwe
2011-11-02 15:01 ` [PATCH] branch -m: handle no arg properly Tay Ray Chuan
2011-11-02 15:09 ` Stefan Näwe
2011-11-02 16:17 ` Tay Ray Chuan
2011-11-02 15:07 ` [PATCH] t3200: add test case for 'branch -m' Stefan Naewe
2011-11-02 19:43 ` Junio C Hamano
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).