Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th November 2020, 12:58   #1  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Updating x265 to a specific revision: git vs. Mercurial

I already asked it once in the x265 encoder thread, but there are still issues, and I don't want to clutter that thread more, so I'll prefer a separate thread.

When x265 used Mercurial (hg), I could use a simple shell script to update my local working directory to either the latest commit in the default branch, or the "tip" regardless of the branch, or a specific commit by checksum.

uptodate_x265.sh
Code:
#!/bin/sh
hg pull --cwd build/x265-hg -r "${1:-default}"
hg update --cwd build/x265-hg -r "${1:-default}"
Apparently, this worked due to the simplicity and flexibility of hg handling submitted parameters and deciding which meaning a parameter has.

I had to learn that I am not able to understand the meaning of all the parameters git offers to achieve the same result.

Until today I believed that the following script is able to ensure that my local working directory gets updated to the latest commit in the default branch:

uptodate_x265-git.sh
Code:
#!/bin/sh
git -C build/x265_git-git fetch -v --progress origin
git -C build/x265_git-git pull -v --no-rebase --progress origin master
But since I failed updating it to a specific revision by checksum with a modified script, until I ran a "git merge" command (which popped up a Vim which I don't want and need), I started to doubt that.

So I remain helpless.

It would be nice if I could have one script which does the same as my previous one, but won't mind if I have to split it into separate versions to handle default, tip, and revision-by-checksum-parameter in optimal sequences, to avoid complex case switches.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 17th November 2020, 17:49   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
In most cases a simple git pull will be sufficient

Anyway, I think the most reliable way to update your local branch to the latest commit (HEAD) of the remote branch is:
git fetch --all && git reset --hard origin/master

If you want a different branch or a specific commit, replace origin/master with origin/some_branch or just commit_id. Additionally, you may want to run git clean -fdx after the update, in order to get rid of any old cruft.

Note that git pull is just a shorthand for git fetch followed by git merge FETCH_HEAD. In other words, it first fetches the latest changes from the remote tracking branch and then merges them into your local branch. This will create additional "merge" commits in your local branch, unless the merge is purely fast forward. These merge commits obviously won't exist on the remote. Also, the merge can fail for various reasons.

With the "git fetch plus git reset --hard" method you throw away the local changes (if any) and simply reset your local branch to the HEAD of the remote. It will not try to merge anything, which probably is what you want here.

Using a GUI like "Tortoise Git" can help to make things more obvious:
https://i.imgur.com/m7W3xRB.png
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th November 2020 at 18:19.
LoRd_MuldeR is offline   Reply With Quote
Old 17th November 2020, 23:00   #3  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
I want to run it semi-automated in scripts in the MinGW shells of MABS. So I will test your suggestions soonish...

I will always only retrieve from the distant repo to my local working directory, revoking local changes will be intended.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 17th November 2020 at 23:03.
LigH is offline   Reply With Quote
Old 17th November 2020, 23:07   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by LigH View Post
I want to run it semi-automated in scripts in the MinGW shells of MABS. So I will test your suggestions soonish...

I will always only retrieve from the distant repo to my local working directory, revoking local changes will be intended.
Then I'd suggest either rm -rf the existing directory and do a fresh git clone or, as was suggested before, do git fetch followed by git reset --hard (followed by git clean -fdx)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 18th November 2020 at 17:56.
LoRd_MuldeR is offline   Reply With Quote
Old 18th November 2020, 09:28   #5  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Cleaning so thoroughly would be counterproductive, using MABS with ccache as environment, I found... but apart from that it works well now.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.