Commit Graph

2728 Commits

Author SHA1 Message Date
Junio C Hamano
d23748a6af update-index: allow --index-info to add higher stages.
The new merge world order tells the merge strategies to leave
the cache unmerged and store the automerge result in the working
tree if automerge is not clean.  This was done for the resolve
strategy and recursive strategy when no rename is involved, but
recording a conflicting merge in the rename case could not
easily be done by the recursive strategy.

This commit adds a new input format, in addition to the exsting
two, to "update-index --index-info".

    (1) mode         SP sha1          TAB path
    The first format is what "git-apply --index-info"
    reports, and used to reconstruct a partial tree
    that is used for phony merge base tree when falling
    back on 3-way merge.

    (2) mode SP type SP sha1          TAB path
    The second format is to stuff git-ls-tree output
    into the index file.

    (3) mode         SP sha1 SP stage TAB path
    This format is to put higher order stages into the
    index file and matches git-ls-files --stage output.

To place a higher stage entry to the index, the path should
first be removed by feeding a mode=0 entry for the path, and
then feeding necessary input lines in the (3) format.

For example, starting with this index:

$ git ls-files -s
100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz

$ git update-index --index-info ;# interactive session -- input follows...

0 0000000000000000000000000000000000000000	frotz
100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1	frotz
100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2	frotz

The first line of the input feeds 0 as the mode to remove the
path; the SHA1 does not matter as long as it is well formatted.
Then the second and third line feeds stage 1 and stage 2 entries
for that path.  After the above, we would end up with this:

$ git ls-files -s
100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1	frotz
100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2	frotz

This completes the groundwork for the new merge world order.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-07 01:53:50 -08:00
Junio C Hamano
b539c5e8fb git-merge-one: new merge world order.
This does two things:

 - Use new --stage=2 option to create the working tree file with
   leading paths and correct permission bits using
   checkout-index, as before.

 - Make sure we do not confuse "merge" program when the file
   being merged has an unfortunate name, '-L'.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-07 00:50:33 -08:00
Junio C Hamano
3bd348aeea checkout-index: allow checking out from higher stages.
The new option, --stage=<n>, lets you copy out from an unmerged,
higher stage.  This is to help the new merge world order during
a nontrivial merge.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-07 00:44:30 -08:00
Jason Riedy
9754563ca9 Use printf rather than echo -n.
On AIX, there is no -n option to the system's echo.  Instead,
it needs the '\c' control character.  We could replace
  echo -n "foo"
with
  echo -e "foo\c"
but printf is recommended by most man pages.  Tested on AIX
5.3, Solaris 8, and Debian.

[jc: futureproofed two instances that uses variable with '%s'
 so later feeding different messages would not break things too
 easily; others are emitting literal so whoever changes the
 literal ought to notice more easily so they are safe.]

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-06 18:09:12 -08:00
Junio C Hamano
e23eff8be9 qsort() ptrdiff_t may be larger than int
Morten Welinder <mwelinder@gmail.com> writes:

> The code looks wrong.  It assumes that pointers are no larger than ints.
> If pointers are larger than ints, the code does not necessarily compute
> a consistent ordering and qsort is allowed to do whatever it wants.
>
> Morten
>
> static int compare_object_pointers(const void *a, const void *b)
> {
> 	const struct object * const *pa = a;
> 	const struct object * const *pb = b;
> 	return *pa - *pb;
> }

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-06 17:28:26 -08:00
Jason Riedy
a6da9395a5 [PATCH] Initial AIX portability fixes.
Added an AIX clause in the Makefile; that clause likely
will be wrong for any AIX pre-5.2, but I can only test
on 5.3.  mailinfo.c was missing the compat header file,
and convert-objects.c needs to define a specific
_XOPEN_SOURCE as well as _XOPEN_SOURCE_EXTENDED.

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-06 16:15:55 -08:00
Junio C Hamano
be61db922a git-merge-one-file: resurrect leading path creation.
Since we do not use git-update-index followed by
git-checkout-index -u to create the half-merged file on
conflicting case anymore, we need to make sure the leading
directories are created here.

Maybe a better solution would be to allow update-index to add to
higher stage, and checkout-index to extract from such, but that
is a change slightly bigger than I would like to have so close
to 1.0, so this should do for now.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-06 00:07:58 -08:00
Junio C Hamano
bb6d7b893e Documentaiton (read-tree): update description of 3-way
The merge-one-file used to leave the working tree intact, but
it has long been changed to leave the merge result there since
2a68a8659f commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 23:26:10 -08:00
Junio C Hamano
5f6da1d9d2 Documentation: hash-object.
The file parameter is better spelled just "file", not "any file
on the filesystem".  We stress that in the description text
later anyway.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 22:36:22 -08:00
Junio C Hamano
75a46f6b0e write-tree: check extra arguments and die but be a bit more helpful.
"git-write-tree junk" complains and dies, but it does not say
what option it supports.  Die with the usage string in such a
case.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 22:31:18 -08:00
Junio C Hamano
4a62eaed31 init-db: check extra arguments and complain.
"git-init-db junk" does not complain but just ignores "junk".
Die with the usage string in such a case.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 22:29:36 -08:00
Junio C Hamano
9c2e7c0ca2 hash-object: -- and --help
It was cumbersome to feed hash-object the file '-t' (you could
have said "./-t", though).  Teach it '--' that terminates the
option list, like everybody else.  There is no way to extract
usage string from the command either, so teach it "--help" as
well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 22:29:05 -08:00
Jon Loeliger
61f693bd5a Added documentation for few missing options.
More $ shell prompts in examples.
Minor English grammar improvements.
Added a few "See Also"s.
Use back-ticks on more command examples.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 21:47:16 -08:00
Junio C Hamano
23c99d8460 git-mv to work with Perl 5.6
List form of pipe open is 5.8 invention.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 19:12:27 -08:00
Junio C Hamano
8d69195124 Fix 5501 test
Not everybody can rely on /bin/sh to be sane, and we support
SHELL_PATH for that.  Use it.

mktemp(1) is not used anywhere else in the core git.  Do not
introduce dependency on it.

Not everybody's "which" gives a sane return value.  For example,
on Solaris 'which XXX' says "no XXX in /usr/bin /bin ..." and
exits with zero status.  The lesson here is to never use 'which'
in your scripts.

Signed-off-by: Junio C Hamano <junkio@twinsun.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 19:12:26 -08:00
Junio C Hamano
4050c0df8e Clean up compatibility definitions.
This attempts to clean up the way various compatibility
functions are defined and used.

 - A new header file, git-compat-util.h, is introduced.  This
   looks at various NO_XXX and does necessary function name
   replacements, equivalent of -Dstrcasestr=gitstrcasestr in the
   Makefile.

 - Those function name replacements are removed from the Makefile.

 - Common features such as usage(), die(), xmalloc() are moved
   from cache.h to git-compat-util.h; cache.h includes
   git-compat-util.h itself.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 15:50:29 -08:00
Jason Riedy
cd8c458947 [PATCH] Document config.mak in INSTALL.
The existing config.mak should satisfy almost everyone...  You
can change the prefix and other vars catch the new setting
anyways.  I had forgotten that ?= acts as = (lazy value binding)
and as not := (immediate value binding).

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 13:19:39 -08:00
Junio C Hamano
53e7181cd9 config.c: remove unnecessary header in minimum configuration file.
It is just silly to start the file called "config" with a
comment that says "This is the config file."

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 12:58:53 -08:00
Junio C Hamano
9cebe90bc5 server-info.c: and two functions are not used anymore.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 11:12:01 -08:00
Junio C Hamano
f13d7db4af server-info.c: use pack_local like everybody else.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 10:39:17 -08:00
Junio C Hamano
dc5f9239f7 Documentation: shared repository management in tutorial.
The branch policy script I outlined was improved and polished by
Carl and posted on the list twice since then.  It is a shame not
to pick it up, so replace the original outline in
howto/update-hook-example.txt with the latest from Carl.

Also talk about setting up git-shell to allow git-push/git-fetch
only SSH access to a shared repository host in the tutorial.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 00:58:23 -08:00
Junio C Hamano
eb0362a467 Documentation: push/receive hook references.
Mention documentation pages that talk about update and
post-update hooks from git-push, because a frequently asked
question is "I want X to happen when I push" and people would
not know to look at git-receive-pack documentation until they
understand that is what runs on the other end.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 00:58:23 -08:00
Junio C Hamano
dfa2f22f94 Documentation: git-diff asciidoc table workaround.
The table facility was nice in rendering HTML but was disastrous
for man page.  Reword the text and do not use table for now.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 00:22:01 -08:00
Junio C Hamano
63d34b0b13 Documentation: git-mv manpage workaround.
Work-around asciidoc manpage trouble that does not seem to allow
more than one line in the SYNOPSIS section.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 00:15:44 -08:00
Junio C Hamano
556cb4e583 Documentation: talk about pathspec in bisect.
Also work-around asciidoc manpage trouble that does not seem to
allow more than one line in the SYNOPSIS section.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 00:15:24 -08:00
Junio C Hamano
3e15c67c90 server-info: throw away T computation as well.
Again, dumb transport clients are too dumb to make use of the
top objects information to make a choice among multiple packs,
so computing these lines are useless for now.  We could
resurrect them if needed later.  Also dumb transport clients
presumably can do their own approximation by downloading idx
files to see how relevant each pack is for their fetch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:32 -08:00
Junio C Hamano
d5eac49868 server-info: stop sorting packs by latest date.
This does not seem to buy us much, for the same reason as the
previous change.  Dumb clients are still too dumb.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:31 -08:00
Junio C Hamano
6f42f89c1f server-info.c: drop unused D lines.
We tried to compute pack interdependency information in
$GIT_DIR/objects/info/packs, hoping that dumb transports would
make use of it when choosing from multiple choice, but that has
never materialized, so stop computing D lines for now.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:31 -08:00
Junio C Hamano
1494e03888 sha1_file.c: make sure packs in an alternate odb is named properly.
We somehow ended up registering packs in alternate object
directories as "dir/object//pack/pack-*", which confusd the
update-server-info code very badly.  Also we did not attempt to
detect a mistake of listing the object directory itself as one
of the alternates. This does not lead to incorrect behaviour,
but is simply wasteful, so try to do so when we are trivially
able to.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:31 -08:00
Junio C Hamano
b270c634b7 git.c: remove excess output for debugging when command is too long.
When the given command name was too long, we exited with a
message with the number of bytes of the final command name
inside parentheses, without saying what that number is.  It was
only meant as a debugging aid while development, so remove it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:31 -08:00
Junio C Hamano
18d1e701b7 struct tree: remove unused field "parent"
The field is not used anymore, after the recent ls-tree rewrite.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 23:19:31 -08:00
Junio C Hamano
f83df6d66e Documentation: rebase does not use cherry-pick anymore.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 16:38:40 -08:00
Petr Baudis
8bf14d6ef9 Document the --(no-)edit switch of git-revert and git-cherry-pick
This switch was not documented properly. I decided not to mention
the --no-edit switch in the git-cherry-pick documentation since
we always default to no editing.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 16:34:35 -08:00
Junio C Hamano
287f860054 show-branch: allow glob pattern to name branches to show.
With this, you can say "git-show-branch topic/* master" to show
all the topic branches you have under .git/refs/heads/topic/ and
your master branch.  Another example is "git-show-branch --list
v1.0*" to show all the v1.0 tags.  You can disambiguate by
saying "heads/topic/*" to show only topic branches if you have
tags under .git/refs/tags/topic/ as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 16:06:35 -08:00
Petr Baudis
7b9b4c452c Update the git-ls-tree documentation
This patch aims to freshen up a bit the git-ls-tree documentation. It hints
that the list of paths are in fact patterns to be matched, explains the new
-t, --name-only and --name-status options, corrects the original autorship
information to refer to yours sincerely, corrects several grammar mistakes,
etc.

Since the documentation still deserves some significant work (at least
proper description of the pattern matching), I also added the stub notice.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 16:02:16 -08:00
Junio C Hamano
9a79c5a8b4 git.c: two fixes, gitsetenv type and off-by-one error.
gitsetenv as implemented in compat/setenv.c takes two const char*
and int; match that.

Also fix an incorrect attempt in prepend_to_path() to
NUL-terminate the string which stuffed the NUL character at one
past the end of allocation, and was not needed to begin with (we
copy the old_path string including the NUL which terminates it).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 14:59:58 -08:00
Junio C Hamano
3a2674337c compat/setenv: do not free what we fed putenv(3).
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 14:41:35 -08:00
Daniel Barkalow
4c353e890c Warn when send-pack does nothing
If you try to push into an empty repository with no ref arguments to
git push, it doesn't do anything and doesn't say anything. This adds a
warning when send-pack isn't going to push anything, so you don't
assume that it silently did what you wanted.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 10:32:49 -08:00
Junio C Hamano
d79374c7b5 [PATCH] daemon.c and path.enter_repo(): revamp path validation.
The whitelist of git-daemon is checked against return value from
enter_repo(), and enter_repo() used to return the value obtained
from getcwd() to avoid directory aliasing issues as discussed
earier (mid October 2005).

Unfortunately, it did not go well as we hoped.

For example, /pub on a kernel.org public machine is a symlink to
its real mountpoint, and it is understandable that the
administrator does not want to adjust the whitelist every time
/pub needs to point at a different partition for storage
allcation or whatever reasons.  Being able to keep using
/pub/scm as the whitelist is a desirable property.

So this version of enter_repo() reports what it used to chdir()
and validate, but does not use getcwd() to canonicalize the
directory name.  When it sees a user relative path ~user/path,
it internally resolves it to try chdir() there, but it still
reports ~user/path (possibly after appending .git if allowed to
do so, in which case it would report ~user/path.git).

What this means is that if a whitelist wants to allow a user
relative path, it needs to say "~" (for all users) or list user
home directories like "~alice" "~bob".  And no, you cannot say
/home if the advertised way to access user home directories are
~alice,~bob, etc.  The whole point of this is to avoid
unnecessary aliasing issues.

Anyway, because of this, daemon needs to do a bit more work to
guard itself.  Namely, it needs to make sure that the accessor
does not try to exploit its leading path match rule by inserting
/../ in the middle or hanging /.. at the end.  I resurrected the
belts and suspender paranoia code HPA did for this purpose.

This check cannot be done in the enter_repo() unconditionally,
because there are valid callers of enter_repo() that want to
honor /../; authorized users coming over ssh to run send-pack
and fetch-pack should be allowed to do so.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 23:17:42 -08:00
H. Peter Anvin
7950571ad7 A few more options for git-cat-file
This adds '-e' option to git-cat-file, to test for the existence
of the object.

This also cleans up the option-parsing in git-cat-file slightly.

[jc: HPA version had -n option which did rev-parse --verify; the
real value of this patch is the option parsing cleanup.]

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 23:07:17 -08:00
Jason Riedy
e40b61fb6b Add compat/setenv.c, use in git.c.
There is no setenv() in Solaris 5.8.  The trivial calls to
setenv() were replaced by putenv() in a much earlier patch,
but setenv() was used again in git.c.  This patch just adds
a compat/setenv.c.

The rule for building git$(X) also needs to include compat.
objects and compiler flags.  Those are now in makefile vars
COMPAT_OBJS and COMPAT_CFLAGS.

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 22:25:25 -08:00
Fredrik Kuivinen
7057463463 New test case: Criss-cross merge
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 12:29:07 -08:00
Fredrik Kuivinen
72d1216a04 New test case: merge with directory/file conflicts
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 12:29:05 -08:00
Fredrik Kuivinen
d3bfdb755e test-lib.sh: Add new function, test_expect_code
The test is considered OK if it exits with code $1

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 12:28:57 -08:00
Fredrik Kuivinen
4275df5170 git-merge: Exit with code 2 if no strategy was able to handle the merge.
This way it is possible to test in scripts if the merge was non-clean
or if the strategy had other problems with the merge.

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 12:28:52 -08:00
No name
56b5e946f2 documentation: git-tag
[jc: light edit applied on top of the original]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-02 12:20:34 -08:00
Junio C Hamano
d2abdd2647 documentation: git-bisect (help HTML break man)
Use the same trick Josef used to introduce line breaks for
git-mv documentation for now, to help HTML rendering.  This
breaks manpages and we need to come up with a better solution.

Noticed by linux@horizon.com (No Name).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-02 12:20:34 -08:00
No name
3f41f5a9fe documentation: clarify read-tree --reset
[jc: light edit applied on top of the original]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-02 12:20:34 -08:00
Junio C Hamano
3ace1fe34b git-merge documentation: conflicting merge leaves higher stages in index
This hopefully concludes the latest updates that changes the
behaviour of the merge on an unsuccessful automerge.  Instead of
collapsing the conflicted path in the index to show HEAD, we
leave it unmerged, now that diff-files can compare working tree
files with higher stages.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-02 01:08:14 -08:00
Junio C Hamano
54dd99a127 merge-one-file: make sure we do not mismerge symbolic links.
We ran "merge" command on O->A, O->B, A!=B case without
verifying the path involved is not a symlink.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-02 01:08:14 -08:00