All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Jérémie NIKAES" <jeremie.nikaes@gmail.com>
Cc: git@vger.kernel.org, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Sylvain Boulme <Sylvain.Boulme@imag.fr>,
	Mike Hommey <mh@glandium.org>
Subject: Re: Git fast-import : Warning duplicated ref: refs/remotes/origin/master
Date: Mon, 30 May 2011 12:35:17 -0500	[thread overview]
Message-ID: <20110530173517.GA13539@elie> (raw)
In-Reply-To: <BANLkTinhH7ksP8EZV+Sd4ryCT1_bhVhgaw@mail.gmail.com>

Jérémie NIKAES wrote:

> No, I actually still have the problem. The version commited on github
> is pulling revisions straight to refs/heads/master which is gross
> After discussing this matter with our teacher Matthieu Moy, I wanted
> to change this to refs/remotes/origin/master but then this warning
> gets thrown.

The following fixes it for me.

-- >8 --
Subject: use refs/mediawiki/<remote> namespace for private refs

Unless the "refspec" capability is used, the remote helper machinery
expects remote helpers to write remote refs/heads/master ref to
refs/heads/master.  That's not very good since it scribbles on top of
whatever local changes the user might have.

So specify a refspec that puts the refs elsewhere.  For now this
only works when fetching from a named remote, like so:

	git remote add origin mediawiki::testwiki
	git fetch origin

Attempting to fetch directly from a URL with a command like
"git fetch mediawiki::testwiki" produces an "Invalid refspec"
error.
---
 git-remote-mediawiki |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/git-remote-mediawiki b/git-remote-mediawiki
index af66b58..7a3fdd3 100755
--- a/git-remote-mediawiki
+++ b/git-remote-mediawiki
@@ -7,6 +7,7 @@ use Storable qw(freeze thaw);
 use DateTime::Format::ISO8601;
 use Encode qw(encode_utf8);
 
+my $remotename = $ARGV[0];
 my $url = $ARGV[1];
 
 print STDERR "$url\n";
@@ -62,6 +63,7 @@ while ($loop) {
 
 sub mw_capabilities {
 #	print STDOUT "fetch\n";
+	print STDOUT "refspec refs/heads/*:refs/mediawiki/$remotename/*\n";
 	print STDOUT "import\n";
 	print STDOUT "list\n";
 	print STDOUT "option\n";
@@ -91,7 +93,7 @@ sub mw_import {
 	
 	sub get_last_revision {
 		# Get last commit sha1
-		my $commit_sha1 = `git rev-parse refs/remotes/origin/master 2>/dev/null`;
+		my $commit_sha1 = `git rev-parse refs/mediawiki/$remotename/master 2>/dev/null`;
 
 		# Get note regarding that commit
 		chomp($commit_sha1);
@@ -202,15 +204,15 @@ sub mw_import {
 		
 		# If it's a clone and the first revision, initalize this ref
 		if ($fetch_from == 1 && $n == 1) {
-			#print "reset refs/remotes/origin/master\n";
+			#print "reset refs/mediawiki/$remotename/master\n";
 		}
-		print "commit refs/remotes/origin/master\n";
+		print "commit refs/mediawiki/$remotename/master\n";
 		print "mark :$n\n";
 		print "committer $user <$user\@$wiki_name> ", $dt->epoch, " +0000\n";
 		print "data ", bytes::length(encode_utf8($comment)), "\n", encode_utf8($comment);
 		# If it's not a clone, needs to know where to start from
 		if ($fetch_from != 1 && $n == 1) {
-			print "from refs/remotes/origin/master^0\n";
+			print "from refs/mediawiki/$remotename/master^0\n";
 		}
 		print "M 644 inline $title.wiki\n";
 		print "data ", bytes::length(encode_utf8($content)), "\n", encode_utf8($content);
-- 
1.7.5.3

  parent reply	other threads:[~2011-05-30 17:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-29 16:09 Git fast-import : Warning duplicated ref: refs/remotes/origin/master Jérémie NIKAES
2011-05-29 23:24 ` Jonathan Nieder
2011-05-30 14:44   ` Jérémie NIKAES
2011-05-30 14:52     ` Jonathan Nieder
2011-05-30 15:07       ` Jérémie NIKAES
2011-05-30 15:52         ` [PATCH] Documentation: do not misinterpret refspecs as bold text (Re: Git fast-import : Warning duplicated ref: refs/remotes/origin/master) Jonathan Nieder
2011-05-30 16:40           ` remote helpers: best practices for using the "refspec" capability Jonathan Nieder
2011-05-30 17:43             ` Daniel Barkalow
2011-05-30 18:04               ` Sverre Rabbelier
2011-05-30 17:35     ` Jonathan Nieder [this message]
2011-05-30 19:46       ` Git fast-import : Warning duplicated ref: refs/remotes/origin/master Matthieu Moy
2011-05-30 19:55         ` Jérémie NIKAES
2011-05-30 20:13         ` Jonathan Nieder
2011-05-30 20:32           ` Jérémie NIKAES
2011-05-30 23:09             ` Sverre Rabbelier

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=20110530173517.GA13539@elie \
    --to=jrnieder@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=Sylvain.Boulme@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=jeremie.nikaes@gmail.com \
    --cc=mh@glandium.org \
    /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.