{"thread":{"id":"60621","subject":"Question: rerere preimage format","startedAt":"2023-12-16T15:46:27Z","lastAt":"2023-12-16T17:34:30Z","messageCount":2,"participants":["Mohamed Mohey","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"485749","messageId":"CAAY9aimx4X2jDaFz+jWtAj==g+J3QA8LKPQFePyGFhVvbwKNtQ@mail.gmail.com","threadId":"60621","inReplyTo":null,"subject":"Question: rerere preimage format","fromName":"Mohamed Mohey","fromEmail":"mmi9433@gmail.com","sentAt":"2023-12-16T15:46:15Z","receivedAt":"2023-12-16T15:46:27Z","isPatch":false,"sender":{"key":"mmi9433@gmail.com","avatar":null},"body":"Hi,\n\nI was reading the Rerere section of the Pro Git book when I came\nacross the following snippet:\n\n$ git rerere diff\n--- a/hello.rb\n+++ b/hello.rb\n@@ -1,11 +1,11 @@\n #! /usr/bin/env ruby\n def hello\n-<<<<<<<\n-  puts 'hello mundo'\n-=======\n+<<<<<<< HEAD\n   puts 'hola world'\n->>>>>>>\n+=======\n+  puts 'hello mundo'\n+>>>>>>> i18n-world\n end\n\nIf I understand correctly, this is the diff between rerere's preimage\nand the version in the current working directory, as explained in this\nStackOverflow answer:\n\nhttps://stackoverflow.com/a/27364585\n\n\nWhat I don't understand, however, is why rerere records its initial\npreimage without labels. This seems to have been rerere's behavior\never since it was introduced as a perl script back in 2006:\n\nhttps://lore.kernel.org/git/7v4q3no0v7.fsf@assigned-by-dhcp.cox.net/\n\n+ $one = join('', @{$side[0]});\n+ $two = join('', @{$side[1]});\n+ if ($two le $one) {\n+ ($one, $two) = ($two, $one);\n+ }\n+ print $out \"<<<<<<<\\n\";\n+ print $out $one;\n+ print $out \"=======\\n\";\n+ print $out $two;\n+ print $out \">>>>>>>\\n\";\n+ @side = ();\n\n\nSo the preimage format doesn't contain any labels, and outputs the\nlexicographically smaller hunk first,\nwhile the default merge conflict output has labels and outputs the\ncurrent branch first followed by the other branch.\n\nIf rerere recorded its preimage in the same format as the default\nmerge conflict format,\nthe above rerere diff output would be empty as there would be no\ndifference between what we started with and what we resolved into.\n\nThe same behaviour would still occur with the diff3 style format, for\nexample, but at least it wouldn't occur with the default merge style\nformat.\n\nMy question is:\n\nIs there a reason rerere's output is like this that I'm missing? Or is\nit just there for convenience since it doesn't affect rerere's\nintended functionality?\n\n\nThanks,\nMohamed Mohey\n"},{"id":"485750","messageId":"xmqq34w2jbky.fsf@gitster.g","threadId":"60621","inReplyTo":"CAAY9aimx4X2jDaFz+jWtAj==g+J3QA8LKPQFePyGFhVvbwKNtQ@mail.gmail.com","subject":"Re: Question: rerere preimage format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-16T17:34:21Z","receivedAt":"2023-12-16T17:34:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mohamed Mohey <mmi9433@gmail.com> writes:\n\n> My question is:\n>\n> Is there a reason rerere's output is like this that I'm missing? Or is\n> it just there for convenience since it doesn't affect rerere's\n> intended functionality?\n>\n>\n> Thanks,\n> Mohamed Mohey\n\nDocumentation/technical/rerere.txt would be a good place to start.\n\n"}]}