All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] fetch: refuse to fetch into the current branch in a non-bare repository
Date: Sun, 12 Oct 2008 11:52:09 -0700	[thread overview]
Message-ID: <20081012185209.GB5255@spearce.org> (raw)
In-Reply-To: <alpine.DEB.1.00.0810111336350.22125@pacific.mpi-cbg.de.mpi-cbg.de>

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> diff --git a/builtin-fetch.c b/builtin-fetch.c
> index ee93d3a..d701550 100644
> --- a/builtin-fetch.c
> +++ b/builtin-fetch.c
> @@ -534,6 +534,25 @@ static void find_non_local_tags(struct transport *transport,
>  	string_list_clear(&new_refs, 0);
>  }
>  
> +static void check_ref_map(struct ref *ref_map)
> +{
> +	int flag;
> +	unsigned char sha1[20];
> +	const char *HEAD;
> +
> +	if (is_bare_repository())
> +		return;
> +
> +	HEAD = resolve_ref("HEAD", sha1, 1, &flag);

I'd rather see local variables named lowercase.  Constants should
be the only thing that is all uppercase.

> @@ -558,6 +577,7 @@ static int do_fetch(struct transport *transport,
>  	}
>  
>  	ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
> +	check_ref_map(ref_map);

This should only be called if update_head_ok is false.  So maybe:

	if (!update_head_ok)
		check_ref_map(ref_map)
  
> diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
> index 9aae496..cd8b550 100755
> --- a/t/t5510-fetch.sh
> +++ b/t/t5510-fetch.sh
> @@ -323,4 +323,10 @@ test_expect_success 'auto tag following fetches minimum' '
>  	)
>  '
>  
> +test_expect_success 'refuse to fetch into the current branch' '
> +
> +	test_must_fail git fetch . side:master
> +
> +'
> +

Repeat this test, but with --update-head-ok and expect success,
since the check_ref_map logic is conditional on that?

-- 
Shawn.

  parent reply	other threads:[~2008-10-12 18:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-11 11:38 [PATCH] fetch: refuse to fetch into the current branch in a non-bare repository Johannes Schindelin
2008-10-11 21:44 ` Junio C Hamano
2008-10-12 18:47   ` Shawn O. Pearce
2008-10-13  9:28     ` Johannes Schindelin
2008-10-12 18:52 ` Shawn O. Pearce [this message]
2008-10-12 20:37 ` Daniel Barkalow
2008-10-13  9:36   ` [PATCH v2] Fix fetch/pull when run without --update-head-ok Johannes Schindelin
2008-10-13 14:09     ` Shawn O. Pearce
2008-10-13 17:57       ` Johannes Schindelin
2008-10-13 14:23     ` Junio C Hamano
2008-10-13 17:30       ` Junio C Hamano
2008-10-13 18:12       ` Johannes Schindelin
2008-10-13 20:05         ` Daniel Barkalow
2008-10-14  9:49           ` Johannes Schindelin
2008-10-14 15:02             ` Shawn O. Pearce
2008-10-14 16:04               ` Daniel Barkalow
2008-10-14 16:15               ` Johannes Schindelin
2008-10-14 15:57             ` Daniel Barkalow
2008-10-14 16:17               ` Johannes Schindelin
2008-10-14 16:52                 ` Daniel Barkalow
2008-10-14 17:02                   ` Daniel Barkalow
2008-10-14 22:07                     ` Junio C Hamano
2008-10-14 22:53                       ` [PATCH] pull: allow "git pull origin $something:$current_branch" into an unborn branch Junio C Hamano
2008-10-13 17:08     ` [PATCH v2] Fix fetch/pull when run without --update-head-ok Daniel Barkalow

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=20081012185209.GB5255@spearce.org \
    --to=spearce@spearce.org \
    --cc=Johannes.Schindelin@gmx.de \
    --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 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.