1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-16 14:04:52 +01:00
Find a file
Junio C Hamano 64cab59159 apply: do not get confused by symlinks in the middle
HPA noticed that git-rebase fails when changes involve symlinks
in the middle of the hierarchy.  Consider:

 * The tree state before the patch is applied has arch/x86_64/boot
   as a symlink pointing at ../i386/boot/

 * The patch tries to remove arch/x86_64/boot symlink, and
   create bunch of files there: .gitignore, Makefile, etc.

git-apply tries to be careful while applying patches; it never
touches the working tree until it is convinced that the patch
would apply cleanly.  One of the check it does is that when it
knows a path is going to be created by the patch, it runs
lstat() on the path to make sure it does not exist.

This leads to a false alarm.  Because we do not touch the
working tree before all the check passes, when we try to make
sure that arch/x86_64/boot/.gitignore does not exist yet, we
haven't removed the arch/x86_64/boot symlink.  The lstat() check
ends up seeing arch/i386/boot/.gitignore through the
yet-to-be-removed symlink, and says "Hey, you already have a
file there, but what you fed me is a patch to create a new
file. I am not going to clobber what you have in the working
tree."

We have similar checks to see a file we are going to modify does
exist and match the preimage of the diff, which is done by
directly opening and reading the file.

For a file we are going to delete, we make sure that it does
exist and matches what is going to be removed (a removal patch
records the full preimage, so we check what you have in your
working tree matches it in full -- otherwise we would risk
losing your local changes), which again is done by directly
opening and reading the file.

These checks need to be adjusted so that they are not fooled by
symlinks in the middle.

 - To make sure something does not exist, first lstat().  If it
   does not exist, it does not, so be happy.  If it _does_, we
   might be getting fooled by a symlink in the middle, so break
   leading paths and see if there are symlinks involved.  When
   we are checking for a path a/b/c/d, if any of a, a/b, a/b/c
   is a symlink, then a/b/c/d does _NOT_ exist, for the purpose
   of our test.

   This would fix this particular case you saw, and would not
   add extra overhead in the usual case.

 - To make sure something already exists, first lstat().  If it
   does not exist, barf (up to this, we already do).  Even if it
   does seem to exist, we might be getting fooled by a symlink
   in the middle, so make sure leading paths are not symlinks.

   This would make the normal codepath much more expensive for
   deep trees, which is a bit worrisome.

This patch implements the first side of the check "making sure
it does not exist".  The latter "making sure it exists" check is
not done yet, so applying the patch in reverse would still
fail, but we have to start from somewhere.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-11 22:26:08 -07:00
arm
compat
contrib Merge branch 'maint' 2007-05-10 14:48:04 -07:00
Documentation Minor copyediting on Release Notes for 1.5.2 2007-05-10 21:59:13 -07:00
git-gui Merge branch 'master' of git://repo.or.cz/git-gui 2007-05-10 15:08:18 -07:00
gitweb gitweb: Do not use absolute font sizes 2007-05-10 14:13:29 -07:00
mozilla-sha1
perl Git.pm: config_boolean() -> config_bool() 2007-05-10 14:13:29 -07:00
ppc
t apply: do not get confused by symlinks in the middle 2007-05-11 22:26:08 -07:00
templates Have sample update hook not refuse deleting a branch through push. 2007-04-16 01:35:39 -07:00
xdiff
.gitignore git-gui: Refactor into multiple files to save my sanity 2007-05-07 23:35:48 -04:00
.mailmap .mailmap: add some aliases 2007-05-10 13:26:26 -07:00
alloc.c Clean up object creation to use more common code 2007-04-16 23:36:16 -07:00
archive-tar.c
archive-zip.c
archive.h
attr.c Fix crash in t0020 (crlf conversion) 2007-04-22 10:44:56 -07:00
attr.h Fix funny types used in attribute value representation 2007-04-18 16:17:13 -07:00
base85.c (encode_85, decode_85): Mark source buffer pointer as "const". 2007-04-11 00:51:20 -07:00
blob.c Clean up object creation to use more common code 2007-04-16 23:36:16 -07:00
blob.h
builtin-add.c git-add -u: match the index with working tree. 2007-04-20 01:47:47 -07:00
builtin-annotate.c
builtin-apply.c apply: do not get confused by symlinks in the middle 2007-05-11 22:26:08 -07:00
builtin-archive.c git-archive: make tar the default format 2007-04-09 18:51:40 -07:00
builtin-blame.c Merge branch 'maint' 2007-05-06 00:21:03 -07:00
builtin-branch.c Make builtin-branch.c handle the git config file 2007-04-06 16:54:39 -07:00
builtin-bundle.c Rename warn() to warning() to fix symbol conflicts on BSD and Mac OS 2007-03-31 01:11:11 -07:00
builtin-cat-file.c Cleanup variables in cat-file 2007-04-22 00:43:24 -07:00
builtin-check-attr.c Fix funny types used in attribute value representation 2007-04-18 16:17:13 -07:00
builtin-check-ref-format.c
builtin-checkout-index.c _GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file. 2007-04-03 23:44:32 -07:00
builtin-commit-tree.c init_buffer(): Kill buf pointer 2007-04-25 13:45:12 -07:00
builtin-config.c Update git-config documentation 2007-04-18 22:08:16 -07:00
builtin-count-objects.c get rid of num_packed_objects() 2007-04-10 12:48:14 -07:00
builtin-describe.c
builtin-diff-files.c Removing -n option from git-diff-files documentation 2007-04-26 22:43:10 -07:00
builtin-diff-index.c
builtin-diff-tree.c
builtin-diff.c Diff between two blobs should take mode changes into account now. 2007-04-24 00:08:49 -07:00
builtin-fetch--tool.c Merge branch 'maint' 2007-04-29 01:52:43 -07:00
builtin-fmt-merge-msg.c
builtin-for-each-ref.c
builtin-fsck.c Merge branch 'maint' 2007-04-29 01:52:43 -07:00
builtin-gc.c
builtin-grep.c sscanf/strtoul: parse integers robustly 2007-04-14 19:47:20 -07:00
builtin-init-db.c
builtin-log.c Add support for "commit name decorations" to log family of commands 2007-04-16 16:51:11 -07:00
builtin-ls-files.c Fix some "git ls-files -o" fallout from gitlinks 2007-04-14 17:42:58 -07:00
builtin-ls-tree.c Teach core object handling functions about gitlinks 2007-04-10 13:50:43 -07:00
builtin-mailinfo.c git-mailinfo fixes for patch munging 2007-03-31 00:59:19 -07:00
builtin-mailsplit.c
builtin-merge-base.c
builtin-merge-file.c
builtin-mv.c Merge branch 'jc/index-output' 2007-04-07 02:26:24 -07:00
builtin-name-rev.c
builtin-pack-objects.c Increase pack.depth default to 50 2007-05-08 22:47:17 -07:00
builtin-pack-refs.c
builtin-prune-packed.c
builtin-prune.c
builtin-push.c git-push to multiple locations does not stop at the first failure 2007-04-07 02:27:31 -07:00
builtin-read-tree.c Merge branch 'jc/read-tree-df' (early part) 2007-04-07 23:52:40 -07:00
builtin-reflog.c
builtin-rerere.c rerere: make sorting really stable. 2007-04-04 14:12:03 -07:00
builtin-rev-list.c Add --date={local,relative,default} 2007-04-25 21:39:43 -07:00
builtin-rev-parse.c
builtin-revert.c Correct error message in revert/cherry-pick 2007-05-10 15:21:50 -07:00
builtin-rm.c Add --ignore-unmatch option to exit with zero status when no files are removed. 2007-04-17 00:19:11 -07:00
builtin-runstatus.c
builtin-shortlog.c Remove pointless calls to access(2) when checking for .mailmap 2007-04-30 16:57:52 -07:00
builtin-show-branch.c
builtin-show-ref.c
builtin-stripspace.c
builtin-symbolic-ref.c
builtin-tar-tree.c
builtin-unpack-objects.c make progress "title" part of the common progress interface 2007-04-22 22:18:05 -07:00
builtin-update-index.c Merge branch 'lt/gitlink' 2007-04-21 17:21:10 -07:00
builtin-update-ref.c
builtin-upload-archive.c
builtin-verify-pack.c
builtin-write-tree.c Merge branch 'maint' 2007-04-25 23:31:45 -07:00
builtin.h Add basic infrastructure to assign attributes to paths 2007-04-14 08:57:06 -07:00
cache-tree.c Teach core object handling functions about gitlinks 2007-04-10 13:50:43 -07:00
cache-tree.h
cache.h Add has_symlink_leading_path() function. 2007-05-11 22:11:07 -07:00
check-builtins.sh
check-racy.c
color.c
color.h
combine-diff.c Support 'diff=pgm' attribute 2007-04-22 22:16:14 -07:00
commit.c Merge branch 'maint' 2007-05-06 00:21:03 -07:00
commit.h Add --date={local,relative,default} 2007-04-25 21:39:43 -07:00
config.c Fix renaming branch without config file 2007-04-05 14:53:22 -07:00
config.mak.in Add --with-tcltk and --without-tcltk to configure. 2007-03-31 23:59:47 -07:00
configure.ac Eliminate checks of user-specified Tcl/Tk interpreter. 2007-03-31 23:59:47 -07:00
connect.c Fix "getaddrinfo()" buglet 2007-03-27 13:00:13 -07:00
convert-objects.c fix up strtoul_ui error handling 2007-04-18 19:26:33 -07:00
convert.c Add 'filter' attribute and external filter driver definition. 2007-04-24 22:38:51 -07:00
copy.c
COPYING
csum-file.c compute a CRC32 for each object as stored in a pack 2007-04-10 12:48:14 -07:00
csum-file.h compute a CRC32 for each object as stored in a pack 2007-04-10 12:48:14 -07:00
ctype.c
daemon.c
date.c Add --date={local,relative,default} 2007-04-25 21:39:43 -07:00
decorate.c Fix a copy-n-paste bug in the object decorator code. 2007-04-20 19:16:12 -07:00
decorate.h Add a generic "object decorator" interface, and make object refs use it 2007-04-16 16:51:09 -07:00
delta.h
diff-delta.c
diff-lib.c Merge branch 'lt/gitlink' 2007-04-21 17:21:10 -07:00
diff.c diff.c: do not use a separate "size cache". 2007-05-07 15:54:32 -07:00
diff.h Support 'diff=pgm' attribute 2007-04-22 22:16:14 -07:00
diffcore-break.c
diffcore-delta.c
diffcore-order.c
diffcore-pickaxe.c diff -S: release the image after looking for needle in it 2007-05-07 15:54:32 -07:00
diffcore-rename.c diff -M: release the preimage candidate blobs after rename detection. 2007-05-07 15:54:32 -07:00
diffcore.h Make macros to prevent double-inclusion in headers consistent. 2007-04-29 02:05:11 -07:00
dir.c dir.c: Omit non-excluded directories with dir->show_ignored 2007-05-07 15:29:29 -07:00
dir.h Teach directory traversal about subprojects 2007-04-11 19:09:55 -07:00
dump-cache-tree.c
entry.c entry.c: Use const qualifier for 'struct checkout' parameters 2007-04-25 13:15:59 -07:00
environment.c
exec_cmd.c
exec_cmd.h Make macros to prevent double-inclusion in headers consistent. 2007-04-29 02:05:11 -07:00
fast-import.c Create pack-write.c for common pack writing code 2007-05-02 13:24:18 -04:00
fetch-pack.c
fetch.c
fetch.h
generate-cmdlist.sh
git-add--interactive.perl
git-am.sh Fix typo in git-am: s/Was is/Was it/ 2007-04-23 22:14:24 -07:00
git-applymbox.sh applymbox & quiltimport: typofix. 2007-04-24 14:27:41 -07:00
git-applypatch.sh
git-archimport.perl
git-bisect.sh Bisect: simplify "bisect start" logging. 2007-04-16 21:44:40 -07:00
git-checkout.sh add file checkout progress 2007-04-23 21:39:28 -07:00
git-clean.sh Add clean.requireForce option, and add -f option to git-clean to override it 2007-04-23 22:13:50 -07:00
git-clone.sh git-clone: don't get fooled by $PWD 2007-05-10 13:26:14 -07:00
git-commit.sh Display the subject of the commit just made. 2007-04-16 01:06:00 -07:00
git-compat-util.h Merge branch 'maint' 2007-05-03 23:26:54 -07:00
git-cvsexportcommit.perl cvsexportcommit -p : fix the usage of git-apply -C. 2007-04-09 18:52:41 -07:00
git-cvsimport.perl cvsimport: Improve usage error reporting 2007-04-06 16:46:11 -07:00
git-cvsserver.perl Merge branch 'maint' 2007-05-02 11:27:31 -07:00
git-fetch.sh git-fetch: Fix "argument list too long" 2007-04-24 00:08:01 -07:00
git-instaweb.sh
git-lost-found.sh Fix lost-found to show commits only referenced by reflogs 2007-04-05 15:00:03 -07:00
git-ls-remote.sh
git-merge-octopus.sh
git-merge-one-file.sh
git-merge-ours.sh Use diff* with --exit-code in git-am, git-rebase and git-merge-ours 2007-03-24 23:01:36 -07:00
git-merge-resolve.sh
git-merge-stupid.sh
git-merge.sh A new merge stragety 'subtree'. 2007-04-07 02:29:40 -07:00
git-mergetool.sh mergetool: Clean up description of files and prompts for merge resolutions 2007-03-29 22:46:16 -04:00
git-p4import.py
git-parse-remote.sh
git-pull.sh
git-quiltimport.sh applymbox & quiltimport: typofix. 2007-04-24 14:27:41 -07:00
git-rebase.sh Use rev-list --reverse in git-rebase.sh 2007-04-13 19:06:40 -07:00
git-relink.perl
git-remote.perl Git.pm: config_boolean() -> config_bool() 2007-05-10 14:13:29 -07:00
git-repack.sh
git-request-pull.sh Improve request-pull to handle non-rebased branches 2007-05-03 23:27:03 -07:00
git-reset.sh add file checkout progress 2007-04-23 21:39:28 -07:00
git-send-email.perl Git.pm: config_boolean() -> config_bool() 2007-05-10 14:13:29 -07:00
git-sh-setup.sh
git-svn.perl Add --no-rebase option to git-svn dcommit 2007-05-04 15:08:31 -07:00
git-svnimport.perl
git-tag.sh
git-verify-tag.sh
GIT-VERSION-GEN GIT v1.5.2-rc3 2007-05-10 15:22:02 -07:00
git.c Add basic infrastructure to assign attributes to paths 2007-04-14 08:57:06 -07:00
git.spec.in Added new git-gui library files to rpm spec 2007-05-10 00:09:28 -07:00
gitk gitk: Allow user to choose whether to see the diff, old file, or new file 2007-04-19 11:39:12 +10:00
grep.c
grep.h
hash-object.c
help.c use xrealloc in help.c 2007-03-27 16:57:57 -07:00
http-fetch.c Fix lseek(2) calls with args 2 and 3 swapped 2007-04-05 15:39:12 -07:00
http-push.c Fix lseek(2) calls with args 2 and 3 swapped 2007-04-05 15:39:12 -07:00
http.c http.c: Fix problem with repeated calls of http_init 2007-04-29 01:34:59 -07:00
http.h http-fetch: Disable use of curl multi support for libcurl < 7.16. 2007-05-03 22:12:40 -07:00
ident.c Fall back to $EMAIL for missing GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL 2007-04-29 02:05:06 -07:00
imap-send.c
index-pack.c Reuse fixup_pack_header_footer in index-pack 2007-05-02 13:24:21 -04:00
INSTALL
interpolate.c
interpolate.h
list-objects.c Teach git list-objects logic to not follow gitlinks 2007-04-14 03:14:14 -07:00
list-objects.h
local-fetch.c
lockfile.c lockfile: record the primary process. 2007-04-21 11:55:23 -07:00
log-tree.c Merge branch 'maint' 2007-05-06 00:21:03 -07:00
log-tree.h
mailmap.c Include mailmap.h in mailmap.c to catch mailmap interface changes 2007-04-30 16:57:59 -07:00
mailmap.h Split out mailmap handling out of shortlog 2007-04-29 02:05:06 -07:00
Makefile apply: do not get confused by symlinks in the middle 2007-05-11 22:26:08 -07:00
match-trees.c A new merge stragety 'subtree'. 2007-04-07 02:29:40 -07:00
merge-file.c
merge-index.c
merge-recursive.c Ignore merged status of the file-level merge 2007-04-26 16:11:39 -07:00
merge-tree.c
mktag.c
mktree.c
object-refs.c Add a generic "object decorator" interface, and make object refs use it 2007-04-16 16:51:09 -07:00
object.c add add_object_array_with_mode 2007-04-24 00:08:49 -07:00
object.h add add_object_array_with_mode 2007-04-24 00:08:49 -07:00
pack-check.c get rid of num_packed_objects() 2007-04-10 12:48:14 -07:00
pack-redundant.c pack-redundant.c: learn about index v2 2007-04-10 12:48:14 -07:00
pack-write.c Create pack-write.c for common pack writing code 2007-05-02 13:24:18 -04:00
pack.h Create pack-write.c for common pack writing code 2007-05-02 13:24:18 -04:00
pager.c
patch-delta.c
patch-id.c
patch-ids.c Refactor patch-id filtering out of git-cherry and git-format-patch. 2007-04-11 20:02:03 -07:00
patch-ids.h Refactor patch-id filtering out of git-cherry and git-format-patch. 2007-04-11 20:02:03 -07:00
path-list.c
path-list.h Make macros to prevent double-inclusion in headers consistent. 2007-04-29 02:05:11 -07:00
path.c
peek-remote.c
pkt-line.c
pkt-line.h
progress.c provide a facility for "delayed" progress reporting 2007-04-22 22:18:05 -07:00
progress.h Make macros to prevent double-inclusion in headers consistent. 2007-04-29 02:05:11 -07:00
quote.c
quote.h
reachable.c
reachable.h
read-cache.c read_cache_from(): small simplification 2007-04-25 13:44:27 -07:00
README Update README to point at a few key periodical messages to the list 2007-03-25 17:42:32 -07:00
receive-pack.c
reflog-walk.c
reflog-walk.h
refs.c Merge branch 'lt/gitlink' 2007-04-21 17:21:10 -07:00
refs.h Add 'resolve_gitlink_ref()' helper function 2007-04-10 13:44:16 -07:00
RelNotes GIT v1.5.1.4 2007-05-08 22:11:17 -07:00
revision.c Handle return code of parse_commit in revision machinery 2007-05-06 00:07:07 -07:00
revision.h Handle return code of parse_commit in revision machinery 2007-05-06 00:07:07 -07:00
rsh.c
rsh.h
run-command.c
run-command.h
send-pack.c
server-info.c
setup.c
sha1_file.c Merge branch 'maint' 2007-04-25 23:31:45 -07:00
sha1_name.c add get_sha1_with_mode 2007-04-24 00:08:49 -07:00
shallow.c
shell.c
show-index.c show-index.c: learn about index v2 2007-04-10 12:48:14 -07:00
sideband.c
sideband.h
ssh-fetch.c
ssh-pull.c
ssh-push.c
ssh-upload.c
strbuf.c
strbuf.h
symlinks.c Add has_symlink_leading_path() function. 2007-05-11 22:11:07 -07:00
tag.c Clean up object creation to use more common code 2007-04-16 23:36:16 -07:00
tag.h
tar.h
test-chmtime.c
test-date.c
test-delta.c Fix compilation of test-delta 2007-05-01 02:59:08 -07:00
test-genrandom.c simple random data generator for tests 2007-04-11 19:23:32 -07:00
test-match-trees.c A new merge stragety 'subtree'. 2007-04-07 02:29:40 -07:00
test-sha1.c
test-sha1.sh
trace.c
tree-diff.c
tree-walk.c
tree-walk.h
tree.c Merge branch 'lt/objalloc' 2007-04-21 17:42:02 -07:00
tree.h
unpack-file.c
unpack-trees.c delay progress display when checking out files 2007-04-22 22:18:05 -07:00
unpack-trees.h unpack-trees: get rid of *indpos parameter. 2007-04-04 00:19:28 -07:00
update-server-info.c
upload-pack.c git-upload-pack: make sure we close unused pipe ends 2007-03-29 01:41:23 -07:00
usage.c Rename warn() to warning() to fix symbol conflicts on BSD and Mac OS 2007-03-31 01:11:11 -07:00
utf8.c wcwidth redeclaration 2007-05-07 22:02:40 -07:00
utf8.h
var.c
write_or_die.c
wt-status.c Optimize directory listing with pathspec limiter. 2007-03-31 17:41:32 -07:00
wt-status.h
xdiff-interface.c
xdiff-interface.h

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

	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.