{"thread":{"id":"43352","subject":"Re: [PATCH] git-branch: deleting remote branches in new layout","startedAt":"2006-12-18T06:08:04Z","lastAt":"2006-12-18T22:42:16Z","messageCount":6,"participants":["Junio C Hamano","Quy Tonthat"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297117","messageId":"45863044.4040406@gmail.com","threadId":"43352","inReplyTo":null,"subject":"[PATCH] git-branch: deleting remote branches in new layout","fromName":"Quy Tonthat","fromEmail":"qtonthat@gmail.com","sentAt":"2006-12-18T06:08:04Z","receivedAt":"2006-12-18T06:08:04Z","isPatch":true,"sender":{"key":"qtonthat@gmail.com","avatar":null},"body":"Now that remote branches are in refs/remotes/, branch -D needs to know\nwhere to find them.\n\nSigned-off-by: Quy Tonthat <qtonthat@gmail.com>\n---\n builtin-branch.c |   10 ++++++++--\n 1 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 560309c..b2f0aae 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -95,6 +95,8 @@ static void delete_branches(int argc, const char **argv, int force)\n \tunsigned char sha1[20];\n \tchar *name;\n \tint i;\n+\tchar ** s;\n+\tstatic char * branches_dir[] = {\"refs/heads\", \"refs/remotes\", NULL};\n \n \tif (!force) {\n \t\thead_rev = lookup_commit_reference(head_sha1);\n@@ -105,8 +107,12 @@ static void delete_branches(int argc, const char **argv, int force)\n \t\tif (!strcmp(head, argv[i]))\n \t\t\tdie(\"Cannot delete the branch you are currently on.\");\n \n-\t\tname = xstrdup(mkpath(\"refs/heads/%s\", argv[i]));\n-\t\tif (!resolve_ref(name, sha1, 1, NULL))\n+\t\tfor (s = branches_dir; *s != NULL; s++) {\n+\t\t\tname = xstrdup(mkpath(\"%s/%s\", *s, argv[i]));\n+\t\t\tif (resolve_ref(name, sha1, 1, NULL))\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (*s == NULL)\n \t\t\tdie(\"Branch '%s' not found.\", argv[i]);\n \n \t\trev = lookup_commit_reference(sha1);\n-- \n1.4.4.1.GIT\n"},{"id":"296965","messageId":"7vbqm13cm0.fsf@assigned-by-dhcp.cox.net","threadId":"43352","inReplyTo":"45863044.4040406@gmail.com","subject":"Re: [PATCH] git-branch: deleting remote branches in new layout","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-18T07:08:23Z","receivedAt":"2006-12-18T07:08:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Quy Tonthat <qtonthat@gmail.com> writes:\n\n> Now that remote branches are in refs/remotes/, branch -D needs to know\n> where to find them.\n>\n> Signed-off-by: Quy Tonthat <qtonthat@gmail.com>\n\nI recognize that giving end users a way to remove a \"remote\ntracking branch\" might be a worthy goal (\"update-ref -d\" _could_\nbe used, but \"branch -D\" feels more natural).\n\n> +\tchar ** s;\n> +\tstatic char * branches_dir[] = {\"refs/heads\", \"refs/remotes\", NULL};\n\nBut I do not like these two entries in branches_dir[].\n\n(style: lose SP after '*' in these two lines, by the way).\n\nIf you had refs/heads/$X and refs/remotes/$X, I do not think\nthis code allows you to disambiguate.  You cannot remove\n\"remote\" one without first removing the local one, can you?\n\n> +\t\tfor (s = branches_dir; *s != NULL; s++) {\n> +\t\t\tname = xstrdup(mkpath(\"%s/%s\", *s, argv[i]));\n> +\t\t\tif (resolve_ref(name, sha1, 1, NULL))\n> +\t\t\t\tbreak;\n> +\t\t}\n> +\t\tif (*s == NULL)\n>  \t\t\tdie(\"Branch '%s' not found.\", argv[i]);\n\n(style: we seem to prefer \"if (!*s)\").\n"},{"id":"294451","messageId":"7vodq11w49.fsf@assigned-by-dhcp.cox.net","threadId":"43352","inReplyTo":"7vbqm13cm0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-branch: deleting remote branches in new layout","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-18T07:49:58Z","receivedAt":"2006-12-18T07:49:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"How about this instead?\n\nBecause -r already means \"remote\" when listing, you can say:\n\n\t$ git branch -d -r origin/todo origin/html origin/man\n\nI just twisted it not to do fast-forward check with the current\nbranch, because remote tracking branches are more like tags than\nbranches, and when you are removing them, most likely that is\nnot because you are \"done with\" them (for a local branch, it\nusually means \"you merged it up\") but because you are not even\ninterested in them.\n\n--\n\nJunio C Hamano <junkio@cox.net> writes:\n\n> Quy Tonthat <qtonthat@gmail.com> writes:\n>\n>> Now that remote branches are in refs/remotes/, branch -D needs to know\n>> where to find them.\n>>\n>> Signed-off-by: Quy Tonthat <qtonthat@gmail.com>\n>\n> I recognize that giving end users a way to remove a \"remote\n> tracking branch\" might be a worthy goal (\"update-ref -d\" _could_\n> be used, but \"branch -D\" feels more natural).\n\n builtin-branch.c |   41 ++++++++++++++++++++++++++++-------------\n 1 files changed, 28 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 560309c..7fb93e7 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -12,8 +12,12 @@\n #include \"builtin.h\"\n \n static const char builtin_branch_usage[] =\n-  \"git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]\";\n+  \"git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]\";\n \n+#define REF_UNKNOWN_TYPE    0x00\n+#define REF_LOCAL_BRANCH    0x01\n+#define REF_REMOTE_BRANCH   0x02\n+#define REF_TAG             0x04\n \n static const char *head;\n static unsigned char head_sha1[20];\n@@ -89,25 +93,40 @@ static int in_merge_bases(const unsigned char *sha1,\n \treturn ret;\n }\n \n-static void delete_branches(int argc, const char **argv, int force)\n+static void delete_branches(int argc, const char **argv, int force, int kinds)\n {\n \tstruct commit *rev, *head_rev = head_rev;\n \tunsigned char sha1[20];\n \tchar *name;\n+\tconst char *fmt, *remote;\n \tint i;\n \n+\tswitch (kinds) {\n+\tcase REF_REMOTE_BRANCH:\n+\t\tfmt = \"refs/remotes/%s\";\n+\t\tremote = \"remote \";\n+\t\tforce = 1;\n+\t\tbreak;\n+\tcase REF_LOCAL_BRANCH:\n+\t\tfmt = \"refs/heads/%s\";\n+\t\tremote = \"\";\n+\t\tbreak;\n+\tdefault:\n+\t\tdie(\"cannot use -a with -d\");\n+\t}\n+\n \tif (!force) {\n \t\thead_rev = lookup_commit_reference(head_sha1);\n \t\tif (!head_rev)\n \t\t\tdie(\"Couldn't look up commit object for HEAD\");\n \t}\n \tfor (i = 0; i < argc; i++) {\n-\t\tif (!strcmp(head, argv[i]))\n+\t\tif (kinds == REF_LOCAL_BRANCH && !strcmp(head, argv[i]))\n \t\t\tdie(\"Cannot delete the branch you are currently on.\");\n \n-\t\tname = xstrdup(mkpath(\"refs/heads/%s\", argv[i]));\n+\t\tname = xstrdup(mkpath(fmt, argv[i]));\n \t\tif (!resolve_ref(name, sha1, 1, NULL))\n-\t\t\tdie(\"Branch '%s' not found.\", argv[i]);\n+\t\t\tdie(\"%sbranch '%s' not found.\", remote, argv[i]);\n \n \t\trev = lookup_commit_reference(sha1);\n \t\tif (!rev)\n@@ -128,19 +147,15 @@ static void delete_branches(int argc, const char **argv, int force)\n \t\t}\n \n \t\tif (delete_ref(name, sha1))\n-\t\t\tprintf(\"Error deleting branch '%s'\\n\", argv[i]);\n+\t\t\tprintf(\"Error deleting %sbranch '%s'\\n\", remote,\n+\t\t\t       argv[i]);\n \t\telse\n-\t\t\tprintf(\"Deleted branch %s.\\n\", argv[i]);\n+\t\t\tprintf(\"Deleted %sbranch %s.\\n\", remote, argv[i]);\n \n \t\tfree(name);\n \t}\n }\n \n-#define REF_UNKNOWN_TYPE    0x00\n-#define REF_LOCAL_BRANCH    0x01\n-#define REF_REMOTE_BRANCH   0x02\n-#define REF_TAG             0x04\n-\n struct ref_item {\n \tchar *name;\n \tunsigned int kind;\n@@ -435,7 +450,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \thead += 11;\n \n \tif (delete)\n-\t\tdelete_branches(argc - i, argv + i, force_delete);\n+\t\tdelete_branches(argc - i, argv + i, force_delete, kinds);\n \telse if (i == argc)\n \t\tprint_ref_list(kinds, verbose, abbrev);\n \telse if (rename && (i == argc - 1))\n"},{"id":"295608","messageId":"4586671D.5020305@gmail.com","threadId":"43352","inReplyTo":"7vodq11w49.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-branch: deleting remote branches in new layout","fromName":"Quy Tonthat","fromEmail":"qtonthat@gmail.com","sentAt":"2006-12-18T10:02:05Z","receivedAt":"2006-12-18T10:02:05Z","isPatch":true,"sender":{"key":"qtonthat@gmail.com","avatar":null},"body":"Junio C Hamano wrote:\n> How about this instead?\n> \n> Because -r already means \"remote\" when listing, you can say:\n> \n> \t$ git branch -d -r origin/todo origin/html origin/man\n> \n> I just twisted it not to do fast-forward check with the current\n> branch, because remote tracking branches are more like tags than\n> branches, and when you are removing them, most likely that is\n> not because you are \"done with\" them (for a local branch, it\n> usually means \"you merged it up\") but because you are not even\n> interested in them.\n\nIt sure is much more unambiguous that way.\n\nUsers won't be able to mix \"local\" and \"remote\" on one command\nline as they were with the old layout. But that's OK for such an\ninfrequently used command.\n\n>  \t\tif (!resolve_ref(name, sha1, 1, NULL))\n> -\t\t\tdie(\"Branch '%s' not found.\", argv[i]);\n> +\t\t\tdie(\"%sbranch '%s' not found.\", remote, argv[i]);\n\nThis should not be a fatal error. We should only give warning\nand move on to the next item. The way \"rm\" does.\n\nQuy\n"},{"id":"295506","messageId":"458699FC.9060407@gmail.com","threadId":"43352","inReplyTo":"7vodq11w49.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] (Take 2) git-branch: deleting remote branches in new layout","fromName":"Quy Tonthat","fromEmail":"qtonthat@gmail.com","sentAt":"2006-12-18T13:39:08Z","receivedAt":"2006-12-18T13:39:08Z","isPatch":true,"sender":{"key":"qtonthat@gmail.com","avatar":null},"body":"This patch is based on Junio's patch (all errors are my fault, of\ncourse) to provide the following features to 'git-branch -d|-D'\n\no Option -r can be used with -d or -D to delete \"remote\" (tracking)\n  branch(es), for examples,\n\tgit branch -d -r origin/man origin/html\n  this command will delete the named branches in $GIT_DIR/refs/remotes,\n  according to the new layout.\n  (No, you can no longer mix \"local\" and \"remote\" branches in one\n  deletion command.)\n\no If there are more than one branches to be deleted, failure on one will\n  no longer stop git-branch to process the next ones.\n\no 'git-branch -d|-D' now returns error code 1 if at least one of\n  branches deleting is failed. (0 returned for fully success as before) \n\nSigned-off-by: Quy Tonthat <qtonthat@gmail.com>\n---\n\n\tThis patch is to replace my previous patch.\n\n\n builtin-branch.c |   57 ++++++++++++++++++++++++++++++++++++-----------------\n 1 files changed, 39 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 7fb93e7..52b6b5a 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -93,13 +93,14 @@ static int in_merge_bases(const unsigned char *sha1,\n \treturn ret;\n }\n \n-static void delete_branches(int argc, const char **argv, int force, int kinds)\n+static int delete_branches(int argc, const char **argv, int force, int kinds)\n {\n \tstruct commit *rev, *head_rev = head_rev;\n \tunsigned char sha1[20];\n-\tchar *name;\n+\tchar *name = NULL;\n \tconst char *fmt, *remote;\n \tint i;\n+\tint ret = 0;\n \n \tswitch (kinds) {\n \tcase REF_REMOTE_BRANCH:\n@@ -121,16 +122,30 @@ static void delete_branches(int argc, const char **argv, int force, int kinds)\n \t\t\tdie(\"Couldn't look up commit object for HEAD\");\n \t}\n \tfor (i = 0; i < argc; i++) {\n-\t\tif (kinds == REF_LOCAL_BRANCH && !strcmp(head, argv[i]))\n-\t\t\tdie(\"Cannot delete the branch you are currently on.\");\n+\t\tif (kinds == REF_LOCAL_BRANCH && !strcmp(head, argv[i])) {\n+\t\t\terror(\"Cannot delete the branch '%s' \"\n+\t\t\t\t\"which you are currently on.\", argv[i]);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (name)\n+\t\t\tfree(name);\n \n \t\tname = xstrdup(mkpath(fmt, argv[i]));\n-\t\tif (!resolve_ref(name, sha1, 1, NULL))\n-\t\t\tdie(\"%sbranch '%s' not found.\", remote, argv[i]);\n+\t\tif (!resolve_ref(name, sha1, 1, NULL)) {\n+\t\t\terror(\"%sbranch '%s' not found.\",\n+\t\t\t\t\tremote, argv[i]);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n+\t\t}\n \n \t\trev = lookup_commit_reference(sha1);\n-\t\tif (!rev)\n-\t\t\tdie(\"Couldn't look up commit object for '%s'\", name);\n+\t\tif (!rev) {\n+\t\t\terror(\"Couldn't look up commit object for '%s'\", name);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n+\t\t}\n \n \t\t/* This checks whether the merge bases of branch and\n \t\t * HEAD contains branch -- which means that the HEAD\n@@ -139,21 +154,26 @@ static void delete_branches(int argc, const char **argv, int force, int kinds)\n \n \t\tif (!force &&\n \t\t    !in_merge_bases(sha1, rev, head_rev)) {\n-\t\t\tfprintf(stderr,\n-\t\t\t\t\"The branch '%s' is not a strict subset of your current HEAD.\\n\"\n-\t\t\t\t\"If you are sure you want to delete it, run 'git branch -D %s'.\\n\",\n+\t\t\terror(\"The branch '%s' is not a strict subset of your current HEAD.\"\n+\t\t\t\t\"If you are sure you want to delete it, run 'git branch -D %s'.\",\n \t\t\t\targv[i], argv[i]);\n-\t\t\texit(1);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n \t\t}\n \n-\t\tif (delete_ref(name, sha1))\n-\t\t\tprintf(\"Error deleting %sbranch '%s'\\n\", remote,\n+\t\tif (delete_ref(name, sha1)) {\n+\t\t\terror(\"Error deleting %sbranch '%s'\", remote,\n \t\t\t       argv[i]);\n-\t\telse\n+\t\t\tret = 1;\n+\t\t} else\n \t\t\tprintf(\"Deleted %sbranch %s.\\n\", remote, argv[i]);\n \n-\t\tfree(name);\n \t}\n+\n+\tif (name)\n+\t\tfree(name);\n+\n+\treturn(ret);\n }\n \n struct ref_item {\n@@ -372,6 +392,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tint reflog = 0;\n \tint kinds = REF_LOCAL_BRANCH;\n \tint i;\n+\tint status = 0;\n \n \tsetup_ident();\n \tgit_config(git_branch_config);\n@@ -450,7 +471,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \thead += 11;\n \n \tif (delete)\n-\t\tdelete_branches(argc - i, argv + i, force_delete, kinds);\n+\t\tstatus = delete_branches(argc - i, argv + i, force_delete, kinds);\n \telse if (i == argc)\n \t\tprint_ref_list(kinds, verbose, abbrev);\n \telse if (rename && (i == argc - 1))\n@@ -464,5 +485,5 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \telse\n \t\tusage(builtin_branch_usage);\n \n-\treturn 0;\n+\treturn (status);\n }\n-- \n1.4.4.1.GIT\n"},{"id":"296377","messageId":"45871948.9090309@gmail.com","threadId":"43352","inReplyTo":"7vodq11w49.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] (Take 3) git-branch: deleting remote branches in new layout","fromName":"Quy Tonthat","fromEmail":"qtonthat@gmail.com","sentAt":"2006-12-18T22:42:16Z","receivedAt":"2006-12-18T22:42:16Z","isPatch":true,"sender":{"key":"qtonthat@gmail.com","avatar":null},"body":"This patch is based on Junio's patch (all errors are my fault, of\ncourse) to provide the following features to 'git-branch -d|-D'\n\no Option -r can be used with -d or -D to delete \"remote\" (tracking)\n  branch(es), for examples,\n\tgit branch -d -r origin/man origin/html\n  this command will delete the named branches in $GIT_DIR/refs/remotes,\n  according to the new layout.\n  (No, you can no longer mix \"local\" and \"remote\" branches in one\n  deletion command.)\n\no If there are more than one branches to be deleted, failure on one will\n  no longer stop git-branch to process the next ones.\n\no 'git-branch -d|-D' now returns error code 1 if at least one of\n  branches deleting is failed. (0 returned for fully success as before) \n\nSigned-off-by: Quy Tonthat <qtonthat@gmail.com>\n---\n\n\tThis patch is to replace all my previous patches on this thread.\n\n builtin-branch.c |   88 ++++++++++++++++++++++++++++++++++++++----------------\n 1 files changed, 62 insertions(+), 26 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 560309c..52b6b5a 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -12,8 +12,12 @@\n #include \"builtin.h\"\n \n static const char builtin_branch_usage[] =\n-  \"git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]\";\n+  \"git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]\";\n \n+#define REF_UNKNOWN_TYPE    0x00\n+#define REF_LOCAL_BRANCH    0x01\n+#define REF_REMOTE_BRANCH   0x02\n+#define REF_TAG             0x04\n \n static const char *head;\n static unsigned char head_sha1[20];\n@@ -89,12 +93,28 @@ static int in_merge_bases(const unsigned char *sha1,\n \treturn ret;\n }\n \n-static void delete_branches(int argc, const char **argv, int force)\n+static int delete_branches(int argc, const char **argv, int force, int kinds)\n {\n \tstruct commit *rev, *head_rev = head_rev;\n \tunsigned char sha1[20];\n-\tchar *name;\n+\tchar *name = NULL;\n+\tconst char *fmt, *remote;\n \tint i;\n+\tint ret = 0;\n+\n+\tswitch (kinds) {\n+\tcase REF_REMOTE_BRANCH:\n+\t\tfmt = \"refs/remotes/%s\";\n+\t\tremote = \"remote \";\n+\t\tforce = 1;\n+\t\tbreak;\n+\tcase REF_LOCAL_BRANCH:\n+\t\tfmt = \"refs/heads/%s\";\n+\t\tremote = \"\";\n+\t\tbreak;\n+\tdefault:\n+\t\tdie(\"cannot use -a with -d\");\n+\t}\n \n \tif (!force) {\n \t\thead_rev = lookup_commit_reference(head_sha1);\n@@ -102,16 +122,30 @@ static void delete_branches(int argc, const char **argv, int force)\n \t\t\tdie(\"Couldn't look up commit object for HEAD\");\n \t}\n \tfor (i = 0; i < argc; i++) {\n-\t\tif (!strcmp(head, argv[i]))\n-\t\t\tdie(\"Cannot delete the branch you are currently on.\");\n+\t\tif (kinds == REF_LOCAL_BRANCH && !strcmp(head, argv[i])) {\n+\t\t\terror(\"Cannot delete the branch '%s' \"\n+\t\t\t\t\"which you are currently on.\", argv[i]);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (name)\n+\t\t\tfree(name);\n \n-\t\tname = xstrdup(mkpath(\"refs/heads/%s\", argv[i]));\n-\t\tif (!resolve_ref(name, sha1, 1, NULL))\n-\t\t\tdie(\"Branch '%s' not found.\", argv[i]);\n+\t\tname = xstrdup(mkpath(fmt, argv[i]));\n+\t\tif (!resolve_ref(name, sha1, 1, NULL)) {\n+\t\t\terror(\"%sbranch '%s' not found.\",\n+\t\t\t\t\tremote, argv[i]);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n+\t\t}\n \n \t\trev = lookup_commit_reference(sha1);\n-\t\tif (!rev)\n-\t\t\tdie(\"Couldn't look up commit object for '%s'\", name);\n+\t\tif (!rev) {\n+\t\t\terror(\"Couldn't look up commit object for '%s'\", name);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n+\t\t}\n \n \t\t/* This checks whether the merge bases of branch and\n \t\t * HEAD contains branch -- which means that the HEAD\n@@ -120,26 +154,27 @@ static void delete_branches(int argc, const char **argv, int force)\n \n \t\tif (!force &&\n \t\t    !in_merge_bases(sha1, rev, head_rev)) {\n-\t\t\tfprintf(stderr,\n-\t\t\t\t\"The branch '%s' is not a strict subset of your current HEAD.\\n\"\n-\t\t\t\t\"If you are sure you want to delete it, run 'git branch -D %s'.\\n\",\n+\t\t\terror(\"The branch '%s' is not a strict subset of your current HEAD.\"\n+\t\t\t\t\"If you are sure you want to delete it, run 'git branch -D %s'.\",\n \t\t\t\targv[i], argv[i]);\n-\t\t\texit(1);\n+\t\t\tret = 1;\n+\t\t\tcontinue;\n \t\t}\n \n-\t\tif (delete_ref(name, sha1))\n-\t\t\tprintf(\"Error deleting branch '%s'\\n\", argv[i]);\n-\t\telse\n-\t\t\tprintf(\"Deleted branch %s.\\n\", argv[i]);\n+\t\tif (delete_ref(name, sha1)) {\n+\t\t\terror(\"Error deleting %sbranch '%s'\", remote,\n+\t\t\t       argv[i]);\n+\t\t\tret = 1;\n+\t\t} else\n+\t\t\tprintf(\"Deleted %sbranch %s.\\n\", remote, argv[i]);\n \n-\t\tfree(name);\n \t}\n-}\n \n-#define REF_UNKNOWN_TYPE    0x00\n-#define REF_LOCAL_BRANCH    0x01\n-#define REF_REMOTE_BRANCH   0x02\n-#define REF_TAG             0x04\n+\tif (name)\n+\t\tfree(name);\n+\n+\treturn(ret);\n+}\n \n struct ref_item {\n \tchar *name;\n@@ -357,6 +392,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tint reflog = 0;\n \tint kinds = REF_LOCAL_BRANCH;\n \tint i;\n+\tint status = 0;\n \n \tsetup_ident();\n \tgit_config(git_branch_config);\n@@ -435,7 +471,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \thead += 11;\n \n \tif (delete)\n-\t\tdelete_branches(argc - i, argv + i, force_delete);\n+\t\tstatus = delete_branches(argc - i, argv + i, force_delete, kinds);\n \telse if (i == argc)\n \t\tprint_ref_list(kinds, verbose, abbrev);\n \telse if (rename && (i == argc - 1))\n@@ -449,5 +485,5 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \telse\n \t\tusage(builtin_branch_usage);\n \n-\treturn 0;\n+\treturn (status);\n"}]}