git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* diffcore and directory renames
@ 2008-09-01 21:39 Yann Dirson
  2008-09-01 22:50 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Yann Dirson @ 2008-09-01 21:39 UTC (permalink / raw)
  To: GIT list

I often found myself lost when looking at a diff where a couple of
large dirs where renamed, and a handful of files were modified to take
the rename into account - not a rare situation, I'd say.  In such a
case, the diffs themselves are mostly hidden among numerous rename
entries.

To that, I felt that git ought to know better, and could easily
present a directory rename as such.  Among the advantages of having
such "dir rename detection", aside from readability which we should
not neglect, we'd have more accurate "svn dcommit" for such renames
and, and better decisions made when merging a branch with adds a file
into a dir, with a branch which renames that dir (ok, maybe not that
frequent, but still).


Looking closer at the current behaviour, I realized that git-diff-tree
*is* already able to report such renames in raw mode :

$ ./git-diff-tree 0f1027 -M
0f1027e1aceb4bc5fa682776ab9f72935e2cd1b3
:040000 040000 6f6159f0245784352414ff38ffb68bae80f30bd6 6f6159f0245784352414ff38ffb68bae80f30bd6 R100   ppc     moved

... but patch output breaks this into file moves, and even other
commands which I would have expected to display the same do in fact
not (eg. "git show --raw").  Is there any reason for this ?  I would
have expected git-show to do the same as diff-tree, and it would not
be so much of a problem to introduce a special form of the "rename"
chunk to handle dir renames ?


Since current diff-tree behaviour is based on comparing tree hashs, it
only detects 100%-similarity renames, and naturally diff-index and
diff-files cannot even do that much yet.  However, an optional
factorization pass following rename detection could quite easily
detect if, when a containing directory disappears because of a set of
renames - this is what I have started to look at.

Since what I propose is indeed just a factorization of file renames,
it could be adequate to represent them as such instead of directory
renames, so as to read something like:

|diff --git a/ppc/* b/moved/
|rename from ppc/*
|rename to moved/

This would have the additional advantage of also working when the
target destination was pre-existing, and when merging several dirs
into a single one - while at the same time to mistaking the reader too
much into thinking that git cares about directories so much ;)

Callers should also be careful about interpreting the output when
mixing this behaviour with file filtering, obviously, so it is not
meant to be activated by default.

Does any of this sound sensible ?


On the technical side, I figured out that the best way to plug the
factorization was inside diffcore_rename to take advantage of the fact
it has a list of all renames, that's not going to be published out of
this function - that only left me the "cleanup:" label as insertion
point, not that I find it conceptually very comfortable :)

But if I have understood correctly, diffcore only gets access to
changed filepairs, and does not know about the trees it is comparing.

The most sensible way to go I can think of would be to give to
diffcore enough information (src and dst tree-hash|"INDEX"|"WORKING
COPY") to be able to know for directory existence.  I'd rather check
it does not sound completely wrong to anyone before going into that -
opinions ?

Best regards,
-- 
Yann

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-10-27 19:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-01 21:39 diffcore and directory renames Yann Dirson
2008-09-01 22:50 ` Junio C Hamano
2008-09-02 20:48   ` Yann Dirson
2008-09-25 21:47   ` [RFC PATCH] detection of " Yann Dirson
2008-09-25 21:47     ` [PATCH] Introduce patch factorization in diffcore Yann Dirson
2008-09-25 22:39       ` Andreas Ericsson
2008-09-26 19:21         ` Yann Dirson
2008-09-25 23:19     ` [RFC PATCH] detection of directory renames Jakub Narebski
2008-09-26 19:06       ` Yann Dirson
2008-10-27 13:35     ` Jakub Narebski
2008-10-27 19:13       ` Yann Dirson

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).