This introduces the concept of git "library" objects that
the real programs use, and makes it easier to add such things
to a "libgit.a".
This will also make it trivial to split the current "read-cache.o"
into more aptly named pieces (it does a lot more than just read
the index file).
They sure as hell aren't perfect, but they allow you to do:
./git-pull-script {other-git-directory}
to do the initial merge, and if that had content clashes, you do
merge-cache ./git-merge-one-file-script -a
which tries to auto-merge. When/if the auto-merge fails, it will
leave the last file in your working directory, and you can edit
it and then when you're happy you can do "update-cache filename"
on it. Re-do the merge-cache thing until there are no files left
to be merged, and now you can write the tree and commit:
write-tree
commit-tree .... -p $(cat .git/HEAD) -p $(cat .git/MERGE_HEAD)
and you're done.
I noticed this when I tried a non-trivial scsi merge and checked the
results against BK. The problem is that remove_entry_at() actually
decrements active_nr, so decrementing it in add_cache_entry() before
calling remove_entry_at() is a double decrement (hence we lose cache
entries at the end).
This switches to my implementation of merge-base, but with the new parsing
library.
Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This ports fsck-cache to use parsing functions. Note that performance
could be improved here by only reading each object once, but this requires
somewhat more complicated flow control.
Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This ports rev-tree to use the parsing functions introduced in the
previous patches.
Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This adds the structs and function declarations for parsing git objects.
Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The "update-cache --refresh" command attempts refresh_entry()
on unmerged path, which results in as many "needs update" messages
as there are unmerged stages for that path. This does not do
any harm to the working directory, but it is confusing.
Here is a fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The patch to introduce shell safety to show-diff has an
off-by-one error. Here is an fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Fix remove_specials for real. The second half logic needs the original
head of the string.
Signed-off-by: Brad Roberts <braddr@puremagic.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Also, make it a fatal error to pass in a non-commit object. The callers
never checked, so better check here.
This simplifies merge-base further. It's now so trivial that it's almost
ridiculous.
parent of two commits.
The question of "best" commit can probably be tweaked almost arbitrarily.
In particular, trying to take things like how big the tree differences
are into account migt be a good idea. This one is just very simple.
- mark_reachable() can be more generic, marking the reachable revisions
with an arbitrary mask.
- date parsing will parse to a date of 0 rather than ULONG_MAX for the
bad old case, sorting the dates correctly.
This also drops the old-style date parsing. We just don't care
enough, since we dropped that format pretty early.
Yes, this could do with some cleanup, and a common library file.
Some day.
This fixes show-diff listing all +x files as differring.
Signed-off-by: Petr Baudis <pasky@ucw.cz>
[ That's what I get for working on a G5 - my testing was all
big-endian in the first place. -- Linus ]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The function index_fd() in update-cache.c takes 5 arguments, but
two is not necessary and one that is a pointer to a structure
really needs to be a pointer to one member of that structure.
This patch cleans it up.
Also it removes printf() apparently left after initial
debugging.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The checkout-cache command says "file is not in the cache" when
an unmerged path is given. This patch adds code to distinguish
the unmerged and the nonexistent cases and gives an appropriate
error message.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Use the proper octal mode naming instead of random decimal
crud, and don't reset the mode after the create with fchmod:
the whole point was to let "umask" do its thing.
Duh.
When update-cache --remove is run, resolve unmerged state for
the path. This is consistent with the update-cache --add
behaviour. Essentially, the user is telling us how he wants to
resolve the merge by running update-cache.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Fixed to do the right thing at the end.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This is my bad. I added #include <ctype.h> to the file,
which I ended up not using and failed to remove it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
When run on unmerged dircache, show-diff compares the working
file with each non-empty stage for that path. Two out of three
times, this is not very helpful. This patch makes it report the
unmergedness only once per each path and avoids running the
actual diff.
Upper layer SCMs like Cogito are expected to find out mode/SHA1
for each stage by using "show-files --stage" and run the diff
itself. This would result in more sensible diffs.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This fixes some stylistic problems introduced by my previous set
of patches. I'll be sending my last patch to show-diff next,
which depends on this cleanup.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The show-diff command uses a variable "new" but it is always
used to point at the original data recorded in the dircache
before the user started editing in the working file. Rename it
to "old" to avoid confusion.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The command line for running "diff" command is built without
taking shell metacharacters into account. A malicious dircache
entry "foo 2>bar" (yes, a filename with space) would result in
creating a file called "bar" with the error message "diff: foo:
No such file or directory" in it.
This is not just a user screwing over himself. Such a dircache
can be created as a result of a merge with tree from others.
Here is a fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This patch adds the -z option to the show-diff command,
primarily for use by scripts. The information emitted is
similar to that of -q option, but in a more machine readable
form. Records are terminated with NUL instead of LF, so that
the scripts can deal with pathnames with embedded newlines.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
SCMs have ways to say "I want diff only this particular file",
or "I want diff files under this directory". This patch teaches
show-diff to do something similar. Without command line
arguments, it still examines everything in the dircache as
before.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
ls-tree unconditionally called read_sha1_file() for all paths
even when not needed, which was a mistake introduced by me.
Rectify this by first checking S_ISDIR(mode) and read the tree
contents only when it is a tree and we are recursive. There is
no need to read it in any other cases.
The patch also removes the confusing comment that led to this
incorrect implementation.
Thanks to Peter Baudis for noticing this problem.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
It's there in the history if somebody wants to resurrect it, but it
seems to have been successfully superceded by the new and improved
index-merge thing, where we do all merging entirely in the index.
This cuts down the work for the "real merge" to stuff where
people might actually disagree on the algorithm. The trivial
cases would seem to be totally independent of any policy.
This adds --stage option to show-files command. It shows
file-mode, SHA1, stage and pathname. Record separator follows
the usual convention of -z option as before.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The ce_namelen field has been renamed to ce_flags and split into
the top 2-bit unused, next 2-bit stage number and the lowest
12-bit name-length, stored in the network byte order. A new
macro create_ce_flags() is defined to synthesize this value from
length and stage, but it forgets to turn the value into the
network byte order. Here is a fix.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Normally you'd use state 0 for the "merged" state, and start out with
state 1 being "origin", state 2 being "first tree" and state 3 being
"second tree".
Once all the index entries are back in state 0, we have a successful
merge and can write the result tree back.
Of course, we can't even generate such an index yet, but give me
some time. This is a cunning plan. Let's see if it actually works.
(I feel like Wile E Coyote, waiting for the big rock to fall).