Skip to contentSkip to conversation

New: support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

Buildroot [email protected] 2 participants 8 messages Jun 10, 2022 – Jun 15, 2024

lore
Share & tools
lore
#0 lore raw

https://bugs.busybox.net/show_bug.cgi?id=14841

Bug ID: 14841
Summary: support/download/git fails with "fatal: No such remote
'origin'" due to incorrect check for origin remote
Product: buildroot
Version: 2020.02.10
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P5
Component: Other
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---

The git script does the following:

- initializes a git repo
- checks if the remote named origin exists
- if it exists, it call git remote set-url to set the correct url for the origin remote

The problem is, it uses the command 'git remote | grep '^origin$'' to check if origin exists. This command always prints the word origin, even if the origin remote doesn't actually exist in the repo. It's unfortunate, but that's how git works. On a brand new git repo, origin does not exist, but this part of the script believes it does exist, so it calls git remote set-url which then fails because origin doesn't exist.

In my project I noticed two packages, flashbench and mmc_utils that use the git download method and it fails for both of them. The packages still succeed because they fallback to a different download method. I can imagine that's one reason why this has not been noticed.

You will also not see this error if the git repo already exists with an actual origin remote that has been configured.

The proper way to check if origin exists is to do this:

if ! git config remote.origin.url | /dev/null; then...

I have a patch for this and I will work on sending it to the mailing list.

Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

[Buildroot] [Bug 14841] support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

https://bugs.busybox.net/show_bug.cgi?id=14841

--- Comment #1 from [email protected] ---
I checked latest master in the buildroot git repo and it appears this bug is still present there too.

Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to [email protected]

Hello!

On 2022-06-11, [email protected] reported:

Quoted 3 lines

[support/download/git] uses the command 'git remote | grep '^origin$'' to check if origin exists. This command always prints the word origin, even if the origin remote doesn't actually exist in the repo.

I cannot reproduce this. My copy of git does not print “origin” if there is no remote named such:

    $ git --version
    git version 2.25.1
    $ git init foo
    Initialized empty Git repository in /home/edgar/foo/.git/
    $ cd foo/
    $ git remote | grep '^origin$'
    $     # <- empty output

I also tried with both a quite old and a fairly recent version of git (2.11.0 from Debian Stretch and 2.35.1 from Debian Testing) with the same result.

Regards,

Edgar.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

[Buildroot] [Bug 14841] support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

In reply to [email protected]

https://bugs.busybox.net/show_bug.cgi?id=14841

Yann E. MORIN <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #2 from Yann E. MORIN <[email protected]> --- Hello,

Thanks for the report.

I'll be quoting what Edgar explained on the mailing list [0]:

---
I cannot reproduce this. My copy of git does not print “origin” if there is no remote named such:

    $ git --version
    git version 2.25.1
    $ git init foo
    Initialized empty Git repository in /home/edgar/foo/.git/
    $ cd foo/
    $ git remote | grep '^origin$'
    $     # <- empty output

I also tried with both a quite old and a fairly recent version of git (2.11.0 from Debian Stretch and 2.35.1 from Debian Testing) with the same result.
---

I also tried the same as Edgar, and I too can't reproduce.

Can you provide more information, please?

[0]
https://lore.kernel.org/buildroot/[email protected]/T/#t

Regards,
Yann E. MORIN.

Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

[Buildroot] [Bug 14841] support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

In reply to [email protected]

https://bugs.busybox.net/show_bug.cgi?id=14841

Yann E. MORIN <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

         Resolution|---                         |WORKSFORME
             Status|NEW                         |RESOLVED

--- Comment #3 from Yann E. MORIN <[email protected]> --- Hello,

We did not get feedback, or more explanations about your issue, and there are two people that reported that the case you described did in fact work as expected.

So we're clodsing this issue report. Feel free to reopen with more information if you still have the issue.

Regards,
Yann E. MORIN.

Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

[Buildroot] [Bug 14841] support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

In reply to [email protected]

https://bugs.busybox.net/show_bug.cgi?id=14841

--- Comment #4 from Emil Medve <[email protected]> --- Newer versions of git will expose this issue:

```bash
$ git --version
git version 2.37.2
$ git init
Initialized empty Git repository in .../.git/
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
$ git remote -v
origin
```
Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

[Buildroot] [Bug 14841] support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

In reply to [email protected]

https://bugs.busybox.net/show_bug.cgi?id=14841

Emil Medve <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---
Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

[Buildroot] [Bug 14841] support/download/git fails with "fatal: No such remote 'origin'" due to incorrect check for origin remote

In reply to [email protected]

https://bugs.busybox.net/show_bug.cgi?id=14841

Yann E. MORIN <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

--- Comment #5 from Yann E. MORIN <[email protected]> --- Thank you for your report.

The issue tracker for the Buildroot project has been moved to the Gitlab.com issue tracker:
https://gitlab.com/buildroot.org/buildroot/-/issues

We are taking this opportunity to close old issues in this old tracker. If you believe your issue is still relevant, please open one in the new issue tracker.

Thank you!

Signature · 6 lines
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot