From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Vikrant Varma <vikrant.varma94@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] help: add help_unknown_ref
Date: Thu, 2 May 2013 02:02:43 +0530 [thread overview]
Message-ID: <CALkWK0nJSoBoAXR=ViGan6keFzXjmDGkfKqqWkTHqF89mHDDOQ@mail.gmail.com> (raw)
In-Reply-To: <51817319.6060201@gmail.com>
Vikrant Varma wrote:
> I agree with Matthieu, the people who don't want to see this advice never
> will, because they won't make that mistake. Maybe advice is the wrong word,
> corrections might be more appropriate.
Makes sense.
Perhaps it would make sense to hook into help.autocorrect. I would
definitely like that.
>> I see that there are other structs in our codebase suffixing _cb, to
>> indicate "callback data". I normally reserve _cb for callback
>> functions.
>
>
> I'm following the convention (builtin/merge.c: struct append_ref_cb). If
> there's a better way to name it, I'll use that.
Fine leaving it as it is.
> ref_cb.similar_refs has already been defined. The compiler won't let me
> assign to it unless I cast first. However, I think compound literals are a
> C99/gcc feature. Is this better?
>
> struct similar_ref_cb ref_cb = {ref, STRING_LIST_INIT_NODUP};
As Johannes pointed out, ref is a variable and that is problematic.
Leave the cast on: I didn't notice the compiler warning in my head.
> Q_ is a pluralization helper that picks one of the two strings based on
> ref_cb.similar_refs.nr. It's used in help.c:help_unknown_cmd for the same
> reason.
Thanks.
> Again, because help_unknown_cmd exited with 1. I've tried to follow the
> convention as laid down there.
Ah, I didn't notice that.
> What's the significance of the error code for
> die()?
When something _really_ bad happens, exit() with 128, without
bothering to go up the callstack. Return error() is a common idiom to
print an error message immediately, and propagate the return status -1
up the callstack.
> When is it correct to use die(), and when to use error() followed by
> exit(128)?
exit(128) is a bit rare [grep for it yourself]. It's for when you
want to die(), but exit() only after doing an important task in the
caller.
next prev parent reply other threads:[~2013-05-01 20:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 11:22 [PATCH 0/2] Better advice on merge Vikrant Varma
2013-05-01 11:22 ` [PATCH 1/2] help: add help_unknown_ref Vikrant Varma
2013-05-01 12:23 ` Ramkumar Ramachandra
2013-05-01 14:06 ` Matthieu Moy
2013-05-01 19:55 ` Vikrant Varma
2013-05-01 20:23 ` Johannes Sixt
2013-05-01 20:32 ` Ramkumar Ramachandra [this message]
2013-05-01 21:45 ` Vikrant Varma
2013-05-01 22:12 ` Junio C Hamano
2013-05-01 18:35 ` Junio C Hamano
2013-05-01 22:26 ` Vikrant Varma
2013-05-01 23:07 ` Junio C Hamano
2013-05-01 11:22 ` [PATCH 2/2] merge: use help_unknown_ref instead of die Vikrant Varma
2013-05-01 18:36 ` Junio C Hamano
2013-05-01 18:27 ` [PATCH 0/2] Better advice on merge Jonathan Nieder
2013-05-01 23:06 ` Vikrant Varma
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='CALkWK0nJSoBoAXR=ViGan6keFzXjmDGkfKqqWkTHqF89mHDDOQ@mail.gmail.com' \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=vikrant.varma94@gmail.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).