git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: sverre@rabbelier.nl
Cc: Michele Ballabio <barra_cuda@katamail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH 7/9] builtin-checkout-index.c: use parse_options()
Date: Fri, 25 Jul 2008 11:01:11 +0200	[thread overview]
Message-ID: <48899657.5090209@lsrfire.ath.cx> (raw)
In-Reply-To: <bd6139dc0807241335i3ab5280aq6a46325428ccc70f@mail.gmail.com>

Sverre Rabbelier schrieb:
> On Thu, Jul 24, 2008 at 10:08 PM, Michele Ballabio
> <barra_cuda@katamail.com> wrote:
>> On Thursday 24 July 2008, Johannes Schindelin wrote:
>>> On Wed, 23 Jul 2008, Michele Ballabio wrote:
>>>
>>>> +           { OPTION_CALLBACK, 'f', "force", &state, NULL,
>>>> +             "force overwrite of existing files",
>>>> +             PARSE_OPT_NOARG, parse_state_force_cb, 0 },
>>> I wonder if this could not be written as
>>>
>>>               OPT_BOOLEAN('f', "force", &state.force,
>>>                       "force overwrite of existing files"),
>> I did it that way because 'force' is a bitfield.
> 
> I thought there is an OPT_BIT?

OPT_BIT is for flags and bitmasks, not for bitfields.

Since you can't get the address of a bitfield member, a function that
wants to change its value needs to know its name.  Switching to bitmasks
would make the option parsing code look cleaner, but you'd have to
change all those bitfield accesses to explicit bitmask operations, e.g.:

	if (state.force)
		state.force = 0;

vs.

	if (state.flags & CHECKOUT_FORCE)
		state.flags &= ~CHECKOUT_FORCE;

In the case of struct checkout, though, we could simply make the
bitfield members full ints, because there are only a few instances of
this structure in memory at any given time.  Wasting a few bytes of RAM
in order to gain much simpler code is OK in this case, I think.
OPT_BOOLEAN looks a lot nicer than a callback.

René

  reply	other threads:[~2008-07-25  9:02 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-23 21:42 [PATCH 0/9] Extend use of parse_options() Michele Ballabio
2008-07-23 21:42 ` [PATCH 1/9] builtin-verify-tag.c: use parse_options() Michele Ballabio
2008-07-24 16:59   ` Olivier Marin
2008-07-24 17:08     ` Johannes Schindelin
2008-07-25 15:20       ` Olivier Marin
2008-07-26  0:53         ` Johannes Schindelin
2008-07-28 10:48         ` [PATCH] builtin-verify-tag: fix -v option parsing Olivier Marin
2008-07-28 11:06           ` Johannes Schindelin
2008-07-28 11:42             ` Olivier Marin
2008-07-28 12:10               ` Johannes Schindelin
2008-07-23 21:42 ` [PATCH 2/9] builtin-write-tree.c: use parse_options() Michele Ballabio
2008-07-23 21:42 ` [PATCH 3/9] builtin-prune-packed.c: " Michele Ballabio
2008-07-23 21:42 ` [PATCH 4/9] builtin-ls-tree.c: " Michele Ballabio
2008-07-23 21:42 ` [PATCH 5/9] builtin-rev-list.c: " Michele Ballabio
2008-07-23 21:42 ` [PATCH 6/9] builtin-init-db.c: " Michele Ballabio
2008-07-24 16:15   ` Olivier Marin
2008-07-24 17:07     ` Johannes Schindelin
2008-07-25 15:20       ` Olivier Marin
2008-07-26  0:55         ` Johannes Schindelin
2008-07-24 20:07     ` Michele Ballabio
2008-07-25  8:15       ` [PATCH 6/9 - v2] " Michele Ballabio
2008-07-25 15:20       ` [PATCH 6/9] " Olivier Marin
2008-07-25 19:53         ` [PATCH 6/9 - v3] " Michele Ballabio
2008-07-23 21:42 ` [PATCH 7/9] builtin-checkout-index.c: " Michele Ballabio
2008-07-24 14:44   ` Johannes Schindelin
2008-07-24 20:08     ` Michele Ballabio
2008-07-24 20:35       ` Sverre Rabbelier
2008-07-25  9:01         ` René Scharfe [this message]
2008-07-25 16:25           ` [PATCH 7/9 - v2] " Michele Ballabio
2008-07-23 21:42 ` [PATCH 8/9] builtin-fetch-pack.c: " Michele Ballabio
2008-07-23 21:42 ` [PATCH 9/9] builtin-mailinfo.c: " Michele Ballabio

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48899657.5090209@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=barra_cuda@katamail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sverre@rabbelier.nl \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).