From: David Aguilar <davvid@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Luis Gutierrez <luisgutz@gmail.com>,
John Keeping <john@keeping.me.uk>,
git@vger.kernel.org
Subject: Re: git-mergetool reverse file ordering
Date: Tue, 16 Aug 2016 23:46:12 -0700 [thread overview]
Message-ID: <20160817064612.GA14619@gmail.com> (raw)
In-Reply-To: <882f5f1d-19a6-7b4b-7c6a-7347981fee72@kdbg.org>
On Wed, Aug 17, 2016 at 08:10:46AM +0200, Johannes Sixt wrote:
> Am 17.08.2016 um 08:05 schrieb Johannes Sixt:
> > Am 17.08.2016 um 03:25 schrieb David Aguilar:
> > > Hmm, I do like the idea of reusing the diff orderFile, but a
> > > mechanism for sorting arbitrary inputs based on the orderFile
> > > isn't currently exposed in a way that mergetool could use it.
> >
> > Instead of using 'git ls-files -u | sed ... | sort -u' you could use
> >
> > git diff-files --name-status -O... | sed -ne '/^U/s/^..//p'
>
> Or even better:
>
> git diff-files --name-only --diff-filter=U -O...
Nice!
> > > But, that sort is honestly kinda crude. It can't implement the
> > > interesting case where we want bar.h to sort before bar.c but
> > > not foo.h.
> > >
Note: I had a subtle typo above -- I meant to describe this desired
order:
bar.h
bar.c
foo.h
foo.c
which is not possible with an orderFile that has only:
*.h
*.c
But...
> > > If we did the sort option, we could have both.
> >
> > I don't think that we need a new filter when the diff machinery is
> > capable of re-ordering files. We should enhance the diff machinery instead.
> >
Reading the code more thoroughly, I fully agree.
Switching to a diff-files invocation lets us reuse the
diff.orderFile machinery and does not require exposing any
additional helpers.
While it would be *nice* if we had a way to sort foo.h before
foo.c and after bar.c, that's just a pie-in-the-sky idea.
Consistency is king.
The only thing that using diff-files doesn't address is the
rerere support in mergetool where it processes the files in
the order specified by "git rerere remaining". This is why I
initially thought we needed a generic sort-like command.
That code path does not currently do any sorting (which may
explain why we didn't notice it if we were just looking for
"sort" invocations) but maybe that's an edge case that we don't
need to address initially (if at all).
Would it be okay for the rerere code path to not honor the
orderFile? IMO if we documented the behavior then it would be
acceptable, and perhaps can be improved as a follow-up.
For the basic support the implementation becomes really
simple: switch to using diff-files instead of ls-files.
If we did want consistency in the "git rerere remaining" code
path, would it be acceptable to teach "rerere" about
"-O<orderfile>" so that we could drive it from mergetool?
I only suggest an option, and not config support, because I
would be hesitant to make "rerere remaining" unconditionally
honor the orderFile since that feature is diff-centric, while
"rerere remaining" is a different beast altogether. Adding a
flag is a middle-ground that would allow mergetool to drive it
while not suddently changing rerere's behavior.
The patches could then be:
1. switch to diff-files, add tests, and document how
diff.orderFile affects mergetool.
2. Teach mergetool about the "-O<orderFile>" flag so that it can
override the configuration, and add tests. It could be
argued that this should be squashed into (1).
3. (optional) teach "rerere remaining" to honor the
-O<orderfile> flag and teach mergetool to supply the option.
Sound good?
ciao,
--
David
next prev parent reply other threads:[~2016-08-17 6:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-27 10:14 git-mergetool reverse file ordering Luis Gutierrez
2016-08-14 3:42 ` David Aguilar
2016-08-14 10:38 ` John Keeping
2016-08-15 20:19 ` Luis Gutierrez
2016-08-17 1:25 ` David Aguilar
2016-08-17 6:05 ` Johannes Sixt
2016-08-17 6:10 ` Johannes Sixt
2016-08-17 6:46 ` David Aguilar [this message]
2016-08-17 7:35 ` Johannes Sixt
2016-08-17 21:18 ` David Aguilar
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=20160817064612.GA14619@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=john@keeping.me.uk \
--cc=luisgutz@gmail.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.
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).