aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Documentation/Makefile6
-rw-r--r--Documentation/config.txt16
-rw-r--r--Documentation/core-tutorial.txt10
-rw-r--r--Documentation/cvs-migration.txt4
-rw-r--r--Documentation/everyday.txt6
-rw-r--r--Documentation/git-apply.txt2
-rw-r--r--Documentation/git-blame.txt2
-rw-r--r--Documentation/git-cat-file.txt9
-rw-r--r--Documentation/git-clone.txt9
-rw-r--r--Documentation/git-commit.txt2
-rw-r--r--Documentation/git-cvsserver.txt2
-rw-r--r--Documentation/git-daemon.txt4
-rw-r--r--Documentation/git-diff-index.txt2
-rw-r--r--Documentation/git-diff-tree.txt4
-rw-r--r--Documentation/git-diff.txt2
-rw-r--r--Documentation/git-format-patch.txt69
-rw-r--r--Documentation/git-fsck-objects.txt2
-rw-r--r--Documentation/git-grep.txt4
-rw-r--r--Documentation/git-merge-index.txt2
-rw-r--r--Documentation/git-patch-id.txt2
-rw-r--r--Documentation/git-read-tree.txt4
-rw-r--r--Documentation/git-repo-config.txt2
-rw-r--r--Documentation/git-reset.txt2
-rw-r--r--Documentation/git-rev-parse.txt4
-rw-r--r--Documentation/git-send-email.txt2
-rw-r--r--Documentation/git-send-pack.txt2
-rw-r--r--Documentation/git-sh-setup.txt2
-rw-r--r--Documentation/git-tools.txt2
-rw-r--r--Documentation/git-update-index.txt2
-rw-r--r--Documentation/hooks.txt4
-rw-r--r--Documentation/technical/pack-format.txt11
-rw-r--r--Documentation/technical/pack-heuristics.txt2
-rw-r--r--Documentation/tutorial-2.txt4
-rw-r--r--Documentation/tutorial.txt20
-rw-r--r--Makefile48
-rw-r--r--builtin-add.c2
-rw-r--r--builtin-apply.c22
-rw-r--r--builtin-cat-file.c2
-rw-r--r--builtin-diff-tree.c10
-rw-r--r--builtin-log.c61
-rw-r--r--builtin-read-tree.c86
-rw-r--r--builtin-rev-list.c3
-rw-r--r--builtin-rev-parse.c (renamed from rev-parse.c)3
-rw-r--r--builtin-rm.c2
-rw-r--r--builtin.h1
-rw-r--r--cache-tree.c531
-rw-r--r--cache-tree.h31
-rw-r--r--cache.h1
-rw-r--r--checkout-index.c1
-rwxr-xr-xcontrib/git-svn/git-svn.perl1
-rw-r--r--contrib/git-svn/t/t0001-contrib-git-svn-props.sh3
-rwxr-xr-xcontrib/gitview/gitview26
-rw-r--r--contrib/gitview/gitview.txt6
-rw-r--r--dump-cache-tree.c64
-rw-r--r--exec_cmd.c36
-rw-r--r--fsck-objects.c25
-rwxr-xr-xgit-clean.sh4
-rwxr-xr-xgit-clone.sh10
-rwxr-xr-xgit-commit.sh40
-rwxr-xr-xgit-cvsexportcommit.perl44
-rwxr-xr-xgit-cvsimport.perl2
-rwxr-xr-xgit-fetch.sh11
-rwxr-xr-xgit-ls-remote.sh10
-rwxr-xr-xgit-send-email.perl36
-rwxr-xr-xgit-svnimport.perl11
-rw-r--r--git.c3
-rwxr-xr-xgitk102
-rw-r--r--http-fetch.c4
-rw-r--r--http.c9
-rw-r--r--log-tree.c43
-rw-r--r--mailinfo.c150
-rw-r--r--mailsplit.c2
-rw-r--r--read-cache.c72
-rw-r--r--repo-config.c3
-rw-r--r--revision.c8
-rw-r--r--revision.h2
-rw-r--r--sha1_file.c30
-rwxr-xr-xt/t1002-read-tree-m-u-2way.sh20
-rwxr-xr-xt/t2101-update-index-reupdate.sh48
-rwxr-xr-xt/t3300-funny-names.sh51
-rwxr-xr-xt/t3600-rm.sh42
-rwxr-xr-xt/t4012-diff-binary.sh17
-rwxr-xr-xt/t4113-apply-ending.sh53
-rwxr-xr-xt/t5500-fetch-pack.sh30
-rwxr-xr-xt/t6000lib.sh4
-rwxr-xr-xt/t9001-send-email.sh41
-rw-r--r--tree-walk.c21
-rw-r--r--update-index.c13
-rw-r--r--write-tree.c147
90 files changed, 1726 insertions, 546 deletions
diff --git a/.gitignore b/.gitignore
index 199cc310a..afd087621 100644
--- a/.gitignore
+++ b/.gitignore
@@ -116,6 +116,7 @@ git-update-index
git-update-ref
git-update-server-info
git-upload-pack
+git-upload-tar
git-var
git-verify-pack
git-verify-tag
@@ -124,6 +125,7 @@ git-write-tree
git-core-*/?*
test-date
test-delta
+test-dump-cache-tree
common-cmds.h
*.tar.gz
*.dsc
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 2a08f592d..2b0efe792 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -52,9 +52,9 @@ man1: $(DOC_MAN1)
man7: $(DOC_MAN7)
install: man
- $(INSTALL) -d -m755 $(DESTDIR)/$(man1) $(DESTDIR)/$(man7)
- $(INSTALL) $(DOC_MAN1) $(DESTDIR)/$(man1)
- $(INSTALL) $(DOC_MAN7) $(DESTDIR)/$(man7)
+ $(INSTALL) -d -m755 $(DESTDIR)$(man1) $(DESTDIR)$(man7)
+ $(INSTALL) $(DOC_MAN1) $(DESTDIR)$(man1)
+ $(INSTALL) $(DOC_MAN7) $(DESTDIR)$(man7)
#
diff --git a/Documentation/config.txt b/Documentation/config.txt
index e178ee2de..c861c6ce1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2,7 +2,7 @@ CONFIGURATION FILE
------------------
The git configuration file contains a number of variables that affect
-the git commands behaviour. They can be used by both the git plumbing
+the git commands behavior. They can be used by both the git plumbing
and the porcelains. The variables are divided to sections, where
in the fully qualified variable name the variable itself is the last
dot-separated segment and the section name is everything before the last
@@ -53,7 +53,7 @@ core.gitProxy::
may be set multiple times and is matched in the given order;
the first match wins.
- Can be overriden by the 'GIT_PROXY_COMMAND' environment variable
+ Can be overridden by the 'GIT_PROXY_COMMAND' environment variable
(which always applies universally, without the special "for"
handling).
@@ -123,12 +123,12 @@ http.sslCert::
http.sslKey::
File containing the SSL private key when fetching or pushing
- over HTTPS. Can be overriden by the 'GIT_SSL_KEY' environment
+ over HTTPS. Can be overridden by the 'GIT_SSL_KEY' environment
variable.
http.sslCAInfo::
File containing the certificates to verify the peer with when
- fetching or pushing over HTTPS. Can be overriden by the
+ fetching or pushing over HTTPS. Can be overridden by the
'GIT_SSL_CAINFO' environment variable.
http.sslCAPath::
@@ -137,13 +137,13 @@ http.sslCAPath::
by the 'GIT_SSL_CAPATH' environment variable.
http.maxRequests::
- How many HTTP requests to launch in parallel. Can be overriden
+ How many HTTP requests to launch in parallel. Can be overridden
by the 'GIT_HTTP_MAX_REQUESTS' environment variable. Default is 5.
http.lowSpeedLimit, http.lowSpeedTime::
If the HTTP transfer speed is less than 'http.lowSpeedLimit'
for longer than 'http.lowSpeedTime' seconds, the transfer is aborted.
- Can be overriden by the 'GIT_HTTP_LOW_SPEED_LIMIT' and
+ Can be overridden by the 'GIT_HTTP_LOW_SPEED_LIMIT' and
'GIT_HTTP_LOW_SPEED_TIME' environment variables.
i18n.commitEncoding::
@@ -174,12 +174,12 @@ showbranch.default::
user.email::
Your email address to be recorded in any newly created commits.
- Can be overriden by the 'GIT_AUTHOR_EMAIL' and 'GIT_COMMITTER_EMAIL'
+ Can be overridden by the 'GIT_AUTHOR_EMAIL' and 'GIT_COMMITTER_EMAIL'
environment variables. See gitlink:git-commit-tree[1].
user.name::
Your full name to be recorded in any newly created commits.
- Can be overriden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME'
+ Can be overridden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME'
environment variables. See gitlink:git-commit-tree[1].
whatchanged.difftree::
diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt
index d1360ecde..1185897f7 100644
--- a/Documentation/core-tutorial.txt
+++ b/Documentation/core-tutorial.txt
@@ -1,5 +1,5 @@
-A short git tutorial
-====================
+A git core tutorial for developers
+==================================
Introduction
------------
@@ -184,7 +184,7 @@ $ git-cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
----------------
where the `-t` tells `git-cat-file` to tell you what the "type" of the
-object is. git will tell you that you have a "blob" object (ie just a
+object is. git will tell you that you have a "blob" object (i.e., just a
regular file), and you can see the contents with
----------------
@@ -619,7 +619,7 @@ $ git tag -s <tagname>
----------------
which will sign the current `HEAD` (but you can also give it another
-argument that specifies the thing to tag, ie you could have tagged the
+argument that specifies the thing to tag, i.e., you could have tagged the
current `mybranch` point by using `git tag <tagname> mybranch`).
You normally only do signed tags for major releases or things
@@ -1097,7 +1097,7 @@ commit object by downloading from `repo.git/objects/xx/xxx\...`
using the object name of that commit object. Then it reads the
commit object to find out its parent commits and the associate
tree object; it repeats this process until it gets all the
-necessary objects. Because of this behaviour, they are
+necessary objects. Because of this behavior, they are
sometimes also called 'commit walkers'.
+
The 'commit walkers' are sometimes also called 'dumb
diff --git a/Documentation/cvs-migration.txt b/Documentation/cvs-migration.txt
index fa94efde8..826d0897e 100644
--- a/Documentation/cvs-migration.txt
+++ b/Documentation/cvs-migration.txt
@@ -1,7 +1,7 @@
git for CVS users
=================
-So you're a CVS user. That's ok, it's a treatable condition. The job of
+So you're a CVS user. That's OK, it's a treatable condition. The job of
this document is to put you on the road to recovery, by helping you
convert an existing cvs repository to git, and by showing you how to use a
git repository in a cvs-like fashion.
@@ -159,7 +159,7 @@ other than `master`.
[NOTE]
============
-Because of this behaviour, if the shared repository and the developer's
+Because of this behavior, if the shared repository and the developer's
repository both have branches named `origin`, then a push like the above
attempts to update the `origin` branch in the shared repository from the
developer's `origin` branch. The results may be unexpected, so it's
diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt
index 4b5637093..2ad2d6130 100644
--- a/Documentation/everyday.txt
+++ b/Documentation/everyday.txt
@@ -66,7 +66,7 @@ $ git prune <4>
<1> running without "--full" is usually cheap and assures the
repository health reasonably well.
<2> check how many loose objects there are and how much
-diskspace is wasted by not repacking.
+disk space is wasted by not repacking.
<3> without "-a" repacks incrementally. repacking every 4-5MB
of loose objects accumulation may be a good rule of thumb.
<4> after repack, prune removes the duplicate loose objects.
@@ -86,7 +86,7 @@ Individual Developer (Standalone)[[Individual Developer (Standalone)]]
----------------------------------------------------------------------
A standalone individual developer does not exchange patches with
-other poeple, and works alone in a single repository, using the
+other people, and works alone in a single repository, using the
following commands.
* gitlink:git-show-branch[1] to see where you are.
@@ -370,7 +370,7 @@ Examples
Run git-daemon to serve /pub/scm from inetd.::
+
------------
-$ grep git /etc/inet.conf
+$ grep git /etc/inetd.conf
git stream tcp nowait nobody \
/usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm
------------
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index e93ea1f26..9cc7c74de 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -113,7 +113,7 @@ OPTIONS
When `git-apply` is used for statistics and not applying a
patch, it defaults to `nowarn`.
You can use different `<option>` to control this
- behaviour:
+ behavior:
+
* `nowarn` turns off the trailing whitespace warning.
* `warn` outputs warnings for a few such errors, but applies the
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 51898787e..0a1fa00db 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -16,7 +16,7 @@ which introduced the line. Start annotation from the given revision.
OPTIONS
-------
--c, --compability::
+-c, --compatibility::
Use the same output mode as git-annotate (Default: off).
-l, --long::
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index 504eb1b16..5e9cbf875 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -8,12 +8,12 @@ git-cat-file - Provide content or type information for repository objects
SYNOPSIS
--------
-'git-cat-file' [-t | -s | -e | <type>] <object>
+'git-cat-file' [-t | -s | -e | -p | <type>] <object>
DESCRIPTION
-----------
Provides content or type of objects in the repository. The type
-is required unless '-t' is used to find the object type,
+is required unless '-t' or '-p' is used to find the object type,
or '-s' is used to find the object size.
OPTIONS
@@ -33,6 +33,9 @@ OPTIONS
Suppress all output; instead exit with zero status if <object>
exists and is a valid object.
+-p::
+ Pretty-print the contents of <object> based on its type.
+
<type>::
Typically this matches the real type of <object> but asking
for a type that can trivially be dereferenced from the given
@@ -49,6 +52,8 @@ If '-s' is specified, the size of the <object> in bytes.
If '-e' is specified, no output.
+If '-p' is specified, the contents of <object> are pretty-printed.
+
Otherwise the raw (though uncompressed) contents of the <object> will
be returned.
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index b333f5104..94d939337 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -9,8 +9,8 @@ git-clone - Clones a repository
SYNOPSIS
--------
[verse]
-'git-clone' [-l [-s]] [-q] [-n] [--bare] [-o <name>] [-u <upload-pack>]
- [--reference <repository>]
+'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
+ [-o <name>] [-u <upload-pack>] [--reference <repository>]
<repository> [<directory>]
DESCRIPTION
@@ -89,6 +89,11 @@ OPTIONS
the command to specify non-default path for the command
run on the other end.
+--template=<template_directory>::
+ Specify the directory from which templates will be used;
+ if unset the templates are taken from the installation
+ defined default, typically `/usr/share/git-core/templates`.
+
<repository>::
The (possibly remote) repository to clone from. It can
be any URL git-fetch supports.
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 38df59ce2..0fe66f2d0 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -98,7 +98,7 @@ but can be used to amend a merge commit.
Instead of committing only the files specified on the
command line, update them in the index file and then
commit the whole index. This is the traditional
- behaviour.
+ behavior.
-o|--only::
Commit only the files specified on the command line.
diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index 4dc13c35d..952635d80 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -94,7 +94,7 @@ To get a checkout with the Eclipse CVS client:
4. Pick 'HEAD' when it asks what branch/tag to check out. Untick the
"launch commit wizard" to avoid committing the .project file.
-Protocol notes: If you are using anonymous acces via pserver, just select that.
+Protocol notes: If you are using anonymous access via pserver, just select that.
Those using SSH access should choose the 'ext' protocol, and configure 'ext'
access on the Preferences->Team->CVS->ExtConnection pane. Set CVS_SERVER to
'git-cvsserver'. Not that password support is not good when using 'ext',
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
index 924a676a6..4c357daf6 100644
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -20,7 +20,7 @@ aka 9418. It waits for a connection, and will just execute "git-upload-pack"
when it gets one.
It's careful in that there's a magic request-line that gives the command and
-what directory to upload, and it verifies that the directory is ok.
+what directory to upload, and it verifies that the directory is OK.
It verifies that the directory has the magic file "git-daemon-export-ok", and
it will refuse to export any git directory that hasn't explicitly been marked
@@ -28,7 +28,7 @@ for export this way (unless the '--export-all' parameter is specified). If you
pass some directory paths as 'git-daemon' arguments, you can further restrict
the offers to a whitelist comprising of those.
-This is ideally suited for read-only updates, ie pulling from git repositories.
+This is ideally suited for read-only updates, i.e., pulling from git repositories.
OPTIONS
-------
diff --git a/Documentation/git-diff-index.txt b/Documentation/git-diff-index.txt
index 5d2096a4c..9cd43f105 100644
--- a/Documentation/git-diff-index.txt
+++ b/Documentation/git-diff-index.txt
@@ -101,7 +101,7 @@ have not actually done a "git-update-index" on it yet - there is no
torvalds@ppc970:~/v2.6/linux> git-diff-index HEAD
*100644->100664 blob 7476bb......->000000...... kernel/sched.c
-ie it shows that the tree has changed, and that `kernel/sched.c` has is
+i.e., it shows that the tree has changed, and that `kernel/sched.c` has is
not up-to-date and may contain new stuff. The all-zero sha1 means that to
get the real diff, you need to look at the object in the working directory
directly rather than do an object-to-object diff.
diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
index 906830d4b..f7e8ff296 100644
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -32,7 +32,7 @@ include::diff-options.txt[]
<path>...::
If provided, the results are limited to a subset of files
matching one of these prefix strings.
- ie file matches `/^<pattern1>|<pattern2>|.../`
+ i.e., file matches `/^<pattern1>|<pattern2>|.../`
Note that this parameter does not provide any wildcard or regexp
features.
@@ -54,7 +54,7 @@ include::diff-options.txt[]
+
When a single commit is given on one line of such input, it compares
the commit with its parents. The following flags further affects its
-behaviour. This does not apply to the case where two <tree-ish>
+behavior. This does not apply to the case where two <tree-ish>
separated with a single space are given.
-m::
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 7267bcd7a..7ab208037 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -85,7 +85,7 @@ $ git diff arch/i386 include/asm-i386 <3>
nor deletion.
<2> show only names and the nature of change, but not actual
diff output. --name-status disables usual patch generation
-which in turn also disables recursive behaviour, so without -r
+which in turn also disables recursive behavior, so without -r
you would only see the directory name if there is a change in a
file in a subdirectory.
<3> limit diff output to named subtrees.
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 7cc7fafc1..493cac22d 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -9,37 +9,46 @@ git-format-patch - Prepare patches for e-mail submission
SYNOPSIS
--------
[verse]
-'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [-s] [-c]
- [--diff-options] <his> [<mine>]
+'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach]
+ [-s | --signoff] [--diff-options] [--start-number <n>]
+ <since>[..<until>]
DESCRIPTION
-----------
-Prepare each commit with its patch since <mine> head forked from
-<his> head, one file per patch formatted to resemble UNIX mailbox
-format, for e-mail submission or use with gitlink:git-am[1].
+
+Prepare each commit between <since> and <until> with its patch in
+one file per commit, formatted to resemble UNIX mailbox format.
+If ..<until> is not specified, the head of the current working
+tree is implied.
+
+The output of this command is convenient for e-mail submission or
+for use with gitlink:git-am[1].
Each output file is numbered sequentially from 1, and uses the
-first line of the commit message (massaged for pathname safety)
-as the filename.
+first line of the commit message (massaged for pathname safety) as
+the filename. The names of the output files are printed to standard
+output, unless the --stdout option is specified.
-When -o is specified, output files are created in <dir>; otherwise
-they are created in the current working directory. This option
-is ignored if --stdout is specified.
+If -o is specified, output files are created in <dir>. Otherwise
+they are created in the current working directory.
-When -n is specified, instead of "[PATCH] Subject", the first
-line is formatted as "[PATCH N/M] Subject", unless you have only
-one patch.
+If -n is specified, instead of "[PATCH] Subject", the first line
+is formatted as "[PATCH n/m] Subject".
OPTIONS
-------
-o|--output-directory <dir>::
Use <dir> to store the resulting files, instead of the
- current working directory.
+ current working directory. This option is ignored if
+ --stdout is specified.
-n|--numbered::
Name output in '[PATCH n/m]' format.
+--start-number <n>::
+ Start numbering the patches at <n> instead of 1.
+
-k|--keep-subject::
Do not strip/add '[PATCH]' from the first line of the
commit log message.
@@ -48,17 +57,9 @@ OPTIONS
Add `Signed-off-by:` line to the commit message, using
the committer identity of yourself.
--c|--check::
- Display suspicious lines in the patch. The definition
- of 'suspicious lines' is currently the lines that has
- trailing whitespaces, and the lines whose indentation
- has a SP character immediately followed by a TAB
- character.
-
--stdout::
- This flag generates the mbox formatted output to the
- standard output, instead of saving them into a file per
- patch and implies --mbox.
+ Print all commits to the standard output in mbox format,
+ instead of creating a file for each one.
--attach::
Create attachments instead of inlining patches.
@@ -82,18 +83,18 @@ git-format-patch -k --stdout R1..R2 | git-am -3 -k::
cherry-pick them.
git-format-patch origin::
- Extract commits the current branch accumulated since it
- pulled from origin the last time in a patch form for
- e-mail submission.
+ Extract all commits which are in the current branch but
+ not in the origin branch. For each commit a separate file
+ is created in the current directory.
git-format-patch -M -B origin::
- The same as the previous one, except detect and handle
- renames and complete rewrites intelligently to produce
- renaming patch. A renaming patch reduces the amount of
- text output, and generally makes it easier to review
- it. Note that the "patch" program does not understand
- renaming patch well, so use it only when you know the
- recipient uses git to apply your patch.
+ The same as the previous one. Additionally, it detects
+ and handles renames and complete rewrites intelligently to
+ produce a renaming patch. A renaming patch reduces the
+ amount of text output, and generally makes it easier to
+ review it. Note that the "patch" program does not
+ understand renaming patches, so use it only when you know
+ the recipient uses git to apply your patch.
See Also
diff --git a/Documentation/git-fsck-objects.txt b/Documentation/git-fsck-objects.txt
index 93ce9dcc9..d0af99d35 100644
--- a/Documentation/git-fsck-objects.txt
+++ b/Documentation/git-fsck-objects.txt
@@ -71,7 +71,7 @@ sorted properly etc), but on the whole if "git-fsck-objects" is happy, you
do have a valid tree.
Any corrupt objects you will have to find in backups or other archives
-(ie you can just remove them and do an "rsync" with some other site in
+(i.e., you can just remove them and do an "rsync" with some other site in
the hopes that somebody else has the object you have corrupted).
Of course, "valid tree" doesn't mean that it wasn't generated by some
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 74102b794..7b810dfda 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -30,7 +30,7 @@ OPTIONS
-------
--cached::
Instead of searching in the working tree files, check
- the blobs registerd in the index file.
+ the blobs registered in the index file.
-a | --text::
Process binary files as if they were text.
@@ -65,7 +65,7 @@ OPTIONS
-[ABC] <context>::
Show `context` trailing (`A` -- after), or leading (`B`
-- before), or both (`C` -- context) lines, and place a
- line containing `--` between continguous groups of
+ line containing `--` between contiguous groups of
matches.
-f <file>::
diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt
index 332e023d0..6cd060108 100644
--- a/Documentation/git-merge-index.txt
+++ b/Documentation/git-merge-index.txt
@@ -69,7 +69,7 @@ or
fatal: merge program failed
where the latter example shows how "git-merge-index" will stop trying to
-merge once anything has returned an error (ie "cat" returned an error
+merge once anything has returned an error (i.e., "cat" returned an error
for the AA file, because it didn't exist in the original, and thus
"git-merge-index" didn't even try to merge the MM thing).
diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt
index 723b8ccbf..5389097f7 100644
--- a/Documentation/git-patch-id.txt
+++ b/Documentation/git-patch-id.txt
@@ -13,7 +13,7 @@ DESCRIPTION
-----------
A "patch ID" is nothing but a SHA1 of the diff associated with a patch, with
whitespace and line numbers ignored. As such, it's "reasonably stable", but at
-the same time also reasonably unique, ie two patches that have the same "patch
+the same time also reasonably unique, i.e., two patches that have the same "patch
ID" are almost guaranteed to be the same thing.
IOW, you can use this thing to look for likely duplicate commits.
diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt
index 844cfda8d..02c7e99fe 100644
--- a/Documentation/git-read-tree.txt
+++ b/Documentation/git-read-tree.txt
@@ -205,7 +205,7 @@ The `git-write-tree` command refuses to write a nonsensical tree, and it
will complain about unmerged entries if it sees a single entry that is not
stage 0.
-Ok, this all sounds like a collection of totally nonsensical rules,
+OK, this all sounds like a collection of totally nonsensical rules,
but it's actually exactly what you want in order to do a fast
merge. The different stages represent the "result tree" (stage 0, aka
"merged"), the original tree (stage 1, aka "orig"), and the two trees
@@ -226,7 +226,7 @@ populated. Here is an outline of how the algorithm works:
- the index file saves and restores with all this information, so you
can merge things incrementally, but as long as it has entries in
- stages 1/2/3 (ie "unmerged entries") you can't write the result. So
+ stages 1/2/3 (i.e., "unmerged entries") you can't write the result. So
now the merge algorithm ends up being really simple:
* you walk the index in order, and ignore all entries of stage 0,
diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index 660c18ff8..d5142e0dc 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -49,7 +49,7 @@ OPTIONS
-------
--replace-all::
- Default behaviour is to replace at most one line. This replaces
+ Default behavior is to replace at most one line. This replaces
all lines matching the key (and optionally the value_regex).
--get::
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index b27399dd4..73a0ffc41 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -24,7 +24,7 @@ gitlink:git-revert[1] is your friend.
OPTIONS
-------
--mixed::
- Resets the index but not the working tree (ie, the changed files
+ Resets the index but not the working tree (i.e., the changed files
are preserved but not marked for commit) and reports what has not
been updated. This is the default action.
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index b89469436..627cde852 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -13,7 +13,7 @@ SYNOPSIS
DESCRIPTION
-----------
-Many git Porcelainish commands take mixture of flags
+Many git porcelainish commands take mixture of flags
(i.e. parameters that begin with a dash '-') and parameters
meant for underlying `git-rev-list` command they use internally
and flags and parameters for other commands they use as the
@@ -91,7 +91,7 @@ OPTIONS
--short, --short=number::
Instead of outputting the full SHA1 values of object names try to
- abbriviate them to a shorter unique name. When no length is specified
+ abbreviate them to a shorter unique name. When no length is specified
7 is used. The minimum length is 4.
--since=datestring, --after=datestring::
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 8c58685e2..ad1b9cf2e 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -52,7 +52,7 @@ The options available are:
is not set, this will be prompted for.
--no-signed-off-by-cc::
- Do not add emails foudn in Signed-off-by: lines to the cc list.
+ Do not add emails found in Signed-off-by: lines to the cc list.
--quiet::
Make git-send-email less verbose. One line per email should be
diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt
index 08e070530..9e67f1730 100644
--- a/Documentation/git-send-pack.txt
+++ b/Documentation/git-send-pack.txt
@@ -53,7 +53,7 @@ Specifying the Refs
There are three ways to specify which refs to update on the
remote end.
-With '--all' flag, all refs that exist locally are transfered to
+With '--all' flag, all refs that exist locally are transferred to
the remote side. You cannot specify any '<ref>' if you use
this flag.
diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index 6742c9bfc..79217d8a5 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -13,7 +13,7 @@ DESCRIPTION
-----------
Sets up the normal git environment variables and a few helper functions
-(currently just "die()"), and returns ok if it all looks like a git archive.
+(currently just "die()"), and returns OK if it all looks like a git archive.
So, to make the rest of the git scripts more careful and readable,
use it as follows:
diff --git a/Documentation/git-tools.txt b/Documentation/git-tools.txt
index 00e57a69a..d79523f56 100644
--- a/Documentation/git-tools.txt
+++ b/Documentation/git-tools.txt
@@ -12,7 +12,7 @@ This document presents a brief summary of each tool and the corresponding
link.
-Alternative/Augmentative Procelains
+Alternative/Augmentative Porcelains
-----------------------------------
- *Cogito* (http://www.kernel.org/pub/software/scm/cogito/)
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index d043e86a7..3ae6e7457 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -40,7 +40,7 @@ OPTIONS
--remove::
If a specified file is in the index but is missing then it's
removed.
- Default behaviour is to ignore removed file.
+ Default behavior is to ignore removed file.
--refresh::
Looks at the current index and checks to see if merges or
diff --git a/Documentation/hooks.txt b/Documentation/hooks.txt
index 3824a9517..e3dde3919 100644
--- a/Documentation/hooks.txt
+++ b/Documentation/hooks.txt
@@ -100,7 +100,7 @@ update
This hook is invoked by `git-receive-pack` on the remote repository,
which is happens when a `git push` is done on a local repository.
Just before updating the ref on the remote repository, the update hook
-is invoked. It's exit status determins the success or failure of
+is invoked. It's exit status determines the success or failure of
the ref update.
The hook executes once for each ref to be updated, and takes
@@ -151,7 +151,7 @@ so it is a poor place to do log old..new.
The default post-update hook, when enabled, runs
`git-update-server-info` to keep the information used by dumb
-transports (eg, http) up-to-date. If you are publishing
+transports (e.g., http) up-to-date. If you are publishing
a git repository that is accessible via http, you should
probably enable this hook.
diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt
index ed2decc10..0e1ffb242 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -5,8 +5,13 @@ GIT pack format
- The header appears at the beginning and consists of the following:
- 4-byte signature
- 4-byte version number (network byte order)
+ 4-byte signature:
+ The signature is: {'P', 'A', 'C', 'K'}
+
+ 4-byte version number (network byte order):
+ GIT currently accepts version number 2 or 3 but
+ generates version 2 only.
+
4-byte number of objects contained in the pack (network byte order)
Observation: we cannot have more than 4G versions ;-) and
@@ -41,7 +46,7 @@ GIT pack format
8-byte integers to go beyond 4G objects per pack, but it is
not strictly necessary.
- - The header is followed by sorted 28-byte entries, one entry
+ - The header is followed by sorted 24-byte entries, one entry
per object in the pack. Each entry is:
4-byte network byte order integer, recording where the
diff --git a/Documentation/technical/pack-heuristics.txt b/Documentation/technical/pack-heuristics.txt
index eaab3eecd..9aadd5cee 100644
--- a/Documentation/technical/pack-heuristics.txt
+++ b/Documentation/technical/pack-heuristics.txt
@@ -288,7 +288,7 @@ And of course there is the "Other Shoe" Factor too.
- we actively try to generate deltas from a larger object to a
smaller one
- this means that the top-of-tree very seldom has deltas
- (ie deltas in _practice_ are "backwards deltas")
+ (i.e. deltas in _practice_ are "backwards deltas")
Again, we should reread that whole paragraph. Not just because
Linus has slipped Linus's Law in there on us, but because it is
diff --git a/Documentation/tutorial-2.txt b/Documentation/tutorial-2.txt
index 08d3453e5..82c692254 100644
--- a/Documentation/tutorial-2.txt
+++ b/Documentation/tutorial-2.txt
@@ -49,7 +49,7 @@ tree
A tree can refer to one or more "blob" objects, each corresponding to
a file. In addition, a tree can also refer to other tree objects,
-thus creating a directory heirarchy. You can examine the contents of
+thus creating a directory hierarchy. You can examine the contents of
any tree using ls-tree (remember that a long enough initial portion
of the SHA1 will also work):
@@ -377,7 +377,7 @@ At this point you should know everything necessary to read the man
pages for any of the git commands; one good place to start would be
with the commands mentioned in link:everyday.html[Everyday git]. You
should be able to find any unknown jargon in the
-link:glossary.html[Glosssay].
+link:glossary.html[Glossary].
The link:cvs-migration.html[CVS migration] document explains how to
import a CVS repository into git, and shows how to use git in a
diff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt
index 79781adf4..db563127b 100644
--- a/Documentation/tutorial.txt
+++ b/Documentation/tutorial.txt
@@ -194,7 +194,7 @@ $ git clone /home/alice/project myrepo
This creates a new directory "myrepo" containing a clone of Alice's
repository. The clone is on an equal footing with the original
-project, posessing its own copy of the original project's history.
+project, possessing its own copy of the original project's history.
Bob then makes some changes and commits them:
@@ -240,7 +240,7 @@ $ git log -p master..bob-incoming
shows a list of all the changes that Bob made since he branched from
Alice's master branch.
-After examing those changes, and possibly fixing things, Alice can
+After examining those changes, and possibly fixing things, Alice can
pull the changes into her master branch:
-------------------------------------
@@ -374,7 +374,7 @@ project, so
$ git grep "hello" v2.5
-------------------------------------
-searches for all occurences of "hello" in v2.5.
+searches for all occurrences of "hello" in v2.5.
If you leave out the commit name, git grep will search any of the
files it manages in your current directory. So
@@ -429,16 +429,24 @@ $ gitk --since="2 weeks ago" drivers/
-------------------------------------
allows you to browse any commits from the last 2 weeks of commits
-that modified files under the "drivers" directory.
+that modified files under the "drivers" directory. (Note: you can
+adjust gitk's fonts by holding down the control key while pressing
+"-" or "+".)
Finally, most commands that take filenames will optionally allow you
to precede any filename by a commit, to specify a particular version
-fo the file:
+of the file:
-------------------------------------
$ git diff v2.5:Makefile HEAD:Makefile.in
-------------------------------------
+You can also use "git cat-file -p" to see any such file:
+
+-------------------------------------
+$ git cat-file -p v2.5:Makefile
+-------------------------------------
+
Next Steps
----------
@@ -474,6 +482,6 @@ digressions that may be interesting at this point are:
smart enough to perform a close-to-optimal search even in the
case of complex non-linear history with lots of merged branches.
- * link:everyday.html[Everday GIT with 20 Commands Or So]
+ * link:everyday.html[Everyday GIT with 20 Commands Or So]
* link:cvs-migration.html[git for CVS users].
diff --git a/Makefile b/Makefile
index dbf19c627..004c2169c 100644
--- a/Makefile
+++ b/Makefile
@@ -154,8 +154,7 @@ PROGRAMS = \
git-hash-object$X git-index-pack$X git-local-fetch$X \
git-mailinfo$X git-merge-base$X \
git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
- git-peek-remote$X git-prune-packed$X \
- git-receive-pack$X git-rev-parse$X \
+ git-peek-remote$X git-prune-packed$X git-receive-pack$X \
git-send-pack$X git-shell$X \
git-show-index$X git-ssh-fetch$X \
git-ssh-upload$X git-unpack-file$X \
@@ -168,7 +167,7 @@ PROGRAMS = \
BUILT_INS = git-log$X git-whatchanged$X git-show$X \
git-count-objects$X git-diff$X git-push$X \
git-grep$X git-add$X git-rm$X git-rev-list$X \
- git-check-ref-format$X \
+ git-check-ref-format$X git-rev-parse$X \
git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
git-ls-files$X git-ls-tree$X \
git-read-tree$X git-commit-tree$X \
@@ -210,7 +209,7 @@ DIFF_OBJS = \
diffcore-delta.o log-tree.o
LIB_OBJS = \
- blob.o commit.o connect.o csum-file.o base85.o \
+ blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \
object.o pack-check.o patch-delta.o path.o pkt-line.o \
quote.o read-cache.o refs.o run-command.o dir.o \
@@ -222,7 +221,7 @@ LIB_OBJS = \
BUILTIN_OBJS = \
builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
- builtin-rm.o builtin-init-db.o \
+ builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
builtin-tar-tree.o builtin-upload-tar.o \
builtin-ls-files.o builtin-ls-tree.o \
builtin-read-tree.o builtin-commit-tree.o \
@@ -496,37 +495,43 @@ $(BUILT_INS): git$X
rm -f $@ && ln git$X $@
common-cmds.h: Documentation/git-*.txt
- ./generate-cmdlist.sh > $@
+ ./generate-cmdlist.sh > $@+
+ mv $@+ $@
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
- rm -f $@
+ rm -f $@ $@+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
-e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
- $@.sh >$@
- chmod +x $@
+ $@.sh >$@+
+ chmod +x $@+
+ mv $@+ $@
$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
- rm -f $@
+ rm -f $@ $@+
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
- $@.perl >$@
- chmod +x $@
+ $@.perl >$@+
+ chmod +x $@+
+ mv $@+ $@
$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
- rm -f $@
+ rm -f $@ $@+
sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
-e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
- $@.py >$@
- chmod +x $@
+ $@.py >$@+
+ chmod +x $@+
+ mv $@+ $@
git-cherry-pick: git-revert
- cp $< $@
+ cp $< $@+
+ mv $@+ $@
git-status: git-commit
- cp $< $@
+ cp $< $@+
+ mv $@+ $@
# These can record GIT_VERSION
git$X git.spec \
@@ -620,6 +625,9 @@ test-date$X: test-date.c date.o ctype.o
test-delta$X: test-delta.c diff-delta.o patch-delta.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
+test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
+ $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
+
check:
for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
@@ -653,7 +661,8 @@ install-doc:
### Maintainer's dist rules
git.spec: git.spec.in
- sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
+ sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
+ mv $@+ $@
GIT_TARNAME=git-$(GIT_VERSION)
dist: git.spec git-tar-tree
@@ -680,7 +689,7 @@ dist-doc:
:
rm -fr .doc-tmp-dir
mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
- $(MAKE) -C Documentation DESTDIR=. \
+ $(MAKE) -C Documentation DESTDIR=./ \
man1=../.doc-tmp-dir/man1 \
man7=../.doc-tmp-dir/man7 \
install
@@ -724,4 +733,3 @@ check-docs::
*) echo "no link: $$v";; \
esac ; \
done | sort
-
diff --git a/builtin-add.c b/builtin-add.c
index 6166f66bc..02fe38b0c 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -8,6 +8,7 @@
#include "cache.h"
#include "builtin.h"
#include "dir.h"
+#include "cache-tree.h"
static const char builtin_add_usage[] =
"git-add [-n] [-v] <filepattern>...";
@@ -117,6 +118,7 @@ static int add_file_to_index(const char *path, int verbose)
die("unable to add %s to index",path);
if (verbose)
printf("add '%s'\n", path);
+ cache_tree_invalidate_path(active_cache_tree, path);
return 0;
}
diff --git a/builtin-apply.c b/builtin-apply.c
index 4056b9d67..6a4fb9663 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -8,6 +8,7 @@
*/
#include <fnmatch.h>
#include "cache.h"
+#include "cache-tree.h"
#include "quote.h"
#include "blob.h"
#include "delta.h"
@@ -1334,6 +1335,7 @@ static int apply_line(char *output, const char *patch, int plen)
static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
{
+ int match_beginning, match_end;
char *buf = desc->buffer;
const char *patch = frag->patch;
int offset, size = frag->size;
@@ -1396,10 +1398,22 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
newlines = new;
leading = frag->leading;
trailing = frag->trailing;
+
+ /*
+ * If we don't have any leading/trailing data in the patch,
+ * we want it to match at the beginning/end of the file.
+ */
+ match_beginning = !leading && (frag->oldpos == 1);
+ match_end = !trailing;
+
lines = 0;
pos = frag->newpos;
for (;;) {
offset = find_offset(buf, desc->size, oldlines, oldsize, pos, &lines);
+ if (match_end && offset + oldsize != desc->size)
+ offset = -1;
+ if (match_beginning && offset)
+ offset = -1;
if (offset >= 0) {
int diff = newsize - oldsize;
unsigned long size = desc->size + diff;
@@ -1429,6 +1443,10 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
/* Am I at my context limits? */
if ((leading <= p_context) && (trailing <= p_context))
break;
+ if (match_beginning || match_end) {
+ match_beginning = match_end = 0;
+ continue;
+ }
/* Reduce the number of context lines
* Reduce both leading and trailing if they are equal
* otherwise just reduce the larger context.
@@ -1918,6 +1936,7 @@ static void remove_file(struct patch *patch)
if (write_index) {
if (remove_file_from_cache(patch->old_name) < 0)
die("unable to remove %s from index", patch->old_name);
+ cache_tree_invalidate_path(active_cache_tree, patch->old_name);
}
if (!cached)
unlink(patch->old_name);
@@ -2019,8 +2038,9 @@ static void create_file(struct patch *patch)
if (!mode)
mode = S_IFREG | 0644;
- create_one_file(path, mode, buf, size);
+ create_one_file(path, mode, buf, size);
add_index_file(path, mode, buf, size);
+ cache_tree_invalidate_path(active_cache_tree, path);
}
static void write_out_one_result(struct patch *patch)
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 8ab136e98..4d36817e5 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -141,7 +141,7 @@ int cmd_cat_file(int argc, const char **argv, char **envp)
/* custom pretty-print here */
if (!strcmp(type, tree_type))
- return execl_git_cmd("ls-tree", argv[2], NULL);
+ return cmd_ls_tree(2, argv + 1, NULL);
buf = read_sha1_file(sha1, type, &size);
if (!buf)
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index cc53b81ac..58cf65856 100644
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
@@ -138,11 +138,15 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
if (opt->diffopt.detect_rename)
opt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
DIFF_SETUP_USE_CACHE);
- while (fgets(line, sizeof(line), stdin))
- if (line[0] == '\n')
+ while (fgets(line, sizeof(line), stdin)) {
+ unsigned char sha1[20];
+
+ if (get_sha1_hex(line, sha1)) {
+ fputs(line, stdout);
fflush(stdout);
+ }
else
diff_tree_stdin(line);
-
+ }
return 0;
}
diff --git a/builtin-log.c b/builtin-log.c
index c8feb0f79..6612f4c2a 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -85,6 +85,23 @@ static int istitlechar(char c)
(c >= '0' && c <= '9') || c == '.' || c == '_';
}
+static char *extra_headers = NULL;
+static int extra_headers_size = 0;
+
+static int git_format_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "format.headers")) {
+ int len = strlen(value);
+ extra_headers_size += len + 1;
+ extra_headers = realloc(extra_headers, extra_headers_size);
+ extra_headers[extra_headers_size - len - 1] = 0;
+ strcat(extra_headers, value);
+ return 0;
+ }
+ return git_default_config(var, value);
+}
+
+
static FILE *realstdout = NULL;
static char *output_directory = NULL;
@@ -148,7 +165,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
int nr = 0, total, i, j;
int use_stdout = 0;
int numbered = 0;
+ int start_number = -1;
int keep_subject = 0;
+ char *add_signoff = NULL;
init_revisions(&rev);
rev.commit_format = CMIT_FMT_EMAIL;
@@ -160,6 +179,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
rev.ignore_merges = 1;
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
+ git_config(git_format_config);
+ rev.extra_headers = extra_headers;
+
/*
* Parse the arguments before setup_revisions(), or something
* like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
@@ -171,11 +193,20 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
else if (!strcmp(argv[i], "-n") ||
!strcmp(argv[i], "--numbered"))
numbered = 1;
+ else if (!strncmp(argv[i], "--start-number=", 15))
+ start_number = strtol(argv[i] + 15, NULL, 10);
+ else if (!strcmp(argv[i], "--start-number")) {
+ i++;
+ if (i == argc)
+ die("Need a number for --start-number");
+ start_number = strtol(argv[i], NULL, 10);
+ }
else if (!strcmp(argv[i], "-k") ||
!strcmp(argv[i], "--keep-subject")) {
keep_subject = 1;
rev.total = -1;
- } else if (!strcmp(argv[i], "-o")) {
+ }
+ else if (!strcmp(argv[i], "-o")) {
if (argc < 3)
die ("Which directory?");
if (mkdir(argv[i + 1], 0777) < 0 && errno != EEXIST)
@@ -184,6 +215,16 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
output_directory = strdup(argv[i + 1]);
i++;
}
+ else if (!strcmp(argv[i], "--signoff") ||
+ !strcmp(argv[i], "-s")) {
+ const char *committer = git_committer_info(1);
+ const char *endpos = strchr(committer, '>');
+ if (!endpos)
+ die("bogos committer info %s\n", committer);
+ add_signoff = xmalloc(endpos - committer + 2);
+ memcpy(add_signoff, committer, endpos - committer + 1);
+ add_signoff[endpos - committer + 1] = 0;
+ }
else if (!strcmp(argv[i], "--attach"))
rev.mime_boundary = git_version_string;
else if (!strncmp(argv[i], "--attach=", 9))
@@ -193,7 +234,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
}
argc = j;
- if (numbered && keep_subject < 0)
+ if (start_number < 0)
+ start_number = 1;
+ if (numbered && keep_subject)
die ("-n and -k are mutually exclusive.");
argc = setup_revisions(argc, argv, &rev, "HEAD");
@@ -219,16 +262,26 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
}
total = nr;
if (numbered)
- rev.total = total;
+ rev.total = total + start_number - 1;
+ rev.add_signoff = add_signoff;
while (0 <= --nr) {
int shown;
commit = list[nr];
- rev.nr = total - nr;
+ rev.nr = total - nr + (start_number - 1);
if (!use_stdout)
reopen_stdout(commit, rev.nr, keep_subject);
shown = log_tree_commit(&rev, commit);
free(commit->buffer);
commit->buffer = NULL;
+
+ /* We put one extra blank line between formatted
+ * patches and this flag is used by log-tree code
+ * to see if it needs to emit a LF before showing
+ * the log; when using one file per patch, we do
+ * not want the extra blank line.
+ */
+ if (!use_stdout)
+ rev.shown_one = 0;
if (shown) {
if (rev.mime_boundary)
printf("\n--%s%s--\n\n\n",
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index ec40d013c..21361dff4 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -9,6 +9,7 @@
#include "object.h"
#include "tree.h"
+#include "cache-tree.h"
#include <sys/time.h>
#include <signal.h>
#include "builtin.h"
@@ -427,6 +428,12 @@ static void verify_uptodate(struct cache_entry *ce)
die("Entry '%s' not uptodate. Cannot merge.", ce->name);
}
+static void invalidate_ce_path(struct cache_entry *ce)
+{
+ if (ce)
+ cache_tree_invalidate_path(active_cache_tree, ce->name);
+}
+
/*
* We do not want to remove or overwrite a working tree file that
* is not tracked.
@@ -457,10 +464,13 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old)
*merge = *old;
} else {
verify_uptodate(old);
+ invalidate_ce_path(old);
}
}
- else
+ else {
verify_absent(merge->name, "overwritten");
+ invalidate_ce_path(merge);
+ }
merge->ce_flags &= ~htons(CE_STAGEMASK);
add_cache_entry(merge, ADD_CACHE_OK_TO_ADD);
@@ -475,6 +485,7 @@ static int deleted_entry(struct cache_entry *ce, struct cache_entry *old)
verify_absent(ce->name, "removed");
ce->ce_mode = 0;
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD);
+ invalidate_ce_path(ce);
return 1;
}
@@ -740,24 +751,59 @@ static int oneway_merge(struct cache_entry **src)
static int read_cache_unmerged(void)
{
- int i, deleted;
+ int i;
struct cache_entry **dst;
+ struct cache_entry *last = NULL;
read_cache();
dst = active_cache;
- deleted = 0;
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce)) {
- deleted++;
- continue;
+ if (last && !strcmp(ce->name, last->name))
+ continue;
+ invalidate_ce_path(ce);
+ last = ce;
+ ce->ce_mode = 0;
+ ce->ce_flags &= ~htons(CE_STAGEMASK);
+ }
+ *dst++ = ce;
+ }
+ active_nr = dst - active_cache;
+ return !!last;
+}
+
+static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
+{
+ struct tree_entry_list *ent;
+ int cnt;
+
+ memcpy(it->sha1, tree->object.sha1, 20);
+ for (cnt = 0, ent = tree->entries; ent; ent = ent->next) {
+ if (!ent->directory)
+ cnt++;
+ else {
+ struct cache_tree_sub *sub;
+ struct tree *subtree = (struct tree *)ent->item.tree;
+ if (!subtree->object.parsed)
+ parse_tree(subtree);
+ sub = cache_tree_sub(it, ent->name);
+ sub->cache_tree = cache_tree();
+ prime_cache_tree_rec(sub->cache_tree, subtree);
+ cnt += sub->cache_tree->entry_count;
}
- if (deleted)
- *dst = ce;
- dst++;
}
- active_nr -= deleted;
- return deleted;
+ it->entry_count = cnt;
+}
+
+static void prime_cache_tree(void)
+{
+ struct tree *tree = (struct tree *)trees->item;
+ if (!tree)
+ return;
+ active_cache_tree = cache_tree();
+ prime_cache_tree_rec(active_cache_tree, tree);
+
}
static const char read_tree_usage[] = "git-read-tree (<sha> | -m [--aggressive] [-u | -i] <sha1> [<sha2> [<sha3>]])";
@@ -805,7 +851,10 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
continue;
}
- /* This differs from "-m" in that we'll silently ignore unmerged entries */
+ /* This differs from "-m" in that we'll silently ignore
+ * unmerged entries and overwrite working tree files that
+ * correspond to them.
+ */
if (!strcmp(arg, "--reset")) {
if (stage || merge)
usage(read_tree_usage);
@@ -861,10 +910,9 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
fn = twoway_merge;
break;
case 3:
- fn = threeway_merge;
- break;
default:
fn = threeway_merge;
+ cache_tree_free(&active_cache_tree);
break;
}
@@ -875,6 +923,18 @@ int cmd_read_tree(int argc, const char **argv, char **envp)
}
unpack_trees(fn);
+
+ /*
+ * When reading only one tree (either the most basic form,
+ * "-m ent" or "--reset ent" form), we can obtain a fully
+ * valid cache-tree because the index must match exactly
+ * what came from the tree.
+ */
+ if (trees && trees->item && (!merge || (stage == 2))) {
+ cache_tree_free(&active_cache_tree);
+ prime_cache_tree();
+ }
+
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))
die("unable to write new index file");
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index f11dbd65c..5277d3cf1 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -103,6 +103,7 @@ static struct object_list **process_blob(struct blob *blob,
if (obj->flags & (UNINTERESTING | SEEN))
return p;
obj->flags |= SEEN;
+ name = strdup(name);
return add_object(obj, p, path, name);
}
@@ -122,6 +123,7 @@ static struct object_list **process_tree(struct tree *tree,
if (parse_tree(tree) < 0)
die("bad tree object %s", sha1_to_hex(obj->sha1));
obj->flags |= SEEN;
+ name = strdup(name);
p = add_object(obj, p, path, name);
me.up = path;
me.elem = name;
@@ -134,6 +136,7 @@ static struct object_list **process_tree(struct tree *tree,
p = process_tree(entry->item.tree, p, &me, entry->name);
else
p = process_blob(entry->item.blob, p, &me, entry->name);
+ free(entry->name);
free(entry);
entry = next;
}
diff --git a/rev-parse.c b/builtin-rev-parse.c
index 4e2d9fbdf..c353a481b 100644
--- a/rev-parse.c
+++ b/builtin-rev-parse.c
@@ -7,6 +7,7 @@
#include "commit.h"
#include "refs.h"
#include "quote.h"
+#include "builtin.h"
#define DO_REVS 1
#define DO_NOREV 2
@@ -163,7 +164,7 @@ static int show_file(const char *arg)
return 0;
}
-int main(int argc, char **argv)
+int cmd_rev_parse(int argc, const char **argv, char **envp)
{
int i, as_is = 0, verify = 0;
unsigned char sha1[20];
diff --git a/builtin-rm.c b/builtin-rm.c
index 9014c6155..e7793a20f 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -6,6 +6,7 @@
#include "cache.h"
#include "builtin.h"
#include "dir.h"
+#include "cache-tree.h"
static const char builtin_rm_usage[] =
"git-rm [-n] [-v] [-f] <filepattern>...";
@@ -117,6 +118,7 @@ int cmd_rm(int argc, const char **argv, char **envp)
if (remove_file_from_cache(path))
die("git rm: unable to remove %s", path);
+ cache_tree_invalidate_path(active_cache_tree, path);
}
/*
diff --git a/builtin.h b/builtin.h
index 738ec3d94..ffa9340c3 100644
--- a/builtin.h
+++ b/builtin.h
@@ -43,5 +43,6 @@ extern int cmd_diff_index(int argc, const char **argv, char **envp);
extern int cmd_diff_stages(int argc, const char **argv, char **envp);
extern int cmd_diff_tree(int argc, const char **argv, char **envp);
extern int cmd_cat_file(int argc, const char **argv, char **envp);
+extern int cmd_rev_parse(int argc, const char **argv, char **envp);
#endif
diff --git a/cache-tree.c b/cache-tree.c
new file mode 100644
index 000000000..a880c97b3
--- /dev/null
+++ b/cache-tree.c
@@ -0,0 +1,531 @@
+#include "cache.h"
+#include "tree.h"
+#include "cache-tree.h"
+
+#define DEBUG 0
+
+struct cache_tree *cache_tree(void)
+{
+ struct cache_tree *it = xcalloc(1, sizeof(struct cache_tree));
+ it->entry_count = -1;
+ return it;
+}
+
+void cache_tree_free(struct cache_tree **it_p)
+{
+ int i;
+ struct cache_tree *it = *it_p;
+
+ if (!it)
+ return;
+ for (i = 0; i < it->subtree_nr; i++)
+ if (it->down[i])
+ cache_tree_free(&it->down[i]->cache_tree);
+ free(it->down);
+ free(it);
+ *it_p = NULL;
+}
+
+static int subtree_name_cmp(const char *one, int onelen,
+ const char *two, int twolen)
+{
+ if (onelen < twolen)
+ return -1;
+ if (twolen < onelen)
+ return 1;
+ return memcmp(one, two, onelen);
+}
+
+static int subtree_pos(struct cache_tree *it, const char *path, int pathlen)
+{
+ struct cache_tree_sub **down = it->down;
+ int lo, hi;
+ lo = 0;
+ hi = it->subtree_nr;
+ while (lo < hi) {
+ int mi = (lo + hi) / 2;
+ struct cache_tree_sub *mdl = down[mi];
+ int cmp = subtree_name_cmp(path, pathlen,
+ mdl->name, mdl->namelen);
+ if (!cmp)
+ return mi;
+ if (cmp < 0)
+ hi = mi;
+ else
+ lo = mi + 1;
+ }
+ return -lo-1;
+}
+
+static struct cache_tree_sub *find_subtree(struct cache_tree *it,
+ const char *path,
+ int pathlen,
+ int create)
+{
+ struct cache_tree_sub *down;
+ int pos = subtree_pos(it, path, pathlen);
+ if (0 <= pos)
+ return it->down[pos];
+ if (!create)
+ return NULL;
+
+ pos = -pos-1;
+ if (it->subtree_alloc <= it->subtree_nr) {
+ it->subtree_alloc = alloc_nr(it->subtree_alloc);
+ it->down = xrealloc(it->down, it->subtree_alloc *
+ sizeof(*it->down));
+ }
+ it->subtree_nr++;
+
+ down = xmalloc(sizeof(*down) + pathlen + 1);
+ down->cache_tree = NULL;
+ down->namelen = pathlen;
+ memcpy(down->name, path, pathlen);
+ down->name[pathlen] = 0;
+
+ if (pos < it->subtree_nr)
+ memmove(it->down + pos + 1,
+ it->down + pos,
+ sizeof(down) * (it->subtree_nr - pos - 1));
+ it->down[pos] = down;
+ return down;
+}
+
+struct cache_tree_sub *cache_tree_sub(struct cache_tree *it, const char *path)
+{
+ int pathlen = strlen(path);
+ return find_subtree(it, path, pathlen, 1);
+}
+
+void cache_tree_invalidate_path(struct cache_tree *it, const char *path)
+{
+ /* a/b/c
+ * ==> invalidate self
+ * ==> find "a", have it invalidate "b/c"
+ * a
+ * ==> invalidate self
+ * ==> if "a" exists as a subtree, remove it.
+ */
+ const char *slash;
+ int namelen;
+ struct cache_tree_sub *down;
+
+#if DEBUG
+ fprintf(stderr, "cache-tree invalidate <%s>\n", path);
+#endif
+
+ if (!it)
+ return;
+ slash = strchr(path, '/');
+ it->entry_count = -1;
+ if (!slash) {
+ int pos;
+ namelen = strlen(path);
+ pos = subtree_pos(it, path, namelen);
+ if (0 <= pos) {
+ cache_tree_free(&it->down[pos]->cache_tree);
+ free(it->down[pos]);
+ /* 0 1 2 3 4 5
+ * ^ ^subtree_nr = 6
+ * pos
+ * move 4 and 5 up one place (2 entries)
+ * 2 = 6 - 3 - 1 = subtree_nr - pos - 1
+ */
+ memmove(it->down+pos, it->down+pos+1,
+ sizeof(struct cache_tree_sub *) *
+ (it->subtree_nr - pos - 1));
+ it->subtree_nr--;
+ }
+ return;
+ }
+ namelen = slash - path;
+ down = find_subtree(it, path, namelen, 0);
+ if (down)
+ cache_tree_invalidate_path(down->cache_tree, slash + 1);
+}
+
+static int verify_cache(struct cache_entry **cache,
+ int entries)
+{
+ int i, funny;
+
+ /* Verify that the tree is merged */
+ funny = 0;
+ for (i = 0; i < entries; i++) {
+ struct cache_entry *ce = cache[i];
+ if (ce_stage(ce)) {
+ if (10 < ++funny) {
+ fprintf(stderr, "...\n");
+ break;
+ }
+ fprintf(stderr, "%s: unmerged (%s)\n",
+ ce->name, sha1_to_hex(ce->sha1));
+ }
+ }
+ if (funny)
+ return -1;
+
+ /* Also verify that the cache does not have path and path/file
+ * at the same time. At this point we know the cache has only
+ * stage 0 entries.
+ */
+ funny = 0;
+ for (i = 0; i < entries - 1; i++) {
+ /* path/file always comes after path because of the way
+ * the cache is sorted. Also path can appear only once,
+ * which means conflicting one would immediately follow.
+ */
+ const char *this_name = cache[i]->name;
+ const char *next_name = cache[i+1]->name;
+ int this_len = strlen(this_name);
+ if (this_len < strlen(next_name) &&
+ strncmp(this_name, next_name, this_len) == 0 &&
+ next_name[this_len] == '/') {
+ if (10 < ++funny) {
+ fprintf(stderr, "...\n");
+ break;
+ }
+ fprintf(stderr, "You have both %s and %s\n",
+ this_name, next_name);
+ }
+ }
+ if (funny)
+ return -1;
+ return 0;
+}
+
+static void discard_unused_subtrees(struct cache_tree *it)
+{
+ struct cache_tree_sub **down = it->down;
+ int nr = it->subtree_nr;
+ int dst, src;
+ for (dst = src = 0; src < nr; src++) {
+ struct cache_tree_sub *s = down[src];
+ if (s->used)
+ down[dst++] = s;
+ else {
+ cache_tree_free(&s->cache_tree);
+ free(s);
+ it->subtree_nr--;
+ }
+ }
+}
+
+int cache_tree_fully_valid(struct cache_tree *it)
+{
+ int i;
+ if (!it)
+ return 0;
+ if (it->entry_count < 0 || !has_sha1_file(it->sha1))
+ return 0;
+ for (i = 0; i < it->subtree_nr; i++) {
+ if (!cache_tree_fully_valid(it->down[i]->cache_tree))
+ return 0;
+ }
+ return 1;
+}
+
+static int update_one(struct cache_tree *it,
+ struct cache_entry **cache,
+ int entries,
+ const char *base,
+ int baselen,
+ int missing_ok,
+ int dryrun)
+{
+ unsigned long size, offset;
+ char *buffer;
+ int i;
+
+ if (0 <= it->entry_count && has_sha1_file(it->sha1))
+ return it->entry_count;
+
+ /*
+ * We first scan for subtrees and update them; we start by
+ * marking existing subtrees -- the ones that are unmarked
+ * should not be in the result.
+ */
+ for (i = 0; i < it->subtree_nr; i++)
+ it->down[i]->used = 0;
+
+ /*
+ * Find the subtrees and update them.
+ */
+ for (i = 0; i < entries; i++) {
+ struct cache_entry *ce = cache[i];
+ struct cache_tree_sub *sub;
+ const char *path, *slash;
+ int pathlen, sublen, subcnt;
+
+ path = ce->name;
+ pathlen = ce_namelen(ce);
+ if (pathlen <= baselen || memcmp(base, path, baselen))
+ break; /* at the end of this level */
+
+ slash = strchr(path + baselen, '/');
+ if (!slash)
+ continue;
+ /*
+ * a/bbb/c (base = a/, slash = /c)
+ * ==>
+ * path+baselen = bbb/c, sublen = 3
+ */
+ sublen = slash - (path + baselen);
+ sub = find_subtree(it, path + baselen, sublen, 1);
+ if (!sub->cache_tree)
+ sub->cache_tree = cache_tree();
+ subcnt = update_one(sub->cache_tree,
+ cache + i, entries - i,
+ path,
+ baselen + sublen + 1,
+ missing_ok,
+ dryrun);
+ i += subcnt - 1;
+ sub->used = 1;
+ }
+
+ discard_unused_subtrees(it);
+
+ /*
+ * Then write out the tree object for this level.
+ */
+ size = 8192;
+ buffer = xmalloc(size);
+ offset = 0;
+
+ for (i = 0; i < entries; i++) {
+ struct cache_entry *ce = cache[i];
+ struct cache_tree_sub *sub;
+ const char *path, *slash;
+ int pathlen, entlen;
+ const unsigned char *sha1;
+ unsigned mode;
+
+ path = ce->name;
+ pathlen = ce_namelen(ce);
+ if (pathlen <= baselen || memcmp(base, path, baselen))
+ break; /* at the end of this level */
+
+ slash = strchr(path + baselen, '/');
+ if (slash) {
+ entlen = slash - (path + baselen);
+ sub = find_subtree(it, path + baselen, entlen, 0);
+ if (!sub)
+ die("cache-tree.c: '%.*s' in '%s' not found",
+ entlen, path + baselen, path);
+ i += sub->cache_tree->entry_count - 1;
+ sha1 = sub->cache_tree->sha1;
+ mode = S_IFDIR;
+ }
+ else {
+ sha1 = ce->sha1;
+ mode = ntohl(ce->ce_mode);
+ entlen = pathlen - baselen;
+ }
+ if (!missing_ok && !has_sha1_file(sha1))
+ return error("invalid object %s", sha1_to_hex(sha1));
+
+ if (!ce->ce_mode)
+ continue; /* entry being removed */
+
+ if (size < offset + entlen + 100) {
+ size = alloc_nr(offset + entlen + 100);
+ buffer = xrealloc(buffer, size);
+ }
+ offset += sprintf(buffer + offset,
+ "%o %.*s", mode, entlen, path + baselen);
+ buffer[offset++] = 0;
+ memcpy(buffer + offset, sha1, 20);
+ offset += 20;
+
+#if DEBUG
+ fprintf(stderr, "cache-tree update-one %o %.*s\n",
+ mode, entlen, path + baselen);
+#endif
+ }
+
+ if (dryrun) {
+ unsigned char hdr[200];
+ int hdrlen;
+ write_sha1_file_prepare(buffer, offset, tree_type, it->sha1,
+ hdr, &hdrlen);
+ }
+ else
+ write_sha1_file(buffer, offset, tree_type, it->sha1);
+ free(buffer);
+ it->entry_count = i;
+#if DEBUG
+ fprintf(stderr, "cache-tree update-one (%d ent, %d subtree) %s\n",
+ it->entry_count, it->subtree_nr,
+ sha1_to_hex(it->sha1));
+#endif
+ return i;
+}
+
+int cache_tree_update(struct cache_tree *it,
+ struct cache_entry **cache,
+ int entries,
+ int missing_ok,
+ int dryrun)
+{
+ int i;
+ i = verify_cache(cache, entries);
+ if (i)
+ return i;
+ i = update_one(it, cache, entries, "", 0, missing_ok, dryrun);
+ if (i < 0)
+ return i;
+ return 0;
+}
+
+static void *write_one(struct cache_tree *it,
+ char *path,
+ int pathlen,
+ char *buffer,
+ unsigned long *size,
+ unsigned long *offset)
+{
+ int i;
+
+ /* One "cache-tree" entry consists of the following:
+ * path (NUL terminated)
+ * entry_count, subtree_nr ("%d %d\n")
+ * tree-sha1 (missing if invalid)
+ * subtree_nr "cache-tree" entries for subtrees.
+ */
+ if (*size < *offset + pathlen + 100) {
+ *size = alloc_nr(*offset + pathlen + 100);
+ buffer = xrealloc(buffer, *size);
+ }
+ *offset += sprintf(buffer + *offset, "%.*s%c%d %d\n",
+ pathlen, path, 0,
+ it->entry_count, it->subtree_nr);
+
+#if DEBUG
+ if (0 <= it->entry_count)
+ fprintf(stderr, "cache-tree <%.*s> (%d ent, %d subtree) %s\n",
+ pathlen, path, it->entry_count, it->subtree_nr,
+ sha1_to_hex(it->sha1));
+ else
+ fprintf(stderr, "cache-tree <%.*s> (%d subtree) invalid\n",
+ pathlen, path, it->subtree_nr);
+#endif
+
+ if (0 <= it->entry_count) {
+ memcpy(buffer + *offset, it->sha1, 20);
+ *offset += 20;
+ }
+ for (i = 0; i < it->subtree_nr; i++) {
+ struct cache_tree_sub *down = it->down[i];
+ if (i) {
+ struct cache_tree_sub *prev = it->down[i-1];
+ if (subtree_name_cmp(down->name, down->namelen,
+ prev->name, prev->namelen) <= 0)
+ die("fatal - unsorted cache subtree");
+ }
+ buffer = write_one(down->cache_tree, down->name, down->namelen,
+ buffer, size, offset);
+ }
+ return buffer;
+}
+
+void *cache_tree_write(struct cache_tree *root, unsigned long *size_p)
+{
+ char path[PATH_MAX];
+ unsigned long size = 8192;
+ char *buffer = xmalloc(size);
+
+ *size_p = 0;
+ path[0] = 0;
+ return write_one(root, path, 0, buffer, &size, size_p);
+}
+
+static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
+{
+ const char *buf = *buffer;
+ unsigned long size = *size_p;
+ const char *cp;
+ char *ep;
+ struct cache_tree *it;
+ int i, subtree_nr;
+
+ it = NULL;
+ /* skip name, but make sure name exists */
+ while (size && *buf) {
+ size--;
+ buf++;
+ }
+ if (!size)
+ goto free_return;
+ buf++; size--;
+ it = cache_tree();
+
+ cp = buf;
+ it->entry_count = strtol(cp, &ep, 10);
+ if (cp == ep)
+ goto free_return;
+ cp = ep;
+ subtree_nr = strtol(cp, &ep, 10);
+ if (cp == ep)
+ goto free_return;
+ while (size && *buf && *buf != '\n') {
+ size--;
+ buf++;
+ }
+ if (!size)
+ goto free_return;
+ buf++; size--;
+ if (0 <= it->entry_count) {
+ if (size < 20)
+ goto free_return;
+ memcpy(it->sha1, buf, 20);
+ buf += 20;
+ size -= 20;
+ }
+
+#if DEBUG
+ if (0 <= it->entry_count)
+ fprintf(stderr, "cache-tree <%s> (%d ent, %d subtree) %s\n",
+ *buffer, it->entry_count, subtree_nr,
+ sha1_to_hex(it->sha1));
+ else
+ fprintf(stderr, "cache-tree <%s> (%d subtrees) invalid\n",
+ *buffer, subtree_nr);
+#endif
+
+ /*
+ * Just a heuristic -- we do not add directories that often but
+ * we do not want to have to extend it immediately when we do,
+ * hence +2.
+ */
+ it->subtree_alloc = subtree_nr + 2;
+ it->down = xcalloc(it->subtree_alloc, sizeof(struct cache_tree_sub *));
+ for (i = 0; i < subtree_nr; i++) {
+ /* read each subtree */
+ struct cache_tree *sub;
+ struct cache_tree_sub *subtree;
+ const char *name = buf;
+
+ sub = read_one(&buf, &size);
+ if (!sub)
+ goto free_return;
+ subtree = cache_tree_sub(it, name);
+ subtree->cache_tree = sub;
+ }
+ if (subtree_nr != it->subtree_nr)
+ die("cache-tree: internal error");
+ *buffer = buf;
+ *size_p = size;
+ return it;
+
+ free_return:
+ cache_tree_free(&it);
+ return NULL;
+}
+
+struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
+{
+ if (buffer[0])
+ return NULL; /* not the whole tree */
+ return read_one(&buffer, &size);
+}
diff --git a/cache-tree.h b/cache-tree.h
new file mode 100644
index 000000000..72c64801f
--- /dev/null
+++ b/cache-tree.h
@@ -0,0 +1,31 @@
+#ifndef CACHE_TREE_H
+#define CACHE_TREE_H
+
+struct cache_tree;
+struct cache_tree_sub {
+ struct cache_tree *cache_tree;
+ int namelen;
+ int used;
+ char name[FLEX_ARRAY];
+};
+
+struct cache_tree {
+ int entry_count; /* negative means "invalid" */
+ unsigned char sha1[20];
+ int subtree_nr;
+ int subtree_alloc;
+ struct cache_tree_sub **down;
+};
+
+struct cache_tree *cache_tree(void);
+void cache_tree_free(struct cache_tree **);
+void cache_tree_invalidate_path(struct cache_tree *, const char *);
+struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
+
+void *cache_tree_write(struct cache_tree *root, unsigned long *size_p);
+struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
+
+int cache_tree_fully_valid(struct cache_tree *);
+int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int);
+
+#endif
diff --git a/cache.h b/cache.h
index 07212b62d..d530af97c 100644
--- a/cache.h
+++ b/cache.h
@@ -114,6 +114,7 @@ static inline unsigned int create_ce_mode(unsigned int mode)
extern struct cache_entry **active_cache;
extern unsigned int active_nr, active_alloc, active_cache_changed;
+extern struct cache_tree *active_cache_tree;
#define GIT_DIR_ENVIRONMENT "GIT_DIR"
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
diff --git a/checkout-index.c b/checkout-index.c
index cc3a745c1..9876af6fd 100644
--- a/checkout-index.c
+++ b/checkout-index.c
@@ -39,6 +39,7 @@
#include "cache.h"
#include "strbuf.h"
#include "quote.h"
+#include "cache-tree.h"
#define CHECKOUT_ALL 4
static const char *prefix;
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684c4..aac877974 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -567,7 +567,6 @@ sub precommit_check {
sub svn_checkout_tree {
my ($svn_rev, $treeish) = @_;
my $from = file_to_s("$REV_DIR/$svn_rev");
- assert_svn_wc_clean($svn_rev);
assert_tree($from);
print "diff-tree $from $treeish\n";
my $pid = open my $diff_fh, '-|';
diff --git a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh b/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
index 6fa7889e9..23a5a2a22 100644
--- a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
+++ b/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
@@ -20,9 +20,10 @@ a_empty_cr=
a_empty_crlf=
cd import
- cat >> kw.c <<''
+ cat >> kw.c <<\EOF
/* Make it look like somebody copied a file from CVS into SVN: */
/* $Id: kw.c,v 1.1.1.1 1994/03/06 00:00:00 eric Exp $ */
+EOF
printf "Hello\r\nWorld\r\n" > crlf
a_crlf=`git-hash-object -w crlf`
diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 781badbc5..b836047cf 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -425,7 +425,7 @@ class DiffWindow:
class GitView:
""" This is the main class
"""
- version = "0.7"
+ version = "0.8"
def __init__(self, with_diff=0):
self.with_diff = with_diff
@@ -449,8 +449,17 @@ class GitView:
self.accel_group = gtk.AccelGroup()
self.window.add_accel_group(self.accel_group)
+ self.accel_group.connect_group(0xffc2, 0, gtk.ACCEL_LOCKED, self.refresh);
- self.construct()
+ self.window.add(self.construct())
+
+ def refresh(self, widget, event=None, *arguments, **keywords):
+ self.get_encoding()
+ self.get_bt_sha1()
+ Commit.children_sha1 = {}
+ self.set_branch(sys.argv[without_diff:])
+ self.window.show()
+ return True
def get_bt_sha1(self):
""" Update the bt_sha1 dictionary with the
@@ -500,9 +509,9 @@ class GitView:
menu_bar.show()
vbox.pack_start(menu_bar, expand=False, fill=True)
vbox.pack_start(paned, expand=True, fill=True)
- self.window.add(vbox)
paned.show()
vbox.show()
+ return vbox
def construct_top(self):
@@ -974,10 +983,15 @@ class GitView:
try:
self.treeview.set_cursor(self.index[revid])
except KeyError:
- print "Revision %s not present in the list" % revid
+ dialog = gtk.MessageDialog(parent=None, flags=0,
+ type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_CLOSE,
+ message_format=None)
+ dialog.set_markup("Revision <b>%s</b> not present in the list" % revid)
# revid == 0 is the parent of the first commit
if (revid != 0 ):
- print "Try running gitview without any options"
+ dialog.format_secondary_text("Try running gitview without any options")
+ dialog.run()
+ dialog.destroy()
self.treeview.grab_focus()
@@ -987,8 +1001,8 @@ class GitView:
window.set_diff(commit_sha1, parent_sha1, encoding)
self.treeview.grab_focus()
+without_diff = 0
if __name__ == "__main__":
- without_diff = 0
if (len(sys.argv) > 1 ):
if (sys.argv[1] == "--without-diff"):
diff --git a/contrib/gitview/gitview.txt b/contrib/gitview/gitview.txt
index fcf759c30..e3bc4f46c 100644
--- a/contrib/gitview/gitview.txt
+++ b/contrib/gitview/gitview.txt
@@ -25,6 +25,9 @@ OPTIONS
<args>
All the valid option for git-rev-list(1)
+ Key Bindings:
+ F5:
+ To reread references.
EXAMPLES
------
@@ -33,6 +36,5 @@ EXAMPLES
or drivers/scsi subdirectories
gitview --since=2.weeks.ago
- Show the changes during the last two weeks
+ Show the changes during the last two weeks
-
diff --git a/dump-cache-tree.c b/dump-cache-tree.c
new file mode 100644
index 000000000..1ccaf5177
--- /dev/null
+++ b/dump-cache-tree.c
@@ -0,0 +1,64 @@
+#include "cache.h"
+#include "tree.h"
+#include "cache-tree.h"
+
+
+static void dump_one(struct cache_tree *it, const char *pfx, const char *x)
+{
+ if (it->entry_count < 0)
+ printf("%-40s %s%s (%d subtrees)\n",
+ "invalid", x, pfx, it->subtree_nr);
+ else
+ printf("%s %s%s (%d entries, %d subtrees)\n",
+ sha1_to_hex(it->sha1), x, pfx,
+ it->entry_count, it->subtree_nr);
+}
+
+static int dump_cache_tree(struct cache_tree *it,
+ struct cache_tree *ref,
+ const char *pfx)
+{
+ int i;
+ int errs = 0;
+
+ if (!it || !ref)
+ /* missing in either */
+ return 0;
+
+ if (it->entry_count < 0) {
+ dump_one(it, pfx, "");
+ dump_one(ref, pfx, "#(ref) ");
+ if (it->subtree_nr != ref->subtree_nr)
+ errs = 1;
+ }
+ else {
+ dump_one(it, pfx, "");
+ if (memcmp(it->sha1, ref->sha1, 20) ||
+ ref->entry_count != it->entry_count ||
+ ref->subtree_nr != it->subtree_nr) {
+ dump_one(ref, pfx, "#(ref) ");
+ errs = 1;
+ }
+ }
+
+ for (i = 0; i < it->subtree_nr; i++) {
+ char path[PATH_MAX];
+ struct cache_tree_sub *down = it->down[i];
+ struct cache_tree_sub *rdwn;
+
+ rdwn = cache_tree_sub(ref, down->name);
+ sprintf(path, "%s%.*s/", pfx, down->namelen, down->name);
+ if (dump_cache_tree(down->cache_tree, rdwn->cache_tree, path))
+ errs = 1;
+ }
+ return errs;
+}
+
+int main(int ac, char **av)
+{
+ struct cache_tree *another = cache_tree();
+ if (read_cache() < 0)
+ die("unable to read index file");
+ cache_tree_update(another, active_cache, active_nr, 0, 1);
+ return dump_cache_tree(active_cache_tree, another, "");
+}
diff --git a/exec_cmd.c b/exec_cmd.c
index 44bb2f23d..c1539d12c 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -21,7 +21,7 @@ const char *git_exec_path(void)
return current_exec_path;
env = getenv("GIT_EXEC_PATH");
- if (env) {
+ if (env && *env) {
return env;
}
@@ -32,22 +32,25 @@ const char *git_exec_path(void)
int execv_git_cmd(const char **argv)
{
char git_command[PATH_MAX + 1];
- int len, i;
+ int i;
const char *paths[] = { current_exec_path,
getenv("GIT_EXEC_PATH"),
builtin_exec_path };
for (i = 0; i < ARRAY_SIZE(paths); ++i) {
+ size_t len;
+ int rc;
const char *exec_dir = paths[i];
const char *tmp;
- if (!exec_dir) continue;
+ if (!exec_dir || !*exec_dir) continue;
if (*exec_dir != '/') {
if (!getcwd(git_command, sizeof(git_command))) {
fprintf(stderr, "git: cannot determine "
- "current directory\n");
- exit(1);
+ "current directory: %s\n",
+ strerror(errno));
+ break;
}
len = strlen(git_command);
@@ -57,17 +60,28 @@ int execv_git_cmd(const char **argv)
while (*exec_dir == '/')
exec_dir++;
}
- snprintf(git_command + len, sizeof(git_command) - len,
- "/%s", exec_dir);
+
+ rc = snprintf(git_command + len,
+ sizeof(git_command) - len, "/%s",
+ exec_dir);
+ if (rc < 0 || rc >= sizeof(git_command) - len) {
+ fprintf(stderr, "git: command name given "
+ "is too long.\n");
+ break;
+ }
} else {
+ if (strlen(exec_dir) + 1 > sizeof(git_command)) {
+ fprintf(stderr, "git: command name given "
+ "is too long.\n");
+ break;
+ }
strcpy(git_command, exec_dir);
}
len = strlen(git_command);
- len += snprintf(git_command + len, sizeof(git_command) - len,
- "/git-%s", argv[0]);
-
- if (sizeof(git_command) <= len) {
+ rc = snprintf(git_command + len, sizeof(git_command) - len,
+ "/git-%s", argv[0]);
+ if (rc < 0 || rc >= sizeof(git_command) - len) {
fprintf(stderr,
"git: command name given is too long.\n");
break;
diff --git a/fsck-objects.c b/fsck-objects.c
index 59b25904c..1922b6d84 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -8,6 +8,7 @@
#include "tag.h"
#include "refs.h"
#include "pack.h"
+#include "cache-tree.h"
#define REACHABLE 0x0001
@@ -438,6 +439,28 @@ static int fsck_head_link(void)
return 0;
}
+static int fsck_cache_tree(struct cache_tree *it)
+{
+ int i;
+ int err = 0;
+
+ if (0 <= it->entry_count) {
+ struct object *obj = parse_object(it->sha1);
+ if (!obj) {
+ error("%s: invalid sha1 pointer in cache-tree",
+ sha1_to_hex(it->sha1));
+ return 1;
+ }
+ mark_reachable(obj, REACHABLE);
+ obj->used = 1;
+ if (obj->type != tree_type)
+ err |= objerror(obj, "non-tree in cache-tree");
+ }
+ for (i = 0; i < it->subtree_nr; i++)
+ err |= fsck_cache_tree(it->down[i]->cache_tree);
+ return err;
+}
+
int main(int argc, char **argv)
{
int i, heads;
@@ -547,6 +570,8 @@ int main(int argc, char **argv)
obj->used = 1;
mark_reachable(obj, REACHABLE);
}
+ if (active_cache_tree)
+ fsck_cache_tree(active_cache_tree);
}
check_connectivity();
diff --git a/git-clean.sh b/git-clean.sh
index bb56264e0..3834323bc 100755
--- a/git-clean.sh
+++ b/git-clean.sh
@@ -19,8 +19,8 @@ ignored=
ignoredonly=
cleandir=
quiet=
-rmf="rm -f"
-rmrf="rm -rf"
+rmf="rm -f --"
+rmrf="rm -rf --"
rm_refuse="echo Not removing"
echo1="echo"
diff --git a/git-clone.sh b/git-clone.sh
index d96894d4c..de59904d5 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -9,7 +9,7 @@
unset CDPATH
usage() {
- echo >&2 "Usage: $0 [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
+ echo >&2 "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
exit 1
}
@@ -102,6 +102,7 @@ quiet=
local=no
use_local=no
local_shared=no
+unset template
no_checkout=
upload_pack=
bare=
@@ -120,6 +121,11 @@ while
*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
*,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
local_shared=yes; use_local=yes ;;
+ 1,--template) usage ;;
+ *,--template)
+ shift; template="--template=$1" ;;
+ *,--template=*)
+ template="$1" ;;
*,-q|*,--quiet) quiet=-q ;;
*,--use-separate-remote)
use_separate_remote=t ;;
@@ -203,7 +209,7 @@ trap 'err=$?; cd ..; rm -r "$D"; exit $err' 0
case "$bare" in
yes) GIT_DIR="$D" ;;
*) GIT_DIR="$D/.git" ;;
-esac && export GIT_DIR && git-init-db || usage
+esac && export GIT_DIR && git-init-db ${template+"$template"} || usage
case "$bare" in
yes)
GIT_DIR="$D" ;;
diff --git a/git-commit.sh b/git-commit.sh
index 0a01a0b96..6dd04fd36 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -260,20 +260,41 @@ do
-m|--m|--me|--mes|--mess|--messa|--messag|--message)
case "$#" in 1) usage ;; esac
shift
- log_given=t$log_given
- log_message="$1"
+ log_given=m$log_given
+ if test "$log_message" = ''
+ then
+ log_message="$1"
+ else
+ log_message="$log_message
+
+$1"
+ fi
no_edit=t
shift
;;
-m*)
- log_given=t$log_given
- log_message=`expr "$1" : '-m\(.*\)'`
+ log_given=m$log_given
+ if test "$log_message" = ''
+ then
+ log_message=`expr "$1" : '-m\(.*\)'`
+ else
+ log_message="$log_message
+
+`expr "$1" : '-m\(.*\)'`"
+ fi
no_edit=t
shift
;;
--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)
- log_given=t$log_given
- log_message=`expr "$1" : '-[^=]*=\(.*\)'`
+ log_given=m$log_given
+ if test "$log_message" = ''
+ then
+ log_message=`expr "$1" : '-[^=]*=\(.*\)'`
+ else
+ log_message="$log_message
+
+`expr "$1" : '-[^=]*=\(.*\)'`"
+ fi
no_edit=t
shift
;;
@@ -378,7 +399,9 @@ esac
case "$log_given" in
tt*)
- die "Only one of -c/-C/-F/-m can be used." ;;
+ die "Only one of -c/-C/-F can be used." ;;
+*tm*|*mt*)
+ die "Option -m cannot be combined with -c/-C/-F." ;;
esac
case "$#,$also,$only,$amend" in
@@ -626,6 +649,9 @@ fi
if test -z "$no_edit"
then
{
+ echo ""
+ echo "# Please enter the commit message for your changes."
+ echo "# (Comment lines starting with '#' will not be included)"
test -z "$only_include_assumed" || echo "$only_include_assumed"
run_status
} >>"$GIT_DIR"/COMMIT_EDITMSG
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index f994443c6..57088c3f0 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -1,10 +1,16 @@
#!/usr/bin/perl -w
+# Known limitations:
+# - cannot add or remove binary files
+# - does not propagate permissions
+# - tells "ready for commit" even when things could not be completed
+# (eg addition of a binary file)
+
use strict;
use Getopt::Std;
use File::Temp qw(tempdir);
use Data::Dumper;
-use File::Basename qw(basename);
+use File::Basename qw(basename dirname);
unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
die "GIT_DIR is not defined or is unreadable";
@@ -84,7 +90,7 @@ close MSG;
`git-cat-file commit $commit | sed -e '1,/^\$/d' >> .msg`;
$? && die "Error extracting the commit message";
-my (@afiles, @dfiles, @mfiles);
+my (@afiles, @dfiles, @mfiles, @dirs);
my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
#print @files;
$? && die "Error in git-diff-tree";
@@ -92,7 +98,14 @@ foreach my $f (@files) {
chomp $f;
my @fields = split(m!\s+!, $f);
if ($fields[4] eq 'A') {
- push @afiles, $fields[5];
+ my $path = $fields[5];
+ push @afiles, $path;
+ # add any needed parent directories
+ $path = dirname $path;
+ while (!-d $path and ! grep { $_ eq $path } @dirs) {
+ unshift @dirs, $path;
+ $path = dirname $path;
+ }
}
if ($fields[4] eq 'M') {
push @mfiles, $fields[5];
@@ -107,13 +120,21 @@ undef @files; # don't need it anymore
# check that the files are clean and up to date according to cvs
my $dirty;
+foreach my $d (@dirs) {
+ if (-e $d) {
+ $dirty = 1;
+ warn "$d exists and is not a directory!\n";
+ }
+}
foreach my $f (@afiles) {
# This should return only one value
my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f));
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
- unless ($status[0] =~ m/Status: Unknown$/) {
+ if (-d dirname $f and $status[0] !~ m/Status: Unknown$/
+ and $status[0] !~ m/^File: no file /) {
$dirty = 1;
warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n";
+ warn "Status was: $status\n";
}
}
foreach my $f (@mfiles, @dfiles) {
@@ -139,6 +160,19 @@ if ($dirty) {
###
+print "Creating new directories\n";
+foreach my $d (@dirs) {
+ unless (mkdir $d) {
+ warn "Could not mkdir $d: $!";
+ $dirty = 1;
+ }
+ `cvs add $d`;
+ if ($?) {
+ $dirty = 1;
+ warn "Failed to cvs add directory $d -- you may need to do it manually";
+ }
+}
+
print "'Patching' binary files\n";
my @bfiles = grep(m/^Binary/, safe_pipe_capture('git-diff-tree', '-p', $parent, $commit));
@@ -151,7 +185,7 @@ foreach my $f (@bfiles) {
my $blob = `git-ls-tree $tree "$f" | cut -f 1 | cut -d ' ' -f 3`;
chomp $blob;
`git-cat-file blob $blob > $tmpdir/blob`;
- if (system('cmp', '-q', $f, "$tmpdir/blob")) {
+ if (system('cmp', '-s', $f, "$tmpdir/blob")) {
warn "Binary file $f in CVS does not match parent.\n";
$dirty = 1;
next;
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index af331d9c4..76f6246a3 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -23,7 +23,7 @@ use File::Basename qw(basename dirname);
use Time::Local;
use IO::Socket;
use IO::Pipe;
-use POSIX qw(strftime dup2 :errno_h);
+use POSIX qw(strftime dup2 ENOENT);
use IPC::Open2;
$SIG{'PIPE'}="IGNORE";
diff --git a/git-fetch.sh b/git-fetch.sh
index 280f62e4b..48818f822 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -166,7 +166,10 @@ fast_forward_local () {
mb=$(git-merge-base "$local" "$2") &&
case "$2,$mb" in
$local,*)
- echo >&2 "* $1: same as $3"
+ if test -n "$verbose"
+ then
+ echo >&2 "* $1: same as $3"
+ fi
;;
*,$local)
echo >&2 "* $1: fast forward to $3"
@@ -211,12 +214,12 @@ esac
reflist=$(get_remote_refs_for_fetch "$@")
if test "$tags"
then
- taglist=$(IFS=" " &&
+ taglist=`IFS=" " &&
git-ls-remote $upload_pack --tags "$remote" |
while read sha1 name
do
case "$name" in
- (*^*) continue ;;
+ *^*) continue ;;
esac
if git-check-ref-format "$name"
then
@@ -224,7 +227,7 @@ then
else
echo >&2 "warning: tag ${name} ignored"
fi
- done)
+ done`
if test "$#" -gt 1
then
# remote URL plus explicit refspecs; we need to merge them.
diff --git a/git-ls-remote.sh b/git-ls-remote.sh
index b6882a90c..2fdcaf788 100755
--- a/git-ls-remote.sh
+++ b/git-ls-remote.sh
@@ -58,11 +58,19 @@ http://* | https://* )
;;
rsync://* )
- mkdir $tmpdir
+ mkdir $tmpdir &&
+ rsync -rlq "$peek_repo/HEAD" $tmpdir &&
rsync -rq "$peek_repo/refs" $tmpdir || {
echo "failed slurping"
exit
}
+ head=$(cat "$tmpdir/HEAD") &&
+ case "$head" in
+ ref:' '*)
+ head=$(expr "z$head" : 'zref: \(.*\)') &&
+ head=$(cat "$tmpdir/$head") || exit
+ esac &&
+ echo "$head HEAD"
(cd $tmpdir && find refs -type f) |
while read path
do
diff --git a/git-send-email.perl b/git-send-email.perl
index 312a4ea2a..ed1d89b3f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -21,7 +21,6 @@ use warnings;
use Term::ReadLine;
use Getopt::Long;
use Data::Dumper;
-use Net::SMTP;
# most mail servers generate the Date: header, but not all...
$ENV{LC_ALL} = 'C';
@@ -37,7 +36,8 @@ sub cleanup_compose_files();
my $compose_filename = ".msg.$$";
# Variables we fill in automatically, or via prompting:
-my (@to,@cc,@initial_cc,$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
+my (@to,@cc,@initial_cc,@bcclist,
+ $initial_reply_to,$initial_subject,@files,$from,$compose,$time);
# Behavior modification variables
my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc) = (1, 0, 0, 0);
@@ -56,6 +56,7 @@ my $rc = GetOptions("from=s" => \$from,
"subject=s" => \$initial_subject,
"to=s" => \@to,
"cc=s" => \@initial_cc,
+ "bcc=s" => \@bcclist,
"chain-reply-to!" => \$chain_reply_to,
"smtp-server=s" => \$smtp_server,
"compose" => \$compose,
@@ -160,6 +161,7 @@ sub expand_aliases {
@to = expand_aliases(@to);
@initial_cc = expand_aliases(@initial_cc);
+@bcclist = expand_aliases(@bcclist);
if (!defined $initial_subject && $compose) {
do {
@@ -269,6 +271,9 @@ Options:
--cc Specify an initial "Cc:" list for the entire series
of emails.
+ --bcc Specify a list of email addresses that should be Bcc:
+ on all the emails.
+
--compose Use \$EDITOR to edit an introductory message for the
patch series.
@@ -303,7 +308,7 @@ EOT
}
# Variables we set as part of the loop over files
-our ($message_id, $cc, %mail, $subject, $reply_to, $message);
+our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message);
sub extract_valid_address {
my $address = shift;
@@ -316,7 +321,11 @@ sub extract_valid_address {
} else {
# less robust/correct than the monster regexp in Email::Valid,
# but still does a 99% job, and one less dependency
- return ($address =~ /([^\"<>\s]+@[^<>\s]+)/);
+ my $cleaned_address;
+ if ($address =~ /([^\"<>\s]+@[^<>\s]+)/) {
+ $cleaned_address = $1;
+ }
+ return $cleaned_address;
}
}
@@ -348,7 +357,7 @@ sub send_message
{
my @recipients = unique_email_list(@to);
my $to = join (",\n\t", @recipients);
- @recipients = unique_email_list(@recipients,@cc);
+ @recipients = unique_email_list(@recipients,@cc,@bcclist);
my $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($time++));
my $gitversion = '@@GIT_VERSION@@';
if ($gitversion =~ m/..GIT_VERSION../) {
@@ -367,17 +376,24 @@ Date: $date
Message-Id: $message_id
X-Mailer: git-send-email $gitversion
";
- $header .= "In-Reply-To: $reply_to\n" if $reply_to;
+ if ($reply_to) {
+
+ $header .= "In-Reply-To: $reply_to\n";
+ $header .= "References: $references\n";
+ }
if ($smtp_server =~ m#^/#) {
my $pid = open my $sm, '|-';
defined $pid or die $!;
if (!$pid) {
- exec($smtp_server,'-i',@recipients) or die $!;
+ exec($smtp_server,'-i',
+ map { scalar extract_valid_address($_) }
+ @recipients) or die $!;
}
print $sm "$header\n$message";
close $sm or die $?;
} else {
+ require Net::SMTP;
$smtp ||= Net::SMTP->new( $smtp_server );
$smtp->mail( $from ) or die $smtp->message;
$smtp->to( @recipients ) or die $smtp->message;
@@ -406,6 +422,7 @@ X-Mailer: git-send-email $gitversion
}
$reply_to = $initial_reply_to;
+$references = $initial_reply_to || '';
make_message_id();
$subject = $initial_subject;
@@ -482,6 +499,11 @@ foreach my $t (@files) {
# set up for the next message
if ($chain_reply_to || length($reply_to) == 0) {
$reply_to = $message_id;
+ if (length $references > 0) {
+ $references .= " $message_id";
+ } else {
+ $references = "$message_id";
+ }
}
make_message_id();
}
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 61f559f0a..38ac732ca 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -63,10 +63,17 @@ my $svn_dir = $ARGV[1];
our @mergerx = ();
if ($opt_m) {
- @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i );
+ my $branch_esc = quotemeta ($branch_name);
+ my $trunk_esc = quotemeta ($trunk_name);
+ @mergerx =
+ (
+ qr!\b(?:merg(?:ed?|ing))\b.*?\b((?:(?<=$branch_esc/)[\w\.\-]+)|(?:$trunk_esc))\b!i,
+ qr!\b(?:from|of)\W+((?:(?<=$branch_esc/)[\w\.\-]+)|(?:$trunk_esc))\b!i,
+ qr!\b(?:from|of)\W+(?:the )?([\w\.\-]+)[-\s]branch\b!i
+ );
}
if ($opt_M) {
- push (@mergerx, qr/$opt_M/);
+ unshift (@mergerx, qr/$opt_M/);
}
# Absolutize filename now, since we will have chdir'ed by the time we
diff --git a/git.c b/git.c
index 10ea934bc..bc463c98e 100644
--- a/git.c
+++ b/git.c
@@ -69,7 +69,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "diff-index", cmd_diff_index },
{ "diff-stages", cmd_diff_stages },
{ "diff-tree", cmd_diff_tree },
- { "cat-file", cmd_cat_file }
+ { "cat-file", cmd_cat_file },
+ { "rev-parse", cmd_rev_parse }
};
int i;
diff --git a/gitk b/gitk
index 4aa57c01c..101cf9bd9 100755
--- a/gitk
+++ b/gitk
@@ -34,10 +34,10 @@ proc start_rev_list {view} {
set order "--date-order"
}
if {[catch {
- set fd [open [concat | git-rev-list --header $order \
+ set fd [open [concat | git rev-list --header $order \
--parents --boundary --default HEAD $args] r]
} err]} {
- puts stderr "Error executing git-rev-list: $err"
+ puts stderr "Error executing git rev-list: $err"
exit 1
}
set commfd($view) $fd
@@ -94,10 +94,10 @@ proc getcommitlines {fd view} {
}
if {[string range $err 0 4] == "usage"} {
set err "Gitk: error reading commits$fv:\
- bad arguments to git-rev-list."
+ bad arguments to git rev-list."
if {$viewname($view) eq "Command line"} {
append err \
- " (Note: arguments to gitk are passed to git-rev-list\
+ " (Note: arguments to gitk are passed to git rev-list\
to allow selection of commits to be displayed.)"
}
} else {
@@ -148,7 +148,7 @@ proc getcommitlines {fd view} {
if {[string length $shortcmit] > 80} {
set shortcmit "[string range $shortcmit 0 80]..."
}
- error_popup "Can't parse git-rev-list output: {$shortcmit}"
+ error_popup "Can't parse git rev-list output: {$shortcmit}"
exit 1
}
set id [lindex $ids 0]
@@ -217,7 +217,7 @@ proc doupdate {} {
}
proc readcommit {id} {
- if {[catch {set contents [exec git-cat-file commit $id]}]} return
+ if {[catch {set contents [exec git cat-file commit $id]}]} return
parsecommit $id $contents 0
}
@@ -276,8 +276,8 @@ proc parsecommit {id contents listed} {
set headline $comment
}
if {!$listed} {
- # git-rev-list indents the comment by 4 spaces;
- # if we got this via git-cat-file, add the indentation
+ # git rev-list indents the comment by 4 spaces;
+ # if we got this via git cat-file, add the indentation
set newcomment {}
foreach line [split $comment "\n"] {
append newcomment " "
@@ -337,14 +337,14 @@ proc readrefs {} {
set type {}
set tag {}
catch {
- set commit [exec git-rev-parse "$id^0"]
+ set commit [exec git rev-parse "$id^0"]
if {"$commit" != "$id"} {
set tagids($name) $commit
lappend idtags($commit) $name
}
}
catch {
- set tagcontents($name) [exec git-cat-file tag "$id"]
+ set tagcontents($name) [exec git cat-file tag "$id"]
}
} elseif { $type == "heads" } {
set headids($name) $id
@@ -357,21 +357,21 @@ proc readrefs {} {
close $refd
}
-proc show_error {w msg} {
+proc show_error {w top msg} {
message $w.m -text $msg -justify center -aspect 400
pack $w.m -side top -fill x -padx 20 -pady 20
- button $w.ok -text OK -command "destroy $w"
+ button $w.ok -text OK -command "destroy $top"
pack $w.ok -side bottom -fill x
- bind $w <Visibility> "grab $w; focus $w"
- bind $w <Key-Return> "destroy $w"
- tkwait window $w
+ bind $top <Visibility> "grab $top; focus $top"
+ bind $top <Key-Return> "destroy $top"
+ tkwait window $top
}
proc error_popup msg {
set w .error
toplevel $w
wm transient $w .
- show_error $w $msg
+ show_error $w $w $msg
}
proc makewindow {} {
@@ -380,7 +380,7 @@ proc makewindow {} {
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
global maincursor textcursor curtextcursor
- global rowctxmenu mergemax
+ global rowctxmenu mergemax wrapcomment
menu .bar
.bar add cascade -label "File" -menu .bar.file
@@ -527,6 +527,7 @@ proc makewindow {} {
pack $ctext -side left -fill both -expand 1
.ctop.cdet add .ctop.cdet.left
+ $ctext tag conf comment -wrap $wrapcomment
$ctext tag conf filesep -font [concat $textfont bold] -back "#aaaaaa"
$ctext tag conf hunksep -fore blue
$ctext tag conf d0 -fore red
@@ -696,7 +697,7 @@ proc savestuff {w} {
global stuffsaved findmergefiles maxgraphpct
global maxwidth
global viewname viewfiles viewargs viewperm nextviewnum
- global cmitmode
+ global cmitmode wrapcomment
if {$stuffsaved} return
if {![winfo viewable .]} return
@@ -709,6 +710,7 @@ proc savestuff {w} {
puts $f [list set maxgraphpct $maxgraphpct]
puts $f [list set maxwidth $maxwidth]
puts $f [list set cmitmode $cmitmode]
+ puts $f [list set wrapcomment $wrapcomment]
puts $f "set geometry(width) [winfo width .ctop]"
puts $f "set geometry(height) [winfo height .ctop]"
puts $f "set geometry(canv1) [expr {[winfo width $canv]-2}]"
@@ -1285,7 +1287,7 @@ proc vieweditor {top n title} {
checkbutton $top.perm -text "Remember this view" -variable newviewperm($n)
grid $top.perm - -pady 5 -sticky w
message $top.al -aspect 1000 -font $uifont \
- -text "Commits to include (arguments to git-rev-list):"
+ -text "Commits to include (arguments to git rev-list):"
grid $top.al - -sticky w -pady 5
entry $top.args -width 50 -textvariable newviewargs($n) \
-background white
@@ -2939,7 +2941,7 @@ proc findpatches {} {
}
if {[catch {
- set f [open [list | git-diff-tree --stdin -s -r -S$findstring \
+ set f [open [list | git diff-tree --stdin -s -r -S$findstring \
<< $inputids] r]
} err]} {
error_popup "Error starting search process: $err"
@@ -2971,7 +2973,7 @@ proc readfindproc {} {
return
}
if {![regexp {^[0-9a-f]{40}} $line id]} {
- error_popup "Can't parse git-diff-tree output: $line"
+ error_popup "Can't parse git diff-tree output: $line"
stopfindproc
return
}
@@ -3036,10 +3038,10 @@ proc findfiles {} {
if {$l == $findstartline} break
}
- # start off a git-diff-tree process if needed
+ # start off a git diff-tree process if needed
if {$diffsneeded ne {}} {
if {[catch {
- set df [open [list | git-diff-tree -r --stdin << $diffsneeded] r]
+ set df [open [list | git diff-tree -r --stdin << $diffsneeded] r]
} err ]} {
error_popup "Error starting search process: $err"
return
@@ -3069,7 +3071,7 @@ proc readfilediffs {df} {
if {[catch {close $df} err]} {
stopfindproc
bell
- error_popup "Error in git-diff-tree: $err"
+ error_popup "Error in git diff-tree: $err"
} elseif {[info exists findid]} {
set id $findid
stopfindproc
@@ -3096,7 +3098,7 @@ proc donefilediff {} {
if {[info exists fdiffid]} {
while {[lindex $fdiffsneeded $fdiffpos] ne $fdiffid
&& $fdiffpos < [llength $fdiffsneeded]} {
- # git-diff-tree doesn't output anything for a commit
+ # git diff-tree doesn't output anything for a commit
# which doesn't change anything
set nullid [lindex $fdiffsneeded $fdiffpos]
set treediffs($nullid) {}
@@ -3213,8 +3215,11 @@ proc selcanvline {w x y} {
proc commit_descriptor {p} {
global commitinfo
+ if {![info exists commitinfo($p)]} {
+ getcommit $p
+ }
set l "..."
- if {[info exists commitinfo($p)]} {
+ if {[llength $commitinfo($p)] > 1} {
set l [lindex $commitinfo($p) 0]
}
return "$p ($l)"
@@ -3222,11 +3227,11 @@ proc commit_descriptor {p} {
# append some text to the ctext widget, and make any SHA1 ID
# that we know about be a clickable link.
-proc appendwithlinks {text} {
+proc appendwithlinks {text tags} {
global ctext commitrow linknum curview
set start [$ctext index "end - 1c"]
- $ctext insert end $text
+ $ctext insert end $text $tags
$ctext insert end "\n"
set links [regexp -indices -all -inline {[0-9a-f]{40}} $text]
foreach l $links {
@@ -3354,7 +3359,7 @@ proc selectline {l isnew} {
$ctext insert end "\n"
}
- set comment {}
+ set headers {}
set olds [lindex $parentlist $l]
if {[llength $olds] > 1} {
set np 0
@@ -3365,23 +3370,22 @@ proc selectline {l isnew} {
set tag m$np
}
$ctext insert end "Parent: " $tag
- appendwithlinks [commit_descriptor $p]
+ appendwithlinks [commit_descriptor $p] {}
incr np
}
} else {
foreach p $olds {
- append comment "Parent: [commit_descriptor $p]\n"
+ append headers "Parent: [commit_descriptor $p]\n"
}
}
foreach c [lindex $childlist $l] {
- append comment "Child: [commit_descriptor $c]\n"
+ append headers "Child: [commit_descriptor $c]\n"
}
- append comment "\n"
- append comment [lindex $info 5]
# make anything that looks like a SHA1 ID be a clickable link
- appendwithlinks $comment
+ appendwithlinks $headers {}
+ appendwithlinks [lindex $info 5] {comment}
$ctext tag delete Comments
$ctext tag remove found 1.0 end
@@ -3426,6 +3430,7 @@ proc selnextpage {dir} {
set lpp 1
}
allcanvs yview scroll [expr {$dir * $lpp}] units
+ drawvisible
if {![info exists selectedline]} return
set l [expr {$selectedline + $dir * $lpp}]
if {$l < 0} {
@@ -3521,7 +3526,7 @@ proc gettree {id} {
catch {unset diffmergeid}
if {![info exists treefilelist($id)]} {
if {![info exists treepending]} {
- if {[catch {set gtf [open [concat | git-ls-tree -r $id] r]}]} {
+ if {[catch {set gtf [open [concat | git ls-tree -r $id] r]}]} {
return
}
set treepending $id
@@ -3569,7 +3574,7 @@ proc showfile {f} {
return
}
set blob [lindex $treeidlist($diffids) $i]
- if {[catch {set bf [open [concat | git-cat-file blob $blob] r]} err]} {
+ if {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {
puts "oops, error reading blob $blob: $err"
return
}
@@ -3611,7 +3616,7 @@ proc mergediff {id l} {
set diffids $id
# this doesn't seem to actually affect anything...
set env(GIT_DIFF_OPTS) $diffopts
- set cmd [concat | git-diff-tree --no-commit-id --cc $id]
+ set cmd [concat | git diff-tree --no-commit-id --cc $id]
if {[catch {set mdf [open $cmd r]} err]} {
error_popup "Error getting merge diffs: $err"
return
@@ -3723,7 +3728,7 @@ proc gettreediffs {ids} {
set treepending $ids
set treediff {}
if {[catch \
- {set gdtf [open [concat | git-diff-tree --no-commit-id -r $ids] r]} \
+ {set gdtf [open [concat | git diff-tree --no-commit-id -r $ids] r]} \
]} return
fconfigure $gdtf -blocking 0
fileevent $gdtf readable [list gettreediffline $gdtf $ids]
@@ -3759,7 +3764,7 @@ proc getblobdiffs {ids} {
global nextupdate diffinhdr treediffs
set env(GIT_DIFF_OPTS) $diffopts
- set cmd [concat | git-diff-tree --no-commit-id -r -p -C $ids]
+ set cmd [concat | git diff-tree --no-commit-id -r -p -C $ids]
if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err"
return
@@ -4296,7 +4301,7 @@ proc mkpatchgo {} {
set oldid [$patchtop.fromsha1 get]
set newid [$patchtop.tosha1 get]
set fname [$patchtop.fname get]
- if {[catch {exec git-diff-tree -p $oldid $newid >$fname &} err]} {
+ if {[catch {exec git diff-tree -p $oldid $newid >$fname &} err]} {
error_popup "Error creating patch: $err"
}
catch {destroy $patchtop}
@@ -4504,7 +4509,7 @@ proc showtag {tag isnew} {
} else {
set text "Tag: $tag\nId: $tagids($tag)"
}
- appendwithlinks $text
+ appendwithlinks $text {}
$ctext conf -state disabled
init_flist {}
}
@@ -4863,11 +4868,11 @@ proc tcl_encoding {enc} {
# defaults...
set datemode 0
set diffopts "-U 5 -p"
-set wrcomcmd "git-diff-tree --stdin -p --pretty"
+set wrcomcmd "git diff-tree --stdin -p --pretty"
set gitencoding {}
catch {
- set gitencoding [exec git-repo-config --get i18n.commitencoding]
+ set gitencoding [exec git repo-config --get i18n.commitencoding]
}
if {$gitencoding == ""} {
set gitencoding "utf-8"
@@ -4890,6 +4895,7 @@ set downarrowlen 7
set mingaplen 30
set flistmode "flat"
set cmitmode "patch"
+set wrapcomment "none"
set colors {green red blue magenta darkgrey brown orange}
@@ -4911,7 +4917,7 @@ foreach arg $argv {
# check that we can find a .git directory somewhere...
set gitdir [gitdir]
if {![file isdirectory $gitdir]} {
- show_error . "Cannot find the git directory \"$gitdir\"."
+ show_error {} . "Cannot find the git directory \"$gitdir\"."
exit 1
}
@@ -4922,7 +4928,7 @@ if {$i >= 0} {
set revtreeargs [lrange $revtreeargs 0 [expr {$i - 1}]]
} elseif {$revtreeargs ne {}} {
if {[catch {
- set f [eval exec git-rev-parse --no-revs --no-flags $revtreeargs]
+ set f [eval exec git rev-parse --no-revs --no-flags $revtreeargs]
set cmdline_files [split $f "\n"]
set n [llength $cmdline_files]
set revtreeargs [lrange $revtreeargs 0 end-$n]
@@ -4931,9 +4937,9 @@ if {$i >= 0} {
# so look for "fatal:".
set i [string first "fatal:" $err]
if {$i > 0} {
- set err [string range [expr {$i + 6}] end]
+ set err [string range $err [expr {$i + 6}] end]
}
- show_error . "Bad arguments to gitk:\n$err"
+ show_error {} . "Bad arguments to gitk:\n$err"
exit 1
}
}
diff --git a/http-fetch.c b/http-fetch.c
index cc7bd1f36..661c90915 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1271,10 +1271,10 @@ int main(int argc, char **argv)
if (pull(commit_id))
rc = 1;
- curl_slist_free_all(no_pragma_header);
-
http_cleanup();
+ curl_slist_free_all(no_pragma_header);
+
if (corrupt_object_found) {
fprintf(stderr,
"Some loose object were found to be corrupt, but they might be just\n"
diff --git a/http.c b/http.c
index 0cb42a85d..146cf7bf3 100644
--- a/http.c
+++ b/http.c
@@ -25,7 +25,6 @@ long curl_low_speed_limit = -1;
long curl_low_speed_time = -1;
struct curl_slist *pragma_header;
-struct curl_slist *no_range_header;
struct active_request_slot *active_queue_head = NULL;
@@ -208,7 +207,6 @@ void http_init(void)
curl_global_init(CURL_GLOBAL_ALL);
pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
- no_range_header = curl_slist_append(no_range_header, "Range:");
#ifdef USE_CURL_MULTI
{
@@ -344,9 +342,14 @@ struct active_request_slot *get_active_slot(void)
slot->finished = NULL;
slot->callback_data = NULL;
slot->callback_func = NULL;
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_range_header);
curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, curl_errorstr);
+ curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, NULL);
+ curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
+ curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
+ curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
return slot;
}
diff --git a/log-tree.c b/log-tree.c
index 58b016378..ebb49f297 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -12,6 +12,37 @@ static void show_parents(struct commit *commit, int abbrev)
}
}
+static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
+{
+ int signoff_len = strlen(signoff);
+ static const char signed_off_by[] = "Signed-off-by: ";
+ char *cp = buf;
+
+ /* Do we have enough space to add it? */
+ if (buf_sz - at <= strlen(signed_off_by) + signoff_len + 2)
+ return at;
+
+ /* First see if we already have the sign-off by the signer */
+ while (1) {
+ cp = strstr(cp, signed_off_by);
+ if (!cp)
+ break;
+ cp += strlen(signed_off_by);
+ if ((cp + signoff_len < buf + at) &&
+ !strncmp(cp, signoff, signoff_len) &&
+ isspace(cp[signoff_len]))
+ return at; /* we already have him */
+ }
+
+ strcpy(buf + at, signed_off_by);
+ at += strlen(signed_off_by);
+ strcpy(buf + at, signoff);
+ at += signoff_len;
+ buf[at++] = '\n';
+ buf[at] = 0;
+ return at;
+}
+
void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
{
static char this_header[16384];
@@ -20,7 +51,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
const char *extra;
int len;
- char *subject = NULL, *after_subject = NULL;
+ const char *subject = NULL, *extra_headers = opt->extra_headers;
opt->loginfo = NULL;
if (!opt->verbose_header) {
@@ -69,6 +100,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
static char subject_buffer[1024];
static char buffer[1024];
snprintf(subject_buffer, sizeof(subject_buffer) - 1,
+ "%s"
"MIME-Version: 1.0\n"
"Content-Type: multipart/mixed;\n"
" boundary=\"%s%s\"\n"
@@ -79,9 +111,10 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
"Content-Type: text/plain; "
"charset=UTF-8; format=fixed\n"
"Content-Transfer-Encoding: 8bit\n\n",
+ extra_headers ? extra_headers : "",
mime_boundary_leader, opt->mime_boundary,
mime_boundary_leader, opt->mime_boundary);
- after_subject = subject_buffer;
+ extra_headers = subject_buffer;
snprintf(buffer, sizeof(buffer) - 1,
"--%s%s\n"
@@ -110,7 +143,11 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
/*
* And then the pretty-printed message itself
*/
- len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, after_subject);
+ len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, extra_headers);
+
+ if (opt->add_signoff)
+ len = append_signoff(this_header, sizeof(this_header), len,
+ opt->add_signoff);
printf("%s%s%s", this_header, extra, sep);
}
diff --git a/mailinfo.c b/mailinfo.c
index b27651935..5b6c2157e 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -72,11 +72,14 @@ static int bogus_from(char *line)
return 1;
}
-static int handle_from(char *line)
+static int handle_from(char *in_line)
{
- char *at = strchr(line, '@');
+ char line[1000];
+ char *at;
char *dst;
+ strcpy(line, in_line);
+ at = strchr(line, '@');
if (!at)
return bogus_from(line);
@@ -237,38 +240,46 @@ static int eatspace(char *line)
#define SEEN_FROM 01
#define SEEN_DATE 02
#define SEEN_SUBJECT 04
+#define SEEN_BOGUS_UNIX_FROM 010
+#define SEEN_PREFIX 020
/* First lines of body can have From:, Date:, and Subject: */
-static int handle_inbody_header(int *seen, char *line)
+static void handle_inbody_header(int *seen, char *line)
{
+ if (!memcmp(">From", line, 5) && isspace(line[5])) {
+ if (!(*seen & SEEN_BOGUS_UNIX_FROM)) {
+ *seen |= SEEN_BOGUS_UNIX_FROM;
+ return;
+ }
+ }
if (!memcmp("From:", line, 5) && isspace(line[5])) {
if (!(*seen & SEEN_FROM) && handle_from(line+6)) {
*seen |= SEEN_FROM;
- return 1;
+ return;
}
}
if (!memcmp("Date:", line, 5) && isspace(line[5])) {
if (!(*seen & SEEN_DATE)) {
handle_date(line+6);
*seen |= SEEN_DATE;
- return 1;
+ return;
}
}
if (!memcmp("Subject:", line, 8) && isspace(line[8])) {
if (!(*seen & SEEN_SUBJECT)) {
handle_subject(line+9);
*seen |= SEEN_SUBJECT;
- return 1;
+ return;
}
}
if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
if (!(*seen & SEEN_SUBJECT)) {
handle_subject(line);
*seen |= SEEN_SUBJECT;
- return 1;
+ return;
}
}
- return 0;
+ *seen |= SEEN_PREFIX;
}
static char *cleanup_subject(char *subject)
@@ -324,6 +335,7 @@ static void cleanup_space(char *buf)
}
}
+static void decode_header_bq(char *it);
typedef int (*header_fn_t)(char *);
struct header_def {
const char *name;
@@ -331,7 +343,7 @@ struct header_def {
int namelen;
};
-static void check_header(char *line, int len, struct header_def *header)
+static void check_header(char *line, struct header_def *header)
{
int i;
@@ -343,13 +355,17 @@ static void check_header(char *line, int len, struct header_def *header)
int len = header[i].namelen;
if (!strncasecmp(line, header[i].name, len) &&
line[len] == ':' && isspace(line[len + 1])) {
+ /* Unwrap inline B and Q encoding, and optionally
+ * normalize the meta information to utf8.
+ */
+ decode_header_bq(line + len + 2);
header[i].func(line + len + 2);
break;
}
}
}
-static void check_subheader_line(char *line, int len)
+static void check_subheader_line(char *line)
{
static struct header_def header[] = {
{ "Content-Type", handle_subcontent_type },
@@ -357,9 +373,9 @@ static void check_subheader_line(char *line, int len)
handle_content_transfer_encoding },
{ NULL },
};
- check_header(line, len, header);
+ check_header(line, header);
}
-static void check_header_line(char *line, int len)
+static void check_header_line(char *line)
{
static struct header_def header[] = {
{ "From", handle_from },
@@ -370,7 +386,30 @@ static void check_header_line(char *line, int len)
handle_content_transfer_encoding },
{ NULL },
};
- check_header(line, len, header);
+ check_header(line, header);
+}
+
+static int is_rfc2822_header(char *line)
+{
+ /*
+ * The section that defines the loosest possible
+ * field name is "3.6.8 Optional fields".
+ *
+ * optional-field = field-name ":" unstructured CRLF
+ * field-name = 1*ftext
+ * ftext = %d33-57 / %59-126
+ */
+ int ch;
+ char *cp = line;
+ while ((ch = *cp++)) {
+ if (ch == ':')
+ return cp != line;
+ if ((33 <= ch && ch <= 57) ||
+ (59 <= ch && ch <= 126))
+ continue;
+ break;
+ }
+ return 0;
}
static int read_one_header_line(char *line, int sz, FILE *in)
@@ -379,18 +418,25 @@ static int read_one_header_line(char *line, int sz, FILE *in)
while (ofs < sz) {
int peek, len;
if (fgets(line + ofs, sz - ofs, in) == NULL)
- return ofs;
+ break;
len = eatspace(line + ofs);
if (len == 0)
- return ofs;
- peek = fgetc(in); ungetc(peek, in);
- if (peek == ' ' || peek == '\t') {
- /* Yuck, 2822 header "folding" */
- ofs += len;
- continue;
+ break;
+ if (!is_rfc2822_header(line)) {
+ /* Re-add the newline */
+ line[ofs + len] = '\n';
+ line[ofs + len + 1] = '\0';
+ break;
}
- return ofs + len;
+ ofs += len;
+ /* Yuck, 2822 header "folding" */
+ peek = fgetc(in); ungetc(peek, in);
+ if (peek != ' ' && peek != '\t')
+ break;
}
+ /* Count mbox From headers as headers */
+ if (!ofs && !memcmp(line, "From ", 5))
+ ofs = 1;
return ofs;
}
@@ -585,25 +631,13 @@ static void decode_transfer_encoding(char *line)
static void handle_info(void)
{
char *sub;
- static int done_info = 0;
-
- if (done_info)
- return;
- done_info = 1;
sub = cleanup_subject(subject);
cleanup_space(name);
cleanup_space(date);
cleanup_space(email);
cleanup_space(sub);
- /* Unwrap inline B and Q encoding, and optionally
- * normalize the meta information to utf8.
- */
- decode_header_bq(name);
- decode_header_bq(date);
- decode_header_bq(email);
- decode_header_bq(sub);
printf("Author: %s\nEmail: %s\nSubject: %s\nDate: %s\n\n",
name, email, sub, date);
}
@@ -611,7 +645,7 @@ static void handle_info(void)
/* We are inside message body and have read line[] already.
* Spit out the commit log.
*/
-static int handle_commit_msg(void)
+static int handle_commit_msg(int *seen)
{
if (!cmitmsg)
return 0;
@@ -635,6 +669,11 @@ static int handle_commit_msg(void)
decode_transfer_encoding(line);
if (metainfo_charset)
convert_to_utf8(line, charset);
+
+ handle_inbody_header(seen, line);
+ if (!(*seen & SEEN_PREFIX))
+ continue;
+
fputs(line, cmitmsg);
} while (fgets(line, sizeof(line), stdin) != NULL);
fclose(cmitmsg);
@@ -666,26 +705,16 @@ static void handle_patch(void)
* that the first part to contain commit message and a patch, and
* handle other parts as pure patches.
*/
-static int handle_multipart_one_part(void)
+static int handle_multipart_one_part(int *seen)
{
- int seen = 0;
int n = 0;
- int len;
while (fgets(line, sizeof(line), stdin) != NULL) {
again:
- len = eatspace(line);
n++;
- if (!len)
- continue;
if (is_multipart_boundary(line))
break;
- if (0 <= seen && handle_inbody_header(&seen, line))
- continue;
- seen = -1; /* no more inbody headers */
- line[len] = '\n';
- handle_info();
- if (handle_commit_msg())
+ if (handle_commit_msg(seen))
goto again;
handle_patch();
break;
@@ -697,6 +726,7 @@ static int handle_multipart_one_part(void)
static void handle_multipart_body(void)
{
+ int seen = 0;
int part_num = 0;
/* Skip up to the first boundary */
@@ -709,16 +739,16 @@ static void handle_multipart_body(void)
return;
/* We are on boundary line. Start slurping the subhead. */
while (1) {
- int len = read_one_header_line(line, sizeof(line), stdin);
- if (!len) {
- if (handle_multipart_one_part() < 0)
+ int hdr = read_one_header_line(line, sizeof(line), stdin);
+ if (!hdr) {
+ if (handle_multipart_one_part(&seen) < 0)
return;
/* Reset per part headers */
transfer_encoding = TE_DONTCARE;
charset[0] = 0;
}
else
- check_subheader_line(line, len);
+ check_subheader_line(line);
}
fclose(patchfile);
if (!patch_lines) {
@@ -732,18 +762,9 @@ static void handle_body(void)
{
int seen = 0;
- while (fgets(line, sizeof(line), stdin) != NULL) {
- int len = eatspace(line);
- if (!len)
- continue;
- if (0 <= seen && handle_inbody_header(&seen, line))
- continue;
- seen = -1; /* no more inbody headers */
- line[len] = '\n';
- handle_info();
- handle_commit_msg();
+ if (line[0] || fgets(line, sizeof(line), stdin) != NULL) {
+ handle_commit_msg(&seen);
handle_patch();
- break;
}
fclose(patchfile);
if (!patch_lines) {
@@ -787,15 +808,16 @@ int main(int argc, char **argv)
exit(1);
}
while (1) {
- int len = read_one_header_line(line, sizeof(line), stdin);
- if (!len) {
+ int hdr = read_one_header_line(line, sizeof(line), stdin);
+ if (!hdr) {
if (multipart_boundary[0])
handle_multipart_body();
else
handle_body();
+ handle_info();
break;
}
- check_header_line(line, len);
+ check_header_line(line);
}
return 0;
}
diff --git a/mailsplit.c b/mailsplit.c
index c529e2d06..70a569c12 100644
--- a/mailsplit.c
+++ b/mailsplit.c
@@ -162,7 +162,7 @@ int main(int argc, const char **argv)
while (*argp) {
const char *file = *argp++;
- FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "rt");
+ FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
int file_done = 0;
if ( !f )
diff --git a/read-cache.c b/read-cache.c
index 32ba91792..c499c5185 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -4,11 +4,26 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "cache-tree.h"
+
+/* Index extensions.
+ *
+ * The first letter should be 'A'..'Z' for extensions that are not
+ * necessary for a correct operation (i.e. optimization data).
+ * When new extensions are added that _needs_ to be understood in
+ * order to correctly interpret the index file, pick character that
+ * is outside the range, to cause the reader to abort.
+ */
+
+#define CACHE_EXT(s) ( (s[0]<<24)|(s[1]<<16)|(s[2]<<8)|(s[3]) )
+#define CACHE_EXT_TREE 0x54524545 /* "TREE" */
struct cache_entry **active_cache = NULL;
static time_t index_file_timestamp;
unsigned int active_nr = 0, active_alloc = 0, active_cache_changed = 0;
+struct cache_tree *active_cache_tree = NULL;
+
/*
* This only updates the "non-critical" parts of the directory
* cache, ie the parts that aren't tracked by GIT, and only used
@@ -696,6 +711,22 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
return 0;
}
+static int read_index_extension(const char *ext, void *data, unsigned long sz)
+{
+ switch (CACHE_EXT(ext)) {
+ case CACHE_EXT_TREE:
+ active_cache_tree = cache_tree_read(data, sz);
+ break;
+ default:
+ if (*ext < 'A' || 'Z' < *ext)
+ return error("index uses %.4s extension, which we do not understand",
+ ext);
+ fprintf(stderr, "ignoring %.4s extension\n", ext);
+ break;
+ }
+ return 0;
+}
+
int read_cache(void)
{
int fd, i;
@@ -744,6 +775,22 @@ int read_cache(void)
active_cache[i] = ce;
}
index_file_timestamp = st.st_mtime;
+ while (offset <= size - 20 - 8) {
+ /* After an array of active_nr index entries,
+ * there can be arbitrary number of extended
+ * sections, each of which is prefixed with
+ * extension name (4-byte) and section length
+ * in 4-byte network byte order.
+ */
+ unsigned long extsize;
+ memcpy(&extsize, map + offset + 4, 4);
+ extsize = ntohl(extsize);
+ if (read_index_extension(map + offset,
+ map + offset + 8, extsize) < 0)
+ goto unmap;
+ offset += 8;
+ offset += extsize;
+ }
return active_nr;
unmap:
@@ -778,6 +825,17 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
return 0;
}
+static int write_index_ext_header(SHA_CTX *context, int fd,
+ unsigned int ext, unsigned int sz)
+{
+ ext = htonl(ext);
+ sz = htonl(sz);
+ if ((ce_write(context, fd, &ext, 4) < 0) ||
+ (ce_write(context, fd, &sz, 4) < 0))
+ return -1;
+ return 0;
+}
+
static int ce_flush(SHA_CTX *context, int fd)
{
unsigned int left = write_buffer_len;
@@ -874,5 +932,19 @@ int write_cache(int newfd, struct cache_entry **cache, int entries)
if (ce_write(&c, newfd, ce, ce_size(ce)) < 0)
return -1;
}
+
+ /* Write extension data here */
+ if (active_cache_tree) {
+ unsigned long sz;
+ void *data = cache_tree_write(active_cache_tree, &sz);
+ if (data &&
+ !write_index_ext_header(&c, newfd, CACHE_EXT_TREE, sz) &&
+ !ce_write(&c, newfd, data, sz))
+ ;
+ else {
+ free(data);
+ return -1;
+ }
+ }
return ce_flush(&c, newfd);
}
diff --git a/repo-config.c b/repo-config.c
index 127afd784..08fc4cc57 100644
--- a/repo-config.c
+++ b/repo-config.c
@@ -108,7 +108,8 @@ static int get_value(const char* key_, const char* regex_)
int main(int argc, const char **argv)
{
- setup_git_directory();
+ int nongit = 0;
+ setup_git_directory_gently(&nongit);
while (1 < argc) {
if (!strcmp(argv[1], "--int"))
diff --git a/revision.c b/revision.c
index 2294b16ea..42c077a4c 100644
--- a/revision.c
+++ b/revision.c
@@ -733,6 +733,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->abbrev = DEFAULT_ABBREV;
continue;
}
+ if (!strncmp(arg, "--abbrev=", 9)) {
+ revs->abbrev = strtoul(arg + 9, NULL, 10);
+ if (revs->abbrev < MINIMUM_ABBREV)
+ revs->abbrev = MINIMUM_ABBREV;
+ else if (revs->abbrev > 40)
+ revs->abbrev = 40;
+ continue;
+ }
if (!strcmp(arg, "--abbrev-commit")) {
revs->abbrev_commit = 1;
continue;
diff --git a/revision.h b/revision.h
index bdbdd235d..7d85b0f2e 100644
--- a/revision.h
+++ b/revision.h
@@ -60,6 +60,8 @@ struct rev_info {
struct log_info *loginfo;
int nr, total;
const char *mime_boundary;
+ const char *add_signoff;
+ const char *extra_headers;
/* special limits */
int max_count;
diff --git a/sha1_file.c b/sha1_file.c
index f77c18934..aea0f40d5 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -617,6 +617,12 @@ static void prepare_packed_git_one(char *objdir, int local)
/* we have .idx. Is it a file we can map? */
strcpy(path + len, de->d_name);
+ for (p = packed_git; p; p = p->next) {
+ if (!memcmp(path, p->pack_name, len + namelen - 4))
+ break;
+ }
+ if (p)
+ continue;
p = add_packed_git(path, len + namelen, local);
if (!p)
continue;
@@ -626,12 +632,12 @@ static void prepare_packed_git_one(char *objdir, int local)
closedir(dir);
}
+static int prepare_packed_git_run_once = 0;
void prepare_packed_git(void)
{
- static int run_once = 0;
struct alternate_object_database *alt;
- if (run_once)
+ if (prepare_packed_git_run_once)
return;
prepare_packed_git_one(get_object_directory(), 1);
prepare_alt_odb();
@@ -640,7 +646,13 @@ void prepare_packed_git(void)
prepare_packed_git_one(alt->base, 0);
alt->name[-1] = '/';
}
- run_once = 1;
+ prepare_packed_git_run_once = 1;
+}
+
+static void reprepare_packed_git(void)
+{
+ prepare_packed_git_run_once = 0;
+ prepare_packed_git();
}
int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long size, const char *type)
@@ -1212,9 +1224,12 @@ int sha1_object_info(const unsigned char *sha1, char *type, unsigned long *sizep
if (!map) {
struct pack_entry e;
- if (!find_pack_entry(sha1, &e))
- return error("unable to find %s", sha1_to_hex(sha1));
- return packed_object_info(&e, type, sizep);
+ if (find_pack_entry(sha1, &e))
+ return packed_object_info(&e, type, sizep);
+ reprepare_packed_git();
+ if (find_pack_entry(sha1, &e))
+ return packed_object_info(&e, type, sizep);
+ return error("unable to find %s", sha1_to_hex(sha1));
}
if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0)
status = error("unable to unpack %s header",
@@ -1256,6 +1271,9 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size
munmap(map, mapsize);
return buf;
}
+ reprepare_packed_git();
+ if (find_pack_entry(sha1, &e))
+ return read_packed_sha1(sha1, type, size);
return NULL;
}
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index 8335a63e2..da3c81357 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -75,7 +75,7 @@ test_expect_success \
git-update-index --add yomin &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >4.out || return 1
- diff --unified=0 M.out 4.out >4diff.out
+ diff -U0 M.out 4.out >4diff.out
compare_change 4diff.out expected &&
check_cache_at yomin clean &&
sum bozbar frotz nitfol >actual4.sum &&
@@ -94,7 +94,7 @@ test_expect_success \
echo yomin yomin >yomin &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >5.out || return 1
- diff --unified=0 M.out 5.out >5diff.out
+ diff -U0 M.out 5.out >5diff.out
compare_change 5diff.out expected &&
check_cache_at yomin dirty &&
sum bozbar frotz nitfol >actual5.sum &&
@@ -112,7 +112,7 @@ test_expect_success \
git-update-index --add frotz &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >6.out &&
- diff --unified=0 M.out 6.out &&
+ diff -U0 M.out 6.out &&
check_cache_at frotz clean &&
sum bozbar frotz nitfol >actual3.sum &&
cmp M.sum actual3.sum &&
@@ -129,7 +129,7 @@ test_expect_success \
echo frotz frotz >frotz &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >7.out &&
- diff --unified=0 M.out 7.out &&
+ diff -U0 M.out 7.out &&
check_cache_at frotz dirty &&
sum bozbar frotz nitfol >actual7.sum &&
if cmp M.sum actual7.sum; then false; else :; fi &&
@@ -206,7 +206,7 @@ test_expect_success \
git-update-index --add nitfol &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >14.out || return 1
- diff --unified=0 M.out 14.out >14diff.out
+ diff -U0 M.out 14.out >14diff.out
compare_change 14diff.out expected &&
sum bozbar frotz >actual14.sum &&
grep -v nitfol M.sum > expected14.sum &&
@@ -227,7 +227,7 @@ test_expect_success \
echo nitfol nitfol nitfol >nitfol &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >15.out || return 1
- diff --unified=0 M.out 15.out >15diff.out
+ diff -U0 M.out 15.out >15diff.out
compare_change 15diff.out expected &&
check_cache_at nitfol dirty &&
sum bozbar frotz >actual15.sum &&
@@ -264,7 +264,7 @@ test_expect_success \
git-update-index --add bozbar &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >18.out &&
- diff --unified=0 M.out 18.out &&
+ diff -U0 M.out 18.out &&
check_cache_at bozbar clean &&
sum bozbar frotz nitfol >actual18.sum &&
cmp M.sum actual18.sum'
@@ -278,7 +278,7 @@ test_expect_success \
echo gnusto gnusto >bozbar &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >19.out &&
- diff --unified=0 M.out 19.out &&
+ diff -U0 M.out 19.out &&
check_cache_at bozbar dirty &&
sum frotz nitfol >actual19.sum &&
grep -v bozbar M.sum > expected19.sum &&
@@ -297,7 +297,7 @@ test_expect_success \
git-update-index --add bozbar &&
git-read-tree -m -u $treeH $treeM &&
git-ls-files --stage >20.out &&
- diff --unified=0 M.out 20.out &&
+ diff -U0 M.out 20.out &&
check_cache_at bozbar clean &&
sum bozbar frotz nitfol >actual20.sum &&
cmp M.sum actual20.sum'
@@ -338,7 +338,7 @@ test_expect_success \
git-update-index --add DF &&
git-read-tree -m -u $treeDF $treeDFDF &&
git-ls-files --stage >DFDFcheck.out &&
- diff --unified=0 DFDF.out DFDFcheck.out &&
+ diff -U0 DFDF.out DFDFcheck.out &&
check_cache_at DF/DF clean'
test_done
diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh
index 77aed8d80..a78ea7f0b 100755
--- a/t/t2101-update-index-reupdate.sh
+++ b/t/t2101-update-index-reupdate.sh
@@ -8,15 +8,16 @@ test_description='git-update-index --again test.
. ./test-lib.sh
+cat > expected <<\EOF
+100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
+100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
+EOF
test_expect_success 'update-index --add' \
'echo hello world >file1 &&
echo goodbye people >file2 &&
git-update-index --add file1 file2 &&
git-ls-files -s >current &&
- cmp current - <<\EOF
-100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
-100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
-EOF'
+ cmp current expected'
test_expect_success 'update-index --again' \
'rm -f file1 &&
@@ -29,20 +30,22 @@ test_expect_success 'update-index --again' \
echo happy - failed as expected
fi &&
git-ls-files -s >current &&
- cmp current - <<\EOF
-100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0 file1
-100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0 file2
-EOF'
+ cmp current expected'
+cat > expected <<\EOF
+100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
+EOF
test_expect_success 'update-index --remove --again' \
'git-update-index --remove --again &&
git-ls-files -s >current &&
- cmp current - <<\EOF
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
-EOF'
+ cmp current expected'
test_expect_success 'first commit' 'git-commit -m initial'
+cat > expected <<\EOF
+100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3
+100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
+EOF
test_expect_success 'update-index again' \
'mkdir -p dir1 &&
echo hello world >dir1/file3 &&
@@ -52,11 +55,12 @@ test_expect_success 'update-index again' \
echo happy >dir1/file3 &&
git-update-index --again &&
git-ls-files -s >current &&
- cmp current - <<\EOF
-100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0 dir1/file3
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
-EOF'
+ cmp current expected'
+cat > expected <<\EOF
+100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3
+100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
+EOF
test_expect_success 'update-index --update from subdir' \
'echo not so happy >file2 &&
cd dir1 &&
@@ -64,19 +68,17 @@ test_expect_success 'update-index --update from subdir' \
git-update-index --again &&
cd .. &&
git-ls-files -s >current &&
- cmp current - <<\EOF
-100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0 dir1/file3
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
-EOF'
+ cmp current expected'
+cat > expected <<\EOF
+100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
+100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
+EOF
test_expect_success 'update-index --update with pathspec' \
'echo very happy >file2 &&
cat file2 >dir1/file3 &&
git-update-index --again dir1/ &&
git-ls-files -s >current &&
- cmp current - <<\EOF
-100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
-100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
-EOF'
+ cmp current expected'
test_done
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 72a93da08..c12270efa 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -40,9 +40,11 @@ test_expect_success 'git-ls-files no-funny' \
t0=`git-write-tree`
echo "$t0" >t0
-echo 'just space
+cat > expected <<\EOF
+just space
no-funny
-"tabs\t,\" (dq) and spaces"' >expected
+"tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-ls-files with-funny' \
'git-update-index --add "$p1" &&
git-ls-files >current &&
@@ -58,14 +60,18 @@ test_expect_success 'git-ls-files -z with-funny' \
t1=`git-write-tree`
echo "$t1" >t1
-echo 'just space
+cat > expected <<\EOF
+just space
no-funny
-"tabs\t,\" (dq) and spaces"' >expected
+"tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-ls-tree with funny' \
'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
diff -u expected current'
-echo 'A "tabs\t,\" (dq) and spaces"' >expected
+cat > expected <<\EOF
+A "tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-diff-index with-funny' \
'git-diff-index --name-status $t0 >current &&
diff -u expected current'
@@ -84,53 +90,62 @@ test_expect_success 'git-diff-tree -z with-funny' \
'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
diff -u expected current'
-echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
+cat > expected <<\EOF
+CNUM no-funny "tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-diff-tree -C with-funny' \
'git-diff-tree -C --find-copies-harder --name-status \
$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
diff -u expected current'
-echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
+cat > expected <<\EOF
+RNUM no-funny "tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-diff-tree delete with-funny' \
'git-update-index --force-remove "$p0" &&
git-diff-index -M --name-status \
$t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
diff -u expected current'
-echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
+cat > expected <<\EOF
+diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
similarity index NUM%
rename from no-funny
-rename to "tabs\t,\" (dq) and spaces"' >expected
-
+rename to "tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current'
chmod +x "$p1"
-echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
+cat > expected <<\EOF
+diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
old mode 100644
new mode 100755
similarity index NUM%
rename from no-funny
-rename to "tabs\t,\" (dq) and spaces"' >expected
-
+rename to "tabs\t,\" (dq) and spaces"
+EOF
test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current'
-echo >expected ' "tabs\t,\" (dq) and spaces"
- 1 files changed, 0 insertions(+), 0 deletions(-)'
+cat >expected <<\EOF
+ "tabs\t,\" (dq) and spaces"
+ 1 files changed, 0 insertions(+), 0 deletions(-)
+EOF
test_expect_success 'git-diff-tree rename with-funny applied' \
'git-diff-index -M -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
diff -u expected current'
-echo >expected ' no-funny
+cat > expected <<\EOF
+ no-funny
"tabs\t,\" (dq) and spaces"
- 2 files changed, 3 insertions(+), 3 deletions(-)'
-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+EOF
test_expect_success 'git-diff-tree delete with-funny applied' \
'git-diff-index -p $t0 |
git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index acaa4d6bd..201d1642d 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -8,30 +8,34 @@ test_description='Test of the various options to git-rm.'
. ./test-lib.sh
# Setup some files to be removed, some with funny characters
-touch -- foo bar baz 'space embedded' -q
-git-add -- foo bar baz 'space embedded' -q
-git-commit -m "add normal files"
-test_tabs=y
-if touch -- 'tab embedded' 'newline
-embedded'
-then
-git-add -- 'tab embedded' 'newline
+test_expect_success \
+ 'Initialize test directory' \
+ "touch -- foo bar baz 'space embedded' -q &&
+ git-add -- foo bar baz 'space embedded' -q &&
+ git-commit -m 'add normal files' &&
+ test_tabs=y &&
+ if touch -- 'tab embedded' 'newline
embedded'
-git-commit -m "add files with tabs and newlines"
-else
- say 'Your filesystem does not allow tabs in filenames.'
- test_tabs=n
-fi
+ then
+ git-add -- 'tab embedded' 'newline
+embedded' &&
+ git-commit -m 'add files with tabs and newlines'
+ else
+ say 'Your filesystem does not allow tabs in filenames.'
+ test_tabs=n
+ fi"
# Later we will try removing an unremovable path to make sure
# git-rm barfs, but if the test is run as root that cannot be
# arranged.
-: >test-file
-chmod a-w .
-rm -f test-file
-test -f test-file && test_failed_remove=y
-chmod 775 .
-rm -f test-file
+test_expect_success \
+ 'Determine rm behavior' \
+ ': >test-file
+ chmod a-w .
+ rm -f test-file
+ test -f test-file && test_failed_remove=y
+ chmod 775 .
+ rm -f test-file'
test_expect_success \
'Pre-check that foo exists and is in index before git-rm foo' \
diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh
index bdd95c0d3..323606c65 100755
--- a/t/t4012-diff-binary.sh
+++ b/t/t4012-diff-binary.sh
@@ -16,25 +16,20 @@ test_expect_success 'prepare repository' \
echo git >c &&
cat b b >d'
-test_expect_success 'diff without --binary' \
- 'git-diff | git-apply --stat --summary >current &&
- cmp current - <<\EOF
+cat > expected <<\EOF
a | 2 +-
b | Bin
c | 2 +-
d | Bin
4 files changed, 2 insertions(+), 2 deletions(-)
-EOF'
+EOF
+test_expect_success 'diff without --binary' \
+ 'git-diff | git-apply --stat --summary >current &&
+ cmp current expected'
test_expect_success 'diff with --binary' \
'git-diff --binary | git-apply --stat --summary >current &&
- cmp current - <<\EOF
- a | 2 +-
- b | Bin
- c | 2 +-
- d | Bin
- 4 files changed, 2 insertions(+), 2 deletions(-)
-EOF'
+ cmp current expected'
# apply needs to be able to skip the binary material correctly
# in order to report the line number of a corrupt patch.
diff --git a/t/t4113-apply-ending.sh b/t/t4113-apply-ending.sh
new file mode 100755
index 000000000..7fd0cf62e
--- /dev/null
+++ b/t/t4113-apply-ending.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Catalin Marinas
+#
+
+test_description='git-apply trying to add an ending line.
+
+'
+. ./test-lib.sh
+
+# setup
+
+cat >test-patch <<\EOF
+diff --git a/file b/file
+--- a/file
++++ b/file
+@@ -1,2 +1,3 @@
+ a
+ b
++c
+EOF
+
+echo 'a' >file
+echo 'b' >>file
+echo 'c' >>file
+
+test_expect_success setup \
+ 'git-update-index --add file'
+
+# test
+
+test_expect_failure 'apply at the end' \
+ 'git-apply --index test-patch'
+
+cat >test-patch <<\EOF
+diff a/file b/file
+--- a/file
++++ b/file
+@@ -1,2 +1,3 @@
++a
+ b
+ c
+EOF
+
+echo >file 'a
+b
+c'
+git-update-index file
+
+test_expect_failure 'apply at the beginning' \
+ 'git-apply --index test-patch'
+
+test_done
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 92f12d9cf..f7625a6f4 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -12,11 +12,11 @@ test_description='Testing multi_ack pack fetching
# Some convenience functions
-function add () {
- local name=$1
- local text="$@"
- local branch=${name:0:1}
- local parents=""
+add () {
+ name=$1
+ text="$@"
+ branch=`echo $name | sed -e 's/^\(.\).*$/\1/'`
+ parents=""
shift
while test $1; do
@@ -36,13 +36,13 @@ function add () {
eval ${branch}TIP=$commit
}
-function count_objects () {
+count_objects () {
ls .git/objects/??/* 2>>log2.txt | wc -l | tr -d " "
}
-function test_expect_object_count () {
- local message=$1
- local count=$2
+test_expect_object_count () {
+ message=$1
+ count=$2
output="$(count_objects)"
test_expect_success \
@@ -50,18 +50,18 @@ function test_expect_object_count () {
"test $count = $output"
}
-function pull_to_client () {
- local number=$1
- local heads=$2
- local count=$3
- local no_strict_count_check=$4
+pull_to_client () {
+ number=$1
+ heads=$2
+ count=$3
+ no_strict_count_check=$4
cd client
test_expect_success "$number pull" \
"git-fetch-pack -k -v .. $heads"
case "$heads" in *A*) echo $ATIP > .git/refs/heads/A;; esac
case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac
- git-symbolic-ref HEAD refs/heads/${heads:0:1}
+ git-symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'`
test_expect_success "fsck" 'git-fsck-objects --full > fsck.txt 2>&1'
diff --git a/t/t6000lib.sh b/t/t6000lib.sh
index c6752af48..d40262159 100755
--- a/t/t6000lib.sh
+++ b/t/t6000lib.sh
@@ -69,7 +69,9 @@ on_committer_date()
{
_date=$1
shift 1
- GIT_COMMITTER_DATE=$_date "$@"
+ export GIT_COMMITTER_DATE="$_date"
+ "$@"
+ unset GIT_COMMITTER_DATE
}
# Execute a command and suppress any error output.
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
new file mode 100755
index 000000000..a61da1efb
--- /dev/null
+++ b/t/t9001-send-email.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='git-send-email'
+. ./test-lib.sh
+
+PROG='git send-email'
+test_expect_success \
+ 'prepare reference tree' \
+ 'echo "1A quick brown fox jumps over the" >file &&
+ echo "lazy dog" >>file &&
+ git add file
+ GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
+
+test_expect_success \
+ 'Setup helper tool' \
+ '(echo "#!/bin/sh"
+ echo shift
+ echo for a
+ echo do
+ echo " echo \"!\$a!\""
+ echo "done >commandline"
+ echo "cat > msgtxt"
+ ) >fake.sendmail
+ chmod +x ./fake.sendmail
+ git add fake.sendmail
+ GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
+
+test_expect_success \
+ 'Extract patches and send' \
+ 'git format-patch -n HEAD^1
+ git send-email -from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" ./0001*txt'
+
+cat >expected <<\EOF
+!nobody@example.com!
+!author@example.com!
+EOF
+test_expect_success \
+ 'Verify commandline' \
+ 'diff commandline expected'
+
+test_done
diff --git a/tree-walk.c b/tree-walk.c
index 9f7abb7cb..392205827 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -47,18 +47,33 @@ void update_tree_entry(struct tree_desc *desc)
desc->size = size - len;
}
+static const char *get_mode(const char *str, unsigned int *modep)
+{
+ unsigned char c;
+ unsigned int mode = 0;
+
+ while ((c = *str++) != ' ') {
+ if (c < '0' || c > '7')
+ return NULL;
+ mode = (mode << 3) + (c - '0');
+ }
+ *modep = mode;
+ return str;
+}
+
const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
{
void *tree = desc->buf;
unsigned long size = desc->size;
int len = strlen(tree)+1;
const unsigned char *sha1 = tree + len;
- const char *path = strchr(tree, ' ');
+ const char *path;
unsigned int mode;
- if (!path || size < len + 20 || sscanf(tree, "%o", &mode) != 1)
+ path = get_mode(tree, &mode);
+ if (!path || size < len + 20)
die("corrupt tree file");
- *pathp = path+1;
+ *pathp = path;
*modep = canon_mode(mode);
return sha1;
}
diff --git a/update-index.c b/update-index.c
index 5854d11fd..956b6b34f 100644
--- a/update-index.c
+++ b/update-index.c
@@ -6,6 +6,7 @@
#include "cache.h"
#include "strbuf.h"
#include "quote.h"
+#include "cache-tree.h"
#include "tree-walk.h"
/*
@@ -51,6 +52,7 @@ static int mark_valid(const char *path)
active_cache[pos]->ce_flags &= ~htons(CE_VALID);
break;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
active_cache_changed = 1;
return 0;
}
@@ -64,6 +66,12 @@ static int add_file_to_cache(const char *path)
struct stat st;
status = lstat(path, &st);
+
+ /* We probably want to do this in remove_file_from_cache() and
+ * add_cache_entry() instead...
+ */
+ cache_tree_invalidate_path(active_cache_tree, path);
+
if (status < 0 || S_ISDIR(st.st_mode)) {
/* When we used to have "path" and now we want to add
* "path/file", we need a way to remove "path" before
@@ -145,6 +153,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
return error("%s: cannot add to the index - missing --add option?",
path);
report("add '%s'", path);
+ cache_tree_invalidate_path(active_cache_tree, path);
return 0;
}
@@ -169,6 +178,7 @@ static void chmod_path(int flip, const char *path)
default:
goto fail;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
active_cache_changed = 1;
report("chmod %cx '%s'", flip, path);
return;
@@ -190,6 +200,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
die("Unable to mark file %s", path);
goto free_return;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
if (force_remove) {
if (remove_file_from_cache(p))
@@ -268,6 +279,7 @@ static void read_index_info(int line_termination)
free(path_name);
continue;
}
+ cache_tree_invalidate_path(active_cache_tree, path_name);
if (!mode) {
/* mode == 0 means there is no such path -- remove */
@@ -374,6 +386,7 @@ static int unresolve_one(const char *path)
goto free_return;
}
+ cache_tree_invalidate_path(active_cache_tree, path);
remove_file_from_cache(path);
if (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) {
error("%s: cannot add our version to the index.", path);
diff --git a/write-tree.c b/write-tree.c
index dcad6e667..7a4f691d8 100644
--- a/write-tree.c
+++ b/write-tree.c
@@ -5,95 +5,21 @@
*/
#include "cache.h"
#include "tree.h"
+#include "cache-tree.h"
static int missing_ok = 0;
-static int check_valid_sha1(unsigned char *sha1)
-{
- int ret;
-
- /* If we were anal, we'd check that the sha1 of the contents actually matches */
- ret = has_sha1_file(sha1);
- if (ret == 0)
- perror(sha1_file_name(sha1));
- return ret ? 0 : -1;
-}
-
-static int write_tree(struct cache_entry **cachep, int maxentries, const char *base, int baselen, unsigned char *returnsha1)
-{
- unsigned char subdir_sha1[20];
- unsigned long size, offset;
- char *buffer;
- int nr;
-
- /* Guess at some random initial size */
- size = 8192;
- buffer = xmalloc(size);
- offset = 0;
-
- nr = 0;
- while (nr < maxentries) {
- struct cache_entry *ce = cachep[nr];
- const char *pathname = ce->name, *filename, *dirname;
- int pathlen = ce_namelen(ce), entrylen;
- unsigned char *sha1;
- unsigned int mode;
-
- /* Did we hit the end of the directory? Return how many we wrote */
- if (baselen >= pathlen || memcmp(base, pathname, baselen))
- break;
-
- sha1 = ce->sha1;
- mode = ntohl(ce->ce_mode);
-
- /* Do we have _further_ subdirectories? */
- filename = pathname + baselen;
- dirname = strchr(filename, '/');
- if (dirname) {
- int subdir_written;
-
- subdir_written = write_tree(cachep + nr, maxentries - nr, pathname, dirname-pathname+1, subdir_sha1);
- nr += subdir_written;
-
- /* Now we need to write out the directory entry into this tree.. */
- mode = S_IFDIR;
- pathlen = dirname - pathname;
-
- /* ..but the directory entry doesn't count towards the total count */
- nr--;
- sha1 = subdir_sha1;
- }
-
- if (!missing_ok && check_valid_sha1(sha1) < 0)
- exit(1);
-
- entrylen = pathlen - baselen;
- if (offset + entrylen + 100 > size) {
- size = alloc_nr(offset + entrylen + 100);
- buffer = xrealloc(buffer, size);
- }
- offset += sprintf(buffer + offset, "%o %.*s", mode, entrylen, filename);
- buffer[offset++] = 0;
- memcpy(buffer + offset, sha1, 20);
- offset += 20;
- nr++;
- }
-
- write_sha1_file(buffer, offset, tree_type, returnsha1);
- free(buffer);
- return nr;
-}
-
static const char write_tree_usage[] = "git-write-tree [--missing-ok]";
+static struct cache_file cache_file;
+
int main(int argc, char **argv)
{
- int i, funny;
- int entries;
- unsigned char sha1[20];
-
+ int entries, was_valid, newfd;
+
setup_git_directory();
+ newfd = hold_index_file_for_update(&cache_file, get_index_file());
entries = read_cache();
if (argc == 2) {
if (!strcmp(argv[1], "--missing-ok"))
@@ -108,51 +34,26 @@ int main(int argc, char **argv)
if (entries < 0)
die("git-write-tree: error reading cache");
- /* Verify that the tree is merged */
- funny = 0;
- for (i = 0; i < entries; i++) {
- struct cache_entry *ce = active_cache[i];
- if (ce_stage(ce)) {
- if (10 < ++funny) {
- fprintf(stderr, "...\n");
- break;
- }
- fprintf(stderr, "%s: unmerged (%s)\n", ce->name, sha1_to_hex(ce->sha1));
+ if (!active_cache_tree)
+ active_cache_tree = cache_tree();
+
+ was_valid = cache_tree_fully_valid(active_cache_tree);
+ if (!was_valid) {
+ if (cache_tree_update(active_cache_tree,
+ active_cache, active_nr,
+ missing_ok, 0) < 0)
+ die("git-write-tree: error building trees");
+ if (0 <= newfd) {
+ if (!write_cache(newfd, active_cache, active_nr))
+ commit_index_file(&cache_file);
}
- }
- if (funny)
- die("git-write-tree: not able to write tree");
-
- /* Also verify that the cache does not have path and path/file
- * at the same time. At this point we know the cache has only
- * stage 0 entries.
- */
- funny = 0;
- for (i = 0; i < entries - 1; i++) {
- /* path/file always comes after path because of the way
- * the cache is sorted. Also path can appear only once,
- * which means conflicting one would immediately follow.
+ /* Not being able to write is fine -- we are only interested
+ * in updating the cache-tree part, and if the next caller
+ * ends up using the old index with unupdated cache-tree part
+ * it misses the work we did here, but that is just a
+ * performance penalty and not a big deal.
*/
- const char *this_name = active_cache[i]->name;
- const char *next_name = active_cache[i+1]->name;
- int this_len = strlen(this_name);
- if (this_len < strlen(next_name) &&
- strncmp(this_name, next_name, this_len) == 0 &&
- next_name[this_len] == '/') {
- if (10 < ++funny) {
- fprintf(stderr, "...\n");
- break;
- }
- fprintf(stderr, "You have both %s and %s\n",
- this_name, next_name);
- }
}
- if (funny)
- die("git-write-tree: not able to write tree");
-
- /* Ok, write it out */
- if (write_tree(active_cache, entries, "", 0, sha1) != entries)
- die("git-write-tree: internal error");
- printf("%s\n", sha1_to_hex(sha1));
+ printf("%s\n", sha1_to_hex(active_cache_tree->sha1));
return 0;
}