* an option to make "git-diff Z A" prints Z's diff before A's
@ 2006-10-25 7:15 Jim Meyering
2006-10-25 19:16 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Jim Meyering @ 2006-10-25 7:15 UTC (permalink / raw
To: git
Hello,
In a recent patch set I prepared, I placed the names of the
more relevant files at the front of the list given to "git-diff".
So I was surprised to see diff output in which the blocks of output
are sorted by file name. The parts I'd tried to put at the "top"
ended up being buried in the latter part of the patch.
Here's a small test case:
mkdir d && cd d && touch x y && git-init-db
git-add x y && git-commit -m. x y
echo a > x && echo a > y
git-diff y x|grep '^d'
I expected this git-diff output, with "y's" diff first:
diff --git a/y b/y
diff --git a/x b/x
but got this, where x's come first:
diff --git a/x b/x
diff --git a/y b/y
I know about the -O<orderfile> option, and it can make git-diff do
what I want, but only if I first create a separate file containing
the names that I'm already providing to git-diff in the very same order.
Is there an easier way?
If not, would you be amenable to a new option enabling this behavior
without requiring a temporary file?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: an option to make "git-diff Z A" prints Z's diff before A's
2006-10-25 7:15 an option to make "git-diff Z A" prints Z's diff before A's Jim Meyering
@ 2006-10-25 19:16 ` Junio C Hamano
2006-10-26 8:42 ` Karl Hasselström
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2006-10-25 19:16 UTC (permalink / raw
To: Jim Meyering; +Cc: git
Jim Meyering <jim@meyering.net> writes:
> In a recent patch set I prepared, I placed the names of the
> more relevant files at the front of the list given to "git-diff".
>...
> I know about the -O<orderfile> option, and it can make git-diff do
> what I want, but only if I first create a separate file containing
> the names that I'm already providing to git-diff in the very same order.
>
> Is there an easier way?
No, not right now.
> If not, would you be amenable to a new option enabling this behavior
> without requiring a temporary file?
The thing is, "git diff -- Z A" does *not* mean:
I know I have a file called Z and a file called A;
please give diff for these files.
What it means is:
Please give me the diff as usual, but I care about paths
that match these patterns, Z or A.
So "git diff -- Documentation" names all changed files in that
directory; you could also spell it "Documentation/" for clarity.
git-diff traverses two tree-like things (either tree-vs-tree,
tree-vs-index, or tree-vs-working tree) in parallel in the
canonical order, but skips comparing paths that do not match the
list of patterns you gave on the command line. While it does
so, we do not record which pattern caused the path to be
included in the output anywhere, so there currently is no way to
tell which ones matched an earlier pattern and which ones
matched a later one.
If somebody wants to do this, the place to modify would be the
following:
- add a new parameter, "int match_number", to change_fn_t and
add_remove_fn_t functions, and add a new member to struct
diff_filepair to record it.
- update all callers of diff_addremove, diff_change, and
diff_unmerge to pass which pathspec the user gave on the
command line matched the path to be included (in your example
if both Z and A were directory, file Z/foo gets number 1 and
file A/bar gets number 2).
- update diff_addremove, diff_change and diff_unmerge to pass
that match_number to diff_queue(), and make diff_queue()
record the number in the new diff_filepair it creates.
- in places where an existing filepair is split into two and
two existing filepairs are merged into one (e.g. "break" and
"rename"), make sure match_number is propagated sensibly from
the original filepairs to the modified ones.
- in diffcore_std(), if orderfile is not in use, use the
match_number to sort the queued filepairs.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: an option to make "git-diff Z A" prints Z's diff before A's
2006-10-25 19:16 ` Junio C Hamano
@ 2006-10-26 8:42 ` Karl Hasselström
2006-10-26 15:16 ` Linus Torvalds
0 siblings, 1 reply; 4+ messages in thread
From: Karl Hasselström @ 2006-10-26 8:42 UTC (permalink / raw
To: Junio C Hamano; +Cc: Jim Meyering, git
On 2006-10-25 12:16:07 -0700, Junio C Hamano wrote:
> The thing is, "git diff -- Z A" does *not* mean:
>
> I know I have a file called Z and a file called A; please give
> diff for these files.
>
> What it means is:
>
> Please give me the diff as usual, but I care about paths that
> match these patterns, Z or A.
A related question: is there a way to limit the path to Z, but
excluding Z/B? That is, I'm interested in the changes in Z, but not
the changes in its subdirectory B.
--
Karl Hasselström, kha@treskal.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: an option to make "git-diff Z A" prints Z's diff before A's
2006-10-26 8:42 ` Karl Hasselström
@ 2006-10-26 15:16 ` Linus Torvalds
0 siblings, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2006-10-26 15:16 UTC (permalink / raw
To: Karl Hasselström; +Cc: Junio C Hamano, Jim Meyering, git
[-- Attachment #1: Type: TEXT/PLAIN, Size: 947 bytes --]
On Thu, 26 Oct 2006, Karl Hasselström wrote:
>
> A related question: is there a way to limit the path to Z, but
> excluding Z/B? That is, I'm interested in the changes in Z, but not
> the changes in its subdirectory B.
We never did that, no. It's certainly a relevant thing to do, and it would
be sensible to have a kind of common logic with revision parsing (where a
caret (^) at the beginning would mean "not"), but at the same time, it's
not been common enough (read: "I have personally never missed it") to
actually become an issue.
So I _think_ it would fit fairly well into the current code (just teach
the stuff that uses "char **pathspec" about that new rule), and it might
not be too bad. On the other hand, that particular code is pretty dense
and part of a very core and performance critical subsystem, so unless you
_really_ want this, you might be better off averting your eyes and just
ignoring this issue ;)
Linus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-26 15:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-25 7:15 an option to make "git-diff Z A" prints Z's diff before A's Jim Meyering
2006-10-25 19:16 ` Junio C Hamano
2006-10-26 8:42 ` Karl Hasselström
2006-10-26 15:16 ` Linus Torvalds
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).