{"thread":{"id":"59185","subject":"Hash for a commit sourcetree beside to a commit hash","startedAt":"2023-02-03T01:28:05Z","lastAt":"2023-02-26T09:35:43Z","messageCount":11,"participants":["Andry","Đoàn Trần Công Danh","Philip Oakley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"471413","messageId":"1798489336.20230203042837@inbox.ru","threadId":"59185","inReplyTo":null,"subject":"Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-03T01:28:37Z","receivedAt":"2023-02-03T01:28:05Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Git,\n\nIs there a chance to add this property to a commit and a set of commands, for example, to search a commit by a sourcetree hash?\n\nSometimes a forked branch has edits which does chance commit hashes without changing the sourcetree, like user mail rewrite or commits remove or just a commit random property change. This leads to rewriting the rest commits in a branch or tree.\n\nThis feature will be useful to search in all commits including rewritten.\n\nOf cause in case of rebase it won't work if is happened at least one merge with the interference with other commits in a commit chain. But if not, then it might help to search commits even after automatic rebase.\n\n"},{"id":"471414","messageId":"Y9xq5VAMjzUqTb6X@danh.dev","threadId":"59185","inReplyTo":"1798489336.20230203042837@inbox.ru","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2023-02-03T02:01:09Z","receivedAt":"2023-02-03T02:01:18Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2023-02-03 04:28:37+0300, Andry <andry@inbox.ru> wrote:\n> Hello Git,\n> \n> Is there a chance to add this property to a commit and a set of\n> commands,\n\nDoes `git rev-parse commit^{tree}` works for you? E.g.\n\n\tgit rev-parse HEAD^{tree}\n\n> for example, to search a commit by a sourcetree hash?\n\nI'm not sure if I understand your question correctly, but does this\nwork?\n\n\tgit rev-list <a-commit-tish> |\n\twhile read commit; do\n\t\tif test $(git rev-parse $commit^{tree}) = $hash; then\n\t\t\techo $commit\n\t\t\tbreak\n\t\tfi\n\tdone\n\n> Sometimes a forked branch has edits which does chance commit hashes\n> without changing the sourcetree, like user mail rewrite or commits\n> remove or just a commit random property change. This leads to\n> rewriting the rest commits in a branch or tree.\n> \n> This feature will be useful to search in all commits including\n> rewritten.\n> \n> Of cause in case of rebase it won't work if is happened at least one\n> merge with the interference with other commits in a commit chain.\n> But if not, then it might help to search commits even after\n> automatic rebase.\n> \n\n-- \nDanh\n"},{"id":"471415","messageId":"563617028.20230203052145@inbox.ru","threadId":"59185","inReplyTo":"Y9xq5VAMjzUqTb6X@danh.dev","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-03T02:21:45Z","receivedAt":"2023-02-03T03:02:14Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Đoàn,\n\n\n\nFriday, February 3, 2023, 5:01:09 AM, you wrote:\n\nĐTCD> On 2023-02-03 04:28:37+0300, Andry <andry@inbox.ru> wrote:\n>> Hello Git,\n>> \n>> Is there a chance to add this property to a commit and a set of\n>> commands,\n\nĐTCD> Does `git rev-parse commit^{tree}` works for you? E.g.\nĐTCD>         git rev-parse HEAD^{tree}\n\nIf the `^{tree}` does calculate a commit internal sourcetree hash without other commits, then yes.\nIf it does rely on other commits and accumulates the sourcetree over the chain of commits, then it does not calculate the hash by the difference and can not be applied as I have described.\n\n>> for example, to search a commit by a sourcetree hash?\n\nĐTCD> I'm not sure if I understand your question correctly, but does this\nĐTCD> work?\n\nĐTCD>         git rev-list <a-commit-tish> |\nĐTCD>         while read commit; do\nĐTCD>                 if test $(git rev-parse $commit^{tree}) = $hash; then\nĐTCD>                         echo $commit\nĐTCD>                         break\nĐTCD>                 fi\nĐTCD>         done\n\nNice, but I can not apply this over a git hub or a web interface without a clone.\n\n"},{"id":"471419","messageId":"22255406-42da-9ac3-4783-11a035877a3c@iee.email","threadId":"59185","inReplyTo":"563617028.20230203052145@inbox.ru","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2023-02-03T11:11:19Z","receivedAt":"2023-02-03T11:11:25Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 03/02/2023 02:21, Andry wrote:\n> Đoàn, \n> Friday, February 3, 2023, 5:01:09 AM, you wrote:\n> ĐTCD>         git rev-list <a-commit-tish> |\n> ĐTCD>         while read commit; do\n> ĐTCD>                 if test $(git rev-parse $commit^{tree}) = $hash; then\n> ĐTCD>                         echo $commit\n> ĐTCD>                         break\n> ĐTCD>                 fi\n> ĐTCD>         done\n>\n> Nice, but I can not apply this over a git hub or a web interface without a clone.\n\nAs a 'Distributed'-VCS, cloning the repository would be the de-facto\nnormal approach, otherwise you have re-invented centralised VCS ;-)\n\nAlternatively, you could approach the server (hub/web interface)\nprovider to see if they are willing to provide that level of search\ninterface.\n\nThat said, having extra search capability within rev-list to search for\nblobs and tree would/could be useful in specialised scenarios, though\nthat is becoming rather niche.\n--\nPhilip\n"},{"id":"471429","messageId":"1309893232.20230203163720@inbox.ru","threadId":"59185","inReplyTo":"22255406-42da-9ac3-4783-11a035877a3c@iee.email","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-03T13:37:20Z","receivedAt":"2023-02-03T13:37:02Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Philip,\n\n\n\nFriday, February 3, 2023, 2:11:19 PM, you wrote:\n\nPO> On 03/02/2023 02:21, Andry wrote:\n>> Đoàn, \n>> Friday, February 3, 2023, 5:01:09 AM, you wrote:\n>> ĐTCD>         git rev-list <a-commit-tish> |\n>> ĐTCD>         while read commit; do\n>> ĐTCD>                 if test $(git rev-parse $commit^{tree}) = $hash; then\n>> ĐTCD>                         echo $commit\n>> ĐTCD>                         break\n>> ĐTCD>                 fi\n>> ĐTCD>         done\n>>\n>> Nice, but I can not apply this over a git hub or a web interface without a clone.\n\nPO> As a 'Distributed'-VCS, cloning the repository would be the de-facto\nPO> normal approach, otherwise you have re-invented centralised VCS ;-)\n\nCloning repository is a heavy operation by downloading everything instead of search a single commit.\nAnd searching at the remote does not make it a central.\n\nPO> Alternatively, you could approach the server (hub/web interface)\nPO> provider to see if they are willing to provide that level of search\nPO> interface.\n\nThe GitHub already provides that in the search field. Just input a hash and see what happens.\n\n"},{"id":"471434","messageId":"Y90lBJ8b5nCUcLv2@danh.dev","threadId":"59185","inReplyTo":"1309893232.20230203163720@inbox.ru","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2023-02-03T15:15:16Z","receivedAt":"2023-02-03T15:19:03Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2023-02-03 16:37:20+0300, Andry <andry@inbox.ru> wrote:\n> Hello Philip,\n> >> Nice, but I can not apply this over a git hub or a web interface without a clone.\n> \n> PO> As a 'Distributed'-VCS, cloning the repository would be the de-facto\n> PO> normal approach, otherwise you have re-invented centralised VCS ;-)\n> \n> Cloning repository is a heavy operation by downloading everything\n> instead of search a single commit.\n\nYou can limit the download with \"git clone --filter=tree:0\"\nwhich only fetch the commit but not any tree or file contents.\n\n-- \nDanh\n"},{"id":"471465","messageId":"01dd49c1-026d-1215-dd06-02fe73ce14f8@iee.email","threadId":"59185","inReplyTo":"1309893232.20230203163720@inbox.ru","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2023-02-03T22:39:31Z","receivedAt":"2023-02-03T22:39:37Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 03/02/2023 13:37, Andry wrote:\n> Hello Philip,\n>\n>\n>\n> Friday, February 3, 2023, 2:11:19 PM, you wrote:\n>\n> PO> On 03/02/2023 02:21, Andry wrote:\n>>> Đoàn, \n>>> Friday, February 3, 2023, 5:01:09 AM, you wrote:\n>>> ĐTCD>         git rev-list <a-commit-tish> |\n>>> ĐTCD>         while read commit; do\n>>> ĐTCD>                 if test $(git rev-parse $commit^{tree}) = $hash; then\n>>> ĐTCD>                         echo $commit\n>>> ĐTCD>                         break\n>>> ĐTCD>                 fi\n>>> ĐTCD>         done\n>>>\n>>> Nice, but I can not apply this over a git hub or a web interface without a clone.\n> PO> As a 'Distributed'-VCS, cloning the repository would be the de-facto\n> PO> normal approach, otherwise you have re-invented centralised VCS ;-)\n>\n> Cloning repository is a heavy operation by downloading everything instead of search a single commit.\n> And searching at the remote does not make it a central.\n\nIt's not local though ;-)\n\nGiven that there's usually a trusted remote in this scenario (that's why\nyour searching it) it does feel very like a 'centralised' VCS, even if\nformally is isn't stated as such.\n>\n> PO> Alternatively, you could approach the server (hub/web interface)\n> PO> provider to see if they are willing to provide that level of search\n> PO> interface.\n>\n> The GitHub already provides that in the search field. Just input a hash and see what happens.\n\nThere is still a need to walk the commit graph to discover each commit's\ntree to do the look-back. There are some catch 22 steps to be done.\n\nHow do you determine the sourcetree has that starts this process? (have\nwe accidentally created an XY problem?)\n\nObliterating history is hard [1].\n--\nPhilip\n\n[1]\nhttps://lore.kernel.org/git/5cab1530-f8b6-cef3-7b93-48fad410a160@iee.email/\n"},{"id":"471472","messageId":"1196589662.20230204075023@inbox.ru","threadId":"59185","inReplyTo":"Y90lBJ8b5nCUcLv2@danh.dev","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-04T04:50:23Z","receivedAt":"2023-02-04T04:50:24Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Đoàn,\n\n\n\nFriday, February 3, 2023, 6:15:16 PM, you wrote:\n\nĐTCD> On 2023-02-03 16:37:20+0300, Andry <andry@inbox.ru> wrote:\n>> Hello Philip,\n>> >> Nice, but I can not apply this over a git hub or a web interface without a clone.\n>> \n>> PO> As a 'Distributed'-VCS, cloning the repository would be the de-facto\n>> PO> normal approach, otherwise you have re-invented centralised VCS ;-)\n>> \n>> Cloning repository is a heavy operation by downloading everything\n>> instead of search a single commit.\n\nĐTCD> You can limit the download with \"git clone --filter=tree:0\"\nĐTCD> which only fetch the commit but not any tree or file contents.\n\nAnd what next? You still need to download something to see.\nBetter to start search in the remote anyway, because, for example, it is someone's else repository you don't want to download at all until you find something.\nThis is how it works in first place - you search something to start download, instead of to download at first to search something.\n\n"},{"id":"471510","messageId":"1185159444.20230205044106@inbox.ru","threadId":"59185","inReplyTo":"01dd49c1-026d-1215-dd06-02fe73ce14f8@iee.email","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-05T01:41:06Z","receivedAt":"2023-02-05T01:41:03Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Philip,\n\n\n\nSaturday, February 4, 2023, 1:39:31 AM, you wrote:\n\n>> PO> As a 'Distributed'-VCS, cloning the repository would be the de-facto\n>> PO> normal approach, otherwise you have re-invented centralised VCS ;-)\n>>\n>> Cloning repository is a heavy operation by downloading everything instead of search a single commit.\n>> And searching at the remote does not make it a central.\n\nPO> It's not local though ;-)\nPO> Given that there's usually a trusted remote in this scenario (that's why\nPO> your searching it)\n\nI am searching it because it is a fork of many other forks.\n\nPO> it does feel very like a 'centralised' VCS, even if\nPO> formally is isn't stated as such.\n\nIt feels not. I don't see how this is connected to anything.\n\n>>\n>> PO> Alternatively, you could approach the server (hub/web interface)\n>> PO> provider to see if they are willing to provide that level of search\n>> PO> interface.\n>>\n>> The GitHub already provides that in the search field. Just input a hash and see what happens.\n\nPO> There is still a need to walk the commit graph to discover each commit's\nPO> tree to do the look-back. There are some catch 22 steps to be done.\n\nCalculate a hash from an ordered sourcetree diff is not 22 steps.\n\nPO> How do you determine the sourcetree has that starts this process? (have\nPO> we accidentally created an XY problem?)\n\nPO> Obliterating history is hard [1].\nPO> --\nPO> Philip\n\nPO> [1]\nPO> https://lore.kernel.org/git/5cab1530-f8b6-cef3-7b93-48fad410a160@iee.email/\n\nHow this related to the issue?\n\n"},{"id":"471992","messageId":"7910309440.20230212162759@inbox.ru","threadId":"59185","inReplyTo":"1798489336.20230203042837@inbox.ru","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-12T13:27:59Z","receivedAt":"2023-02-12T13:27:33Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Git,\n\n\n\nFriday, February 3, 2023, 4:28:37 AM, you wrote:\n\nA> Hello Git,\n\nA> Is there a chance to add this property to a commit and a set of commands, for example, to search a commit by a sourcetree hash?\n\nI've suddenly found another interesting ability of such hash. It could may restore a commit submodule add/update reference hashes to submodule commits after submodule repo rewrite.\n\nLets say you have 2 repositories.\n\n```\n[Repo A] of Owner A\n\n  ...\n  |\n  Commit A1\n  | |\n  | +-- submodule add/update hash B1\n  |\n  Commit A2\n  | |\n  | +-- submodule add/update hash B2\n  |\n  ...\n\n[Repo B] of Owner B (submodule to A)\n\n  ...\n  |\n  Commit B1\n  |\n  Commit B2\n  |\n  ...\n```\n\nIf owner of [Repo B] would try to rewrite repository because, for example, of a mistake in the commit author email address,\nthen [Repo A] becomes broken and will reference invalid hashes.\nHard to rewrite hashes in [Repo A] because of unrelated histories and tricky algorithm with the hash mappings.\n\nBut if add a second hash into a commit property as hash of an ordered sourcetree diff, then\nwe can automatically map such hashes even in unrelated histories.\nBecause basically a commit hash changes because of change in a commit properties instead of in the source tree.\nAnd even a change in source may not lead to trigger changes in following commits because depends on the context and\nthe sources intersection (including source movement).\n\nSo the git could suggest with these hashes a semi automatic merge even if a repo was rewriten.\nOf cause this needs additionally to detect changes in all properties to show to the user before semi automatic merge.\n\nIn case of [Repo A] it just needs to add second hash into [repo A] submodule add/update and now you can rewrite [Repo A]\nthrough the mapping by ordered sourcetree diff hash.\n\n"},{"id":"472743","messageId":"93307185.20230226123730@inbox.ru","threadId":"59185","inReplyTo":"1798489336.20230203042837@inbox.ru","subject":"Re: Hash for a commit sourcetree beside to a commit hash","fromName":"Andry","fromEmail":"andry@inbox.ru","sentAt":"2023-02-26T09:37:30Z","receivedAt":"2023-02-26T09:35:43Z","isPatch":false,"sender":{"key":"andry@inbox.ru","avatar":null},"body":"Hello Git,\n\n\n\nFriday, February 3, 2023, 4:28:37 AM, you wrote:\n\nA> Is there a chance to add this property to a commit and a set of commands, for example, to search a commit by a sourcetree hash?\n\nAnd another interesting ability of such hash. It could optimize upload/download of objects, for example, after commits rewrite when non sourcetree change happens.\nFor example, user email and name is changed. Currently git retransfers all objects to the remote repository on the push. In case of new hash there is won't be a need to retransfer the sourcetree if it didn't change.\n\n"}]}