* [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid
@ 2005-10-27 17:40 Johannes Schindelin
2005-10-27 19:01 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2005-10-27 17:40 UTC (permalink / raw)
To: git
for_each_ref() used to ignore refs which point nowhere. Making git-fsck-objects
be happy about them.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
Of course, it may be by design. But then, it does not feel
right to me. If this is intended behaviour, please don't let me
die dumb.
refs.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
applies-to: d29f6558d14b1da55642659c9874d4f52dac18bf
047627834b0ecb7ec0e0a98066b4b28688c374bc
diff --git a/refs.c b/refs.c
index a52b038..d74ede9 100644
--- a/refs.c
+++ b/refs.c
@@ -194,9 +194,9 @@ static int do_for_each_ref(const char *b
continue;
}
if (read_ref(git_path("%s", path), sha1) < 0)
- continue;
+ die("%s points nowhere!", path);
if (!has_sha1_file(sha1))
- continue;
+ die("%s does not point to a valid commit object!", path);
retval = fn(path, sha1);
if (retval)
break;
---
0.99.8.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid
2005-10-27 17:40 [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid Johannes Schindelin
@ 2005-10-27 19:01 ` Junio C Hamano
2005-10-27 19:28 ` Johannes Schindelin
2005-10-27 21:13 ` [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid Horst von Brand
0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2005-10-27 19:01 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
The only case that I can think of that this patch may make a
difference in behaviour in a valid repository is the HEAD
pointer that points at nowhere (i.e. refs/heads/master)
immediately after git-init-db, so in that sense this change may
be safe for most purposes.
However, we might want to write a tool to iterate over what we
have under .git/refs/ and warn about them to help the user fix
broken branches/tags, and do_for_each_ref() dying like this
would not help that usage.
Not that the current loop is any better for that purpose. We
silently ignore not just dangling ref and ref not storing
40-byte hex, but files starting with a period '.', names longer
than 255 bytes, and unreadable ones, all of which we would
probably want to warn about in such a tool.
-jc
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid
2005-10-27 19:01 ` Junio C Hamano
@ 2005-10-27 19:28 ` Johannes Schindelin
2005-10-27 20:45 ` Junio C Hamano
2005-10-27 21:13 ` [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid Horst von Brand
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2005-10-27 19:28 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Thu, 27 Oct 2005, Junio C Hamano wrote:
> Not that the current loop is any better for that purpose. We
> silently ignore not just dangling ref and ref not storing
> 40-byte hex, but files starting with a period '.', names longer
> than 255 bytes, and unreadable ones, all of which we would
> probably want to warn about in such a tool.
Okay, how about 'fprintf(stderr, "Warning: ...\n"); continue;' instead of
'die("...");' then?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid
2005-10-27 19:28 ` Johannes Schindelin
@ 2005-10-27 20:45 ` Junio C Hamano
2006-02-28 21:16 ` [PATCH] Warn about invalid refs Johannes Schindelin
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2005-10-27 20:45 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Hi,
>
> On Thu, 27 Oct 2005, Junio C Hamano wrote:
>
>> Not that the current loop is any better for that purpose. We
>> silently ignore not just dangling ref and ref not storing
>> 40-byte hex, but files starting with a period '.', names longer
>> than 255 bytes, and unreadable ones, all of which we would
>> probably want to warn about in such a tool.
>
> Okay, how about 'fprintf(stderr, "Warning: ...\n"); continue;' instead of
> 'die("...");' then?
Yup. That sounds sensible.
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH] Warn about invalid refs
2005-10-27 20:45 ` Junio C Hamano
@ 2006-02-28 21:16 ` Johannes Schindelin
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2006-02-28 21:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
On Thu, 27 Oct 2005, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > On Thu, 27 Oct 2005, Junio C Hamano wrote:
> >
> >> Not that the current loop is any better for that purpose.
> >> We silently ignore not just dangling ref and ref not storing
> >> 40-byte hex, but files starting with a period '.', names
> >> longer than 255 bytes, and unreadable ones, all of which we
> >> would probably want to warn about in such a tool.
> >
> > Okay, how about 'fprintf(stderr, "Warning: ...\n"); continue;'
> > instead of 'die("...");' then?
>
> Yup. That sounds sensible.
Sorry for taking so long...
refs.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c
index 826ae7a..982ebf8 100644
--- a/refs.c
+++ b/refs.c
@@ -151,10 +151,15 @@ static int do_for_each_ref(const char *b
break;
continue;
}
- if (read_ref(git_path("%s", path), sha1) < 0)
+ if (read_ref(git_path("%s", path), sha1) < 0) {
+ fprintf(stderr, "%s points nowhere!", path);
continue;
- if (!has_sha1_file(sha1))
+ }
+ if (!has_sha1_file(sha1)) {
+ fprintf(stderr, "%s does not point to a valid "
+ "commit object!", path);
continue;
+ }
retval = fn(path, sha1);
if (retval)
break;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid
2005-10-27 19:01 ` Junio C Hamano
2005-10-27 19:28 ` Johannes Schindelin
@ 2005-10-27 21:13 ` Horst von Brand
1 sibling, 0 replies; 6+ messages in thread
From: Horst von Brand @ 2005-10-27 21:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, git
Junio C Hamano <junkio@cox.net> wrote:
[...]
> Not that the current loop is any better for that purpose. We
> silently ignore not just dangling ref and ref not storing
> 40-byte hex, but files starting with a period '.', names longer
> than 255 bytes, and unreadable ones, all of which we would
> probably want to warn about in such a tool.
I have yet to come across a filesystem allowing names of more than 255
characters...
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-02-28 21:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-27 17:40 [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid Johannes Schindelin
2005-10-27 19:01 ` Junio C Hamano
2005-10-27 19:28 ` Johannes Schindelin
2005-10-27 20:45 ` Junio C Hamano
2006-02-28 21:16 ` [PATCH] Warn about invalid refs Johannes Schindelin
2005-10-27 21:13 ` [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid Horst von Brand
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 NNTP newsgroup(s).