* [PATCH] git-symbolic-ref: fix error message when ref doesn't exist
@ 2007-03-18 1:53 Julian Phillips
2007-03-19 8:47 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Julian Phillips @ 2007-03-18 1:53 UTC (permalink / raw
To: git
When calling resolve_ref from check_symref set reading to 1, since we
do want to know if the given ref doesn't exist. This means that
"git symbolic-ref foo" will now print "fatal: No such ref: foo" as
expected.
Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
---
While looking at how fetch worked, I noticed that symbolic-ref was
supposed to differentiate between non-existent refs and non-symbolic refs.
Something I hadn't noticed it doing on those occasions when my fingers
had failed me ...
I also noticed that the man page says that symbolic-ref will return 1 when
the specified reference is non-symbolic. This is only true when using -q,
but I don't know if the code or man page wants changing ...
builtin-symbolic-ref.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index d41b406..a93c85d 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -9,7 +9,7 @@ static void check_symref(const char *HEAD, int quiet)
{
unsigned char sha1[20];
int flag;
- const char *refs_heads_master = resolve_ref(HEAD, sha1, 0, &flag);
+ const char *refs_heads_master = resolve_ref(HEAD, sha1, 1, &flag);
if (!refs_heads_master)
die("No such ref: %s", HEAD);
--
1.5.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] git-symbolic-ref: fix error message when ref doesn't exist
2007-03-18 1:53 [PATCH] git-symbolic-ref: fix error message when ref doesn't exist Julian Phillips
@ 2007-03-19 8:47 ` Junio C Hamano
2007-03-19 9:03 ` Julian Phillips
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-03-19 8:47 UTC (permalink / raw
To: Julian Phillips; +Cc: git
Julian Phillips <julian@quantumfyre.co.uk> writes:
> When calling resolve_ref from check_symref set reading to 1, since we
> do want to know if the given ref doesn't exist. This means that
> "git symbolic-ref foo" will now print "fatal: No such ref: foo" as
> expected.
Hmmmm. That would break:
$ rm -fr a; mkdir a; cd a
$ git init-db
$ git symbolic-ref HEAD
refs/heads/master
wouldn't it? We do want it not to fail and tell us that the
commit we are going to create will be on refs/heads/master
(i.e. "the master branch").
And the command errors out as expected when given a
non-existent symbolic ref:
$ git symbolic-ref no-such; echo $?
fatal: ref no-such is not a symbolic ref
128
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] git-symbolic-ref: fix error message when ref doesn't exist
2007-03-19 8:47 ` Junio C Hamano
@ 2007-03-19 9:03 ` Julian Phillips
0 siblings, 0 replies; 3+ messages in thread
From: Julian Phillips @ 2007-03-19 9:03 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
On Mon, 19 Mar 2007, Junio C Hamano wrote:
> Julian Phillips <julian@quantumfyre.co.uk> writes:
>
>> When calling resolve_ref from check_symref set reading to 1, since we
>> do want to know if the given ref doesn't exist. This means that
>> "git symbolic-ref foo" will now print "fatal: No such ref: foo" as
>> expected.
>
> Hmmmm. That would break:
>
> $ rm -fr a; mkdir a; cd a
> $ git init-db
> $ git symbolic-ref HEAD
> refs/heads/master
>
> wouldn't it? We do want it not to fail and tell us that the
> commit we are going to create will be on refs/heads/master
> (i.e. "the master branch").
Um .. yes ... as per the comment in refs.c ... :$
>
> And the command errors out as expected when given a
> non-existent symbolic ref:
>
> $ git symbolic-ref no-such; echo $?
> fatal: ref no-such is not a symbolic ref
> 128
>
The thing is, that wasn't what I expected. From looking at the code for
symbolic-ref I was expecting:
$ git symbolic-ref no-such; echo $?
fatal: No such ref: no-such
128
In particular, in quiet mode you will get a return of 1 - rather than
128, which would potentially lead you astray if you belived the man page
...
--
Julian
---
"Intelligence without character is a dangerous thing."
-- G. Steinem
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-19 9:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-18 1:53 [PATCH] git-symbolic-ref: fix error message when ref doesn't exist Julian Phillips
2007-03-19 8:47 ` Junio C Hamano
2007-03-19 9:03 ` Julian Phillips
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).