# Portdowngrade & Gitup Tweak for Downgrading



## Lamia (May 6, 2021)

Now that the ports repo does not support svn, how can one downgrade a port like portdowngrade used to do? Perhaps, I need use a method "git" as argument and replace the revision number with a git hash value when using the  portdowngrade command. If the port maintainer could do that, it would make things easier.

Someone showed how to use gitup not long ago, but I can't remember how.


----------



## SirDice (May 6, 2021)

Find the commit that updated the port and use `git revert` to revert that commit. You're going to need a 'complete' git checkout for this to work, it cannot work with gitup ports tree.


----------



## Lamia (May 7, 2021)

Many thanks SirDice . How do I do it when the only valuable information I have is the revision number from freshports?

Will git revert not require one having a git account with git.freebsd.org? Or should one rely on ports on github.com for this kind of activity?


----------



## Lamia (May 7, 2021)

I'm looking at this - https://wiki.freebsd.org/GitWorkflow.


----------



## SirDice (May 7, 2021)

Lamia said:


> How do I do it when the only valuable information I have is the revision number from freshports?


Browse on cgit.freebsd.org (or github), lookup the port. Then look at the commit logs to find the commit that updated the port. 



Lamia said:


> Will git revert not require one having a git account with git.freebsd.org?


No, it's applied to your local _working_ copy. Best is to create a new branch, then revert the commit in your own branch. That way you can easily switch back to the main branch to get the original again. 



Lamia said:


> Or should one rely on ports on github.com for this kind of activity?


Doesn't matter.


----------



## Lamia (May 7, 2021)

Thanks SirDice; this is too much of a process for new entrants wanting to downgrade a package. I hope one of the existing tools will soon be modified to make life easier as I earlier envisaged.


----------



## jmehr (May 10, 2021)

net/gitup should be able to revert your local ports tree to an earlier state.  If you have the full hash value of the commit you want to go back to, all you need to do is add it to the command line via the -w parameter:

`gitup ports -w 484ae4ecd943ba80353ec6c0629a275018ec06cc`


----------



## rawthey (May 10, 2021)

Where do we find the full hash?
Beefy16 shows the latest package build for 130amd64-default is ad49ee98c4b6 which I assume is the first part of the hash but gitup doesn't like it:

```
curlew:/root# gitup ports -w ad49ee98c4b6
# Host: git.freebsd.org
# Port: 443
# Repository Path: /ports.git
# Target Directory: /usr/ports
# Have: 218ad8035b585651aeaaddbcffc2d423b557dde7
# Want: ad49ee98c4b6
# Branch: (detached)
# Action: pull
gitup: fetch_pack: malformed pack data:

: Inappropriate file type or format
```


----------



## SirDice (May 10, 2021)

rawthey said:


> Where do we find the full hash?


Git logs. 

Find the port: https://cgit.freebsd.org/ports/tree/  and look at the logs for that port. Each commit will have a full hash.


----------



## rawthey (May 12, 2021)

SirDice said:


> Git logs.
> 
> Find the port: https://cgit.freebsd.org/ports/tree/  and look at the logs for that port. Each commit will have a full hash.


But that's ok for finding the commit for when a single port was last changed but what I want to do is to find the commit corresponding to the latest build on the package cluster. I use packages for most things but use ports for a small number of packages for which I need different options, e.g. to add ffmpeg to audacity.

In the past I was able to use the build number from the beefy16 web page to get the corresponding version of ports with svn and I had been hoping that I could do similar with gitup but this doesn't work.

beefy16 currently shows the checksum for the latest package run is 0c0a4f4b9148 but gitup fails if I supply this shortened hash.
	
	



```
curlew:/tmp# gitup ports -w 0c0a4f4b9148
# Host: git.freebsd.org
# Port: 443
# Repository Path: /ports.git
# Target Directory: /usr/ports
# Have: 218ad8035b585651aeaaddbcffc2d423b557dde7
# Want: 0c0a4f4b9148
# Branch: (detached)
# Action: pull
gitup: fetch_pack: malformed pack data:

: Inappropriate file type or format
```
It looks like gitup needs the full 40 character hash.

I have been able to find the full hash by going to github.com/freebsd/freebsd-ports , clicking the commits link and scrolling through several pages until I found a port with a 10 digit hash matching the first 10 characters of 0c0a4f4b9148. Clicking on that port then took me to a page which displayed the full hash 0c0a4f4b91481ccc3e0ba9df781ab80ec3fee876 which gitup accepts without any problem..

But this is very tedious and I was hoping there was a simpler way of finding the full hash. It would be even better if gitup would accept a shortened hash in the same way as git does. Could it be that this is a bug in gitup?


----------



## jmehr (May 15, 2021)

It's not a bug in net/gitup but more of a limitation.  The git server only accepts 40 character hashes when requesting a pull or a clone and because net/gitup doesn't currently have the full commit history, it doesn't have a way of looking up the full 40 character hash when given a 10 character hash.

I'm working on adding the full commit history download functionality (it's working for clones but not quite working yet for pulls) and when I get that sorted out, looking up the full hash from a short hash should be pretty straight forward.


----------



## rawthey (May 15, 2021)

jmehr said:


> I'm working on adding the full commit history download functionality (it's working for clones but not quite working yet for pulls) and when I get that sorted out, looking up the full hash from a short hash should be pretty straight forward.


Thanks, that will be a useful feature for me.


----------

