From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Dave Olszewski <cxreg@pobox.com>
Cc: Vladimir Panteleev <vladimir@thecybershadow.net>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: Re: "git stash list" shows HEAD reflog
Date: Sat, 13 Mar 2010 21:11:29 +0100 [thread overview]
Message-ID: <4B9BF171.2000102@lsrfire.ath.cx> (raw)
In-Reply-To: <alpine.DEB.2.00.1003130939240.796@narbuckle.genericorp.net>
Am 13.03.2010 18:41, schrieb Dave Olszewski:
> On Sat, 13 Mar 2010, Ren? Scharfe wrote:
>
>> Am 12.03.2010 15:52, schrieb Vladimir Panteleev:
>
>>> That doesn't explain why git displayed the HEAD reflog, though. That
>>> seems to happen thanks to the check (revs->def && !revs->pending.nr) in
>>> setup_revisions ("HEAD" is the default, as specified in the caller
>>> cmd_log_init). It looks like (ideally) git shouldn't rely on whether
>>> revs->pending is empty to decide whether to use the default, but rather
>>> if a ref was specified by the user or not.
>>
>> We could add some kind of check there, but with the patch applied I can't
>> trigger this second issue any more. It would be nice to have a test
>> script
>> along with such a sanity check. Any idea how to cause this error,
>> perhaps
>> with another type of invalid reflog file?
>
> I actually noticed this last week. You can reproduce it by doing "git
> reflog" on a branch which has been idle for longer than the expiration.
> Any 0-byte files in logs/refs/heads would give me this same behavior.
>
> Dave
Perhaps something like this?
---
revision.c | 4 ++++
t/t1411-reflog-show.sh | 13 +++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/revision.c b/revision.c
index 29721ec..6991475 100644
--- a/revision.c
+++ b/revision.c
@@ -896,6 +896,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
struct object *object;
unsigned char sha1[20];
int local_flags;
+ int empty_after, empty_before = !revs->pending.nr;
dotdot = strstr(arg, "..");
if (dotdot) {
@@ -971,6 +972,9 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
verify_non_filename(revs->prefix, arg);
object = get_reference(revs, arg, sha1, flags ^ local_flags);
add_pending_object_with_mode(revs, object, arg, mode);
+ empty_after = !revs->pending.nr;
+ if (empty_before && empty_after)
+ die("bad revision '%s' (empty reflog?)", arg);
return 0;
}
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index c18ed8e..3f48c2d 100755
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
@@ -64,4 +64,17 @@ test_expect_success 'using --date= shows reflog date (oneline)' '
test_cmp expect actual
'
+: >expected.out
+cat >expected.err <<'EOF'
+fatal: bad revision 'empty' (empty reflog?)
+EOF
+test_expect_success 'empty reflog file' '
+ git branch empty &&
+ : >.git/logs/refs/heads/empty &&
+
+ test_must_fail git log -g empty >actual.out 2>actual.err &&
+ test_cmp expected.out actual.out &&
+ test_cmp expected.err actual.err
+'
+
test_done
--
1.7.0.2
next prev parent reply other threads:[~2010-03-13 20:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-12 14:52 "git stash list" shows HEAD reflog Vladimir Panteleev
2010-03-13 17:37 ` René Scharfe
2010-03-13 17:41 ` Dave Olszewski
2010-03-13 20:11 ` René Scharfe [this message]
2010-03-13 21:21 ` Re: [git] " Dave Olszewski
2010-03-13 21:49 ` René Scharfe
2010-03-13 22:47 ` [PATCH] don't use default revision if a rev was specified Dave Olszewski
2010-03-13 23:19 ` René Scharfe
2010-03-14 6:57 ` Junio C Hamano
2010-03-13 21:43 ` "git stash list" shows HEAD reflog Pete Harlan
2010-03-13 22:07 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B9BF171.2000102@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=cxreg@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=vladimir@thecybershadow.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).