{"thread":{"id":"5995","subject":"[PATCH 0/3] Add -v and -w options to git-branch","startedAt":"2006-10-22T11:30:23Z","lastAt":"2006-10-22T20:50:06Z","messageCount":7,"participants":["Lars Hjemli","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"29600","messageId":"1161516626749-git-send-email-hjemli@gmail.com","threadId":"5995","inReplyTo":null,"subject":"[PATCH 0/3] Add -v and -w options to git-branch","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-10-22T11:30:23Z","receivedAt":"2006-10-22T11:30:23Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This patch-series teaches git-branch to show sha1 and first line\nof commit message for each branch (and is a replacement for my\nprevious patches)\n\nDiffstat:\n Documentation/git-branch.txt |    8 ++++-\n git-branch.sh                |   71 ++++++++++++++++++++++++++++++++---------\n 2 files changed, 62 insertions(+), 17 deletions(-)\n"},{"id":"29602","messageId":"11615166272840-git-send-email-hjemli@gmail.com","threadId":"5995","inReplyTo":"1161516626749-git-send-email-hjemli@gmail.com","subject":"[PATCH 1/3] Fix usagestring for git-branch","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-10-22T11:30:24Z","receivedAt":"2006-10-22T11:30:24Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n git-branch.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-branch.sh b/git-branch.sh\nindex 4379a07..b80bcda 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'\n+USAGE=' [-l] [-f] <branchname> [<start-point>] | (-d | -D) <branchname> | [-r]'\n LONG_USAGE='If no arguments, show available branches and mark current branch with a star.\n If one argument, create a new branch <branchname> based off of current HEAD.\n If two arguments, create a new branch <branchname> based off of <start-point>.'\n-- \n1.4.3.1.g1688\n"},{"id":"29601","messageId":"11615166272930-git-send-email-hjemli@gmail.com","threadId":"5995","inReplyTo":"1161516626749-git-send-email-hjemli@gmail.com","subject":"[PATCH 2/3] Refactor git-branch","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-10-22T11:30:25Z","receivedAt":"2006-10-22T11:30:25Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This moves the code used to display local branches into a\nseparate function.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n git-branch.sh |   28 ++++++++++++++++------------\n 1 files changed, 16 insertions(+), 12 deletions(-)\n\ndiff --git a/git-branch.sh b/git-branch.sh\nindex b80bcda..1f628a4 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -54,6 +54,21 @@ ls_remote_branches () {\n     sort\n }\n \n+ls_local_branches () {\n+\tgit-rev-parse --symbolic --branches |\n+\tsort |\n+\twhile read ref\n+\tdo\n+\t\tif test \"$headref\" = \"$ref\"\n+\t\tthen\n+\t\t\tpfx='*'\n+\t\telse\n+\t\t\tpfx=' '\n+\t\tfi\n+\t\techo \"$pfx $ref\"\n+\tdone\n+}\n+\n force=\n create_log=\n while case \"$#,$1\" in 0,*) break ;; *,-*) ;; *) break ;; esac\n@@ -86,18 +101,7 @@ done\n \n case \"$#\" in\n 0)\n-\tgit-rev-parse --symbolic --branches |\n-\tsort |\n-\twhile read ref\n-\tdo\n-\t\tif test \"$headref\" = \"$ref\"\n-\t\tthen\n-\t\t\tpfx='*'\n-\t\telse\n-\t\t\tpfx=' '\n-\t\tfi\n-\t\techo \"$pfx $ref\"\n-\tdone\n+\tls_local_branches\n \texit 0 ;;\n 1)\n \thead=HEAD ;;\n-- \n1.4.3.1.g1688\n"},{"id":"29603","messageId":"11615166273819-git-send-email-hjemli@gmail.com","threadId":"5995","inReplyTo":"1161516626749-git-send-email-hjemli@gmail.com","subject":"[PATCH 3/3] Teach git-branch -v and -w options","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-10-22T11:30:26Z","receivedAt":"2006-10-22T11:30:26Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This makes git-branch display sha1 and first line of commit\nmessage for each branch.\n\nAdditionaly, the -w option may be used to specify columnwidth\nfor branchname (default is 20 characters)\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n Documentation/git-branch.txt |    8 ++++++-\n git-branch.sh                |   47 ++++++++++++++++++++++++++++++++++++-----\n 2 files changed, 48 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex d43ef1d..efbab61 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -8,7 +8,7 @@ git-branch - List, create, or delete bra\n SYNOPSIS\n --------\n [verse]\n-'git-branch' [-r]\n+'git-branch' [-r] [-v [-w width]]\n 'git-branch' [-l] [-f] <branchname> [<start-point>]\n 'git-branch' (-d | -D) <branchname>...\n \n@@ -47,6 +47,12 @@ OPTIONS\n -r::\n \tList only the \"remote\" branches.\n \n+-v::\n+\tShow sha1 and first line of commit message for each branch\n+\n+-w <width>::\n+\tSet columnwidth for branchname display\n+\n <branchname>::\n \tThe name of the branch to create or delete.\n \tThe new branch name must pass all checks defined by\ndiff --git a/git-branch.sh b/git-branch.sh\nindex 1f628a4..73839b4 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-USAGE=' [-l] [-f] <branchname> [<start-point>] | (-d | -D) <branchname> | [-r]'\n+USAGE=' [-l] [-f] <branchname> [<start-point>] | (-d | -D) <branchname> | [-r] [-v [-w width]]'\n LONG_USAGE='If no arguments, show available branches and mark current branch with a star.\n If one argument, create a new branch <branchname> based off of current HEAD.\n If two arguments, create a new branch <branchname> based off of <start-point>.'\n@@ -49,12 +49,26 @@ If you are sure you want to delete it, r\n }\n \n ls_remote_branches () {\n+\tverbose=\"$1\"\n+\twidth=\"$2\"\n     git-rev-parse --symbolic --all |\n     sed -ne 's|^refs/\\(remotes/\\)|\\1|p' |\n-    sort\n+    sort |\n+    while read ref\n+    do\n+\t\tif test \"$verbose\" = \"yes\"\n+\t\tthen\n+\t\t\tlog=$(git-log --pretty=oneline --max-count=1 \"$ref\")\n+\t\t\tprintf \"%-*s %s\\n\" \"$width\" \"$ref\" \"$log\"\n+\t\telse\n+\t\t\techo \"$ref\"\n+\t\tfi\n+\tdone\n }\n \n ls_local_branches () {\n+\tverbose=\"$1\"\n+\twidth=\"$2\"\n \tgit-rev-parse --symbolic --branches |\n \tsort |\n \twhile read ref\n@@ -65,12 +79,22 @@ ls_local_branches () {\n \t\telse\n \t\t\tpfx=' '\n \t\tfi\n-\t\techo \"$pfx $ref\"\n+\t\tif test \"$verbose\" = \"yes\"\n+\t\tthen\n+\t\t\tlog=$(git-log --pretty=oneline --max-count=1 \"$ref\")\n+\t\t\tprintf \"%s %-*s %s\\n\" \"$pfx\" \"$width\" \"$ref\" \"$log\"\n+\t\telse\n+\t\t\techo \"$pfx $ref\"\n+\t\tfi\n \tdone\n }\n \n force=\n create_log=\n+remotes=\n+verbose=\n+width=20\n+\n while case \"$#,$1\" in 0,*) break ;; *,-*) ;; *) break ;; esac\n do\n \tcase \"$1\" in\n@@ -79,8 +103,14 @@ do\n \t\texit\n \t\t;;\n \t-r)\n-\t\tls_remote_branches\n-\t\texit\n+\t\tremotes=\"yes\"\n+\t\t;;\n+\t-v)\n+\t\tverbose=\"yes\"\n+\t\t;;\n+\t-w)\n+\t\tshift\n+\t\twidth=\"$1\"\n \t\t;;\n \t-f)\n \t\tforce=\"$1\"\n@@ -101,7 +131,12 @@ done\n \n case \"$#\" in\n 0)\n-\tls_local_branches\n+\tif test \"$remotes\" = \"yes\"\n+\tthen\n+\t\tls_remote_branches \"$verbose\" \"$width\"\n+\telse\n+\t\tls_local_branches \"$verbose\" \"$width\"\n+\tfi\n \texit 0 ;;\n 1)\n \thead=HEAD ;;\n-- \n1.4.3.1.g1688\n"},{"id":"29660","messageId":"7vmz7o5eki.fsf@assigned-by-dhcp.cox.net","threadId":"5995","inReplyTo":"11615166273819-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH 3/3] Teach git-branch -v and -w options","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-22T19:35:25Z","receivedAt":"2006-10-22T19:35:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> This makes git-branch display sha1 and first line of commit\n> message for each branch.\n>\n> Additionaly, the -w option may be used to specify columnwidth\n> for branchname (default is 20 characters)\n>\n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n\nIf you are going in this direction, probably you would want to\nrefactor 2/3 a bit differently, so that you do not have to\nduplicate the same printf for local and remote cases?\n"},{"id":"29663","messageId":"8c5c35580610221255n521e84e2u8594016297c6cf87@mail.gmail.com","threadId":"5995","inReplyTo":"7vmz7o5eki.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] Teach git-branch -v and -w options","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-10-22T19:55:52Z","receivedAt":"2006-10-22T19:55:52Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 10/22/06, Junio C Hamano <junkio@cox.net> wrote:\n> If you are going in this direction, probably you would want to\n> refactor 2/3 a bit differently, so that you do not have to\n> duplicate the same printf for local and remote cases?\n>\n\nI actually did, but then abandoned it since it would change the output\nfor remote branches (two spaces indent). I didn't want to cause any\nregressions :-)\n\nBut if that's ok, my abandoned patch contained this:\n\n@@ -48,14 +48,35 @@ If you are sure you want to delete it, r\n    exit 0\n }\n\n-ls_remote_branches () {\n-    git-rev-parse --symbolic --all |\n-    sed -ne 's|^refs/\\(remotes/\\)|\\1|p' |\n-    sort\n-}\n-+width=20\n+sedmatch=\"^refs/heads/\"\n+sedsubst=\n+verbose=\n force=\n create_log=\n+\n+ls_refs () {\n+       git-rev-parse --symbolic --all |\n+       sed -ne \"s|$sedmatch|$sedsubst|p\" |\n+       sort |\n+       while read ref\n+       do\n+               if test \"$headref\" = \"$ref\"\n+               then\n+                       pfx='*'\n+               else\n+                       pfx=' '\n+               fi\n+               if test \"$verbose\" = \"yes\"\n+               then\n+                       log=$(git-log --max-count=1 --pretty=oneline $ref)\n+                       printf \"%s %-*s %s\\n\" \"$pfx\" \"$width\" \"$ref\" \"$log\"\n+               else\n+                       echo \"$pfx $ref\"\n+               fi\n+       done\n+}\n+\n while case \"$#,$1\" in 0,*) break ;; *,-*) ;; *) break ;; esac\n do\n       case \"$1\" in\n@@ -64,8 +85,8 @@ do\n               exit\n               ;;\n       -r)\n-               ls_remote_branches\n-               exit\n+               sedmatch=\"^refs/\\(remotes/\\)\"\n+               sedsubst=\"\\1\"\n               ;;\n       -f)\n               force=\"$1\"\n@@ -73,6 +94,13 @@ do\n       -l)\n               create_log=\"yes\"\n               ;;\n+       -v)\n+               verbose=\"yes\"\n+               ;;\n+       -w)\n+               shift\n+               width=$1\n+               ;;\n       --)\n               shift\n               break\n@@ -86,18 +114,7 @@ done\n\n case \"$#\" in\n 0)\n-       git-rev-parse --symbolic --branches |\n-       sort |\n-       while read ref\n-       do\n-               if test \"$headref\" = \"$ref\"\n-               then\n-                       pfx='*'\n-               else\n-                       pfx=' '\n-               fi\n-               echo \"$pfx $ref\"\n-       done\n+       ls_refs\n       exit 0 ;;\n 1)\n       head=HEAD ;;\n\n\nAnd then I added -a and -t (for \"all\" and \"tags\", obviously), and felt\nI went over the top :-)\n\nBtw: in the meantime, Kristian Høgsberg pointed me to an earlier\nthread regarding making git-branch a builtin, which I'm going to look\nat tonight.\n\nSo many options, so little time :-)\n\nI'm open for suggestions/preferences etc...\n\n--\nlarsh\n"},{"id":"29672","messageId":"8c5c35580610221350q7107286eqd2ee8c5a4b09d341@mail.gmail.com","threadId":"5995","inReplyTo":"7vy7r83x9f.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] Teach git-branch -v and -w options","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-10-22T20:50:06Z","receivedAt":"2006-10-22T20:50:06Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"[the gitlist fell off my first reply, so I've put it back...]\n\nOn 10/22/06, Junio C Hamano <junkio@cox.net> wrote:\n> I was almost going to say that your patch saddened me because\n> doing builtin-branch on top of Linus's packed-refs work (which\n> means doing the series on top of \"next\") was part of my plan,\n\nHeh, I don't want to compete with your c-skills :-)\n\n\n> If you are aware of Kristian's patch that is a good news.  I do\n> not have much objection to add optional frills to git-branch\n> listing output, but I'd rather not see it done in the shell\n> implementation.  Doing anything on the current git-branch.sh\n> means that would need to be re-done later.\n\nAgreed. I'll try and come up with a builtin instead, and let you worry\nabout more interesting stuff.\n\n-- \nlarsh\n"}]}