From: Mohamed Mohey <mmi9433@gmail.com>
To: git@vger.kernel.org
Subject: Question: rerere preimage format
Date: Sat, 16 Dec 2023 17:46:15 +0200 [thread overview]
Message-ID: <CAAY9aimx4X2jDaFz+jWtAj==g+J3QA8LKPQFePyGFhVvbwKNtQ@mail.gmail.com> (raw)
Hi,
I was reading the Rerere section of the Pro Git book when I came
across the following snippet:
$ git rerere diff
--- a/hello.rb
+++ b/hello.rb
@@ -1,11 +1,11 @@
#! /usr/bin/env ruby
def hello
-<<<<<<<
- puts 'hello mundo'
-=======
+<<<<<<< HEAD
puts 'hola world'
->>>>>>>
+=======
+ puts 'hello mundo'
+>>>>>>> i18n-world
end
If I understand correctly, this is the diff between rerere's preimage
and the version in the current working directory, as explained in this
StackOverflow answer:
https://stackoverflow.com/a/27364585
What I don't understand, however, is why rerere records its initial
preimage without labels. This seems to have been rerere's behavior
ever since it was introduced as a perl script back in 2006:
https://lore.kernel.org/git/7v4q3no0v7.fsf@assigned-by-dhcp.cox.net/
+ $one = join('', @{$side[0]});
+ $two = join('', @{$side[1]});
+ if ($two le $one) {
+ ($one, $two) = ($two, $one);
+ }
+ print $out "<<<<<<<\n";
+ print $out $one;
+ print $out "=======\n";
+ print $out $two;
+ print $out ">>>>>>>\n";
+ @side = ();
So the preimage format doesn't contain any labels, and outputs the
lexicographically smaller hunk first,
while the default merge conflict output has labels and outputs the
current branch first followed by the other branch.
If rerere recorded its preimage in the same format as the default
merge conflict format,
the above rerere diff output would be empty as there would be no
difference between what we started with and what we resolved into.
The same behaviour would still occur with the diff3 style format, for
example, but at least it wouldn't occur with the default merge style
format.
My question is:
Is there a reason rerere's output is like this that I'm missing? Or is
it just there for convenience since it doesn't affect rerere's
intended functionality?
Thanks,
Mohamed Mohey
next reply other threads:[~2023-12-16 15:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-16 15:46 Mohamed Mohey [this message]
2023-12-16 17:34 ` Question: rerere preimage format Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAY9aimx4X2jDaFz+jWtAj==g+J3QA8LKPQFePyGFhVvbwKNtQ@mail.gmail.com' \
--to=mmi9433@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).