summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Documentation/RelNotes-1.5.6.3.txt42
-rw-r--r--Documentation/RelNotes-1.6.0.txt35
-rw-r--r--Documentation/config.txt7
-rw-r--r--Documentation/git-add.txt1
-rw-r--r--Documentation/git-apply.txt10
-rw-r--r--Documentation/git-config.txt9
-rw-r--r--Documentation/git-rev-parse.txt24
-rw-r--r--Documentation/git.txt10
-rw-r--r--Documentation/gitcore-tutorial.txt2
-rw-r--r--Documentation/gitglossary.txt2
-rwxr-xr-xDocumentation/install-doc-quick.sh2
-rw-r--r--Documentation/user-manual.txt18
-rw-r--r--INSTALL20
-rw-r--r--Makefile2
-rw-r--r--builtin-apply.c34
-rw-r--r--builtin-clone.c8
-rw-r--r--builtin-config.c15
-rw-r--r--builtin-mailinfo.c1
-rw-r--r--builtin-reflog.c156
-rw-r--r--builtin-rerere.c118
-rw-r--r--builtin-send-pack.c3
-rw-r--r--bundle.c13
-rw-r--r--cache.h5
-rw-r--r--config.c47
-rwxr-xr-xcontrib/completion/git-completion.bash36
-rwxr-xr-xcontrib/examples/git-remote.perl5
-rwxr-xr-xcontrib/fast-import/import-zips.py72
-rw-r--r--daemon.c70
-rwxr-xr-xgit-add--interactive.perl206
-rw-r--r--git-compat-util.h8
-rwxr-xr-xgit-gui/git-gui.sh41
-rw-r--r--git-gui/lib/diff.tcl87
-rwxr-xr-xgit-send-email.perl3
-rwxr-xr-xgit-submodule.sh3
-rwxr-xr-xgit-svn.perl2
-rw-r--r--git.c51
-rw-r--r--gitweb/INSTALL6
-rw-r--r--gitweb/README46
-rw-r--r--path.c96
-rw-r--r--perl/Git.pm56
-rw-r--r--refs.c6
-rw-r--r--run-command.c2
-rw-r--r--setup.c31
-rw-r--r--sha1_file.c1
-rw-r--r--t/lib-httpd.sh18
-rw-r--r--t/lib-httpd/apache.conf1
-rwxr-xr-xt/t0000-basic.sh8
-rwxr-xr-xt/t0060-path-utils.sh87
-rwxr-xr-xt/t1400-update-ref.sh9
-rwxr-xr-xt/t1504-ceiling-dirs.sh163
-rwxr-xr-xt/t3701-add-interactive.sh67
-rwxr-xr-xt/t4112-apply-renames.sh20
-rwxr-xr-xt/t4128-apply-root.sh43
-rwxr-xr-xt/t4200-rerere.sh16
-rwxr-xr-xt/t5404-tracking-branches.sh7
-rwxr-xr-xt/t5540-http-push.sh16
-rwxr-xr-xt/t5601-clone.sh20
-rwxr-xr-xt/t7701-repack-unpack-unreachable.sh34
-rwxr-xr-xt/t9100-git-svn-basic.sh8
-rwxr-xr-xt/t9113-git-svn-dcommit-new-file.sh8
-rw-r--r--t/test-lib.sh1
-rw-r--r--test-absolute-path.c11
-rw-r--r--test-path-utils.c26
64 files changed, 1623 insertions, 354 deletions
diff --git a/.gitignore b/.gitignore
index 8054d9ddb8..a213e8e25b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -141,7 +141,6 @@ git-write-tree
git-core-*/?*
gitk-wish
gitweb/gitweb.cgi
-test-absolute-path
test-chmtime
test-date
test-delta
@@ -149,6 +148,7 @@ test-dump-cache-tree
test-genrandom
test-match-trees
test-parse-options
+test-path-utils
test-sha1
common-cmds.h
*.tar.gz
diff --git a/Documentation/RelNotes-1.5.6.3.txt b/Documentation/RelNotes-1.5.6.3.txt
new file mode 100644
index 0000000000..dd0559b64a
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.3.txt
@@ -0,0 +1,42 @@
+GIT v1.5.6.3 Release Notes
+==========================
+
+Fixes since v1.5.6.2
+--------------------
+
+* Setting GIT_TRACE will report spawning of external process via run_command().
+
+* Bash completion script did not notice '--' marker on the command
+ line and tried the relatively slow "ref completion" even when
+ completing arguments after one.
+
+* Registering a non-empty blob racily and then truncating the working
+ tree file for it confused "racy-git avoidance" logic into thinking
+ that the path is now unchanged.
+
+* "git clone" had a leftover debugging fprintf().
+
+* "git clone -q" was not quiet enough as it used to and gave object count
+ and progress reports.
+
+* "git clone" marked downloaded packfile with .keep; this could be a
+ good thing if the remote side is well packed but otherwise not,
+ especially for a project that is not really big.
+
+* The section that describes attributes related to git-archive were placed
+ in a wrong place in the gitattributes(5) manual page.
+
+* When "git push" tries to remove a remote ref, and corresponding
+ tracking ref is missing, we used to report error (i.e. failure to
+ remove something that does not exist).
+
+* "git mailinfo" (hence "git am") did not handle commit log messages in a
+ MIME multipart mail correctly.
+
+Contains other various documentation fixes.
+
+--
+exec >/var/tmp/1
+O=v1.5.6.2-23-ge965647
+echo O=$(git describe maint)
+git shortlog --no-merges $O..maint
diff --git a/Documentation/RelNotes-1.6.0.txt b/Documentation/RelNotes-1.6.0.txt
index e5c285f9c0..e1f013bd3b 100644
--- a/Documentation/RelNotes-1.6.0.txt
+++ b/Documentation/RelNotes-1.6.0.txt
@@ -23,6 +23,13 @@ encoding introduced in v1.4.4. Pack idx files are using version 2 that
allows larger packs and added robustness thanks to its CRC checking,
introduced in v1.5.2.
+GIT_CONFIG, which was only documented as affecting "git config", but
+actually affected all git commands, now only affects "git config".
+GIT_LOCAL_CONFIG, also only documented as affecting "git config" and
+not different from GIT_CONFIG in a useful way, is removed.
+
+An ancient merge strategy "stupid" has been removed.
+
Updates since v1.5.6
--------------------
@@ -32,8 +39,13 @@ Updates since v1.5.6
* git-p4 in contrib learned "allowSubmit" configuration to control on
which branch to allow "submit" subcommand.
+* git-gui learned to stage changes per-line.
+
(portability)
+* Changes for MinGW port have been merged, thanks to Johannes Sixt and
+ gangs.
+
* Sample hook scripts shipped in templates/ are now suffixed with
*.sample. We used to prevent them from triggering by default by
relying on the fact that we install them as unexecutable, but on
@@ -48,7 +60,8 @@ Updates since v1.5.6
* Updated howto/update-hook-example
-* Got rid of usage of "git-foo" from the tutorial.
+* Got rid of usage of "git-foo" from the tutorial and made typography
+ more consistent.
* Disambiguating "--" between revs and paths is finally documented.
@@ -79,6 +92,11 @@ Updates since v1.5.6
(usability, bells and whistles)
+* A new environment variable GIT_CEILING_DIRECTORIES can be used to stop
+ the discovery process of the toplevel of working tree; this may be useful
+ when you are working in a slow network disk and are outside any working tree,
+ as bash-completion and "git help" may still need to run in these places.
+
* git-apply can handle a patch that touches the same path more than once
much better than before.
@@ -102,13 +120,16 @@ Updates since v1.5.6
* fast-export learned to export and import marks file; this can be used to
interface with fast-import incrementally.
-* Original SHA-1 value for "update-ref -d" is optional now.
+* "git rerere" can be told to update the index with auto-reused resolution
+ with rerere.autoupdate configuration variable.
* git-send-mail can talk not just over SSL but over TLS now.
* You can tell "git status -u" to even more aggressively omit checking
untracked files with --untracked-files=no.
+* Original SHA-1 value for "update-ref -d" is optional now.
+
* Error codes from gitweb are made more descriptive where possible, rather
than "403 forbidden" as we used to issue everywhere.
@@ -121,14 +142,12 @@ Fixes since v1.5.6
All of the fixes in v1.5.6 maintenance series are included in
this release, unless otherwise noted.
- * diff -c/--cc showed unnecessary "deletion" lines at the context
- boundary (needs backmerge to maint).
-
- * "git-clone <src> <dst>" did not create leading directories for <dst>
- like the scripted version used to do (needs backport to maint).
+ * "git fetch" into an empty repository used to remind the fetch will
+ be huge by saying "no common commits", but it is already known by
+ the user anyway (need to backport 8cb560f to 'maint').
---
exec >/var/tmp/1
-O=v1.5.6.1-155-gaa0c1f2
+O=v1.5.6.2-246-g86d7244
echo O=$(git describe refs/heads/master)
git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint
diff --git a/Documentation/config.txt b/Documentation/config.txt
index a403d46c1b..e7848055a9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -658,6 +658,11 @@ gc.rerereunresolved::
kept for this many days when 'git-rerere gc' is run.
The default is 15 days. See linkgit:git-rerere[1].
+rerere.autoupdate::
+ When set to true, `git-rerere` updates the index with the
+ resulting contents after it cleanly resolves conflicts using
+ previously recorded resolution. Defaults to false.
+
rerere.enabled::
Activate recording of resolved conflicts, so that identical
conflict hunks can be resolved automatically, should they
@@ -680,7 +685,7 @@ gitcvs.usecrlfattr
treat it as text. If `crlf` is explicitly unset, the file
will be set with '-kb' mode, which supresses any newline munging
the client might otherwise do. If `crlf` is not specified,
- then 'gitcvs.allbinary' is used. See linkgit:gitattribute[5].
+ then 'gitcvs.allbinary' is used. See linkgit:gitattributes[5].
gitcvs.allbinary::
This is used if 'gitcvs.usecrlfattr' does not resolve
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 011a743652..46dd56c12a 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -236,6 +236,7 @@ patch::
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
+ e - manually edit the current hunk
? - print help
+
After deciding the fate for all hunks, if there is any hunk
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index e9f724b2fa..feb51f124a 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -14,7 +14,7 @@ SYNOPSIS
[--allow-binary-replacement | --binary] [--reject] [-z]
[-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
[--whitespace=<nowarn|warn|fix|error|error-all>]
- [--exclude=PATH] [--verbose] [<patch>...]
+ [--exclude=PATH] [--directory=<root>] [--verbose] [<patch>...]
DESCRIPTION
-----------
@@ -182,6 +182,14 @@ behavior:
by inspecting the patch (e.g. after editing the patch without
adjusting the hunk headers appropriately).
+--directory=<root>::
+ Prepend <root> to all filenames. If a "-p" argument was passed, too,
+ it is applied before prepending the new root.
++
+For example, a patch that talks about updating `a/git-gui.sh` to `b/git-gui.sh`
+can be applied to the file in the working tree `modules/git-gui/git-gui.sh` by
+running `git apply --directory=modules/git-gui`.
+
Configuration
-------------
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index df419e21fd..697824cbab 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -191,11 +191,6 @@ variables. The '--global' and the '--system' options will limit the file used
to the global or system-wide file respectively. The GIT_CONFIG environment
variable has a similar effect, but you can specify any filename you want.
-The GIT_CONFIG_LOCAL environment variable on the other hand only changes
-the name used instead of the repository configuration file. The global and
-the system-wide configuration files will still be read. (For writing options
-this will obviously result in the same behavior as using GIT_CONFIG.)
-
ENVIRONMENT
-----------
@@ -205,10 +200,6 @@ GIT_CONFIG::
Using the "--global" option forces this to ~/.gitconfig. Using the
"--system" option forces this to $(prefix)/etc/gitconfig.
-GIT_CONFIG_LOCAL::
- Take the configuration from the given file instead if .git/config.
- Still read the global and the system-wide configuration files, though.
-
See also <<FILES>>.
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 0501a87025..088f971b79 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -166,7 +166,7 @@ blobs contained in a commit.
first match in the following rules:
. if `$GIT_DIR/<name>` exists, that is what you mean (this is usually
- useful only for `HEAD`, `FETCH_HEAD` and `MERGE_HEAD`);
+ useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD` and `MERGE_HEAD`);
. otherwise, `$GIT_DIR/refs/<name>` if exists;
@@ -177,6 +177,16 @@ blobs contained in a commit.
. otherwise, `$GIT_DIR/refs/remotes/<name>` if exists;
. otherwise, `$GIT_DIR/refs/remotes/<name>/HEAD` if exists.
++
+HEAD names the commit your changes in the working tree is based on.
+FETCH_HEAD records the branch you fetched from a remote repository
+with your last 'git-fetch' invocation.
+ORIG_HEAD is created by commands that moves your HEAD in a drastic
+way, to record the position of the HEAD before their operation, so that
+you can change the tip of the branch back to the state before you ran
+them easily.
+MERGE_HEAD records the commit(s) you are merging into your branch
+when you run 'git-merge'.
* A ref followed by the suffix '@' with a date specification
enclosed in a brace
@@ -289,10 +299,10 @@ notation is used. E.g. "`{caret}r1 r2`" means commits reachable
from `r2` but exclude the ones reachable from `r1`.
This set operation appears so often that there is a shorthand
-for it. "`r1..r2`" is equivalent to "`{caret}r1 r2`". It is
-the difference of two sets (subtract the set of commits
-reachable from `r1` from the set of commits reachable from
-`r2`).
+for it. When you have two commits `r1` and `r2` (named according
+to the syntax explained in SPECIFYING REVISIONS above), you can ask
+for commits that are reachable from r2 excluding those that are reachable
+from r1 by "`{caret}r1 r2`" and it can be written as "`r1..r2`".
A similar notation "`r1\...r2`" is called symmetric difference
of `r1` and `r2` and is defined as
@@ -301,9 +311,9 @@ It is the set of commits that are reachable from either one of
`r1` or `r2` but not from both.
Two other shorthands for naming a set that is formed by a commit
-and its parent commits exists. `r1{caret}@` notation means all
+and its parent commits exist. The `r1{caret}@` notation means all
parents of `r1`. `r1{caret}!` includes commit `r1` but excludes
-its all parents.
+all of its parents.
Here are a handful of examples:
diff --git a/Documentation/git.txt b/Documentation/git.txt
index adc027ce49..4ecdc9f876 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -427,6 +427,14 @@ git so take care if using Cogito etc.
This can also be controlled by the '--work-tree' command line
option and the core.worktree configuration variable.
+'GIT_CEILING_DIRECTORIES'::
+ This should be a colon-separated list of absolute paths.
+ If set, it is a list of directories that git should not chdir
+ up into while looking for a repository directory.
+ It will not exclude the current working directory or
+ a GIT_DIR set on the command line or in the environment.
+ (Useful for excluding slow-loading network directories.)
+
git Commits
~~~~~~~~~~~
'GIT_AUTHOR_NAME'::
@@ -592,7 +600,7 @@ contributors on the git-list <git@vger.kernel.org>.
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
-linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
+linkgit:everyday[7], linkgit:gitcvs-migration[7],
linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
linkgit:gitcli[7], link:user-manual.html[The Git User's Manual]
diff --git a/Documentation/gitcore-tutorial.txt b/Documentation/gitcore-tutorial.txt
index a2b92933f7..49179b0a00 100644
--- a/Documentation/gitcore-tutorial.txt
+++ b/Documentation/gitcore-tutorial.txt
@@ -1690,7 +1690,7 @@ to follow, not easier.
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
-linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
+linkgit:everyday[7], linkgit:gitcvs-migration[7],
link:user-manual.html[The Git User's Manual]
GIT
diff --git a/Documentation/gitglossary.txt b/Documentation/gitglossary.txt
index 5c5c31d31c..565719ed5f 100644
--- a/Documentation/gitglossary.txt
+++ b/Documentation/gitglossary.txt
@@ -17,7 +17,7 @@ include::glossary-content.txt[]
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
-linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
+linkgit:everyday[7], linkgit:gitcvs-migration[7],
link:user-manual.html[The Git User's Manual]
GIT
diff --git a/Documentation/install-doc-quick.sh b/Documentation/install-doc-quick.sh
index 5433cf8ced..35f440876e 100755
--- a/Documentation/install-doc-quick.sh
+++ b/Documentation/install-doc-quick.sh
@@ -6,7 +6,7 @@ head="$1"
mandir="$2"
SUBDIRECTORY_OK=t
USAGE='<refname> <target directory>'
-. git-sh-setup
+. "$(git --exec-path)"/git-sh-setup
cd_to_toplevel
test -z "$mandir" && usage
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 01c1af6b6a..92d400753d 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -518,7 +518,7 @@ $ git bisect visualize
-------------------------------------------------
which will run gitk and label the commit it chose with a marker that
-says "bisect". Chose a safe-looking commit nearby, note its commit
+says "bisect". Choose a safe-looking commit nearby, note its commit
id, and check it out with:
-------------------------------------------------
@@ -1988,8 +1988,8 @@ intend to manage the branch.
It's also possible for a push to fail in this way when other people have
the right to push to the same repository. In that case, the correct
-solution is to retry the push after first updating your work by either a
-pull or a fetch followed by a rebase; see the
+solution is to retry the push after first updating your work: either by a
+pull, or by a fetch followed by a rebase; see the
<<setting-up-a-shared-repository,next section>> and
linkgit:gitcvs-migration[7] for more.
@@ -2861,7 +2861,7 @@ There are four different types of objects: "blob", "tree", "commit", and
"tag".
- A <<def_blob_object,"blob" object>> is used to store file data.
-- A <<def_tree_object,"tree" object>> is an object that ties one or more
+- A <<def_tree_object,"tree" object>> ties one or more
"blob" objects into a directory structure. In addition, a tree object
can refer to other tree objects, thus creating a directory hierarchy.
- A <<def_commit_object,"commit" object>> ties such directory hierarchies
@@ -3036,7 +3036,7 @@ Tag Object
A tag object contains an object, object type, tag name, the name of the
person ("tagger") who created the tag, and a message, which may contain
-a signature, as can be seen using the linkgit:git-cat-file[1]:
+a signature, as can be seen using linkgit:git-cat-file[1]:
------------------------------------------------
$ git cat-file tag v1.5.0
@@ -3986,13 +3986,13 @@ $ mv -f hello.c~2 hello.c
$ git update-index hello.c
-------------------------------------------------
-When a path is in unmerged state, running `git-update-index` for
+When a path is in the "unmerged" state, running `git-update-index` for
that path tells git to mark the path resolved.
The above is the description of a git merge at the lowest level,
to help you understand what conceptually happens under the hood.
-In practice, nobody, not even git itself, uses three `git-cat-file`
-for this. There is `git-merge-index` program that extracts the
+In practice, nobody, not even git itself, runs `git-cat-file` three times
+for this. There is a `git-merge-index` program that extracts the
stages to temporary files and calls a "merge" script on it:
-------------------------------------------------
@@ -4061,7 +4061,7 @@ Note that terminology has changed since that revision. For example, the
README in that revision uses the word "changeset" to describe what we
now call a <<def_commit_object,commit>>.
-Also, we do not call it "cache" any more, but "index", however, the
+Also, we do not call it "cache" any more, but rather "index"; however, the
file is still called `cache.h`. Remark: Not much reason to change it now,
especially since there is no good single name for it anyway, because it is
basically _the_ header file which is included by _all_ of Git's C sources.
diff --git a/INSTALL b/INSTALL
index 0efb4b7801..7d0c2c2f86 100644
--- a/INSTALL
+++ b/INSTALL
@@ -24,17 +24,15 @@ set up install paths (via config.mak.autogen), so you can write instead
Issues of note:
- - git normally installs a helper script wrapper called "git", which
- conflicts with a similarly named "GNU interactive tools" program.
-
- Let's face it, most of us don't have GNU interactive tools, and even
- if we had it, we wouldn't know what it does. I don't think it has
- been actively developed since 1997, and people have moved over to
- graphical file managers.
-
- In addition, as of gnuit-4.9.2, the GNU interactive tools package has
- been renamed. You can compile gnuit with the --disable-transition
- option and then it will not conflict with git.
+ - Ancient versions of GNU Interactive Tools (pre-4.9.2) installed a
+ program "git", whose name conflicts with this program. But with
+ version 4.9.2, after long hiatus without active maintenance (since
+ around 1997), it changed its name to gnuit and the name conflict is no
+ longer a problem.
+
+ NOTE: When compiled with backward compatiblity option, the GNU
+ Interactive Tools package still can install "git", but you can build it
+ with --disable-transition option to avoid this.
- You can use git after building but without installing if you
wanted to. Various git commands need to find other git
diff --git a/Makefile b/Makefile
index bddd1a7e48..4796565ab3 100644
--- a/Makefile
+++ b/Makefile
@@ -1265,7 +1265,7 @@ endif
### Testing rules
-TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-absolute-path$X test-parse-options$X
+TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-parse-options$X test-path-utils$X
all:: $(TEST_PROGRAMS)
diff --git a/builtin-apply.c b/builtin-apply.c
index c0f867daed..d13313f105 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -58,6 +58,8 @@ static int whitespace_error;
static int squelch_whitespace_errors = 5;
static int applied_after_fixing_ws;
static const char *patch_input_file;
+static const char *root;
+static int root_len;
static void parse_whitespace_option(const char *option)
{
@@ -340,6 +342,8 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
*/
strbuf_remove(&name, 0, cp - name.buf);
free(def);
+ if (root)
+ strbuf_insert(&name, 0, root, root_len);
return strbuf_detach(&name, NULL);
}
}
@@ -378,6 +382,14 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
free(def);
}
+ if (root) {
+ char *ret = xmalloc(root_len + len + 1);
+ strcpy(ret, root);
+ memcpy(ret + root_len, start, len);
+ ret[root_len + len] = '\0';
+ return ret;
+ }
+
return xmemdupz(start, len);
}
@@ -2284,7 +2296,8 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
strbuf_init(&buf, 0);
- if ((tpatch = in_fn_table(patch->old_name)) != NULL) {
+ if (!(patch->is_copy || patch->is_rename) &&
+ ((tpatch = in_fn_table(patch->old_name)) != NULL)) {
if (tpatch == (struct patch *) -1) {
return error("patch %s has been renamed/deleted",
patch->old_name);
@@ -2363,7 +2376,7 @@ static int verify_index_match(struct cache_entry *ce, struct stat *st)
static int check_preimage(struct patch *patch, struct cache_entry **ce, struct stat *st)
{
const char *old_name = patch->old_name;
- struct patch *tpatch;
+ struct patch *tpatch = NULL;
int stat_ret = 0;
unsigned st_mode = 0;
@@ -2377,7 +2390,9 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
return 0;
assert(patch->is_new <= 0);
- if ((tpatch = in_fn_table(old_name)) != NULL) {
+
+ if (!(patch->is_copy || patch->is_rename) &&
+ (tpatch = in_fn_table(old_name)) != NULL) {
if (tpatch == (struct patch *) -1) {
return error("%s: has been deleted/renamed", old_name);
}
@@ -2387,6 +2402,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
if (stat_ret && errno != ENOENT)
return error("%s: %s", old_name, strerror(errno));
}
+
if (check_index && !tpatch) {
int pos = cache_name_pos(old_name, strlen(old_name));
if (pos < 0) {
@@ -3240,6 +3256,18 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
options |= RECOUNT;
continue;
}
+ if (!prefixcmp(arg, "--directory=")) {
+ arg += strlen("--directory=");
+ root_len = strlen(arg);
+ if (root_len && arg[root_len - 1] != '/') {
+ char *new_root;
+ root = new_root = xmalloc(root_len + 2);
+ strcpy(new_root, arg);
+ strcpy(new_root + root_len++, "/");
+ } else
+ root = arg;
+ continue;
+ }
if (0 < prefix_length)
arg = prefix_filename(prefix, prefix_length, arg);
diff --git a/builtin-clone.c b/builtin-clone.c
index 643c7d4169..ec36209600 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -341,6 +341,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
const struct ref *refs, *head_points_at, *remote_head, *mapped_refs;
char branch_top[256], key[256], value[256];
struct strbuf reflog_msg;
+ struct transport *transport = NULL;
struct refspec refspec;
@@ -421,7 +422,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
die("could not create leading directories of '%s'", git_dir);
set_git_dir(make_absolute_path(git_dir));
- fprintf(stderr, "Initialize %s\n", git_dir);
init_db(option_template, option_quiet ? INIT_DB_QUIET : 0);
/*
@@ -463,8 +463,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
refs = clone_local(path, git_dir);
else {
struct remote *remote = remote_get(argv[0]);
- struct transport *transport =
- transport_get(remote, remote->url[0]);
+ transport = transport_get(remote, remote->url[0]);
if (!transport->get_refs_list || !transport->fetch)
die("Don't know how to clone %s", transport->url);
@@ -534,6 +533,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
option_no_checkout = 1;
}
+ if (transport)
+ transport_unlock_pack(transport);
+
if (!option_no_checkout) {
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
struct unpack_trees_options opts;
diff --git a/builtin-config.c b/builtin-config.c
index 3a441ef648..39f63d7b10 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -81,12 +81,10 @@ static int get_value(const char* key_, const char* regex_)
char *global = NULL, *repo_config = NULL;
const char *system_wide = NULL, *local;
- local = getenv(CONFIG_ENVIRONMENT);
+ local = config_exclusive_filename;
if (!local) {
const char *home = getenv("HOME");
- local = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!local)
- local = repo_config = xstrdup(git_path("config"));
+ local = repo_config = xstrdup(git_path("config"));
if (git_config_global() && home)
global = xstrdup(mkpath("%s/.gitconfig", home));
if (git_config_system())
@@ -289,6 +287,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
char* value;
const char *file = setup_git_directory_gently(&nongit);
+ config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
+
while (1 < argc) {
if (!strcmp(argv[1], "--int"))
type = T_INT;
@@ -309,14 +309,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
char *home = getenv("HOME");
if (home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
- setenv(CONFIG_ENVIRONMENT, user_config, 1);
- free(user_config);
+ config_exclusive_filename = user_config;
} else {
die("$HOME not set");
}
}
else if (!strcmp(argv[1], "--system"))
- setenv(CONFIG_ENVIRONMENT, git_etc_gitconfig(), 1);
+ config_exclusive_filename = git_etc_gitconfig();
else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
if (argc < 3)
usage(git_config_set_usage);
@@ -325,7 +324,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
argv[2]);
else
file = argv[2];
- setenv(CONFIG_ENVIRONMENT, file, 1);
+ config_exclusive_filename = file;
argc--;
argv++;
}
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 97c1ff9744..fa6e8f90a4 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -812,6 +812,7 @@ static void handle_body(void)
np - newline);
if (!handle_boundary())
return;
+ len = strlen(line);
}
/* Unwrap transfer encoding */
diff --git a/builtin-reflog.c b/builtin-reflog.c
index b151e24ff9..125d455b97 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -269,7 +269,9 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
int status = 0;
memset(&cb, 0, sizeof(cb));
- /* we take the lock for the ref itself to prevent it from
+
+ /*
+ * we take the lock for the ref itself to prevent it from
* getting updated.
*/
lock = lock_any_ref_for_update(ref, sha1, 0);
@@ -331,21 +333,130 @@ static int collect_reflog(const char *ref, const unsigned char *sha1, int unused
return 0;
}
-static int reflog_expire_config(const char *var, const char *value, void *cb)
+static struct reflog_expire_cfg {
+ struct reflog_expire_cfg *next;
+ unsigned long expire_total;
+ unsigned long expire_unreachable;
+ size_t len;
+ char pattern[FLEX_ARRAY];
+} *reflog_expire_cfg, **reflog_expire_cfg_tail;
+
+static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)
{
- if (!strcmp(var, "gc.reflogexpire")) {
- if (!value)
- config_error_nonbool(var);
- default_reflog_expire = approxidate(value);
+ struct reflog_expire_cfg *ent;
+
+ if (!reflog_expire_cfg_tail)
+ reflog_expire_cfg_tail = &reflog_expire_cfg;
+
+ for (ent = reflog_expire_cfg; ent; ent = ent->next)
+ if (ent->len == len &&
+ !memcmp(ent->pattern, pattern, len))
+ return ent;
+
+ ent = xcalloc(1, (sizeof(*ent) + len));
+ memcpy(ent->pattern, pattern, len);
+ ent->len = len;
+ *reflog_expire_cfg_tail = ent;
+ reflog_expire_cfg_tail = &(ent->next);
+ return ent;
+}
+
+static int parse_expire_cfg_value(const char *var, const char *value, unsigned long *expire)
+{
+ if (!value)
+ return config_error_nonbool(var);
+ if (!strcmp(value, "never") || !strcmp(value, "false")) {
+ *expire = 0;
return 0;
}
- if (!strcmp(var, "gc.reflogexpireunreachable")) {
- if (!value)
- config_error_nonbool(var);
- default_reflog_expire_unreachable = approxidate(value);
+ *expire = approxidate(value);
+ return 0;
+}
+
+/* expiry timer slot */
+#define EXPIRE_TOTAL 01
+#define EXPIRE_UNREACH 02
+
+static int reflog_expire_config(const char *var, const char *value, void *cb)
+{
+ const char *lastdot = strrchr(var, '.');
+ unsigned long expire;
+ int slot;
+ struct reflog_expire_cfg *ent;
+
+ if (!lastdot || prefixcmp(var, "gc."))
+ return git_default_config(var, value, cb);
+
+ if (!strcmp(lastdot, ".reflogexpire")) {
+ slot = EXPIRE_TOTAL;
+ if (parse_expire_cfg_value(var, value, &expire))
+ return -1;
+ } else if (!strcmp(lastdot, ".reflogexpireunreachable")) {
+ slot = EXPIRE_UNREACH;
+ if (parse_expire_cfg_value(var, value, &expire))
+ return -1;
+ } else
+ return git_default_config(var, value, cb);
+
+ if (lastdot == var + 2) {
+ switch (slot) {
+ case EXPIRE_TOTAL:
+ default_reflog_expire = expire;
+ break;
+ case EXPIRE_UNREACH:
+ default_reflog_expire_unreachable = expire;
+ break;
+ }
return 0;
}
- return git_default_config(var, value, cb);
+
+ ent = find_cfg_ent(var + 3, lastdot - (var+3));
+ if (!ent)
+ return -1;
+ switch (slot) {
+ case EXPIRE_TOTAL:
+ ent->expire_total = expire;
+ break;
+ case EXPIRE_UNREACH:
+ ent->expire_unreachable = expire;
+ break;
+ }
+ return 0;
+}
+
+static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, const char *ref)
+{
+ struct reflog_expire_cfg *ent;
+
+ if (slot == (EXPIRE_TOTAL|EXPIRE_UNREACH))
+ return; /* both given explicitly -- nothing to tweak */
+
+ for (ent = reflog_expire_cfg; ent; ent = ent->next) {
+ if (!fnmatch(ent->pattern, ref, 0)) {
+ if (!(slot & EXPIRE_TOTAL))
+ cb->expire_total = ent->expire_total;
+ if (!(slot & EXPIRE_UNREACH))
+ cb->expire_unreachable = ent->expire_unreachable;
+ return;
+ }
+ }
+
+ /*
+ * If unconfigured, make stash never expire
+ */
+ if (!strcmp(ref, "refs/stash")) {
+ if (!(slot & EXPIRE_TOTAL))
+ cb->expire_total = 0;
+ if (!(slot & EXPIRE_UNREACH))
+ cb->expire_unreachable = 0;
+ return;
+ }
+
+ /* Nothing matched -- use the default value */
+ if (!(slot & EXPIRE_TOTAL))
+ cb->expire_total = default_reflog_expire;
+ if (!(slot & EXPIRE_UNREACH))
+ cb->expire_unreachable = default_reflog_expire_unreachable;
}
static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
@@ -353,6 +464,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
struct cmd_reflog_expire_cb cb;
unsigned long now = time(NULL);
int i, status, do_all;
+ int explicit_expiry = 0;
git_config(reflog_expire_config, NULL);
@@ -367,20 +479,18 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
cb.expire_total = default_reflog_expire;
cb.expire_unreachable = default_reflog_expire_unreachable;
- /*
- * We can trust the commits and objects reachable from refs
- * even in older repository. We cannot trust what's reachable
- * from reflog if the repository was pruned with older git.
- */
-
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
cb.dry_run = 1;
- else if (!prefixcmp(arg, "--expire="))
+ else if (!prefixcmp(arg, "--expire=")) {
cb.expire_total = approxidate(arg + 9);
- else if (!prefixcmp(arg, "--expire-unreachable="))
+ explicit_expiry |= EXPIRE_TOTAL;
+ }
+ else if (!prefixcmp(arg, "--expire-unreachable=")) {
cb.expire_unreachable = approxidate(arg + 21);
+ explicit_expiry |= EXPIRE_UNREACH;
+ }
else if (!strcmp(arg, "--stale-fix"))
cb.stalefix = 1;
else if (!strcmp(arg, "--rewrite"))
@@ -400,6 +510,12 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
else
break;
}
+
+ /*
+ * We can trust the commits and objects reachable from refs
+ * even in older repository. We cannot trust what's reachable
+ * from reflog if the repository was pruned with older git.
+ */
if (cb.stalefix) {
init_revisions(&cb.revs, prefix);
if (cb.verbose)
@@ -417,6 +533,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
for_each_reflog(collect_reflog, &collected);
for (i = 0; i < collected.nr; i++) {
struct collected_reflog *e = collected.e[i];
+ set_reflog_expiry_param(&cb, explicit_expiry, e->reflog);
status |= expire_reflog(e->reflog, e->sha1, 0, &cb);
free(e);
}
@@ -430,6 +547,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
status |= error("%s points nowhere!", ref);
continue;
}
+ set_reflog_expiry_param(&cb, explicit_expiry, ref);
status |= expire_reflog(ref, sha1, 0, &cb);
}
return status;
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 85222d9bc5..839b26e8e0 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -16,6 +16,9 @@ static int cutoff_resolve = 60;
/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
static int rerere_enabled = -1;
+/* automatically update cleanly resolved paths to the index */
+static int rerere_autoupdate;
+
static char *merge_rr_path;
static const char *rr_path(const char *name, const char *file)
@@ -23,6 +26,18 @@ static const char *rr_path(const char *name, const char *file)
return git_path("rr-cache/%s/%s", name, file);
}
+static time_t rerere_created_at(const char *name)
+{
+ struct stat st;
+ return stat(rr_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
+}
+
+static int has_resolution(const char *name)
+{
+ struct stat st;
+ return !stat(rr_path(name, "postimage"), &st);
+}
+
static void read_rr(struct path_list *rr)
{
unsigned char sha1[20];
@@ -54,8 +69,12 @@ static int write_rr(struct path_list *rr, int out_fd)
{
int i;
for (i = 0; i < rr->nr; i++) {
- const char *path = rr->items[i].path;
- int length = strlen(path) + 1;
+ const char *path;
+ int length;
+ if (!rr->items[i].util)
+ continue;
+ path = rr->items[i].path;
+ length = strlen(path) + 1;
if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
write_in_full(out_fd, "\t", 1) != 1 ||
write_in_full(out_fd, path, length) != length)
@@ -98,13 +117,10 @@ static int handle_file(const char *path,
else if (!prefixcmp(buf, "======="))
hunk = 2;
else if (!prefixcmp(buf, ">>>>>>> ")) {
- int cmp = strbuf_cmp(&one, &two);
-
+ if (strbuf_cmp(&one, &two) > 0)
+ strbuf_swap(&one, &two);
hunk_no++;
hunk = 0;
- if (cmp > 0) {
- strbuf_swap(&one, &two);
- }
if (out) {
fputs("<<<<<<<\n", out);
fwrite(one.buf, one.len, 1, out);
@@ -135,6 +151,11 @@ static int handle_file(const char *path,
fclose(out);
if (sha1)
SHA1_Final(sha1, &ctx);
+ if (hunk) {
+ if (output)
+ unlink(output);
+ return error("Could not parse conflict hunks in %s", path);
+ }
return hunk_no;
}
@@ -201,33 +222,24 @@ static void unlink_rr_item(const char *name)
static void garbage_collect(struct path_list *rr)
{
struct path_list to_remove = { NULL, 0, 0, 1 };
- char buf[1024];
DIR *dir;
struct dirent *e;
- int len, i, cutoff;
+ int i, cutoff;
time_t now = time(NULL), then;
- strlcpy(buf, git_path("rr-cache"), sizeof(buf));
- len = strlen(buf);
- dir = opendir(buf);
- strcpy(buf + len++, "/");
+ dir = opendir(git_path("rr-cache"));
while ((e = readdir(dir))) {
const char *name = e->d_name;
- struct stat st;
- if (name[0] == '.' && (name[1] == '\0' ||
- (name[1] == '.' && name[2] == '\0')))
+ if (name[0] == '.' &&
+ (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')))
continue;
- i = snprintf(buf + len, sizeof(buf) - len, "%s", name);
- strlcpy(buf + len + i, "/preimage", sizeof(buf) - len - i);
- if (stat(buf, &st))
+ then = rerere_created_at(name);
+ if (!then)
continue;
- then = st.st_mtime;
- strlcpy(buf + len + i, "/postimage", sizeof(buf) - len - i);
- cutoff = stat(buf, &st) ? cutoff_noresolve : cutoff_resolve;
- if (then < now - cutoff * 86400) {
- buf[len + i] = '\0';
- path_list_insert(xstrdup(name), &to_remove);
- }
+ cutoff = (has_resolution(name)
+ ? cutoff_resolve : cutoff_noresolve);
+ if (then < now - cutoff * 86400)
+ path_list_append(name, &to_remove);
}
for (i = 0; i < to_remove.nr; i++)
unlink_rr_item(to_remove.items[i].path);
@@ -267,9 +279,36 @@ static int diff_two(const char *file1, const char *label1,
return 0;
}
+static struct lock_file index_lock;
+
+static int update_paths(struct path_list *update)
+{
+ int i;
+ int fd = hold_locked_index(&index_lock, 0);
+ int status = 0;
+
+ if (fd < 0)
+ return -1;
+
+ for (i = 0; i < update->nr; i++) {
+ struct path_list_item *item = &update->items[i];
+ if (add_file_to_cache(item->path, ADD_CACHE_IGNORE_ERRORS))
+ status = -1;
+ }
+
+ if (!status && active_cache_changed) {
+ if (write_cache(fd, active_cache, active_nr) ||
+ commit_locked_index(&index_lock))
+ die("Unable to write new index file");
+ } else if (fd >= 0)
+ rollback_lock_file(&index_lock);
+ return status;
+}
+
static int do_plain_rerere(struct path_list *rr, int fd)
{
struct path_list conflict = { NULL, 0, 0, 1 };
+ struct path_list update = { NULL, 0, 0, 1 };
int i;
find_conflict(&conflict);
@@ -306,17 +345,17 @@ static int do_plain_rerere(struct path_list *rr, int fd)
*/
for (i = 0; i < rr->nr; i++) {
- struct stat st;
int ret;
const char *path = rr->items[i].path;
const char *name = (const char *)rr->items[i].util;
- if (!stat(rr_path(name, "preimage"), &st) &&
- !stat(rr_path(name, "postimage"), &st)) {
+ if (has_resolution(name)) {
if (!merge(name, path)) {
fprintf(stderr, "Resolved '%s' using "
"previous resolution.\n", path);
- goto tail_optimization;
+ if (rerere_autoupdate)
+ path_list_insert(path, &update);
+ goto mark_resolved;
}
}
@@ -327,15 +366,13 @@ static int do_plain_rerere(struct path_list *rr, int fd)
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
copy_file(rr_path(name, "postimage"), path, 0666);
-tail_optimization:
- if (i < rr->nr - 1)
- memmove(rr->items + i,
- rr->items + i + 1,
- sizeof(rr->items[0]) * (rr->nr - i - 1));
- rr->nr--;
- i--;
+ mark_resolved:
+ rr->items[i].util = NULL;
}
+ if (update.nr)
+ update_paths(&update);
+
return write_rr(rr, fd);
}
@@ -347,6 +384,8 @@ static int git_rerere_config(const char *var, const char *value, void *cb)
cutoff_noresolve = git_config_int(var, value);
else if (!strcmp(var, "rerere.enabled"))
rerere_enabled = git_config_bool(var, value);
+ else if (!strcmp(var, "rerere.autoupdate"))
+ rerere_autoupdate = git_config_bool(var, value);
else
return git_default_config(var, value, cb);
return 0;
@@ -410,11 +449,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
return do_plain_rerere(&merge_rr, fd);
else if (!strcmp(argv[1], "clear")) {
for (i = 0; i < merge_rr.nr; i++) {
- struct stat st;
const char *name = (const char *)merge_rr.items[i].util;
- if (!stat(git_path("rr-cache/%s", name), &st) &&
- S_ISDIR(st.st_mode) &&
- stat(rr_path(name, "postimage"), &st))
+ if (!has_resolution(name))
unlink_rr_item(name);
}
unlink(merge_rr_path);
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index d76260c09e..a708d0af48 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -226,8 +226,7 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
if (args.verbose)
fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst);
if (ref->deletion) {
- if (delete_ref(rs.dst, NULL))
- error("Failed to delete");
+ delete_ref(rs.dst, NULL);
} else
update_ref("update by push", rs.dst,
ref->new_sha1, NULL, 0, 0);
diff --git a/bundle.c b/bundle.c
index 0ba5df17e1..00b2aabefc 100644
--- a/bundle.c
+++ b/bundle.c
@@ -178,6 +178,7 @@ int create_bundle(struct bundle_header *header, const char *path,
int i, ref_count = 0;
char buffer[1024];
struct rev_info revs;
+ int read_from_stdin = 0;
struct child_process rls;
FILE *rls_fout;
@@ -227,8 +228,16 @@ int create_bundle(struct bundle_header *header, const char *path,
/* write references */
argc = setup_revisions(argc, argv, &revs, NULL);
- if (argc > 1)
- return error("unrecognized argument: %s'", argv[1]);
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "--stdin")) {
+ if (read_from_stdin++)
+ die("--stdin given twice?");
+ read_revisions_from_stdin(&revs);
+ continue;
+ }
+ return error("unrecognized argument: %s'", argv[i]);
+ }
for (i = 0; i < revs.pending.nr; i++) {
struct object_array_entry *e = revs.pending.objects + i;
diff --git a/cache.h b/cache.h
index 35a91320a5..0d8eddac77 100644
--- a/cache.h
+++ b/cache.h
@@ -298,8 +298,8 @@ static inline enum object_type object_type(unsigned int mode)
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
-#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
+#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
#define GITATTRIBUTES_FILE ".gitattributes"
#define INFOATTRIBUTES_FILE "info/attributes"
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
@@ -527,6 +527,8 @@ static inline int is_absolute_path(const char *path)
const char *make_absolute_path(const char *path);
const char *make_nonrelative_path(const char *path);
const char *make_relative_path(const char *abs, const char *base);
+int normalize_absolute_path(char *buf, const char *path);
+int longest_ancestor_length(const char *path, const char *prefix_list);
/* Read and unpack a sha1 file into memory, write memory to a sha1 file */
extern int sha1_object_info(const unsigned char *, unsigned long *);
@@ -743,6 +745,7 @@ extern int check_repository_format_version(const char *var, const char *value, v
extern int git_config_system(void);
extern int git_config_global(void);
extern int config_error_nonbool(const char *);
+extern const char *config_exclusive_filename;
#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
diff --git a/config.c b/config.c
index 58749bf416..2862cc45cb 100644
--- a/config.c
+++ b/config.c
@@ -16,6 +16,8 @@ static int config_linenr;
static int config_file_eof;
static int zlib_compression_seen;
+const char *config_exclusive_filename = NULL;
+
static int get_next_char(void)
{
int c;
@@ -611,31 +613,28 @@ int git_config(config_fn_t fn, void *data)
{
int ret = 0;
char *repo_config = NULL;
- const char *home = NULL, *filename;
+ const char *home = NULL;
/* $GIT_CONFIG makes git read _only_ the given config file,
* $GIT_CONFIG_LOCAL will make it process it in addition to the
* global config file, the same way it would the per-repository
* config file otherwise. */
- filename = getenv(CONFIG_ENVIRONMENT);
- if (!filename) {
- if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
- ret += git_config_from_file(fn, git_etc_gitconfig(),
- data);
- home = getenv("HOME");
- filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!filename)
- filename = repo_config = xstrdup(git_path("config"));
- }
+ if (config_exclusive_filename)
+ return git_config_from_file(fn, config_exclusive_filename, data);
+ if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
+ ret += git_config_from_file(fn, git_etc_gitconfig(),
+ data);
+ home = getenv("HOME");
if (git_config_global() && home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
if (!access(user_config, R_OK))
- ret = git_config_from_file(fn, user_config, data);
+ ret += git_config_from_file(fn, user_config, data);
free(user_config);
}
- ret += git_config_from_file(fn, filename, data);
+ repo_config = xstrdup(git_path("config"));
+ ret += git_config_from_file(fn, repo_config, data);
free(repo_config);
return ret;
}
@@ -873,13 +872,10 @@ int git_config_set_multivar(const char* key, const char* value,
struct lock_file *lock = NULL;
const char* last_dot = strrchr(key, '.');
- config_filename = getenv(CONFIG_ENVIRONMENT);
- if (!config_filename) {
- config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!config_filename)
- config_filename = git_path("config");
- }
- config_filename = xstrdup(config_filename);
+ if (config_exclusive_filename)
+ config_filename = xstrdup(config_exclusive_filename);
+ else
+ config_filename = xstrdup(git_path("config"));
/*
* Since "key" actually contains the section name and the real
@@ -1136,13 +1132,10 @@ int git_config_rename_section(const char *old_name, const char *new_name)
int out_fd;
char buf[1024];
- config_filename = getenv(CONFIG_ENVIRONMENT);
- if (!config_filename) {
- config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!config_filename)
- config_filename = git_path("config");
- }
- config_filename = xstrdup(config_filename);
+ if (config_exclusive_filename)
+ config_filename = xstrdup(config_exclusive_filename);
+ else
+ config_filename = xstrdup(git_path("config"));
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
if (out_fd < 0) {
ret = error("could not lock config file %s", config_filename);
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3f46149853..27332ed8b1 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -451,6 +451,18 @@ __git_find_subcommand ()
done
}
+__git_has_doubledash ()
+{
+ local c=1
+ while [ $c -lt $COMP_CWORD ]; do
+ if [ "--" = "${COMP_WORDS[c]}" ]; then
+ return 0
+ fi
+ c=$((++c))
+ done
+ return 1
+}
+
__git_whitespacelist="nowarn warn error error-all strip"
_git_am ()
@@ -497,6 +509,8 @@ _git_apply ()
_git_add ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -511,7 +525,9 @@ _git_add ()
_git_bisect ()
{
- local subcommands="start bad good reset visualize replay log"
+ __git_has_doubledash && return
+
+ local subcommands="start bad good skip reset visualize replay log run"
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
@@ -519,7 +535,7 @@ _git_bisect ()
fi
case "$subcommand" in
- bad|good|reset)
+ bad|good|reset|skip)
__gitcomp "$(__git_refs)"
;;
*)
@@ -546,7 +562,7 @@ _git_branch ()
--*)
__gitcomp "
--color --no-color --verbose --abbrev= --no-abbrev
- --track --no-track
+ --track --no-track --contains --merged --no-merged
"
;;
*)
@@ -613,6 +629,8 @@ _git_cherry_pick ()
_git_commit ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -632,6 +650,8 @@ _git_describe ()
_git_diff ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -734,6 +754,8 @@ _git_ls_tree ()
_git_log ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--pretty=*)
@@ -1086,6 +1108,8 @@ _git_remote ()
_git_reset ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -1098,6 +1122,8 @@ _git_reset ()
_git_shortlog ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -1144,6 +1170,8 @@ _git_stash ()
_git_submodule ()
{
+ __git_has_doubledash && return
+
local subcommands="add status init update"
if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1350,6 +1378,8 @@ _git ()
_gitk ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
local g="$(git rev-parse --git-dir 2>/dev/null)"
local merge=""
diff --git a/contrib/examples/git-remote.perl b/contrib/examples/git-remote.perl
index b30ed734e7..36bd54c985 100755
--- a/contrib/examples/git-remote.perl
+++ b/contrib/examples/git-remote.perl
@@ -129,10 +129,7 @@ sub update_ls_remote {
return if (($harder == 0) ||
(($harder == 1) && exists $info->{'LS_REMOTE'}));
- my @ref = map {
- s|^[0-9a-f]{40}\s+refs/heads/||;
- $_;
- } $git->command(qw(ls-remote --heads), $info->{'URL'});
+ my @ref = map { s|refs/heads/||; $_; } keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])};
$info->{'LS_REMOTE'} = \@ref;
}
diff --git a/contrib/fast-import/import-zips.py b/contrib/fast-import/import-zips.py
new file mode 100755
index 0000000000..c674fa2d1b
--- /dev/null
+++ b/contrib/fast-import/import-zips.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+## zip archive frontend for git-fast-import
+##
+## For example:
+##
+## mkdir project; cd project; git init
+## python import-zips.py *.zip
+## git log --stat import-zips
+
+from os import popen, path
+from sys import argv, exit
+from time import mktime
+from zipfile import ZipFile
+
+if len(argv) < 2:
+ print 'Usage:', argv[0], '<zipfile>...'
+ exit(1)
+
+branch_ref = 'refs/heads/import-zips'
+committer_name = 'Z Ip Creator'
+committer_email = 'zip@example.com'
+
+fast_import = popen('git fast-import --quiet', 'w')
+def printlines(list):
+ for str in list:
+ fast_import.write(str + "\n")
+
+for zipfile in argv[1:]:
+ commit_time = 0
+ next_mark = 1
+ common_prefix = None
+ mark = dict()
+
+ zip = ZipFile(zipfile, 'r')
+ for name in zip.namelist():
+ if name.endswith('/'):
+ continue
+ info = zip.getinfo(name)
+
+ if commit_time < info.date_time:
+ commit_time = info.date_time
+ if common_prefix == None:
+ common_prefix = name[:name.rfind('/') + 1]
+ else:
+ while not name.startswith(common_prefix):
+ common_prefix = name[:name.rfind('/') + 1]
+
+ mark[name] = ':' + str(next_mark)
+ next_mark += 1
+
+ printlines(('blob', 'mark ' + mark[name], \
+ 'data ' + str(info.file_size)))
+ fast_import.write(zip.read(name) + "\n")
+
+ committer = committer_name + ' <' + committer_email + '> %d +0000' % \
+ mktime(commit_time + (0, 0, 0))
+
+ printlines(('commit ' + branch_ref, 'committer ' + committer, \
+ 'data <<EOM', 'Imported from ' + zipfile + '.', 'EOM', \
+ '', 'deleteall'))
+
+ for name in mark.keys():
+ fast_import.write('M 100644 ' + mark[name] + ' ' +
+ name[len(common_prefix):] + "\n")
+
+ printlines(('', 'tag ' + path.basename(zipfile), \
+ 'from ' + branch_ref, 'tagger ' + committer, \
+ 'data <<EOM', 'Package ' + zipfile, 'EOM', ''))
+
+if fast_import.close():
+ exit(1)
diff --git a/daemon.c b/daemon.c
index 63cd12cd9c..ce3a6f58f3 100644
--- a/daemon.c
+++ b/daemon.c
@@ -694,23 +694,47 @@ static void kill_some_children(int signo, unsigned start, unsigned stop)
}
}
+static void check_dead_children(void)
+{
+ unsigned spawned, reaped, deleted;
+
+ spawned = children_spawned;
+ reaped = children_reaped;
+ deleted = children_deleted;
+
+ while (deleted < reaped) {
+ pid_t pid = dead_child[deleted % MAX_CHILDREN];
+ const char *dead = pid < 0 ? " (with error)" : "";
+
+ if (pid < 0)
+ pid = -pid;
+
+ /* XXX: Custom logging, since we don't wanna getpid() */
+ if (verbose) {
+ if (log_syslog)
+ syslog(LOG_INFO, "[%d] Disconnected%s",
+ pid, dead);
+ else
+ fprintf(stderr, "[%d] Disconnected%s\n",
+ pid, dead);
+ }
+ remove_child(pid, deleted, spawned);
+ deleted++;
+ }
+ children_deleted = deleted;
+}
+
static void check_max_connections(void)
{
for (;;) {
int active;
- unsigned spawned, reaped, deleted;
+ unsigned spawned, deleted;
+
+ check_dead_children();
spawned = children_spawned;
- reaped = children_reaped;
deleted = children_deleted;
- while (deleted < reaped) {
- pid_t pid = dead_child[deleted % MAX_CHILDREN];
- remove_child(pid, deleted, spawned);
- deleted++;
- }
- children_deleted = deleted;
-
active = spawned - deleted;
if (active <= max_connections)
break;
@@ -760,18 +784,10 @@ static void child_handler(int signo)
if (pid > 0) {
unsigned reaped = children_reaped;
+ if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
+ pid = -pid;
dead_child[reaped % MAX_CHILDREN] = pid;
children_reaped = reaped + 1;
- /* XXX: Custom logging, since we don't wanna getpid() */
- if (verbose) {
- const char *dead = "";
- if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
- dead = " (with error)";
- if (log_syslog)
- syslog(LOG_INFO, "[%d] Disconnected%s", pid, dead);
- else
- fprintf(stderr, "[%d] Disconnected%s\n", pid, dead);
- }
continue;
}
break;
@@ -928,8 +944,18 @@ static int service_loop(int socknum, int *socklist)
for (;;) {
int i;
+ int timeout;
- if (poll(pfd, socknum, -1) < 0) {
+ /*
+ * This 1-sec timeout could lead to idly looping but it is
+ * here so that children culled in child_handler() are reported
+ * without too much delay. We could probably set up a pipe
+ * to ourselves that we poll, and write to the fd from child_handler()
+ * to wake us up (and consume it when the poll() returns...
+ */
+ timeout = (children_spawned != children_deleted) ? 1000 : -1;
+ i = poll(pfd, socknum, timeout);
+ if (i < 0) {
if (errno != EINTR) {
error("poll failed, resuming: %s",
strerror(errno));
@@ -937,6 +963,10 @@ static int service_loop(int socknum, int *socklist)
}
continue;
}
+ if (i == 0) {
+ check_dead_children();
+ continue;
+ }
for (i = 0; i < socknum; i++) {
if (pfd[i].revents & POLLIN) {
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 903953e68e..801d7c0251 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -18,6 +18,18 @@ my ($fraginfo_color) =
$diff_use_color ? (
$repo->get_color('color.diff.frag', 'cyan'),
) : ();
+my ($diff_plain_color) =
+ $diff_use_color ? (
+ $repo->get_color('color.diff.plain', ''),
+ ) : ();
+my ($diff_old_color) =
+ $diff_use_color ? (
+ $repo->get_color('color.diff.old', 'red'),
+ ) : ();
+my ($diff_new_color) =
+ $diff_use_color ? (
+ $repo->get_color('color.diff.new', 'green'),
+ ) : ();
my $normal_color = $repo->get_color("", "reset");
@@ -682,92 +694,104 @@ sub split_hunk {
return @split;
}
-sub find_last_o_ctx {
- my ($it) = @_;
- my $text = $it->{TEXT};
- my ($o_ofs, $o_cnt) = parse_hunk_header($text->[0]);
- my $i = @{$text};
- my $last_o_ctx = $o_ofs + $o_cnt;
- while (0 < --$i) {
- my $line = $text->[$i];
- if ($line =~ /^ /) {
- $last_o_ctx--;
- next;
- }
- last;
- }
- return $last_o_ctx;
+
+sub color_diff {
+ return map {
+ colored((/^@/ ? $fraginfo_color :
+ /^\+/ ? $diff_new_color :
+ /^-/ ? $diff_old_color :
+ $diff_plain_color),
+ $_);
+ } @_;
}
-sub merge_hunk {
- my ($prev, $this) = @_;
- my ($o0_ofs, $o0_cnt, $n0_ofs, $n0_cnt) =
- parse_hunk_header($prev->{TEXT}[0]);
- my ($o1_ofs, $o1_cnt, $n1_ofs, $n1_cnt) =
- parse_hunk_header($this->{TEXT}[0]);
-
- my (@line, $i, $ofs, $o_cnt, $n_cnt);
- $ofs = $o0_ofs;
- $o_cnt = $n_cnt = 0;
- for ($i = 1; $i < @{$prev->{TEXT}}; $i++) {
- my $line = $prev->{TEXT}[$i];
- if ($line =~ /^\+/) {
- $n_cnt++;
- push @line, $line;
- next;
- }
+sub edit_hunk_manually {
+ my ($oldtext) = @_;
- last if ($o1_ofs <= $ofs);
+ my $hunkfile = $repo->repo_path . "/addp-hunk-edit.diff";
+ my $fh;
+ open $fh, '>', $hunkfile
+ or die "failed to open hunk edit file for writing: " . $!;
+ print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
+ print $fh @$oldtext;
+ print $fh <<EOF;
+# ---
+# To remove '-' lines, make them ' ' lines (context).
+# To remove '+' lines, delete them.
+# Lines starting with # will be removed.
+#
+# If the patch applies cleanly, the edited hunk will immediately be
+# marked for staging. If it does not apply cleanly, you will be given
+# an opportunity to edit again. If all lines of the hunk are removed,
+# then the edit is aborted and the hunk is left unchanged.
+EOF
+ close $fh;
- $o_cnt++;
- $ofs++;
- if ($line =~ /^ /) {
- $n_cnt++;
- }
- push @line, $line;
+ my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor")
+ || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+ system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
+
+ open $fh, '<', $hunkfile
+ or die "failed to open hunk edit file for reading: " . $!;
+ my @newtext = grep { !/^#/ } <$fh>;
+ close $fh;
+ unlink $hunkfile;
+
+ # Abort if nothing remains
+ if (!grep { /\S/ } @newtext) {
+ return undef;
}
- for ($i = 1; $i < @{$this->{TEXT}}; $i++) {
- my $line = $this->{TEXT}[$i];
- if ($line =~ /^\+/) {
- $n_cnt++;
- push @line, $line;
- next;
- }
- $ofs++;
- $o_cnt++;
- if ($line =~ /^ /) {
- $n_cnt++;
- }
- push @line, $line;
+ # Reinsert the first hunk header if the user accidentally deleted it
+ if ($newtext[0] !~ /^@/) {
+ unshift @newtext, $oldtext->[0];
+ }
+ return \@newtext;
+}
+
+sub diff_applies {
+ my $fh;
+ open $fh, '| git apply --recount --cached --check';
+ for my $h (@_) {
+ print $fh @{$h->{TEXT}};
}
- my $head = ("@@ -$o0_ofs" .
- (($o_cnt != 1) ? ",$o_cnt" : '') .
- " +$n0_ofs" .
- (($n_cnt != 1) ? ",$n_cnt" : '') .
- " @@\n");
- @{$prev->{TEXT}} = ($head, @line);
+ return close $fh;
}
-sub coalesce_overlapping_hunks {
- my (@in) = @_;
- my @out = ();
+sub prompt_yesno {
+ my ($prompt) = @_;
+ while (1) {
+ print colored $prompt_color, $prompt;
+ my $line = <STDIN>;
+ return 0 if $line =~ /^n/i;
+ return 1 if $line =~ /^y/i;
+ }
+}
- my ($last_o_ctx);
+sub edit_hunk_loop {
+ my ($head, $hunk, $ix) = @_;
+ my $text = $hunk->[$ix]->{TEXT};
- for (grep { $_->{USE} } @in) {
- my $text = $_->{TEXT};
- my ($o_ofs) = parse_hunk_header($text->[0]);
- if (defined $last_o_ctx &&
- $o_ofs <= $last_o_ctx) {
- merge_hunk($out[-1], $_);
+ while (1) {
+ $text = edit_hunk_manually($text);
+ if (!defined $text) {
+ return undef;
+ }
+ my $newhunk = { TEXT => $text, USE => 1 };
+ if (diff_applies($head,
+ @{$hunk}[0..$ix-1],
+ $newhunk,
+ @{$hunk}[$ix+1..$#{$hunk}])) {
+ $newhunk->{DISPLAY} = [color_diff(@{$text})];
+ return $newhunk;
}
else {
- push @out, $_;
+ prompt_yesno(
+ 'Your edited hunk does not apply. Edit again '
+ . '(saying "no" discards!) [y/n]? '
+ ) or return undef;
}
- $last_o_ctx = find_last_o_ctx($out[-1]);
}
- return @out;
}
sub help_patch_cmd {
@@ -781,6 +805,7 @@ J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
+e - manually edit the current hunk
? - print help
EOF
}
@@ -885,6 +910,7 @@ sub patch_update_file {
if (hunk_splittable($hunk[$ix]{TEXT})) {
$other .= '/s';
}
+ $other .= '/e';
for (@{$hunk[$ix]{DISPLAY}}) {
print;
}
@@ -949,6 +975,12 @@ sub patch_update_file {
$num = scalar @hunk;
next;
}
+ elsif ($line =~ /^e/) {
+ my $newhunk = edit_hunk_loop($head, \@hunk, $ix);
+ if (defined $newhunk) {
+ splice @hunk, $ix, 1, $newhunk;
+ }
+ }
else {
help_patch_cmd($other);
next;
@@ -962,47 +994,21 @@ sub patch_update_file {
}
}
- @hunk = coalesce_overlapping_hunks(@hunk);
-
my $n_lofs = 0;
my @result = ();
if ($mode->{USE}) {
push @result, @{$mode->{TEXT}};
}
for (@hunk) {
- my $text = $_->{TEXT};
- my ($o_ofs, $o_cnt, $n_ofs, $n_cnt) =
- parse_hunk_header($text->[0]);
-
- if (!$_->{USE}) {
- # We would have added ($n_cnt - $o_cnt) lines
- # to the postimage if we were to use this hunk,
- # but we didn't. So the line number that the next
- # hunk starts at would be shifted by that much.
- $n_lofs -= ($n_cnt - $o_cnt);
- next;
- }
- else {
- if ($n_lofs) {
- $n_ofs += $n_lofs;
- $text->[0] = ("@@ -$o_ofs" .
- (($o_cnt != 1)
- ? ",$o_cnt" : '') .
- " +$n_ofs" .
- (($n_cnt != 1)
- ? ",$n_cnt" : '') .
- " @@\n");
- }
- for (@$text) {
- push @result, $_;
- }
+ if ($_->{USE}) {
+ push @result, @{$_->{TEXT}};
}
}
if (@result) {
my $fh;
- open $fh, '| git apply --cached';
+ open $fh, '| git apply --cached --recount';
for (@{$head->{TEXT}}, @result) {
print $fh $_;
}
diff --git a/git-compat-util.h b/git-compat-util.h
index 545df59242..8c7e114733 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -110,6 +110,14 @@
#define PRIuMAX "llu"
#endif
+#ifndef PRIu32
+#define PRIu32 "u"
+#endif
+
+#ifndef PRIx32
+#define PRIx32 "x"
+#endif
+
#ifndef PATH_SEP
#define PATH_SEP ':'
#endif
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index e6e88902f1..d89f156fd5 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1774,6 +1774,11 @@ proc do_commit {} {
commit_tree
}
+proc next_diff {} {
+ global next_diff_p next_diff_w next_diff_i
+ show_diff $next_diff_p $next_diff_w $next_diff_i
+}
+
proc toggle_or_diff {w x y} {
global file_states file_lists current_diff_path ui_index ui_workdir
global last_clicked selected_paths
@@ -1792,12 +1797,34 @@ proc toggle_or_diff {w x y} {
$ui_index tag remove in_sel 0.0 end
$ui_workdir tag remove in_sel 0.0 end
- if {$col == 0} {
- if {$current_diff_path eq $path} {
+ if {$col == 0 && $y > 1} {
+ set i [expr {$lno-1}]
+ set ll [expr {[llength $file_lists($w)]-1}]
+
+ if {$i == $ll && $i == 0} {
set after {reshow_diff;}
} else {
- set after {}
+ global next_diff_p next_diff_w next_diff_i
+
+ set next_diff_w $w
+
+ if {$i < $ll} {
+ set i [expr {$i + 1}]
+ set next_diff_i $i
+ } else {
+ set next_diff_i $i
+ set i [expr {$i - 1}]
+ }
+
+ set next_diff_p [lindex $file_lists($w) $i]
+
+ if {$next_diff_p ne {} && $current_diff_path ne {}} {
+ set after {next_diff;}
+ } else {
+ set after {}
+ }
}
+
if {$w eq $ui_index} {
update_indexinfo \
"Unstaging [short_path $path] from commit" \
@@ -2639,6 +2666,11 @@ $ctxm add command \
-command {apply_hunk $cursorX $cursorY}
set ui_diff_applyhunk [$ctxm index last]
lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
+$ctxm add command \
+ -label [mc "Apply/Reverse Line"] \
+ -command {apply_line $cursorX $cursorY; do_rescan}
+set ui_diff_applyline [$ctxm index last]
+lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
$ctxm add separator
$ctxm add command \
-label [mc "Show Less Context"] \
@@ -2687,8 +2719,10 @@ proc popup_diff_menu {ctxm x y X Y} {
set ::cursorY $y
if {$::ui_index eq $::current_diff_side} {
set l [mc "Unstage Hunk From Commit"]
+ set t [mc "Unstage Line From Commit"]
} else {
set l [mc "Stage Hunk For Commit"]
+ set t [mc "Stage Line For Commit"]
}
if {$::is_3way_diff
|| $current_diff_path eq {}
@@ -2699,6 +2733,7 @@ proc popup_diff_menu {ctxm x y X Y} {
set s normal
}
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
+ $ctxm entryconf $::ui_diff_applyline -state $s -label $t
tk_popup $ctxm $X $Y
}
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index d04f6dbde2..96ba94906c 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -362,3 +362,90 @@ proc apply_hunk {x y} {
set current_diff_path $current_diff_path
}
}
+
+proc apply_line {x y} {
+ global current_diff_path current_diff_header current_diff_side
+ global ui_diff ui_index file_states
+
+ if {$current_diff_path eq {} || $current_diff_header eq {}} return
+ if {![lock_index apply_hunk]} return
+
+ set apply_cmd {apply --cached --whitespace=nowarn}
+ set mi [lindex $file_states($current_diff_path) 0]
+ if {$current_diff_side eq $ui_index} {
+ set failed_msg [mc "Failed to unstage selected line."]
+ set to_context {+}
+ lappend apply_cmd --reverse
+ if {[string index $mi 0] ne {M}} {
+ unlock_index
+ return
+ }
+ } else {
+ set failed_msg [mc "Failed to stage selected line."]
+ set to_context {-}
+ if {[string index $mi 1] ne {M}} {
+ unlock_index
+ return
+ }
+ }
+
+ set the_l [$ui_diff index @$x,$y]
+
+ # operate only on change lines
+ set c1 [$ui_diff get "$the_l linestart"]
+ if {$c1 ne {+} && $c1 ne {-}} {
+ unlock_index
+ return
+ }
+ set sign $c1
+
+ set i_l [$ui_diff search -backwards -regexp ^@@ $the_l 0.0]
+ if {$i_l eq {}} {
+ unlock_index
+ return
+ }
+ # $i_l is now at the beginning of a line
+
+ # pick start line number from hunk header
+ set hh [$ui_diff get $i_l "$i_l + 1 lines"]
+ set hh [lindex [split $hh ,] 0]
+ set hln [lindex [split $hh -] 1]
+
+ set n 0
+ set i_l [$ui_diff index "$i_l + 1 lines"]
+ set patch {}
+ while {[$ui_diff compare $i_l < "end - 1 chars"] &&
+ [$ui_diff get $i_l "$i_l + 2 chars"] ne {@@}} {
+ set next_l [$ui_diff index "$i_l + 1 lines"]
+ set c1 [$ui_diff get $i_l]
+ if {[$ui_diff compare $i_l <= $the_l] &&
+ [$ui_diff compare $the_l < $next_l]} {
+ # the line to stage/unstage
+ set ln [$ui_diff get $i_l $next_l]
+ set patch "$patch$ln"
+ } elseif {$c1 ne {-} && $c1 ne {+}} {
+ # context line
+ set ln [$ui_diff get $i_l $next_l]
+ set patch "$patch$ln"
+ set n [expr $n+1]
+ } elseif {$c1 eq $to_context} {
+ # turn change line into context line
+ set ln [$ui_diff get "$i_l + 1 chars" $next_l]
+ set patch "$patch $ln"
+ set n [expr $n+1]
+ }
+ set i_l $next_l
+ }
+ set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch"
+
+ if {[catch {
+ set p [eval git_write $apply_cmd]
+ fconfigure $p -translation binary -encoding binary
+ puts -nonewline $p $current_diff_header
+ puts -nonewline $p $patch
+ close $p} err]} {
+ error_popup [append $failed_msg "\n\n$err"]
+ }
+
+ unlock_index
+}
diff --git a/git-send-email.perl b/git-send-email.perl
index 3564419e81..6adb669472 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -773,6 +773,9 @@ X-Mailer: git-send-email $gitversion
$smtp = Net::SMTP::SSL->start_SSL($smtp)
or die "STARTTLS failed! ".$smtp->message;
$smtp_encryption = '';
+ # Send EHLO again to receive fresh
+ # supported commands
+ $smtp->hello();
} else {
die "Server does not support STARTTLS! ".$smtp->message;
}
diff --git a/git-submodule.sh b/git-submodule.sh
index 3eb78cc724..099a7d7560 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -167,8 +167,7 @@ cmd_add()
# perhaps the path exists and is already a git repo, else clone it
if test -e "$path"
then
- if test -d "$path/.git" &&
- test "$(unset GIT_DIR; cd $path; git rev-parse --git-dir)" = ".git"
+ if test -d "$path"/.git -o -f "$path"/.git
then
echo "Adding existing repo at '$path' to the index"
else
diff --git a/git-svn.perl b/git-svn.perl
index f789a6eeca..a366c891dc 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -643,6 +643,8 @@ sub canonicalize_path {
$path =~ s#/[^/]+/\.\.##g;
$path =~ s#/$##g;
$path =~ s#^\./## if $dot_slash_added;
+ $path =~ s#^/##;
+ $path =~ s#^\.$##;
return $path;
}
diff --git a/git.c b/git.c
index 3307c078e5..7075533aa7 100644
--- a/git.c
+++ b/git.c
@@ -9,6 +9,43 @@ const char git_usage_string[] =
const char git_more_info_string[] =
"See 'git help COMMAND' for more information on a specific command.";
+static int use_pager = -1;
+struct pager_config {
+ const char *cmd;
+ int val;
+};
+
+static int pager_command_config(const char *var, const char *value, void *data)
+{
+ struct pager_config *c = data;
+ if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd))
+ c->val = git_config_bool(var, value);
+ return 0;
+}
+
+/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */
+int check_pager_config(const char *cmd)
+{
+ struct pager_config c;
+ c.cmd = cmd;
+ c.val = -1;
+ git_config(pager_command_config, &c);
+ return c.val;
+}
+
+static void commit_pager_choice(void) {
+ switch (use_pager) {
+ case 0:
+ setenv("GIT_PAGER", "cat", 1);
+ break;
+ case 1:
+ setup_pager();
+ break;
+ default:
+ break;
+ }
+}
+
static int handle_options(const char*** argv, int* argc, int* envchanged)
{
int handled = 0;
@@ -38,9 +75,9 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
exit(0);
}
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
- setup_pager();
+ use_pager = 1;
} else if (!strcmp(cmd, "--no-pager")) {
- setenv("GIT_PAGER", "cat", 1);
+ use_pager = 0;
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--git-dir")) {
@@ -242,8 +279,13 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
prefix = NULL;
if (p->option & RUN_SETUP)
prefix = setup_git_directory();
- if (p->option & USE_PAGER)
- setup_pager();
+
+ if (use_pager == -1 && p->option & RUN_SETUP)
+ use_pager = check_pager_config(p->cmd);
+ if (use_pager == -1 && p->option & USE_PAGER)
+ use_pager = 1;
+ commit_pager_choice();
+
if (p->option & NEED_WORK_TREE)
setup_work_tree();
@@ -466,6 +508,7 @@ int main(int argc, const char **argv)
argv++;
argc--;
handle_options(&argv, &argc, NULL);
+ commit_pager_choice();
if (argc > 0) {
if (!prefixcmp(argv[0], "--"))
argv[0] += 2;
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index f7194dbef7..26967e201a 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -144,6 +144,12 @@ Gitweb repositories
Spaces in both project path and project owner have to be encoded as either
'%20' or '+'.
+ Other characters that have to be url-encoded, i.e. replaced by '%'
+ followed by two-digit character number in octal, are: other whitespace
+ characters (because they are field separator in a record), plus sign '+'
+ (because it can be used as replacement for spaces), and percent sign '%'
+ (which is used for encoding / escaping).
+
You can generate the projects list index file using the project_index
action (the 'TXT' link on projects list page) directly from gitweb.
diff --git a/gitweb/README b/gitweb/README
index 356ab7b327..6908036402 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -156,10 +156,11 @@ not include variables usually directly set during build):
set correctly for gitweb to find repositories.
* $projects_list
Source of projects list, either directory to scan, or text file
- with list of repositories (in the "<URI-encoded repository path> SPC
- <URI-encoded repository owner>" format). Set to $GITWEB_LIST
- during installation. If empty, $projectroot is used to scan for
- repositories.
+ with list of repositories (in the "<URI-encoded repository path> SP
+ <URI-encoded repository owner>" line format; actually there can be
+ any sequence of whitespace in place of space (SP)). Set to
+ $GITWEB_LIST during installation. If empty, $projectroot is used
+ to scan for repositories.
* $my_url, $my_uri
URL and absolute URL of gitweb script; you might need to set those
variables if you are using 'pathinfo' feature: see also below.
@@ -214,6 +215,39 @@ not include variables usually directly set during build):
('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or
set it to () if you don't want to have renames detection.
+
+Projects list file format
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Instead of having gitweb find repositories by scanning filesystem starting
+from $projectroot (or $projects_list, if it points to directory), you can
+provide list of projects by setting $projects_list to a text file with list
+of projects (and some additional info). This file uses the following
+format:
+
+One record (for project / repository) per line, whitespace separated fields;
+does not support (at least for now) lines continuation (newline escaping).
+Leading and trailing whitespace are ignored, any run of whitespace can be
+used as field separator (rules for Perl's "split(' ', $line)"). Keyed by
+the first field, which is project name, i.e. path to repository GIT_DIR
+relative to $projectroot. Fields use modified URI encoding, defined in
+RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding"
+(see http://en.wikipedia.org/wiki/Query_string#URL_encoding), the difference
+being that SP (' ') can be encoded as '+' (and therefore '+' has to be also
+percent-encoded). Reserved characters are: '%' (used for encoding), '+'
+(can be used to encode SPACE), all whitespace characters as defined in Perl,
+including SP, TAB and LF, (used to separate fields in a record).
+
+Currently list of fields is
+ * <repository path> - path to repository GIT_DIR, relative to $projectroot
+ * <repository owner> - displayed as repository owner, preferably full name,
+ or email, or both
+
+You can additionally use $projects_list file to limit which repositories
+are visible, and together with $strict_export to limit access to
+repositories (see "Gitweb repositories" section in gitweb/INSTALL).
+
+
Per-repository gitweb configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -225,8 +259,8 @@ You can use the following files in repository:
* README.html
A .html file (HTML fragment) which is included on the gitweb project
summary page inside <div> block element. You can use it for longer
- description of a project, to provide links for example to projects
- homepage, etc.
+ description of a project, to provide links (for example to project's
+ homepage), etc.
* description (or gitweb.description)
Short (shortened by default to 25 characters in the projects list page)
single line description of a project (of a repository). Plain text file;
diff --git a/path.c b/path.c
index 496123ca55..598325598b 100644
--- a/path.c
+++ b/path.c
@@ -343,3 +343,99 @@ const char *make_relative_path(const char *abs, const char *base)
strcpy(buf, abs + baselen);
return buf;
}
+
+/*
+ * path = absolute path
+ * buf = buffer of at least max(2, strlen(path)+1) bytes
+ * It is okay if buf == path, but they should not overlap otherwise.
+ *
+ * Performs the following normalizations on path, storing the result in buf:
+ * - Removes trailing slashes.
+ * - Removes empty components.
+ * - Removes "." components.
+ * - Removes ".." components, and the components the precede them.
+ * "" and paths that contain only slashes are normalized to "/".
+ * Returns the length of the output.
+ *
+ * Note that this function is purely textual. It does not follow symlinks,
+ * verify the existence of the path, or make any system calls.
+ */
+int normalize_absolute_path(char *buf, const char *path)
+{
+ const char *comp_start = path, *comp_end = path;
+ char *dst = buf;
+ int comp_len;
+ assert(buf);
+ assert(path);
+
+ while (*comp_start) {
+ assert(*comp_start == '/');
+ while (*++comp_end && *comp_end != '/')
+ ; /* nothing */
+ comp_len = comp_end - comp_start;
+
+ if (!strncmp("/", comp_start, comp_len) ||
+ !strncmp("/.", comp_start, comp_len))
+ goto next;
+
+ if (!strncmp("/..", comp_start, comp_len)) {
+ while (dst > buf && *--dst != '/')
+ ; /* nothing */
+ goto next;
+ }
+
+ memcpy(dst, comp_start, comp_len);
+ dst += comp_len;
+ next:
+ comp_start = comp_end;
+ }
+
+ if (dst == buf)
+ *dst++ = '/';
+
+ *dst = '\0';
+ return dst - buf;
+}
+
+/*
+ * path = Canonical absolute path
+ * prefix_list = Colon-separated list of absolute paths
+ *
+ * Determines, for each path in parent_list, whether the "prefix" really
+ * is an ancestor directory of path. Returns the length of the longest
+ * ancestor directory, excluding any trailing slashes, or -1 if no prefix
+ * is an ancestor. (Note that this means 0 is returned if prefix_list is
+ * "/".) "/foo" is not considered an ancestor of "/foobar". Directories
+ * are not considered to be their own ancestors. path must be in a
+ * canonical form: empty components, or "." or ".." components are not
+ * allowed. prefix_list may be null, which is like "".
+ */
+int longest_ancestor_length(const char *path, const char *prefix_list)
+{
+ char buf[PATH_MAX+1];
+ const char *ceil, *colon;
+ int len, max_len = -1;
+
+ if (prefix_list == NULL || !strcmp(path, "/"))
+ return -1;
+
+ for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
+ for (colon = ceil; *colon && *colon != ':'; colon++);
+ len = colon - ceil;
+ if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
+ continue;
+ strlcpy(buf, ceil, len+1);
+ len = normalize_absolute_path(buf, buf);
+ /* Strip "trailing slashes" from "/". */
+ if (len == 1)
+ len = 0;
+
+ if (!strncmp(path, buf, len) &&
+ path[len] == '/' &&
+ len > max_len) {
+ max_len = len;
+ }
+ }
+
+ return max_len;
+}
diff --git a/perl/Git.pm b/perl/Git.pm
index 97e61efaff..d99e778200 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -56,7 +56,8 @@ require Exporter;
@EXPORT_OK = qw(command command_oneline command_noisy
command_output_pipe command_input_pipe command_close_pipe
command_bidi_pipe command_close_bidi_pipe
- version exec_path hash_object git_cmd_try);
+ version exec_path hash_object git_cmd_try
+ remote_refs);
=head1 DESCRIPTION
@@ -668,6 +669,59 @@ sub get_color {
return $color;
}
+=item remote_refs ( REPOSITORY [, GROUPS [, REFGLOBS ] ] )
+
+This function returns a hashref of refs stored in a given remote repository.
+The hash is in the format C<refname =\> hash>. For tags, the C<refname> entry
+contains the tag object while a C<refname^{}> entry gives the tagged objects.
+
+C<REPOSITORY> has the same meaning as the appropriate C<git-ls-remote>
+argument; either an URL or a remote name (if called on a repository instance).
+C<GROUPS> is an optional arrayref that can contain 'tags' to return all the
+tags and/or 'heads' to return all the heads. C<REFGLOB> is an optional array
+of strings containing a shell-like glob to further limit the refs returned in
+the hash; the meaning is again the same as the appropriate C<git-ls-remote>
+argument.
+
+This function may or may not be called on a repository instance. In the former
+case, remote names as defined in the repository are recognized as repository
+specifiers.
+
+=cut
+
+sub remote_refs {
+ my ($self, $repo, $groups, $refglobs) = _maybe_self(@_);
+ my @args;
+ if (ref $groups eq 'ARRAY') {
+ foreach (@$groups) {
+ if ($_ eq 'heads') {
+ push (@args, '--heads');
+ } elsif ($_ eq 'tags') {
+ push (@args, '--tags');
+ } else {
+ # Ignore unknown groups for future
+ # compatibility
+ }
+ }
+ }
+ push (@args, $repo);
+ if (ref $refglobs eq 'ARRAY') {
+ push (@args, @$refglobs);
+ }
+
+ my @self = $self ? ($self) : (); # Ultra trickery
+ my ($fh, $ctx) = Git::command_output_pipe(@self, 'ls-remote', @args);
+ my %refs;
+ while (<$fh>) {
+ chomp;
+ my ($hash, $ref) = split(/\t/, $_, 2);
+ $refs{$ref} = $hash;
+ }
+ Git::command_close_pipe(@self, $fh, $ctx);
+ return \%refs;
+}
+
+
=item ident ( TYPE | IDENTSTR )
=item ident_person ( TYPE | IDENTSTR | IDENTARRAY )
diff --git a/refs.c b/refs.c
index 9e8e8581ba..39a3b23804 100644
--- a/refs.c
+++ b/refs.c
@@ -925,7 +925,7 @@ int delete_ref(const char *refname, const unsigned char *sha1)
i = strlen(lock->lk->filename) - 5; /* .lock */
lock->lk->filename[i] = 0;
err = unlink(lock->lk->filename);
- if (err) {
+ if (err && errno != ENOENT) {
ret = 1;
error("unlink(%s) failed: %s",
lock->lk->filename, strerror(errno));
@@ -1412,6 +1412,10 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
tz = strtoul(tz_c, NULL, 10);
if (get_sha1_hex(logdata, sha1))
die("Log %s is corrupt.", logfile);
+ if (is_null_sha1(sha1)) {
+ if (get_sha1_hex(logdata + 41, sha1))
+ die("Log %s is corrupt.", logfile);
+ }
if (msg)
*msg = ref_msg(logdata, logend);
munmap(log_mapped, mapsz);
diff --git a/run-command.c b/run-command.c
index 2ce8c2b2f0..6e29fdf9e2 100644
--- a/run-command.c
+++ b/run-command.c
@@ -65,6 +65,8 @@ int start_command(struct child_process *cmd)
cmd->err = fderr[0];
}
+ trace_argv_printf(cmd->argv, "trace: run_command:");
+
#ifndef __MINGW32__
cmd->pid = fork();
if (!cmd->pid) {
diff --git a/setup.c b/setup.c
index cc3fb380c1..6cf909463d 100644
--- a/setup.c
+++ b/setup.c
@@ -376,11 +376,11 @@ const char *read_gitfile_gently(const char *path)
const char *setup_git_directory_gently(int *nongit_ok)
{
const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);
+ const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
static char cwd[PATH_MAX+1];
const char *gitdirenv;
const char *gitfile_dir;
- int len, offset;
- int minoffset = 0;
+ int len, offset, ceil_offset;
/*
* Let's assume that we are in a git repository.
@@ -431,8 +431,10 @@ const char *setup_git_directory_gently(int *nongit_ok)
if (!getcwd(cwd, sizeof(cwd)-1))
die("Unable to read current working directory");
- if (has_dos_drive_prefix(cwd))
- minoffset = 2;
+
+ ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
+ if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
+ ceil_offset = 1;
/*
* Test in the following order (relative to the cwd):
@@ -463,18 +465,17 @@ const char *setup_git_directory_gently(int *nongit_ok)
check_repository_format_gently(nongit_ok);
return NULL;
}
- chdir("..");
- do {
- if (offset <= minoffset) {
- if (nongit_ok) {
- if (chdir(cwd))
- die("Cannot come back to cwd");
- *nongit_ok = 1;
- return NULL;
- }
- die("Not a git repository");
+ while (--offset > ceil_offset && cwd[offset] != '/');
+ if (offset <= ceil_offset) {
+ if (nongit_ok) {
+ if (chdir(cwd))
+ die("Cannot come back to cwd");
+ *nongit_ok = 1;
+ return NULL;
}
- } while (offset > minoffset && cwd[--offset] != '/');
+ die("Not a git repository");
+ }
+ chdir("..");
}
inside_git_dir = 0;
diff --git a/sha1_file.c b/sha1_file.c
index 1670e913af..2df78b5afd 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1630,6 +1630,7 @@ static void *unpack_delta_entry(struct packed_git *p,
(uintmax_t)curpos, p->pack_name);
return NULL;
}
+ unuse_pack(w_curs);
base = cache_or_unpack_entry(p, base_offset, &base_size, type, 0);
if (!base) {
/*
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index a5c4436fd1..dc473dfb53 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -45,22 +45,22 @@ else
error "Could not identify web server at '$LIB_HTTPD_PATH'"
fi
-HTTPD_PARA="-d $HTTPD_ROOT_PATH -f $TEST_PATH/apache.conf"
+HTTPD_PARA=""
prepare_httpd() {
- mkdir -p $HTTPD_DOCUMENT_ROOT_PATH
+ mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
- ln -s $LIB_HTTPD_MODULE_PATH $HTTPD_ROOT_PATH/modules
+ ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
if test -n "$LIB_HTTPD_SSL"
then
HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
- -config $TEST_PATH/ssl.cnf \
+ -config "$TEST_PATH/ssl.cnf" \
-new -x509 -nodes \
- -out $HTTPD_ROOT_PATH/httpd.pem \
- -keyout $HTTPD_ROOT_PATH/httpd.pem
+ -out "$HTTPD_ROOT_PATH/httpd.pem" \
+ -keyout "$HTTPD_ROOT_PATH/httpd.pem"
GIT_SSL_NO_VERIFY=t
export GIT_SSL_NO_VERIFY
HTTPD_PARA="$HTTPD_PARA -DSSL"
@@ -86,12 +86,14 @@ start_httpd() {
trap 'stop_httpd; die' exit
- "$LIB_HTTPD_PATH" $HTTPD_PARA \
+ "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
+ -f "$TEST_PATH/apache.conf" $HTTPD_PARA \
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
}
stop_httpd() {
trap 'die' exit
- "$LIB_HTTPD_PATH" $HTTPD_PARA -k stop
+ "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
+ -f "$TEST_PATH/apache.conf" -k stop
}
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index a4473462d1..4717c2d33b 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -1,3 +1,4 @@
+ServerName dummy
PidFile httpd.pid
DocumentRoot www
ErrorLog error.log
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 690f80ab27..d7cbc5c6da 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -301,14 +301,14 @@ test_expect_success 'absolute path works as expected' '
mkdir third &&
dir="$(cd .git; pwd -P)" &&
dir2=third/../second/other/.git &&
- test "$dir" = "$(test-absolute-path $dir2)" &&
+ test "$dir" = "$(test-path-utils make_absolute_path $dir2)" &&
file="$dir"/index &&
- test "$file" = "$(test-absolute-path $dir2/index)" &&
+ test "$file" = "$(test-path-utils make_absolute_path $dir2/index)" &&
basename=blub &&
- test "$dir/$basename" = "$(cd .git && test-absolute-path "$basename")" &&
+ test "$dir/$basename" = "$(cd .git && test-path-utils make_absolute_path "$basename")" &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
- test "$sym" = "$(test-absolute-path "$dir2/syml")"
+ test "$sym" = "$(test-path-utils make_absolute_path "$dir2/syml")"
'
test_expect_success 'very long name in the index handled sanely' '
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
new file mode 100755
index 0000000000..6e7501f352
--- /dev/null
+++ b/t/t0060-path-utils.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 David Reiss
+#
+
+test_description='Test various path utilities'
+
+. ./test-lib.sh
+
+norm_abs() {
+ test_expect_success "normalize absolute" \
+ "test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
+}
+
+ancestor() {
+ test_expect_success "longest ancestor" \
+ "test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
+}
+
+norm_abs "" /
+norm_abs / /
+norm_abs // /
+norm_abs /// /
+norm_abs /. /
+norm_abs /./ /
+norm_abs /./.. /
+norm_abs /../. /
+norm_abs /./../.// /
+norm_abs /dir/.. /
+norm_abs /dir/sub/../.. /
+norm_abs /dir /dir
+norm_abs /dir// /dir
+norm_abs /./dir /dir
+norm_abs /dir/. /dir
+norm_abs /dir///./ /dir
+norm_abs /dir//sub/.. /dir
+norm_abs /dir/sub/../ /dir
+norm_abs //dir/sub/../. /dir
+norm_abs /dir/s1/../s2/ /dir/s2
+norm_abs /d1/s1///s2/..//../s3/ /d1/s3
+norm_abs /d1/s1//../s2/../../d2 /d2
+norm_abs /d1/.../d2 /d1/.../d2
+norm_abs /d1/..././../d2 /d1/d2
+
+ancestor / "" -1
+ancestor / / -1
+ancestor /foo "" -1
+ancestor /foo : -1
+ancestor /foo ::. -1
+ancestor /foo ::..:: -1
+ancestor /foo / 0
+ancestor /foo /fo -1
+ancestor /foo /foo -1
+ancestor /foo /foo/ -1
+ancestor /foo /bar -1
+ancestor /foo /bar/ -1
+ancestor /foo /foo/bar -1
+ancestor /foo /foo:/bar/ -1
+ancestor /foo /foo/:/bar/ -1
+ancestor /foo /foo::/bar/ -1
+ancestor /foo /:/foo:/bar/ 0
+ancestor /foo /foo:/:/bar/ 0
+ancestor /foo /:/bar/:/foo 0
+ancestor /foo/bar "" -1
+ancestor /foo/bar / 0
+ancestor /foo/bar /fo -1
+ancestor /foo/bar foo -1
+ancestor /foo/bar /foo 4
+ancestor /foo/bar /foo/ 4
+ancestor /foo/bar /foo/ba -1
+ancestor /foo/bar /:/fo 0
+ancestor /foo/bar /foo:/foo/ba 4
+ancestor /foo/bar /bar -1
+ancestor /foo/bar /bar/ -1
+ancestor /foo/bar /fo: -1
+ancestor /foo/bar :/fo -1
+ancestor /foo/bar /foo:/bar/ 4
+ancestor /foo/bar /:/foo:/bar/ 4
+ancestor /foo/bar /foo:/:/bar/ 4
+ancestor /foo/bar /:/bar/:/fo 0
+ancestor /foo/bar /:/bar/ 0
+ancestor /foo/bar :://foo/. 4
+ancestor /foo/bar :://foo/.:: 4
+ancestor /foo/bar //foo/./::/bar 4
+ancestor /foo/bar ::/bar -1
+
+test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index f387d46f1a..ca99d37616 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -155,7 +155,8 @@ rm -f .git/$m .git/logs/$m expect
git update-ref $m $D
cat >.git/logs/$m <<EOF
-$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
+0000000000000000000000000000000000000000 $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
+$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
@@ -186,6 +187,12 @@ test_expect_success \
'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
'rm -f o e
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
+ test '"$C"' = $(cat o) &&
+ test "" = "$(cat e)"'
+test_expect_success \
+ 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
+ 'rm -f o e
+ git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
test '"$A"' = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh
new file mode 100755
index 0000000000..91b704a3a4
--- /dev/null
+++ b/t/t1504-ceiling-dirs.sh
@@ -0,0 +1,163 @@
+#!/bin/sh
+
+test_description='test GIT_CEILING_DIRECTORIES'
+. ./test-lib.sh
+
+test_prefix() {
+ test_expect_success "$1" \
+ "test '$2' = \"\$(git rev-parse --show-prefix)\""
+}
+
+test_fail() {
+ test_expect_code 128 "$1: prefix" \
+ "git rev-parse --show-prefix"
+}
+
+TRASH_ROOT="$(pwd)"
+ROOT_PARENT=$(dirname "$TRASH_ROOT")
+
+
+unset GIT_CEILING_DIRECTORIES
+test_prefix no_ceil ""
+
+export GIT_CEILING_DIRECTORIES
+
+GIT_CEILING_DIRECTORIES=""
+test_prefix ceil_empty ""
+
+GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
+test_prefix ceil_at_parent ""
+
+GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
+test_prefix ceil_at_parent_slash ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
+test_prefix ceil_at_trash ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
+test_prefix ceil_at_trash_slash ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
+test_prefix ceil_at_sub ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
+test_prefix ceil_at_sub_slash ""
+
+
+mkdir -p sub/dir || exit 1
+cd sub/dir || exit 1
+
+unset GIT_CEILING_DIRECTORIES
+test_prefix subdir_no_ceil "sub/dir/"
+
+export GIT_CEILING_DIRECTORIES
+
+GIT_CEILING_DIRECTORIES=""
+test_prefix subdir_ceil_empty "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
+test_fail subdir_ceil_at_trash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
+test_fail subdir_ceil_at_trash_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
+test_fail subdir_ceil_at_sub
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
+test_fail subdir_ceil_at_sub_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
+test_prefix subdir_ceil_at_subdir "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
+test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
+
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
+test_prefix subdir_ceil_at_su "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
+test_prefix subdir_ceil_at_su_slash "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
+test_prefix subdir_ceil_at_sub_di "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
+test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
+test_prefix subdir_ceil_at_subdi "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
+test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
+
+
+GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+test_fail second_of_two
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
+test_fail first_of_two
+
+GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+test_fail second_of_three
+
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
+GIT_DIR=../../.git
+export GIT_DIR
+test_prefix git_dir_specified ""
+unset GIT_DIR
+
+
+cd ../.. || exit 1
+mkdir -p s/d || exit 1
+cd s/d || exit 1
+
+unset GIT_CEILING_DIRECTORIES
+test_prefix sd_no_ceil "s/d/"
+
+export GIT_CEILING_DIRECTORIES
+
+GIT_CEILING_DIRECTORIES=""
+test_prefix sd_ceil_empty "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
+test_fail sd_ceil_at_trash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
+test_fail sd_ceil_at_trash_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
+test_fail sd_ceil_at_s
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
+test_fail sd_ceil_at_s_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
+test_prefix sd_ceil_at_sd "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
+test_prefix sd_ceil_at_sd_slash "s/d/"
+
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
+test_prefix sd_ceil_at_su "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
+test_prefix sd_ceil_at_su_slash "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
+test_prefix sd_ceil_at_s_di "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
+test_prefix sd_ceil_at_s_di_slash "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
+test_prefix sd_ceil_at_sdi "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
+test_prefix sd_ceil_at_sdi_slash "s/d/"
+
+
+test_done
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index fae64eae9f..e95663d8e6 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -66,6 +66,73 @@ test_expect_success 'revert works (commit)' '
grep "unchanged *+3/-0 file" output
'
+cat >expected <<EOF
+EOF
+cat >fake_editor.sh <<EOF
+EOF
+chmod a+x fake_editor.sh
+test_set_editor "$(pwd)/fake_editor.sh"
+test_expect_success 'dummy edit works' '
+ (echo e; echo a) | git add -p &&
+ git diff > diff &&
+ test_cmp expected diff
+'
+
+cat >patch <<EOF
+@@ -1,1 +1,4 @@
+ this
++patch
+-doesn't
+ apply
+EOF
+echo "#!$SHELL_PATH" >fake_editor.sh
+cat >>fake_editor.sh <<\EOF
+mv -f "$1" oldpatch &&
+mv -f patch "$1"
+EOF
+chmod a+x fake_editor.sh
+test_set_editor "$(pwd)/fake_editor.sh"
+test_expect_success 'bad edit rejected' '
+ git reset &&
+ (echo e; echo n; echo d) | git add -p >output &&
+ grep "hunk does not apply" output
+'
+
+cat >patch <<EOF
+this patch
+is garbage
+EOF
+test_expect_success 'garbage edit rejected' '
+ git reset &&
+ (echo e; echo n; echo d) | git add -p >output &&
+ grep "hunk does not apply" output
+'
+
+cat >patch <<EOF
+@@ -1,0 +1,0 @@
+ baseline
++content
++newcontent
++lines
+EOF
+cat >expected <<EOF
+diff --git a/file b/file
+index b5dd6c9..f910ae9 100644
+--- a/file
++++ b/file
+@@ -1,4 +1,4 @@
+ baseline
+ content
+-newcontent
++more
+ lines
+EOF
+test_expect_success 'real edit works' '
+ (echo e; echo n; echo d) | git add -p &&
+ git diff >output &&
+ test_cmp expected output
+'
+
if test "$(git config --bool core.filemode)" = false
then
say 'skipping filemode tests (filesystem does not properly support modes)'
diff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh
index 70a1859503..f9ad183758 100755
--- a/t/t4112-apply-renames.sh
+++ b/t/t4112-apply-renames.sh
@@ -36,6 +36,9 @@ typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */
EOF
+cat >klibc/README <<\EOF
+This is a simple readme file.
+EOF
cat >patch <<\EOF
diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/cris/klibc/archsetjmp.h
@@ -113,6 +116,23 @@ rename to include/arch/m32r/klibc/archsetjmp.h
-#endif /* _SETJMP_H */
+#endif /* _KLIBC_ARCHSETJMP_H */
+diff --git a/klibc/README b/klibc/README
+--- a/klibc/README
++++ b/klibc/README
+@@ -1,1 +1,4 @@
+ This is a simple readme file.
++And we add a few
++lines at the
++end of it.
+diff --git a/klibc/README b/klibc/arch/README
+copy from klibc/README
+copy to klibc/arch/README
+--- a/klibc/README
++++ b/klibc/arch/README
+@@ -1,1 +1,3 @@
+ This is a simple readme file.
++And we copy it to one level down, and
++add a few lines at the end of it.
EOF
find klibc -type f -print | xargs git update-index --add --
diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh
new file mode 100755
index 0000000000..2dd0c75f96
--- /dev/null
+++ b/t/t4128-apply-root.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='apply same filename'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ mkdir -p some/sub/dir &&
+ echo Hello > some/sub/dir/file &&
+ git add some/sub/dir/file &&
+ git commit -m initial &&
+ git tag initial
+
+'
+
+cat > patch << EOF
+diff a/bla/blub/dir/file b/bla/blub/dir/file
+--- a/bla/blub/dir/file
++++ b/bla/blub/dir/file
+@@ -1,1 +1,1 @@
+-Hello
++Bello
+EOF
+
+test_expect_success 'apply --directory -p (1)' '
+
+ git apply --directory=some/sub -p3 --index patch &&
+ test Bello = $(git show :some/sub/dir/file) &&
+ test Bello = $(cat some/sub/dir/file)
+
+'
+
+test_expect_success 'apply --directory -p (2) ' '
+
+ git reset --hard initial &&
+ git apply --directory=some/sub/ -p3 --index patch &&
+ test Bello = $(git show :some/sub/dir/file) &&
+ test Bello = $(cat some/sub/dir/file)
+
+'
+
+test_done
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 85d7e3edcd..a64727d5ad 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -193,9 +193,19 @@ test_expect_success 'resolution was recorded properly' '
echo Bello > file3 &&
git add file3 &&
git commit -m version2 &&
- ! git merge fifth &&
- git diff-files -q &&
- test Cello = "$(cat file3)"
+ git tag version2 &&
+ test_must_fail git merge fifth &&
+ test Cello = "$(cat file3)" &&
+ test 0 != $(git ls-files -u | wc -l)
+'
+
+test_expect_success 'rerere.autoupdate' '
+ git config rerere.autoupdate true
+ git reset --hard &&
+ git checkout version2 &&
+ test_must_fail git merge fifth &&
+ test 0 = $(git ls-files -u | wc -l)
+
'
test_done
diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh
index 1493a92c06..64fe2615ac 100755
--- a/t/t5404-tracking-branches.sh
+++ b/t/t5404-tracking-branches.sh
@@ -10,6 +10,7 @@ test_expect_success 'setup' '
git commit -m 1 &&
git branch b1 &&
git branch b2 &&
+ git branch b3 &&
git clone . aa &&
git checkout b1 &&
echo b1 >>file &&
@@ -50,4 +51,10 @@ test_expect_success 'deleted branches have their tracking branches removed' '
test "$(git rev-parse origin/b1)" = "origin/b1"
'
+test_expect_success 'already deleted tracking branches ignored' '
+ git branch -d -r origin/b3 &&
+ git push origin :b3 >output 2>&1 &&
+ ! grep error output
+'
+
test_done
diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh
index f15dd03e4d..21dbb557b7 100755
--- a/t/t5540-http-push.sh
+++ b/t/t5540-http-push.sh
@@ -12,6 +12,13 @@ This test runs various sanity checks on http-push.'
ROOT_PATH="$PWD"
LIB_HTTPD_DAV=t
+if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
+then
+ say "skipping test, USE_CURL_MULTI is not defined"
+ test_done
+ exit
+fi
+
. ../lib-httpd.sh
if ! start_httpd >&3 2>&4
@@ -36,7 +43,7 @@ test_expect_success 'setup remote repository' '
git --bare update-server-info &&
chmod +x hooks/post-update &&
cd - &&
- mv test_repo.git $HTTPD_DOCUMENT_ROOT_PATH
+ mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
'
test_expect_success 'clone remote repository' '
@@ -44,16 +51,17 @@ test_expect_success 'clone remote repository' '
git clone $HTTPD_URL/test_repo.git test_repo_clone
'
-test_expect_success 'push to remote repository' '
+test_expect_failure 'push to remote repository' '
cd "$ROOT_PATH"/test_repo_clone &&
: >path2 &&
git add path2 &&
test_tick &&
git commit -m path2 &&
- git push
+ git push &&
+ [ -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/refs/heads/master" ]
'
-test_expect_success 'create and delete remote branch' '
+test_expect_failure 'create and delete remote branch' '
cd "$ROOT_PATH"/test_repo_clone &&
git checkout -b dev &&
: >path3 &&
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index b642fb260b..d785b3df78 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -17,14 +17,32 @@ test_expect_success setup '
'
-test_expect_success 'clone with excess parameters' '
+test_expect_success 'clone with excess parameters (1)' '
+ rm -fr dst &&
+ test_must_fail git clone -n src dst junk
+
+'
+
+test_expect_success 'clone with excess parameters (2)' '
+
+ rm -fr dst &&
test_must_fail git clone -n "file://$(pwd)/src" dst junk
'
+test_expect_success 'clone does not keep pack' '
+
+ rm -fr dst &&
+ git clone -n "file://$(pwd)/src" dst &&
+ ! test -f dst/file &&
+ ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
+
+'
+
test_expect_success 'clone checks out files' '
+ rm -fr dst &&
git clone src dst &&
test -f dst/file
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index 6a5211f187..31c340fd38 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -4,6 +4,10 @@ test_description='git-repack works correctly'
. ./test-lib.sh
+fsha1=
+csha1=
+tsha1=
+
test_expect_success '-A option leaves unreachable objects unpacked' '
echo content > file1 &&
git add . &&
@@ -44,4 +48,34 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
git show $tsha1
'
+compare_mtimes ()
+{
+ perl -e 'my $reference = shift;
+ foreach my $file (@ARGV) {
+ exit(1) unless(-f $file && -M $file == -M $reference);
+ }
+ exit(0);
+ ' -- "$@"
+}
+
+test_expect_success 'unpacked objects receive timestamp of pack file' '
+ fsha1path=$(echo "$fsha1" | sed -e "s|\(..\)|\1/|") &&
+ fsha1path=".git/objects/$fsha1path" &&
+ csha1path=$(echo "$csha1" | sed -e "s|\(..\)|\1/|") &&
+ csha1path=".git/objects/$csha1path" &&
+ tsha1path=$(echo "$tsha1" | sed -e "s|\(..\)|\1/|") &&
+ tsha1path=".git/objects/$tsha1path" &&
+ git branch transient_branch $csha1 &&
+ git repack -a -d -l &&
+ test ! -f "$fsha1path" &&
+ test ! -f "$csha1path" &&
+ test ! -f "$tsha1path" &&
+ test 1 = $(ls -1 .git/objects/pack/pack-*.pack | wc -l) &&
+ packfile=$(ls .git/objects/pack/pack-*.pack) &&
+ git branch -D transient_branch &&
+ sleep 1 &&
+ git repack -A -l &&
+ compare_mtimes "$packfile" "$fsha1path" "$csha1path" "$tsha1path"
+'
+
test_done
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 242cdf092a..3bc6164125 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -4,9 +4,9 @@
#
test_description='git-svn basic tests'
-GIT_SVN_LC_ALL=$LC_ALL
+GIT_SVN_LC_ALL=${LC_ALL:-$LANG}
-case "$LC_ALL" in
+case "$GIT_SVN_LC_ALL" in
*.UTF-8)
have_utf8=t
;;
@@ -17,7 +17,7 @@ esac
. ./lib-git-svn.sh
-echo 'define NO_SVN_TESTS to skip git-svn tests'
+say 'define NO_SVN_TESTS to skip git-svn tests'
test_expect_success \
'initialize git-svn' '
@@ -183,7 +183,7 @@ then
git-svn set-tree HEAD"
unset LC_ALL
else
- echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
+ say "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
fi
name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
diff --git a/t/t9113-git-svn-dcommit-new-file.sh b/t/t9113-git-svn-dcommit-new-file.sh
index 31c929b573..8da8ce58eb 100755
--- a/t/t9113-git-svn-dcommit-new-file.sh
+++ b/t/t9113-git-svn-dcommit-new-file.sh
@@ -7,12 +7,18 @@
# I don't like the idea of taking a port and possibly leaving a
# daemon running on a users system if the test fails.
# Not all git users will need to interact with SVN.
-test -z "$SVNSERVE_PORT" && exit 0
test_description='git-svn dcommit new files over svn:// test'
. ./lib-git-svn.sh
+if test -z "$SVNSERVE_PORT"
+then
+ say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
+ test_done
+ exit
+fi
+
start_svnserve () {
svnserve --listen-port $SVNSERVE_PORT \
--root "$rawsvnrepo" \
diff --git a/t/test-lib.sh b/t/test-lib.sh
index c0c5e0e83b..8e2849b5ce 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -35,6 +35,7 @@ unset GIT_WORK_TREE
unset GIT_EXTERNAL_DIFF
unset GIT_INDEX_FILE
unset GIT_OBJECT_DIRECTORY
+unset GIT_CEILING_DIRECTORIES
unset SHA1_FILE_DIRECTORIES
unset SHA1_FILE_DIRECTORY
GIT_MERGE_VERBOSITY=5
diff --git a/test-absolute-path.c b/test-absolute-path.c
deleted file mode 100644
index c959ea20d3..0000000000
--- a/test-absolute-path.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "cache.h"
-
-int main(int argc, char **argv)
-{
- while (argc > 1) {
- puts(make_absolute_path(argv[1]));
- argc--;
- argv++;
- }
- return 0;
-}
diff --git a/test-path-utils.c b/test-path-utils.c
new file mode 100644
index 0000000000..a0bcb0e210
--- /dev/null
+++ b/test-path-utils.c
@@ -0,0 +1,26 @@
+#include "cache.h"
+
+int main(int argc, char **argv)
+{
+ if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
+ char *buf = xmalloc(strlen(argv[2])+1);
+ int rv = normalize_absolute_path(buf, argv[2]);
+ assert(strlen(buf) == rv);
+ puts(buf);
+ }
+
+ if (argc >= 2 && !strcmp(argv[1], "make_absolute_path")) {
+ while (argc > 2) {
+ puts(make_absolute_path(argv[2]));
+ argc--;
+ argv++;
+ }
+ }
+
+ if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
+ int len = longest_ancestor_length(argv[2], argv[3]);
+ printf("%d\n", len);
+ }
+
+ return 0;
+}