{"thread":{"id":"5586","subject":"[PATCH 1/2] Add [-s|--hash] option to Linus' show-ref.","startedAt":"2006-09-17T04:20:24Z","lastAt":"2006-09-17T11:32:01Z","messageCount":4,"participants":["Christian Couder","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"27041","messageId":"20060917062024.c476e07d.chriscool@tuxfamily.org","threadId":"5586","inReplyTo":null,"subject":"[PATCH 1/2] Add [-s|--hash] option to Linus' show-ref.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2006-09-17T04:20:24Z","receivedAt":"2006-09-17T04:20:24Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"With this option only the sha1 hash of the ref should\nbe printed.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin-show-ref.c |   14 +++++++++++---\n 1 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-show-ref.c b/builtin-show-ref.c\nindex 161b236..577d934 100644\n--- a/builtin-show-ref.c\n+++ b/builtin-show-ref.c\n@@ -3,9 +3,10 @@ #include \"refs.h\"\n #include \"object.h\"\n #include \"tag.h\"\n \n-static const char show_ref_usage[] = \"git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--deref] [--tags] [--heads] [--] [pattern*]\";\n+static const char show_ref_usage[] = \"git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--deref] [-s|--hash] [--tags] [--heads] [--] [pattern*]\";\n \n-static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0, found_match = 0, verify = 0, quiet = 0;\n+static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,\n+\tfound_match = 0, verify = 0, quiet = 0, hash_only = 0;\n static const char **pattern;\n \n static int show_ref(const char *refname, const unsigned char *sha1)\n@@ -50,7 +51,10 @@ match:\n \t}\n \tif (quiet)\n \t\treturn 0;\n-\tprintf(\"%s %s\\n\", sha1_to_hex(sha1), refname);\n+\tif (hash_only)\n+\t\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n+\telse\n+\t\tprintf(\"%s %s\\n\", sha1_to_hex(sha1), refname);\n \tif (deref_tags && obj->type == OBJ_TAG) {\n \t\tobj = deref_tag(obj, refname, 0);\n \t\tprintf(\"%s %s^{}\\n\", sha1_to_hex(obj->sha1), refname);\n@@ -86,6 +90,10 @@ int cmd_show_ref(int argc, const char **\n \t\t\tderef_tags = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"-s\") || !strcmp(arg, \"--hash\")) {\n+\t\t\thash_only = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--verify\")) {\n \t\t\tverify = 1;\n \t\t\tcontinue;\n-- \n1.4.2.1.gea00f-dirty\n"},{"id":"27042","messageId":"20060917063224.0dc298ae.chriscool@tuxfamily.org","threadId":"5586","inReplyTo":"20060917062024.c476e07d.chriscool@tuxfamily.org","subject":"[PATCH 2/2] Use Linus' show ref in \"git-branch.sh\".","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2006-09-17T04:32:24Z","receivedAt":"2006-09-17T04:32:24Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-branch.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-branch.sh b/git-branch.sh\nindex e0501ec..2600e9c 100755\n--- a/git-branch.sh\n+++ b/git-branch.sh\n@@ -21,7 +21,7 @@ delete_branch () {\n \t,,)\n \t    die \"What branch are you on anyway?\" ;;\n \tesac\n-\tbranch=$(cat \"$GIT_DIR/refs/heads/$branch_name\") &&\n+\tbranch=$(git-show-ref --verify --hash -- \"refs/heads/$branch_name\") &&\n \t    branch=$(git-rev-parse --verify \"$branch^0\") ||\n \t\tdie \"Seriously, what branch are you talking about?\"\n \tcase \"$option\" in\n@@ -112,7 +112,7 @@ rev=$(git-rev-parse --verify \"$head\") ||\n git-check-ref-format \"heads/$branchname\" ||\n \tdie \"we do not like '$branchname' as a branch name.\"\n \n-if [ -e \"$GIT_DIR/refs/heads/$branchname\" ]\n+if git-show-ref --verify --quiet -- \"refs/heads/$branchname\"\n then\n \tif test '' = \"$force\"\n \tthen\n-- \n1.4.2.1.gea00f-dirty\n"},{"id":"27044","messageId":"eeiskc$l5n$1@sea.gmane.org","threadId":"5586","inReplyTo":"20060917062024.c476e07d.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/2] Add [-s|--hash] option to Linus' show-ref.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-17T07:15:01Z","receivedAt":"2006-09-17T07:15:01Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Christian Couder wrote:\n\n> With this option only the sha1 hash of the ref should\n> be printed.\n\nCould you please update manpage as well?\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"27070","messageId":"200609171332.01123.chriscool@tuxfamily.org","threadId":"5586","inReplyTo":"eeiskc$l5n$1@sea.gmane.org","subject":"Re: [PATCH 1/2] Add [-s|--hash] option to Linus' show-ref.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2006-09-17T11:32:01Z","receivedAt":"2006-09-17T11:32:01Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Jakub Narebski wrote:\n> Christian Couder wrote:\n> > With this option only the sha1 hash of the ref should\n> > be printed.\n>\n> Could you please update manpage as well?\n\nIt seems to me that there is no man page for git-show-ref in next right now.\n\nI could add one but I may not describe some part of it correctly.\n\nChristian.\n"}]}