git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jaime Soriano Pastor <jsorianopastor@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] read-cache.c: Ensure unmerged entries are removed
Date: Fri, 15 Aug 2014 21:50:11 +0200	[thread overview]
Message-ID: <CAPuZ2NFJiUt1p_OfefswS8O8_BA6mQy=PStmYyNw=ABZCOQprQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqiolw2dqc.fsf@gitster.dls.corp.google.com>

On Thu, Aug 14, 2014 at 1:04 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Being a conservative, I'd rather avoid doing any magic during
> read_cache() time. "ls-files -s" for example should show the four
> stages so that the "broken" state can be inspected.
>
Well, only read_cache_unmerged() is modified in the sent patch, so no
magic is done in read_cache(), I'd also avoid changes there. Indeed
with the patch, "ls-files -s" can be used to inspect the problem
without further problems.

> Instead, I suspect that the code paths with problematic iterations
> over the index entries that assume that having stage #0 entry for a
> path guarantees that there will not be any higher stage entry first
> need to be identified (you already said "add" and "reset" may be
> problematic, there may be others, or they may be the only ones, I
> dunno), and then the most sensible one, which would be different
> from case to case, among various possibilities need to be chosen as
> a fix to each of them:
>
> (1) the loop may be fixed to ignore/skip unmerged entries;
> (2) the loop may be fixed to ignore/skip the merged entry;
> (3) the loop may be fixed not to spin indefinitely on a path with
> mixed entries; or
> (4) the command should error out.
>
git reset will clean the index anyway if the loop finishes, would it
be ok? I think that it'd be acceptable for git reset --hard to clean
the index as git checkout -f already does it even in this case.

git merge is also affected by the loop in read_cache_unmerged(), but
any of the solutions would be enough for it as only by finishing the
loop with unmerged entries it will die without commiting the cache to
the index file.

For git add probably the best option is to error out and ask the user
to check "git ls-files -s" to investigate the problem and decide what
to do.

The error message given by "git commit -a" is a bit confusing in this
case, I can take a look to this too.

I'll try to prepare a patch with these cases, and rethinking the loop
to avoid future problems there, I think that is a bit dangerous to
look for the position of a path entry (with index_name_pos) for the
next iteration.

> Yes, it would be more work, but I'd feel safer if the following
> worked:
>
> $ git ls-files -s
> 100644 3cc58df83752123644fef39faab2393af643b1d2 0 conflict
> 100644 f70f10e4db19068f79bc43844b49f3eece45c4e8 1 conflict
> 100644 3cc58df83752123644fef39faab2393af643b1d2 2 conflict
> 100644 223b7836fb19fdf64ba2d3cd6173c6a283141f78 3 conflict
> $ >empty
> $ git add empty
> 100644 3cc58df83752123644fef39faab2393af643b1d2 0 conflict
> 100644 f70f10e4db19068f79bc43844b49f3eece45c4e8 1 conflict
> 100644 3cc58df83752123644fef39faab2393af643b1d2 2 conflict
> 100644 223b7836fb19fdf64ba2d3cd6173c6a283141f78 3 conflict
> 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 empty
> $ git cat-file blob :empty >output
> $ cmp empty output && echo OK
> OK
>
> which would be impossible to do if we nuked the "problematic" stages
> whenever we read the index, I am afraid.
>
This works with the first patch as read_cache() is not modified, and
git add would only clean the entries for the paths passed as
arguments.

>> BTW, I didn't know "git cat-file blob 0:$path", but I only manage to
>> get "Not a valid object name" fatals. How is it supposed to be used?
>
> That was a typo of ":$n:$path" (where 0 <= $n <= 3).
Great, thanks!

  reply	other threads:[~2014-08-15 19:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12 15:31 [PATCH] read-cache.c: Ensure unmerged entries are removed Jaime Soriano Pastor
2014-08-12 15:31 ` Jaime Soriano Pastor
2014-08-12 18:39   ` Junio C Hamano
2014-08-13 22:10     ` Jaime Soriano Pastor
2014-08-13 23:04       ` Junio C Hamano
2014-08-15 19:50         ` Jaime Soriano Pastor [this message]
2014-08-15 21:45           ` Junio C Hamano
2014-08-16 14:51             ` Jaime Soriano Pastor
2014-08-18 16:34               ` Junio C Hamano
2014-08-18 17:23                 ` Jaime Soriano Pastor
2014-08-20 11:25                   ` [PATCH 0/4] Handling unmerged files with merged entries Jaime Soriano Pastor
2014-08-20 11:26                     ` [PATCH 1/4] read_index_unmerged doesn't loop forever if merged stage exists for unmerged file Jaime Soriano Pastor
2014-08-20 11:26                     ` [PATCH 2/4] Error out when adding a file with merged and unmerged entries Jaime Soriano Pastor
2014-08-20 11:26                     ` [PATCH 3/4] Added tests for the case of merged and unmerged entries for the same file Jaime Soriano Pastor
2014-08-20 21:00                       ` Junio C Hamano
2014-08-21 13:51                         ` Jaime Soriano Pastor
2014-08-21 22:21                           ` Junio C Hamano
2014-08-20 11:26                     ` [PATCH 4/4] git update-index --cacheinfo can be used to select a stage when there are merged and unmerged entries Jaime Soriano Pastor
2014-08-20 21:08                       ` Junio C Hamano
2014-08-21 13:57                         ` Jaime Soriano Pastor
2014-08-20 22:19                     ` [PATCH 0/4] Handling unmerged files with merged entries Junio C Hamano
2014-08-21 13:42                       ` Jaime Soriano Pastor
2014-08-21 13:43                         ` [PATCH] Check order when reading index Jaime Soriano Pastor
2014-08-21 13:49                           ` Jaime Soriano Pastor
2014-08-21 13:59                           ` Duy Nguyen
2014-08-21 18:51                           ` Junio C Hamano
2014-08-24 17:57                             ` [PATCH 1/2] " Jaime Soriano Pastor
2014-08-24 17:57                               ` [PATCH 2/2] Loop index increases monotonically when reading unmerged entries Jaime Soriano Pastor
2014-08-24 18:04                                 ` Jaime Soriano Pastor
2014-08-25 17:09                                   ` Junio C Hamano
2014-08-25 17:21                               ` [PATCH 1/2] Check order when reading index Junio C Hamano
2014-08-25 19:44                                 ` Jeff King
2014-08-25 20:52                                   ` Junio C Hamano
2014-08-26 12:08                                     ` Jaime Soriano Pastor
2014-08-26 12:20                                       ` Jeff King
2014-08-26 16:53                                         ` Junio C Hamano
2014-08-26 17:22                                           ` Jaime Soriano Pastor
2014-08-26 17:43                                             ` Junio C Hamano
2014-08-27 19:48                                               ` [PATCH 1/2] read_index_from(): catch out of order entries when reading an index file Jaime Soriano Pastor
2014-08-27 19:48                                                 ` [PATCH 2/2] read_index_unmerged(): remove unnecessary loop index adjustment Jaime Soriano Pastor
2014-08-29  2:16                                                 ` [PATCH 1/2] read_index_from(): catch out of order entries when reading an index file Eric Sunshine
2014-08-29  8:54                                                   ` [PATCH] " Jaime Soriano Pastor
2014-08-29 17:06                                                     ` Junio C Hamano
2014-08-27 19:52                                               ` [PATCH 1/2] Check order when reading index Jaime Soriano Pastor
2014-08-27 21:11                                                 ` Junio C Hamano
2014-08-27 22:13                                                   ` Jaime Soriano Pastor
2014-08-25 20:26                                 ` Jaime Soriano Pastor
2014-08-21 18:40                       ` [PATCH 0/4] Handling unmerged files with merged entries Johannes Sixt
2014-08-21 22:18                         ` Junio C Hamano
2014-08-12 18:31 ` [PATCH] read-cache.c: Ensure unmerged entries are removed Junio C Hamano
2014-08-13 22:10   ` Jaime Soriano Pastor

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='CAPuZ2NFJiUt1p_OfefswS8O8_BA6mQy=PStmYyNw=ABZCOQprQ@mail.gmail.com' \
    --to=jsorianopastor@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).