All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	git@vger.kernel.org, Daniel Barkalow <barkalow@iabervon.org>,
	Pierre Habouzit <madcoder@debian.org>
Subject: Re: [PATCH 1/2] clone: do not ignore --no-hardlinks
Date: Thu, 26 Feb 2009 23:59:14 -0800	[thread overview]
Message-ID: <7vr61kmht9.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vy6vsmjeo.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 26 Feb 2009 23:24:47 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Jeff King <peff@peff.net> writes:
>
> So across filesystems:
>
>  - "git clone /p/a/t/h" falls back to copying;
>
>  - "git clone --local /p/a/t/h" should fail without falling back to
>    copying; and
>
>  - "git clone --no-local /p/a/t/h" should work as if file:///p/a/t/h
>    was given.
>
> That is much more sensible than making "git clone --no-hardlinks /p/a/t/h"
> imply more than what the option really means: we are making a local copy
> but do not cheat with hardlinking.

I liked it so much that I wrote a commit message for it:

    commit c255d7bbf4dd567ca60a8991c3ac052c9b2d1593
    Author: Jeff King <peff@peff.net>
    Date:   Thu Feb 26 23:31:49 2009 -0800

        clone: do not ignore --no-local option

        With a variable initialized to false, we couldn't tell if the user didn't
        give --local or if the user explicitly told us --no-local after we get control
        back from parse_options().

        This fixes and makes "git clone --no-local /p/a/t/h" always use non-local
        transport (aka "git native protocol over pipe").

        Signed-off-by: Junio C Hamano <gitster@pobox.com>

Except that it does not work.

Initializing option_local to -1 and then feeding it to parse_options() via
OPT_BOOLEAN() is a cute idea, but when parse_options() sees a command line
like this:

	$ git clone -l /p/a/t/h

It triggers this codepath in get_value():

	case OPTION_BOOLEAN:
		*(int *)opt->value = unset ? 0 : *(int *)opt->value + 1;
		return 0;

and ends up incrementing it to zero.

I wonder what would break if we simply change this to:

	case OPTION_BOOLEAN:
		*(int *)opt->value = !unset;
		return 0;

Damn it, it is called BOOLEAN, and naïvely I would think --option would
set it to 1, --no-option would set it to 0, and not having --option nor
--no-option would leave the associated variable alone, but apparently that
is not what is happening.

Pierre, do you remember why this code is implemented this way?  The
"increment if we have --option" semantics seems to date back to 4a59fd1
(Add a simple option parser., 2007-10-15) which is the day one of the
history of parse-options.

  reply	other threads:[~2009-02-27  8:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1235672273u.git.johannes.schindelin@gmx.de>
2009-02-26 18:20 ` [PATCH] clone: ignore --depth when cloning locally (implicitly --local) Johannes Schindelin
2009-02-26 22:45   ` Junio C Hamano
2009-02-26 22:55     ` Johannes Schindelin
2009-02-26 23:31       ` [PATCH 0/2] shallow clone stuff Johannes Schindelin
2009-02-27  0:35         ` Junio C Hamano
2009-02-26 23:31       ` [PATCH 1/2] clone: do not ignore --no-hardlinks Johannes Schindelin
2009-02-27  2:58         ` Jeff King
2009-02-27  7:24           ` Junio C Hamano
2009-02-27  7:59             ` Junio C Hamano [this message]
2009-02-27  8:13               ` Junio C Hamano
2009-02-27 16:54                 ` Daniel Barkalow
2009-02-27 11:35               ` Jeff King
2009-02-26 23:31       ` [PATCH 2/2] clone: ignore --depth when cloning locally (implicitly --local) Johannes Schindelin

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=7vr61kmht9.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=madcoder@debian.org \
    --cc=peff@peff.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.