Skip to content

TL Localization - Chapter 7, Submodules (1,112 words) #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 97 additions & 97 deletions book/07-git-tools/sections/submodules.asc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Ating simulan sa pamamagitan ng pagdagdag ng isang umiiral na repositoryo ng Git
Upang magdagdag ng isang bagong submodule, gumamit ng utos na `git submodule add` na may ganap o kaugnay na URL ng pryekto na nais mong simulang subaybayan. Upang magdagdag ng isang bagong submodule, gumamit ng utos na `git submodule add` na may ganap o kaugnay na URL ng pryekto na nais mong simulang subaybayan.
Sa halimbawang ito, magdadagdag tayo ng isang library na tinatawag na ``DbConnector''. Sa halimbawang ito, magdadagdag tayo ng isang library na tinatawag na ``DbConnector''.


[source,console] [source,console
---- ----
$ git submodule add https://github.com/chaconinc/DbConnector $ git submodule add https://github.com/chaconinc/DbConnector
Pagkokopya sa 'DbConnector'... Pagkokopya sa 'DbConnector'...
Expand Down Expand Up @@ -384,199 +384,199 @@ Ito ay nangangahulugan na walang lokal na tinatrabahuang branch (tulad ng ``mast
Ng walang tinatrabahuang branch na nagsusubaybay ng mga pagbabago, iyon ay nangangahulugan na kahit na ikaw ay mag-commit ng mga pagbabago sa submodule, ang mga pagbabagong iyon ay posibleng mawala sa susunod na patakbuhin mo ang `git submodule update`. Ng walang tinatrabahuang branch na nagsusubaybay ng mga pagbabago, iyon ay nangangahulugan na kahit na ikaw ay mag-commit ng mga pagbabago sa submodule, ang mga pagbabagong iyon ay posibleng mawala sa susunod na patakbuhin mo ang `git submodule update`.
Kailangan mong gawin ang ilang mga dagdag na hakbang kung nais mong baguhin ang mga submodule na susubaybayan. Kailangan mong gawin ang ilang mga dagdag na hakbang kung nais mong baguhin ang mga submodule na susubaybayan.


In order to set up your submodule to be easier to go in and hack on, you need do two things. Para ma-set up ang iyong submodule na maging mas madaling pasukin at i-hack, kailangan mong gawin ang dalawang bagay.
You need to go into each submodule and check out a branch to work on. Kailangan mong puntahan ang bawat submodule at suriin ang isang branch na tatrabahuin.
Then you need to tell Git what to do if you have made changes and then `git submodule update --remote` pulls in new work from upstream. Pagkatapos ay kailangan mong sabihan ang Git kung ano ang gagawin kung may ginawa kang mga pagbabago at pagkatapos ay ipu-pull ng `git submodule update --remote` sa bagong trabaho mula sa upstream.
The options are that you can merge them into your local work, or you can try to rebase your local work on top of the new changes. Ang mga pagpipilian ay maaari kang mag-merge ng mg ito sa iyong lokal na trabaho, o subukang i-rebase ang iyong lokal na trabaho sa itaas ng mga bagong pagbabago.


First of all, let's go into our submodule directory and check out a branch. Una sa lahat, puntahan natin ang ating submodule na direktoryo at suriin ang isang branch.


[source,console] [source,console]
---- ----
$ git checkout stable $ git checkout stable
Switched to branch 'stable' Pinalitan sa branch na 'stable'
---- ----


Let's try it with the ``merge'' option. Subukan natin ito sa opsyon na ``merge''.
To specify it manually, we can just add the `--merge` option to our `update` call. Upang itakda ito nang mano-mano, maaari lamang nating idagdag ang pagpipilian na `--merge` sa ating `update` na pagtawag.
Here we'll see that there was a change on the server for this submodule and it gets merged in. Dito, makikita natin na may isang pagbabago sa server para sa submodule na ito at ito ay nai-merge.


[source,console] [source,console]
---- ----
$ git submodule update --remote --merge $ git submodule update --remote --merge
remote: Counting objects: 4, done. remote: Pagbibilang ng mga bagay: 4, tapos na.\
remote: Compressing objects: 100% (2/2), done. remote: Pagko-compress ng mga bagay: 100% (2/2), tapos na.
remote: Total 4 (delta 2), reused 4 (delta 2) remote: Kabuuan 4 (delta 2), muling nagamit 4 (delta 2)
Unpacking objects: 100% (4/4), done. Pag-aalis ng laman ng mga bagay: 100% (4/4), tapos na.
From https://github.com/chaconinc/DbConnector Mula sa https://github.com/chaconinc/DbConnector
c87d55d..92c7337 stable -> origin/stable c87d55d..92c7337 stable -> origin/stable
Updating c87d55d..92c7337 Nag-a-update sa c87d55d..92c7337
Fast-forward Fast-forward
src/main.c | 1 + src/main.c | 1 +
1 file changed, 1 insertion(+) 1 file na nabago, 1 pagsisingit(+)
Submodule path 'DbConnector': merged in '92c7337b30ef9e0893e758dac2459d07362ab5ea' Submodule path 'DbConnector': na-merge sa '92c7337b30ef9e0893e758dac2459d07362ab5ea'
---- ----


If we go into the DbConnector directory, we have the new changes already merged into our local `stable` branch. Kung pupuntahan natin ang DbConnector na direktoryo, mayroon na tayong mga bagong pagbabago na na-merge sa lokal `stable` na branch.
Now let's see what happens when we make our own local change to the library and someone else pushes another change upstream at the same time. Ngayon, tingnan natin kung ano ang nangyayari kapag gagawa tayo ng sariling lokal na pagbabago sa library at may ibang tao na mag-push ng iba pang pagbabago na upstream sa parehong oras.


[source,console] [source,console]
---- ----
$ cd DbConnector/ $ cd DbConnector/
$ vim src/db.c $ vim src/db.c
$ git commit -am 'unicode support' $ git commit -am 'unicode support'
[stable f906e16] unicode support [stable f906e16] unicode support
1 file changed, 1 insertion(+) 1 file na nabago, 1 pagsisingit(+)
---- ----


Now if we update our submodule we can see what happens when we have made a local change and upstream also has a change we need to incorporate. Ngayon kung ating ia-update ang ating submodule, makikita natin kung ano ang nangyayari kapag gumawa tayo ng isang lokal na pagbabago at ang upstream din ay may isang pagbabago na kailangan nating isama.


[source,console] [source,console]
---- ----
$ git submodule update --remote --rebase $ git submodule update --remote --rebase
First, rewinding head to replay your work on top of it... Una, nagri-rewind sa head upang ulitin ang iyong trabaho sa itaas nito...
Applying: unicode support Naglalapat: unicode na suporta
Submodule path 'DbConnector': rebased into '5d60ef9bbebf5a0c1c1050f242ceeb54ad58da94' Submodule path 'DbConnector': ni-rebase sa '5d60ef9bbebf5a0c1c1050f242ceeb54ad58da94'
---- ----


If you forget the `--rebase` or `--merge`, Git will just update the submodule to whatever is on the server and reset your project to a detached HEAD state. Kung nalimutan mo ang `--rebase` o `--merge`, ia-update lamang ng Git ang submodule sa kung anuman ang nasa server at ilagay muli ang iyong proyekto sa isang tinanggal na HEAD na estado.


[source,console] [source,console]
---- ----
$ git submodule update --remote $ git submodule update --remote
Submodule path 'DbConnector': checked out '5d60ef9bbebf5a0c1c1050f242ceeb54ad58da94' Submodule path 'DbConnector': nag-check out sa '5d60ef9bbebf5a0c1c1050f242ceeb54ad58da94'
---- ----


If this happens, don't worry, you can simply go back into the directory and check out your branch again (which will still contain your work) and merge or rebase `origin/stable` (or whatever remote branch you want) manually. Kung mangyayari ito, huwag mag-alala, maaari kang bumalik sa direktoryo at suriing muli ang iyong branch (kung saan ay naglalaman pa rin ng iyong trabaho) at i-merge o i-rebase nang mano-mano ang `origin/stable` (o kung anuman ang gustong mong remote na branch).


If you haven't committed your changes in your submodule and you run a submodule update that would cause issues, Git will fetch the changes but not overwrite unsaved work in your submodule directory. Kung hindi ka pa naka-commit ng iyong mga pagbabago sa iyong submodule at nagpatakbo ka ng isang update ng submodule na magiging sanhi ng mga isyu, kukunin ng Git ang mgs pagbabago ngunit hindi nito sasapawan ang mga hindi na-save na trabaho sa iyong submodule na direktoryo.


[source,console] [source,console]
---- ----
$ git submodule update --remote $ git submodule update --remote
remote: Counting objects: 4, done. remote: Pagbibilang ng mga bagay: 4, tapos na.
remote: Compressing objects: 100% (3/3), done. remote: Pagko-compress ng mga bagay: 100% (3/3), tapos na.
remote: Total 4 (delta 0), reused 4 (delta 0) remote: Kabuuan 4 (delta 0), muling nagamit 4 (delta 0)
Unpacking objects: 100% (4/4), done. Pag-aalis ng laman ng mga bagay: 100% (4/4), tapos na.
From https://github.com/chaconinc/DbConnector Mula sa https://github.com/chaconinc/DbConnector
5d60ef9..c75e92a stable -> origin/stable 5d60ef9..c75e92a stable -> origin/stable
error: Your local changes to the following files would be overwritten by checkout: kamalian: Ang lokal na mga pagbabago sa mga sumusunod na mga file ay masasapawan ng checkout:
scripts/setup.sh scripts/setup.sh
Please, commit your changes or stash them before you can switch branches. Pakiusap, i-commit ang iyong mga pagbabago o i-stash ang mga ito bago makapagpalit ng mga branch.
Aborting Nag-uurong
Unable to checkout 'c75e92a2b3855c9e5b66f915308390d9db204aca' in submodule path 'DbConnector' Hindi ma-checkout ang 'c75e92a2b3855c9e5b66f915308390d9db204aca' sa path ng submodule na 'DbConnector'
---- ----


If you made changes that conflict with something changed upstream, Git will let you know when you run the update. Kung gumawa ka ng mga pagbabago na sumasalungat sa ilang nabago na upstream, ipapaalam sa iyo ng Git kapag pinatakbo mo ang update.


[source,console] [source,console]
---- ----
$ git submodule update --remote --merge $ git submodule update --remote --merge
Auto-merging scripts/setup.sh Awtomatikong pagsasama sa scripts/setup.sh
CONFLICT (content): Merge conflict in scripts/setup.sh SALUNGATAN (nilalaman): Kasalungatan sa pag-merge sa scripts/setup.sh
Recorded preimage for 'scripts/setup.sh' Nagtala ng preimage para sa 'scripts/setup.sh'
Automatic merge failed; fix conflicts and then commit the result. Nabigo ang awtomatikong pag-merge; ayusin ang mga kasalungtan at pagkatapos i-commit ang resulta.
Unable to merge 'c75e92a2b3855c9e5b66f915308390d9db204aca' in submodule path 'DbConnector' Hindi ma-merge ang 'c75e92a2b3855c9e5b66f915308390d9db204aca' sa path ng submodule na 'DbConnector'
---- ----


You can go into the submodule directory and fix the conflict just as you normally would. Maaari kang magpunta sa submodule na direktoryo at ayusin ang salungatan tulad ng karaniwan mong ginagawa.


[[_publishing_submodules]] [[_publishing_submodules]]
===== Publishing Submodule Changes ===== Paglalathala sa mga Pagbabago ng Submodule


Now we have some changes in our submodule directory. Ngayon ay mayroon na tayong iilang mga pagbabago sa ating submodule na direktoryo.
Some of these were brought in from upstream by our updates and others were made locally and aren't available to anyone else yet as we haven't pushed them yet. Ilan sa mga ito ay dinala mula sa upstream sa pamamagitan ng ating mga update at ang iba ay ginawa sa lokal at hindi pa magagamit ng sinuman dahil hindi pa natin na-push ang mga ito.


[source,console] [source,console]
---- ----
$ git diff $ git diff
Submodule DbConnector c87d55d..82d2ad3: Submodule DbConnector c87d55d..82d2ad3:
> Merge from origin/stable > Nag-merge mula sa origin/stable
> updated setup script > ina-update ang setup script
> unicode support > unicode na suporta
> remove unnecessary method > tinanggal ang hindi kinakailangang pamamaraan
> add new option for conn pooling > nagdagdag ng bagong opsyon para sa conn pooling
---- ----


If we commit in the main project and push it up without pushing the submodule changes up as well, other people who try to check out our changes are going to be in trouble since they will have no way to get the submodule changes that are depended on. Kung tayo ay nag-commit sa pangunahing proyekto at pi-nush ito, nang wala ring pag-push sa mga pagbabago ng submodule, ang ibang tao na nagsusubok na mag-check out ng mga pagbabago ay magkakaroon ng problema dahil wala silang paraan upang makuha ang mga naka-dependeng pagbabago sa submodule.
Those changes will only exist on our local copy. Ang mga pagbabagong iyon ay umiiral lamang sa ating lokal na kopya.


In order to make sure this doesn't happen, you can ask Git to check that all your submodules have been pushed properly before pushing the main project. Para makasiguro na hindi na ito mangyayari, maaari mong hilingin sa Git na suriin na ang lahat ng iyong mga submodile ay na-push nang maayos bago mag-push sa pangunahing proyekto.
The `git push` command takes the `--recurse-submodules` argument which can be set to either ``check'' or ``on-demand''. Ang utos `git push` ay tumatanggap ng argumento na `--recurse-submodules` na kung saan maaari itakda ang alinman sa ``check'' o ``on-demand''.
The ``check'' option will make `push` simply fail if any of the committed submodule changes haven't been pushed. Ang opsyon na ``check'' ay simpleng bibigo sa `push` kung anuman sa mga na-commit na pagbabago ng submodule ay hindi na-push.


[source,console] [source,console]
---- ----
$ git push --recurse-submodules=check $ git push --recurse-submodules=check
The following submodule paths contain changes that can Ang mga sumusunod na mga path ng submodule ay naglalaman ng mga pagbabago na maaaring
not be found on any remote: hindi matagpuan sa anumang remote:
DbConnector DbConnector


Please try Pakisubukan


git push --recurse-submodules=on-demand git push --recurse-submodules=on-demand


or cd to the path and use o mag-cd sa path at gamitin ang


git push git push


to push them to a remote. upang ma-push ang mga ito sa isang remote.
---- ----


As you can see, it also gives us some helpful advice on what we might want to do next. Tulad ng iyong nakikita, nagbibigay din ito sa atin ng ilang kapaki-pakinabang na payo tungkol sa kung ano ang maaari nating gawin sa susunod.
The simple option is to go into each submodule and manually push to the remotes to make sure they're externally available and then try this push again. Ang simpleng pagpipilian ay pumunta sa bawat submodule at mano-manong i-push sa mga remote upang matiyak na magagamit ang mga ito sa labas at pagkatapos ay subukang muli ang push na ito.
If you want the check behavior to happen for all pushes, you can make this behavior the default by doing `git config push.recurseSubmodules check`. Kung nais mong suriin ang kilos na mangyayari para sa lahat ng push, maaari mong gawing default ang kilos na ito sa pamamagitan ng paggawa ng `git config push.recurseSubmodules check`.


The other option is to use the ``on-demand'' value, which will try to do this for you. Ang isa pang opsyon ay ang paggamit ng ``on-demand'' na halaga, na susubukan na gawin ito para sa iyo.


[source,console] [source,console]
---- ----
$ git push --recurse-submodules=on-demand $ git push --recurse-submodules=on-demand
Pushing submodule 'DbConnector' Pushing submodule 'DbConnector'
Counting objects: 9, done. Pagbibilang ng mga bagay: 9, tapos na.
Delta compression using up to 8 threads. Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done. Pagko-compress ng mga bagay: 100% (8/8), tapos na.
Writing objects: 100% (9/9), 917 bytes | 0 bytes/s, done. Writing objects: 100% (9/9), 917 bytes | 0 bytes/s, tapos na.
Total 9 (delta 3), reused 0 (delta 0) Total 9 (delta 3), muling nagamit 0 (delta 0)
To https://github.com/chaconinc/DbConnector Sa https://github.com/chaconinc/DbConnector
c75e92a..82d2ad3 stable -> stable c75e92a..82d2ad3 stable -> stable
Counting objects: 2, done. Pagbibilang ng mga bagay: 2, tapos na.
Delta compression using up to 8 threads. Delta compression na gumagamit ng hanggap 8 mga thread.
Compressing objects: 100% (2/2), done. Pagko-compress ng mga bagay: 100% (2/2), tapos na.
Writing objects: 100% (2/2), 266 bytes | 0 bytes/s, done. Pagsusulat ng mga bagao: 100% (2/2), 266 bytes | 0 bytes/s, tapos na.
Total 2 (delta 1), reused 0 (delta 0) Total 2 (delta 1), muling nagamit 0 (delta 0)
To https://github.com/chaconinc/MainProject Sa https://github.com/chaconinc/MainProject
3d6d338..9a377d1 master -> master 3d6d338..9a377d1 master -> master
---- ----


As you can see there, Git went into the DbConnector module and pushed it before pushing the main project. Tulad ng makikita mo doon, nagpunta si Git sa module ng DbConnector at nag-push ito bago mag-push sa pangunahing proyekto.
If that submodule push fails for some reason, the main project push will also fail. Kung ang submodule push ay nabigo para sa ilang kadahilanan, ang pangunahing push ng proyekto ay mabibigo din.
You can make this behavior the default by doing `git config push.recurseSubmodules on-demand`. Maaari mong gawing default ang kilos na ito sa pamamagitan ng paggawa ng `git config push.recurseSubmodules on-demand`.


===== Merging Submodule Changes ===== Pag-merge sa mga Pagbabago ng Submodule


If you change a submodule reference at the same time as someone else, you may run into some problems. Kung binago mo ang isang reperensya ng submodule sa parehong oras bilang ibang tao, maaari kang makaranas ng ilang mga problema.
That is, if the submodule histories have diverged and are committed to diverging branches in a superproject, it may take a bit of work for you to fix. Iyon ay, kung ang mga kasaysayan ng submodule ay magkaiba at na-commit sa mga magkaibang branch sa isang superproject, maaaring tumagal nang kaunti na maayos ito.


If one of the commits is a direct ancestor of the other (a fast-forward merge), then Git will simply choose the latter for the merge, so that works fine. Kung ang isa sa mga commit ay isang direktang ninuno ng iba pan (isang mabilis na pagsasama), pagkatapos ay piliin lamang ng Git ang huli para sa pagsasama, upang ito ay gumana.


Git will not attempt even a trivial merge for you, however. Ang Git ay hindi magtatangkang kahit isang maliit na pag-merge para sa iyo, gayunpaman.
If the submodule commits diverge and need to be merged, you will get something that looks like this: Kung ang submodule ay gumagawa ng magkaiba at kailangang i-merge, makakakuha ka ng isang bagay na mukhang ganito:


[source,console] [source,console]
---- ----
$ git pull $ git pull
remote: Counting objects: 2, done. remote: Pagbibilang ng mga bagay: 2, tapos na.
remote: Compressing objects: 100% (1/1), done. remote: Pagko-compress ng mga bagay: 100% (1/1), tapos na.
remote: Total 2 (delta 1), reused 2 (delta 1) remote: Kabuuan 2 (delta 1), muling nagamit 2 (delta 1)
Unpacking objects: 100% (2/2), done. Pag-aalis ng laman ng mga bagay: 100% (2/2), tapos na.
From https://github.com/chaconinc/MainProject Mula sa https://github.com/chaconinc/MainProject
9a377d1..eb974f8 master -> origin/master 9a377d1..eb974f8 master -> origin/master
Fetching submodule DbConnector Nagkukuha sa submodule DbConnector
warning: Failed to merge submodule DbConnector (merge following commits not found) babala: Bigong na-merge ang submodule DbConnector (ang pag-merge ng sumusunod na mga commit ay hindi natagpuan)
Auto-merging DbConnector Awtomatikong pag-merge sa DbConnector
CONFLICT (submodule): Merge conflict in DbConnector SALUNGATAN (submodule): Kasalungatan sa pag-merge sa DbConnector
Automatic merge failed; fix conflicts and then commit the result. Nabigo ang awtomatikong pag-merge; ayusin ang mga salungatan at pagkatapos i-commit ang resulta.
---- ----


So basically what has happened here is that Git has figured out that the two branches record points in the submodule's history that are divergent and need to be merged. So basically what has happened here is that Git has figured out that the two branches record points in the submodule's history that are divergent and need to be merged.
Expand Down