Go to file
Linus Torvalds 6dd4b66fde Fix diffcore-break total breakage
Ok, so on the kernel list, some people noticed that "git log --follow"
doesn't work too well with some files in the x86 merge, because a lot of
files got renamed in very special ways.

In particular, there was a pattern of doing single commits with renames
that looked basically like

 - rename "filename.h" -> "filename_64.h"
 - create new "filename.c" that includes "filename_32.h" or
   "filename_64.h" depending on whether we're 32-bit or 64-bit.

which was preparatory for smushing the two trees together.

Now, there's two issues here:

 - "filename.c" *remained*. Yes, it was a rename, but there was a new file
   created with the old name in the same commit. This was important,
   because we wanted each commit to compile properly, so that it was
   bisectable, so splitting the rename into one commit and the "create
   helper file" into another was *not* an option.

   So we need to break associations where the contents change too much.
   Fine. We have the -B flag for that. When we break things up, then the
   rename detection will be able to figure out whether there are better
   alternatives.

 - "git log --follow" didn't with with -B.

Now, the second case was really simple: we use a different "diffopt"
structure for the rename detection than the basic one (which we use for
showing the diffs). So that second case is trivially fixed by a trivial
one-liner that just copies the break_opt values from the "real" diffopts
to the one used for rename following. So now "git log -B --follow" works
fine:

	diff --git a/tree-diff.c b/tree-diff.c
	index 26bdbdd..7c261fd 100644
	--- a/tree-diff.c
	+++ b/tree-diff.c
	@@ -319,6 +319,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
	 	diff_opts.detect_rename = DIFF_DETECT_RENAME;
	 	diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
	 	diff_opts.single_follow = opt->paths[0];
	+	diff_opts.break_opt = opt->break_opt;
	 	paths[0] = NULL;
	 	diff_tree_setup_paths(paths, &diff_opts);
	 	if (diff_setup_done(&diff_opts) < 0)

however, the end result does *not* work. Because our diffcore-break.c
logic is totally bogus!

In particular:

 - it used to do

	if (base_size < MINIMUM_BREAK_SIZE)
		return 0; /* we do not break too small filepair */

   which basically says "don't bother to break small files". But that
   "base_size" is the *smaller* of the two sizes, which means that if some
   large file was rewritten into one that just includes another file, we
   would look at the (small) result, and decide that it's smaller than the
   break size, so it cannot be worth it to break it up! Even if the other
   side was ten times bigger and looked *nothing* like the samell file!

   That's clearly bogus. I replaced "base_size" with "max_size", so that
   we compare the *bigger* of the filepair with the break size.

 - It calculated a "merge_score", which was the score needed to merge it
   back together if nothing else wanted it. But even if it was *so*
   different that we would never want to merge it back, we wouldn't
   consider it a break! That makes no sense. So I added

	if (*merge_score_p > break_score)
		return 1;

   to make it clear that if we wouldn't want to merge it at the end, it
   was *definitely* a break.

 - It compared the whole "extent of damage", counting all inserts and
   deletes, but it based this score on the "base_size", and generated the
   damage score with

	delta_size = src_removed + literal_added;
	damage_score = delta_size * MAX_SCORE / base_size;

   but that makes no sense either, since quite often, this will result in
   a number that is *bigger* than MAX_SCORE! Why? Because base_size is
   (again) the smaller of the two files we compare, and when you start out
   from a small file and add a lot (or start out from a large file and
   remove a lot), the base_size is going to be much smaller than the
   damage!

   Again, the fix was to replace "base_size" with "max_size", at which
   point the damage actually becomes a sane percentage of the whole.

With these changes in place, not only does "git log -B --follow" work for
the case that triggered this in the first place, ie now

	git log -B --follow arch/x86/kernel/vmlinux_64.lds.S

actually gives reasonable results. But I also wanted to verify it in
general, by doing a full-history

	git log --stat -B -C

on my kernel tree with the old code and the new code.

There's some tweaking to be done, but generally, the new code generates
much better results wrt breaking up files (and then finding better rename
candidates). Here's a few examples of the "--stat" output:

 - This:
	include/asm-x86/Kbuild        |    2 -
	include/asm-x86/debugreg.h    |   79 +++++++++++++++++++++++++++++++++++------
	include/asm-x86/debugreg_32.h |   64 ---------------------------------
	include/asm-x86/debugreg_64.h |   65 ---------------------------------
	4 files changed, 68 insertions(+), 142 deletions(-)

      Becomes:

	include/asm-x86/Kbuild                        |    2 -
	include/asm-x86/{debugreg_64.h => debugreg.h} |    9 +++-
	include/asm-x86/debugreg_32.h                 |   64 -------------------------
	3 files changed, 7 insertions(+), 68 deletions(-)

 - This:
	include/asm-x86/bug.h    |   41 +++++++++++++++++++++++++++++++++++++++--
	include/asm-x86/bug_32.h |   37 -------------------------------------
	include/asm-x86/bug_64.h |   34 ----------------------------------
	3 files changed, 39 insertions(+), 73 deletions(-)

      Becomes

	include/asm-x86/{bug_64.h => bug.h} |   20 +++++++++++++-----
	include/asm-x86/bug_32.h            |   37 -----------------------------------
	2 files changed, 14 insertions(+), 43 deletions(-)

Now, in some other cases, it does actually turn a rename into a real
"delete+create" pair, and then the diff is usually bigger, so truth in
advertizing: it doesn't always generate a nicer diff. But for what -B was
meant for, I think this is a big improvement, and I suspect those cases
where it generates a bigger diff are tweakable.

So I think this diff fixes a real bug, but we might still want to tweak
the default values and perhaps the exact rules for when a break happens.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-21 01:59:42 -04:00
Documentation gitk.txt: Fix markup. 2007-10-19 23:13:28 -04:00
arm
…
compat
…
contrib fixing output of non-fast-forward output of post-receive-email 2007-10-18 00:59:25 -04:00
git-gui Merge branch 'maint' of git://repo.or.cz/git-gui into maint 2007-10-20 23:19:22 -04:00
gitweb gitweb: No difftree output for trivial merge 2007-09-23 23:12:22 -07:00
mozilla-sha1
…
perl Install man3 manpages to $PREFIX/share/man/man3 even for site installs 2007-08-23 01:02:49 -07:00
ppc
…
t send-pack: respect '+' on wildcard refspecs 2007-10-19 22:59:10 -04:00
templates hooks--update: Explicitly check for all zeros for a deleted ref. 2007-09-13 22:33:11 -07:00
xdiff
…
.gitignore
…
.mailmap
…
COPYING
…
GIT-VERSION-GEN GIT 1.5.3.4 2007-10-03 02:33:48 -07:00
INSTALL Mention 'cpio' dependency in INSTALL 2007-10-02 17:35:29 -07:00
Makefile Do not remove distributed configure script 2007-10-15 21:12:06 -04:00
README
…
RelNotes Whip post 1.5.3.4 maintenance series into shape. 2007-10-15 22:29:50 -04:00
alloc.c
…
archive-tar.c
…
archive-zip.c
…
archive.h
…
attr.c attr: fix segfault in gitattributes parsing code 2007-10-18 21:11:27 -04:00
attr.h
…
base85.c
…
blob.c
…
blob.h
…
builtin-add.c Add test to check recent fix to "git add -u" 2007-09-14 14:30:05 -07:00
builtin-annotate.c
…
builtin-apply.c apply: get rid of --index-info in favor of --build-fake-ancestor 2007-09-26 13:42:10 -07:00
builtin-archive.c
…
builtin-blame.c blame: check return value from read_sha1_file() 2007-08-25 08:33:47 -07:00
builtin-branch.c
…
builtin-bundle.c builtin-bundle create - use lock_file 2007-08-13 13:04:18 -07:00
builtin-cat-file.c
…
builtin-check-attr.c Add read_cache to builtin-check-attr 2007-08-14 22:46:01 -07:00
builtin-check-ref-format.c
…
builtin-checkout-index.c
…
builtin-commit-tree.c
…
builtin-config.c git-config: print error message if the config file cannot be read 2007-10-18 01:35:33 -04:00
builtin-count-objects.c
…
builtin-describe.c
…
builtin-diff-files.c
…
builtin-diff-index.c
…
builtin-diff-tree.c
…
builtin-diff.c git-diff: resurrect the traditional empty "diff --git" behaviour 2007-08-31 23:30:14 -07:00
builtin-fetch--tool.c Avoid scary errors about tagged trees/blobs during git-fetch 2007-10-18 20:37:52 -04:00
builtin-fmt-merge-msg.c
…
builtin-for-each-ref.c for-each-ref: fix %(numparent) and %(parent) 2007-10-02 15:12:05 -07:00
builtin-fsck.c
…
builtin-gc.c
…
builtin-grep.c Split grep arguments in a way that does not requires to add /dev/null. 2007-09-14 15:16:43 -07:00
builtin-init-db.c git-init: autodetect core.symlinks 2007-08-31 00:25:04 -07:00
builtin-log.c git-format-patch --in-reply-to: accept <message@id> with angle brackets 2007-09-14 00:49:12 -07:00
builtin-ls-files.c Must not modify the_index.cache as it may be passed to realloc at some point. 2007-10-02 23:18:58 -07:00
builtin-ls-tree.c
…
builtin-mailinfo.c Temporary fix for stack smashing in mailinfo 2007-08-30 18:46:37 -07:00
builtin-mailsplit.c
…
builtin-merge-base.c
…
builtin-merge-file.c
…
builtin-mv.c
…
builtin-name-rev.c name-rev: Fix non-shortest description 2007-08-27 22:36:43 -07:00
builtin-pack-objects.c fix same sized delta logic 2007-08-30 19:18:31 -07:00
builtin-pack-refs.c
…
builtin-prune-packed.c
…
builtin-prune.c
…
builtin-push.c Make --no-thin the default in git-push to save server resources 2007-09-10 00:00:26 -07:00
builtin-read-tree.c Clean-up read-tree error condition. 2007-08-16 21:19:06 -07:00
builtin-reflog.c
…
builtin-rerere.c
…
builtin-rev-list.c
…
builtin-rev-parse.c
…
builtin-revert.c
…
builtin-rm.c
…
builtin-runstatus.c
…
builtin-shortlog.c
…
builtin-show-branch.c
…
builtin-show-ref.c
…
builtin-stripspace.c
…
builtin-symbolic-ref.c
…
builtin-tag.c git-tag -s must fail if gpg cannot sign the tag. 2007-09-09 21:30:54 -07:00
builtin-tar-tree.c
…
builtin-unpack-objects.c
…
builtin-update-index.c Fix "git commit directory/" performance anomaly 2007-08-10 13:57:43 -07:00
builtin-update-ref.c
…
builtin-upload-archive.c
…
builtin-verify-pack.c
…
builtin-verify-tag.c
…
builtin-write-tree.c Fix racy-git handling in git-write-tree. 2007-08-24 18:53:02 -07:00
builtin.h
…
cache-tree.c
…
cache-tree.h
…
cache.h Move make_cache_entry() from merge-recursive.c into read-cache.c 2007-09-26 13:42:10 -07:00
check-builtins.sh
…
check-racy.c
…
color.c
…
color.h
…
combine-diff.c
…
commit.c clear_commit_marks(): avoid deep recursion 2007-10-15 21:05:22 -04:00
commit.h
…
config.c Merge branch 'cr/tag' 2007-08-10 23:17:46 -07:00
config.mak.in
…
configure.ac the ar tool is called gar on some systems 2007-10-02 21:10:25 -07:00
connect.c URL: allow port specification in ssh:// URLs 2007-09-01 03:35:29 -07:00
convert-objects.c
…
convert.c
…
copy.c
…
csum-file.c
…
csum-file.h
…
ctype.c
…
daemon.c Define NI_MAXSERV if not defined by operating system 2007-10-18 21:04:44 -04:00
date.c
…
decorate.c
…
decorate.h
…
delta.h
…
diff-delta.c diff-delta.c: Fix broken skip calculation. 2007-08-23 00:04:10 -07:00
diff-lib.c diff --no-index: do not forget to run diff_setup_done() 2007-09-14 12:12:32 -07:00
diff.c rename diff_free_filespec_data_large() to diff_free_filespec_blob() 2007-10-02 21:02:09 -07:00
diff.h diff: squelch empty diffs even more 2007-08-14 22:34:58 -07:00
diffcore-break.c Fix diffcore-break total breakage 2007-10-21 01:59:42 -04:00
diffcore-delta.c
…
diffcore-order.c
…
diffcore-pickaxe.c
…
diffcore-rename.c rename diff_free_filespec_data_large() to diff_free_filespec_blob() 2007-10-02 21:02:09 -07:00
diffcore.h rename diff_free_filespec_data_large() to diff_free_filespec_blob() 2007-10-02 21:02:09 -07:00
dir.c Fix directory scanner to correctly ignore files without d_type 2007-10-21 01:44:40 -04:00
dir.h
…
dump-cache-tree.c
…
entry.c attr.c: read .gitattributes from index as well. 2007-08-14 23:19:10 -07:00
environment.c Merge branch 'cr/tag' 2007-08-10 23:17:46 -07:00
exec_cmd.c
…
exec_cmd.h
…
fast-import.c fast-import: Fix argument order to die in file_change_m 2007-10-20 21:43:35 -04:00
fetch-pack.c
…
fetch.c
…
fetch.h
…
fixup-builtins
…
generate-cmdlist.sh
…
git-add--interactive.perl git add -i: Remove unused variables 2007-10-15 21:00:40 -04:00
git-am.sh apply: get rid of --index-info in favor of --build-fake-ancestor 2007-09-26 13:42:10 -07:00
git-archimport.perl Make git-archimport log entries more consistent 2007-08-30 19:22:02 -07:00
git-bisect.sh
…
git-checkout.sh
…
git-clean.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-clone.sh git-clone: improve error message if curl program is missing or not executable 2007-09-13 22:39:22 -07:00
git-commit.sh git-commit: initialize TMP_INDEX just to be sure. 2007-10-02 11:48:06 -07:00
git-compat-util.h Introduces xmkstemp() 2007-08-14 22:20:23 -07:00
git-cvsexportcommit.perl Ensure we add directories in the correct order 2007-10-18 20:51:16 -04:00
git-cvsimport.perl (cvs|svn)import: Ask git-tag to overwrite old tags. 2007-09-07 21:02:39 -07:00
git-cvsserver.perl cvsserver: Use exit 1 instead of die when req_Root fails. 2007-10-18 03:02:15 -04:00
git-fetch.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-filter-branch.sh filter-branch: update current branch when rewritten 2007-10-16 22:47:51 -04:00
git-instaweb.sh Avoid 'expr index' on Mac OS X as it isn't supported 2007-10-16 22:48:03 -04:00
git-lost-found.sh
…
git-ls-remote.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-merge-octopus.sh
…
git-merge-one-file.sh
…
git-merge-ours.sh
…
git-merge-resolve.sh Fixing comment in merge strategies 2007-08-30 17:18:22 -07:00
git-merge-stupid.sh Fixing comment in merge strategies 2007-08-30 17:18:22 -07:00
git-merge.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-mergetool.sh mergetool: Fix typo in options passed to kdiff3 2007-09-28 22:26:05 -04:00
git-parse-remote.sh
…
git-pull.sh Make git-pull complain and give advice when there is nothing to merge with 2007-10-02 17:27:48 -07:00
git-quiltimport.sh quiltimport: Skip non-existent patches 2007-09-27 16:19:19 -07:00
git-rebase--interactive.sh rebase -i: use diff plumbing instead of porcelain 2007-10-15 21:16:08 -04:00
git-rebase.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-relink.perl
…
git-remote.perl git-remote: exit with non-zero status after detecting errors. 2007-09-29 23:32:31 -07:00
git-repack.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-request-pull.sh
…
git-reset.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-send-email.perl send-email: make message-id generation a bit more robust 2007-09-17 22:02:19 -07:00
git-sh-setup.sh git-sh-setup: typofix in comments 2007-09-15 16:33:22 -07:00
git-stash.sh Paper bag fix diff invocation in 'git stash show' 2007-10-19 02:18:14 -04:00
git-submodule.sh Supplant the "while case ... break ;; esac" idiom 2007-09-23 16:12:00 -07:00
git-svn.perl git-svn: don't attempt to spawn pager if we don't want one 2007-09-23 17:07:10 -07:00
git-svnimport.perl git-svnimport: Use separate arguments in the pipe for git-rev-parse 2007-09-18 14:00:20 -07:00
git.c git --bare cmd: do not unconditionally nuke GIT_DIR 2007-08-27 22:44:41 -07:00
git.spec.in GIT 1.5.3.1: obsolete git-p4 in RPM spec file. 2007-09-03 01:28:37 -07:00
gitk gitk: Fix bug causing undefined variable error when cherry-picking 2007-08-29 22:41:34 +10:00
grep.c
…
grep.h
…
hash-object.c
…
help.c
…
http-fetch.c
…
http-push.c
…
http.c
…
http.h
…
ident.c Improved hint on how to set identity 2007-08-13 23:34:38 -07:00
imap-send.c
…
index-pack.c Use xmkstemp() instead of mkstemp() 2007-08-14 22:20:26 -07:00
interpolate.c
…
interpolate.h
…
list-objects.c
…
list-objects.h
…
local-fetch.c
…
lockfile.c
…
log-tree.c Clean up "git log" format with DIFF_FORMAT_NO_OUTPUT 2007-10-15 20:24:27 -04:00
log-tree.h
…
mailmap.c
…
mailmap.h
…
match-trees.c
…
merge-file.c
…
merge-index.c
…
merge-recursive.c Move make_cache_entry() from merge-recursive.c into read-cache.c 2007-09-26 13:42:10 -07:00
merge-tree.c
…
mktag.c
…
mktree.c
…
object-refs.c
…
object.c
…
object.h
…
pack-check.c
…
pack-redundant.c
…
pack-write.c Use xmkstemp() instead of mkstemp() 2007-08-14 22:20:26 -07:00
pack.h
…
pager.c
…
patch-delta.c
…
patch-id.c
…
patch-ids.c
…
patch-ids.h
…
path-list.c path-list.c: always free strdup'ed paths 2007-08-15 13:43:08 -07:00
path-list.h path-list.c: always free strdup'ed paths 2007-08-15 13:43:08 -07:00
path.c
…
peek-remote.c
…
pkt-line.c
…
pkt-line.h
…
progress.c
…
progress.h
…
quote.c
…
quote.h
…
reachable.c
…
reachable.h
…
read-cache.c git-blame shouldn't crash if run in an unmerged tree 2007-10-18 02:31:30 -04:00
receive-pack.c Improve receive-pack error message about funny ref creation 2007-10-20 21:49:24 -04:00
reflog-walk.c
…
reflog-walk.h
…
refs.c Fix filehandle leak in "git branch -D" 2007-08-10 22:50:06 -07:00
refs.h
…
remote.c send-pack: respect '+' on wildcard refspecs 2007-10-19 22:59:10 -04:00
remote.h
…
revision.c Fix embarrassing "git log --follow" bug 2007-10-15 20:15:58 -04:00
revision.h Add --log-size to git log to print message size 2007-08-14 01:59:33 -07:00
rsh.c
…
rsh.h
…
run-command.c
…
run-command.h
…
send-pack.c helpful error message when send-pack finds no refs in common. 2007-10-16 22:01:15 -04:00
server-info.c
…
setup.c Fix setup_git_directory_gently() with relative GIT_DIR & GIT_WORK_TREE 2007-10-16 20:18:04 -04:00
sha1_file.c Don't segfault if we failed to inflate a packed delta 2007-08-25 08:33:47 -07:00
sha1_name.c
…
shallow.c
…
shell.c
…
show-index.c
…
sideband.c
…
sideband.h
…
ssh-fetch.c
…
ssh-pull.c
…
ssh-push.c
…
ssh-upload.c
…
strbuf.c
…
strbuf.h
…
symlinks.c
…
tag.c
…
tag.h
…
tar.h
…
test-absolute-path.c
…
test-chmtime.c
…
test-date.c
…
test-delta.c
…
test-genrandom.c
…
test-match-trees.c
…
test-sha1.c
…
test-sha1.sh
…
trace.c
…
tree-diff.c Fix diffcore-break total breakage 2007-10-21 01:59:42 -04:00
tree-walk.c
…
tree-walk.h
…
tree.c Optimize "diff --cached" performance. 2007-08-10 11:44:23 -07:00
tree.h
…
unpack-file.c Use xmkstemp() instead of mkstemp() 2007-08-14 22:20:26 -07:00
unpack-trees.c Optimize the three-way merge of git-read-tree 2007-08-10 23:02:14 -07:00
unpack-trees.h Move old index entry removal from "unpack_trees()" into the individual functions 2007-08-10 13:59:19 -07:00
update-server-info.c
…
upload-pack.c
…
usage.c
…
utf8.c
…
utf8.h
…
var.c
…
write_or_die.c
…
wt-status.c Fix the rename detection limit checking 2007-09-14 12:12:57 -07:00
wt-status.h
…
xdiff-interface.c
…
xdiff-interface.h
…

README

////////////////////////////////////////////////////////////////

	GIT - the stupid content tracker

////////////////////////////////////////////////////////////////

"git" can mean anything, depending on your mood.

 - random three-letter combination that is pronounceable, and not
   actually used by any common UNIX command.  The fact that it is a
   mispronunciation of "get" may or may not be relevant.
 - stupid. contemptible and despicable. simple. Take your pick from the
   dictionary of slang.
 - "global information tracker": you're in a good mood, and it actually
   works for you. Angels sing, and a light suddenly fills the room.
 - "goddamn idiotic truckload of sh*t": when it breaks

Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.

Git is an Open Source project covered by the GNU General Public License.
It was originally written by Linus Torvalds with help of a group of
hackers around the net. It is currently maintained by Junio C Hamano.

Please read the file INSTALL for installation instructions.
See Documentation/tutorial.txt to get started, then see
Documentation/everyday.txt for a useful minimum set of commands,
and "man git-commandname" for documentation of each command.
CVS users may also want to read Documentation/cvs-migration.txt.

Many Git online resources are accessible from http://git.or.cz/
including full documentation and Git related tools.

The user discussion and development of Git take place on the Git
mailing list -- everyone is welcome to post bug reports, feature
requests, comments and patches to git@vger.kernel.org. To subscribe
to the list, send an email with just "subscribe git" in the body to
majordomo@vger.kernel.org. The mailing list archives are available at
http://marc.theaimsgroup.com/?l=git and other archival sites.

The messages titled "A note from the maintainer", "What's in
git.git (stable)" and "What's cooking in git.git (topics)" and
the discussion following them on the mailing list give a good
reference for project status, development direction and
remaining tasks.