All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Organov <sorganov@gmail.com>
To: Elijah Newren <newren@gmail.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Tiran Meltser <Tiran.Meltser@mavenir.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	Amir Yosef <Amir.Yosef@mavenir.com>
Subject: Re: Request for adding a simple mechanism to exclude files from Git merge operation
Date: Wed, 24 Jun 2020 22:15:42 +0300	[thread overview]
Message-ID: <87ftak1di9.fsf@osv.gnss.ru> (raw)
In-Reply-To: <CABPp-BFwNnD-zZvHjCAvvmzy1wTT3yy-smK5nCtQ937apaNmkQ@mail.gmail.com> (Elijah Newren's message of "Tue, 23 Jun 2020 14:46:22 -0700")

Hi Elijah,

Elijah Newren <newren@gmail.com> writes:

> Hi Sergey,
>
> On Tue, Jun 23, 2020 at 1:19 PM Sergey Organov <sorganov@gmail.com> wrote:

[...]

>> I don't see how rebases are affected. I only suggested enhancements to
>> the merge-the-procedure, the "git merge" user command. Once merge is
>> finished and result is committed, there is (fortunately) now way for git
>> to know how exactly the resulting content has been achieved.
>
> Sorry, the original email from Tiran wanted to be able to record
> "branch-specific" files and have merge automatically handle them
> differently.  You also alluded to that when you said
>
> """
> As a
> more generic solution, a new syntax for "git merge" to specify what
> merge strategy to apply to what files could be designed, and then
> ability to put that syntax into a file for "git merge" to pick would
> solve the problem of quasi-static configuration problem. Alternatively,
> even more generic .gitignore way of doing things apparently could be
> re-used to some degree by adding support for .gitmerge files.
> """
>
> Once you record the information for which files it applies to, then
> you want it to happen whenever the merge machinery fires, right?

No. I didn't mean it, no way. I wanted only "git merge" to be affected.

> Rebasing, cherry-picking, and reverting are all created via the merge
> machinery (even if they end up recording one parent instead of more).
> Said another way, if merge automatically handles these special files,
> either rebase/cherry-pick/revert also handle the special files
> automatically or you've just created a very inconsistent and weird
> design.

I disagree. The fact that all of the mentioned commands reuse internal
merge implementation is a good thing, but it's irrelevant to the case at
hand. I never merge side-branches with either of
rebase/cherry-pick/revert, so it's only logical to ask for specific
branch-merging functionality only from "git merge".

I don't even want to think for now if it could be useful in
rebase/cherry-pick/revert/whatever, as it's already difficult enough.

As a side note, if anything, in my POV, having both rebase and
cherry-pick in porcelain is an overkill. Effectively, 'rebase' is a
'cherry-pick' on steroids, so adding a --cherry option to 'rebase' seems
to be logical.

>
> If you're disclaiming your last paragraph and saying that this would
> only be a manual operation where the user specifies which files they
> want to specially merge, then a lot of my complaints go away.

Nothing to disclaim, I think. What I thought was that it will affect
things automatically, but only for "git merge". Apparently generic merge
machinery will need support for this, but it will be used only for "git
merge", at least for a start. Alternatively, there could be generic
option that will turn this handling on, and this option will be turned
on by default only for "git merge". I'm not familiar with Git
implementation enough to even try suggest the right way to implement it
though.

> Although...
>
>> Nor do I see why to limit decisions to "ours" vs "theirs". I meant to
>> support arbitrary merge strategies for different files. Generic feature.
>>
>> My thought was: if git at all supports different merge strategies, why
>> not to support different strategies for different files? I don't see any
>> inherent contradiction in adding of such a feature.
>
> If you're interested in re-merging specific files, why not just call
> `git merge-file` to handle each one?  It supports e.g. --ours/--theirs
> (similar to merge's -Xours/-Xtheirs) and could possibly add more if
> there are ones missing.  So, it seems like we already have a command
> for this, even if it's less well known?

merge-file is likely some low-level utility... check... yeah, it is.
Extremely low-level. Three-way merge of 3 /files/. How does it help? How
much error-prone scripting will I need to get to the point of any
suitable result?

To me what you suggest here is basically what I've described as kludgy
way of achieving the goal. I can probably also make merges with
different strategies in 2 different repositories, then copy files
between them. Does it mean I already have all the needed tools to get
the job done?

Please consider the problem: I did a regular merge, and by analysis of
the resulting conflicts I realized I'd need to visit a few tens of files
and resolve conflicts exactly the way -X ours would. Suppose, for
simplicity, that all these files are in some sub-directory <subdir>.

git merge --force -X ours -- <subdir>

would solve this immediately, if it existed. Honestly, I can't even
estimate what would I need to do to achieve it using "git merge-file". I
mean, I guess it's possible, yet I don't believe it's practical.

>> >   * The pathspec limiting is going to be a bug factory for renaming
>> > handling.  (The simplest form of which is just renaming a special path
>> > to a non-special path or vice-versa and modifying both sides of
>> > history.)  Rename handling can already get some pretty hairy corner
>> > cases without dumping more in the mix.  I'd rather have users decide
>> > what to do with paths that switched from being one of the special
>> > "ours" paths to being a normal 3-way-conflict marker path.
>>
>> I admittedly didn't dive into such details, but I didn't suggest to
>> attach any additional attributes to paths either, so there is no need to
>> care about renames, as far as I'm able to see.
>>
>> Apparently you talk about some other feature here that I didn't suggest.
>
> Perhaps your comments on creating a ".gitmerge" file means something
> different than I understood.  If it indeed does not record pathnames,
> then the rename issue goes away (though then I don't understand what
> its purpose is nor the rest of your comments in that paragraph where
> you suggested it).  But if your .gitmerge comments did imply something
> similar to .gitattributes which specified how certain paths were to be
> handled, then renaming issues would certainly arise.

Well, I had no use for .gitattributes, so I didn't even recall they
exist. Maybe it's where needed support could be defined, so that
existing renames handling machinery is simply reused without additional
efforts. Will it work right now if I define custom merge driver that
does "git merge -X ours" and then assign it to the set of files? It'd
still be a kludge, but one that proves the point that such support could
be implemented without much effort.

OTOH, as I already said, my own use-case doesn't need any permanent
configuration, so what I say about it is mostly just thinking aloud. In
particular, the .gitattributes trick above is again too complex to solve
a casual but heavy problem I sometimes have, though I think I'd still
use it lacking better way.

Thanks,
-- Sergey

  parent reply	other threads:[~2020-06-24 19:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 18:21 Request for adding a simple mechanism to exclude files from Git merge operation Tiran Meltser
2020-06-21 15:43 ` Philip Oakley
2020-06-22 18:42   ` [E] " Tiran Meltser
2020-06-22 19:41 ` brian m. carlson
2020-06-23 12:44   ` Sergey Organov
2020-06-23 16:16     ` Philip Oakley
2020-06-23 17:23       ` Sergey Organov
2020-06-23 17:08     ` Elijah Newren
2020-06-23 20:19       ` Sergey Organov
2020-06-23 21:46         ` Elijah Newren
2020-06-23 22:57           ` Chris Torek
2020-06-24 19:15           ` Sergey Organov [this message]
2020-06-23 22:38       ` Junio C Hamano
2020-06-24 18:03         ` Sergey Organov
2020-06-24 22:38           ` Junio C Hamano
2020-06-25 11:46             ` Sergey Organov

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=87ftak1di9.fsf@osv.gnss.ru \
    --to=sorganov@gmail.com \
    --cc=Amir.Yosef@mavenir.com \
    --cc=Tiran.Meltser@mavenir.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.