Git Product home page Git Product logo

Comments (3)

billiegoose avatar billiegoose commented on May 14, 2024 1

Ah! That scenario slipped through the cracks, because if you create a repo with "git init" it typically sets up a fetch "refspec" for you:
https://git-scm.com/book/en/v2/Git-Internals-The-Refspec

I'll implement a fallback default refspec to use if there's not one in the config file.

from isomorphic-git.

billiegoose avatar billiegoose commented on May 14, 2024 1

aaaahhh........ OK so, interesting thing is, git does something completely different than what you might expect if you actually use that config file as you have it written:

> mkdir issue-84
> cd issue-84
> git init
> cat <<EOF > .git/config
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true

[remote "origin"]
url = https://gitlab.com/TomasHubelbauer/bloggo.git
EOF
> git fetch origin
remote: Counting objects: 1222, done.
remote: Compressing objects: 100% (538/538), done.
Receiving objects:  87% (1064/1222)   d 1169 (delta 654)
Receiving objects: 100% (1222/1222), 256.13 KiB | 2.81 MiB/s, done.
Resolving deltas: 100% (704/704), done.
From https://gitlab.com/TomasHubelbauer/bloggo
 * branch            HEAD       -> FETCH_HEAD

It didn't fetch the branches in the remote and store them in refs/remotes/origin at all!

> ls .git/refs
heads/  tags/

Instead it fetch the remote HEAD and wrote something in .git/FETCH_HEAD in... some new format that I'll have to add support for I guess.

> cat .git/FETCH_HEAD
c610ce1a1e0e383a757af94bb95baeb080d21412                https://gitlab.com/TomasHubelbauer/bloggo

Now if we modify the config file to include the fetch refspec and do the exact same fetch:

> echo "fetch = +refs/heads/*:refs/remotes/origin/*" >> .git/config
> git fetch origin
From https://gitlab.com/TomasHubelbauer/bloggo
 * [new branch]      master     -> origin/master

Now we see it saved the fetched branches where we'd normally expect them:

> ls .git/refs
heads/  remotes/  tags/
> ls .git/refs/remotes
origin/
> ls .git/refs/remotes/origin/
master

Interestingly, it updated FETCH_HEAD too:

> cat .git/FETCH_HEAD
c610ce1a1e0e383a757af94bb95baeb080d21412        not-for-merge   branch 'master' of https://gitlab.com/TomasHubelbauer/bloggo

I don't want to make isomorphic-git differ from canonical git's behavior. But I also haven't implemented the weirdness that is FETCH_HEAD. So for now... I think I'll just throw a warning if the config file is missing the "fetch" field for a remote and suggest using the default fetch = +refs/heads/*:refs/remotes/origin/*

from isomorphic-git.

billiegoose avatar billiegoose commented on May 14, 2024

🎉 This issue has been resolved in version 0.9.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

from isomorphic-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.