git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 5/6] revert: report fine-grained error messages from insn parser
Date: Sun, 8 Jan 2012 15:33:18 -0600	[thread overview]
Message-ID: <20120108213318.GQ1942@burratino> (raw)
In-Reply-To: <CALkWK0mStgcb4EBB+ni9fisDJY=13cJZWCTEcgfyOUyAXbc=tA@mail.gmail.com>

Ramkumar Ramachandra wrote:
> Jonathan Nieder wrote:
>> Ramkumar Ramachandra wrote:

>>>       /* Eat up extra spaces/ tabs before object name */
>>> -     padding = strspn(bol, " \t");
>>> -     if (!padding)
>>> -             return -1;
>>> -     bol += padding;
>>> +     bol += strspn(bol, " \t");
[...]
> Not a bugfix: since I have to report sensible error messages now, I
> changed the "pick" and "revert" checks to "pick " || "pick\t" and
> "revert " || "revert\t" -- then, I can report "invalid action" if it
> doesn't match instead of a useless "missing space after action".

Ah, I forgot that the "if (!padding)" check noticed errors like

	picking foo

before.  So this is just a code cleanup, with no functional effect.

However, you can still report "invalid action" with the old code
structure --- it would just mean duplicating an error message in the
code, since you reach the same conclusion by two code paths.  So it's
a relevant cleanup, but I'd still suggest lifting it into a patch that
comes before so future readers can assure themselves that it introduces
no functional change instead of being confused.

[...]
>>> +             return error(_("%s:%d: Not a valid commit: %.*s"),
>>> +                     todo_file, lineno, (int)error_len, bol);
>>> +     }
>>
>> Hmm, this one can be emitted even when there was no corruption or
>> internal error, because the user removed a commit she was
>> cherry-picking and the gc-ed before a "git cherry-pick --continue".
>> Alternatively, it can happen because the repository has grown very
>> crowded and what used to be an unambiguous commit name no longer is
>> one (not enough digits).  Will the error message be intuitive in these
>> situations?
>
> Something like "Unable to look up commit: %s" perhaps?

My "alternatively" was bogus --- lookup_commit_reference takes a (raw)
full commit name as its argument.

I dunno.  The question was not actually rhetorical --- I just meant
that it's worth thinking about these cases.  There are a few cases:

 - missing object
 - object is present but corrupt
 - object is a blob, not a commit

In the second case, there's an error message printed describing the
problem, but in the other two there isn't.  The other callers tend to
say "not a valid <foo>" or "could not lookup commit <foo>, so I guess

	error: .git/sequencer/todo:5: not a valid commit: 78a89f493

would be fine.

Except that this focusses on the .git/sequencer/todo filename which
would leave the person debugging astray.  It is not that
.git/sequencer/todo contains a typo (that would have been caught by
get_sha1), but that it referred to a bad object or non-commit.  Maybe
something in the direction of

	error: cannot pick 78a89f493 because it is not a valid commit

would be more helpful.

Is this the right moment to report that error?  Will the operator be
happy that we errored out right away before cherry-picking anything
and wasting the human's time in assisting with that process, or will
she be unhappy that inability to do something later that she might
have been planning on skipping anyway prevented making progress right
away?  (I'm not sure what the best thing to do is --- I guess some
advice like

	hint: to abort, use cherry-pick --abort
	hint: to skip or replace that commit, use cherry-pick --edit

would help.)

Thanks for some food for thought.
Jonathan

  reply	other threads:[~2012-01-08 21:28 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 12:27 [PATCH 0/6] The move to sequencer.c Ramkumar Ramachandra
2012-01-08 12:27 ` [PATCH 1/6] revert: move replay_action, replay_subcommand to header Ramkumar Ramachandra
2012-01-08 19:31   ` Jonathan Nieder
2012-01-08 12:27 ` [PATCH 2/6] revert: decouple sequencer actions from builtin commands Ramkumar Ramachandra
2012-01-08 19:34   ` Jonathan Nieder
2012-01-08 19:53     ` Ramkumar Ramachandra
2012-01-08 20:09       ` Jonathan Nieder
2012-01-08 20:07         ` Ramkumar Ramachandra
2012-01-08 20:48           ` Jonathan Nieder
2012-01-08 12:27 ` [PATCH 3/6] revert: don't let revert continue a cherry-pick Ramkumar Ramachandra
2012-01-08 19:37   ` Jonathan Nieder
2012-01-08 20:03     ` Ramkumar Ramachandra
2012-01-08 20:22       ` Jonathan Nieder
2012-01-08 20:28         ` Ramkumar Ramachandra
2012-01-08 20:45           ` Jonathan Nieder
2012-01-08 12:27 ` [PATCH 4/6] revert: allow mixing "pick" and "revert" actions Ramkumar Ramachandra
2012-01-08 19:40   ` Jonathan Nieder
2012-01-08 20:17     ` Ramkumar Ramachandra
2012-01-08 21:40       ` Jonathan Nieder
2012-01-08 21:55         ` Jonathan Nieder
2012-01-10  3:40           ` Ramkumar Ramachandra
2012-01-08 12:27 ` [PATCH 5/6] revert: report fine-grained error messages from insn parser Ramkumar Ramachandra
2012-01-08 20:07   ` Jonathan Nieder
2012-01-08 20:16     ` Ramkumar Ramachandra
2012-01-08 21:33       ` Jonathan Nieder [this message]
2012-01-10 15:24         ` Ramkumar Ramachandra
2012-01-08 12:27 ` [PATCH 6/6] sequencer: factor code out of revert builtin Ramkumar Ramachandra
2012-01-08 20:38   ` Jonathan Nieder
2012-01-10 15:21     ` Ramkumar Ramachandra
2012-01-08 19:28 ` [PATCH 0/6] The move to sequencer.c Jonathan Nieder
2012-01-08 19:51   ` Ramkumar Ramachandra
2012-01-08 20:43     ` Jonathan Nieder
2012-01-10 16:13 ` [PATCH v2 0/8] " Ramkumar Ramachandra
2012-01-10 16:13   ` [PATCH 1/8] revert: prepare to move replay_action to header Ramkumar Ramachandra
2012-01-10 18:27     ` Jonathan Nieder
2012-01-10 16:13   ` [PATCH 2/8] revert: decouple sequencer actions from builtin commands Ramkumar Ramachandra
2012-01-10 18:38     ` Jonathan Nieder
2012-01-11  4:02       ` Ramkumar Ramachandra
2012-01-11  4:17         ` Ramkumar Ramachandra
2012-01-11  5:04           ` Jonathan Nieder
2012-01-11  5:14             ` Ramkumar Ramachandra
2012-01-11  5:26               ` Ramkumar Ramachandra
2012-01-11  5:49                 ` Jonathan Nieder
2012-01-11  9:19                   ` Ramkumar Ramachandra
2012-01-11  9:52                     ` Jonathan Nieder
2012-01-11 10:11                       ` Ramkumar Ramachandra
2012-01-11 13:40                         ` Jonathan Nieder
2012-01-11 13:18               ` Jonathan Nieder
2012-01-11 16:39                 ` Ramkumar Ramachandra
2012-01-11 16:47                   ` Jonathan Nieder
2012-01-11 16:52                     ` Ramkumar Ramachandra
2012-01-11 18:15                     ` [PATCH v3 0/2] The move to sequencer.c Ramkumar Ramachandra
2012-01-11 18:15                       ` [PATCH 1/2] revert: prepare to move replay_action to header Ramkumar Ramachandra
2012-01-11 18:15                       ` [PATCH 2/2] sequencer: factor code out of revert builtin Ramkumar Ramachandra
2012-01-11 18:40                       ` [PATCH v3 0/2] The move to sequencer.c Jonathan Nieder
2012-01-10 16:13   ` [PATCH 3/8] revert: allow mixing "pick" and "revert" actions Ramkumar Ramachandra
2012-01-10 16:13   ` [PATCH 4/8] revert: separate out parse errors logically Ramkumar Ramachandra
2012-01-10 19:03     ` Jonathan Nieder
2012-01-11 12:38       ` Ramkumar Ramachandra
2012-01-10 16:13   ` [PATCH 5/8] revert: report fine-grained errors from insn parser Ramkumar Ramachandra
2012-01-11 12:44     ` Jonathan Nieder
2012-01-10 16:13   ` [PATCH 6/8] sha1_name: introduce getn_sha1() to take length Ramkumar Ramachandra
2012-01-10 16:13   ` [PATCH 7/8] revert: use getn_sha1() to simplify insn parsing Ramkumar Ramachandra
2012-01-10 16:13   ` [PATCH 8/8] sequencer: factor code out of revert builtin Ramkumar Ramachandra

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=20120108213318.GQ1942@burratino \
    --to=jrnieder@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).