{"thread":{"id":"7287","subject":"[PATCH] git-symbolic-ref: fix error message when ref doesn't exist","startedAt":"2007-03-18T01:53:02Z","lastAt":"2007-03-19T09:03:52Z","messageCount":3,"participants":["Julian Phillips","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"37348","messageId":"20070318020645.2444.75365.julian@quantumfyre.co.uk","threadId":"7287","inReplyTo":null,"subject":"[PATCH] git-symbolic-ref: fix error message when ref doesn't exist","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2007-03-18T01:53:02Z","receivedAt":"2007-03-18T01:53:02Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"When calling resolve_ref from check_symref set reading to 1, since we\ndo want to know if the given ref doesn't exist.  This means that\n\"git symbolic-ref foo\" will now print \"fatal: No such ref: foo\" as\nexpected.\n\nSigned-off-by: Julian Phillips <julian@quantumfyre.co.uk>\n---\n\nWhile looking at how fetch worked, I noticed that symbolic-ref was\nsupposed to differentiate between non-existent refs and non-symbolic refs.\nSomething I hadn't noticed it doing on those occasions when my fingers\nhad failed me ...\n\nI also noticed that the man page says that symbolic-ref will return 1 when\nthe specified reference is non-symbolic.  This is only true when using -q,\nbut I don't know if the code or man page wants changing ...\n\n builtin-symbolic-ref.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c\nindex d41b406..a93c85d 100644\n--- a/builtin-symbolic-ref.c\n+++ b/builtin-symbolic-ref.c\n@@ -9,7 +9,7 @@ static void check_symref(const char *HEAD, int quiet)\n {\n \tunsigned char sha1[20];\n \tint flag;\n-\tconst char *refs_heads_master = resolve_ref(HEAD, sha1, 0, &flag);\n+\tconst char *refs_heads_master = resolve_ref(HEAD, sha1, 1, &flag);\n \n \tif (!refs_heads_master)\n \t\tdie(\"No such ref: %s\", HEAD);\n-- \n1.5.0.4\n"},{"id":"37478","messageId":"7vslc1iprn.fsf@assigned-by-dhcp.cox.net","threadId":"7287","inReplyTo":"20070318020645.2444.75365.julian@quantumfyre.co.uk","subject":"Re: [PATCH] git-symbolic-ref: fix error message when ref doesn't exist","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-19T08:47:08Z","receivedAt":"2007-03-19T08:47:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Julian Phillips <julian@quantumfyre.co.uk> writes:\n\n> When calling resolve_ref from check_symref set reading to 1, since we\n> do want to know if the given ref doesn't exist.  This means that\n> \"git symbolic-ref foo\" will now print \"fatal: No such ref: foo\" as\n> expected.\n\nHmmmm.  That would break:\n\n\t$ rm -fr a; mkdir a; cd a\n\t$ git init-db\n        $ git symbolic-ref HEAD\n        refs/heads/master\n\nwouldn't it?  We do want it not to fail and tell us that the\ncommit we are going to create will be on refs/heads/master\n(i.e. \"the master branch\").\n\nAnd  the command errors out as expected when given a\nnon-existent symbolic ref:\n\n\t$ git symbolic-ref no-such; echo $?\n\tfatal: ref no-such is not a symbolic ref\n\t128\n"},{"id":"37479","messageId":"Pine.LNX.4.64.0703190857320.25879@beast.quantumfyre.co.uk","threadId":"7287","inReplyTo":"7vslc1iprn.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-symbolic-ref: fix error message when ref doesn't exist","fromName":"Julian Phillips","fromEmail":"julian@quantumfyre.co.uk","sentAt":"2007-03-19T09:03:52Z","receivedAt":"2007-03-19T09:03:52Z","isPatch":true,"sender":{"key":"julian@quantumfyre.co.uk","avatar":"https://avatars.githubusercontent.com/u/948888?v=4"},"body":"On Mon, 19 Mar 2007, Junio C Hamano wrote:\n\n> Julian Phillips <julian@quantumfyre.co.uk> writes:\n>\n>> When calling resolve_ref from check_symref set reading to 1, since we\n>> do want to know if the given ref doesn't exist.  This means that\n>> \"git symbolic-ref foo\" will now print \"fatal: No such ref: foo\" as\n>> expected.\n>\n> Hmmmm.  That would break:\n>\n> \t$ rm -fr a; mkdir a; cd a\n> \t$ git init-db\n>        $ git symbolic-ref HEAD\n>        refs/heads/master\n>\n> wouldn't it?  We do want it not to fail and tell us that the\n> commit we are going to create will be on refs/heads/master\n> (i.e. \"the master branch\").\n\nUm .. yes ... as per the comment in refs.c ... :$\n\n>\n> And  the command errors out as expected when given a\n> non-existent symbolic ref:\n>\n> \t$ git symbolic-ref no-such; echo $?\n> \tfatal: ref no-such is not a symbolic ref\n> \t128\n>\n\nThe thing is, that wasn't what I expected.  From looking at the code for \nsymbolic-ref I was expecting:\n\n \t$ git symbolic-ref no-such; echo $?\n \tfatal: No such ref: no-such\n \t128\n\nIn particular, in quiet mode you will get a return of 1 - rather than \n128, which would potentially lead you astray if you belived the man page \n...\n\n-- \nJulian\n\n  ---\n\"Intelligence without character is a dangerous thing.\"\n-- G. Steinem\n"}]}