{"thread":{"id":"28823","subject":"'git -m' dumps core","startedAt":"2011-11-02T14:29:08Z","lastAt":"2011-11-02T19:43:25Z","messageCount":6,"participants":["Stefan Näwe","Tay Ray Chuan","Stefan Naewe","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"178688","messageId":"4EB153B4.6070404@atlas-elektronik.com","threadId":"28823","inReplyTo":null,"subject":"'git -m' dumps core","fromName":"Stefan Näwe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2011-11-02T14:29:08Z","receivedAt":"2011-11-02T14:29:08Z","isPatch":false,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"$ /usr/local/git-v1.7.8-rc0/bin/git version\ngit version 1.7.8.rc0\n\n$ /usr/local/git-v1.7.8-rc0/bin/git branch -m\nSpeicherzugriffsfehler (core dumped)\n\n$ /usr/local/git-v1.7.8-rc0/bin/git branch --move\nSpeicherzugriffsfehler (core dumped)\n\nGDB says:\n\n(gdb) bt\n#0  0xb74694f3 in strlen () from /lib/i686/cmov/libc.so.6\n#1  0x0810f1ad in strbuf_branchname (sb=0xbfb20bbc, name=0x0) at sha1_name.c:873\n#2  0x0810f20e in strbuf_check_branch_ref (sb=0xbfb20bbc, name=0x0) at sha1_name.c:882\n#3  0x080b516a in validate_new_branchname (name=0x0, ref=0xbfb20bbc, force=0, attr_only=0) at branch.c:142\n#4  0x080b550c in create_branch (head=0x94e32ab \"master\", name=0x0, start_name=0x94e32ab \"master\", force=0, reflog=0, track=BRANCH_TRACK_REMOTE)\n    at branch.c:177\n#5  0x0805a8fe in cmd_branch (argc=0, argv=0xbfb215f8, prefix=0x0) at builtin/branch.c:729\n#6  0x0804ba29 in handle_internal_command (argc=2, argv=0xbfb215f8) at git.c:308\n#7  0x0804bc67 in main (argc=2, argv=0xbfb215f8) at git.c:512\n\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: If ignorance is bliss, you must be ecstatic.\npython -c \"print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')\"\n"},{"id":"178690","messageId":"1320246098-6912-1-git-send-email-rctay89@gmail.com","threadId":"28823","inReplyTo":"4EB153B4.6070404@atlas-elektronik.com","subject":"[PATCH] branch -m: handle no arg properly","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-11-02T15:01:38Z","receivedAt":"2011-11-02T15:01:38Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Modify the option parsing heuristic to handle all -m (rename) cases,\nincluding the no-arg case. Previously, this \"fell through\" to the argc\n<= 2 case.\n\nAdd a regression test in t3200-branch.sh while we're at it.\n\nReported-by: Stefan Näwe <stefan.naewe@atlas-elektronik.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n builtin/branch.c  |   13 ++++++++-----\n t/t3200-branch.sh |    4 ++++\n 2 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 009b713..ebda8e7 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -719,11 +719,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \telse if (list)\n \t\treturn print_ref_list(kinds, detached, verbose, abbrev,\n \t\t\t\t      with_commit, argv);\n-\telse if (rename && (argc == 1))\n-\t\trename_branch(head, argv[0], rename > 1);\n-\telse if (rename && (argc == 2))\n-\t\trename_branch(argv[0], argv[1], rename > 1);\n-\telse if (argc <= 2) {\n+\telse if (rename) {\n+\t\tif (argc == 1)\n+\t\t\trename_branch(head, argv[0], rename > 1);\n+\t\telse if (argc == 2)\n+\t\t\trename_branch(argv[0], argv[1], rename > 1);\n+\t\telse\n+\t\t\tdie(_(\"new branch not specified for -m|--move\"));\n+\t} else if (argc <= 2) {\n \t\tif (kinds != REF_LOCAL_BRANCH)\n \t\t\tdie(_(\"-a and -r options to 'git branch' do not make sense with a branch name\"));\n \t\tcreate_branch(head, argv[0], (argc == 2) ? argv[1] : head,\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 2f5eada..78587fe 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -75,6 +75,10 @@ test_expect_success \\\n         git branch l'\n \n test_expect_success \\\n+    'git branch -m with no arg fails' \\\n+       'test_must_fail git branch -m'\n+\n+test_expect_success \\\n     'git branch -m m m/m should work' \\\n        'git branch -l m &&\n         git branch -m m m/m &&\n-- \n1.7.7.1.599.g03eec\n"},{"id":"178692","messageId":"1320246425-2141-1-git-send-email-stefan.naewe@gmail.com","threadId":"28823","inReplyTo":"4EB153B4.6070404@atlas-elektronik.com","subject":"[PATCH] t3200: add test case for 'branch -m'","fromName":"Stefan Naewe","fromEmail":"stefan.naewe@gmail.com","sentAt":"2011-11-02T15:07:05Z","receivedAt":"2011-11-02T15:07:05Z","isPatch":true,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>\n---\n t/t3200-branch.sh |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 2f5eada..3ce31b5 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -75,6 +75,11 @@ test_expect_success \\\n         git branch l'\n \n test_expect_success \\\n+    'git branch -m dumps usage' \\\n+       'test_expect_code 129 git branch -m 2>err &&\n+        grep \"[Uu]sage: git branch\" err'\n+\n+test_expect_success \\\n     'git branch -m m m/m should work' \\\n        'git branch -l m &&\n         git branch -m m m/m &&\n-- \n1.7.8.rc0.1.gb345ae\n"},{"id":"178691","messageId":"4EB15D20.1060107@atlas-elektronik.com","threadId":"28823","inReplyTo":"1320246098-6912-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH] branch -m: handle no arg properly","fromName":"Stefan Näwe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2011-11-02T15:09:20Z","receivedAt":"2011-11-02T15:09:20Z","isPatch":true,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Am 02.11.2011 16:01, schrieb Tay Ray Chuan:\n> Modify the option parsing heuristic to handle all -m (rename) cases,\n> including the no-arg case. Previously, this \"fell through\" to the argc\n> <= 2 case.\n> \n> Add a regression test in t3200-branch.sh while we're at it.\n\nGreat. I just sent a patch for t3200 as well...\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: If At First You Don't Succeed Ignore The Docs...\npython -c \"print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')\"\n"},{"id":"178693","messageId":"20111103001712.000024b9@unknown","threadId":"28823","inReplyTo":"4EB15D20.1060107@atlas-elektronik.com","subject":"Re: [PATCH] branch -m: handle no arg properly","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2011-11-02T16:17:12Z","receivedAt":"2011-11-02T16:17:12Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"On Wed, 02 Nov 2011 16:09:20 +0100\nStefan Näwe <stefan.naewe@atlas-elektronik.com> wrote:\n\n> Am 02.11.2011 16:01, schrieb Tay Ray Chuan:\n> > Modify the option parsing heuristic to handle all -m (rename) cases,\n> > including the no-arg case. Previously, this \"fell through\" to the argc\n> > <= 2 case.\n> > \n> > Add a regression test in t3200-branch.sh while we're at it.\n> \n> Great. I just sent a patch for t3200 as well...\n\nHmm, yeah, printing usage is a good idea.\n\nPopped my change to t3200 as well, yours looks better. :)\n\n-->8--\n\nSubject: [PATCH] branch -m: handle no arg properly\n\nModify the option parsing heuristic to handle all -m (rename) cases,\nincluding the no-arg case. Previously, this \"fell through\" to the argc\n<= 2 case.\n\nReported-by: Stefan Näwe <stefan.naewe@atlas-elektronik.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n builtin/branch.c |   13 ++++++++-----\n 1 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 009b713..51ca6a0 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -719,11 +719,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \telse if (list)\n \t\treturn print_ref_list(kinds, detached, verbose, abbrev,\n \t\t\t\t      with_commit, argv);\n-\telse if (rename && (argc == 1))\n-\t\trename_branch(head, argv[0], rename > 1);\n-\telse if (rename && (argc == 2))\n-\t\trename_branch(argv[0], argv[1], rename > 1);\n-\telse if (argc <= 2) {\n+\telse if (rename) {\n+\t\tif (argc == 1)\n+\t\t\trename_branch(head, argv[0], rename > 1);\n+\t\telse if (argc == 2)\n+\t\t\trename_branch(argv[0], argv[1], rename > 1);\n+\t\telse\n+\t\t\tusage_with_options(builtin_branch_usage, options);\n+\t} else if (argc <= 2) {\n \t\tif (kinds != REF_LOCAL_BRANCH)\n \t\t\tdie(_(\"-a and -r options to 'git branch' do not make sense with a branch name\"));\n \t\tcreate_branch(head, argv[0], (argc == 2) ? argv[1] : head,\n-- \n1.7.7.1.599.g03eec\n\n\n\n--\nCheers,\nRay Chuan\n"},{"id":"178712","messageId":"7vpqhaia3m.fsf@alter.siamese.dyndns.org","threadId":"28823","inReplyTo":"1320246425-2141-1-git-send-email-stefan.naewe@gmail.com","subject":"Re: [PATCH] t3200: add test case for 'branch -m'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-02T19:43:25Z","receivedAt":"2011-11-02T19:43:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, both.\n"}]}