aboutsummaryrefslogtreecommitdiff
path: root/unpack-trees.c
Commit message (Collapse)AuthorAge
* Merge branch 'tg/ce-namelen-field'Junio C Hamano2012-07-23
|\ | | | | | | | | | | | | | | Split lower bits of ce_flags field and creates a new ce_namelen field in the in-core index structure. * tg/ce-namelen-field: Strip namelen out of ce_flags into a ce_namelen field
| * Strip namelen out of ce_flags into a ce_namelen fieldThomas Gummerer2012-07-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strip the name length from the ce_flags field and move it into its own ce_namelen field in struct cache_entry. This will both give us a tiny bit of a performance enhancement when working with long pathnames and is a refactoring for more readability of the code. It enhances readability, by making it more clear what is a flag, and where the length is stored and make it clear which functions use stages in comparisions and which only use the length. It also makes CE_NAMEMASK private, so that users don't mistakenly write the name length in the flags. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Replace strlen() with ce_namelen()Thomas Gummerer2012-07-08
|/ | | | | | | | | Replace strlen(ce->name) with ce_namelen() in a couple of places which gives us some additional bits of performance. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jc/ls-files-i-dir'Junio C Hamano2012-06-21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | "git ls-files --exclude=t -i" did not consider anything under t/ as excluded, as it did not pay attention to exclusion of leading paths while walking the index. Other two users of excluded() are also updated. * jc/ls-files-i-dir: dir.c: make excluded() file scope static unpack-trees.c: use path_excluded() in check_ok_to_remove() builtin/add.c: use path_excluded() path_excluded(): update API to less cache-entry centric ls-files -i: micro-optimize path_excluded() ls-files -i: pay attention to exclusion of leading paths
| * unpack-trees.c: use path_excluded() in check_ok_to_remove()Junio C Hamano2012-06-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function is responsible for determining if a path that is not tracked is ignored and allow "checkout" to overwrite it as needed. It used excluded() without checking if higher level directory in the path is ignored; correct it to use path_excluded() for this check. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * There are uses of lower-level interface excluded_from_list() in the codepath for narrow-checkout hack; they are supposed to be already checking each level as they descend, and are not touched with this patch.
* | Merge branch 'maint'Junio C Hamano2012-05-20
|\ \ | | | | | | | | | | | | | | | | | | By Jens Lehmann (1) and Johannes Sixt (1) * maint: Consistently use "superproject" instead of "supermodule" t3404: begin "exchange commits with -p" test with correct preconditions
| * | Consistently use "superproject" instead of "supermodule"Jens Lehmann2012-05-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We fairly consistently say "superproject" and never "supermodule" these days. But there are seven occurrences of "supermodule" left in the current work tree. Three appear in Release Notes for 1.5.3 and 1.7.7, three in test names and one in a C-code comment. Replace all occurrences of "supermodule" outside of the Release Notes (which shouldn't be changed after the fact) with "superproject" for consistency. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'pw/message-cleanup'Junio C Hamano2012-05-02
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many error/warning messages had extra trailing newlines that are unnecessary. By Pete Wyckoff * pw/message-cleanup: remove blank filename in error message remove superfluous newlines in error messages
| * | | remove superfluous newlines in error messagesPete Wyckoff2012-04-30
| |/ / | | | | | | | | | | | | | | | | | | | | | The error handling routines add a newline. Remove the duplicate ones in error messages. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'jc/index-v4'Junio C Hamano2012-05-02
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trivially shrinks the on-disk size of the index file to save both I/O and checksum overhead. The topic should give a solid base to build on further updates, with the code refactoring in its earlier parts, and the backward compatibility mechanism in its later parts. * jc/index-v4: index-v4: document the entry format unpack-trees: preserve the index file version of original update-index: upgrade/downgrade on-disk index version read-cache.c: write prefix-compressed names in the index read-cache.c: read prefix-compressed names in index on-disk version v4 read-cache.c: move code to copy incore to ondisk cache to a helper function read-cache.c: move code to copy ondisk to incore cache to a helper function read-cache.c: report the header version we do not understand read-cache.c: make create_from_disk() report number of bytes it consumed read-cache.c: allow unaligned mapping of the index file cache.h: hide on-disk index details varint: make it available outside the context of pack
| * | unpack-trees: preserve the index file version of originalJunio C Hamano2012-04-27
| |/ | | | | | | | | | | | | Otherwise "git checkout $other_branch" (or even "git checkout HEAD") would end up writing the index out in the default format. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | unpack-trees: plug minor memory leakRené Scharfe2012-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The allocations made by unpack_nondirectories() using create_ce_entry() are never freed. In the non-merge case, we duplicate them using add_entry() and later only look at the first allocated element (src[0]), perhaps even only by mistake. Split out the actual addition from add_entry() into the new helper do_add_entry() and call this non-duplicating function instead of add_entry() to avoid the leak. Valgrind reports this for the command "git archive v1.7.9" without the patch: ==13372== LEAK SUMMARY: ==13372== definitely lost: 230,986 bytes in 2,325 blocks ==13372== indirectly lost: 0 bytes in 0 blocks ==13372== possibly lost: 98 bytes in 1 blocks ==13372== still reachable: 2,259,198 bytes in 3,243 blocks ==13372== suppressed: 0 bytes in 0 blocks And with the patch applied: ==13375== LEAK SUMMARY: ==13375== definitely lost: 65 bytes in 1 blocks ==13375== indirectly lost: 0 bytes in 0 blocks ==13375== possibly lost: 0 bytes in 0 blocks ==13375== still reachable: 2,364,417 bytes in 3,245 blocks ==13375== suppressed: 0 bytes in 0 blocks Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | unpack-trees: don't perform any index operation if we're not mergingRené Scharfe2012-04-10
|/ | | | | | | | | src[0] points to the index entry in the merge case and to the first tree to unpack in the non-merge case. We only want to mark the index entry, so check first if we're merging. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* tree-walk.c: do not leak internal structure in tree_entry_len()Nguyễn Thái Ngọc Duy2011-10-27
| | | | | | | | | | | | | tree_entry_len() does not simply take two random arguments and return a tree length. The two pointers must point to a tree item structure, or struct name_entry. Passing random pointers will return incorrect value. Force callers to pass struct name_entry instead of two pointers (with hope that they don't manually construct struct name_entry themselves) Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'nd/maint-sparse-errors'Junio C Hamano2011-10-13
|\ | | | | | | | | | | * nd/maint-sparse-errors: Add explanation why we do not allow to sparse checkout to empty working tree sparse checkout: show error messages when worktree shaping fails
| * Add explanation why we do not allow to sparse checkout to empty working treeNguyễn Thái Ngọc Duy2011-09-22
| | | | | | | | | | Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * sparse checkout: show error messages when worktree shaping failsNguyễn Thái Ngọc Duy2011-09-22
| | | | | | | | | | | | | | | | | | | | | | verify_* functions can queue errors up and to be printed later at label return_failed. In case of errors, do not go to label "done" directly because all queued messages would be dropped on the floor. Found-by: Joshua Jensen <jjensen@workspacewhiz.com> Tracked-down-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'mg/maint-doc-sparse-checkout'Junio C Hamano2011-10-05
|\ \ | | | | | | | | | | | | | | | | | | * mg/maint-doc-sparse-checkout: git-read-tree.txt: correct sparse-checkout and skip-worktree description git-read-tree.txt: language and typography fixes unpack-trees: print "Aborting" to stderr
| * | unpack-trees: print "Aborting" to stderrMichael J Gruber2011-09-21
| |/ | | | | | | | | | | | | | | | | display_error_msgs() prints all the errors to stderr already (if any), followed by "Aborting" (if any) to stdout. Make the latter go to stderr instead. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/diff-index-unpack'Junio C Hamano2011-10-05
|\ \ | | | | | | | | | | | | | | | | | | * jc/diff-index-unpack: diff-index: pass pathspec down to unpack-trees machinery unpack-trees: allow pruning with pathspec traverse_trees(): allow pruning with pathspec
| * | unpack-trees: allow pruning with pathspecJunio C Hamano2011-08-29
| |/ | | | | | | | | | | | | | | | | | | | | Use the pathspec pruning of traverse_trees() from unpack_trees(). Again, the unpack_trees() machinery is primarily meant for merging two (or more) trees, and because a merge is a full tree operation, it didn't support any pruning with pathspec, and this codepath probably should not be enabled while running a merge, but the caller in diff-lib.c::diff_cache() should be able to take advantage of it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'maint'Junio C Hamano2011-07-31
|\ \ | | | | | | | | | | | | | | | | | | * maint: Break down no-lstat() condition checks in verify_uptodate() t7400: fix bogus test failure with symlinked trash Documentation: clarify the invalidated tree entry format
| * | Break down no-lstat() condition checks in verify_uptodate()Nguyễn Thái Ngọc Duy2011-07-31
| |/ | | | | | | | | | | | | | | | | Make it easier to grok under what conditions we can skip lstat(). While at there, shorten ie_match_stat() line for the sake of my eyes. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/diff-index-quick-exit-early'Junio C Hamano2011-06-29
|\ \ | |/ |/| | | | | | | | | | | * jc/diff-index-quick-exit-early: diff-index --quiet: learn the "stop feeding the backend early" logic Conflicts: unpack-trees.h
| * diff-index --quiet: learn the "stop feeding the backend early" logicJunio C Hamano2011-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A negative return from the unpack callback function usually means unpack failed for the entry and signals the unpack_trees() machinery to fail the entire merge operation, immediately and there is no other way for the callback to tell the machinery to exit early without reporting an error. This is what we usually want to make a merge all-or-nothing operation, but the machinery is also used for diff-index codepath by using a custom unpack callback function. And we do sometimes want to exit early without failing, namely when we are under --quiet and can short-cut the diff upon finding the first difference. Add "exiting_early" field to unpack_trees_options structure, to signal the unpack_trees() machinery that the negative return value is not signaling an error but an early return from the unpack_trees() machinery. As this by definition hasn't unpacked everything, discard the resulting index just like the failure codepath. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | unpack-trees: add the dry_run flag to unpack_trees_optionsJens Lehmann2011-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now there was no way to test if unpack_trees() with update=1 would succeed without really updating the work tree. The reason for that is that setting update to 0 does skip the tests for new files and deactivates the sparse handling, thereby making that unsuitable as a dry run. Add the new dry_run flag to struct unpack_trees_options unpack_trees(). Setting that together with the update flag will check if the work tree update would be successful without doing it for real. The only class of problems that is not detected at the moment are file system conditions like ENOSPC or missing permissions. Also the index entries of updated files are not as they would be after a real checkout because lstat() isn't run as the files aren't updated for real. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | sparse checkout: do not eagerly decide the fate for whole directoryNguyễn Thái Ngọc Duy2011-05-10
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sparse-setting code follows closely how files are excluded in read_directory(), every entry (including directories) are fed to excluded_from_list() to decide if the entry is suitable. Directories are treated no different than files. If a directory is matched (or not), the whole directory is considered matched (or not) and the process moves on. This generally works as long as there are no patterns to exclude parts of the directory. In case of sparse checkout code, the following patterns t !t/t0000-basic.sh will produce a worktree with full directory "t" even if t0000-basic.sh is requested to stay out. By the same reasoning, if a directory is to be excluded, any rules to re-include certain files within that directory will be ignored. Fix it by always checking files against patterns. If no pattern can be used to decide whether an entry is in our out (ie. excluded_from_list() returns -1), the entry will be included/excluded the same as their parent directory. Noticed-by: <skillzero@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix sparse warningsStephen Boyd2011-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix warnings from 'make check'. - These files don't include 'builtin.h' causing sparse to complain that cmd_* isn't declared: builtin/clone.c:364, builtin/fetch-pack.c:797, builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78, builtin/merge-index.c:69, builtin/merge-recursive.c:22 builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426 builtin/notes.c:822, builtin/pack-redundant.c:596, builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149, builtin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25, builtin/var.c:75 - These files have symbols which should be marked static since they're only file scope: submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13, submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79, unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123, url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48 - These files redeclare symbols to be different types: builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571, usage.c:49, usage.c:58, usage.c:63, usage.c:72 - These files use a literal integer 0 when they really should use a NULL pointer: daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362 While we're in the area, clean up some unused #includes in builtin files (mostly exec_cmd.h). Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Revert "unpack_trees(): skip trees that are the same in all input"Junio C Hamano2011-02-15
| | | | | | This reverts commit 83c90314aa27ae3768c04375d02e4f3fb12b726d, which seems to have broken merge to report conflicts when there should be none.
* Merge branch 'jc/unpack-trees'Junio C Hamano2011-02-09
|\ | | | | | | | | | | | | | | | | * jc/unpack-trees: unpack_trees(): skip trees that are the same in all input unpack-trees.c: cosmetic fix Conflicts: unpack-trees.c
| * unpack_trees(): skip trees that are the same in all inputJunio C Hamano2011-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unpack_trees() merges two trees (the current HEAD and the destination commit) when switching to another branch, checking and updating the index entry where the destination differs from the current HEAD. It merges three trees (the common ancestor, the current HEAD and the other commit) when performing a three-way merge, checking and updating the index entry when the merge result differs from the current HEAD. It does so by walking the input trees in parallel all the way down to the leaves. One common special case is a directory is identical across the trees involved in the merge. In such a case, we do not have to descend into the directory at all---we know that the end result is to keep the entries in the current index. This optimization cannot be applied in a few special cases in unpack_trees(), though. We need to descend into the directory and update the index entries from the target tree in the following cases: - When resetting (e.g. "git reset --hard"); and - When checking out a tree for the first time into an empty working tree (e.g. "git read-tree -m -u HEAD HEAD" with missing .git/index). Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * unpack-trees.c: cosmetic fixJunio C Hamano2010-12-22
| | | | | | | | | | | | Make the parts a bit more readable before touching them. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jn/unpack-lstat-failure-report'Junio C Hamano2011-02-09
|\ \ | | | | | | | | | | | | | | | * jn/unpack-lstat-failure-report: unpack-trees: handle lstat failure for existing file unpack-trees: handle lstat failure for existing directory
| * | unpack-trees: handle lstat failure for existing fileJonathan Nieder2011-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When check_leading_path notices a file in the way of a new entry to be checked out, verify_absent uses (1) the mode to determine whether it is a directory (2) the rest of the stat information to check if this is actually an old entry, disguised by a change in filename (e.g., README -> Readme) that is significant to git but insignificant to the underlying filesystem. If lstat fails, these checks are performed with an uninitialied stat structure, producing essentially random results. Better to just error out when lstat fails. The easiest way to reproduce this is to remove a file after the check_leading_path call and before the lstat in verify_absent. An lstat failure other than ENOENT in check_leading_path would also trigger the same code path. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | unpack-trees: handle lstat failure for existing directoryJonathan Nieder2011-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When check_leading_path notices no file in the way of the new entry to be checked out, verify_absent checks whether there is a directory there or nothing at all. If that lstat call fails (for example due to ENOMEM), it assumes ENOENT, meaning a directory with untracked files would be clobbered in that case. Check errno after calling lstat, and for conditions other than ENOENT, just error out. This is a theoretical race condition. lstat has to succeed moments before it fails for there to be trouble. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | use persistent memory for rejected pathsClemens Buchacher2010-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An aborted merge prints the list of rejected paths as part of the error message. Since commit f66caaf9 (do not overwrite files in leading path), some of those paths do not have static buffers, so we have to keep a copy. Use string_list's to accomplish this. This changes the order of the list to the order in which the paths are processed. Previously, it was reversed. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | do not overwrite files in leading pathClemens Buchacher2010-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the work tree contains an untracked file x, and unpack-trees wants to checkout a path x/*, the file x is removed unconditionally. Instead, apply the same checks that are normally used for untracked files, and abort if the file cannot be removed. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | add function check_ok_to_remove()Clemens Buchacher2010-12-14
| | | | | | | | | | | | | | | | | | | | | | | | This wraps some inline code into the function check_ok_to_remove(), which will later be used for leading path components as well. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'nd/maint-fix-add-typo-detection'Junio C Hamano2010-12-22
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | * nd/maint-fix-add-typo-detection: Revert "excluded_1(): support exclude files in index" unpack-trees: fix sparse checkout's "unable to match directories" unpack-trees: move all skip-worktree checks back to unpack_trees() dir.c: add free_excludes() cache.h: realign and use (1 << x) form for CE_* constants
| * | unpack-trees: fix sparse checkout's "unable to match directories"Nguyễn Thái Ngọc Duy2010-11-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Matching index entries against an excludes file currently has two problems. First, there's no function to do it. Code paths (like sparse checkout) that wanted to try it would iterate over index entries and for each index entry pass that path to excluded_from_list(). But that is not how excluded_from_list() works; one is supposed to feed in each ancester of a path before a given path to find out if it was excluded because of some parent or grandparent matching a bigsubdirectory/ pattern despite the path not matching any .gitignore pattern directly. Second, it's inefficient. The excludes mechanism is supposed to let us block off vast swaths of the filesystem as uninteresting; separately checking every index entry doesn't fit that model. Introduce a new function to take care of both these problems. This traverses the index in depth-first order (well, that's what order the index is in) to mark un-excluded entries. Maybe some day the in-core index format will be restructured to make this sort of operation easier. Or maybe we will want to try some binary search based thing. The interface is simple enough to allow all those things. Example: clear_ce_flags(the_index.cache, the_index.cache_nr, CE_CANDIDATE, CE_CLEARME, exclude_list); would clear the CE_CLEARME flag on all index entries with CE_CANDIDATE flag and not matched by exclude_list. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | unpack-trees: move all skip-worktree checks back to unpack_trees()Nguyễn Thái Ngọc Duy2010-11-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Earlier, the will_have_skip_worktree() checks are done in various places, which makes it hard to traverse the index tree-alike, required by excluded_from_list(). This patch moves all the checks into two loops in unpack_trees(). Entries in index in this operation can be classified into two groups: ones already in index before unpack_trees() is called and ones added to index after traverse_trees() is called. In both groups, before checking file status on worktree, the future skip-worktree bit must be checked, so that if an entry will be outside worktree, worktree should not be checked. For the first group, the future skip-worktree bit is precomputed and stored as CE_NEW_SKIP_WORKTREE in the first loop before traverse_trees() is called so that *way_merge() function does not need to compute it again. For the second group, because we don't know what entries will be in this group until traverse_trees() finishes, operations that need future skip-worktree check is delayed until CE_NEW_SKIP_WORKTREE is computed in the second loop. CE_ADDED is used to mark entries in the second group. CE_ADDED and CE_NEW_SKIP_WORKTREE are temporary flags used in unpack_trees(). CE_ADDED is only used by add_to_index(), which should not be called while unpack_trees() is running. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | dir.c: add free_excludes()Nguyễn Thái Ngọc Duy2010-11-29
| |/ | | | | | | | | Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | use persistent memory for rejected pathsClemens Buchacher2010-11-15
| | | | | | | | | | | | | | | | | | | | | | | | | | An aborted merge prints the list of rejected paths as part of the error message. Since commit f66caaf9 (do not overwrite files in leading path), some of those paths do not have static buffers, so we have to keep a copy. Use string_list's to accomplish this. This changes the order of the list to the order in which the paths are processed. Previously, it was reversed. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | do not overwrite files in leading pathClemens Buchacher2010-10-13
| | | | | | | | | | | | | | | | | | | | | | | | If the work tree contains an untracked file x, and unpack-trees wants to checkout a path x/*, the file x is removed unconditionally. Instead, apply the same checks that are normally used for untracked files, and abort if the file cannot be removed. Signed-off-by: Clemens Buchacher <drizzd@aon.at>
* | add function check_ok_to_remove()Clemens Buchacher2010-10-13
|/ | | | | | | This wraps some inline code into the function check_ok_to_remove(), which will later be used for leading path components as well. Signed-off-by: Clemens Buchacher <drizzd@aon.at>
* Merge branch 'dg/local-mod-error-messages'Junio C Hamano2010-09-03
|\ | | | | | | | | | | | | | | | | | | | | * dg/local-mod-error-messages: t7609-merge-co-error-msgs: test non-fast forward case too. Move "show_all_errors = 1" to setup_unpack_trees_porcelain() setup_unpack_trees_porcelain: take the whole options struct as parameter Move set_porcelain_error_msgs to unpack-trees.c and rename it Conflicts: merge-recursive.c
| * Move "show_all_errors = 1" to setup_unpack_trees_porcelain()Matthieu Moy2010-09-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not only this makes the code clearer since setting up the porcelain error message is meant to work with show_all_errors, but this fixes a call to setup_unpack_trees_porcelain() in git_merge_trees() which did not set show_all_errors. add_rejected_path() used to double-check whether it was running in plumbing mode. This check was ineffective since it was setting show_all_errors too late for traverse_trees() to see it, and is made useless by this patch. Remove it. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * setup_unpack_trees_porcelain: take the whole options struct as parameterMatthieu Moy2010-09-03
| | | | | | | | | | | | | | | | This is a preparation patch to let setup_unpack_trees_porcelain set show_all_errors itself. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Move set_porcelain_error_msgs to unpack-trees.c and rename itMatthieu Moy2010-09-03
| | | | | | | | | | | | | | | | | | The function is currently dealing only with error messages, but the intent of calling it is really to notify the unpack-tree mechanics that it is running in porcelain mode. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'nd/fix-sparse-checkout'Junio C Hamano2010-08-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * nd/fix-sparse-checkout: unpack-trees: mark new entries skip-worktree appropriately unpack-trees: do not check for conflict entries too early unpack-trees: let read-tree -u remove index entries outside sparse area unpack-trees: only clear CE_UPDATE|CE_REMOVE when skip-worktree is always set t1011 (sparse checkout): style nitpicks