diff --git a/book/07-git-tools/sections/submodules.asc b/book/07-git-tools/sections/submodules.asc index 92c3db8e4..93ec7fc8e 100644 --- a/book/07-git-tools/sections/submodules.asc +++ b/book/07-git-tools/sections/submodules.asc @@ -579,13 +579,13 @@ SALUNGATAN (submodule): Kasalungatan sa pag-merge sa DbConnector 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. -It explains it as ``merge following commits not found'', which is confusing but we'll explain why that is in a bit. +Sa totoo lang kung ano ang nangyari dito ay napag-alaman ng Git na ang dalawang branch ay nagtatala ng mga puntos sa kasaysayan ng submodule na magkakaiba at kailangang i-merge. +Ipinapaliwanag ito bilang ``hindi natagpuan ang mga sumusunod na mga commit sa pag-merge'', kung saan ay nakakalito ngunit aming ipapaliwanag kung bakit ganyan nang ilang sandali. -To solve the problem, you need to figure out what state the submodule should be in. -Strangely, Git doesn't really give you much information to help out here, not even the SHA-1s of the commits of both sides of the history. -Fortunately, it's simple to figure out. -If you run `git diff` you can get the SHA-1s of the commits recorded in both branches you were trying to merge. +Upang malutas ang problema, kailangan mong alamin kung ano ang dapat na estado ng submodule. +Kakaiba, hindi masyadong nagbibigay ang Git sa iyo ng impormasyon na tutulong dito, kahit na ang SHA-1s ng mga commit sa parehong panig ng kasaysayan. +Sa kabutihang-palad, madali itong alamin. +Kung patakbuhin mo ang `git diff` maaari kang makakuha ng SHA-1s ng mga commit na nakatala sa parehong mga branch na sinubukang mong i-merge. [source,console] ---- @@ -596,16 +596,16 @@ index eb41d76,c771610..0000000 +++ b/DbConnector ---- -So, in this case, `eb41d76` is the commit in our submodule that *we* had and `c771610` is the commit that upstream had. -If we go into our submodule directory, it should already be on `eb41d76` as the merge would not have touched it. -If for whatever reason it's not, you can simply create and checkout a branch pointing to it. +Kaya, sa kasong ito, ang `eb41d76` ay ang commit sa ating submodule na mayroon *tayo* at `c771610` ay ang commit na mayroon ang upstream. +Kung pupunta tayo sa ating submodule na direktoryo, ito ay dapat nasa `eb41d76` dahil hindi ito ginalaw ng merge. +Kung para sa kahit anong dahilan ito ay hindi, maaari mo lamang ilikha at i-checkout ang branch na tumuturo dito. -What is important is the SHA-1 of the commit from the other side. -This is what you'll have to merge in and resolve. -You can either just try the merge with the SHA-1 directly, or you can create a branch for it and then try to merge that in. -We would suggest the latter, even if only to make a nicer merge commit message. +Ang mahalaga ay ang SHA-1 ng commiut mula sa ibang bahagi. +Ito ang kinakailangan mong i-merge at lutasin. +Maaari mo ring subukan ang pag-merge nang direkta, gamit ang SHA-1, o maaari kang lumikha ng isang branch para rito at pagkatapos ay subukang i-merge iyon. +Iminungkahi namin ang huli, kahit na ang paggawa ng mas magandang commit na mensahe ng merge. -So, we will go into our submodule directory, create a branch based on that second SHA-1 from `git diff` and manually merge. +Kaya, pupunta tayo sa ating submodule na direktoryo, lumikha ng isang branch batay sa pangalawang SHA-1 na iyon mula sa `git diff` at mano-manong i-merge. [source,console] ---- @@ -616,21 +616,21 @@ eb41d764bccf88be77aced643c13a7fa86714135 $ git branch try-merge c771610 (DbConnector) $ git merge try-merge -Auto-merging src/main.c -CONFLICT (content): Merge conflict in src/main.c -Recorded preimage for 'src/main.c' -Automatic merge failed; fix conflicts and then commit the result. +Awtomatikong pag-merge sa src/main.c +SALUNGATAN (nilalaman): Salungatan ng pag-merge sa src/main.c +Naitala ang preimage para sa 'src/main.c' +Nabigo ang awtomatikong pag-merge; ayusin ang mga salungatan at pagkatapos ay i-commit ang resulta. ---- -We got an actual merge conflict here, so if we resolve that and commit it, then we can simply update the main project with the result. +Nakakuha tayo dito ng aktwal na salungan sa pag-merge, kaya kung malutas natin iyon at ma-commit ito, maaari tayong mag-update sa pangunahing proyekto gamit ang resulta. [source,console] ---- $ vim src/main.c <1> $ git add src/main.c $ git commit -am 'merged our changes' -Recorded resolution for 'src/main.c'. -[master 9fd905e] merged our changes +Naitala ang resolusyon para sa 'src/main.c'. +[master 9fd905e] nai-merge ang ating mga pagbabago $ cd .. <2> $ git diff <3> @@ -644,100 +644,106 @@ index eb41d76,c771610..0000000 ++Subproject commit 9fd905e5d7f45a0d4cbc43d1ee550f16a30e825a $ git add DbConnector <4> -$ git commit -m "Merge Tom's Changes" <5> -[master 10d2c60] Merge Tom's Changes +$ git commit -m "Nag-merge sa mga pagbabago ni Tom" <5> +[master 10d2c60] Nag-merge sa mga pagbabago ni Tom ---- -<1> First we resolve the conflict -<2> Then we go back to the main project directory -<3> We can check the SHA-1s again -<4> Resolve the conflicted submodule entry -<5> Commit our merge +<1> Una, ating nilutas ang salungatan sa pag-merge +<2> Pagkatapos, tayo ay bumalik sa direktoryo ng pangunahing proyekto +<3> Maaari nating suriing muli ang SHA-1s +<4> Lutasin ang mga nagkasalungatang submodule na tala +<5> I-commit ang ating merge -It can be a bit confusing, but it's really not very hard. -Interestingly, there is another case that Git handles. -If a merge commit exists in the submodule directory that contains *both* commits in its history, Git will suggest it to you as a possible solution. -It sees that at some point in the submodule project, someone merged branches containing these two commits, so maybe you'll want that one. +Ito ay maaaring nakakalito, ngunit ito ay hindi ganoon kahirap. -This is why the error message from before was ``merge following commits not found'', because it could not do *this*. -It's confusing because who would expect it to *try* to do this? +Kapansin-pansin na mayroong ibang kaso na hinahawakan ng Git. +Kung umiiral ang isang commit ng merge sa direktoryo ng submodule na naglalaman ng *parehong* mga commit sa kasaysayan nito, imumungkahi ito ng Git sa iyo bilang isang posibleng solusyon. +Nakikita nito na sa ilang punto sa proyekto ng submodule, may isang naka-merge ng mga branch na naglalaman ng dalawang commit na ito, kaya maaaring gugustuhin mo ang isang iyon. -If it does find a single acceptable merge commit, you'll see something like this: + +Ito ang dahilan kung bakit ang mensahe ng kamalian mula noon ay ``pag-merge ng mga sumusunod na commit ay hindi natagpuan'', dahil ito makakagawa *nito*. +Ito ay nakakalito dahil sino ang aasa nito na *subukuan* na gawin ito? + +Kung ito ay makakahanap ng isang katanggap-tanggap na commit ng pag-merge, makikita mo ang katulad nito. [source,console] ---- $ git merge origin/master -warning: Failed to merge submodule DbConnector (not fast-forward) -Found a possible merge resolution for the submodule: - 9fd905e5d7f45a0d4cbc43d1ee550f16a30e825a: > merged our changes -If this is correct simply add it to the index for example -by using: +babala: Bigong nai-merge ang submodule na DbConnector (hindi pinabilis) +Nakatagpo ng isang posibleng resolusyon sa merge para sa submodule: + 9fd905e5d7f45a0d4cbc43d1ee550f16a30e825a: > nai-merge ang ating mga pagbabago +Kung ito ay tama, idagdag lamang ito sa indeks bilang halimbawa +sa pamamagitan ng paggamit ng: + git update-index --cacheinfo 160000 9fd905e5d7f45a0d4cbc43d1ee550f16a30e825a "DbConnector" -which will accept this suggestion. -Auto-merging DbConnector -CONFLICT (submodule): Merge conflict in DbConnector -Automatic merge failed; fix conflicts and then commit the result. +na tatanggap sa mungkahing ito. +Awtomatikong pag-merge sa DbConnector +SALUNGATAN (submodule): Salungatan ng pag-merge sa DbConnector +Nabigo ang awtomatikong pag-merge; ayusin ang mga salungatan at pagkatapos ay i-commit ang resulta. + ---- -What it's suggesting that you do is to update the index like you had run `git add`, which clears the conflict, then commit. You probably shouldn't do this though. You can just as easily go into the submodule directory, see what the difference is, fast-forward to this commit, test it properly, and then commit it. +Ang imininungkahi nito na gawin mo ay i-update ang indeks katulad ng pinatakbo mo ang `git add`, na naglilinis sa salungatan, pagkatapos i-commit.Gayunpaman, hindi mo dapat gawin ito. Maaari kang pumunta sa direktoryo ng submodule, tingnan kung ano ang pagkakaiba, pabilisan sa commit na ito, suriin ito nang maayos, at pagtapos i-commit ito. [source,console] ---- $ cd DbConnector/ $ git merge 9fd905e -Updating eb41d76..9fd905e -Fast-forward +Nag-a-update sa eb41d76..9fd905e +Pinabilis $ cd .. $ git add DbConnector -$ git commit -am 'Fast forwarded to a common submodule child' +$ git commit -am 'Pinabilis sa isang karaniwang submodule child' ---- -This accomplishes the same thing, but at least this way you can verify that it works and you have the code in your submodule directory when you're done. +Ito ay nagsasakatuparan ng parehong bagay, ngunit hindi bababa sa ganitong paraan na maaari mong patunayan na gumagana ito at mayroon kang code sa iyong direktoryo ng submodule kapag tapos ka na. -==== Submodule Tips +==== Mga Tip ng Submodule -There are a few things you can do to make working with submodules a little easier. +May ilang mga bagay na maaaring mong gawin upang gawing mas madali ang pagtatrabaho sa mga aubmodule. ===== Submodule Foreach -There is a `foreach` submodule command to run some arbitrary command in each submodule. -This can be really helpful if you have a number of submodules in the same project. +May utos ng submodule na `foreach` upang magpatakbo ng ilang arbitraryong utos sa bawat submodule. +Ito ay talagang makakatulong kung mayroon kang iilang mga submodule sa parehong proyekto. + +Halimbawa, sabihin natin na nais nating magsimula ng isang bagong tampok o gumawa ng isang bugfix at mayroon tayong ginagawang trabaho sa iilang mga submodule. +Madali nating mai-stash ang lahat ng trabaho sa lahat ng ating mga submodule. -For example, let's say we want to start a new feature or do a bugfix and we have work going on in several submodules. -We can easily stash all the work in all our submodules. [source,console] ---- $ git submodule foreach 'git stash' -Entering 'CryptoLibrary' -No local changes to save -Entering 'DbConnector' -Saved working directory and index state WIP on stable: 82d2ad3 Merge from origin/stable -HEAD is now at 82d2ad3 Merge from origin/stable +Pumapasok sa 'CryptoLibrary' +Walang lokal na pagbabago ang isi-save +Pumapasok sa 'DbConnector' +Naka-save na gumaganang direktoryo at estado ng imdeks na WIP na pirmi: 82d2ad3 Na-merge mula sa origin/stable +Ang HEAD ngayon ay nasa 82d2ad3 Merge mula sa origin/stable ---- -Then we can create a new branch and switch to it in all our submodules. +Pagkatapos ay maaari tayong lumikha ng isang bagong branch at gamitin ito sa lahat ng ating mga submodule. [source,console] ---- $ git submodule foreach 'git checkout -b featureA' -Entering 'CryptoLibrary' -Switched to a new branch 'featureA' -Entering 'DbConnector' -Switched to a new branch 'featureA' +Pumapasok sa 'CryptoLibrary' +Pinalitan sa isang bagong branch na 'featureA' +Pumapasok sa 'DbConnector' +Pinalitan sa isang bagong branch na 'featureA' ---- -You get the idea. -One really useful thing you can do is produce a nice unified diff of what is changed in your main project and all your subprojects as well. +Nakuha mo ang ideya. +Isang bagay na talagang makakatulong na maaari mong gawin ay ang paglikha ng isang magandang pinagsamang diff ng kung ano ang binago sa iyong pangunahing proyekto at pati na rin sa lahat ng iyong mga subproject. + [source,console] ---- $ git diff; git submodule foreach 'git diff' -Submodule DbConnector contains modified content +Submodule DbConnector ay naglalaman ng binagong nilalaman diff --git a/src/main.c b/src/main.c index 210f1ae..1f0acdc 100644 --- a/src/main.c @@ -751,7 +757,7 @@ index 210f1ae..1f0acdc 100644 /* build alias_argv */ alias_argv = xmalloc(sizeof(*alias_argv) * (argc + 1)); alias_argv[0] = alias_string + 1; -Entering 'DbConnector' +Pumapasok sa 'DbConnector' diff --git a/src/db.c b/src/db.c index 1aaefb6..5297645 100644 --- a/src/db.c @@ -770,13 +776,15 @@ index 1aaefb6..5297645 100644 struct strbuf out = STRBUF_INIT; ---- -Here we can see that we're defining a function in a submodule and calling it in the main project. -This is obviously a simplified example, but hopefully it gives you an idea of how this may be useful. +Makikita natin dito na tayo ay nagtutukoy ng isang paggawa sa isang submodule at tumatawag ito sa pangunahing proyekto. +Ito ay halatang isang pinasimpleng halimbawa, ngunit sana ay nagbibigay ito sa iyo ng ideya kung paano ito maaaring kapaki-pakinabang. + + +===== Kapaki-pakinabang na mga Alyas -===== Useful Aliases +Maaaring naisin mo na itakda ang ilang mga alyas para sa ilang mga utos na ito dahil ang mga ito ay mahahaba ng kaunti at hindi mo maaaring itakda ang mga pagpipilian sa pagsasaayos para sa halos lahat ng ito upang gawin silang mga default. +Natalakay natin ang pag-set up ng mga alyas sa <<_git_basics_chapter#_git_aliases>>, ngunit heto ang isang halimbawa sa kung ano ang maaaring naisin mong i-set up kung ikaw ay nagpaplano sa paggawa ng mga submodule sa Git nang maramng beses. -You may want to set up some aliases for some of these commands as they can be quite long and you can't set configuration options for most of them to make them defaults. -We covered setting up Git aliases in <<_git_basics_chapter#_git_aliases>>, but here is an example of what you may want to set up if you plan on working with submodules in Git a lot. [source,console] ---- @@ -785,56 +793,59 @@ $ git config alias.spush 'push --recurse-submodules=on-demand' $ git config alias.supdate 'submodule update --remote --merge' ---- -This way you can simply run `git supdate` when you want to update your submodules, or `git spush` to push with submodule dependency checking. +Sa paraang ito, maaari mo lang patakbuhin ang `git supdate` kapag nais mong i-update ang iyong mga submodule, o `git spush` upang i-push na may pagausuri sa submodule dependency. -==== Issues with Submodules +==== Mga Isyu sa mga Submodule -Using submodules isn’t without hiccups, however. +Gayunpaman, ang paggamit ng submodule ay walang hiccups. + +Halimbawa, ang pagpapalit ng mga branch na may mga submodule sa loob nito ay maaari ring mapanlinlang. +Kung ikaw ay lumikha ng isang bagong branch, idagdag ang isang submodule doon, at pagkatapos ay bumalik sa isang branch nang wala ang submodule na iyon, mayroon ka pang direktoryo ng submodule bilang hindi sinubaybayang direktoryo: -For instance switching branches with submodules in them can also be tricky. -If you create a new branch, add a submodule there, and then switch back to a branch without that submodule, you still have the submodule directory as an untracked directory: [source,console] ---- $ git checkout -b add-crypto -Switched to a new branch 'add-crypto' +Pinalitan sa isang bagong branch na 'add-crypto' $ git submodule add https://github.com/chaconinc/CryptoLibrary -Cloning into 'CryptoLibrary'... +Nagkokopya sa 'CryptoLibrary'... ... -$ git commit -am 'adding crypto library' +$ git commit -am 'nagdaragdag sa crypto library' [add-crypto 4445836] adding crypto library - 2 files changed, 4 insertions(+) - create mode 160000 CryptoLibrary + 2 mga file ang nabago, 4 pagsisingit(+) + nalikha ang mode 160000 CryptoLibrary $ git checkout master -warning: unable to rmdir CryptoLibrary: Directory not empty -Switched to branch 'master' -Your branch is up-to-date with 'origin/master'. +babala: hindi maka-rmdir sa CryptoLibrary: May laman ang direktoryo +Pinalitan sa branch na 'master' +Ang iyong branch ay napanahon sa 'origin/master'. + $ git status -On branch master -Your branch is up-to-date with 'origin/master'. +Sa branch na master +Ang iyong branch ay napapanahon sa 'origin/master'. -Untracked files: - (use "git add ..." to include in what will be committed) +Mga hindi sinubaybayang file: + (gumamit ng "git add ..." upang isama kung ano ang mako-commit) CryptoLibrary/ -nothing added to commit but untracked files present (use "git add" to track) +walang naidagdag sa commit ngunit may hindi sinubaybayang mga file (gumamit ng "git add" upang masubaybayan) ---- -Removing the directory isn't difficult, but it can be a bit confusing to have that in there. -If you do remove it and then switch back to the branch that has that submodule, you will need to run `submodule update --init` to repopulate it. + +Ang pagtatanggal sa direktoryo ay hindi mahirap, ngunit ito ay maaaring nakakalito na gawin ito doon. +Kung nagawa mong tanggalin ito at bumalik sa branch na may submodule na iyon, kinakailangan mong patakbuhin ang `submodule update --init` upang muli itong punan. [source,console] ---- $ git clean -ffdx -Removing CryptoLibrary/ +Nagtatanggal CryptoLibrary/ $ git checkout add-crypto -Switched to branch 'add-crypto' +Pinalitan sa branch na 'add-crypto' $ ls CryptoLibrary/ @@ -845,62 +856,62 @@ $ ls CryptoLibrary/ Makefile includes scripts src ---- -Again, not really very difficult, but it can be a little confusing. +Muli, hindi talaga napakahirap, ngunit ito ay maaaring nakakalito. -The other main caveat that many people run into involves switching from subdirectories to submodules. -If you’ve been tracking files in your project and you want to move them out into a submodule, you must be careful or Git will get angry at you. -Assume that you have files in a subdirectory of your project, and you want to switch it to a submodule. -If you delete the subdirectory and then run `submodule add`, Git yells at you: +Ang ibang pangunahing caveat na pinapatakbo ng karamihan ay kinabibilangan ng pagpapalit mula sa mga subdirectory sa mga submodule. +Kung sinusubaybayan mo ang mga file sa iyong proyekto at nais mong ilipat ang mga ito sa isang submodule, kailangan mong mag-ingat o papagalitan ka ng Git. +Ipagpalagay na mayroon kang mga file sa isang subdirectory ng iyong proyekto, at nais mong ilipat ito sa isang submodule. +Kung tatanggalin mo ang subdirectory at pagkatapos ay patakbuhin ang `submodule add`, sisigawan ka ng Git: [source,console] ---- $ rm -Rf CryptoLibrary/ $ git submodule add https://github.com/chaconinc/CryptoLibrary -'CryptoLibrary' already exists in the index +'CryptoLibrary' ay umiiral na sa index ---- -You have to unstage the `CryptoLibrary` directory first. -Then you can add the submodule: +Kailangan mo munang hindi i-stage ang direktoryo na `CryptoLibrary` directory. +Pagkatapos ay maaari mo ng idagdag ang submodule: [source,console] ---- $ git rm -r CryptoLibrary $ git submodule add https://github.com/chaconinc/CryptoLibrary -Cloning into 'CryptoLibrary'... -remote: Counting objects: 11, done. -remote: Compressing objects: 100% (10/10), done. -remote: Total 11 (delta 0), reused 11 (delta 0) -Unpacking objects: 100% (11/11), done. -Checking connectivity... done. +Nagkokopya sa 'CryptoLibrary'... +remote: Pagbibilang ng mga bagay: 11, tapos na. +remote: Pagko-compress ng mga bagay: 100% (10/10), done. +remote: Kabuuan 11 (delta 0), muling nagamit 11 (delta 0) +Pag-aalis ng laman ng mga bagay: 100% (11/11), tapos na. +Pagsusuri ng pagkakakonekta... tapos na. ---- -Now suppose you did that in a branch. -If you try to switch back to a branch where those files are still in the actual tree rather than a submodule – you get this error: +Ngayon ipagpalagay na ginawa mo iyon sa isang branch. +Kung susubukan mong bumalik sa isang branch kung saan ang mga file ay nasa aktwal na tree sa halip na isang submodule - nakukuha mo ang error na ito: [source,console] ---- $ git checkout master -error: The following untracked working tree files would be overwritten by checkout: +kamalian: Ang mga sumusunod na hindi sinubaybayan na gumaganang tree na mga file ay masasapawan ng checkout: CryptoLibrary/Makefile CryptoLibrary/includes/crypto.h ... -Please move or remove them before you can switch branches. -Aborting +Mangyaring ilipat o tanggalin ang mga ito bago mo mapalitan sa mga branch. +Naghihinto ---- -You can force it to switch with `checkout -f`, but be careful that you don't have unsaved changes in there as they could be overwritten with that command. +Maaari mong palitan ito gamit ang `checkout -f`, ngunit mag-ingat na wala kang hindi naka-save ng mga pagbabago doon dahil ang mga iyon ay masasapawan ng utos na ito. [source,console] ---- $ git checkout -f master -warning: unable to rmdir CryptoLibrary: Directory not empty -Switched to branch 'master' +babala: hindi maka-rmdir CryptoLibrary: May laman ang direktoryo +Pinalitan sa branch na 'master' ---- -Then, when you switch back, you get an empty `CryptoLibrary` directory for some reason and `git submodule update` may not fix it either. -You may need to go into your submodule directory and run a `git checkout .` to get all your files back. -You could run this in a `submodule foreach` script to run it for multiple submodules. +Pagkatapos, kapag bumalik ka, makakakuha ka ng isang walang laman na direktoryo na `CryptoLibrary` para sa ilang kadahilanan at hindi na maaaring maayos ito. +Kinakailangan mong pumunta sa iyong direktoryo ng submodule at patakbuhin ang `git checkout .` upang makuha ang lahat ng iyong mga file pabalik. +Maaari mong patakbuhin ang script na `submodule foreach` upang patakbuhin ito para sa marimihang submodule. -It's important to note that submodules these days keep all their Git data in the top project's `.git` directory, so unlike much older versions of Git, destroying a submodule directory won't lose any commits or branches that you had. +Mahalagang alalahanin na ang mga submodule sa ngayon ay nagpapanatili sa lahat ng datos ng Git sa direktoryo ng pinakamataas na proyekto na `.git`, kaya hindi katulad ng mas lumang mga bersyon ng Git, hindi mawawalan ng anumang commit o mga branch ang pagsisira sa direktoryo ng submodule. -With these tools, submodules can be a fairly simple and effective method for developing on several related but still separate projects simultaneously. +Gamit ang mga kagamitang ito, ang mga submodule ay maaaring maging isang simple at epektibong pamamaraan para sa pagbuo sa ilang kaugnay ngunit maghihiwalay na proyekto nang sabay-sabay.