johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
51 stars 9 forks source link

Cannot quarterly switch from 2022Q1 to 2022Q2 #81

Closed michael-o closed 2 years ago

michael-o commented 2 years ago

Running from: e6b52cd4d687060fa2b2496f7905ac169894ede1

with

        "ports":{
                "repository_path":"/ports.git",
                "branch":"quarterly",
                "target_directory":"/usr/ports",
                "ignores":[
                        "distfiles",
                        "packages",
                        "INDEX-11",
                        "INDEX-12",
                        "INDEX-13",
                        "INDEX-14"
                ]

and

# cat /usr/ports/.gituprevision
2022Q1:22c91b968

then

# gitup  ports
# Scanning local repository...
# Host: git.freebsd.org
# Port: 443
# Proxy Host: de.coia.siemens.net
# Proxy Port: 9400
# Repository Path: /ports.git
# Target Directory: /usr/ports
# Have: 22c91b968c5578863af4aedf809eb4116b72dacb
# Want: 7de40f7d3b31cb1e642aa53b4b38fd3fdeba4bec
# Branch: 2022Q2
# Action: pull
gitup: load_object: local file for object 656fc7433e789e9e477c7413c3416aec98f78d4a -- (null) not found: No such file or directory
michael-o commented 2 years ago

Without haven't analyzed it any further, I believe the operation is doomed to fail because it send a have on branch 2022Q1, but wants a commit on another branch. How can this be reasonably satisfied?! I guess gitup needs to detect branch change and simply do a clone, not a pull.

michael-o commented 2 years ago

Did another test, moved in gitup.conf to 2021Q4, before the clone it was on 2022Q1. Same behavior. So gitup needs to detect whether the target commit (want) is on another branch then it needs to perform a clone, not a pull.

michael-o commented 2 years ago

Another sample:

# gitup ports
# Scanning local repository...
# Host: git.freebsd.org
# Port: 443
# Repository Path: /ports.git
# Target Directory: /usr/ports
# Have: 08f07d35843d6607bef4b0df44999e541a85cd42
# Want: b76aa00714838142a7b2b9fafa1aec10e8354da6
# Branch: main
# Action: pull
gitup: load_object: local file for object 9f7abadf31bd18130bcff145afabd23521756e59 -- (null) not found: No such file or directory
root@bsd1srv:~
johnmehr commented 2 years ago

It looks like the failure is occurring because the local repository scan is skipping the contents of cad/kicad-library-packages3d and cad/kicad-library-packages3d-devel because the paths pattern match "packages" is in the ignores list.

Does it work if you change "packages" to "/packages/" in the ignores list?

michael-o commented 2 years ago

Indeed! I did:

                "ignores":[
                        "/distfiles",
                        "/packages",
                        "/INDEX-11",
                        "/INDEX-12",
                        "/INDEX-13",
                        "/INDEX-14"
                ]

and if you look into .gitignore it should have been like this:

$ cat .gitignore
/distfiles
/packages
/security/vuxml/vuln-flat.xml
Makefile.local
/*/*/work
/*/*/work-*
/INDEX-[0-9]*
*~
*.rej
*.orig
*.sw[p-z]

Basically, you need to update the sample gitup.conf with the predeceding slash. Moreover, is there any POSIX or FreeBSD-specific function to implement this kind of globbing to readin .gitignore and apply it if not defined in gitup.conf explicitly?

johnmehr commented 2 years ago

The transition from 2022Q2 to 2022Q3 was successful so I think this issue is safe to close now. Thank you!