git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3 3/3] correct ce_compare_data() in a middle of a merge
Date: Fri, 01 Jul 2016 15:11:42 -0700	[thread overview]
Message-ID: <xmqq8txlvwip.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <62eb3d75-126e-427b-8701-d490e80e3501@web.de> ("Torsten Bögershausen"'s message of "Thu, 30 Jun 2016 18:52:20 +0200")

Torsten Bögershausen <tboegi@web.de> writes:

>> The checkout process hopefully does not blindly turn LF into CRLF,
>> making it "first line \r\r\nsame line\r\rn".  Instead the (virtual)
>> working tree file will have "first line\r\nsame line\r\n".
> Yes
>> 
>> Then "git add" should turn that CRLF into LF, which would give us
>> "first line\nsame line\n", but because the "safer autocrlf" rule
>> prevents it from happening.  The (real) index already has CR in it
>> in the blob in stage #2, so the check-in process would (this is not
>> describing the ideal, but what is done by today's code) disable
>> CRLF->LF conversion.
>> 
>> Is that the problem you are trying to solve?
> Not sure, if that problem isn't already solved.

OK, so in short, renormalizing three blobs in the conflicted index
is done correcte because you do not allow safer-crlf kicks in during
the renormalization?

So how does ce_compare_data() judge "first line\r\nsame line\r\n"
in stage #2 and working tree (both with CRLF) not to match?  The
CRLF in working tree data, when run convert_to_git(), will be kept
as CRLF because of safer-crlf rule, and would match, no?  Or do you
disable safer-crlf for that case, too?

> This is my understanding:
> - git checkout and git add are working as expected:
>   LF in blob gives CRLF in the working tree at checkout (if attr says "auto")
>   CRLF in blob gives CRLF in the working tree at checkout.

OK.
>   CRLF in the working tree gives CRLF in the blob at "git add", when
>   the new safer CRLF handling says so.

OK.

> - Merges
>  First the working tree is checked, if it is clean.
>  I haven't digged deep enough to follow the whole code path,
>  but that is what ce_compare_data() does, and it fails in a merge.

OK, I misunderstood what you are trying to fix.  I somehow thought
that you wanted to tweak the renormalization of three blobs.

>  Next thing is that the blobs are merged, and when a blob with CRLF
>  is merged with a blob with LF, there are only conflicts :-(
>  (Remember that both may have CRLF in the worktree)
>  And here renormalize_buffer() comes in (only when "merge.renormalize" is true):
>  - convert the blob with convert_to_working_tree_internal() into the working
>     tree format (but do it in memory), and back to the "blob":
>  - convert_to_git(path, src, len, dst, SAFE_CRLF_RENORMALIZE, NULL);
>
>  Note the the "new safer autocrlf" is suppressed here, because of SAFE_CRLF_RENORMALIZE.

That makes sense.

> - check for a clean worktree in ce_compare_data() # fails -> this is the problem to be solved

But it is unclear to me how that need an extra "no, do not look at
the indexed blob, but look at this blob instead"?

The relevant part is this:

diff --git a/read-cache.c b/read-cache.c
index a3ef967..c109b6d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -163,7 +163,9 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
 
 	if (fd >= 0) {
 		unsigned char sha1[20];
-		if (!index_fd(sha1, fd, st, OBJ_BLOB, ce->name, 0))
+		unsigned flags = HASH_USE_SHA_NOT_PATH;
+		memcpy(sha1, ce->sha1, sizeof(sha1));
+		if (!index_fd(sha1, fd, st, OBJ_BLOB, ce->name, flags))
 			match = hashcmp(sha1, ce->sha1);
 		/* index_fd() closed the file descriptor already */
 	}

I do not quite see how "Don't use ce->sha1, but use sha1 given to
you" flag affects this call, when sha1 and ce->sha1 are the same due
to memcpy() just before the call?


  reply	other threads:[~2016-07-01 22:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 23:21 What's cooking in git.git (Jun 2016, #09; Mon, 27) Junio C Hamano
2016-06-28  8:01 ` [PATCH v3 0/3] unified auto CRLF handling, V3 tboegi
2016-06-28  8:01 ` [PATCH v3 1/3] convert: unify the "auto" handling of CRLF tboegi
2016-06-28  8:01 ` [PATCH v3 2/3] read-cache: factor out get_sha1_from_index() helper tboegi
2016-06-28  8:01 ` [PATCH v3 3/3] correct ce_compare_data() in a middle of a merge tboegi
2016-06-29 16:14   ` Junio C Hamano
2016-06-30 16:52     ` Torsten Bögershausen
2016-07-01 22:11       ` Junio C Hamano [this message]
2016-07-02 18:41         ` Torsten Bögershausen
2016-07-06 14:57           ` Junio C Hamano
2016-07-07 17:16             ` Torsten Bögershausen
2016-07-07 18:43               ` Junio C Hamano
2016-07-07 22:19                 ` Junio C Hamano
2016-07-08  7:52                 ` Torsten Bögershausen
2016-07-08 16:36                   ` Junio C Hamano
2016-07-08 17:13                     ` Torsten Bögershausen
2016-07-08 17:25                       ` Junio C Hamano
2016-07-08 17:59                         ` Junio C Hamano
2016-07-08 19:01                       ` Junio C Hamano
2016-07-08 20:50                         ` Junio C Hamano
2016-07-11 20:07                           ` Junio C Hamano
2016-07-12  2:23                             ` Torsten Bögershausen
2016-07-12 19:54                               ` Junio C Hamano
2016-07-08 15:00                 ` Torsten Bögershausen

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8txlvwip.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).