Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You appear to have cloned an empty MediaWiki. #70

Closed
adrelanos opened this issue Apr 19, 2020 · 4 comments · Fixed by #75
Closed

You appear to have cloned an empty MediaWiki. #70

adrelanos opened this issue Apr 19, 2020 · 4 comments · Fixed by #75

Comments

@adrelanos
Copy link

 git config -l
user.name=whonix
user.email=postmaster at whonix.org (manually redacted to reduce spam)
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
git clone mediawiki::https://www.whonix.org/w

Says Found 0 revision(s). for all pages.

[snip]
page 799/800: Upgrade
Found 0 revision(s).
page 800/800: Dev/Archived Discussions
Found 0 revision(s).
You appear to have cloned an empty MediaWiki.
fatal: could not read ref refs/mediawiki/origin/master

Any advice?

@mrMams
Copy link

mrMams commented Aug 26, 2021

Hi, I'm having the same issue. @adrelanos, did you manage to find a workaround here ?
Thanks for letting me know.

@mrMams
Copy link

mrMams commented Aug 27, 2021

I just found the root cause in my case: it is exactly the same as #65 .

Indeed, in the MediaWiki I'm working on, there was no page with a revision 1. In Git-MediaWiki, in the function fetch_mw_revisions_for_page, a query is made using MediaWiki API in order to get all the revisions for a given page.

However, as stated in MediaWiki API documentation about the parameter rvstartid used in the query (check (here)[https://www.mediawiki.org/w/api.php?action=help&modules=query%2Brevisions]) :

Start enumeration from this revision's timestamp. The revision must exist, but need not belong to this page.
May only be used with a single page (mode #2).
Type: integer

If this parameter is provided with a revision that doesn't exist (1 here), an error is returned. Therefore, no revision is processed, and "Found 0 revision(s)" is returned.

So I made the quick (and possibly dirty) fix below in git-remote-mediawiki.perl file in order to make it work.

sub fetch_mw_revisions_for_page {
    my $page = shift;
    my $id = shift;
    my $fetch_from = shift;
    my @page_revs = ();
    my $query = {
        action => 'query',
        prop => 'revisions',
        rvprop => 'ids',
        rvdir => 'newer',
        # FIX start : rvstartid should not be added if $fetch_from is 1, because rev 1 does not always exist on pages
        # rvstartid => $fetch_from,
        # FIX end
        rvlimit => 500,
        pageids => $id,

        # Let MediaWiki know that we support the latest API.
        continue => '',
    };

    #FIX start : adding rvstartid to query only if $fetch_from is not equals to 1
    if ($fetch_from != 1) {
        $query->{rvstartid} = $fetch_from;
    }
    #FIX end

    my $revnum = 0;
    # Get 500 revisions at a time due to the mediawiki api limit
    
    # ... rest of the code....
}

@anarcat , I don't know if you are still a maintainer here, but you may want to have a look (and possibly include, if relevant) my quick fix above.

@cooljeanius
Copy link

huh I wonder if this was the same issue I was running into a few years back...

@adrelanos
Copy link
Author

Could you please send a pull request here?

https://github.com/git/git/blob/master/contrib/mw-to-git/git-remote-mediawiki.perl

hexmode added a commit to hexmode/Git-Mediawiki that referenced this issue Feb 19, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

    $ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 0 revision(s).
    You appear to have cloned an empty MediaWiki.
		fatal: could not read ref refs/mediawiki/origin/master

After this patch

    $ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 115 revision(s).
    Namespace MediaWiki not found in cache, querying the wiki ...
		1/115: Revision Git-Mediawiki#7 of MediaWiki:Sidebar
    2/115: Revision Git-Mediawiki#8 of MediaWiki:Sidebar
    3/115: Revision Git-Mediawiki#9 of MediaWiki:Sidebar
		4/115: Revision Git-Mediawiki#10 of MediaWiki:Sidebar
		5/115: Revision Git-Mediawiki#11 of MediaWiki:Sidebar
		6/115: Revision Git-Mediawiki#12 of MediaWiki:Sidebar

Fixes Git-Mediawiki#70
hexmode added a commit to hexmode/Git-Mediawiki that referenced this issue Feb 19, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

    $ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 0 revision(s).
    You appear to have cloned an empty MediaWiki.
		fatal: could not read ref refs/mediawiki/origin/master

After this patch

    $ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 115 revision(s).
    Namespace MediaWiki not found in cache, querying the wiki ...
		1/115: Revision Git-Mediawiki#7 of MediaWiki:Sidebar
    2/115: Revision Git-Mediawiki#8 of MediaWiki:Sidebar
    3/115: Revision Git-Mediawiki#9 of MediaWiki:Sidebar
		4/115: Revision Git-Mediawiki#10 of MediaWiki:Sidebar
		5/115: Revision Git-Mediawiki#11 of MediaWiki:Sidebar
		6/115: Revision Git-Mediawiki#12 of MediaWiki:Sidebar

Fixes Git-Mediawiki#70
hexmode added a commit to hexmode/Git-Mediawiki that referenced this issue Feb 19, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

    $ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 0 revision(s).
		You appear to have cloned an empty MediaWiki.
		fatal: could not read ref refs/mediawiki/origin/master

After this patch

    $ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 115 revision(s).
		Namespace MediaWiki not found in cache, querying the wiki ...
		1/115: Revision Git-Mediawiki#7 of MediaWiki:Sidebar
		2/115: Revision Git-Mediawiki#8 of MediaWiki:Sidebar
		3/115: Revision Git-Mediawiki#9 of MediaWiki:Sidebar
		4/115: Revision Git-Mediawiki#10 of MediaWiki:Sidebar
		5/115: Revision Git-Mediawiki#11 of MediaWiki:Sidebar
		6/115: Revision Git-Mediawiki#12 of MediaWiki:Sidebar

Fixes Git-Mediawiki#70
hexmode added a commit to hexmode/Git-Mediawiki that referenced this issue Feb 19, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

	$ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
	…
	page 1/1: MediaWiki:Sidebar
	  Found 0 revision(s).
	You appear to have cloned an empty MediaWiki.
	fatal: could not read ref refs/mediawiki/origin/master

After this patch

	$ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
	…
	page 1/1: MediaWiki:Sidebar
	  Found 115 revision(s).
	Namespace MediaWiki not found in cache, querying the wiki ...
	1/115: Revision Git-Mediawiki#7 of MediaWiki:Sidebar
	2/115: Revision Git-Mediawiki#8 of MediaWiki:Sidebar
	3/115: Revision Git-Mediawiki#9 of MediaWiki:Sidebar
	4/115: Revision Git-Mediawiki#10 of MediaWiki:Sidebar
	5/115: Revision Git-Mediawiki#11 of MediaWiki:Sidebar
	6/115: Revision Git-Mediawiki#12 of MediaWiki:Sidebar

Fixes Git-Mediawiki#70
hexmode added a commit to hexmode/Git-Mediawiki that referenced this issue Feb 22, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

    $ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 0 revision(s).
    You appear to have cloned an empty MediaWiki.
		fatal: could not read ref refs/mediawiki/origin/master

After this patch

    $ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 115 revision(s).
    Namespace MediaWiki not found in cache, querying the wiki ...
		1/115: Revision Git-Mediawiki#7 of MediaWiki:Sidebar
    2/115: Revision Git-Mediawiki#8 of MediaWiki:Sidebar
    3/115: Revision Git-Mediawiki#9 of MediaWiki:Sidebar
		4/115: Revision Git-Mediawiki#10 of MediaWiki:Sidebar
		5/115: Revision Git-Mediawiki#11 of MediaWiki:Sidebar
		6/115: Revision Git-Mediawiki#12 of MediaWiki:Sidebar

Fixes Git-Mediawiki#70
hexmode added a commit to hexmode/Git-Mediawiki that referenced this issue Feb 22, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

    $ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 0 revision(s).
		You appear to have cloned an empty MediaWiki.
		fatal: could not read ref refs/mediawiki/origin/master

After this patch

    $ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 115 revision(s).
		Namespace MediaWiki not found in cache, querying the wiki ...
		1/115: Revision Git-Mediawiki#7 of MediaWiki:Sidebar
		2/115: Revision Git-Mediawiki#8 of MediaWiki:Sidebar
		3/115: Revision Git-Mediawiki#9 of MediaWiki:Sidebar
		4/115: Revision Git-Mediawiki#10 of MediaWiki:Sidebar
		5/115: Revision Git-Mediawiki#11 of MediaWiki:Sidebar
		6/115: Revision Git-Mediawiki#12 of MediaWiki:Sidebar

Fixes Git-Mediawiki#70
@moy moy closed this as completed in #75 Feb 22, 2022
moy pushed a commit that referenced this issue Feb 22, 2022
On a wiki where MediaWiki:Sidebar does not start with rev 1:

    $ git clone -c remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 0 revision(s).
		You appear to have cloned an empty MediaWiki.
		fatal: could not read ref refs/mediawiki/origin/master

After this patch

    $ git clone -c  remote.origin.pages=MediaWiki:Sidebar mediawiki::https://www.wiki.org/w/
		…
		page 1/1: MediaWiki:Sidebar
		  Found 115 revision(s).
		Namespace MediaWiki not found in cache, querying the wiki ...
		1/115: Revision #7 of MediaWiki:Sidebar
		2/115: Revision #8 of MediaWiki:Sidebar
		3/115: Revision #9 of MediaWiki:Sidebar
		4/115: Revision #10 of MediaWiki:Sidebar
		5/115: Revision #11 of MediaWiki:Sidebar
		6/115: Revision #12 of MediaWiki:Sidebar

Fixes #70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants