git-commit-vandalism/builtin
Junio C Hamano 75973b2cb5 Fix "add -u" that sometimes fails to resolve unmerged paths
"git add -u" updates the index with the updated contents from the working
tree by internally running "diff-files" to grab the set of paths that are
different from the index. Then it updates the index entries for the paths
that are modified in the working tree, and deletes the index entries for
the paths that are deleted in the working tree.

It ignored the output from the diff-files that indicated that a path is
unmerged.  For these paths, it instead relied on the fact that an unmerged
path is followed by the result of comparison between stage #2 (ours) and
the working tree, and used that to update or delete such a path when it is
used to record the resolution of a conflict.

As the result, when a path did not have stage #2 (e.g. "we deleted while
the other side added"), these unmerged stages were left behind, instead of
recording what the user resolved in the working tree.

Since we recently fixed "diff-files" to indicate if the corresponding path
exists on the working tree for an unmerged path, we do not have to rely on
the comparison with stage #2 anymore. We can instead tell the diff-files
not to compare with higher stages, and use the unmerged output to update
the index to reflect the state of the working tree.

The changes to the test vector in t2200 illustrates the nature of the bug
and the fix.  The test expected stage #1 and #3 entries be left behind,
but it was codifying the buggy behaviour.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-23 23:13:28 -07:00
..
add.c Fix "add -u" that sometimes fails to resolve unmerged paths 2011-04-23 23:13:28 -07:00
annotate.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
apply.c Merge branch 'jn/apply-filename-with-sp' 2010-09-03 09:43:44 -07:00
archive.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
bisect--helper.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
blame.c Merge branch 'maint' 2010-08-22 20:18:37 -07:00
branch.c Merge branch 'sm/branch-broken-ref' 2010-06-21 06:02:47 -07:00
bundle.c bundle: run setup_git_directory_gently() sooner 2010-08-15 19:57:33 -07:00
cat-file.c Merge branch 'cp/textconv-cat-file' 2010-06-27 12:07:55 -07:00
check-attr.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
check-ref-format.c Allow "check-ref-format --branch" from subdirectory 2010-08-06 10:01:45 -07:00
checkout-index.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
checkout.c Merge branch 'jl/submodule-ignore-diff' 2010-09-04 08:17:09 -07:00
clean.c builtin/clean.c: Use STRING_LIST_INIT_NODUP. 2010-09-06 16:56:51 -07:00
clone.c clone: warn users --depth is ignored in local clones 2010-08-24 09:28:02 -07:00
commit-tree.c make commit_tree a library function 2010-04-01 23:53:54 -07:00
commit.c Merge branch 'jl/submodule-ignore-diff' 2010-08-18 12:36:25 -07:00
config.c Merge branch 'jn/paginate-fix' 2010-08-31 16:23:31 -07:00
count-objects.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
describe.c Merge branch 'sp/maint-describe-tiebreak-with-tagger-date' into maint 2010-06-16 16:21:15 -07:00
diff-files.c Submodules: Use "ignore" settings from .gitmodules too for diff and status 2010-08-09 09:11:44 -07:00
diff-index.c Submodules: Use "ignore" settings from .gitmodules too for diff and status 2010-08-09 09:11:44 -07:00
diff-tree.c Submodules: Use "ignore" settings from .gitmodules too for diff and status 2010-08-09 09:11:44 -07:00
diff.c Submodules: Use "ignore" settings from .gitmodules too for diff and status 2010-08-09 09:11:44 -07:00
fast-export.c Merge branch 'en/d-f-conflict-fix' 2010-09-08 08:54:01 -07:00
fetch-pack.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
fetch.c builtin/fetch.c: comment that branch->remote_name is usable when has_merge 2010-09-09 17:15:58 -07:00
fmt-merge-msg.c Merge branch 'jn/update-contrib-example-merge' 2010-09-03 09:43:42 -07:00
for-each-ref.c for-each-ref: fix objectname:short bug 2010-08-26 16:42:25 -07:00
fsck.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
gc.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
grep.c Merge branch 'jn/paginate-fix' 2010-08-31 16:23:31 -07:00
hash-object.c Merge branch 'lt/deepen-builtin-source' 2010-03-10 15:25:18 -08:00
help.c Cast execl*() NULL sentinels to (char *) 2010-07-25 23:14:18 -07:00
index-pack.c Merge branch 'jn/paginate-fix' 2010-08-31 16:23:31 -07:00
init-db.c handle "git --bare init <dir>" properly 2010-05-10 11:25:37 -07:00
log.c Fix 'git log' early pager startup error case 2010-08-25 12:11:59 -07:00
ls-files.c Merge branch 'ar/string-list-foreach' 2010-08-18 12:14:38 -07:00
ls-remote.c ls-remote: run setup_git_directory_gently() sooner 2010-08-15 20:00:02 -07:00
ls-tree.c ls-tree $di $dir: do not mistakenly recurse into directories 2010-09-12 13:52:03 -07:00
mailinfo.c enums: omit trailing comma for portability 2010-05-31 16:59:27 -07:00
mailsplit.c string_list: Add STRING_LIST_INIT macro and make use of it. 2010-07-05 11:47:57 -07:00
merge-base.c merge-base --independent to print reduced parent list in a merge 2010-08-18 14:02:03 -07:00
merge-file.c merge-file: run setup_git_directory_gently() sooner 2010-08-15 20:00:03 -07:00
merge-index.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
merge-ours.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
merge-recursive.c Merge branch 'jn/merge-renormalize' 2010-09-03 09:43:41 -07:00
merge-tree.c merge-tree: fix where two branches share no changes 2010-07-14 12:56:49 -07:00
merge.c Merge branch 'dg/local-mod-error-messages' 2010-09-03 22:23:49 -07:00
mktag.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
mktree.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
mv.c string_list: Add STRING_LIST_INIT macro and make use of it. 2010-07-05 11:47:57 -07:00
name-rev.c object.h: Add OBJECT_ARRAY_INIT macro and make use of it. 2010-08-29 22:42:49 -07:00
notes.c notes: Don't create (empty) commit when removing non-existing notes 2010-08-31 11:07:34 -07:00
pack-objects.c Merge branch 'js/try-to-free-stackable' 2010-06-13 11:21:21 -07:00
pack-redundant.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
pack-refs.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
patch-id.c patch-id: Add support for mbox format 2010-04-19 13:01:49 -07:00
prune-packed.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
prune.c prune: allow --dry-run for -n and --verbose for -v 2010-08-09 10:13:18 -07:00
push.c Merge branch 'maint' 2010-08-12 18:07:09 -07:00
read-tree.c Merge remote branch 'ko/master' into jc/read-tree-cache-tree-fix 2010-07-08 18:55:50 -07:00
receive-pack.c string_list: Add STRING_LIST_INIT macro and make use of it. 2010-07-05 11:47:57 -07:00
reflog.c Merge branch 'jc/maint-no-reflog-expire-unreach-for-head' 2010-05-21 04:02:18 -07:00
remote.c string_list: Add STRING_LIST_INIT macro and make use of it. 2010-07-05 11:47:57 -07:00
replace.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
rerere.c Merge branch 'jn/merge-renormalize' 2010-09-03 09:43:41 -07:00
reset.c reset: suggest what to do upon "git reset --mixed <paths>" 2010-08-21 23:17:35 -07:00
rev-list.c rev-list: introduce --count option 2010-06-12 09:39:06 -07:00
rev-parse.c Merge branch 'maint' 2010-07-07 11:18:26 -07:00
revert.c Merge branch 'jn/merge-renormalize' 2010-09-03 09:43:41 -07:00
rm.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
send-pack.c Merge branch 'ld/push-porcelain' 2010-03-15 00:58:24 -07:00
shortlog.c shortlog: run setup_git_directory_gently() sooner 2010-08-11 09:24:01 -07:00
show-branch.c show-branch: use DEFAULT_ABBREV instead of 7 2010-05-25 09:48:49 -07:00
show-ref.c string_list: Add STRING_LIST_INIT macro and make use of it. 2010-07-05 11:47:57 -07:00
stripspace.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
symbolic-ref.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
tag.c tag -v: use RUN_GIT_CMD to run verify-tag 2010-04-17 12:40:19 -07:00
tar-tree.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
unpack-file.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
unpack-objects.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
update-index.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
update-ref.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
update-server-info.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
upload-archive.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
var.c var: run setup_git_directory_gently() sooner 2010-08-15 20:00:02 -07:00
verify-pack.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
verify-tag.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00
write-tree.c Move 'builtin-*' into a 'builtin/' subdirectory 2010-02-22 14:29:41 -08:00