* Bad error message
@ 2006-05-04 23:57 Robin Rosenberg (list subscriber)
2006-05-05 0:20 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Robin Rosenberg (list subscriber) @ 2006-05-04 23:57 UTC (permalink / raw)
To: git
Hi,
While playing with git I got the following "impossible" error message:
$ git commit --amend
fatal: Ref HEAD is at 3cec3036287d6b24f7ad7f724f8bb9d4032fb1a3 but expected
3cec3036287d6b24f7ad7f724f8bb9d4032fb1a3
Since impossible things happen rarely, I was somewhat puzzled and it turned
out not to be so impossible after all, but a rather typical C bug. Since I
fixed my working directory using git-reset, I'm not sure how to verify the
code (suggestions welcome), but I'm not sure if that's important since the
code being replaced by this patch probably wasn't tested either. :/
Maybe someone could explain what might have been wrong with my work space (git
status turned up nothing wrong or missing).
-- robin
--- git-1.3.1.orig/update-ref.c 2006-04-25 08:07:54.000000000 +0200
+++ git-1.3.1/update-ref.c 2006-05-04 16:30:04.000000000 +0200
@@ -43,8 +43,13 @@
die("No such ref: %s", refname);
if (oldval) {
- if (memcmp(currsha1, oldsha1, 20))
- die("Ref %s is at %s but expected %s", refname, sha1_to_hex(currsha1), sha1_to_hex(oldsha1));
+ if (memcmp(currsha1, oldsha1, 20)) {
+ char sha1str1[41];
+ char sha1str2[41];
+ strcpy(sha1str1, sha1_to_hex(currsha1));
+ strcpy(sha1str2, sha1_to_hex(oldsha1));
+ die("Ref %s is at %s but expected %s", refname, sha1str1, sha1str2);
+ }
/* Nothing to do? */
if (!memcmp(oldsha1, sha1, 20))
exit(0);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Bad error message
2006-05-04 23:57 Bad error message Robin Rosenberg (list subscriber)
@ 2006-05-05 0:20 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-05-05 0:20 UTC (permalink / raw)
To: Robin Rosenberg (list subscriber); +Cc: git
"Robin Rosenberg (list subscriber)" <robin.rosenberg.lists@dewire.com> writes:
> @@ -43,8 +43,13 @@
> die("No such ref: %s", refname);
>
> if (oldval) {
> - if (memcmp(currsha1, oldsha1, 20))
> - die("Ref %s is at %s but expected %s", refname, sha1_to_hex(currsha1), sha1_to_hex(oldsha1));
> + if (memcmp(currsha1, oldsha1, 20)) {
> + char sha1str1[41];
> + char sha1str2[41];
> + strcpy(sha1str1, sha1_to_hex(currsha1));
> + strcpy(sha1str2, sha1_to_hex(oldsha1));
> + die("Ref %s is at %s but expected %s", refname, sha1str1, sha1str2);
> + }
Your patch looks correct, but probably is made unnecessary with
the "you can use up to 4 sha1_to_hex() safely" patch Linus did.
We have it in "master" and my plan is to cherry-pick it to
"maint" branch and included it in the next stale release 1.3.3,
along with core.prefersymlinkrefs patch also only in "master",
if we do not hear somebody scream in the next few days.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-05 0:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-04 23:57 Bad error message Robin Rosenberg (list subscriber)
2006-05-05 0:20 ` Junio C Hamano
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).