Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/Makefile5
-rw-r--r--Documentation/RelNotes-1.5.6.txt59
-rw-r--r--Documentation/config.txt111
-rw-r--r--Documentation/cvs-migration.txt2
-rw-r--r--Documentation/git-add.txt24
-rw-r--r--Documentation/git-bisect.txt58
-rw-r--r--Documentation/git-branch.txt25
-rw-r--r--Documentation/git-checkout.txt2
-rw-r--r--Documentation/git-cherry-pick.txt5
-rw-r--r--Documentation/git-commit.txt4
-rw-r--r--Documentation/git-config.txt2
-rw-r--r--Documentation/git-filter-branch.txt14
-rw-r--r--Documentation/git-fmt-merge-msg.txt18
-rw-r--r--Documentation/git-format-patch.txt74
-rw-r--r--Documentation/git-fsck.txt3
-rw-r--r--Documentation/git-help.txt57
-rw-r--r--Documentation/git-init.txt8
-rw-r--r--Documentation/git-merge.txt15
-rw-r--r--Documentation/git-prune.txt20
-rw-r--r--Documentation/git-pull.txt86
-rw-r--r--Documentation/git-push.txt4
-rw-r--r--Documentation/git-remote.txt6
-rw-r--r--Documentation/git-rev-parse.txt7
-rw-r--r--Documentation/git-revert.txt5
-rw-r--r--Documentation/git-status.txt5
-rw-r--r--Documentation/git-svn.txt21
-rw-r--r--Documentation/git-unpack-objects.txt5
-rw-r--r--Documentation/git-web--browse.txt24
-rw-r--r--Documentation/git.txt12
-rw-r--r--Documentation/gitcli.txt2
-rw-r--r--Documentation/githooks.txt (renamed from Documentation/hooks.txt)39
-rw-r--r--Documentation/gitk.txt6
-rw-r--r--Documentation/merge-config.txt40
-rw-r--r--Documentation/merge-options.txt19
-rw-r--r--Documentation/pretty-formats.txt1
-rw-r--r--Documentation/repository-layout.txt7
-rw-r--r--Documentation/user-manual.txt2
-rwxr-xr-xGIT-VERSION-GEN2
-rw-r--r--INSTALL4
-rw-r--r--Makefile5
l---------RelNotes2
-rw-r--r--branch.c22
-rw-r--r--builtin-apply.c10
-rw-r--r--builtin-branch.c16
-rw-r--r--builtin-checkout.c2
-rw-r--r--builtin-commit.c125
-rw-r--r--builtin-config.c28
-rw-r--r--builtin-fetch.c10
-rw-r--r--builtin-fmt-merge-msg.c14
-rw-r--r--builtin-gc.c31
-rw-r--r--builtin-init-db.c11
-rw-r--r--builtin-log.c16
-rw-r--r--builtin-merge-recursive.c14
-rw-r--r--builtin-push.c24
-rw-r--r--builtin-read-tree.c2
-rw-r--r--builtin-remote.c14
-rw-r--r--builtin-rev-parse.c56
-rw-r--r--builtin-revert.c20
-rw-r--r--builtin-unpack-objects.c177
-rw-r--r--cache.h73
-rw-r--r--combine-diff.c23
-rw-r--r--commit.h3
-rw-r--r--compat/fopen.c13
-rw-r--r--config.c73
-rwxr-xr-xcontrib/completion/git-completion.bash18
-rw-r--r--contrib/emacs/git.el11
-rw-r--r--contrib/hooks/pre-auto-gc-battery36
-rw-r--r--diff-lib.c45
-rw-r--r--diff.c86
-rw-r--r--diff.h2
-rw-r--r--diffcore-rename.c83
-rw-r--r--dir.c24
-rw-r--r--environment.c5
-rwxr-xr-xgit-add--interactive.perl49
-rwxr-xr-xgit-bisect.sh50
-rwxr-xr-xgit-clone.sh8
-rw-r--r--git-compat-util.h19
-rwxr-xr-xgit-filter-branch.sh30
-rwxr-xr-xgit-merge.sh19
-rwxr-xr-xgit-mergetool.sh4
-rwxr-xr-xgit-pull.sh20
-rwxr-xr-xgit-rebase.sh56
-rwxr-xr-xgit-send-email.perl23
-rwxr-xr-xgit-submodule.sh20
-rwxr-xr-xgit-svn.perl71
-rw-r--r--git.c2
-rw-r--r--gitweb/INSTALL83
-rw-r--r--gitweb/README59
-rw-r--r--gitweb/gitweb.css8
-rwxr-xr-xgitweb/gitweb.perl128
-rw-r--r--help.c171
-rw-r--r--http-push.c33
-rw-r--r--http-walker.c4
-rw-r--r--http.c18
-rw-r--r--http.h2
-rw-r--r--ident.c3
-rw-r--r--log-tree.c30
-rw-r--r--log-tree.h2
-rw-r--r--name-hash.c119
-rw-r--r--pack-write.c8
-rw-r--r--path.c38
-rw-r--r--perl/Git.pm45
-rw-r--r--pkt-line.c15
-rw-r--r--pretty.c68
-rw-r--r--read-cache.c146
-rw-r--r--receive-pack.c36
-rw-r--r--refs.c20
-rw-r--r--remote.c99
-rw-r--r--remote.h5
-rw-r--r--revision.c2
-rw-r--r--revision.h3
-rw-r--r--setup.c107
-rw-r--r--sha1-lookup.c171
-rw-r--r--sha1-lookup.h9
-rw-r--r--sha1_file.c49
-rw-r--r--symlinks.c82
-rw-r--r--t/.gitignore2
-rw-r--r--t/lib-git-svn.sh12
-rw-r--r--t/lib-httpd.sh3
-rwxr-xr-xt/t0000-basic.sh4
-rwxr-xr-xt/t0002-gitfile.sh103
-rwxr-xr-xt/t1020-subdirectory.sh22
-rwxr-xr-xt/t1300-repo-config.sh58
-rwxr-xr-xt/t1301-shared-repo.sh50
-rwxr-xr-xt/t1303-wacky-config.sh6
-rwxr-xr-xt/t1500-rev-parse.sh9
-rwxr-xr-xt/t1501-worktree.sh34
-rwxr-xr-xt/t1503-rev-parse-verify.sh107
-rwxr-xr-xt/t2002-checkout-cache-u.sh4
-rwxr-xr-xt/t3050-subprojects-fetch.sh2
-rwxr-xr-xt/t3200-branch.sh234
-rwxr-xr-xt/t3201-branch-contains.sh42
-rwxr-xr-xt/t3400-rebase.sh7
-rwxr-xr-xt/t3404-rebase-interactive.sh3
-rwxr-xr-xt/t3407-rebase-abort.sh33
-rwxr-xr-xt/t3500-cherry.sh3
-rwxr-xr-xt/t3700-add.sh6
-rwxr-xr-xt/t3701-add-interactive.sh19
-rwxr-xr-xt/t4027-diff-submodule.sh7
-rwxr-xr-xt/t5000-tar-tree.sh8
-rwxr-xr-xt/t5300-pack-object.sh95
-rwxr-xr-xt/t5302-pack-index.sh2
-rwxr-xr-xt/t5500-fetch-pack.sh4
-rwxr-xr-xt/t5512-ls-remote.sh2
-rwxr-xr-xt/t5516-fetch-push.sh6
-rwxr-xr-xt/t5517-push-mirror.sh41
-rwxr-xr-xt/t5700-clone-reference.sh2
-rwxr-xr-xt/t5710-info-alternate.sh4
-rwxr-xr-xt/t6000lib.sh9
-rwxr-xr-xt/t6010-merge-base.sh9
-rwxr-xr-xt/t6030-bisect-porcelain.sh25
-rwxr-xr-xt/t6032-merge-large-rename.sh73
-rwxr-xr-xt/t6200-fmt-merge-msg.sh60
-rwxr-xr-xt/t7003-filter-branch.sh34
-rwxr-xr-xt/t7004-tag.sh3
-rwxr-xr-xt/t7010-setup.sh2
-rwxr-xr-xt/t7300-clean.sh2
-rwxr-xr-xt/t7401-submodule-summary.sh13
-rwxr-xr-xt/t7501-commit.sh10
-rwxr-xr-xt/t7502-commit.sh27
-rwxr-xr-xt/t7502-status.sh134
-rwxr-xr-xt/t7504-commit-msg-hook.sh23
-rwxr-xr-xt/t7505-prepare-commit-msg-hook.sh17
-rwxr-xr-xt/t7506-status-submodule.sh38
-rwxr-xr-xt/t7600-merge.sh39
-rwxr-xr-xt/t9001-send-email.sh71
-rwxr-xr-xt/t9100-git-svn-basic.sh120
-rwxr-xr-xt/t9101-git-svn-props.sh8
-rwxr-xr-xt/t9102-git-svn-deep-rmdir.sh20
-rwxr-xr-xt/t9103-git-svn-tracked-directory-removed.sh20
-rwxr-xr-xt/t9104-git-svn-follow-parent.sh172
-rwxr-xr-xt/t9105-git-svn-commit-diff.sh32
-rwxr-xr-xt/t9106-git-svn-commit-diff-clobber.sh56
-rwxr-xr-xt/t9106-git-svn-dcommit-clobber-series.sh30
-rwxr-xr-xt/t9107-git-svn-migrate.sh124
-rwxr-xr-xt/t9108-git-svn-glob.sh76
-rwxr-xr-xt/t9110-git-svn-use-svm-props.sh12
-rwxr-xr-xt/t9111-git-svn-use-svnsync-props.sh12
-rwxr-xr-xt/t9112-git-svn-md5less-file.sh4
-rwxr-xr-xt/t9113-git-svn-dcommit-new-file.sh10
-rwxr-xr-xt/t9114-git-svn-dcommit-merge.sh22
-rwxr-xr-xt/t9115-git-svn-dcommit-funky-renames.sh47
-rwxr-xr-xt/t9116-git-svn-log.sh12
-rwxr-xr-xt/t9117-git-svn-init-clone.sh30
-rwxr-xr-xt/t9118-git-svn-funky-branch-names.sh24
-rwxr-xr-xt/t9120-git-svn-clone-with-percent-escapes.sh6
-rwxr-xr-xt/t9121-git-svn-fetch-renamed-dir.sh12
-rwxr-xr-xt/t9400-git-cvsserver-server.sh16
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh25
-rwxr-xr-xt/t9600-cvsimport.sh2
-rw-r--r--t/test-lib.sh22
-rw-r--r--transport.c16
-rw-r--r--unpack-trees.c55
-rw-r--r--unpack-trees.h22
-rw-r--r--var.c3
-rw-r--r--walker.c6
-rw-r--r--walker.h2
-rw-r--r--write_or_die.c4
-rw-r--r--wt-status.c43
199 files changed, 4863 insertions, 1556 deletions
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 43781fb248..4144d1e086 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -2,8 +2,8 @@ MAN1_TXT= \
$(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
$(wildcard git-*.txt)) \
gitk.txt
-MAN5_TXT=gitattributes.txt gitignore.txt gitcli.txt gitmodules.txt
-MAN7_TXT=git.txt
+MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt
+MAN7_TXT=git.txt gitcli.txt
MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
@@ -18,7 +18,6 @@ ARTICLES += cvs-migration
ARTICLES += diffcore
ARTICLES += howto-index
ARTICLES += repository-layout
-ARTICLES += hooks
ARTICLES += everyday
ARTICLES += git-tools
ARTICLES += glossary
diff --git a/Documentation/RelNotes-1.5.6.txt b/Documentation/RelNotes-1.5.6.txt
new file mode 100644
index 0000000000..f3256fb82c
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.txt
@@ -0,0 +1,59 @@
+GIT v1.5.6 Release Notes
+========================
+
+Updates since v1.5.5
+--------------------
+
+(subsystems)
+
+
+(portability)
+
+
+(performance)
+
+* "git rebase --onto $there $from $branch" used to switch to the tip of
+ $branch only to immediately reset back to $from, smudging work tree
+ files unnecessarily. This has been optimized.
+
+(usability, bells and whistles)
+
+* "git add -p" (and the "patch" subcommand of "git add -i") can choose to
+ apply (or not apply) mode changes independently from contents changes.
+
+* "git bisect help" gives longer and more helpful usage information.
+
+* "git diff/log --dirstat" output is consistent between binary and textual
+ changes.
+
+* "git gc --auto" honors a new pre-aut-gc hook to temporarily disable it.
+
+* "git log --pretty=tformat:<custom format>" gives a LF after each entry,
+ instead of giving a LF between each pair of entries which is how
+ "git log --pretty=format:<custom format>" works.
+
+* "git send-email" now can send out messages outside a git repository.
+
+* "git status" can optionally include output from "git submodule
+ summary".
+
+* "gitweb" can read from a system-wide configuration file.
+
+(internal)
+
+* "git unpack-objects" and "git receive-pack" is now more strict about
+ detecting breakage in the objects they receive over the wire.
+
+
+Fixes since v1.5.5
+------------------
+
+All of the fixes in v1.5.5 maintenance series are included in
+this release, unless otherwise noted.
+
+
+--
+exec >/var/tmp/1
+O=v1.5.5-56-g5f0734f
+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 273b358069..217980f48d 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -234,7 +234,13 @@ core.worktree::
used in combination with repositories found automatically in
a .git directory (i.e. $GIT_DIR is not set).
This can be overridden by the GIT_WORK_TREE environment
- variable and the '--work-tree' command line option.
+ variable and the '--work-tree' command line option. It can be
+ a absolute path or relative path to the directory specified by
+ --git-dir or GIT_DIR.
+ Note: If --git-dir or GIT_DIR are specified but none of
+ --work-tree, GIT_WORK_TREE and core.worktree is specified,
+ the current working directory is regarded as the top directory
+ of your working tree.
core.logAllRefUpdates::
Enable the reflog. Updates to a ref <ref> is logged to the file
@@ -261,7 +267,12 @@ core.sharedRepository::
group-writable). When 'all' (or 'world' or 'everybody'), the
repository will be readable by all users, additionally to being
group-shareable. When 'umask' (or 'false'), git will use permissions
- reported by umask(2). See linkgit:git-init[1]. False by default.
+ reported by umask(2). When '0xxx', where '0xxx' is an octal number,
+ files in the repository will have this mode value. '0xxx' will override
+ user's umask value, and thus, users with a safe umask (0077) can use
+ this option. Examples: '0660' is equivalent to 'group'. '0640' is a
+ repository that is group-readable but not group-writable.
+ See linkgit:git-init[1]. False by default.
core.warnAmbiguousRefs::
If true, git will warn you if the ref name you passed it is ambiguous
@@ -388,6 +399,21 @@ branch.autosetupmerge::
done when the starting point is either a local branch or remote
branch. This option defaults to true.
+branch.autosetuprebase::
+ When a new branch is created with `git-branch` or `git-checkout`
+ that tracks another branch, this variable tells git to set
+ up pull to rebase instead of merge (see "branch.<name>.rebase").
+ When `never`, rebase is never automatically set to true.
+ When `local`, rebase is set to true for tracked branches of
+ other local branches.
+ When `remote`, rebase is set to true for tracked branches of
+ remote branches.
+ When `always`, rebase will be set to true for all tracking
+ branches.
+ See "branch.autosetupmerge" for details on how to set up a
+ branch to track another branch.
+ This option defaults to never.
+
branch.<name>.remote::
When in branch <name>, it tells `git fetch` which remote to fetch.
If this option is not given, `git fetch` defaults to remote "origin".
@@ -674,6 +700,36 @@ specified as 'gitcvs.<access_method>.<varname>' (where 'access_method'
is one of "ext" and "pserver") to make them apply only for the given
access method.
+gui.commitmsgwidth::
+ Defines how wide the commit message window is in the
+ linkgit:git-gui[1]. "75" is the default.
+
+gui.diffcontext::
+ Specifies how many context lines should be used in calls to diff
+ made by the linkgit:git-gui[1]. The default is "5".
+
+gui.matchtrackingbranch::
+ Determines if new branches created with linkgit:git-gui[1] should
+ default to tracking remote branches with matching names or
+ not. Default: "false".
+
+gui.newbranchtemplate::
+ Is used as suggested name when creating new branches using the
+ linkgit:git-gui[1].
+
+gui.pruneduringfetch::
+ "true" if linkgit:git-gui[1] should prune tracking branches when
+ performing a fetch. The default value is "false".
+
+gui.trustmtime::
+ Determines if linkgit:git-gui[1] should trust the file modification
+ timestamp or not. By default the timestamps are not trusted.
+
+gui.spellingdictionary::
+ Specifies the dictionary used for spell checking commit messages in
+ the linkgit:git-gui[1]. When set to "none" spell checking is turned
+ off.
+
help.browser::
Specify the browser that will be used to display help in the
'web' format. See linkgit:git-help[1].
@@ -769,37 +825,16 @@ man.viewer::
Specify the programs that may be used to display help in the
'man' format. See linkgit:git-help[1].
-merge.summary::
- Whether to include summaries of merged commits in newly created
- merge commit messages. False by default.
-
-merge.tool::
- Controls which merge resolution program is used by
- linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
- "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
- "opendiff". Any other value is treated is custom merge tool
- and there must be a corresponing mergetool.<tool>.cmd option.
-
-merge.verbosity::
- Controls the amount of output shown by the recursive merge
- strategy. Level 0 outputs nothing except a final error
- message if conflicts were detected. Level 1 outputs only
- conflicts, 2 outputs conflicts and file changes. Level 5 and
- above outputs debugging information. The default is level 2.
- Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
-
-merge.<driver>.name::
- Defines a human readable name for a custom low-level
- merge driver. See linkgit:gitattributes[5] for details.
-
-merge.<driver>.driver::
- Defines the command that implements a custom low-level
- merge driver. See linkgit:gitattributes[5] for details.
-
-merge.<driver>.recursive::
- Names a low-level merge driver to be used when
- performing an internal merge between common ancestors.
- See linkgit:gitattributes[5] for details.
+include::merge-config.txt[]
+
+man.<tool>.cmd::
+ Specify the command to invoke the specified man viewer. The
+ specified command is evaluated in shell with the man page
+ passed as argument. (See linkgit:git-help[1].)
+
+man.<tool>.path::
+ Override the path for the given tool that may be used to
+ display help in the 'man' format. See linkgit:git-help[1].
mergetool.<tool>.path::
Override the path for the given tool. This is useful in case
@@ -911,6 +946,10 @@ remote.<name>.push::
The default set of "refspec" for linkgit:git-push[1]. See
linkgit:git-push[1].
+remote.<name>.mirror::
+ If true, pushing to this remote will automatically behave
+ as if the `\--mirror` option was given on the command line.
+
remote.<name>.skipDefaultUpdate::
If true, this remote will be skipped by default when updating
using the update subcommand of linkgit:git-remote[1].
@@ -992,6 +1031,12 @@ imap::
The configuration variables in the 'imap' section are described
in linkgit:git-imap-send[1].
+receive.fsckObjects::
+ If it is set to true, git-receive-pack will check all received
+ objects. It will abort in the case of a malformed object or a
+ broken link. The result of an abort are only dangling objects.
+ Defaults to false.
+
receive.unpackLimit::
If the number of objects received in a push is below this
limit then the objects will be unpacked into loose object
diff --git a/Documentation/cvs-migration.txt b/Documentation/cvs-migration.txt
index 00f2e36b2e..374bc87b10 100644
--- a/Documentation/cvs-migration.txt
+++ b/Documentation/cvs-migration.txt
@@ -137,7 +137,7 @@ Advanced Shared Repository Management
Git allows you to specify scripts called "hooks" to be run at certain
points. You can use these, for example, to send all commits to the shared
-repository to a mailing list. See link:hooks.html[Hooks used by git].
+repository to a mailing list. See linkgit:githooks[5][Hooks used by git].
You can enforce finer grained permissions using update hooks. See
link:howto/update-hook-example.txt[Controlling access to branches using
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index e2389e380b..e0e730b6c4 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -100,21 +100,27 @@ those in info/exclude. See link:repository-layout.html[repository layout].
EXAMPLES
--------
-git-add Documentation/\\*.txt::
- Adds content from all `\*.txt` files under `Documentation`
- directory and its subdirectories.
+* Adds content from all `\*.txt` files under `Documentation` directory
+and its subdirectories:
++
+------------
+$ git add Documentation/\\*.txt
+------------
+
Note that the asterisk `\*` is quoted from the shell in this
example; this lets the command to include the files from
subdirectories of `Documentation/` directory.
-git-add git-*.sh::
-
- Considers adding content from all git-*.sh scripts.
- Because this example lets shell expand the asterisk
- (i.e. you are listing the files explicitly), it does not
- consider `subdir/git-foo.sh`.
+* Considers adding content from all git-*.sh scripts:
++
+------------
+$ git add git-*.sh
+------------
++
+Because this example lets shell expand the asterisk (i.e. you are
+listing the files explicitly), it does not consider
+`subdir/git-foo.sh`.
Interactive mode
----------------
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 96585ae8d9..0b8b0ebba7 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -15,6 +15,7 @@ DESCRIPTION
The command takes various subcommands, and different options depending
on the subcommand:
+ git bisect help
git bisect start [<bad> [<good>...]] [--] [<paths>...]
git bisect bad [<rev>]
git bisect good [<rev>...]
@@ -29,6 +30,12 @@ This command uses 'git-rev-list --bisect' option to help drive the
binary search process to find which change introduced a bug, given an
old "good" commit object name and a later "bad" commit object name.
+Getting help
+~~~~~~~~~~~~
+
+Use "git bisect" to get a short usage description, and "git bisect
+help" or "git bisect -h" to get a long usage description.
+
Basic bisect commands: start, bad, good
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -78,7 +85,7 @@ Oh, and then after you want to reset to the original head, do a
$ git bisect reset
------------------------------------------------
-to get back to the master branch, instead of being in one of the
+to get back to the original branch, instead of being in one of the
bisection branches ("git bisect start" will do that for you too,
actually: it will reset the bisection state, and before it does that
it checks that you're not using some old bisection branch).
@@ -217,6 +224,55 @@ tree to the pristine state. Finally the "run" script can exit with
the status of the real test to let "git bisect run" command loop to
know the outcome.
+EXAMPLES
+--------
+
+* Automatically bisect a broken build between v1.2 and HEAD:
++
+------------
+$ git bisect start HEAD v1.2 -- # HEAD is bad, v1.2 is good
+$ git bisect run make # "make" builds the app
+------------
+
+* Automatically bisect a broken test suite:
++
+------------
+$ cat ~/test.sh
+#!/bin/sh
+make || exit 125 # this "skip"s broken builds
+make test # "make test" runs the test suite
+$ git bisect start v1.3 v1.1 -- # v1.3 is bad, v1.1 is good
+$ git bisect run ~/test.sh
+------------
++
+Here we use a "test.sh" custom script. In this script, if "make"
+fails, we "skip" the current commit.
++
+It's safer to use a custom script outside the repo to prevent
+interactions between the bisect, make and test processes and the
+script.
++
+And "make test" should "exit 0", if the test suite passes, and
+"exit 1" (for example) otherwise.
+
+* Automatically bisect a broken test case:
++
+------------
+$ cat ~/test.sh
+#!/bin/sh
+make || exit 125 # this "skip"s broken builds
+~/check_test_case.sh # does the test case passes ?
+$ git bisect start HEAD HEAD~10 -- # culprit is among the last 10
+$ git bisect run ~/test.sh
+------------
++
+Here "check_test_case.sh" should "exit 0", if the test case passes,
+and "exit 1" (for example) otherwise.
++
+It's safer if both "test.sh" and "check_test_case.sh" scripts are
+outside the repo to prevent interactions between the bisect, make and
+test processes and the scripts.
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 6f07a17a2c..c824d88742 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -8,7 +8,7 @@ git-branch - List, create, or delete branches
SYNOPSIS
--------
[verse]
-'git-branch' [--color | --no-color] [-r | -a]
+'git-branch' [--color | --no-color] [-r | -a] [--merged | --no-merged]
[-v [--abbrev=<length> | --no-abbrev]]
[--contains <commit>]
'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
@@ -24,6 +24,8 @@ and option `-a` shows both.
With `--contains <commit>`, shows only the branches that
contains the named commit (in other words, the branches whose
tip commits are descendant of the named commit).
+With `--merged`, only branches merged into HEAD will be listed, and
+with `--no-merged` only branches not merged into HEAD will be listed.
In its second form, a new branch named <branchname> will be created.
It will start out with a head equal to the one given as <start-point>.
@@ -118,6 +120,15 @@ OPTIONS
--no-track::
Ignore the branch.autosetupmerge configuration variable.
+--contains <commit>::
+ Only list branches which contain the specified commit.
+
+--merged::
+ Only list branches which are fully contained by HEAD.
+
+--no-merged::
+ Do not list branches which are fully contained by HEAD.
+
<branchname>::
The name of the branch to create or delete.
The new branch name must pass all checks defined by
@@ -175,6 +186,18 @@ If you are creating a branch that you want to immediately checkout, it's
easier to use the git checkout command with its `-b` option to create
a branch and check it out with a single command.
+The options `--contains`, `--merged` and `--no-merged` serves three related
+but different purposes:
+
+- `--contains <commit>` is used to find all branches which will need
+ special attention if <commit> were to be rebased or amended, since those
+ branches contain the specified <commit>.
+
+- `--merged` is used to find all branches which can be safely deleted,
+ since those branches are fully contained by HEAD.
+
+- `--no-merged` is used to find branches which are candidates for merging
+ into HEAD, since those branches are not fully contained by HEAD.
Author
------
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index e11cddbfc9..a644173e15 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -47,7 +47,7 @@ OPTIONS
by linkgit:git-check-ref-format[1]. Some of these checks
may restrict the characters allowed in a branch name.
---track::
+-t, --track::
When creating a new branch, set up configuration so that git-pull
will automatically retrieve data from the start point, which must be
a branch. Use this if you always pull from the same upstream branch
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index f0beb412e6..ca048f46f6 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -7,7 +7,7 @@ git-cherry-pick - Apply the change introduced by an existing commit
SYNOPSIS
--------
-'git-cherry-pick' [--edit] [-n] [-m parent-number] [-x] <commit>
+'git-cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] <commit>
DESCRIPTION
-----------
@@ -64,6 +64,9 @@ OPTIONS
This is useful when cherry-picking more than one commits'
effect to your working tree in a row.
+-s|--signoff::
+ Add Signed-off-by line at the end of the commit message.
+
Author
------
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 4bb51cc06e..c3c9f5b902 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -87,7 +87,7 @@ OPTIONS
--no-verify::
This option bypasses the pre-commit and commit-msg hooks.
- See also link:hooks.html[hooks].
+ See also linkgit:githooks[5][hooks].
--allow-empty::
Usually recording a commit that has the exact same tree as its
@@ -292,7 +292,7 @@ order).
HOOKS
-----
This command can run `commit-msg`, `prepare-commit-msg`, `pre-commit`,
-and `post-commit` hooks. See link:hooks.html[hooks] for more
+and `post-commit` hooks. See linkgit:githooks[5][hooks] for more
information.
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index fa161718dd..5de5d051b7 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -144,6 +144,8 @@ See also <<FILES>>.
"auto". If `stdout-is-tty` is missing, then checks the standard
output of the command itself, and exits with status 0 if color
is to be used, or exits with status 1 otherwise.
+ When the color setting for `name` is undefined, the command uses
+ `color.ui` as fallback.
--get-color name default::
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 6454e49bf2..8d80f0d074 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -133,10 +133,16 @@ use "--tag-name-filter cat" to simply update the tags. In this
case, be very careful and make sure you have the old tags
backed up in case the conversion has run afoul.
+
-Note that there is currently no support for proper rewriting of
-tag objects; in layman terms, if the tag has a message or signature
-attached, the rewritten tag won't have it. Sorry. (It is by
-definition impossible to preserve signatures at any rate.)
+Nearly proper rewriting of tag objects is supported. If the tag has
+a message attached, a new tag object will be created with the same message,
+author, and timestamp. If the tag has a signature attached, the
+signature will be stripped. It is by definition impossible to preserve
+signatures. The reason this is "nearly" proper, is because ideally if
+the tag did not change (points to the same object, has the same name, etc.)
+it should retain any signature. That is not the case, signatures will always
+be removed, buyer beware. There is also no support for changing the
+author or timestamp (or the tag message for that matter). Tags which point
+to other tags will be rewritten to point to the underlying commit.
--subdirectory-filter <directory>::
Only look at the history which touches the given subdirectory.
diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt
index 8615ae353e..457cf42561 100644
--- a/Documentation/git-fmt-merge-msg.txt
+++ b/Documentation/git-fmt-merge-msg.txt
@@ -9,8 +9,8 @@ git-fmt-merge-msg - Produce a merge commit message
SYNOPSIS
--------
[verse]
-git-fmt-merge-msg [--summary | --no-summary] <$GIT_DIR/FETCH_HEAD
-git-fmt-merge-msg [--summary | --no-summary] -F <file>
+git-fmt-merge-msg [--log | --no-log] <$GIT_DIR/FETCH_HEAD
+git-fmt-merge-msg [--log | --no-log] -F <file>
DESCRIPTION
-----------
@@ -24,15 +24,19 @@ automatically invoking `git-merge`.
OPTIONS
-------
---summary::
+--log::
In addition to branch names, populate the log message with
one-line descriptions from the actual commits that are being
merged.
---no-summary::
+--no-log::
Do not list one-line descriptions from the actual commits being
merged.
+--summary,--no-summary::
+ Synonyms to --log and --no-log; these are deprecated and will be
+ removed in the future.
+
--file <file>, -F <file>::
Take the list of merged objects from <file> instead of
stdin.
@@ -40,10 +44,14 @@ OPTIONS
CONFIGURATION
-------------
-merge.summary::
+merge.log::
Whether to include summaries of merged commits in newly
merge commit messages. False by default.
+merge.summary::
+ Synonym to `merge.log`; this is deprecated and will be removed in
+ the future.
+
SEE ALSO
--------
linkgit:git-merge[1]
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index b5207b7604..c60ce123ec 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -156,6 +156,12 @@ want a filename like `0001-description-of-my-change.patch`, and
the first letter does not have to be a dot. Leaving it empty would
not add any suffix.
+--no-binary::
+ Don't output contents of changes in binary files, just take note
+ that they differ. Note that this disable the patch to be properly
+ applied. By default the contents of changes in those files are
+ encoded in the patch.
+
CONFIGURATION
-------------
You can specify extra mail header lines to be added to each message
@@ -168,38 +174,54 @@ and file suffix, and number patches when outputting more than one.
subjectprefix = CHANGE
suffix = .txt
numbered = auto
+ cc = <email>
------------
EXAMPLES
--------
-git-format-patch -k --stdout R1..R2 | git-am -3 -k::
- Extract commits between revisions R1 and R2, and apply
- them on top of the current branch using `git-am` to
- cherry-pick them.
-
-git-format-patch origin::
- Extract all commits which are in the current branch but
- not in the origin branch. For each commit a separate file
- is created in the current directory.
-
-git-format-patch \--root origin::
- Extract all commits that lead to 'origin' since the
- inception of the project.
-
-git-format-patch -M -B origin::
- The same as the previous one. Additionally, it detects
- and handles renames and complete rewrites intelligently to
- produce a renaming patch. A renaming patch reduces the
- amount of text output, and generally makes it easier to
- review it. Note that the "patch" program does not
- understand renaming patches, so use it only when you know
- the recipient uses git to apply your patch.
-
-git-format-patch -3::
- Extract three topmost commits from the current branch
- and format them as e-mailable patches.
+* Extract commits between revisions R1 and R2, and apply them on top of
+the current branch using `git-am` to cherry-pick them:
++
+------------
+$ git format-patch -k --stdout R1..R2 | git-am -3 -k
+------------
+
+* Extract all commits which are in the current branch but not in the
+origin branch:
++
+------------
+$ git format-patch origin
+------------
++
+For each commit a separate file is created in the current directory.
+
+* Extract all commits that lead to 'origin' since the inception of the
+project:
++
+------------
+$ git format-patch \--root origin
+------------
+
+* The same as the previous one:
++
+------------
+$ git format-patch -M -B origin
+------------
++
+Additionally, it detects and handles renames and complete rewrites
+intelligently to produce a renaming patch. A renaming patch reduces
+the amount of text output, and generally makes it easier to review it.
+Note that the "patch" program does not understand renaming patches, so
+use it only when you know the recipient uses git to apply your patch.
+
+* Extract three topmost commits from the current branch and format them
+as e-mailable patches:
++
+------------
+$ git format-patch -3
+------------
See Also
--------
diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt
index f16cb98612..4cc26fb744 100644
--- a/Documentation/git-fsck.txt
+++ b/Documentation/git-fsck.txt
@@ -22,7 +22,8 @@ OPTIONS
An object to treat as the head of an unreachability trace.
+
If no objects are given, git-fsck defaults to using the
-index file and all SHA1 references in .git/refs/* as heads.
+index file, all SHA1 references in .git/refs/*, and all reflogs (unless
+--no-reflogs is given) as heads.
--unreachable::
Print out objects that exist but that aren't readable from any
diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index be2ae53b90..bfbba9e235 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -82,28 +82,75 @@ man.viewer
~~~~~~~~~~
The 'man.viewer' config variable will be checked if the 'man' format
-is chosen. Only the following values are currently supported:
+is chosen. The following values are currently supported:
* "man": use the 'man' program as usual,
* "woman": use 'emacsclient' to launch the "woman" mode in emacs
(this only works starting with emacsclient versions 22),
-* "konqueror": use a man KIO slave in konqueror.
+* "konqueror": use 'kfmclient' to open the man page in a new konqueror
+tab (see 'Note about konqueror' below).
-Multiple values may be given to this configuration variable. Their
-corresponding programs will be tried in the order listed in the
-configuration file.
+Values for other tools can be used if there is a corresponding
+'man.<tool>.cmd' configuration entry (see below).
+
+Multiple values may be given to the 'man.viewer' configuration
+variable. Their corresponding programs will be tried in the order
+listed in the configuration file.
For example, this configuration:
+------------------------------------------------
[man]
viewer = konqueror
viewer = woman
+------------------------------------------------
will try to use konqueror first. But this may fail (for example if
DISPLAY is not set) and in that case emacs' woman mode will be tried.
If everything fails the 'man' program will be tried anyway.
+man.<tool>.path
+~~~~~~~~~~~~~~~
+
+You can explicitly provide a full path to your preferred man viewer by
+setting the configuration variable 'man.<tool>.path'. For example, you
+can configure the absolute path to konqueror by setting
+'man.konqueror.path'. Otherwise, 'git help' assumes the tool is
+available in PATH.
+
+man.<tool>.cmd
+~~~~~~~~~~~~~~
+
+When the man viewer, specified by the 'man.viewer' configuration
+variables, is not among the supported ones, then the corresponding
+'man.<tool>.cmd' configuration variable will be looked up. If this
+variable exists then the specified tool will be treated as a custom
+command and a shell eval will be used to run the command with the man
+page passed as arguments.
+
+Note about konqueror
+~~~~~~~~~~~~~~~~~~~~
+
+When 'konqueror' is specified in the 'man.viewer' configuration
+variable, we launch 'kfmclient' to try to open the man page on an
+already opened konqueror in a new tab if possible.
+
+For consistency, we also try such a trick if 'man.konqueror.path' is
+set to something like 'A_PATH_TO/konqueror'. That means we will try to
+launch 'A_PATH_TO/kfmclient' instead.
+
+If you really want to use 'konqueror', then you can use something like
+the following:
+
+------------------------------------------------
+ [man]
+ viewer = konq
+
+ [man "konq"]
+ cmd = A_PATH_TO/konqueror
+------------------------------------------------
+
Note about git config --global
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt
index 62914da97b..b17ae8485c 100644
--- a/Documentation/git-init.txt
+++ b/Documentation/git-init.txt
@@ -31,7 +31,7 @@ structure, some suggested "exclude patterns", and copies of non-executing
"hook" files. The suggested patterns and hook files are all modifiable and
extensible.
---shared[={false|true|umask|group|all|world|everybody}]::
+--shared[={false|true|umask|group|all|world|everybody|0xxx}]::
Specify that the git repository is to be shared amongst several users. This
allows users belonging to the same group to push into that
@@ -52,6 +52,12 @@ is given:
- 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
readable by all users.
+ - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'
+ Any option except 'umask' can be set using this option. '0xxx' will
+ override users umask(2) value, and thus, users with a safe umask (0077)
+ can use this option. '0640' will create a repository which is group-readable
+ but not writable. '0660' is equivalent to 'group'.
+
By default, the configuration flag receive.denyNonFastForwards is enabled
in shared repositories, so that you cannot force a non fast-forwarding push
into it.
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index c136b10692..ef1f055c85 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -9,7 +9,7 @@ git-merge - Join two or more development histories together
SYNOPSIS
--------
[verse]
-'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...
+'git-merge' [-n] [--stat] [--no-commit] [--squash] [-s <strategy>]...
[-m <msg>] <remote> <remote>...
'git-merge' <msg> HEAD <remote>...
@@ -46,18 +46,7 @@ linkgit:git-reset[1].
CONFIGURATION
-------------
-
-merge.summary::
- Whether to include summaries of merged commits in newly
- created merge commit. False by default.
-
-merge.verbosity::
- Controls the amount of output shown by the recursive merge
- strategy. Level 0 outputs nothing except a final error
- message if conflicts were detected. Level 1 outputs only
- conflicts, 2 outputs conflicts and file changes. Level 5 and
- above outputs debugging information. The default is level 2.
- Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
+include::merge-config.txt[]
branch.<name>.mergeoptions::
Sets default options for merging into branch <name>. The syntax and
diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt
index f151cff5d9..f92bb8cfa0 100644
--- a/Documentation/git-prune.txt
+++ b/Documentation/git-prune.txt
@@ -13,6 +13,9 @@ SYNOPSIS
DESCRIPTION
-----------
+NOTE: In most cases, users should run linkgit:git-gc[1], which calls
+git-prune. See the section "NOTES", below.
+
This runs `git-fsck --unreachable` using all the refs
available in `$GIT_DIR/refs`, optionally with additional set of
objects specified on the command line, and prunes all
@@ -50,6 +53,23 @@ borrows from your repository via its
$ git prune $(cd ../another && $(git-rev-parse --all))
------------
+Notes
+-----
+
+In most cases, users will not need to call git-prune directly, but
+should instead call linkgit:git-gc[1], which handles pruning along with
+many other housekeeping tasks.
+
+For a description of which objects are considered for pruning, see
+git-fsck's --unreachable option.
+
+See Also
+--------
+
+linkgit:git-fsck[1],
+linkgit:git-gc[1],
+linkgit:git-reflog[1]
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 3405ca09e8..66304f0255 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -111,40 +111,58 @@ rules apply:
EXAMPLES
--------
-git pull, git pull origin::
- Update the remote-tracking branches for the repository
- you cloned from, then merge one of them into your
- current branch. Normally the branch merged in is
- the HEAD of the remote repository, but the choice is
- determined by the branch.<name>.remote and
- branch.<name>.merge options; see linkgit:git-config[1]
- for details.
-
-git pull origin next::
- Merge into the current branch the remote branch `next`;
- leaves a copy of `next` temporarily in FETCH_HEAD, but
- does not update any remote-tracking branches.
-
-git pull . fixes enhancements::
- Bundle local branch `fixes` and `enhancements` on top of
- the current branch, making an Octopus merge. This `git pull .`
- syntax is equivalent to `git merge`.
-
-git pull -s ours . obsolete::
- Merge local branch `obsolete` into the current branch,
- using `ours` merge strategy.
-
-git pull --no-commit . maint::
- Merge local branch `maint` into the current branch, but
- do not make a commit automatically. This can be used
- when you want to include further changes to the merge,
- or want to write your own merge commit message.
+* Update the remote-tracking branches for the repository
+ you cloned from, then merge one of them into your
+ current branch:
++
+------------------------------------------------
+$ git pull, git pull origin
+------------------------------------------------
++
+Normally the branch merged in is the HEAD of the remote repository,
+but the choice is determined by the branch.<name>.remote and
+branch.<name>.merge options; see linkgit:git-config[1] for details.
+
+* Merge into the current branch the remote branch `next`:
++
+------------------------------------------------
+$ git pull origin next
+------------------------------------------------
++
+This leaves a copy of `next` temporarily in FETCH_HEAD, but
+does not update any remote-tracking branches.
+
+* Bundle local branch `fixes` and `enhancements` on top of
+ the current branch, making an Octopus merge:
++
+------------------------------------------------
+$ git pull . fixes enhancements
+------------------------------------------------
++
+This `git pull .` syntax is equivalent to `git merge`.
+
+* Merge local branch `obsolete` into the current branch, using `ours`
+ merge strategy:
++
+------------------------------------------------
+$ git pull -s ours . obsolete
+------------------------------------------------
+
+* Merge local branch `maint` into the current branch, but do not make
+ a commit automatically:
++
+------------------------------------------------
+$ git pull --no-commit . maint
+------------------------------------------------
++
+This can be used when you want to include further changes to the
+merge, or want to write your own merge commit message.
+
You should refrain from abusing this option to sneak substantial
changes into a merge commit. Small fixups like bumping
release/version name would be acceptable.
-Command line pull of multiple branches from one repository::
+* Command line pull of multiple branches from one repository:
+
------------------------------------------------
$ git checkout master
@@ -152,12 +170,12 @@ $ git fetch origin +pu:pu maint:tmp
$ git pull . tmp
------------------------------------------------
+
-This updates (or creates, as necessary) branches `pu` and `tmp`
-in the local repository by fetching from the branches
-(respectively) `pu` and `maint` from the remote repository.
+This updates (or creates, as necessary) branches `pu` and `tmp` in
+the local repository by fetching from the branches (respectively)
+`pu` and `maint` from the remote repository.
+
-The `pu` branch will be updated even if it is does not
-fast-forward; the others will not be.
+The `pu` branch will be updated even if it is does not fast-forward;
+the others will not be.
+
The final command then merges the newly fetched `tmp` into master.
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 0585949137..f06d94e318 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -70,7 +70,9 @@ the remote repository.
be mirrored to the remote repository. Newly created local
refs will be pushed to the remote end, locally updated refs
will be force updated on the remote end, and deleted refs
- will be removed from the remote end.
+ will be removed from the remote end. This is the default
+ if the configuration option `remote.<remote>.mirror` is
+ set.
\--dry-run::
Do everything except actually send the updates.
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 2cbd1f764b..b20e851973 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -47,9 +47,11 @@ With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
up to point at remote's `<master>` branch instead of whatever
branch the `HEAD` at the remote repository actually points at.
+
-In mirror mode, enabled with `--mirror`, the refs will not be stored
+In mirror mode, enabled with `\--mirror`, the refs will not be stored
in the 'refs/remotes/' namespace, but in 'refs/heads/'. This option
-only makes sense in bare repositories.
+only makes sense in bare repositories. If a remote uses mirror
+mode, furthermore, `git push` will always behave as if `\--mirror`
+was passed.
'rm'::
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 6513c2efe1..b6b2fe92a1 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -52,6 +52,11 @@ OPTIONS
The parameter given must be usable as a single, valid
object name. Otherwise barf and abort.
+-q, --quiet::
+ Only meaningful in `--verify` mode. Do not output an error
+ message if the first argument is not a valid object name;
+ instead exit with non-zero status silently.
+
--sq::
Usually the output is made one line per flag and
parameter. This option makes output a single line,
@@ -342,7 +347,7 @@ Each line of options has this format:
* Use `*` to mean that this option should not be listed in the usage
generated for the `-h` argument. It's shown for `--help-all` as
- documented in linkgit:gitcli[5].
+ documented in linkgit:gitcli[7].
* Use `!` to not make the corresponding negated long option available.
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 93e20f7752..13ceabbcc8 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -7,7 +7,7 @@ git-revert - Revert an existing commit
SYNOPSIS
--------
-'git-revert' [--edit | --no-edit] [-n] [-m parent-number] <commit>
+'git-revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>
DESCRIPTION
-----------
@@ -51,6 +51,9 @@ OPTIONS
This is useful when reverting more than one commits'
effect to your working tree in a row.
+-s|--signoff::
+ Add Signed-off-by line at the end of the commit message.
+
Author
------
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 3ea269aa7a..ea4376a17f 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -52,6 +52,11 @@ If the config variable `status.relativePaths` is set to false, then all
paths shown are relative to the repository root, not to the current
directory.
+If `status.submodulesummary` is set to a non zero number or true (identical
+to -1 or an unlimited number), the submodule summary will be enabled and a
+summary of commits for modified submodules will be shown (see --summary-limit
+option of linkgit:git-submodule[1]).
+
See Also
--------
linkgit:gitignore[5]
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index bec9accc89..c6b56b4ef3 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -166,11 +166,18 @@ environment). This command has the same behaviour.
Any other arguments are passed directly to `git log'
'blame'::
- Show what revision and author last modified each line of a file. This is
- identical to `git blame', but SVN revision numbers are shown instead of git
- commit hashes.
+ Show what revision and author last modified each line of a file. The
+ output of this mode is format-compatible with the output of
+ `svn blame' by default. Like the SVN blame command,
+ local uncommitted changes in the working copy are ignored;
+ the version of the file in the HEAD revision is annotated. Unknown
+ arguments are passed directly to git-blame.
+
-All arguments are passed directly to `git blame'.
+--git-format;;
+ Produce output in the same format as `git blame', but with
+ SVN revision numbers instead of git commit hashes. In this mode,
+ changes that haven't been committed to SVN (including local
+ working-copy edits) are shown as revision 0.
--
'find-rev'::
@@ -188,6 +195,12 @@ All arguments are passed directly to `git blame'.
commit. All merging is assumed to have taken place
independently of git-svn functions.
+'create-ignore'::
+
+ Recursively finds the svn:ignore property on directories and
+ creates matching .gitignore files. The resulting files are staged to
+ be committed, but are not committed.
+
'show-ignore'::
Recursively finds and lists the svn:ignore property on
directories. The output is suitable for appending to
diff --git a/Documentation/git-unpack-objects.txt b/Documentation/git-unpack-objects.txt
index b79be3fd4c..50947c50df 100644
--- a/Documentation/git-unpack-objects.txt
+++ b/Documentation/git-unpack-objects.txt
@@ -8,7 +8,7 @@ git-unpack-objects - Unpack objects from a packed archive
SYNOPSIS
--------
-'git-unpack-objects' [-n] [-q] [-r] <pack-file
+'git-unpack-objects' [-n] [-q] [-r] [--strict] <pack-file
DESCRIPTION
@@ -40,6 +40,9 @@ OPTIONS
and make the best effort to recover as many objects as
possible.
+--strict::
+ Don't write objects with broken content or links.
+
Author
------
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index ddbae5b194..92ef574565 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -20,7 +20,7 @@ The following browsers (or commands) are currently supported:
* firefox (this is the default under X Window when not using KDE)
* iceweasel
-* konqueror (this is the default under KDE)
+* konqueror (this is the default under KDE, see 'Note about konqueror' below)
* w3m (this is the default outside graphical environments)
* links
* lynx
@@ -71,6 +71,28 @@ variable exists then "git web--browse" will treat the specified tool
as a custom command and will use a shell eval to run the command with
the URLs passed as arguments.
+Note about konqueror
+--------------------
+
+When 'konqueror' is specified by the a command line option or a
+configuration variable, we launch 'kfmclient' to try to open the HTML
+man page on an already opened konqueror in a new tab if possible.
+
+For consistency, we also try such a trick if 'brower.konqueror.path' is
+set to something like 'A_PATH_TO/konqueror'. That means we will try to
+launch 'A_PATH_TO/kfmclient' instead.
+
+If you really want to use 'konqueror', then you can use something like
+the following:
+
+------------------------------------------------
+ [web]
+ browser = konq
+
+ [browser "konq"]
+ cmd = A_PATH_TO/konqueror
+------------------------------------------------
+
Note about git config --global
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/git.txt b/Documentation/git.txt
index a070e078e7..adcd3e00b2 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -143,7 +143,8 @@ help ...'.
--git-dir=<path>::
Set the path to the repository. This can also be controlled by
- setting the GIT_DIR environment variable.
+ setting the GIT_DIR environment variable. It can be an absolute
+ path or relative path to current working directory.
--work-tree=<path>::
Set the path to the working tree. The value will not be
@@ -151,7 +152,12 @@ help ...'.
a .git directory (i.e. $GIT_DIR is not set).
This can also be controlled by setting the GIT_WORK_TREE
environment variable and the core.worktree configuration
- variable.
+ variable. It can be an absolute path or relative path to
+ the directory specified by --git-dir or GIT_DIR.
+ Note: If --git-dir or GIT_DIR are specified but none of
+ --work-tree, GIT_WORK_TREE and core.worktree is specified,
+ the current working directory is regarded as the top directory
+ of your working tree.
--bare::
Treat the repository as a bare repository. If GIT_DIR
@@ -358,7 +364,7 @@ File/Directory Structure
Please see the link:repository-layout.html[repository layout] document.
-Read link:hooks.html[hooks] for more details about each hook.
+Read linkgit:githooks[5][hooks] for more details about each hook.
Higher level SCMs may provide and manage additional information in the
`$GIT_DIR`.
diff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt
index 7ee5ce386f..835cb05f96 100644
--- a/Documentation/gitcli.txt
+++ b/Documentation/gitcli.txt
@@ -1,4 +1,4 @@
-gitcli(5)
+gitcli(7)
=========
NAME
diff --git a/Documentation/hooks.txt b/Documentation/githooks.txt
index 76b8d77460..53747febd2 100644
--- a/Documentation/hooks.txt
+++ b/Documentation/githooks.txt
@@ -1,5 +1,17 @@
-Hooks used by git
-=================
+githooks(5)
+===========
+
+NAME
+----
+githooks - Hooks used by git
+
+SYNOPSIS
+--------
+$GIT_DIR/hooks/*
+
+
+DESCRIPTION
+-----------
Hooks are little scripts you can place in `$GIT_DIR/hooks`
directory to trigger action at certain points. When
@@ -28,10 +40,11 @@ The default 'applypatch-msg' hook, when enabled, runs the
pre-applypatch
--------------
-This hook is invoked by `git-am`. It takes no parameter,
-and is invoked after the patch is applied, but before a commit
-is made. Exiting with non-zero status causes the working tree
-after application of the patch not committed.
+This hook is invoked by `git-am`. It takes no parameter, and is
+invoked after the patch is applied, but before a commit is made.
+
+If it exits with non-zero status, then the working tree will not be
+committed after applying the patch.
It can be used to inspect the current working tree and refuse to
make a commit if it does not pass certain test.
@@ -136,7 +149,8 @@ post-merge
This hook is invoked by `git-merge`, which happens when a `git pull`
is done on a local repository. The hook takes a single parameter, a status
flag specifying whether or not the merge being done was a squash merge.
-This hook cannot affect the outcome of `git-merge`.
+This hook cannot affect the outcome of `git-merge` and is not executed,
+if the merge failed due to conflicts.
This hook can be used in conjunction with a corresponding pre-commit hook to
save and restore any form of metadata associated with the working tree
@@ -276,3 +290,14 @@ probably enable this hook.
Both standard output and standard error output are forwarded to
`git-send-pack` on the other end, so you can simply `echo` messages
for the user.
+
+pre-auto-gc
+-----------
+
+This hook is invoked by `git-gc --auto`. It takes no parameter, and
+exiting with non-zero status from this script causes the `git-gc --auto`
+to abort.
+
+GIT
+---
+Part of the linkgit:git[7] suite
diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index ed3ba83c53..50d12da89f 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -41,6 +41,12 @@ frequently used options.
Show all branches.
+--merge::
+
+ After an attempt to merge stops with conflicts, show the commits on
+ the history between two branches (i.e. the HEAD and the MERGE_HEAD)
+ that modify the conflicted files.
+
<revs>::
Limit the revisions to show. This can be either a single revision
diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
new file mode 100644
index 0000000000..48ce747cf4
--- /dev/null
+++ b/Documentation/merge-config.txt
@@ -0,0 +1,40 @@
+merge.stat::
+ Whether to print the diffstat berween ORIG_HEAD and merge result
+ at the end of the merge. True by default.
+
+merge.log::
+ Whether to include summaries of merged commits in newly created
+ merge commit messages. False by default.
+
+merge.renameLimit::
+ The number of files to consider when performing rename detection
+ during a merge; if not specified, defaults to the value of
+ diff.renameLimit.
+
+merge.tool::
+ Controls which merge resolution program is used by
+ linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
+ "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
+ "opendiff". Any other value is treated is custom merge tool
+ and there must be a corresponing mergetool.<tool>.cmd option.
+
+merge.verbosity::
+ Controls the amount of output shown by the recursive merge
+ strategy. Level 0 outputs nothing except a final error
+ message if conflicts were detected. Level 1 outputs only
+ conflicts, 2 outputs conflicts and file changes. Level 5 and
+ above outputs debugging information. The default is level 2.
+ Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
+
+merge.<driver>.name::
+ Defines a human readable name for a custom low-level
+ merge driver. See linkgit:gitattributes[5] for details.
+
+merge.<driver>.driver::
+ Defines the command that implements a custom low-level
+ merge driver. See linkgit:gitattributes[5] for details.
+
+merge.<driver>.recursive::
+ Names a low-level merge driver to be used when
+ performing an internal merge between common ancestors.
+ See linkgit:gitattributes[5] for details.
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 9f1fc82550..f37a776489 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -1,10 +1,23 @@
---summary::
+--stat::
Show a diffstat at the end of the merge. The diffstat is also
- controlled by the configuration option merge.diffstat.
+ controlled by the configuration option merge.stat.
--n, \--no-summary::
+-n, \--no-stat::
Do not show diffstat at the end of the merge.
+--summary, \--no-summary::
+ Synonyms to --stat and --no-stat; these are deprecated and will be
+ removed in the future.
+
+--log::
+ In addition to branch names, populate the log message with
+ one-line descriptions from the actual commits that are being
+ merged.
+
+--no-log::
+ Do not list one-line descriptions from the actual commits being
+ merged.
+
--no-commit::
Perform the merge but pretend the merge failed and do
not autocommit, to give the user a chance to inspect and
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 0193c3ce58..e8bea3e18e 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -123,3 +123,4 @@ The placeholders are:
- '%Creset': reset color
- '%m': left, right or boundary mark
- '%n': newline
+- '%x00': print a byte from a hex code
diff --git a/Documentation/repository-layout.txt b/Documentation/repository-layout.txt
index 6939130094..7fd187be8a 100644
--- a/Documentation/repository-layout.txt
+++ b/Documentation/repository-layout.txt
@@ -3,7 +3,10 @@ git repository layout
You may find these things in your git repository (`.git`
directory for a repository associated with your working tree, or
-`'project'.git` directory for a public 'bare' repository).
+`'project'.git` directory for a public 'bare' repository. It is
+also possible to have a working tree where `.git` is a plain
+ascii file containing `gitdir: <path>`, i.e. the path to the
+real git repository).
objects::
Object store associated with this repository. Usually
@@ -121,7 +124,7 @@ hooks::
commands. A handful of sample hooks are installed when
`git init` is run, but all of them are disabled by
default. To enable, they need to be made executable.
- Read link:hooks.html[hooks] for more details about
+ Read linkgit:githooks[5][hooks] for more details about
each hook.
index::
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 86b91a53e5..e2db850150 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -1881,7 +1881,7 @@ $ chmod a+x hooks/post-update
(For an explanation of the last two lines, see
linkgit:git-update-server-info[1], and the documentation
-link:hooks.html[Hooks used by git].)
+linkgit:githooks[5][Hooks used by git].)
Advertise the URL of proj.git. Anybody else should then be able to
clone or pull from that URL, for example with a command line like:
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index f60bab896b..3cabc92e7a 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -11,7 +11,7 @@ LF='
if test -f version
then
VN=$(cat version) || VN="$DEF_VER"
-elif test -d .git &&
+elif test -d .git -o -f .git &&
VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
diff --git a/INSTALL b/INSTALL
index 6f3bcb4525..d9b425fa73 100644
--- a/INSTALL
+++ b/INSTALL
@@ -38,6 +38,10 @@ Issues of note:
has been actively developed since 1997, and people have moved over to
graphical file managers.
+ NOTE: 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.
+
- You can use git after building but without installing if you
wanted to. Various git commands need to find other git
commands and scripts to do their work, so you would need to
diff --git a/Makefile b/Makefile
index 7c70b00b82..649ee56c96 100644
--- a/Makefile
+++ b/Makefile
@@ -189,6 +189,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig
# default configuration for gitweb
GITWEB_CONFIG = gitweb_config.perl
+GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
GITWEB_HOME_LINK_STR = projects
GITWEB_SITENAME =
GITWEB_PROJECTROOT = /pub/git
@@ -365,6 +366,7 @@ LIB_H += refs.h
LIB_H += remote.h
LIB_H += revision.h
LIB_H += run-command.h
+LIB_H += sha1-lookup.h
LIB_H += sideband.h
LIB_H += strbuf.h
LIB_H += tag.h
@@ -421,6 +423,7 @@ LIB_OBJS += log-tree.o
LIB_OBJS += mailmap.o
LIB_OBJS += match-trees.o
LIB_OBJS += merge-file.o
+LIB_OBJS += name-hash.o
LIB_OBJS += object.o
LIB_OBJS += pack-check.o
LIB_OBJS += pack-revindex.o
@@ -445,6 +448,7 @@ LIB_OBJS += run-command.o
LIB_OBJS += server-info.o
LIB_OBJS += setup.o
LIB_OBJS += sha1_file.o
+LIB_OBJS += sha1-lookup.o
LIB_OBJS += sha1_name.o
LIB_OBJS += shallow.o
LIB_OBJS += sideband.o
@@ -1034,6 +1038,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-e 's|++GIT_BINDIR++|$(bindir)|g' \
-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+ -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
diff --git a/RelNotes b/RelNotes
index 730df98bdc..e29d6504d9 120000
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.5.5.1.txt \ No newline at end of file
+Documentation/RelNotes-1.5.6.txt \ No newline at end of file
diff --git a/branch.c b/branch.c
index daf862e728..56e949232c 100644
--- a/branch.c
+++ b/branch.c
@@ -32,6 +32,21 @@ static int find_tracked_branch(struct remote *remote, void *priv)
return 0;
}
+static int should_setup_rebase(const struct tracking *tracking)
+{
+ switch (autorebase) {
+ case AUTOREBASE_NEVER:
+ return 0;
+ case AUTOREBASE_LOCAL:
+ return tracking->remote == NULL;
+ case AUTOREBASE_REMOTE:
+ return tracking->remote != NULL;
+ case AUTOREBASE_ALWAYS:
+ return 1;
+ }
+ return 0;
+}
+
/*
* This is called when new_ref is branched off of orig_ref, and tries
* to infer the settings for branch.<new_ref>.{remote,merge} from the
@@ -69,9 +84,14 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
git_config_set(key, tracking.remote ? tracking.remote : ".");
sprintf(key, "branch.%s.merge", new_ref);
git_config_set(key, tracking.src ? tracking.src : orig_ref);
- free(tracking.src);
printf("Branch %s set up to track %s branch %s.\n", new_ref,
tracking.remote ? "remote" : "local", orig_ref);
+ if (should_setup_rebase(&tracking)) {
+ sprintf(key, "branch.%s.rebase", new_ref);
+ git_config_set(key, "true");
+ printf("This branch will rebase on pull.\n");
+ }
+ free(tracking.src);
return 0;
}
diff --git a/builtin-apply.c b/builtin-apply.c
index 30d26e57b3..1103625a4a 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2247,7 +2247,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
* In such a case, path "new_name" does not exist as
* far as git is concerned.
*/
- if (has_symlink_leading_path(new_name, NULL))
+ if (has_symlink_leading_path(strlen(new_name), new_name))
return 0;
return error("%s: already exists in working directory", new_name);
@@ -2981,12 +2981,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
static int git_apply_config(const char *var, const char *value)
{
- if (!strcmp(var, "apply.whitespace")) {
- if (!value)
- return config_error_nonbool(var);
- apply_default_whitespace = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "apply.whitespace"))
+ return git_config_string(&apply_default_whitespace, var, value);
return git_default_config(var, value);
}
diff --git a/builtin-branch.c b/builtin-branch.c
index 5bc4526f64..19c508a608 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -15,7 +15,7 @@
#include "branch.h"
static const char * const builtin_branch_usage[] = {
- "git-branch [options] [-r | -a]",
+ "git-branch [options] [-r | -a] [--merged | --no-merged]",
"git-branch [options] [-l] [-f] <branchname> [<start-point>]",
"git-branch [options] [-r] (-d | -D) <branchname>",
"git-branch [options] (-m | -M) [<oldbranch>] <newbranch>",
@@ -46,6 +46,8 @@ enum color_branch {
COLOR_BRANCH_CURRENT = 4,
};
+static int mergefilter = -1;
+
static int parse_branch_color_slot(const char *var, int ofs)
{
if (!strcasecmp(var+ofs, "plain"))
@@ -210,6 +212,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
struct ref_item *newitem;
int kind = REF_UNKNOWN_TYPE;
int len;
+ static struct commit_list branch;
/* Detect kind */
if (!prefixcmp(refname, "refs/heads/")) {
@@ -231,6 +234,16 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
if ((kind & ref_list->kinds) == 0)
return 0;
+ if (mergefilter > -1) {
+ branch.item = lookup_commit_reference_gently(sha1, 1);
+ if (!branch.item)
+ die("Unable to lookup tip of branch %s", refname);
+ if (mergefilter == 0 && has_commit(head_sha1, &branch))
+ return 0;
+ if (mergefilter == 1 && !has_commit(head_sha1, &branch))
+ return 0;
+ }
+
/* Resize buffer */
if (ref_list->index >= ref_list->alloc) {
ref_list->alloc = alloc_nr(ref_list->alloc);
@@ -444,6 +457,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"),
OPT_BOOLEAN('f', NULL, &force_create, "force creation (when already exists)"),
+ OPT_SET_INT(0, "merged", &mergefilter, "list only merged branches", 1),
OPT_END(),
};
diff --git a/builtin-checkout.c b/builtin-checkout.c
index cf9875c13d..10ec137cce 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -504,7 +504,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT__QUIET(&opts.quiet),
OPT_STRING('b', NULL, &opts.new_branch, "new branch", "branch"),
OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "log for new branch"),
- OPT_SET_INT( 0 , "track", &opts.track, "track",
+ OPT_SET_INT('t', "track", &opts.track, "track",
BRANCH_TRACK_EXPLICIT),
OPT_BOOLEAN('f', NULL, &opts.force, "force"),
OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
diff --git a/builtin-commit.c b/builtin-commit.c
index e3564a526a..0baec6db6a 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -47,6 +47,7 @@ static enum {
static char *logfile, *force_author, *template_file;
static char *edit_message, *use_message;
+static char *author_name, *author_email, *author_date;
static int all, edit_flag, also, interactive, only, amend, signoff;
static int quiet, verbose, untracked_files, no_verify, allow_empty;
/*
@@ -175,9 +176,11 @@ static void add_remove_files(struct path_list *list)
{
int i;
for (i = 0; i < list->nr; i++) {
+ struct stat st;
struct path_list_item *p = &(list->items[i]);
- if (file_exists(p->path))
- add_file_to_cache(p->path, 0);
+
+ if (!lstat(p->path, &st))
+ add_to_cache(p->path, &st, 0);
else
remove_file_from_cache(p->path);
}
@@ -395,6 +398,47 @@ static int is_a_merge(const unsigned char *sha1)
static const char sign_off_header[] = "Signed-off-by: ";
+static void determine_author_info(void)
+{
+ char *name, *email, *date;
+
+ name = getenv("GIT_AUTHOR_NAME");
+ email = getenv("GIT_AUTHOR_EMAIL");
+ date = getenv("GIT_AUTHOR_DATE");
+
+ if (use_message) {
+ const char *a, *lb, *rb, *eol;
+
+ a = strstr(use_message_buffer, "\nauthor ");
+ if (!a)
+ die("invalid commit: %s", use_message);
+
+ lb = strstr(a + 8, " <");
+ rb = strstr(a + 8, "> ");
+ eol = strchr(a + 8, '\n');
+ if (!lb || !rb || !eol)
+ die("invalid commit: %s", use_message);
+
+ name = xstrndup(a + 8, lb - (a + 8));
+ email = xstrndup(lb + 2, rb - (lb + 2));
+ date = xstrndup(rb + 2, eol - (rb + 2));
+ }
+
+ if (force_author) {
+ const char *lb = strstr(force_author, " <");
+ const char *rb = strchr(force_author, '>');
+
+ if (!lb || !rb)
+ die("malformed --author parameter");
+ name = xstrndup(force_author, lb - force_author);
+ email = xstrndup(lb + 2, rb - (lb + 2));
+ }
+
+ author_name = name;
+ author_email = email;
+ author_date = date;
+}
+
static int prepare_to_commit(const char *index_file, const char *prefix)
{
struct stat statbuf;
@@ -404,6 +448,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
FILE *fp;
const char *hook_arg1 = NULL;
const char *hook_arg2 = NULL;
+ int ident_shown = 0;
if (!no_verify && run_hook(index_file, "pre-commit", NULL))
return 0;
@@ -483,7 +528,14 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
strbuf_release(&sb);
+ determine_author_info();
+
+ /* This checks if committer ident is explicitly given */
+ git_committer_info(0);
if (use_editor) {
+ char *author_ident;
+ const char *committer_ident;
+
if (in_merge)
fprintf(fp,
"#\n"
@@ -506,6 +558,27 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
if (only_include_assumed)
fprintf(fp, "# %s\n", only_include_assumed);
+ author_ident = xstrdup(fmt_name(author_name, author_email));
+ committer_ident = fmt_name(getenv("GIT_COMMITTER_NAME"),
+ getenv("GIT_COMMITTER_EMAIL"));
+ if (strcmp(author_ident, committer_ident))
+ fprintf(fp,
+ "%s"
+ "# Author: %s\n",
+ ident_shown++ ? "" : "#\n",
+ author_ident);
+ free(author_ident);
+
+ if (!user_ident_explicitly_given)
+ fprintf(fp,
+ "%s"
+ "# Committer: %s\n",
+ ident_shown++ ? "" : "#\n",
+ committer_ident);
+
+ if (ident_shown)
+ fprintf(fp, "#\n");
+
saved_color_setting = wt_status_use_color;
wt_status_use_color = 0;
commitable = run_status(fp, index_file, prefix, 1);
@@ -622,45 +695,6 @@ static int message_is_empty(struct strbuf *sb, int start)
return 1;
}
-static void determine_author_info(struct strbuf *sb)
-{
- char *name, *email, *date;
-
- name = getenv("GIT_AUTHOR_NAME");
- email = getenv("GIT_AUTHOR_EMAIL");
- date = getenv("GIT_AUTHOR_DATE");
-
- if (use_message) {
- const char *a, *lb, *rb, *eol;
-
- a = strstr(use_message_buffer, "\nauthor ");
- if (!a)
- die("invalid commit: %s", use_message);
-
- lb = strstr(a + 8, " <");
- rb = strstr(a + 8, "> ");
- eol = strchr(a + 8, '\n');
- if (!lb || !rb || !eol)
- die("invalid commit: %s", use_message);
-
- name = xstrndup(a + 8, lb - (a + 8));
- email = xstrndup(lb + 2, rb - (lb + 2));
- date = xstrndup(rb + 2, eol - (rb + 2));
- }
-
- if (force_author) {
- const char *lb = strstr(force_author, " <");
- const char *rb = strchr(force_author, '>');
-
- if (!lb || !rb)
- die("malformed --author parameter");
- name = xstrndup(force_author, lb - force_author);
- email = xstrndup(lb + 2, rb - (lb + 2));
- }
-
- strbuf_addf(sb, "author %s\n", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));
-}
-
static int parse_and_validate_options(int argc, const char *argv[],
const char * const usage[])
{
@@ -745,10 +779,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
die("No paths with --include/--only does not make sense.");
if (argc == 0 && only && amend)
only_include_assumed = "Clever... amending the last one with dirty index.";
- if (argc > 0 && !also && !only) {
+ if (argc > 0 && !also && !only)
only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
- also = 0;
- }
if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
cleanup_mode = use_editor ? CLEANUP_ALL : CLEANUP_SPACE;
else if (!strcmp(cleanup_arg, "verbatim"))
@@ -810,7 +842,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
rev.verbose_header = 1;
rev.show_root_diff = 1;
- rev.commit_format = get_commit_format("format:%h: %s");
+ get_commit_format("format:%h: %s", &rev);
rev.always_show_header = 0;
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 100;
@@ -922,7 +954,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
strbuf_addf(&sb, "parent %s\n", sha1_to_hex(head_sha1));
}
- determine_author_info(&sb);
+ strbuf_addf(&sb, "author %s\n",
+ fmt_ident(author_name, author_email, author_date, IDENT_ERROR_ON_NO_NAME));
strbuf_addf(&sb, "committer %s\n", git_committer_info(IDENT_ERROR_ON_NO_NAME));
if (!is_encoding_utf8(git_commit_encoding))
strbuf_addf(&sb, "encoding %s\n", git_commit_encoding);
diff --git a/builtin-config.c b/builtin-config.c
index c34bc8b6a6..8ee01bdecd 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -3,7 +3,7 @@
#include "color.h"
static const char git_config_set_usage[] =
-"git-config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
+"git-config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
static char *key;
static regex_t *key_regexp;
@@ -16,7 +16,7 @@ static int seen;
static char delim = '=';
static char key_delim = ' ';
static char term = '\n';
-static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;
+static enum { T_RAW, T_INT, T_BOOL, T_BOOL_OR_INT } type = T_RAW;
static int show_all_config(const char *key_, const char *value_)
{
@@ -53,6 +53,14 @@ static int show_config(const char* key_, const char* value_)
sprintf(value, "%d", git_config_int(key_, value_?value_:""));
else if (type == T_BOOL)
vptr = git_config_bool(key_, value_) ? "true" : "false";
+ else if (type == T_BOOL_OR_INT) {
+ int is_bool, v;
+ v = git_config_bool_or_int(key_, value_, &is_bool);
+ if (is_bool)
+ vptr = v ? "true" : "false";
+ else
+ sprintf(value, "%d", v);
+ }
else
vptr = value_?value_:"";
seen++;
@@ -157,6 +165,14 @@ char *normalize_value(const char *key, const char *value)
else if (type == T_BOOL)
sprintf(normalized, "%s",
git_config_bool(key, value) ? "true" : "false");
+ else if (type == T_BOOL_OR_INT) {
+ int is_bool, v;
+ v = git_config_bool_or_int(key, value, &is_bool);
+ if (!is_bool)
+ sprintf(normalized, "%d", v);
+ else
+ sprintf(normalized, "%s", v ? "true" : "false");
+ }
}
return normalized;
@@ -224,6 +240,10 @@ static int git_get_colorbool_config(const char *var, const char *value)
get_diff_color_found =
git_config_colorbool(var, value, stdout_is_tty);
}
+ if (!strcmp(var, "color.ui")) {
+ git_use_color_default = git_config_colorbool(var, value, stdout_is_tty);
+ return 0;
+ }
return 0;
}
@@ -251,7 +271,7 @@ static int get_colorbool(int argc, const char **argv)
if (!strcmp(get_color_slot, "color.diff"))
get_colorbool_found = get_diff_color_found;
if (get_colorbool_found < 0)
- get_colorbool_found = 0;
+ get_colorbool_found = git_use_color_default;
}
if (argc == 1) {
@@ -273,6 +293,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
type = T_INT;
else if (!strcmp(argv[1], "--bool"))
type = T_BOOL;
+ else if (!strcmp(argv[1], "--bool-or-int"))
+ type = T_BOOL_OR_INT;
else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) {
if (argc != 2)
usage(git_config_set_usage);
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 167f948036..f6584ecea1 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -360,12 +360,10 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
if (ref)
update_local_ref(ref, what, verbose, note);
- else if (verbose)
+ else
sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
SUMMARY_WIDTH, *kind ? kind : "branch",
REFCOL_WIDTH, *what ? what : "HEAD");
- else
- *note = '\0';
if (*note) {
if (!shown_url) {
fprintf(stderr, "From %.*s\n",
@@ -510,10 +508,8 @@ static void find_non_local_tags(struct transport *transport,
will_fetch(head, ref->old_sha1))) {
path_list_insert(ref_name, &new_refs);
- rm = alloc_ref(strlen(ref_name) + 1);
- strcpy(rm->name, ref_name);
- rm->peer_ref = alloc_ref(strlen(ref_name) + 1);
- strcpy(rm->peer_ref->name, ref_name);
+ rm = alloc_ref_from_str(ref_name);
+ rm->peer_ref = alloc_ref_from_str(ref_name);
hashcpy(rm->old_sha1, ref_sha1);
**tail = rm;
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 7077d52477..b72cb59e6a 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -6,13 +6,18 @@
#include "tag.h"
static const char *fmt_merge_msg_usage =
- "git-fmt-merge-msg [--summary] [--no-summary] [--file <file>]";
+ "git-fmt-merge-msg [--log] [--no-log] [--file <file>]";
static int merge_summary;
static int fmt_merge_msg_config(const char *key, const char *value)
{
- if (!strcmp("merge.summary", key))
+ static int found_merge_log = 0;
+ if (!strcmp("merge.log", key)) {
+ found_merge_log = 1;
+ merge_summary = git_config_bool(key, value);
+ }
+ if (!found_merge_log && !strcmp("merge.summary", key))
merge_summary = git_config_bool(key, value);
return 0;
}
@@ -258,9 +263,10 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
git_config(fmt_merge_msg_config);
while (argc > 1) {
- if (!strcmp(argv[1], "--summary"))
+ if (!strcmp(argv[1], "--log") || !strcmp(argv[1], "--summary"))
merge_summary = 1;
- else if (!strcmp(argv[1], "--no-summary"))
+ else if (!strcmp(argv[1], "--no-log")
+ || !strcmp(argv[1], "--no-summary"))
merge_summary = 0;
else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
if (argc < 3)
diff --git a/builtin-gc.c b/builtin-gc.c
index 8cef36f6a4..f99ebc7926 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -157,6 +157,34 @@ static int too_many_packs(void)
return gc_auto_pack_limit <= cnt;
}
+static int run_hook(void)
+{
+ const char *argv[2];
+ struct child_process hook;
+ int ret;
+
+ argv[0] = git_path("hooks/pre-auto-gc");
+ argv[1] = NULL;
+
+ if (access(argv[0], X_OK) < 0)
+ return 0;
+
+ memset(&hook, 0, sizeof(hook));
+ hook.argv = argv;
+ hook.no_stdin = 1;
+ hook.stdout_to_stderr = 1;
+
+ ret = start_command(&hook);
+ if (ret) {
+ warning("Could not spawn %s", argv[0]);
+ return ret;
+ }
+ ret = finish_command(&hook);
+ if (ret == -ERR_RUN_COMMAND_WAITPID_SIGNAL)
+ warning("%s exited due to uncaught signal", argv[0]);
+ return ret;
+}
+
static int need_to_gc(void)
{
/*
@@ -176,6 +204,9 @@ static int need_to_gc(void)
append_option(argv_repack, "-A", MAX_ADD);
else if (!too_many_loose_objects())
return 0;
+
+ if (run_hook())
+ return 0;
return 1;
}
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 2854868b4e..a76f5d3474 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -400,9 +400,16 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
char buf[10];
/* We do not spell "group" and such, so that
* the configuration can be read by older version
- * of git.
+ * of git. Note, we use octal numbers for new share modes,
+ * and compatibility values for PERM_GROUP and
+ * PERM_EVERYBODY.
*/
- sprintf(buf, "%d", shared_repository);
+ if (shared_repository == PERM_GROUP)
+ sprintf(buf, "%d", OLD_PERM_GROUP);
+ else if (shared_repository == PERM_EVERYBODY)
+ sprintf(buf, "%d", OLD_PERM_EVERYBODY);
+ else
+ sprintf(buf, "0%o", shared_repository);
git_config_set("core.sharedrepository", buf);
git_config_set("receive.denyNonFastforwards", "true");
}
diff --git a/builtin-log.c b/builtin-log.c
index 5c00725f03..9d046b2e03 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -56,7 +56,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
rev->abbrev = DEFAULT_ABBREV;
rev->commit_format = CMIT_FMT_DEFAULT;
if (fmt_pretty)
- rev->commit_format = get_commit_format(fmt_pretty);
+ get_commit_format(fmt_pretty, rev);
rev->verbose_header = 1;
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
rev->show_root_diff = default_show_root;
@@ -400,6 +400,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
* allow us to set a different default.
*/
rev.commit_format = CMIT_FMT_ONELINE;
+ rev.use_terminator = 1;
rev.always_show_header = 1;
/*
@@ -484,6 +485,13 @@ static int git_format_config(const char *var, const char *value)
fmt_patch_suffix = xstrdup(value);
return 0;
}
+ if (!strcmp(var, "format.cc")) {
+ if (!value)
+ return config_error_nonbool(var);
+ ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc);
+ extra_cc[extra_cc_nr++] = xstrdup(value);
+ return 0;
+ }
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
return 0;
}
@@ -756,6 +764,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
int thread = 0;
int cover_letter = 0;
int boundary_count = 0;
+ int no_binary_diff = 0;
struct commit *origin = NULL, *head = NULL;
const char *in_reply_to = NULL;
struct patch_ids ids;
@@ -769,7 +778,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.diff = 1;
rev.combine_merges = 0;
rev.ignore_merges = 1;
- rev.diffopt.msg_sep = "";
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
rev.subject_prefix = fmt_patch_subject_prefix;
@@ -862,6 +870,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
fmt_patch_suffix = argv[i] + 9;
else if (!strcmp(argv[i], "--cover-letter"))
cover_letter = 1;
+ else if (!strcmp(argv[i], "--no-binary"))
+ no_binary_diff = 1;
else
argv[j++] = argv[i];
}
@@ -914,7 +924,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
- if (!DIFF_OPT_TST(&rev.diffopt, TEXT))
+ if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
DIFF_OPT_SET(&rev.diffopt, BINARY);
if (!output_directory && !use_stdout)
diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c
index 910c0d20e7..46e636fdcf 100644
--- a/builtin-merge-recursive.c
+++ b/builtin-merge-recursive.c
@@ -92,7 +92,8 @@ static struct path_list current_directory_set = {NULL, 0, 0, 1};
static int call_depth = 0;
static int verbosity = 2;
-static int rename_limit = -1;
+static int diff_rename_limit = -1;
+static int merge_rename_limit = -1;
static int buffer_output = 1;
static struct strbuf obuf = STRBUF_INIT;
@@ -361,7 +362,10 @@ static struct path_list *get_renames(struct tree *tree,
diff_setup(&opts);
DIFF_OPT_SET(&opts, RECURSIVE);
opts.detect_rename = DIFF_DETECT_RENAME;
- opts.rename_limit = rename_limit;
+ opts.rename_limit = merge_rename_limit >= 0 ? merge_rename_limit :
+ diff_rename_limit >= 0 ? diff_rename_limit :
+ 500;
+ opts.warn_on_too_large_rename = 1;
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
if (diff_setup_done(&opts) < 0)
die("diff setup failed");
@@ -1343,7 +1347,11 @@ static int merge_config(const char *var, const char *value)
return 0;
}
if (!strcasecmp(var, "diff.renamelimit")) {
- rename_limit = git_config_int(var, value);
+ diff_rename_limit = git_config_int(var, value);
+ return 0;
+ }
+ if (!strcasecmp(var, "merge.renamelimit")) {
+ merge_rename_limit = git_config_int(var, value);
return 0;
}
return git_default_config(var, value);
diff --git a/builtin-push.c b/builtin-push.c
index b68c6813b8..b35aad68e9 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -56,6 +56,17 @@ static int do_push(const char *repo, int flags)
if (!remote)
die("bad repository '%s'", repo);
+ if (remote->mirror)
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
+
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
+ return -1;
+
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
+ (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
+ return error("--all and --mirror are incompatible");
+ }
+
if (!refspec
&& !(flags & TRANSPORT_PUSH_ALL)
&& remote->push_refspec_nr) {
@@ -95,6 +106,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
int dry_run = 0;
int force = 0;
int tags = 0;
+ int rc;
const char *repo = NULL; /* default repository */
struct option options[] = {
@@ -130,14 +142,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
- usage_with_options(push_usage, options);
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
- (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
- error("--all and --mirror are incompatible");
+ rc = do_push(repo, flags);
+ if (rc == -1)
usage_with_options(push_usage, options);
- }
-
- return do_push(repo, flags);
+ else
+ return rc;
}
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index e9cfd2bbc5..7ac30883bc 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -40,7 +40,7 @@ static int read_cache_unmerged(void)
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce)) {
- remove_index_entry(ce);
+ remove_name_hash(ce);
if (last && !strcmp(ce->name, last->name))
continue;
cache_tree_invalidate_path(active_cache_tree, ce->name);
diff --git a/builtin-remote.c b/builtin-remote.c
index 4149f3b3ce..8b63619ef0 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -19,6 +19,8 @@ static const char * const builtin_remote_usage[] = {
static int verbose;
+static int show_all(void);
+
static inline int postfixcmp(const char *string, const char *postfix)
{
int len1 = strlen(string), len2 = strlen(postfix);
@@ -116,6 +118,13 @@ static int add(int argc, const char **argv)
return 1;
}
+ if (mirror) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "remote.%s.mirror", name);
+ if (git_config_set(buf.buf, "yes"))
+ return 1;
+ }
+
if (fetch && fetch_remote(name))
return 1;
@@ -385,8 +394,11 @@ static int show_or_prune(int argc, const char **argv, int prune)
argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
- if (argc < 1)
+ if (argc < 1) {
+ if (!prune)
+ return show_all();
usage_with_options(builtin_remote_usage, options);
+ }
memset(&states, 0, sizeof(states));
for (; argc; argc--, argv++) {
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 0351d54435..f8d8548e9c 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -28,8 +28,6 @@ static int symbolic;
static int abbrev;
static int output_sq;
-static int revs_count;
-
/*
* Some arguments are relevant "revision" arguments,
* others are about output format or other details.
@@ -102,7 +100,6 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
if (!(filter & DO_REVS))
return;
def = NULL;
- revs_count++;
if (type != show_type)
putchar('^');
@@ -150,7 +147,7 @@ static int show_flag(const char *arg)
return 0;
}
-static void show_default(void)
+static int show_default(void)
{
const char *s = def;
@@ -160,9 +157,10 @@ static void show_default(void)
def = NULL;
if (!get_sha1(s, sha1)) {
show_rev(NORMAL, sha1, s);
- return;
+ return 1;
}
}
+ return 0;
}
static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
@@ -365,10 +363,19 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
return 0;
}
+static void die_no_single_rev(int quiet)
+{
+ if (quiet)
+ exit(1);
+ else
+ die("Needed a single revision");
+}
+
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
{
- int i, as_is = 0, verify = 0;
+ int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
unsigned char sha1[20];
+ const char *name = NULL;
if (argc > 1 && !strcmp("--parseopt", argv[1]))
return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -432,6 +439,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
verify = 1;
continue;
}
+ if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
+ quiet = 1;
+ continue;
+ }
if (!strcmp(arg, "--short") ||
!prefixcmp(arg, "--short=")) {
filter &= ~(DO_FLAGS|DO_NOREV);
@@ -549,30 +560,41 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (show_flag(arg) && verify)
- die("Needed a single revision");
+ die_no_single_rev(quiet);
continue;
}
/* Not a flag argument */
if (try_difference(arg))
continue;
- if (!get_sha1(arg, sha1)) {
- show_rev(NORMAL, sha1, arg);
- continue;
+ name = arg;
+ type = NORMAL;
+ if (*arg == '^') {
+ name++;
+ type = REVERSED;
}
- if (*arg == '^' && !get_sha1(arg+1, sha1)) {
- show_rev(REVERSED, sha1, arg+1);
+ if (!get_sha1(name, sha1)) {
+ if (verify)
+ revs_count++;
+ else
+ show_rev(type, sha1, name);
continue;
}
+ if (verify)
+ die_no_single_rev(quiet);
as_is = 1;
if (!show_file(arg))
continue;
- if (verify)
- die("Needed a single revision");
verify_filename(prefix, arg);
}
- show_default();
- if (verify && revs_count != 1)
- die("Needed a single revision");
+ if (verify) {
+ if (revs_count == 1) {
+ show_rev(type, sha1, name);
+ return 0;
+ } else if (revs_count == 0 && show_default())
+ return 0;
+ die_no_single_rev(quiet);
+ } else
+ show_default();
return 0;
}
diff --git a/builtin-revert.c b/builtin-revert.c
index 607a2f0337..2b57525d72 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -33,7 +33,7 @@ static const char * const cherry_pick_usage[] = {
NULL
};
-static int edit, no_replay, no_commit, mainline;
+static int edit, no_replay, no_commit, mainline, signoff;
static enum { REVERT, CHERRY_PICK } action;
static struct commit *commit;
@@ -53,6 +53,7 @@ static void parse_args(int argc, const char **argv)
OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
OPT_BOOLEAN('x', NULL, &no_replay, "append commit name when cherry-picking"),
OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
+ OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
OPT_END(),
};
@@ -404,10 +405,19 @@ static int revert_or_cherry_pick(int argc, const char **argv)
*/
if (!no_commit) {
- if (edit)
- return execl_git_cmd("commit", "-n", NULL);
- else
- return execl_git_cmd("commit", "-n", "-F", defmsg, NULL);
+ /* 6 is max possible length of our args array including NULL */
+ const char *args[6];
+ int i = 0;
+ args[i++] = "commit";
+ args[i++] = "-n";
+ if (signoff)
+ args[i++] = "-s";
+ if (!edit) {
+ args[i++] = "-F";
+ args[i++] = defmsg;
+ }
+ args[i] = NULL;
+ return execv_git_cmd(args);
}
free(reencoded_message);
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 50e07faa12..fecf0be779 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -7,11 +7,13 @@
#include "commit.h"
#include "tag.h"
#include "tree.h"
+#include "tree-walk.h"
#include "progress.h"
#include "decorate.h"
+#include "fsck.h"
-static int dry_run, quiet, recover, has_errors;
-static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";
+static int dry_run, quiet, recover, has_errors, strict;
+static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] [--strict] < pack-file";
/* We always read in 4kB chunks. */
static unsigned char buffer[4096];
@@ -19,6 +21,11 @@ static unsigned int offset, len;
static off_t consumed_bytes;
static SHA_CTX ctx;
+/*
+ * When running under --strict mode, objects whose reachability are
+ * suspect are kept in core without getting written in the object
+ * store.
+ */
struct obj_buffer {
char *buffer;
unsigned long size;
@@ -31,6 +38,16 @@ static struct obj_buffer *lookup_object_buffer(struct object *base)
return lookup_decoration(&obj_decorate, base);
}
+static void add_object_buffer(struct object *object, char *buffer, unsigned long size)
+{
+ struct obj_buffer *obj;
+ obj = xcalloc(1, sizeof(struct obj_buffer));
+ obj->buffer = buffer;
+ obj->size = size;
+ if (add_decoration(&obj_decorate, object, obj))
+ die("object %s tried to add buffer twice!", sha1_to_hex(object->sha1));
+}
+
/*
* Make sure at least "min" bytes are available in the buffer, and
* return the pointer to the buffer.
@@ -134,19 +151,110 @@ static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1,
struct obj_info {
off_t offset;
unsigned char sha1[20];
+ struct object *obj;
};
+#define FLAG_OPEN (1u<<20)
+#define FLAG_WRITTEN (1u<<21)
+
static struct obj_info *obj_list;
+unsigned nr_objects;
+
+/*
+ * Called only from check_object() after it verified this object
+ * is Ok.
+ */
+static void write_cached_object(struct object *obj)
+{
+ unsigned char sha1[20];
+ struct obj_buffer *obj_buf = lookup_object_buffer(obj);
+ if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0)
+ die("failed to write object %s", sha1_to_hex(obj->sha1));
+ obj->flags |= FLAG_WRITTEN;
+}
+
+/*
+ * At the very end of the processing, write_rest() scans the objects
+ * that have reachability requirements and calls this function.
+ * Verify its reachability and validity recursively and write it out.
+ */
+static int check_object(struct object *obj, int type, void *data)
+{
+ if (!obj)
+ return 0;
+
+ if (obj->flags & FLAG_WRITTEN)
+ return 1;
+
+ if (type != OBJ_ANY && obj->type != type)
+ die("object type mismatch");
+
+ if (!(obj->flags & FLAG_OPEN)) {
+ unsigned long size;
+ int type = sha1_object_info(obj->sha1, &size);
+ if (type != obj->type || type <= 0)
+ die("object of unexpected type");
+ obj->flags |= FLAG_WRITTEN;
+ return 1;
+ }
+
+ if (fsck_object(obj, 1, fsck_error_function))
+ die("Error in object");
+ if (!fsck_walk(obj, check_object, 0))
+ die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
+ write_cached_object(obj);
+ return 1;
+}
+
+static void write_rest(void)
+{
+ unsigned i;
+ for (i = 0; i < nr_objects; i++)
+ check_object(obj_list[i].obj, OBJ_ANY, 0);
+}
static void added_object(unsigned nr, enum object_type type,
void *data, unsigned long size);
+/*
+ * Write out nr-th object from the list, now we know the contents
+ * of it. Under --strict, this buffers structured objects in-core,
+ * to be checked at the end.
+ */
static void write_object(unsigned nr, enum object_type type,
void *buf, unsigned long size)
{
- if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
- die("failed to write object");
- added_object(nr, type, buf, size);
+ if (!strict) {
+ if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
+ die("failed to write object");
+ added_object(nr, type, buf, size);
+ free(buf);
+ obj_list[nr].obj = NULL;
+ } else if (type == OBJ_BLOB) {
+ struct blob *blob;
+ if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
+ die("failed to write object");
+ added_object(nr, type, buf, size);
+ free(buf);
+
+ blob = lookup_blob(obj_list[nr].sha1);
+ if (blob)
+ blob->object.flags |= FLAG_WRITTEN;
+ else
+ die("invalid blob object");
+ obj_list[nr].obj = NULL;
+ } else {
+ struct object *obj;
+ int eaten;
+ hash_sha1_file(buf, size, typename(type), obj_list[nr].sha1);
+ added_object(nr, type, buf, size);
+ obj = parse_object_buffer(obj_list[nr].sha1, type, size, buf, &eaten);
+ if (!obj)
+ die("invalid %s", typename(type));
+ add_object_buffer(obj, buf, size);
+ obj->flags |= FLAG_OPEN;
+ obj_list[nr].obj = obj;
+ }
}
static void resolve_delta(unsigned nr, enum object_type type,
@@ -163,9 +271,12 @@ static void resolve_delta(unsigned nr, enum object_type type,
die("failed to apply delta");
free(delta);
write_object(nr, type, result, result_size);
- free(result);
}
+/*
+ * We now know the contents of an object (which is nr-th in the pack);
+ * resolve all the deltified objects that are based on it.
+ */
static void added_object(unsigned nr, enum object_type type,
void *data, unsigned long size)
{
@@ -193,7 +304,24 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,
if (!dry_run && buf)
write_object(nr, type, buf, size);
- free(buf);
+ else
+ free(buf);
+}
+
+static int resolve_against_held(unsigned nr, const unsigned char *base,
+ void *delta_data, unsigned long delta_size)
+{
+ struct object *obj;
+ struct obj_buffer *obj_buffer;
+ obj = lookup_object(base);
+ if (!obj)
+ return 0;
+ obj_buffer = lookup_object_buffer(obj);
+ if (!obj_buffer)
+ return 0;
+ resolve_delta(nr, obj->type, obj_buffer->buffer,
+ obj_buffer->size, delta_data, delta_size);
+ return 1;
}
static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
@@ -202,7 +330,6 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
void *delta_data, *base;
unsigned long base_size;
unsigned char base_sha1[20];
- struct object *obj;
if (type == OBJ_REF_DELTA) {
hashcpy(base_sha1, fill(20));
@@ -212,7 +339,13 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
free(delta_data);
return;
}
- if (!has_sha1_file(base_sha1)) {
+ if (has_sha1_file(base_sha1))
+ ; /* Ok we have this one */
+ else if (resolve_against_held(nr, base_sha1,
+ delta_data, delta_size))
+ return; /* we are done */
+ else {
+ /* cannot resolve yet --- queue it */
hashcpy(obj_list[nr].sha1, null_sha1);
add_delta_to_list(nr, base_sha1, 0, delta_data, delta_size);
return;
@@ -258,22 +391,18 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
}
}
if (!base_found) {
- /* The delta base object is itself a delta that
- has not been resolved yet. */
+ /*
+ * The delta base object is itself a delta that
+ * has not been resolved yet.
+ */
hashcpy(obj_list[nr].sha1, null_sha1);
add_delta_to_list(nr, null_sha1, base_offset, delta_data, delta_size);
return;
}
}
- obj = lookup_object(base_sha1);
- if (obj) {
- struct obj_buffer *obj_buf = lookup_object_buffer(obj);
- if (obj_buf) {
- resolve_delta(nr, obj->type, obj_buf->buffer, obj_buf->size, delta_data, delta_size);
- return;
- }
- }
+ if (resolve_against_held(nr, base_sha1, delta_data, delta_size))
+ return;
base = read_sha1_file(base_sha1, &type, &base_size);
if (!base) {
@@ -336,7 +465,8 @@ static void unpack_all(void)
int i;
struct progress *progress = NULL;
struct pack_header *hdr = fill(sizeof(struct pack_header));
- unsigned nr_objects = ntohl(hdr->hdr_entries);
+
+ nr_objects = ntohl(hdr->hdr_entries);
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
die("bad pack file");
@@ -347,6 +477,7 @@ static void unpack_all(void)
if (!quiet)
progress = start_progress("Unpacking objects", nr_objects);
obj_list = xmalloc(nr_objects * sizeof(*obj_list));
+ memset(obj_list, 0, nr_objects * sizeof(*obj_list));
for (i = 0; i < nr_objects; i++) {
unpack_one(i);
display_progress(progress, i + 1);
@@ -382,6 +513,10 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
recover = 1;
continue;
}
+ if (!strcmp(arg, "--strict")) {
+ strict = 1;
+ continue;
+ }
if (!prefixcmp(arg, "--pack_header=")) {
struct pack_header *hdr;
char *c;
@@ -407,6 +542,8 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
unpack_all();
SHA1_Update(&ctx, buffer, offset);
SHA1_Final(sha1, &ctx);
+ if (strict)
+ write_rest();
if (hashcmp(fill(20), sha1))
die("final sha1 did not match");
use(20);
diff --git a/cache.h b/cache.h
index 2a1e7ec6b2..093f04cec0 100644
--- a/cache.h
+++ b/cache.h
@@ -133,6 +133,7 @@ struct cache_entry {
#define CE_UPDATE (0x10000)
#define CE_REMOVE (0x20000)
#define CE_UPTODATE (0x40000)
+#define CE_ADDED (0x80000)
#define CE_HASHED (0x100000)
#define CE_UNHASHED (0x200000)
@@ -153,20 +154,6 @@ static inline void copy_cache_entry(struct cache_entry *dst, struct cache_entry
dst->ce_flags = (dst->ce_flags & ~CE_STATE_MASK) | state;
}
-/*
- * We don't actually *remove* it, we can just mark it invalid so that
- * we won't find it in lookups.
- *
- * Not only would we have to search the lists (simple enough), but
- * we'd also have to rehash other hash buckets in case this makes the
- * hash bucket empty (common). So it's much better to just mark
- * it.
- */
-static inline void remove_index_entry(struct cache_entry *ce)
-{
- ce->ce_flags |= CE_UNHASHED;
-}
-
static inline unsigned create_ce_flags(size_t len, unsigned stage)
{
if (len >= CE_NAMEMASK)
@@ -241,6 +228,23 @@ struct index_state {
extern struct index_state the_index;
+/* Name hashing */
+extern void add_name_hash(struct index_state *istate, struct cache_entry *ce);
+/*
+ * We don't actually *remove* it, we can just mark it invalid so that
+ * we won't find it in lookups.
+ *
+ * Not only would we have to search the lists (simple enough), but
+ * we'd also have to rehash other hash buckets in case this makes the
+ * hash bucket empty (common). So it's much better to just mark
+ * it.
+ */
+static inline void remove_name_hash(struct cache_entry *ce)
+{
+ ce->ce_flags |= CE_UNHASHED;
+}
+
+
#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
#define active_cache (the_index.cache)
#define active_nr (the_index.cache_nr)
@@ -257,11 +261,12 @@ extern struct index_state the_index;
#define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))
#define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
#define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
+#define add_to_cache(path, st, verbose) add_to_index(&the_index, (path), (st), (verbose))
#define add_file_to_cache(path, verbose) add_file_to_index(&the_index, (path), (verbose))
#define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL)
#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
#define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
-#define cache_name_exists(name, namelen) index_name_exists(&the_index, (name), (namelen))
+#define cache_name_exists(name, namelen, igncase) index_name_exists(&the_index, (name), (namelen), (igncase))
#endif
enum object_type {
@@ -311,6 +316,7 @@ extern char *get_index_file(void);
extern char *get_graft_file(void);
extern int set_git_dir(const char *path);
extern const char *get_git_work_tree(void);
+extern const char *read_gitfile_gently(const char *path);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
@@ -350,7 +356,7 @@ extern int write_index(const struct index_state *, int newfd);
extern int discard_index(struct index_state *);
extern int unmerged_index(const struct index_state *);
extern int verify_path(const char *path);
-extern int index_name_exists(struct index_state *istate, const char *name, int namelen);
+extern struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen, int igncase);
extern int index_name_pos(const struct index_state *, const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
@@ -360,6 +366,7 @@ extern int add_index_entry(struct index_state *, struct cache_entry *ce, int opt
extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
extern int remove_index_entry_at(struct index_state *, int pos);
extern int remove_file_from_index(struct index_state *, const char *path);
+extern int add_to_index(struct index_state *, const char *path, struct stat *, int verbose);
extern int add_file_to_index(struct index_state *, const char *path, int verbose);
extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);
extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
@@ -404,6 +411,7 @@ extern int delete_ref(const char *, const unsigned char *sha1);
extern int trust_executable_bit;
extern int quote_path_fully;
extern int has_symlinks;
+extern int ignore_case;
extern int assume_unchanged;
extern int prefer_symlink_refs;
extern int log_all_ref_updates;
@@ -433,7 +441,15 @@ enum branch_track {
BRANCH_TRACK_EXPLICIT,
};
+enum rebase_setup_type {
+ AUTOREBASE_NEVER = 0,
+ AUTOREBASE_LOCAL,
+ AUTOREBASE_REMOTE,
+ AUTOREBASE_ALWAYS,
+};
+
extern enum branch_track git_branch_track;
+extern enum rebase_setup_type autorebase;
#define GIT_REPO_VERSION 0
extern int repository_format_version;
@@ -474,10 +490,20 @@ static inline void hashclr(unsigned char *hash)
int git_mkstemp(char *path, size_t n, const char *template);
+/*
+ * NOTE NOTE NOTE!!
+ *
+ * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must
+ * not be changed. Old repositories have core.sharedrepository written in
+ * numeric format, and therefore these values are preserved for compatibility
+ * reasons.
+ */
enum sharedrepo {
- PERM_UMASK = 0,
- PERM_GROUP,
- PERM_EVERYBODY
+ PERM_UMASK = 0,
+ OLD_PERM_GROUP = 1,
+ OLD_PERM_EVERYBODY = 2,
+ PERM_GROUP = 0660,
+ PERM_EVERYBODY = 0664,
};
int git_config_perm(const char *var, const char *value);
int adjust_shared_perm(const char *path);
@@ -580,7 +606,7 @@ struct checkout {
};
extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);
-extern int has_symlink_leading_path(const char *name, char *last_symlink);
+extern int has_symlink_leading_path(int len, const char *name);
extern struct alternate_object_database {
struct alternate_object_database *next;
@@ -624,6 +650,7 @@ struct ref {
struct ref *next;
unsigned char old_sha1[20];
unsigned char new_sha1[20];
+ char *symref;
unsigned int force:1,
merge:1,
nonfastforward:1,
@@ -692,6 +719,7 @@ extern int git_parse_long(const char *, long *);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_config_int(const char *, const char *);
extern unsigned long git_config_ulong(const char *, const char *);
+extern int git_config_bool_or_int(const char *, const char *, int *);
extern int git_config_bool(const char *, const char *);
extern int git_config_string(const char **, const char *, const char *);
extern int git_config_set(const char *, const char *);
@@ -707,6 +735,7 @@ extern int config_error_nonbool(const char *);
#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
extern char git_default_name[MAX_GITNAME];
+extern int user_ident_explicitly_given;
extern const char *git_commit_encoding;
extern const char *git_log_output_encoding;
@@ -715,8 +744,8 @@ extern const char *git_log_output_encoding;
extern void maybe_flush_or_die(FILE *, const char *);
extern int copy_fd(int ifd, int ofd);
extern int copy_file(const char *dst, const char *src, int mode);
-extern int read_in_full(int fd, void *buf, size_t count);
-extern int write_in_full(int fd, const void *buf, size_t count);
+extern ssize_t read_in_full(int fd, void *buf, size_t count);
+extern ssize_t write_in_full(int fd, const void *buf, size_t count);
extern void write_or_die(int fd, const void *buf, size_t count);
extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
diff --git a/combine-diff.c b/combine-diff.c
index 0e19cbaacc..588c58bc55 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -701,7 +701,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
else if (0 <= (fd = open(elem->path, O_RDONLY)) &&
!fstat(fd, &st)) {
size_t len = xsize_t(st.st_size);
- size_t sz = 0;
+ ssize_t done;
int is_file, i;
elem->mode = canon_mode(st.st_mode);
@@ -716,14 +716,13 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
result_size = len;
result = xmalloc(len + 1);
- while (sz < len) {
- ssize_t done = xread(fd, result+sz, len-sz);
- if (done == 0)
- break;
- if (done < 0)
- die("read error '%s'", elem->path);
- sz += done;
- }
+
+ done = read_in_full(fd, result, len);
+ if (done < 0)
+ die("read error '%s'", elem->path);
+ else if (done < len)
+ die("early EOF '%s'", elem->path);
+
result[len] = 0;
}
else {
@@ -798,7 +797,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
int deleted = 0;
if (rev->loginfo && !rev->no_commit_id)
- show_log(rev, opt->msg_sep);
+ show_log(rev);
dump_quoted_path(dense ? "diff --cc " : "diff --combined ",
"", elem->path, c_meta, c_reset);
printf("%sindex ", c_meta);
@@ -881,7 +880,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
inter_name_termination = 0;
if (rev->loginfo && !rev->no_commit_id)
- show_log(rev, opt->msg_sep);
+ show_log(rev);
if (opt->output_format & DIFF_FORMAT_RAW) {
offset = strlen(COLONS) - num_parent;
@@ -962,7 +961,7 @@ void diff_tree_combined(const unsigned char *sha1,
paths = intersect_paths(paths, i, num_parent);
if (show_log_first && i == 0) {
- show_log(rev, opt->msg_sep);
+ show_log(rev);
if (rev->verbose_header && opt->output_format)
putchar(opt->line_termination);
}
diff --git a/commit.h b/commit.h
index 2f63bc8b2f..2d94d4148e 100644
--- a/commit.h
+++ b/commit.h
@@ -63,7 +63,8 @@ enum cmit_fmt {
};
extern int non_ascii(int);
-extern enum cmit_fmt get_commit_format(const char *arg);
+struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
+extern void get_commit_format(const char *arg, struct rev_info *);
extern void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb);
extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
diff --git a/compat/fopen.c b/compat/fopen.c
index ccb9e89fa4..b5ca142fed 100644
--- a/compat/fopen.c
+++ b/compat/fopen.c
@@ -1,5 +1,16 @@
+/*
+ * The order of the following two lines is important.
+ *
+ * FREAD_READS_DIRECTORIES is undefined before including git-compat-util.h
+ * to avoid the redefinition of fopen within git-compat-util.h. This is
+ * necessary since fopen is a macro on some platforms which may be set
+ * based on compiler options. For example, on AIX fopen is set to fopen64
+ * when _LARGE_FILES is defined. The previous technique of merely undefining
+ * fopen after including git-compat-util.h is inadequate in this case.
+ */
+#undef FREAD_READS_DIRECTORIES
#include "../git-compat-util.h"
-#undef fopen
+
FILE *git_fopen(const char *path, const char *mode)
{
FILE *fp;
diff --git a/config.c b/config.c
index 062449459e..5195de10c9 100644
--- a/config.c
+++ b/config.c
@@ -303,8 +303,9 @@ unsigned long git_config_ulong(const char *name, const char *value)
return ret;
}
-int git_config_bool(const char *name, const char *value)
+int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
{
+ *is_bool = 1;
if (!value)
return 1;
if (!*value)
@@ -313,7 +314,14 @@ int git_config_bool(const char *name, const char *value)
return 1;
if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
return 0;
- return git_config_int(name, value) != 0;
+ *is_bool = 0;
+ return git_config_int(name, value);
+}
+
+int git_config_bool(const char *name, const char *value)
+{
+ int discard;
+ return !!git_config_bool_or_int(name, value, &discard);
}
int git_config_string(const char **dest, const char *var, const char *value)
@@ -342,6 +350,11 @@ int git_default_config(const char *var, const char *value)
return 0;
}
+ if (!strcmp(var, "core.ignorecase")) {
+ ignore_case = git_config_bool(var, value);
+ return 0;
+ }
+
if (!strcmp(var, "core.bare")) {
is_bare_repository_cfg = git_config_bool(var, value);
return 0;
@@ -435,6 +448,8 @@ int git_default_config(const char *var, const char *value)
if (!value)
return config_error_nonbool(var);
strlcpy(git_default_name, value, sizeof(git_default_name));
+ if (git_default_email[0])
+ user_ident_explicitly_given = 1;
return 0;
}
@@ -442,6 +457,8 @@ int git_default_config(const char *var, const char *value)
if (!value)
return config_error_nonbool(var);
strlcpy(git_default_email, value, sizeof(git_default_email));
+ if (git_default_name[0])
+ user_ident_explicitly_given = 1;
return 0;
}
@@ -479,6 +496,21 @@ int git_default_config(const char *var, const char *value)
git_branch_track = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "branch.autosetuprebase")) {
+ if (!value)
+ return config_error_nonbool(var);
+ else if (!strcmp(value, "never"))
+ autorebase = AUTOREBASE_NEVER;
+ else if (!strcmp(value, "local"))
+ autorebase = AUTOREBASE_LOCAL;
+ else if (!strcmp(value, "remote"))
+ autorebase = AUTOREBASE_REMOTE;
+ else if (!strcmp(value, "always"))
+ autorebase = AUTOREBASE_ALWAYS;
+ else
+ return error("Malformed value for %s", var);
+ return 0;
+ }
/* Add other config variables here and to Documentation/config.txt. */
return 0;
@@ -599,11 +631,9 @@ static int store_aux(const char* key, const char* value)
case KEY_SEEN:
if (matches(key, value)) {
if (store.seen == 1 && store.multi_replace == 0) {
- fprintf(stderr,
- "Warning: %s has multiple values\n",
- key);
+ warning("%s has multiple values", key);
} else if (store.seen >= MAX_MATCHES) {
- fprintf(stderr, "Too many matches\n");
+ error("too many matches for %s", key);
return 1;
}
@@ -653,9 +683,9 @@ static int store_aux(const char* key, const char* value)
return 0;
}
-static int write_error(void)
+static int write_error(const char *filename)
{
- fprintf(stderr, "Failed to write new configuration file\n");
+ error("failed to write new configuration file %s", filename);
/* Same error code as "failed to rename". */
return 4;
@@ -672,7 +702,7 @@ static int store_write_section(int fd, const char* key)
if (dot) {
strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
for (i = dot - key + 1; i < store.baselen; i++) {
- if (key[i] == '"')
+ if (key[i] == '"' || key[i] == '\\')
strbuf_addch(&sb, '\\');
strbuf_addch(&sb, key[i]);
}
@@ -814,7 +844,7 @@ int git_config_set_multivar(const char* key, const char* value,
*/
if (last_dot == NULL) {
- fprintf(stderr, "key does not contain a section: %s\n", key);
+ error("key does not contain a section: %s", key);
ret = 2;
goto out_free;
}
@@ -834,14 +864,14 @@ int git_config_set_multivar(const char* key, const char* value,
/* Leave the extended basename untouched.. */
if (!dot || i > store.baselen) {
if (!iskeychar(c) || (i == store.baselen+1 && !isalpha(c))) {
- fprintf(stderr, "invalid key: %s\n", key);
+ error("invalid key: %s", key);
free(store.key);
ret = 1;
goto out_free;
}
c = tolower(c);
} else if (c == '\n') {
- fprintf(stderr, "invalid key (newline): %s\n", key);
+ error("invalid key (newline): %s", key);
free(store.key);
ret = 1;
goto out_free;
@@ -857,7 +887,7 @@ int git_config_set_multivar(const char* key, const char* value,
lock = xcalloc(sizeof(struct lock_file), 1);
fd = hold_lock_file_for_update(lock, config_filename, 0);
if (fd < 0) {
- fprintf(stderr, "could not lock config file\n");
+ error("could not lock config file %s", config_filename);
free(store.key);
ret = -1;
goto out_free;
@@ -904,8 +934,7 @@ int git_config_set_multivar(const char* key, const char* value,
store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
if (regcomp(store.value_regex, value_regex,
REG_EXTENDED)) {
- fprintf(stderr, "Invalid pattern: %s\n",
- value_regex);
+ error("invalid pattern: %s", value_regex);
free(store.value_regex);
ret = 6;
goto out_free;
@@ -923,7 +952,7 @@ int git_config_set_multivar(const char* key, const char* value,
* existing config file.
*/
if (git_config_from_file(store_aux, config_filename)) {
- fprintf(stderr, "invalid config file\n");
+ error("invalid config file %s", config_filename);
free(store.key);
if (store.value_regex != NULL) {
regfree(store.value_regex);
@@ -1002,7 +1031,7 @@ int git_config_set_multivar(const char* key, const char* value,
}
if (commit_lock_file(lock) < 0) {
- fprintf(stderr, "Cannot commit config file!\n");
+ error("could not commit config file %s", config_filename);
ret = 4;
goto out_free;
}
@@ -1023,7 +1052,7 @@ out_free:
return ret;
write_err_out:
- ret = write_error();
+ ret = write_error(lock->filename);
goto out_free;
}
@@ -1073,7 +1102,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
config_filename = xstrdup(config_filename);
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
if (out_fd < 0) {
- ret = error("Could not lock config file!");
+ ret = error("could not lock config file %s", config_filename);
goto out;
}
@@ -1097,7 +1126,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
}
store.baselen = strlen(new_name);
if (!store_write_section(out_fd, new_name)) {
- ret = write_error();
+ ret = write_error(lock->filename);
goto out;
}
continue;
@@ -1108,14 +1137,14 @@ int git_config_rename_section(const char *old_name, const char *new_name)
continue;
length = strlen(buf);
if (write_in_full(out_fd, buf, length) != length) {
- ret = write_error();
+ ret = write_error(lock->filename);
goto out;
}
}
fclose(config_file);
unlock_and_out:
if (commit_lock_file(lock) < 0)
- ret = error("Cannot commit config file!");
+ ret = error("could not commit config file %s", config_filename);
out:
free(config_filename);
return ret;
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6949cac45d..16984632d9 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -152,7 +152,7 @@ __git_heads ()
done
return
fi
- for i in $(git-ls-remote "$1" 2>/dev/null); do
+ for i in $(git ls-remote "$1" 2>/dev/null); do
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
@@ -173,7 +173,7 @@ __git_tags ()
done
return
fi
- for i in $(git-ls-remote "$1" 2>/dev/null); do
+ for i in $(git ls-remote "$1" 2>/dev/null); do
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
@@ -200,7 +200,7 @@ __git_refs ()
done
return
fi
- for i in $(git-ls-remote "$dir" 2>/dev/null); do
+ for i in $(git ls-remote "$dir" 2>/dev/null); do
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
@@ -223,7 +223,7 @@ __git_refs2 ()
__git_refs_remotes ()
{
local cmd i is_hash=y
- for i in $(git-ls-remote "$1" 2>/dev/null); do
+ for i in $(git ls-remote "$1" 2>/dev/null); do
case "$is_hash,$i" in
n,refs/heads/*)
is_hash=y
@@ -780,7 +780,7 @@ _git_merge ()
;;
--*)
__gitcomp "
- --no-commit --no-summary --squash --strategy
+ --no-commit --no-stat --log --no-log --squash --strategy
"
return
esac
@@ -1053,6 +1053,7 @@ _git_remote ()
local subcommands="add rm show prune update"
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
return
fi
@@ -1345,9 +1346,14 @@ _git ()
_gitk ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
+ local g="$(git rev-parse --git-dir 2>/dev/null)"
+ local merge=""
+ if [ -f $g/MERGE_HEAD ]; then
+ merge="--merge"
+ fi
case "$cur" in
--*)
- __gitcomp "--not --all"
+ __gitcomp "--not --all $merge"
return
;;
esac
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 4fa853fae7..2557a7667f 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -232,10 +232,8 @@ and returns the process output as a string, or nil if the git failed."
(defun git-run-command-region (buffer start end env &rest args)
"Run a git command with specified buffer region as input."
- (unless (eq 0 (if env
- (git-run-process-region
- buffer start end "env"
- (append (git-get-env-strings env) (list "git") args))
+ (unless (eq 0 (let ((process-environment (append (git-get-env-strings env)
+ process-environment)))
(git-run-process-region
buffer start end "git" args)))
(error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string))))
@@ -250,9 +248,8 @@ and returns the process output as a string, or nil if the git failed."
(erase-buffer)
(cd dir)
(setq status
- (if env
- (apply #'call-process "env" nil (list buffer t) nil
- (append (git-get-env-strings env) (list hook-name) args))
+ (let ((process-environment (append (git-get-env-strings env)
+ process-environment)))
(apply #'call-process hook-name nil (list buffer t) nil args))))
(display-message-or-buffer buffer)
(eq 0 status)))))
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
new file mode 100644
index 0000000000..0096f57b7e
--- /dev/null
+++ b/contrib/hooks/pre-auto-gc-battery
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# An example hook script to verify if you are on battery, in case you
+# are running Linux. Called by git-gc --auto with no arguments. The hook
+# should exit with non-zero status after issuing an appropriate message
+# if it wants to stop the auto repacking.
+#
+# This hook is stored in the contrib/hooks directory. Your distribution
+# may have put this somewhere else. If you want to use this hook, you
+# should make this script executable then link to it in the repository
+# you would like to use it in.
+#
+# For example, if the hook is stored in
+# /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:
+#
+# chmod a+x pre-auto-gc-battery
+# cd /path/to/your/repository.git
+# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
+# hooks/pre-auto-gc
+
+if test -x /sbin/on_ac_power && /sbin/on_ac_power
+then
+ exit 0
+elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1
+then
+ exit 0
+elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null
+then
+ exit 0
+elif grep -q '0x01$' /proc/apm 2>/dev/null
+then
+ exit 0
+fi
+
+echo "Auto packing deferred; not on AC"
+exit 1
diff --git a/diff-lib.c b/diff-lib.c
index 069e4507ae..fe2ccec7e6 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -264,6 +264,9 @@ int setup_diff_no_index(struct rev_info *revs,
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
break;
}
+ if (nongit && argc != i + 2)
+ die("git diff [--no-index] takes two paths");
+
if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
!is_outside_repo(argv[i], nongit, prefix)))
return -1;
@@ -334,22 +337,41 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
}
return run_diff_files(revs, options);
}
+
/*
- * See if work tree has an entity that can be staged. Return 0 if so,
- * return 1 if not and return -1 if error.
+ * Has the work tree entity been removed?
+ *
+ * Return 1 if it was removed from the work tree, 0 if an entity to be
+ * compared with the cache entry ce still exists (the latter includes
+ * the case where a directory that is not a submodule repository
+ * exists for ce that is a submodule -- it is a submodule that is not
+ * checked out). Return negative for an error.
*/
-static int check_work_tree_entity(const struct cache_entry *ce, struct stat *st, char *symcache)
+static int check_removed(const struct cache_entry *ce, struct stat *st)
{
if (lstat(ce->name, st) < 0) {
if (errno != ENOENT && errno != ENOTDIR)
return -1;
return 1;
}
- if (has_symlink_leading_path(ce->name, symcache))
+ if (has_symlink_leading_path(ce_namelen(ce), ce->name))
return 1;
if (S_ISDIR(st->st_mode)) {
unsigned char sub[20];
- if (resolve_gitlink_ref(ce->name, "HEAD", sub))
+
+ /*
+ * If ce is already a gitlink, we can have a plain
+ * directory (i.e. the submodule is not checked out),
+ * or a checked out submodule. Either case this is not
+ * a case where something was removed from the work tree,
+ * so we will return 0.
+ *
+ * Otherwise, if the directory is not a submodule
+ * repository, that means ce which was a blob turned into
+ * a directory --- the blob was removed!
+ */
+ if (!S_ISGITLINK(ce->ce_mode) &&
+ resolve_gitlink_ref(ce->name, "HEAD", sub))
return 1;
}
return 0;
@@ -399,7 +421,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
memset(&(dpath->parent[0]), 0,
sizeof(struct combine_diff_parent)*5);
- changed = check_work_tree_entity(ce, &st, symcache);
+ changed = check_removed(ce, &st);
if (!changed)
dpath->mode = ce_mode_from_stat(ce, st.st_mode);
else {
@@ -463,7 +485,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
if (ce_uptodate(ce))
continue;
- changed = check_work_tree_entity(ce, &st, symcache);
+ changed = check_removed(ce, &st);
if (changed) {
if (changed < 0) {
perror(ce->name);
@@ -476,8 +498,11 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
continue;
}
changed = ce_match_stat(ce, &st, ce_option);
- if (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
- continue;
+ if (!changed) {
+ ce_mark_uptodate(ce);
+ if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
+ continue;
+ }
oldmode = ce->ce_mode;
newmode = ce_mode_from_stat(ce, st.st_mode);
diff_change(&revs->diffopt, oldmode, newmode,
@@ -521,7 +546,7 @@ static int get_stat_data(struct cache_entry *ce,
if (!cached) {
int changed;
struct stat st;
- changed = check_work_tree_entity(ce, &st, cbdata->symcache);
+ changed = check_removed(ce, &st);
if (changed < 0)
return -1;
else if (changed) {
diff --git a/diff.c b/diff.c
index 8022e678d1..439d4746ca 100644
--- a/diff.c
+++ b/diff.c
@@ -19,7 +19,7 @@
#endif
static int diff_detect_rename_default;
-static int diff_rename_limit_default = 100;
+static int diff_rename_limit_default = 200;
int diff_use_color_default = -1;
static const char *external_diff_cmd_cfg;
int diff_auto_refresh_index = 1;
@@ -991,18 +991,23 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
}
}
-struct diffstat_dir {
- struct diffstat_file **files;
- int nr, percent, cumulative;
+struct dirstat_file {
+ const char *name;
+ unsigned long changed;
};
-static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long changed, const char *base, int baselen)
+struct dirstat_dir {
+ struct dirstat_file *files;
+ int alloc, nr, percent, cumulative;
+};
+
+static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long changed, const char *base, int baselen)
{
unsigned long this_dir = 0;
unsigned int sources = 0;
while (dir->nr) {
- struct diffstat_file *f = *dir->files;
+ struct dirstat_file *f = dir->files;
int namelen = strlen(f->name);
unsigned long this;
char *slash;
@@ -1017,10 +1022,7 @@ static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long c
this = gather_dirstat(file, dir, changed, f->name, newbaselen);
sources++;
} else {
- if (f->is_unmerged || f->is_binary)
- this = 0;
- else
- this = f->added + f->deleted;
+ this = f->changed;
dir->files++;
dir->nr--;
sources += 2;
@@ -1048,19 +1050,58 @@ static long gather_dirstat(FILE *file, struct diffstat_dir *dir, unsigned long c
return this_dir;
}
-static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
+static void show_dirstat(struct diff_options *options)
{
int i;
unsigned long changed;
- struct diffstat_dir dir;
+ struct dirstat_dir dir;
+ struct diff_queue_struct *q = &diff_queued_diff;
+
+ dir.files = NULL;
+ dir.alloc = 0;
+ dir.nr = 0;
+ dir.percent = options->dirstat_percent;
+ dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
- /* Calculate total changes */
changed = 0;
- for (i = 0; i < data->nr; i++) {
- if (data->files[i]->is_binary || data->files[i]->is_unmerged)
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ const char *name;
+ unsigned long copied, added, damage;
+
+ name = p->one->path ? p->one->path : p->two->path;
+
+ if (DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
+ diff_populate_filespec(p->one, 0);
+ diff_populate_filespec(p->two, 0);
+ diffcore_count_changes(p->one, p->two, NULL, NULL, 0,
+ &copied, &added);
+ diff_free_filespec_data(p->one);
+ diff_free_filespec_data(p->two);
+ } else if (DIFF_FILE_VALID(p->one)) {
+ diff_populate_filespec(p->one, 1);
+ copied = added = 0;
+ diff_free_filespec_data(p->one);
+ } else if (DIFF_FILE_VALID(p->two)) {
+ diff_populate_filespec(p->two, 1);
+ copied = 0;
+ added = p->two->size;
+ diff_free_filespec_data(p->two);
+ } else
continue;
- changed += data->files[i]->added;
- changed += data->files[i]->deleted;
+
+ /*
+ * Original minus copied is the removed material,
+ * added is the new material. They are both damages
+ * made to the preimage.
+ */
+ damage = (p->one->size - copied) + added;
+
+ ALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);
+ dir.files[dir.nr].name = name;
+ dir.files[dir.nr].changed = damage;
+ changed += damage;
+ dir.nr++;
}
/* This can happen even with many files, if everything was renames */
@@ -1068,10 +1109,6 @@ static void show_dirstat(struct diffstat_t *data, struct diff_options *options)
return;
/* Show all directories with more than x% of the changes */
- dir.files = data->files;
- dir.nr = data->nr;
- dir.percent = options->dirstat_percent;
- dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
gather_dirstat(options->file, &dir, changed, "", 0);
}
@@ -2183,7 +2220,6 @@ void diff_setup(struct diff_options *options)
options->rename_limit = -1;
options->dirstat_percent = 3;
options->context = 3;
- options->msg_sep = "";
options->change = diff_change;
options->add_remove = diff_addremove;
@@ -3095,7 +3131,7 @@ void diff_flush(struct diff_options *options)
separator++;
}
- if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIRSTAT)) {
+ if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT)) {
struct diffstat_t diffstat;
memset(&diffstat, 0, sizeof(struct diffstat_t));
@@ -3105,8 +3141,6 @@ void diff_flush(struct diff_options *options)
if (check_pair_status(p))
diff_flush_stat(p, options, &diffstat);
}
- if (output_format & DIFF_FORMAT_DIRSTAT)
- show_dirstat(&diffstat, options);
if (output_format & DIFF_FORMAT_NUMSTAT)
show_numstat(&diffstat, options);
if (output_format & DIFF_FORMAT_DIFFSTAT)
@@ -3116,6 +3150,8 @@ void diff_flush(struct diff_options *options)
free_diffstat_info(&diffstat);
separator++;
}
+ if (output_format & DIFF_FORMAT_DIRSTAT)
+ show_dirstat(options);
if (output_format & DIFF_FORMAT_SUMMARY && !is_summary_empty(q)) {
for (i = 0; i < q->nr; i++)
diff --git a/diff.h b/diff.h
index f2c77391a9..3a02d38d12 100644
--- a/diff.h
+++ b/diff.h
@@ -83,12 +83,12 @@ struct diff_options {
int pickaxe_opts;
int rename_score;
int rename_limit;
+ int warn_on_too_large_rename;
int dirstat_percent;
int setup;
int abbrev;
const char *prefix;
int prefix_length;
- const char *msg_sep;
const char *stat_sep;
long xdl_opts;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 31941bcbbf..1b2ebb4001 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -112,8 +112,8 @@ static int basename_same(struct diff_filespec *src, struct diff_filespec *dst)
struct diff_score {
int src; /* index in rename_src */
int dst; /* index in rename_dst */
- int score;
- int name_score;
+ unsigned short score;
+ short name_score;
};
static int estimate_similarity(struct diff_filespec *src,
@@ -223,6 +223,12 @@ static int score_compare(const void *a_, const void *b_)
{
const struct diff_score *a = a_, *b = b_;
+ /* sink the unused ones to the bottom */
+ if (a->dst < 0)
+ return (0 <= b->dst);
+ else if (b->dst < 0)
+ return -1;
+
if (a->score == b->score)
return b->name_score - a->name_score;
@@ -387,6 +393,22 @@ static int find_exact_renames(void)
return i;
}
+#define NUM_CANDIDATE_PER_DST 4
+static void record_if_better(struct diff_score m[], struct diff_score *o)
+{
+ int i, worst;
+
+ /* find the worst one */
+ worst = 0;
+ for (i = 1; i < NUM_CANDIDATE_PER_DST; i++)
+ if (score_compare(&m[i], &m[worst]) > 0)
+ worst = i;
+
+ /* is it better than the worst one? */
+ if (score_compare(&m[worst], o) > 0)
+ m[worst] = *o;
+}
+
void diffcore_rename(struct diff_options *options)
{
int detect_rename = options->detect_rename;
@@ -470,51 +492,66 @@ void diffcore_rename(struct diff_options *options)
rename_limit = 32767;
if ((num_create > rename_limit && num_src > rename_limit) ||
(num_create * num_src > rename_limit * rename_limit)) {
- warning("too many files, skipping inexact rename detection");
+ if (options->warn_on_too_large_rename)
+ warning("too many files, skipping inexact rename detection");
goto cleanup;
}
- mx = xmalloc(sizeof(*mx) * num_create * num_src);
+ mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx));
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
- int base = dst_cnt * num_src;
struct diff_filespec *two = rename_dst[i].two;
+ struct diff_score *m;
+
if (rename_dst[i].pair)
continue; /* dealt with exact match already. */
+
+ m = &mx[dst_cnt * NUM_CANDIDATE_PER_DST];
+ for (j = 0; j < NUM_CANDIDATE_PER_DST; j++)
+ m[j].dst = -1;
+
for (j = 0; j < rename_src_nr; j++) {
struct diff_filespec *one = rename_src[j].one;
- struct diff_score *m = &mx[base+j];
- m->src = j;
- m->dst = i;
- m->score = estimate_similarity(one, two,
- minimum_score);
- m->name_score = basename_same(one, two);
+ struct diff_score this_src;
+ this_src.score = estimate_similarity(one, two,
+ minimum_score);
+ this_src.name_score = basename_same(one, two);
+ this_src.dst = i;
+ this_src.src = j;
+ record_if_better(m, &this_src);
diff_free_filespec_blob(one);
}
/* We do not need the text anymore */
diff_free_filespec_blob(two);
dst_cnt++;
}
+
/* cost matrix sorted by most to least similar pair */
- qsort(mx, num_create * num_src, sizeof(*mx), score_compare);
- for (i = 0; i < num_create * num_src; i++) {
- struct diff_rename_dst *dst = &rename_dst[mx[i].dst];
- struct diff_filespec *src;
+ qsort(mx, dst_cnt * NUM_CANDIDATE_PER_DST, sizeof(*mx), score_compare);
+
+ for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
+ struct diff_rename_dst *dst;
+
+ if ((mx[i].dst < 0) ||
+ (mx[i].score < minimum_score))
+ break; /* there is no more usable pair. */
+ dst = &rename_dst[mx[i].dst];
if (dst->pair)
continue; /* already done, either exact or fuzzy. */
- if (mx[i].score < minimum_score)
- break; /* there is no more usable pair. */
- src = rename_src[mx[i].src].one;
- if (src->rename_used)
+ if (rename_src[mx[i].src].one->rename_used)
continue;
record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
rename_count++;
}
- for (i = 0; i < num_create * num_src; i++) {
- struct diff_rename_dst *dst = &rename_dst[mx[i].dst];
+
+ for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
+ struct diff_rename_dst *dst;
+
+ if ((mx[i].dst < 0) ||
+ (mx[i].score < minimum_score))
+ break; /* there is no more usable pair. */
+ dst = &rename_dst[mx[i].dst];
if (dst->pair)
continue; /* already done, either exact or fuzzy. */
- if (mx[i].score < minimum_score)
- break; /* there is no more usable pair. */
record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
rename_count++;
}
diff --git a/dir.c b/dir.c
index d79762c7c0..29d1d5ba31 100644
--- a/dir.c
+++ b/dir.c
@@ -52,6 +52,11 @@ int common_prefix(const char **pathspec)
return prefix;
}
+static inline int special_char(unsigned char c1)
+{
+ return !c1 || c1 == '*' || c1 == '[' || c1 == '?';
+}
+
/*
* Does 'match' matches the given name?
* A match is found if
@@ -69,14 +74,27 @@ static int match_one(const char *match, const char *name, int namelen)
int matchlen;
/* If the match was just the prefix, we matched */
- matchlen = strlen(match);
- if (!matchlen)
+ if (!*match)
return MATCHED_RECURSIVELY;
+ for (;;) {
+ unsigned char c1 = *match;
+ unsigned char c2 = *name;
+ if (special_char(c1))
+ break;
+ if (c1 != c2)
+ return 0;
+ match++;
+ name++;
+ namelen--;
+ }
+
+
/*
* If we don't match the matchstring exactly,
* we need to match by fnmatch
*/
+ matchlen = strlen(match);
if (strncmp(match, name, matchlen))
return !fnmatch(match, name, 0) ? MATCHED_FNMATCH : 0;
@@ -371,7 +389,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
{
- if (cache_name_exists(pathname, len))
+ if (cache_name_exists(pathname, len, ignore_case))
return NULL;
ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
diff --git a/environment.c b/environment.c
index 6739a3f417..4fcb471248 100644
--- a/environment.c
+++ b/environment.c
@@ -11,9 +11,11 @@
char git_default_email[MAX_GITNAME];
char git_default_name[MAX_GITNAME];
+int user_ident_explicitly_given;
int trust_executable_bit = 1;
int quote_path_fully = 1;
int has_symlinks = 1;
+int ignore_case;
int assume_unchanged;
int prefer_symlink_refs;
int is_bare_repository_cfg = -1; /* unspecified */
@@ -38,6 +40,7 @@ int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
+enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
/* This is set by setup_git_dir_gently() and/or git_default_config() */
char *git_work_tree_cfg;
@@ -50,6 +53,8 @@ static void setup_git_env(void)
{
git_dir = getenv(GIT_DIR_ENVIRONMENT);
if (!git_dir)
+ git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
git_object_dir = getenv(DB_ENVIRONMENT);
if (!git_object_dir) {
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index a0a81f134a..903953e68e 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -550,6 +550,21 @@ sub parse_diff {
return @hunk;
}
+sub parse_diff_header {
+ my $src = shift;
+
+ my $head = { TEXT => [], DISPLAY => [] };
+ my $mode = { TEXT => [], DISPLAY => [] };
+
+ for (my $i = 0; $i < @{$src->{TEXT}}; $i++) {
+ my $dest = $src->{TEXT}->[$i] =~ /^(old|new) mode (\d+)$/ ?
+ $mode : $head;
+ push @{$dest->{TEXT}}, $src->{TEXT}->[$i];
+ push @{$dest->{DISPLAY}}, $src->{DISPLAY}->[$i];
+ }
+ return ($head, $mode);
+}
+
sub hunk_splittable {
my ($text) = @_;
@@ -795,9 +810,40 @@ sub patch_update_file {
my ($ix, $num);
my $path = shift;
my ($head, @hunk) = parse_diff($path);
+ ($head, my $mode) = parse_diff_header($head);
for (@{$head->{DISPLAY}}) {
print;
}
+
+ if (@{$mode->{TEXT}}) {
+ while (1) {
+ print @{$mode->{DISPLAY}};
+ print colored $prompt_color,
+ "Stage mode change [y/n/a/d/?]? ";
+ my $line = <STDIN>;
+ if ($line =~ /^y/i) {
+ $mode->{USE} = 1;
+ last;
+ }
+ elsif ($line =~ /^n/i) {
+ $mode->{USE} = 0;
+ last;
+ }
+ elsif ($line =~ /^a/i) {
+ $_->{USE} = 1 foreach ($mode, @hunk);
+ last;
+ }
+ elsif ($line =~ /^d/i) {
+ $_->{USE} = 0 foreach ($mode, @hunk);
+ last;
+ }
+ else {
+ help_patch_cmd('');
+ next;
+ }
+ }
+ }
+
$num = scalar @hunk;
$ix = 0;
@@ -920,6 +966,9 @@ sub patch_update_file {
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) =
diff --git a/git-bisect.sh b/git-bisect.sh
index 8e57e9a75d..164e8ed81f 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,7 +1,9 @@
#!/bin/sh
-USAGE='[start|bad|good|skip|next|reset|visualize|replay|log|run]'
-LONG_USAGE='git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
+USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
+LONG_USAGE='git bisect help
+ print this long help message.
+git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
reset bisect state and start bisection.
git bisect bad [<rev>]
mark <rev> a known-bad revision.
@@ -20,7 +22,9 @@ git bisect replay <logfile>
git bisect log
show bisect log.
git bisect run <cmd>...
- use <cmd>... to automatically bisect.'
+ use <cmd>... to automatically bisect.
+
+Please use "git help bisect" to get the full man page.'
OPTIONS_SPEC=
. git-sh-setup
@@ -65,14 +69,19 @@ bisect_start() {
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
die "Bad HEAD - I need a HEAD"
+ #
+ # Check that we either already have BISECT_START, or that the
+ # branches bisect, new-bisect don't exist, to not override them.
+ #
+ test -s "$GIT_DIR/BISECT_START" ||
+ if git show-ref --verify -q refs/heads/bisect ||
+ git show-ref --verify -q refs/heads/new-bisect; then
+ die 'The branches "bisect" and "new-bisect" must not exist.'
+ fi
start_head=''
case "$head" in
refs/heads/bisect)
- if [ -s "$GIT_DIR/BISECT_START" ]; then
- branch=`cat "$GIT_DIR/BISECT_START"`
- else
- branch=master
- fi
+ branch=`cat "$GIT_DIR/BISECT_START"`
git checkout $branch || exit
;;
refs/heads/*|$_x40)
@@ -215,18 +224,33 @@ bisect_auto_next() {
bisect_next_check && bisect_next || :
}
+eval_rev_list() {
+ _eval="$1"
+
+ eval $_eval
+ res=$?
+
+ if [ $res -ne 0 ]; then
+ echo >&2 "'git rev-list --bisect-vars' failed:"
+ echo >&2 "maybe you mistake good and bad revs?"
+ exit $res
+ fi
+
+ return $res
+}
+
filter_skipped() {
_eval="$1"
_skip="$2"
if [ -z "$_skip" ]; then
- eval $_eval
+ eval_rev_list "$_eval"
return
fi
# Let's parse the output of:
# "git rev-list --bisect-vars --bisect-all ..."
- eval $_eval | while read hash line
+ eval_rev_list "$_eval" | while read hash line
do
case "$VARS,$FOUND,$TRIED,$hash" in
# We display some vars.
@@ -324,8 +348,8 @@ bisect_next() {
exit_if_skipped_commits "$bisect_rev"
echo "Bisecting: $bisect_nr revisions left to test after this"
- git branch -f new-bisect "$bisect_rev"
- git checkout -q new-bisect || exit
+ git branch -D new-bisect 2> /dev/null
+ git checkout -q -b new-bisect "$bisect_rev" || exit
git branch -M new-bisect bisect
git show-branch "$bisect_rev"
}
@@ -467,6 +491,8 @@ case "$#" in
cmd="$1"
shift
case "$cmd" in
+ help)
+ git bisect -h ;;
start)
bisect_start "$@" ;;
bad|good|skip)
diff --git a/git-clone.sh b/git-clone.sh
index 8c7fc7f631..547228e13c 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -240,7 +240,6 @@ die "working tree '$GIT_WORK_TREE' already exists."
D=
W=
cleanup() {
- err=$?
test -z "$D" && rm -rf "$dir"
test -z "$W" && test -n "$GIT_WORK_TREE" && rm -rf "$GIT_WORK_TREE"
cd ..
@@ -248,7 +247,7 @@ cleanup() {
test -n "$W" && rm -rf "$W"
exit $err
}
-trap cleanup 0
+trap 'err=$?; cleanup' 0
mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage
test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" &&
W=$(cd "$GIT_WORK_TREE" && pwd) && GIT_WORK_TREE="$W" && export GIT_WORK_TREE
@@ -334,7 +333,10 @@ yes)
fi
fi &&
cd "$repo" &&
- find objects -depth -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
+ # Create dirs using umask and permissions and destination
+ find objects -type d -print | (cd "$GIT_DIR" && xargs mkdir -p) &&
+ # Copy existing 0444 permissions on content
+ find objects ! -type d -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
exit 1
fi
git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
diff --git a/git-compat-util.h b/git-compat-util.h
index a18235e6d0..01c4045e89 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -206,6 +206,9 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
#endif
#ifdef FREAD_READS_DIRECTORIES
+#ifdef fopen
+#undef fopen
+#endif
#define fopen(a,b) git_fopen(a,b)
extern FILE *git_fopen(const char*, const char*);
#endif
@@ -268,6 +271,12 @@ static inline void *xmalloc(size_t size)
return ret;
}
+/*
+ * xmemdupz() allocates (len + 1) bytes of memory, duplicates "len" bytes of
+ * "data" to the allocated memory, zero terminates the allocated memory,
+ * and returns a pointer to the allocated memory. If the allocation fails,
+ * the program dies.
+ */
static inline void *xmemdupz(const void *data, size_t len)
{
char *p = xmalloc(len + 1);
@@ -329,6 +338,11 @@ static inline void *xmmap(void *start, size_t length,
return ret;
}
+/*
+ * xread() is the same a read(), but it automatically restarts read()
+ * operations with a recoverable error (EAGAIN and EINTR). xread()
+ * DOES NOT GUARANTEE that "len" bytes is read even if the data is available.
+ */
static inline ssize_t xread(int fd, void *buf, size_t len)
{
ssize_t nr;
@@ -340,6 +354,11 @@ static inline ssize_t xread(int fd, void *buf, size_t len)
}
}
+/*
+ * xwrite() is the same a write(), but it automatically restarts write()
+ * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
+ * GUARANTEE that "len" bytes is written even if the operation is successful.
+ */
static inline ssize_t xwrite(int fd, const void *buf, size_t len)
{
ssize_t nr;
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ea59015baa..80e99e5394 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -406,8 +406,22 @@ if [ "$filter_tag_name" ]; then
echo "$ref -> $new_ref ($sha1 -> $new_sha1)"
if [ "$type" = "tag" ]; then
- # Warn that we are not rewriting the tag object itself.
- warn "unreferencing tag object $sha1t"
+ new_sha1=$(git cat-file tag "$ref" |
+ sed -n \
+ -e "1,/^$/{
+ s/^object .*/object $new_sha1/
+ s/^type .*/type commit/
+ s/^tag .*/tag $new_ref/
+ }" \
+ -e '/^-----BEGIN PGP SIGNATURE-----/q' \
+ -e 'p' |
+ git mktag) ||
+ die "Could not create new tag object for $ref"
+ if git cat-file tag "$ref" | \
+ grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1
+ then
+ warn "gpg signature stripped from tag object $sha1t"
+ fi
fi
git update-ref "refs/tags/$new_ref" "$new_sha1" ||
@@ -421,11 +435,17 @@ rm -rf "$tempdir"
trap - 0
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
-test -z "$ORIG_GIT_DIR" || GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
-test -z "$ORIG_GIT_WORK_TREE" || GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
+test -z "$ORIG_GIT_DIR" || {
+ GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
+}
+test -z "$ORIG_GIT_WORK_TREE" || {
+ GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
export GIT_WORK_TREE
-test -z "$ORIG_GIT_INDEX_FILE" || GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
+}
+test -z "$ORIG_GIT_INDEX_FILE" || {
+ GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
export GIT_INDEX_FILE
+}
git read-tree -u -m HEAD
exit $ret
diff --git a/git-merge.sh b/git-merge.sh
index 7dbbb1d79d..69b35d87e6 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -8,8 +8,12 @@ OPTIONS_SPEC="\
git-merge [options] <remote>...
git-merge [options] <msg> HEAD <remote>
--
-summary show a diffstat at the end of the merge
-n,no-summary don't show a diffstat at the end of the merge
+stat show a diffstat at the end of the merge
+n,no-stat don't show a diffstat at the end of the merge
+summary (synonym to --stat)
+no-summary (synonym to --no-stat)
+log add list of one-line log to merge commit message
+no-log don't add list of one-line log to merge commit message
squash create a single commit instead of doing a merge
commit perform a commit if the merge sucesses (default)
ff allow fast forward (default)
@@ -37,7 +41,7 @@ use_strategies=
allow_fast_forward=t
allow_trivial_merge=t
-squash= no_commit=
+squash= no_commit= log_arg=
dropsave() {
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -148,10 +152,12 @@ merge_name () {
parse_config () {
while test $# != 0; do
case "$1" in
- -n|--no-summary)
+ -n|--no-stat|--no-summary)
show_diffstat=false ;;
- --summary)
+ --stat|--summary)
show_diffstat=t ;;
+ --log|--no-log)
+ log_arg=$1 ;;
--squash)
test "$allow_fast_forward" = t ||
die "You cannot combine --squash with --no-ff."
@@ -210,6 +216,7 @@ while test $args_left -lt $#; do shift; done
if test -z "$show_diffstat"; then
test "$(git config --bool merge.diffstat)" = false && show_diffstat=false
+ test "$(git config --bool merge.stat)" = false && show_diffstat=false
test -z "$show_diffstat" && show_diffstat=t
fi
@@ -258,7 +265,7 @@ else
merge_name=$(for remote
do
merge_name "$remote"
- done | git fmt-merge-msg
+ done | git fmt-merge-msg $log_arg
)
merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"
fi
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 5c86f69229..fcdec4a504 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -237,9 +237,9 @@ merge_file () {
ecmerge)
touch "$BACKUP"
if base_present; then
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$MERGED"
+ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --default --mode=merge3 --to="$MERGED"
else
- "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$MERGED"
+ "$merge_tool_path" "$LOCAL" "$REMOTE" --default --mode=merge2 --to="$MERGED"
fi
check_unchanged
;;
diff --git a/git-pull.sh b/git-pull.sh
index 3ce32b5f21..bf0c2985af 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -4,7 +4,7 @@
#
# Fetch one or more remote refs and merge it/them into the current HEAD.
-USAGE='[-n | --no-summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
+USAGE='[-n | --no-stat] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
@@ -16,19 +16,19 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
-strategy_args= no_summary= no_commit= squash= no_ff=
+strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
case "$1" in
- -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
- --no-summa|--no-summar|--no-summary)
- no_summary=-n ;;
- --summary)
- no_summary=$1
- ;;
+ -n|--no-stat|--no-summary)
+ no_stat=-n ;;
+ --stat|--summary)
+ no_stat=$1 ;;
+ --log|--no-log)
+ log_arg=$1 ;;
--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
no_commit=--no-commit ;;
--c|--co|--com|--comm|--commi|--commit)
@@ -172,9 +172,9 @@ then
exit
fi
-merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
+merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
-exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \
+exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
"$merge_name" HEAD $merge_head
diff --git a/git-rebase.sh b/git-rebase.sh
index 60c458f201..68855c18ae 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -214,7 +214,7 @@ do
else
die "No rebase in progress?"
fi
- git reset --hard $(cat $dotest/orig-head)
+ git reset --hard $(cat "$dotest/orig-head")
rm -r "$dotest"
exit
;;
@@ -309,22 +309,42 @@ then
}
fi
-# If the branch to rebase is given, first switch to it.
+# If the branch to rebase is given, that is the branch we will rebase
+# $branch_name -- branch being rebased, or HEAD (already detached)
+# $orig_head -- commit object name of tip of the branch before rebasing
+# $head_name -- refs/heads/<that-branch> or "detached HEAD"
+switch_to=
case "$#" in
2)
+ # Is it "rebase other $branchname" or "rebase other $commit"?
branch_name="$2"
- git-checkout "$2" || usage
+ switch_to="$2"
+
+ if git show-ref --verify --quiet -- "refs/heads/$2" &&
+ branch=$(git rev-parse --verify "refs/heads/$2" 2>/dev/null)
+ then
+ head_name="refs/heads/$2"
+ elif branch=$(git rev-parse --verify "$2" 2>/dev/null)
+ then
+ head_name="detached HEAD"
+ else
+ usage
+ fi
;;
*)
+ # Do not need to switch branches, we are already on it.
if branch_name=`git symbolic-ref -q HEAD`
then
+ head_name=$branch_name
branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
else
+ head_name="detached HEAD"
branch_name=HEAD ;# detached
fi
+ branch=$(git rev-parse --verify "${branch_name}^0") || exit
;;
esac
-branch=$(git rev-parse --verify "${branch_name}^0") || exit
+orig_head=$branch
# Now we are rebasing commits $upstream..$branch on top of $onto
@@ -333,8 +353,10 @@ branch=$(git rev-parse --verify "${branch_name}^0") || exit
mb=$(git merge-base "$onto" "$branch")
if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
# linear history?
- ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null
+ ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null
then
+ # Lazily switch to the target branch if needed...
+ test -z "$switch_to" || git checkout "$switch_to"
echo >&2 "Current branch $branch_name is up to date."
exit 0
fi
@@ -346,22 +368,11 @@ then
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
fi
-# move to a detached HEAD
-orig_head=$(git rev-parse HEAD^0)
-head_name=$(git symbolic-ref HEAD 2> /dev/null)
-case "$head_name" in
-'')
- head_name="detached HEAD"
- ;;
-*)
- git checkout "$orig_head" > /dev/null 2>&1 ||
- die "could not detach HEAD"
- ;;
-esac
-
-# Rewind the head to "$onto"; this saves our current head in ORIG_HEAD.
+# Detach HEAD and reset the tree
echo "First, rewinding head to replay your work on top of it..."
-git-reset --hard "$onto"
+git checkout "$onto^0" >/dev/null 2>&1 ||
+ die "could not detach HEAD"
+# git reset --hard "$onto^0"
# If the $onto is a proper descendant of the tip of the branch, then
# we just fast forwarded.
@@ -374,7 +385,8 @@ fi
if test -z "$do_merge"
then
- git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
+ git format-patch -k --stdout --full-index --ignore-if-in-upstream \
+ "$upstream..$orig_head" |
git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
ret=$?
@@ -397,7 +409,7 @@ echo "$orig_head" > "$dotest/orig-head"
echo "$head_name" > "$dotest/head-name"
msgnum=0
-for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD`
+for cmt in `git rev-list --reverse --no-merges "$upstream..$orig_head"`
do
msgnum=$(($msgnum + 1))
echo "$cmt" > "$dotest/cmt.$msgnum"
diff --git a/git-send-email.perl b/git-send-email.perl
index be4a20d7cd..1e1d98656d 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -168,7 +168,8 @@ my $envelope_sender;
# Example reply to:
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
-my $repo = Git->repository();
+my $repo = eval { Git->repository() };
+my @repo = $repo ? ($repo) : ();
my $term = eval {
$ENV{"GIT_SEND_EMAIL_NOTTY"}
? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT
@@ -202,6 +203,7 @@ my %config_settings = (
"smtpuser" => \$smtp_authuser,
"smtppass" => \$smtp_authpass,
"to" => \@to,
+ "cc" => \@initial_cc,
"cccmd" => \$cc_cmd,
"aliasfiletype" => \$aliasfiletype,
"bcc" => \@bcclist,
@@ -271,25 +273,25 @@ sub read_config {
foreach my $setting (keys %config_bool_settings) {
my $target = $config_bool_settings{$setting}->[0];
- $$target = $repo->config_bool("$prefix.$setting") unless (defined $$target);
+ $$target = Git::config_bool(@repo, "$prefix.$setting") unless (defined $$target);
}
foreach my $setting (keys %config_settings) {
my $target = $config_settings{$setting};
if (ref($target) eq "ARRAY") {
unless (@$target) {
- my @values = $repo->config("$prefix.$setting");
+ my @values = Git::config(@repo, "$prefix.$setting");
@$target = @values if (@values && defined $values[0]);
}
}
else {
- $$target = $repo->config("$prefix.$setting") unless (defined $$target);
+ $$target = Git::config(@repo, "$prefix.$setting") unless (defined $$target);
}
}
}
# read configuration from [sendemail "$identity"], fall back on [sendemail]
-$identity = $repo->config("sendemail.identity") unless (defined $identity);
+$identity = Git::config(@repo, "sendemail.identity") unless (defined $identity);
read_config("sendemail.$identity") if (defined $identity);
read_config("sendemail");
@@ -327,8 +329,9 @@ if (0) {
}
}
-my ($repoauthor) = $repo->ident_person('author');
-my ($repocommitter) = $repo->ident_person('committer');
+my ($repoauthor, $repocommitter);
+($repoauthor) = Git::ident_person(@repo, 'author');
+($repocommitter) = Git::ident_person(@repo, 'committer');
# Verify the user input
@@ -415,7 +418,7 @@ if (@files) {
my $prompting = 0;
if (!defined $sender) {
- $sender = $repoauthor || $repocommitter;
+ $sender = $repoauthor || $repocommitter || '';
while (1) {
$_ = $term->readline("Who should the emails appear to be from? [$sender] ");
@@ -509,8 +512,8 @@ GIT: for the patch you are writing.
EOT
close(C);
- my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
- system('sh', '-c', '$0 $@', $editor, $compose_filename);
+ my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+ system('sh', '-c', $editor.' "$@"', $editor, $compose_filename);
open(C2,">",$compose_filename . ".final")
or die "Failed to open $compose_filename.final : " . $!;
diff --git a/git-submodule.sh b/git-submodule.sh
index a745e42bf7..67f7a28cb3 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -300,7 +300,7 @@ cmd_update()
continue
fi
- if ! test -d "$path"/.git
+ if ! test -d "$path"/.git -o -f "$path"/.git
then
module_clone "$path" "$url" || exit
subsha1=
@@ -343,6 +343,7 @@ set_name_rev () {
#
cmd_summary() {
summary_limit=-1
+ for_status=
# parse $args after "submodule ... summary".
while test $# -ne 0
@@ -351,6 +352,9 @@ cmd_summary() {
--cached)
cached="$1"
;;
+ --for-status)
+ for_status="$1"
+ ;;
-n|--summary-limit)
if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
then
@@ -398,7 +402,8 @@ cmd_summary() {
done
)
- test -n "$modules" &&
+ test -z "$modules" && return
+
git diff-index $cached --raw $head -- $modules |
grep -e '^:160000' -e '^:[0-7]* 160000' |
cut -c2- |
@@ -500,7 +505,14 @@ cmd_summary() {
echo
fi
echo
- done
+ done |
+ if test -n "$for_status"; then
+ echo "# Modified submodules:"
+ echo "#"
+ sed -e 's|^|# |' -e 's|^# $|#|'
+ else
+ cat
+ fi
}
#
# List all submodules, prefixed with:
@@ -543,7 +555,7 @@ cmd_status()
do
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
- if test -z "$url" || ! test -d "$path"/.git
+ if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git
then
say "-$sha1 $path"
continue;
diff --git a/git-svn.perl b/git-svn.perl
index b1510495a7..2c53f39aef 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -65,7 +65,8 @@ my ($_stdin, $_help, $_edit,
$_template, $_shared,
$_version, $_fetch_all, $_no_rebase,
$_merge, $_strategy, $_dry_run, $_local,
- $_prefix, $_no_checkout, $_url, $_verbose);
+ $_prefix, $_no_checkout, $_url, $_verbose,
+ $_git_format);
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -188,7 +189,7 @@ my %cmd = (
{ 'url' => \$_url, } ],
'blame' => [ \&Git::SVN::Log::cmd_blame,
"Show what revision and author last modified each line of a file",
- {} ],
+ { 'git-format' => \$_git_format } ],
);
my $cmd;
@@ -225,7 +226,7 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
read_repo_config(\%opts);
-Getopt::Long::Configure('pass_through') if ($cmd && $cmd eq 'log');
+Getopt::Long::Configure('pass_through') if ($cmd && ($cmd eq 'log' || $cmd eq 'blame'));
my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
'minimize-connections' => \$Git::SVN::Migration::_minimize,
'id|i=s' => \$Git::SVN::default_ref_id,
@@ -410,10 +411,12 @@ sub cmd_dcommit {
$head ||= 'HEAD';
my @refs;
my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
- print "Committing to $url ...\n";
+ if ($url) {
+ print "Committing to $url ...\n";
+ }
unless ($gs) {
die "Unable to determine upstream SVN information from ",
- "$head history\n";
+ "$head history.\nPerhaps the repository is empty.";
}
my $last_rev;
my ($linear_refs, $parents) = linearize_history($gs, \@refs);
@@ -612,7 +615,7 @@ sub cmd_create_ignore {
print GITIGNORE "$s\n";
close(GITIGNORE)
or fatal("Failed to close `$ignore': $!");
- command_noisy('add', $ignore);
+ command_noisy('add', '-f', $ignore);
});
}
@@ -2426,13 +2429,15 @@ sub make_log_entry {
$name_field = $1;
}
if (!defined $name_field) {
- #
+ if (!defined $email) {
+ $email = $name;
+ }
} elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
($name, $email) = ($1, $2);
} elsif ($name_field =~ /(.*)@/) {
($name, $email) = ($1, $name_field);
} else {
- ($name, $email) = ($name_field, 'unknown');
+ ($name, $email) = ($name_field, $name_field);
}
}
if (defined $headrev && $self->use_svm_props) {
@@ -3669,7 +3674,7 @@ sub escape_uri_only {
my ($uri) = @_;
my @tmp;
foreach (split m{/}, $uri) {
- s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
+ s/([^\w.%+-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
push @tmp, $_;
}
join('/', @tmp);
@@ -4464,19 +4469,51 @@ out:
}
sub cmd_blame {
- my $path = shift;
+ my $path = pop;
config_pager();
run_pager();
- my ($fh, $ctx) = command_output_pipe('blame', @_, $path);
- while (my $line = <$fh>) {
- if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
- my (undef, $rev, undef) = ::cmt_metadata($1);
- $rev = sprintf('%-10s', $rev);
- $line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
+ my ($fh, $ctx, $rev);
+
+ if ($_git_format) {
+ ($fh, $ctx) = command_output_pipe('blame', @_, $path);
+ while (my $line = <$fh>) {
+ if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
+ # Uncommitted edits show up as a rev ID of
+ # all zeros, which we can't look up with
+ # cmt_metadata
+ if ($1 !~ /^0+$/) {
+ (undef, $rev, undef) =
+ ::cmt_metadata($1);
+ $rev = '0' if (!$rev);
+ } else {
+ $rev = '0';
+ }
+ $rev = sprintf('%-10s', $rev);
+ $line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
+ }
+ print $line;
+ }
+ } else {
+ ($fh, $ctx) = command_output_pipe('blame', '-p', @_, 'HEAD',
+ '--', $path);
+ my ($sha1);
+ my %authors;
+ while (my $line = <$fh>) {
+ if ($line =~ /^([[:xdigit:]]{40})\s\d+\s\d+/) {
+ $sha1 = $1;
+ (undef, $rev, undef) = ::cmt_metadata($1);
+ $rev = '0' if (!$rev);
+ }
+ elsif ($line =~ /^author (.*)/) {
+ $authors{$rev} = $1;
+ $authors{$rev} =~ s/\s/_/g;
+ }
+ elsif ($line =~ /^\t(.*)$/) {
+ printf("%6s %10s %s\n", $rev, $authors{$rev}, $1);
+ }
}
- print $line;
}
command_close_pipe($fh, $ctx);
}
diff --git a/git.c b/git.c
index c4e4644b30..89b431fa28 100644
--- a/git.c
+++ b/git.c
@@ -347,7 +347,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "shortlog", cmd_shortlog, USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
- { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
+ { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE | USE_PAGER },
{ "stripspace", cmd_stripspace },
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
{ "tag", cmd_tag, RUN_SETUP },
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index 9cd5b0a2b1..f7194dbef7 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -29,40 +29,40 @@ Build time configuration
See also "How to configure gitweb for your local system" in README
file for gitweb (in gitweb/README).
-- There are many configuration variables which affects building of
+- There are many configuration variables which affect building of
gitweb.cgi; see "default configuration for gitweb" section in main
(top dir) Makefile, and instructions for building gitweb/gitweb.cgi
target.
- One of most important is where to find git wrapper binary. Gitweb
- tries to find git wrapper at $(bindir)/git, so you have to set $bindir
+ One of the most important is where to find the git wrapper binary. Gitweb
+ tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
when building gitweb.cgi, or $prefix from which $bindir is derived. If
- you build and install gitweb together with the rest of git suite,
+ you build and install gitweb together with the rest of the git suite,
there should be no problems. Otherwise, if git was for example
installed from a binary package, you have to set $prefix (or $bindir)
accordingly.
- Another important issue is where are git repositories you want to make
- available to gitweb. By default gitweb search for repositories under
+ available to gitweb. By default gitweb searches for repositories under
/pub/git; if you want to have projects somewhere else, like /home/git,
use GITWEB_PROJECTROOT build configuration variable.
By default all git repositories under projectroot are visible and
- available to gitweb. List of projects is generated by default by
+ available to gitweb. The list of projects is generated by default by
scanning the projectroot directory for git repositories. This can be
changed (configured) as described in "Gitweb repositories" section
below.
- Note that gitweb deals directly with object database, and does not
- need working directory; the name of the project is the name of its
+ Note that gitweb deals directly with the object database, and does not
+ need a working directory; the name of the project is the name of its
repository object database, usually projectname.git for bare
repositories. If you want to provide gitweb access to non-bare (live)
- repository, you can make projectname.git symbolic link under
+ repositories, you can make projectname.git a symbolic link under
projectroot linking to projectname/.git (but it is just
a suggestion).
- You can control where gitweb tries to find its main CSS style file,
- its favicon and logo with GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
+ its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
build configuration variables. By default gitweb tries to find them
in the same directory as gitweb.cgi script.
@@ -91,13 +91,17 @@ Gitweb config file
See also "Runtime gitweb configuration" section in README file
for gitweb (in gitweb/README).
-- You can configure gitweb further using gitweb configuration file;
- by default it is file named gitweb_config.perl in the same place as
- gitweb.cgi script. You can control default place for config file
- using GITWEB_CONFIG build configuration variable, and you can set it
- using GITWEB_CONFIG environmental variable.
-
-- Gitweb config file is [fragment] of perl code. You can set variables
+- You can configure gitweb further using the gitweb configuration file;
+ by default this is a file named gitweb_config.perl in the same place as
+ gitweb.cgi script. You can control the default place for the config file
+ using the GITWEB_CONFIG build configuration variable, and you can set it
+ using the GITWEB_CONFIG environment variable. If this file does not
+ exist, gitweb looks for a system-wide configuration file, normally
+ /etc/gitweb.conf. You can change the default using the
+ GITWEB_CONFIG_SYSTEM build configuration variable, and override it
+ through the GITWEB_CONFIG_SYSTEM environment variable.
+
+- The gitweb config file is a fragment of perl code. You can set variables
using "our $variable = value"; text from "#" character until the end
of a line is ignored. See perlsyn(1) for details.
@@ -124,36 +128,37 @@ Gitweb repositories
-------------------
- By default all git repositories under projectroot are visible and
- available to gitweb. List of projects is generated by default by
+ available to gitweb. The list of projects is generated by default by
scanning the projectroot directory for git repositories (for object
databases to be more exact).
- You can provide pre-generated list of [visible] repositories,
+ You can provide a pre-generated list of [visible] repositories,
together with information about their owners (the project ownership
- is taken from owner of repository directory otherwise), by setting
- GITWEB_LIST build configuration variable (or $projects_list variable
- in gitweb config file) to point to a plain file.
-
- Each line of projects list file should consist of url-encoded path
- to project repository database (relative to projectroot) separated
- by space from url-encoded project owner; spaces in both project path
- and project owner have to be encoded as either '%20' or '+'.
-
- You can generate projects list index file using project_index action
- (the 'TXT' link on projects list page) directly from gitweb.
-
-- By default even if project is not visible on projects list page, you
- can view it nevertheless by hand-crafting gitweb URL. You can set
- GITWEB_STRICT_EXPORT build configuration variable (or $strict_export
- variable in gitweb config file) to only allow viewing of
+ defaults to the owner of the repository directory otherwise), by setting
+ the GITWEB_LIST build configuration variable (or the $projects_list
+ variable in the gitweb config file) to point to a plain file.
+
+ Each line of the projects list file should consist of the url-encoded path
+ to the project repository database (relative to projectroot), followed
+ by the url-encoded project owner on the same line (separated by a space).
+ Spaces in both project path and project owner have to be encoded as either
+ '%20' or '+'.
+
+ You can generate the projects list index file using the project_index
+ action (the 'TXT' link on projects list page) directly from gitweb.
+
+- By default, even if a project is not visible on projects list page, you
+ can view it nevertheless by hand-crafting a gitweb URL. You can set the
+ GITWEB_STRICT_EXPORT build configuration variable (or the $strict_export
+ variable in the gitweb config file) to only allow viewing of
repositories also shown on the overview page.
- Alternatively, you can configure gitweb to only list and allow
- viewing of the explicitly exported repositories, via
- GITWEB_EXPORT_OK build configuration variable (or $export_ok
+ viewing of the explicitly exported repositories, via the
+ GITWEB_EXPORT_OK build configuration variable (or the $export_ok
variable in gitweb config file). If it evaluates to true, gitweb
- show repository only if this file exists in its object database
- (if directory has the magic file $export_ok).
+ shows repositories only if this file exists in its object database
+ (if directory has the magic file named $export_ok).
Generating projects list using gitweb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/gitweb/README b/gitweb/README
index 2163071047..8f7ea367ba 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -2,7 +2,7 @@ GIT web Interface
=================
The one working on:
- http://www.kernel.org/git/
+ http://git.kernel.org/
From the git version 1.4.0 gitweb is bundled with git.
@@ -10,13 +10,13 @@ From the git version 1.4.0 gitweb is bundled with git.
How to configure gitweb for your local system
---------------------------------------------
-See also "Build time configuration" section in INSTALL
+See also the "Build time configuration" section in the INSTALL
file for gitweb (in gitweb/INSTALL).
You can specify the following configuration variables when building GIT:
* GIT_BINDIR
- Points out where to find git executable. You should set up it to
- the place where git binary was installed (usually /usr/bin) if you
+ Points where to find the git executable. You should set it up to
+ the place where the git binary was installed (usually /usr/bin) if you
don't install git from sources together with gitweb. [Default: $(bindir)]
* GITWEB_SITENAME
Shown in the title of all generated pages, defaults to the server name
@@ -24,13 +24,13 @@ You can specify the following configuration variables when building GIT:
* GITWEB_PROJECTROOT
The root directory for all projects shown by gitweb. Must be set
correctly for gitweb to find repositories to display. See also
- "Gitweb repositories" in INSTALL file for gitweb. [Default: /pub/git]
+ "Gitweb repositories" in the INSTALL file for gitweb. [Default: /pub/git]
* GITWEB_PROJECT_MAXDEPTH
- The filesystem traversing limit for getting projects list; the number
+ The filesystem traversing limit for getting the project list; the number
is taken as depth relative to the projectroot. It is used when
GITWEB_LIST is a directory (or is not set; then project root is used).
Is is meant to speed up project listing on large work trees by limiting
- find depth. [Default: 2007]
+ search depth. [Default: 2007]
* GITWEB_LIST
Points to a directory to scan for projects (defaults to project root
if not set / if empty) or to a file with explicit listing of projects
@@ -72,15 +72,15 @@ You can specify the following configuration variables when building GIT:
Git base URLs used for URL to where fetch project from, i.e. full
URL is "$git_base_url/$project". Shown on projects summary page.
Repository URL for project can be also configured per repository; this
- takes precendence over URL composed from base URL and project name.
+ takes precedence over URLs composed from base URL and a project name.
Note that you can setup multiple base URLs (for example one for
- git:// protocol access, one for http:// access) from gitweb config
- file. [No default]
+ git:// protocol access, another for http:// access) from the gitweb
+ config file. [No default]
* GITWEB_CSS
Points to the location where you put gitweb.css on your web server
- (or to be more generic URI of gitweb stylesheet). Relative to base
- URI of gitweb. Note that you can setup multiple stylesheets from
- gitweb config file. [Default: gitweb.css]
+ (or to be more generic, the URI of gitweb stylesheet). Relative to the
+ base URI of gitweb. Note that you can setup multiple stylesheets from
+ the gitweb config file. [Default: gitweb.css]
* GITWEB_LOGO
Points to the location where you put git-logo.png on your web server
(or to be more generic URI of logo, 72x27 size, displayed in top right
@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:
is set when gitweb.cgi is executed, then the file specified in the
environment variable will be loaded instead of the file specified
when gitweb.cgi was created. [Default: gitweb_config.perl]
+ * GITWEB_CONFIG_SYSTEM
+ This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
+ does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set
+ when gitweb.cgi is executed, then the file specified in the environment
+ variable will be loaded instead of the file specified when gitweb.cgi was
+ created. [Default: /etc/gitweb.conf]
Runtime gitweb configuration
----------------------------
You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
-(defaults to 'gitweb_config.perl' in the same directory as the CGI).
+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
The most notable thing that is not configurable at compile time are the
optional features, stored in the '%features' variable.
@@ -114,15 +121,15 @@ Ultimate description on how to reconfigure the default features setting
in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found
as comments inside 'gitweb.cgi'.
-See also "Gitweb config file" (with example of gitweb config file), and
-"Gitweb repositories" sections in INSTALL file for gitweb.
+See also the "Gitweb config file" (with an example of config file), and
+the "Gitweb repositories" sections in INSTALL file for gitweb.
-Gitweb config file is [fragment] of perl code. You can set variables
+The gitweb config file is a fragment of perl code. You can set variables
using "our $variable = value"; text from "#" character until the end
of a line is ignored. See perlsyn(1) man page for details.
-Below there is list of vaiables which you might want to set in gitweb config.
+Below is the list of variables which you might want to set in gitweb config.
See the top of 'gitweb.cgi' for the full list of variables and their
descriptions.
@@ -133,7 +140,7 @@ You can set, among others, the following variables in gitweb config files
(with the exception of $projectroot and $projects_list this list does
not include variables usually directly set during build):
* $GIT
- Cure git executable to use. By default set to "$GIT_BINDIR/git", which
+ Core git executable to use. By default set to "$GIT_BINDIR/git", which
in turn is by default set to "$(bindir)/git". If you use git from binary
package, set this to "/usr/bin/git". This can just be "git" if your
webserver has a sensible PATH. If you have multiple git versions
@@ -169,7 +176,7 @@ not include variables usually directly set during build):
to make it easier to upgrade gitweb. You can add 'site' stylesheet
for example by using
push @stylesheets, "gitweb-site.css";
- in gitweb config file.
+ in the gitweb config file.
* $logo_url, $logo_label
URI and label (title) of GIT logo link (or your site logo, if you choose
to use different logo image). By default they point to git homepage;
@@ -191,12 +198,12 @@ not include variables usually directly set during build):
Default mimetype for blob_plain (raw) view, if mimetype checking
doesn't result in some other type; by default 'text/plain'.
* $default_text_plain_charset
- Default charset for text files. If not set, web serwer configuration
+ Default charset for text files. If not set, web server configuration
would be used.
* $mimetypes_file
File to use for (filename extension based) guessing of MIME types before
- trying /etc/mime.types. Path, if relative, is taken currently as taken
- relative to current git repositoy.
+ trying /etc/mime.types. Path, if relative, is taken currently as
+ relative to the current git repository.
* $fallback_encoding
Gitweb assumes this charset if line contains non-UTF-8 characters.
Fallback decoding is used without error checking, so it can be even
@@ -225,14 +232,14 @@ You can use the following files in repository:
single line description of a project (of a repository). Plain text file;
HTML will be escaped. By default set to
Unnamed repository; edit this file to name it for gitweb.
- from the template during creating repository. You can use
+ from the template during repository creation. You can use the
gitweb.description repo configuration variable, but the file takes
- precendence.
+ precedence.
* cloneurl (or multiple-valued gitweb.url)
File with repository URL (used for clone and fetch), one per line.
Displayed in the project summary page. You can use multiple-valued
gitweb.url repository configuration variable for that, but the file
- takes precendence.
+ takes precedence.
* gitweb.owner
You can use the gitweb.owner repository configuration variable to set
repository's owner. It is displayed in the project list and summary
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 446a1c333b..aa0eeca247 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -464,6 +464,14 @@ a.rss_logo:hover {
background-color: #ee5500;
}
+a.rss_logo.generic {
+ background-color: #ff8800;
+}
+
+a.rss_logo.generic:hover {
+ background-color: #ee7700;
+}
+
span.refs span {
padding: 0px 4px;
font-size: 70%;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 12843a4846..2facf2db7a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -369,7 +369,12 @@ sub filter_snapshot_fmts {
}
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+if (-e $GITWEB_CONFIG) {
+ do $GITWEB_CONFIG;
+} else {
+ our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+ do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
+}
# version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
@@ -587,7 +592,7 @@ exit;
## ======================================================================
## action links
-sub href(%) {
+sub href (%) {
my %params = @_;
# default is to use -absolute url() i.e. $my_uri
my $href = $params{-full} ? $my_url : $my_uri;
@@ -1443,6 +1448,46 @@ sub format_snapshot_links {
}
}
+## ......................................................................
+## functions returning values to be passed, perhaps after some
+## transformation, to other functions; e.g. returning arguments to href()
+
+# returns hash to be passed to href to generate gitweb URL
+# in -title key it returns description of link
+sub get_feed_info {
+ my $format = shift || 'Atom';
+ my %res = (action => lc($format));
+
+ # feed links are possible only for project views
+ return unless (defined $project);
+ # some views should link to OPML, or to generic project feed,
+ # or don't have specific feed yet (so they should use generic)
+ return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x);
+
+ my $branch;
+ # branches refs uses 'refs/heads/' prefix (fullname) to differentiate
+ # from tag links; this also makes possible to detect branch links
+ if ((defined $hash_base && $hash_base =~ m!^refs/heads/(.*)$!) ||
+ (defined $hash && $hash =~ m!^refs/heads/(.*)$!)) {
+ $branch = $1;
+ }
+ # find log type for feed description (title)
+ my $type = 'log';
+ if (defined $file_name) {
+ $type = "history of $file_name";
+ $type .= "/" if ($action eq 'tree');
+ $type .= " on '$branch'" if (defined $branch);
+ } else {
+ $type = "log of $branch" if (defined $branch);
+ }
+
+ $res{-title} = $type;
+ $res{'hash'} = (defined $branch ? "refs/heads/$branch" : undef);
+ $res{'file_name'} = $file_name;
+
+ return %res;
+}
+
## ----------------------------------------------------------------------
## git utility subroutines, invoking git commands
@@ -2505,30 +2550,49 @@ EOF
}
}
if (defined $project) {
- printf('<link rel="alternate" title="%s log RSS feed" '.
- 'href="%s" type="application/rss+xml" />'."\n",
- esc_param($project), href(action=>"rss"));
- printf('<link rel="alternate" title="%s log RSS feed (no merges)" '.
- 'href="%s" type="application/rss+xml" />'."\n",
- esc_param($project), href(action=>"rss",
- extra_options=>"--no-merges"));
- printf('<link rel="alternate" title="%s log Atom feed" '.
- 'href="%s" type="application/atom+xml" />'."\n",
- esc_param($project), href(action=>"atom"));
- printf('<link rel="alternate" title="%s log Atom feed (no merges)" '.
- 'href="%s" type="application/atom+xml" />'."\n",
- esc_param($project), href(action=>"atom",
- extra_options=>"--no-merges"));
+ my %href_params = get_feed_info();
+ if (!exists $href_params{'-title'}) {
+ $href_params{'-title'} = 'log';
+ }
+
+ foreach my $format qw(RSS Atom) {
+ my $type = lc($format);
+ my %link_attr = (
+ '-rel' => 'alternate',
+ '-title' => "$project - $href_params{'-title'} - $format feed",
+ '-type' => "application/$type+xml"
+ );
+
+ $href_params{'action'} = $type;
+ $link_attr{'-href'} = href(%href_params);
+ print "<link ".
+ "rel=\"$link_attr{'-rel'}\" ".
+ "title=\"$link_attr{'-title'}\" ".
+ "href=\"$link_attr{'-href'}\" ".
+ "type=\"$link_attr{'-type'}\" ".
+ "/>\n";
+
+ $href_params{'extra_options'} = '--no-merges';
+ $link_attr{'-href'} = href(%href_params);
+ $link_attr{'-title'} .= ' (no merges)';
+ print "<link ".
+ "rel=\"$link_attr{'-rel'}\" ".
+ "title=\"$link_attr{'-title'}\" ".
+ "href=\"$link_attr{'-href'}\" ".
+ "type=\"$link_attr{'-type'}\" ".
+ "/>\n";
+ }
+
} else {
printf('<link rel="alternate" title="%s projects list" '.
- 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
+ 'href="%s" type="text/plain; charset=utf-8" />'."\n",
$site_name, href(project=>undef, action=>"project_index"));
printf('<link rel="alternate" title="%s projects feeds" '.
- 'href="%s" type="text/x-opml"/>'."\n",
+ 'href="%s" type="text/x-opml" />'."\n",
$site_name, href(project=>undef, action=>"opml"));
}
if (defined $favicon) {
- print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
+ print qq(<link rel="shortcut icon" href="$favicon" type="image/png" />\n);
}
print "</head>\n" .
@@ -2596,23 +2660,35 @@ EOF
}
sub git_footer_html {
+ my $feed_class = 'rss_logo';
+
print "<div class=\"page_footer\">\n";
if (defined $project) {
my $descr = git_get_project_description($project);
if (defined $descr) {
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
}
- print $cgi->a({-href => href(action=>"rss"),
- -class => "rss_logo"}, "RSS") . " ";
- print $cgi->a({-href => href(action=>"atom"),
- -class => "rss_logo"}, "Atom") . "\n";
+
+ my %href_params = get_feed_info();
+ if (!%href_params) {
+ $feed_class .= ' generic';
+ }
+ $href_params{'-title'} ||= 'log';
+
+ foreach my $format qw(RSS Atom) {
+ $href_params{'action'} = lc($format);
+ print $cgi->a({-href => href(%href_params),
+ -title => "$href_params{'-title'} $format feed",
+ -class => $feed_class}, $format)."\n";
+ }
+
} else {
print $cgi->a({-href => href(project=>undef, action=>"opml"),
- -class => "rss_logo"}, "OPML") . " ";
+ -class => $feed_class}, "OPML") . " ";
print $cgi->a({-href => href(project=>undef, action=>"project_index"),
- -class => "rss_logo"}, "TXT") . "\n";
+ -class => $feed_class}, "TXT") . "\n";
}
- print "</div>\n" ;
+ print "</div>\n"; # class="page_footer"
if (-f $site_footer) {
open (my $fd, $site_footer);
diff --git a/help.c b/help.c
index 10298fb0a1..af80979fcb 100644
--- a/help.c
+++ b/help.c
@@ -11,10 +11,16 @@
#include "run-command.h"
static struct man_viewer_list {
- void (*exec)(const char *);
struct man_viewer_list *next;
+ char name[FLEX_ARRAY];
} *man_viewer_list;
+static struct man_viewer_info_list {
+ struct man_viewer_info_list *next;
+ const char *info;
+ char name[FLEX_ARRAY];
+} *man_viewer_info_list;
+
enum help_format {
HELP_FORMAT_MAN,
HELP_FORMAT_INFO,
@@ -49,6 +55,18 @@ static enum help_format parse_help_format(const char *format)
die("unrecognized help format '%s'", format);
}
+static const char *get_man_viewer_info(const char *name)
+{
+ struct man_viewer_info_list *viewer;
+
+ for (viewer = man_viewer_info_list; viewer; viewer = viewer->next)
+ {
+ if (!strcasecmp(name, viewer->name))
+ return viewer->info;
+ }
+ return NULL;
+}
+
static int check_emacsclient_version(void)
{
struct strbuf buffer = STRBUF_INIT;
@@ -95,56 +113,145 @@ static int check_emacsclient_version(void)
return 0;
}
-static void exec_woman_emacs(const char *page)
+static void exec_woman_emacs(const char* path, const char *page)
{
if (!check_emacsclient_version()) {
/* This works only with emacsclient version >= 22. */
struct strbuf man_page = STRBUF_INIT;
+
+ if (!path)
+ path = "emacsclient";
strbuf_addf(&man_page, "(woman \"%s\")", page);
- execlp("emacsclient", "emacsclient", "-e", man_page.buf, NULL);
+ execlp(path, "emacsclient", "-e", man_page.buf, NULL);
+ warning("failed to exec '%s': %s", path, strerror(errno));
}
}
-static void exec_man_konqueror(const char *page)
+static void exec_man_konqueror(const char* path, const char *page)
{
const char *display = getenv("DISPLAY");
if (display && *display) {
struct strbuf man_page = STRBUF_INIT;
+ const char *filename = "kfmclient";
+
+ /* It's simpler to launch konqueror using kfmclient. */
+ if (path) {
+ const char *file = strrchr(path, '/');
+ if (file && !strcmp(file + 1, "konqueror")) {
+ char *new = xstrdup(path);
+ char *dest = strrchr(new, '/');
+
+ /* strlen("konqueror") == strlen("kfmclient") */
+ strcpy(dest + 1, "kfmclient");
+ path = new;
+ }
+ if (file)
+ filename = file;
+ } else
+ path = "kfmclient";
strbuf_addf(&man_page, "man:%s(1)", page);
- execlp("kfmclient", "kfmclient", "newTab", man_page.buf, NULL);
+ execlp(path, filename, "newTab", man_page.buf, NULL);
+ warning("failed to exec '%s': %s", path, strerror(errno));
}
}
-static void exec_man_man(const char *page)
+static void exec_man_man(const char* path, const char *page)
+{
+ if (!path)
+ path = "man";
+ execlp(path, "man", page, NULL);
+ warning("failed to exec '%s': %s", path, strerror(errno));
+}
+
+static void exec_man_cmd(const char *cmd, const char *page)
{
- execlp("man", "man", page, NULL);
+ struct strbuf shell_cmd = STRBUF_INIT;
+ strbuf_addf(&shell_cmd, "%s %s", cmd, page);
+ execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL);
+ warning("failed to exec '%s': %s", cmd, strerror(errno));
}
-static void do_add_man_viewer(void (*exec)(const char *))
+static void add_man_viewer(const char *name)
{
struct man_viewer_list **p = &man_viewer_list;
+ size_t len = strlen(name);
while (*p)
p = &((*p)->next);
- *p = xmalloc(sizeof(**p));
- (*p)->next = NULL;
- (*p)->exec = exec;
+ *p = xcalloc(1, (sizeof(**p) + len + 1));
+ strncpy((*p)->name, name, len);
}
-static int add_man_viewer(const char *value)
+static int supported_man_viewer(const char *name, size_t len)
{
- if (!strcasecmp(value, "man"))
- do_add_man_viewer(exec_man_man);
- else if (!strcasecmp(value, "woman"))
- do_add_man_viewer(exec_woman_emacs);
- else if (!strcasecmp(value, "konqueror"))
- do_add_man_viewer(exec_man_konqueror);
+ return (!strncasecmp("man", name, len) ||
+ !strncasecmp("woman", name, len) ||
+ !strncasecmp("konqueror", name, len));
+}
+
+static void do_add_man_viewer_info(const char *name,
+ size_t len,
+ const char *value)
+{
+ struct man_viewer_info_list *new = xcalloc(1, sizeof(*new) + len + 1);
+
+ strncpy(new->name, name, len);
+ new->info = xstrdup(value);
+ new->next = man_viewer_info_list;
+ man_viewer_info_list = new;
+}
+
+static int add_man_viewer_path(const char *name,
+ size_t len,
+ const char *value)
+{
+ if (supported_man_viewer(name, len))
+ do_add_man_viewer_info(name, len, value);
else
- warning("'%s': unsupported man viewer.", value);
+ warning("'%s': path for unsupported man viewer.\n"
+ "Please consider using 'man.<tool>.cmd' instead.",
+ name);
return 0;
}
+static int add_man_viewer_cmd(const char *name,
+ size_t len,
+ const char *value)
+{
+ if (supported_man_viewer(name, len))
+ warning("'%s': cmd for supported man viewer.\n"
+ "Please consider using 'man.<tool>.path' instead.",
+ name);
+ else
+ do_add_man_viewer_info(name, len, value);
+
+ return 0;
+}
+
+static int add_man_viewer_info(const char *var, const char *value)
+{
+ const char *name = var + 4;
+ const char *subkey = strrchr(name, '.');
+
+ if (!subkey)
+ return error("Config with no key for man viewer: %s", name);
+
+ if (!strcmp(subkey, ".path")) {
+ if (!value)
+ return config_error_nonbool(var);
+ return add_man_viewer_path(name, subkey - name, value);
+ }
+ if (!strcmp(subkey, ".cmd")) {
+ if (!value)
+ return config_error_nonbool(var);
+ return add_man_viewer_cmd(name, subkey - name, value);
+ }
+
+ warning("'%s': unsupported man viewer sub key.", subkey);
+ return 0;
+}
+
static int git_help_config(const char *var, const char *value)
{
if (!strcmp(var, "help.format")) {
@@ -156,8 +263,12 @@ static int git_help_config(const char *var, const char *value)
if (!strcmp(var, "man.viewer")) {
if (!value)
return config_error_nonbool(var);
- return add_man_viewer(value);
+ add_man_viewer(value);
+ return 0;
}
+ if (!prefixcmp(var, "man."))
+ return add_man_viewer_info(var, value);
+
return git_default_config(var, value);
}
@@ -453,6 +564,22 @@ static void setup_man_path(void)
strbuf_release(&new_path);
}
+static void exec_viewer(const char *name, const char *page)
+{
+ const char *info = get_man_viewer_info(name);
+
+ if (!strcasecmp(name, "man"))
+ exec_man_man(info, page);
+ else if (!strcasecmp(name, "woman"))
+ exec_woman_emacs(info, page);
+ else if (!strcasecmp(name, "konqueror"))
+ exec_man_konqueror(info, page);
+ else if (info)
+ exec_man_cmd(info, page);
+ else
+ warning("'%s': unknown man viewer.", name);
+}
+
static void show_man_page(const char *git_cmd)
{
struct man_viewer_list *viewer;
@@ -461,9 +588,9 @@ static void show_man_page(const char *git_cmd)
setup_man_path();
for (viewer = man_viewer_list; viewer; viewer = viewer->next)
{
- viewer->exec(page); /* will return when unable */
+ exec_viewer(viewer->name, page); /* will return when unable */
}
- exec_man_man(page);
+ exec_viewer("man", page);
die("no man viewer handled the request");
}
diff --git a/http-push.c b/http-push.c
index 5b230380cc..42727c8a45 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1759,15 +1759,15 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
static void one_remote_ref(char *refname)
{
struct ref *ref;
- unsigned char remote_sha1[20];
struct object *obj;
- int len = strlen(refname) + 1;
- if (http_fetch_ref(remote->url, refname + 5 /* "refs/" */,
- remote_sha1) != 0) {
+ ref = alloc_ref_from_str(refname);
+
+ if (http_fetch_ref(remote->url, ref) != 0) {
fprintf(stderr,
"Unable to fetch ref %s from %s\n",
refname, remote->url);
+ free(ref);
return;
}
@@ -1775,18 +1775,15 @@ static void one_remote_ref(char *refname)
* Fetch a copy of the object if it doesn't exist locally - it
* may be required for updating server info later.
*/
- if (remote->can_update_info_refs && !has_sha1_file(remote_sha1)) {
- obj = lookup_unknown_object(remote_sha1);
+ if (remote->can_update_info_refs && !has_sha1_file(ref->old_sha1)) {
+ obj = lookup_unknown_object(ref->old_sha1);
if (obj) {
fprintf(stderr, " fetch %s for %s\n",
- sha1_to_hex(remote_sha1), refname);
+ sha1_to_hex(ref->old_sha1), refname);
add_fetch_request(obj);
}
}
- ref = xcalloc(1, sizeof(*ref) + len);
- hashcpy(ref->old_sha1, remote_sha1);
- memcpy(ref->name, refname, len);
*remote_tail = ref;
remote_tail = &ref->next;
}
@@ -1891,33 +1888,36 @@ static void mark_edges_uninteresting(struct commit_list *list)
static void add_remote_info_ref(struct remote_ls_ctx *ls)
{
struct strbuf *buf = (struct strbuf *)ls->userData;
- unsigned char remote_sha1[20];
struct object *o;
int len;
char *ref_info;
+ struct ref *ref;
+
+ ref = alloc_ref_from_str(ls->dentry_name);
- if (http_fetch_ref(remote->url, ls->dentry_name + 5 /* "refs/" */,
- remote_sha1) != 0) {
+ if (http_fetch_ref(remote->url, ref) != 0) {
fprintf(stderr,
"Unable to fetch ref %s from %s\n",
ls->dentry_name, remote->url);
aborted = 1;
+ free(ref);
return;
}
- o = parse_object(remote_sha1);
+ o = parse_object(ref->old_sha1);
if (!o) {
fprintf(stderr,
"Unable to parse object %s for remote ref %s\n",
- sha1_to_hex(remote_sha1), ls->dentry_name);
+ sha1_to_hex(ref->old_sha1), ls->dentry_name);
aborted = 1;
+ free(ref);
return;
}
len = strlen(ls->dentry_name) + 42;
ref_info = xcalloc(len + 1, 1);
sprintf(ref_info, "%s %s\n",
- sha1_to_hex(remote_sha1), ls->dentry_name);
+ sha1_to_hex(ref->old_sha1), ls->dentry_name);
fwrite_buffer(ref_info, 1, len, buf);
free(ref_info);
@@ -1932,6 +1932,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
free(ref_info);
}
}
+ free(ref);
}
static void update_remote_info_refs(struct remote_lock *lock)
diff --git a/http-walker.c b/http-walker.c
index 7bda34d914..99f397e32b 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -888,10 +888,10 @@ static int fetch(struct walker *walker, unsigned char *sha1)
data->alt->base);
}
-static int fetch_ref(struct walker *walker, char *ref, unsigned char *sha1)
+static int fetch_ref(struct walker *walker, struct ref *ref)
{
struct walker_data *data = walker->data;
- return http_fetch_ref(data->alt->base, ref, sha1);
+ return http_fetch_ref(data->alt->base, ref);
}
static void cleanup(struct walker *walker)
diff --git a/http.c b/http.c
index 256a5f15f4..acf746a12d 100644
--- a/http.c
+++ b/http.c
@@ -589,8 +589,9 @@ static char *quote_ref_url(const char *base, const char *ref)
len += 2; /* extra two hex plus replacement % */
qref = xmalloc(len);
memcpy(qref, base, baselen);
- memcpy(qref + baselen, "/refs/", 6);
- for (cp = ref, dp = qref + baselen + 6; (ch = *cp) != 0; cp++) {
+ dp = qref + baselen;
+ *(dp++) = '/';
+ for (cp = ref; (ch = *cp) != 0; cp++) {
if (needs_quote(ch)) {
*dp++ = '%';
*dp++ = hex((ch >> 4) & 0xF);
@@ -604,7 +605,7 @@ static char *quote_ref_url(const char *base, const char *ref)
return qref;
}
-int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1)
+int http_fetch_ref(const char *base, struct ref *ref)
{
char *url;
struct strbuf buffer = STRBUF_INIT;
@@ -612,7 +613,7 @@ int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1)
struct slot_results results;
int ret;
- url = quote_ref_url(base, ref);
+ url = quote_ref_url(base, ref->name);
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
@@ -624,12 +625,15 @@ int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1)
if (results.curl_result == CURLE_OK) {
strbuf_rtrim(&buffer);
if (buffer.len == 40)
- ret = get_sha1_hex(buffer.buf, sha1);
- else
+ ret = get_sha1_hex(buffer.buf, ref->old_sha1);
+ else if (!prefixcmp(buffer.buf, "ref: ")) {
+ ref->symref = xstrdup(buffer.buf + 5);
+ ret = 0;
+ } else
ret = 1;
} else {
ret = error("Couldn't get %s for %s\n%s",
- url, ref, curl_errorstr);
+ url, ref->name, curl_errorstr);
}
} else {
ret = error("Unable to start request");
diff --git a/http.h b/http.h
index 04169d5f9c..a04fc6a927 100644
--- a/http.h
+++ b/http.h
@@ -105,6 +105,6 @@ static inline int missing__target(int code, int result)
#define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
-extern int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1);
+extern int http_fetch_ref(const char *base, struct ref *ref);
#endif /* HTTP_H */
diff --git a/ident.c b/ident.c
index ed44a5345a..b35504a8d2 100644
--- a/ident.c
+++ b/ident.c
@@ -250,6 +250,9 @@ const char *git_author_info(int flag)
const char *git_committer_info(int flag)
{
+ if (getenv("GIT_COMMITTER_NAME") &&
+ getenv("GIT_COMMITTER_EMAIL"))
+ user_ident_explicitly_given = 1;
return fmt_ident(getenv("GIT_COMMITTER_NAME"),
getenv("GIT_COMMITTER_EMAIL"),
getenv("GIT_COMMITTER_DATE"),
diff --git a/log-tree.c b/log-tree.c
index 5b2963998c..d3fb0e520c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -208,14 +208,13 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
*extra_headers_p = extra_headers;
}
-void show_log(struct rev_info *opt, const char *sep)
+void show_log(struct rev_info *opt)
{
struct strbuf msgbuf;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
- const char *extra;
const char *subject = NULL, *extra_headers = opt->extra_headers;
int need_8bit_cte = 0;
@@ -240,18 +239,11 @@ void show_log(struct rev_info *opt, const char *sep)
}
/*
- * The "oneline" format has several special cases:
- * - The pretty-printed commit lacks a newline at the end
- * of the buffer, but we do want to make sure that we
- * have a newline there. If the separator isn't already
- * a newline, add an extra one.
- * - unlike other log messages, the one-line format does
- * not have an empty line between entries.
+ * If use_terminator is set, add a newline at the end of the entry.
+ * Otherwise, add a diffopt.line_termination character before all
+ * entries but the first. (IOW, as a separator between entries)
*/
- extra = "";
- if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
- extra = "\n";
- if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
+ if (opt->shown_one && !opt->use_terminator)
putchar(opt->diffopt.line_termination);
opt->shown_one = 1;
@@ -292,10 +284,8 @@ void show_log(struct rev_info *opt, const char *sep)
show_reflog_message(opt->reflog_info,
opt->commit_format == CMIT_FMT_ONELINE,
opt->date_mode);
- if (opt->commit_format == CMIT_FMT_ONELINE) {
- printf("%s", sep);
+ if (opt->commit_format == CMIT_FMT_ONELINE)
return;
- }
}
}
@@ -318,7 +308,9 @@ void show_log(struct rev_info *opt, const char *sep)
printf("log size %i\n", (int)msgbuf.len);
if (msgbuf.len)
- printf("%s%s%s", msgbuf.buf, extra, sep);
+ fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+ if (opt->use_terminator)
+ putchar('\n');
strbuf_release(&msgbuf);
}
@@ -340,7 +332,7 @@ int log_tree_diff_flush(struct rev_info *opt)
* an extra newline between the end of log and the
* output for readability.
*/
- show_log(opt, opt->diffopt.msg_sep);
+ show_log(opt);
if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
opt->verbose_header &&
opt->commit_format != CMIT_FMT_ONELINE) {
@@ -428,7 +420,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
shown = log_tree_diff(opt, commit, &log);
if (!shown && opt->loginfo && opt->always_show_header) {
log.parent = NULL;
- show_log(opt, "");
+ show_log(opt);
shown = 1;
}
opt->loginfo = NULL;
diff --git a/log-tree.h b/log-tree.h
index 8946ff377c..59ba4c48b7 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -11,7 +11,7 @@ void init_log_tree_opt(struct rev_info *);
int log_tree_diff_flush(struct rev_info *);
int log_tree_commit(struct rev_info *, struct commit *);
int log_tree_opt_parse(struct rev_info *, const char **, int);
-void show_log(struct rev_info *opt, const char *sep);
+void show_log(struct rev_info *opt);
void show_decorations(struct commit *commit);
void log_write_email_headers(struct rev_info *opt, const char *name,
const char **subject_p,
diff --git a/name-hash.c b/name-hash.c
new file mode 100644
index 0000000000..0031d78e8c
--- /dev/null
+++ b/name-hash.c
@@ -0,0 +1,119 @@
+/*
+ * name-hash.c
+ *
+ * Hashing names in the index state
+ *
+ * Copyright (C) 2008 Linus Torvalds
+ */
+#define NO_THE_INDEX_COMPATIBILITY_MACROS
+#include "cache.h"
+
+/*
+ * This removes bit 5 if bit 6 is set.
+ *
+ * That will make US-ASCII characters hash to their upper-case
+ * equivalent. We could easily do this one whole word at a time,
+ * but that's for future worries.
+ */
+static inline unsigned char icase_hash(unsigned char c)
+{
+ return c & ~((c & 0x40) >> 1);
+}
+
+static unsigned int hash_name(const char *name, int namelen)
+{
+ unsigned int hash = 0x123;
+
+ do {
+ unsigned char c = *name++;
+ c = icase_hash(c);
+ hash = hash*101 + c;
+ } while (--namelen);
+ return hash;
+}
+
+static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
+{
+ void **pos;
+ unsigned int hash;
+
+ if (ce->ce_flags & CE_HASHED)
+ return;
+ ce->ce_flags |= CE_HASHED;
+ ce->next = NULL;
+ hash = hash_name(ce->name, ce_namelen(ce));
+ pos = insert_hash(hash, ce, &istate->name_hash);
+ if (pos) {
+ ce->next = *pos;
+ *pos = ce;
+ }
+}
+
+static void lazy_init_name_hash(struct index_state *istate)
+{
+ int nr;
+
+ if (istate->name_hash_initialized)
+ return;
+ for (nr = 0; nr < istate->cache_nr; nr++)
+ hash_index_entry(istate, istate->cache[nr]);
+ istate->name_hash_initialized = 1;
+}
+
+void add_name_hash(struct index_state *istate, struct cache_entry *ce)
+{
+ ce->ce_flags &= ~CE_UNHASHED;
+ if (istate->name_hash_initialized)
+ hash_index_entry(istate, ce);
+}
+
+static int slow_same_name(const char *name1, int len1, const char *name2, int len2)
+{
+ if (len1 != len2)
+ return 0;
+
+ while (len1) {
+ unsigned char c1 = *name1++;
+ unsigned char c2 = *name2++;
+ len1--;
+ if (c1 != c2) {
+ c1 = toupper(c1);
+ c2 = toupper(c2);
+ if (c1 != c2)
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static int same_name(const struct cache_entry *ce, const char *name, int namelen, int icase)
+{
+ int len = ce_namelen(ce);
+
+ /*
+ * Always do exact compare, even if we want a case-ignoring comparison;
+ * we do the quick exact one first, because it will be the common case.
+ */
+ if (len == namelen && !cache_name_compare(name, namelen, ce->name, len))
+ return 1;
+
+ return icase && slow_same_name(name, namelen, ce->name, len);
+}
+
+struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen, int icase)
+{
+ unsigned int hash = hash_name(name, namelen);
+ struct cache_entry *ce;
+
+ lazy_init_name_hash(istate);
+ ce = lookup_hash(hash, &istate->name_hash);
+
+ while (ce) {
+ if (!(ce->ce_flags & CE_UNHASHED)) {
+ if (same_name(ce, name, namelen, icase))
+ return ce;
+ }
+ ce = ce->next;
+ }
+ return NULL;
+}
diff --git a/pack-write.c b/pack-write.c
index 665e2b29b8..c66c8af725 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -183,7 +183,6 @@ void fixup_pack_header_footer(int pack_fd,
char *index_pack_lockfile(int ip_out)
{
- int len, s;
char packname[46];
/*
@@ -193,11 +192,8 @@ char *index_pack_lockfile(int ip_out)
* case, we need it to remove the corresponding .keep file
* later on. If we don't get that then tough luck with it.
*/
- for (len = 0;
- len < 46 && (s = xread(ip_out, packname+len, 46-len)) > 0;
- len += s);
- if (len == 46 && packname[45] == '\n' &&
- memcmp(packname, "keep\t", 5) == 0) {
+ if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n' &&
+ memcmp(packname, "keep\t", 5) == 0) {
char path[PATH_MAX];
packname[45] = 0;
snprintf(path, sizeof(path), "%s/pack/pack-%s.keep",
diff --git a/path.c b/path.c
index f4ed979997..b7c24a2aac 100644
--- a/path.c
+++ b/path.c
@@ -91,7 +91,8 @@ int validate_headref(const char *path)
struct stat st;
char *buf, buffer[256];
unsigned char sha1[20];
- int len, fd;
+ int fd;
+ ssize_t len;
if (lstat(path, &st) < 0)
return -1;
@@ -266,24 +267,25 @@ int adjust_shared_perm(const char *path)
if (lstat(path, &st) < 0)
return -1;
mode = st.st_mode;
- if (mode & S_IRUSR)
- mode |= (shared_repository == PERM_GROUP
- ? S_IRGRP
- : (shared_repository == PERM_EVERYBODY
- ? (S_IRGRP|S_IROTH)
- : 0));
-
- if (mode & S_IWUSR)
- mode |= S_IWGRP;
-
- if (mode & S_IXUSR)
- mode |= (shared_repository == PERM_GROUP
- ? S_IXGRP
- : (shared_repository == PERM_EVERYBODY
- ? (S_IXGRP|S_IXOTH)
- : 0));
- if (S_ISDIR(mode))
+
+ if (shared_repository) {
+ int tweak = shared_repository;
+ if (!(mode & S_IWUSR))
+ tweak &= ~0222;
+ mode = (mode & ~0777) | tweak;
+ } else {
+ /* Preserve old PERM_UMASK behaviour */
+ if (mode & S_IWUSR)
+ mode |= S_IWGRP;
+ }
+
+ if (S_ISDIR(mode)) {
mode |= FORCE_DIR_SET_GID;
+
+ /* Copy read bits to execute bits */
+ mode |= (shared_repository & 0444) >> 2;
+ }
+
if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
return -2;
return 0;
diff --git a/perl/Git.pm b/perl/Git.pm
index a2812ea612..2e7f896bae 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -487,22 +487,20 @@ does. In scalar context requires the variable to be set only one time
(exception is thrown otherwise), in array context returns allows the
variable to be set multiple times and returns all the values.
-Must be called on a repository instance.
-
This currently wraps command('config') so it is not so fast.
=cut
sub config {
- my ($self, $var) = @_;
- $self->repo_path()
- or throw Error::Simple("not a repository");
+ my ($self, $var) = _maybe_self(@_);
try {
+ my @cmd = ('config');
+ unshift @cmd, $self if $self;
if (wantarray) {
- return $self->command('config', '--get-all', $var);
+ return command(@cmd, '--get-all', $var);
} else {
- return $self->command_oneline('config', '--get', $var);
+ return command_oneline(@cmd, '--get', $var);
}
} catch Git::Error::Command with {
my $E = shift;
@@ -522,20 +520,17 @@ Retrieve the bool configuration C<VARIABLE>. The return value
is usable as a boolean in perl (and C<undef> if it's not defined,
of course).
-Must be called on a repository instance.
-
This currently wraps command('config') so it is not so fast.
=cut
sub config_bool {
- my ($self, $var) = @_;
- $self->repo_path()
- or throw Error::Simple("not a repository");
+ my ($self, $var) = _maybe_self(@_);
try {
- my $val = $self->command_oneline('config', '--bool', '--get',
- $var);
+ my @cmd = ('config', '--bool', '--get', $var);
+ unshift @cmd, $self if $self;
+ my $val = command_oneline(@cmd);
return undef unless defined $val;
return $val eq 'true';
} catch Git::Error::Command with {
@@ -557,19 +552,17 @@ or 'g' in the config file will cause the value to be multiplied
by 1024, 1048576 (1024^2), or 1073741824 (1024^3) prior to output.
It would return C<undef> if configuration variable is not defined,
-Must be called on a repository instance.
-
This currently wraps command('config') so it is not so fast.
=cut
sub config_int {
- my ($self, $var) = @_;
- $self->repo_path()
- or throw Error::Simple("not a repository");
+ my ($self, $var) = _maybe_self(@_);
try {
- return $self->command_oneline('config', '--int', '--get', $var);
+ my @cmd = ('config', '--int', '--get', $var);
+ unshift @cmd, $self if $self;
+ return command_oneline(@cmd);
} catch Git::Error::Command with {
my $E = shift;
if ($E->value() == 1) {
@@ -639,15 +632,15 @@ The synopsis is like:
"$name <$email>" eq ident_person($name);
$time_tz =~ /^\d+ [+-]\d{4}$/;
-Both methods must be called on a repository instance.
-
=cut
sub ident {
- my ($self, $type) = @_;
+ my ($self, $type) = _maybe_self(@_);
my $identstr;
if (lc $type eq lc 'committer' or lc $type eq lc 'author') {
- $identstr = $self->command_oneline('var', 'GIT_'.uc($type).'_IDENT');
+ my @cmd = ('var', 'GIT_'.uc($type).'_IDENT');
+ unshift @cmd, $self if $self;
+ $identstr = command_oneline(@cmd);
} else {
$identstr = $type;
}
@@ -659,8 +652,8 @@ sub ident {
}
sub ident_person {
- my ($self, @ident) = @_;
- $#ident == 0 and @ident = $self->ident($ident[0]);
+ my ($self, @ident) = _maybe_self(@_);
+ $#ident == 0 and @ident = $self ? $self->ident($ident[0]) : ident($ident[0]);
return "$ident[0] <$ident[1]>";
}
diff --git a/pkt-line.c b/pkt-line.c
index 355546a1ad..f5d00863a6 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -65,16 +65,11 @@ void packet_write(int fd, const char *fmt, ...)
static void safe_read(int fd, void *buffer, unsigned size)
{
- size_t n = 0;
-
- while (n < size) {
- ssize_t ret = xread(fd, (char *) buffer + n, size - n);
- if (ret < 0)
- die("read error (%s)", strerror(errno));
- if (!ret)
- die("The remote end hung up unexpectedly");
- n += ret;
- }
+ ssize_t ret = read_in_full(fd, buffer, size);
+ if (ret < 0)
+ die("read error (%s)", strerror(errno));
+ else if (ret < size)
+ die("The remote end hung up unexpectedly");
}
int packet_read_line(int fd, char *buffer, unsigned size)
diff --git a/pretty.c b/pretty.c
index 16bfb86cd3..687293224c 100644
--- a/pretty.c
+++ b/pretty.c
@@ -4,40 +4,49 @@
#include "diff.h"
#include "revision.h"
-static struct cmt_fmt_map {
- const char *n;
- size_t cmp_len;
- enum cmit_fmt v;
-} cmt_fmts[] = {
- { "raw", 1, CMIT_FMT_RAW },
- { "medium", 1, CMIT_FMT_MEDIUM },
- { "short", 1, CMIT_FMT_SHORT },
- { "email", 1, CMIT_FMT_EMAIL },
- { "full", 5, CMIT_FMT_FULL },
- { "fuller", 5, CMIT_FMT_FULLER },
- { "oneline", 1, CMIT_FMT_ONELINE },
- { "format:", 7, CMIT_FMT_USERFORMAT},
-};
-
static char *user_format;
-enum cmit_fmt get_commit_format(const char *arg)
+void get_commit_format(const char *arg, struct rev_info *rev)
{
int i;
-
- if (!arg || !*arg)
- return CMIT_FMT_DEFAULT;
+ static struct cmt_fmt_map {
+ const char *n;
+ size_t cmp_len;
+ enum cmit_fmt v;
+ } cmt_fmts[] = {
+ { "raw", 1, CMIT_FMT_RAW },
+ { "medium", 1, CMIT_FMT_MEDIUM },
+ { "short", 1, CMIT_FMT_SHORT },
+ { "email", 1, CMIT_FMT_EMAIL },
+ { "full", 5, CMIT_FMT_FULL },
+ { "fuller", 5, CMIT_FMT_FULLER },
+ { "oneline", 1, CMIT_FMT_ONELINE },
+ };
+
+ rev->use_terminator = 0;
+ if (!arg || !*arg) {
+ rev->commit_format = CMIT_FMT_DEFAULT;
+ return;
+ }
if (*arg == '=')
arg++;
- if (!prefixcmp(arg, "format:")) {
+ if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
+ const char *cp = strchr(arg, ':') + 1;
free(user_format);
- user_format = xstrdup(arg + 7);
- return CMIT_FMT_USERFORMAT;
+ user_format = xstrdup(cp);
+ if (arg[0] == 't')
+ rev->use_terminator = 1;
+ rev->commit_format = CMIT_FMT_USERFORMAT;
+ return;
}
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
- !strncmp(arg, cmt_fmts[i].n, strlen(arg)))
- return cmt_fmts[i].v;
+ !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
+ if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
+ rev->use_terminator = 1;
+ rev->commit_format = cmt_fmts[i].v;
+ return;
+ }
}
die("invalid --pretty format: %s", arg);
@@ -457,6 +466,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
const struct commit *commit = c->commit;
const char *msg = commit->buffer;
struct commit_list *p;
+ int h1, h2;
/* these are independent of the commit */
switch (placeholder[0]) {
@@ -478,6 +488,16 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
case 'n': /* newline */
strbuf_addch(sb, '\n');
return 1;
+ case 'x':
+ /* %x00 == NUL, %x0a == LF, etc. */
+ if (0 <= (h1 = hexval_table[0xff & placeholder[1]]) &&
+ h1 <= 16 &&
+ 0 <= (h2 = hexval_table[0xff & placeholder[2]]) &&
+ h2 <= 16) {
+ strbuf_addch(sb, (h1<<4)|h2);
+ return 3;
+ } else
+ return 0;
}
/* these depend on the commit */
diff --git a/read-cache.c b/read-cache.c
index a92b25b59b..0382804e76 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -23,80 +23,21 @@
struct index_state the_index;
-static unsigned int hash_name(const char *name, int namelen)
-{
- unsigned int hash = 0x123;
-
- do {
- unsigned char c = *name++;
- hash = hash*101 + c;
- } while (--namelen);
- return hash;
-}
-
-static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
-{
- void **pos;
- unsigned int hash;
-
- if (ce->ce_flags & CE_HASHED)
- return;
- ce->ce_flags |= CE_HASHED;
- ce->next = NULL;
- hash = hash_name(ce->name, ce_namelen(ce));
- pos = insert_hash(hash, ce, &istate->name_hash);
- if (pos) {
- ce->next = *pos;
- *pos = ce;
- }
-}
-
-static void lazy_init_name_hash(struct index_state *istate)
-{
- int nr;
-
- if (istate->name_hash_initialized)
- return;
- for (nr = 0; nr < istate->cache_nr; nr++)
- hash_index_entry(istate, istate->cache[nr]);
- istate->name_hash_initialized = 1;
-}
-
static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
{
- ce->ce_flags &= ~CE_UNHASHED;
istate->cache[nr] = ce;
- if (istate->name_hash_initialized)
- hash_index_entry(istate, ce);
+ add_name_hash(istate, ce);
}
static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
{
struct cache_entry *old = istate->cache[nr];
- remove_index_entry(old);
+ remove_name_hash(old);
set_index_entry(istate, nr, ce);
istate->cache_changed = 1;
}
-int index_name_exists(struct index_state *istate, const char *name, int namelen)
-{
- unsigned int hash = hash_name(name, namelen);
- struct cache_entry *ce;
-
- lazy_init_name_hash(istate);
- ce = lookup_hash(hash, &istate->name_hash);
-
- while (ce) {
- if (!(ce->ce_flags & CE_UNHASHED)) {
- if (!cache_name_compare(name, namelen, ce->name, ce->ce_flags))
- return 1;
- }
- ce = ce->next;
- }
- return 0;
-}
-
/*
* This only updates the "non-critical" parts of the directory
* cache, ie the parts that aren't tracked by GIT, and only used
@@ -257,7 +198,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
static int is_racy_timestamp(const struct index_state *istate, struct cache_entry *ce)
{
- return (istate->timestamp &&
+ return (!S_ISGITLINK(ce->ce_mode) &&
+ istate->timestamp &&
((unsigned int)istate->timestamp) <= ce->ce_mtime);
}
@@ -438,7 +380,7 @@ int remove_index_entry_at(struct index_state *istate, int pos)
{
struct cache_entry *ce = istate->cache[pos];
- remove_index_entry(ce);
+ remove_name_hash(ce);
istate->cache_changed = 1;
istate->cache_nr--;
if (pos >= istate->cache_nr)
@@ -488,21 +430,50 @@ static int index_name_pos_also_unmerged(struct index_state *istate,
return pos;
}
-int add_file_to_index(struct index_state *istate, const char *path, int verbose)
+static int different_name(struct cache_entry *ce, struct cache_entry *alias)
{
- int size, namelen, pos;
- struct stat st;
- struct cache_entry *ce;
- unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
+ int len = ce_namelen(ce);
+ return ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);
+}
- if (lstat(path, &st))
- die("%s: unable to stat (%s)", path, strerror(errno));
+/*
+ * If we add a filename that aliases in the cache, we will use the
+ * name that we already have - but we don't want to update the same
+ * alias twice, because that implies that there were actually two
+ * different files with aliasing names!
+ *
+ * So we use the CE_ADDED flag to verify that the alias was an old
+ * one before we accept it as
+ */
+static struct cache_entry *create_alias_ce(struct cache_entry *ce, struct cache_entry *alias)
+{
+ int len;
+ struct cache_entry *new;
+
+ if (alias->ce_flags & CE_ADDED)
+ die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
+
+ /* Ok, create the new entry using the name of the existing alias */
+ len = ce_namelen(alias);
+ new = xcalloc(1, cache_entry_size(len));
+ memcpy(new->name, alias->name, len);
+ copy_cache_entry(new, ce);
+ free(ce);
+ return new;
+}
+
+int add_to_index(struct index_state *istate, const char *path, struct stat *st, int verbose)
+{
+ int size, namelen;
+ mode_t st_mode = st->st_mode;
+ struct cache_entry *ce, *alias;
+ unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
- if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) && !S_ISDIR(st.st_mode))
+ if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
die("%s: can only add regular files, symbolic links or git-directories", path);
namelen = strlen(path);
- if (S_ISDIR(st.st_mode)) {
+ if (S_ISDIR(st_mode)) {
while (namelen && path[namelen-1] == '/')
namelen--;
}
@@ -510,10 +481,10 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
ce = xcalloc(1, size);
memcpy(ce->name, path, namelen);
ce->ce_flags = namelen;
- fill_stat_cache_info(ce, &st);
+ fill_stat_cache_info(ce, st);
if (trust_executable_bit && has_symlinks)
- ce->ce_mode = create_ce_mode(st.st_mode);
+ ce->ce_mode = create_ce_mode(st_mode);
else {
/* If there is an existing entry, pick the mode bits and type
* from it, otherwise assume unexecutable regular file.
@@ -522,21 +493,22 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
int pos = index_name_pos_also_unmerged(istate, path, namelen);
ent = (0 <= pos) ? istate->cache[pos] : NULL;
- ce->ce_mode = ce_mode_from_stat(ent, st.st_mode);
+ ce->ce_mode = ce_mode_from_stat(ent, st_mode);
}
- pos = index_name_pos(istate, ce->name, namelen);
- if (0 <= pos &&
- !ce_stage(istate->cache[pos]) &&
- !ie_match_stat(istate, istate->cache[pos], &st, ce_option)) {
+ alias = index_name_exists(istate, ce->name, ce_namelen(ce), ignore_case);
+ if (alias && !ce_stage(alias) && !ie_match_stat(istate, alias, st, ce_option)) {
/* Nothing changed, really */
free(ce);
- ce_mark_uptodate(istate->cache[pos]);
+ ce_mark_uptodate(alias);
+ alias->ce_flags |= CE_ADDED;
return 0;
}
-
- if (index_path(ce->sha1, path, &st, 1))
+ if (index_path(ce->sha1, path, st, 1))
die("unable to index file %s", path);
+ if (ignore_case && alias && different_name(ce, alias))
+ ce = create_alias_ce(ce, alias);
+ ce->ce_flags |= CE_ADDED;
if (add_index_entry(istate, ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
die("unable to add %s to index",path);
if (verbose)
@@ -544,6 +516,14 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
return 0;
}
+int add_file_to_index(struct index_state *istate, const char *path, int verbose)
+{
+ struct stat st;
+ if (lstat(path, &st))
+ die("%s: unable to stat (%s)", path, strerror(errno));
+ return add_to_index(istate, path, &st, verbose);
+}
+
struct cache_entry *make_cache_entry(unsigned int mode,
const unsigned char *sha1, const char *path, int stage,
int refresh)
@@ -1370,7 +1350,7 @@ int write_index(const struct index_state *istate, int newfd)
struct cache_entry *ce = cache[i];
if (ce->ce_flags & CE_REMOVE)
continue;
- if (is_racy_timestamp(istate, ce))
+ if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
ce_smudge_racily_clean_entry(ce);
if (ce_write_entry(&c, newfd, ce) < 0)
return -1;
diff --git a/receive-pack.c b/receive-pack.c
index f83ae87e15..828d49001d 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -10,6 +10,7 @@
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
static int deny_non_fast_forwards = 0;
+static int receive_fsck_objects;
static int receive_unpack_limit = -1;
static int transfer_unpack_limit = -1;
static int unpack_limit = 100;
@@ -35,6 +36,11 @@ static int receive_pack_config(const char *var, const char *value)
return 0;
}
+ if (strcmp(var, "receive.fsckobjects") == 0) {
+ receive_fsck_objects = git_config_bool(var, value);
+ return 0;
+ }
+
return git_default_config(var, value);
}
@@ -368,11 +374,13 @@ static const char *unpack(void)
ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));
if (ntohl(hdr.hdr_entries) < unpack_limit) {
- int code;
- const char *unpacker[3];
- unpacker[0] = "unpack-objects";
- unpacker[1] = hdr_arg;
- unpacker[2] = NULL;
+ int code, i = 0;
+ const char *unpacker[4];
+ unpacker[i++] = "unpack-objects";
+ if (receive_fsck_objects)
+ unpacker[i++] = "--strict";
+ unpacker[i++] = hdr_arg;
+ unpacker[i++] = NULL;
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
switch (code) {
case 0:
@@ -393,8 +401,8 @@ static const char *unpack(void)
return "unpacker exited with error code";
}
} else {
- const char *keeper[6];
- int s, status;
+ const char *keeper[7];
+ int s, status, i = 0;
char keep_arg[256];
struct child_process ip;
@@ -402,12 +410,14 @@ static const char *unpack(void)
if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
strcpy(keep_arg + s, "localhost");
- keeper[0] = "index-pack";
- keeper[1] = "--stdin";
- keeper[2] = "--fix-thin";
- keeper[3] = hdr_arg;
- keeper[4] = keep_arg;
- keeper[5] = NULL;
+ keeper[i++] = "index-pack";
+ keeper[i++] = "--stdin";
+ if (receive_fsck_objects)
+ keeper[i++] = "--strict";
+ keeper[i++] = "--fix-thin";
+ keeper[i++] = hdr_arg;
+ keeper[i++] = keep_arg;
+ keeper[i++] = NULL;
memset(&ip, 0, sizeof(ip));
ip.argv = keeper;
ip.out = -1;
diff --git a/refs.c b/refs.c
index 1b0050eee4..9b495eb16e 100644
--- a/refs.c
+++ b/refs.c
@@ -352,6 +352,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
{
int len = strlen(path), retval;
char *gitdir;
+ const char *tmp;
while (len && path[len-1] == '/')
len--;
@@ -359,16 +360,27 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
return -1;
gitdir = xmalloc(len + MAXREFLEN + 8);
memcpy(gitdir, path, len);
- memcpy(gitdir + len, "/.git/", 7);
-
- retval = resolve_gitlink_ref_recursive(gitdir, len+6, refname, result, 0);
+ memcpy(gitdir + len, "/.git", 6);
+ len += 5;
+
+ tmp = read_gitfile_gently(gitdir);
+ if (tmp) {
+ free(gitdir);
+ len = strlen(tmp);
+ gitdir = xmalloc(len + MAXREFLEN + 3);
+ memcpy(gitdir, tmp, len);
+ }
+ gitdir[len] = '/';
+ gitdir[++len] = '\0';
+ retval = resolve_gitlink_ref_recursive(gitdir, len, refname, result, 0);
free(gitdir);
return retval;
}
const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *flag)
{
- int depth = MAXDEPTH, len;
+ int depth = MAXDEPTH;
+ ssize_t len;
char buffer[256];
static char ref_buffer[256];
diff --git a/remote.c b/remote.c
index 2d9af4023e..91cbb72dde 100644
--- a/remote.c
+++ b/remote.c
@@ -337,44 +337,49 @@ static int handle_config(const char *key, const char *value)
return 0;
}
remote = make_remote(name, subkey - name);
- if (!value) {
- /* if we ever have a boolean variable, e.g. "remote.*.disabled"
- * [remote "frotz"]
- * disabled
- * is a valid way to set it to true; we get NULL in value so
- * we need to handle it here.
- *
- * if (!strcmp(subkey, ".disabled")) {
- * val = git_config_bool(key, value);
- * return 0;
- * } else
- *
- */
- return 0; /* ignore unknown booleans */
- }
- if (!strcmp(subkey, ".url")) {
- add_url(remote, xstrdup(value));
+ if (!strcmp(subkey, ".mirror"))
+ remote->mirror = git_config_bool(key, value);
+ else if (!strcmp(subkey, ".skipdefaultupdate"))
+ remote->skip_default_update = git_config_bool(key, value);
+
+ else if (!strcmp(subkey, ".url")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_url(remote, v);
} else if (!strcmp(subkey, ".push")) {
- add_push_refspec(remote, xstrdup(value));
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_push_refspec(remote, v);
} else if (!strcmp(subkey, ".fetch")) {
- add_fetch_refspec(remote, xstrdup(value));
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_fetch_refspec(remote, v);
} else if (!strcmp(subkey, ".receivepack")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
if (!remote->receivepack)
- remote->receivepack = xstrdup(value);
+ remote->receivepack = v;
else
error("more than one receivepack given, using the first");
} else if (!strcmp(subkey, ".uploadpack")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
if (!remote->uploadpack)
- remote->uploadpack = xstrdup(value);
+ remote->uploadpack = v;
else
error("more than one uploadpack given, using the first");
} else if (!strcmp(subkey, ".tagopt")) {
if (!strcmp(value, "--no-tags"))
remote->fetch_tags = -1;
} else if (!strcmp(subkey, ".proxy")) {
- remote->http_proxy = xstrdup(value);
- } else if (!strcmp(subkey, ".skipdefaultupdate"))
- remote->skip_default_update = 1;
+ return git_config_string((const char **)&remote->http_proxy,
+ key, value);
+ }
return 0;
}
@@ -686,6 +691,13 @@ struct ref *alloc_ref(unsigned namelen)
return ret;
}
+struct ref *alloc_ref_from_str(const char* str)
+{
+ struct ref *ret = alloc_ref(strlen(str) + 1);
+ strcpy(ret->name, str);
+ return ret;
+}
+
static struct ref *copy_ref(const struct ref *ref)
{
struct ref *ret = xmalloc(sizeof(struct ref) + strlen(ref->name) + 1);
@@ -706,13 +718,22 @@ struct ref *copy_ref_list(const struct ref *ref)
return ret;
}
+void free_ref(struct ref *ref)
+{
+ if (!ref)
+ return;
+ free(ref->remote_status);
+ free(ref->symref);
+ free(ref);
+}
+
void free_refs(struct ref *ref)
{
struct ref *next;
while (ref) {
next = ref->next;
free(ref->peer_ref);
- free(ref);
+ free_ref(ref);
ref = next;
}
}
@@ -783,7 +804,6 @@ static struct ref *try_explicit_object_name(const char *name)
{
unsigned char sha1[20];
struct ref *ref;
- int len;
if (!*name) {
ref = alloc_ref(20);
@@ -793,21 +813,14 @@ static struct ref *try_explicit_object_name(const char *name)
}
if (get_sha1(name, sha1))
return NULL;
- len = strlen(name) + 1;
- ref = alloc_ref(len);
- memcpy(ref->name, name, len);
+ ref = alloc_ref_from_str(name);
hashcpy(ref->new_sha1, sha1);
return ref;
}
static struct ref *make_linked_ref(const char *name, struct ref ***tail)
{
- struct ref *ret;
- size_t len;
-
- len = strlen(name) + 1;
- ret = alloc_ref(len);
- memcpy(ret->name, name, len);
+ struct ref *ret = alloc_ref_from_str(name);
tail_link_ref(ret, tail);
return ret;
}
@@ -1111,9 +1124,7 @@ static struct ref *get_local_ref(const char *name)
return NULL;
if (!prefixcmp(name, "refs/")) {
- ret = alloc_ref(strlen(name) + 1);
- strcpy(ret->name, name);
- return ret;
+ return alloc_ref_from_str(name);
}
if (!prefixcmp(name, "heads/") ||
@@ -1172,3 +1183,15 @@ int get_fetch_map(const struct ref *remote_refs,
return 0;
}
+
+int resolve_remote_symref(struct ref *ref, struct ref *list)
+{
+ if (!ref->symref)
+ return 0;
+ for (; list; list = list->next)
+ if (!strcmp(ref->symref, list->name)) {
+ hashcpy(ref->old_sha1, list->old_sha1);
+ return 0;
+ }
+ return 1;
+}
diff --git a/remote.h b/remote.h
index a38774bbdc..2ee83a33b3 100644
--- a/remote.h
+++ b/remote.h
@@ -26,6 +26,7 @@ struct remote {
*/
int fetch_tags;
int skip_default_update;
+ int mirror;
const char *receivepack;
const char *uploadpack;
@@ -53,6 +54,8 @@ struct refspec {
struct ref *alloc_ref(unsigned namelen);
+struct ref *alloc_ref_from_str(const char* str);
+
struct ref *copy_ref_list(const struct ref *ref);
int check_ref_type(const struct ref *ref, int flags);
@@ -62,6 +65,8 @@ int check_ref_type(const struct ref *ref, int flags);
*/
void free_refs(struct ref *ref);
+int resolve_remote_symref(struct ref *ref, struct ref *list);
+
/*
* Removes and frees any duplicate refs in the map.
*/
diff --git a/revision.c b/revision.c
index ffbed3fbf2..4231ea2cce 100644
--- a/revision.c
+++ b/revision.c
@@ -1199,7 +1199,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
}
if (!prefixcmp(arg, "--pretty")) {
revs->verbose_header = 1;
- revs->commit_format = get_commit_format(arg+8);
+ get_commit_format(arg+8, revs);
continue;
}
if (!strcmp(arg, "--root")) {
diff --git a/revision.h b/revision.h
index c8b3b948ec..31217f8c67 100644
--- a/revision.h
+++ b/revision.h
@@ -64,7 +64,8 @@ struct rev_info {
/* Format info */
unsigned int shown_one:1,
- abbrev_commit:1;
+ abbrev_commit:1,
+ use_terminator:1;
enum date_mode date_mode;
const char **ignore_packed; /* pretend objects in these are unpacked */
diff --git a/setup.c b/setup.c
index 3d2d9580f3..b8fd476395 100644
--- a/setup.c
+++ b/setup.c
@@ -315,6 +315,44 @@ static int check_repository_format_gently(int *nongit_ok)
}
/*
+ * Try to read the location of the git directory from the .git file,
+ * return path to git directory if found.
+ */
+const char *read_gitfile_gently(const char *path)
+{
+ char *buf;
+ struct stat st;
+ int fd;
+ size_t len;
+
+ if (stat(path, &st))
+ return NULL;
+ if (!S_ISREG(st.st_mode))
+ return NULL;
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ die("Error opening %s: %s", path, strerror(errno));
+ buf = xmalloc(st.st_size + 1);
+ len = read_in_full(fd, buf, st.st_size);
+ close(fd);
+ if (len != st.st_size)
+ die("Error reading %s", path);
+ buf[len] = '\0';
+ if (prefixcmp(buf, "gitdir: "))
+ die("Invalid gitfile format: %s", path);
+ while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
+ len--;
+ if (len < 9)
+ die("No path in gitfile: %s", path);
+ buf[len] = '\0';
+ if (!is_git_directory(buf + 8))
+ die("Not a git repository: %s", buf + 8);
+ path = make_absolute_path(buf + 8);
+ free(buf);
+ return path;
+}
+
+/*
* We cannot decide in this function whether we are in the work tree or
* not, since the config can only be read _after_ this function was called.
*/
@@ -323,6 +361,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);
static char cwd[PATH_MAX+1];
const char *gitdirenv;
+ const char *gitfile_dir;
int len, offset;
/*
@@ -377,8 +416,10 @@ const char *setup_git_directory_gently(int *nongit_ok)
/*
* Test in the following order (relative to the cwd):
+ * - .git (file containing "gitdir: <path>")
* - .git/
* - ./ (bare)
+ * - ../.git
* - ../.git/
* - ../ (bare)
* - ../../.git/
@@ -386,6 +427,12 @@ const char *setup_git_directory_gently(int *nongit_ok)
*/
offset = len = strlen(cwd);
for (;;) {
+ gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ if (gitfile_dir) {
+ if (set_git_dir(gitfile_dir))
+ die("Repository setup failed");
+ break;
+ }
if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
break;
if (is_git_directory(".")) {
@@ -428,21 +475,53 @@ const char *setup_git_directory_gently(int *nongit_ok)
int git_config_perm(const char *var, const char *value)
{
- if (value) {
- int i;
- if (!strcmp(value, "umask"))
- return PERM_UMASK;
- if (!strcmp(value, "group"))
- return PERM_GROUP;
- if (!strcmp(value, "all") ||
- !strcmp(value, "world") ||
- !strcmp(value, "everybody"))
- return PERM_EVERYBODY;
- i = atoi(value);
- if (i > 1)
- return i;
+ int i;
+ char *endptr;
+
+ if (value == NULL)
+ return PERM_GROUP;
+
+ if (!strcmp(value, "umask"))
+ return PERM_UMASK;
+ if (!strcmp(value, "group"))
+ return PERM_GROUP;
+ if (!strcmp(value, "all") ||
+ !strcmp(value, "world") ||
+ !strcmp(value, "everybody"))
+ return PERM_EVERYBODY;
+
+ /* Parse octal numbers */
+ i = strtol(value, &endptr, 8);
+
+ /* If not an octal number, maybe true/false? */
+ if (*endptr != 0)
+ return git_config_bool(var, value) ? PERM_GROUP : PERM_UMASK;
+
+ /*
+ * Treat values 0, 1 and 2 as compatibility cases, otherwise it is
+ * a chmod value.
+ */
+ switch (i) {
+ case PERM_UMASK: /* 0 */
+ return PERM_UMASK;
+ case OLD_PERM_GROUP: /* 1 */
+ return PERM_GROUP;
+ case OLD_PERM_EVERYBODY: /* 2 */
+ return PERM_EVERYBODY;
}
- return git_config_bool(var, value);
+
+ /* A filemode value was given: 0xxx */
+
+ if ((i & 0600) != 0600)
+ die("Problem with core.sharedRepository filemode value "
+ "(0%.3o).\nThe owner of files must always have "
+ "read and write permissions.", i);
+
+ /*
+ * Mask filemode value. Others can not get write permission.
+ * x flags for directories are handled separately.
+ */
+ return i & 0666;
}
int check_repository_format_version(const char *var, const char *value)
diff --git a/sha1-lookup.c b/sha1-lookup.c
new file mode 100644
index 0000000000..da357479cf
--- /dev/null
+++ b/sha1-lookup.c
@@ -0,0 +1,171 @@
+#include "cache.h"
+#include "sha1-lookup.h"
+
+/*
+ * Conventional binary search loop looks like this:
+ *
+ * unsigned lo, hi;
+ * do {
+ * unsigned mi = (lo + hi) / 2;
+ * int cmp = "entry pointed at by mi" minus "target";
+ * if (!cmp)
+ * return (mi is the wanted one)
+ * if (cmp > 0)
+ * hi = mi; "mi is larger than target"
+ * else
+ * lo = mi+1; "mi is smaller than target"
+ * } while (lo < hi);
+ *
+ * The invariants are:
+ *
+ * - When entering the loop, lo points at a slot that is never
+ * above the target (it could be at the target), hi points at a
+ * slot that is guaranteed to be above the target (it can never
+ * be at the target).
+ *
+ * - We find a point 'mi' between lo and hi (mi could be the same
+ * as lo, but never can be as same as hi), and check if it hits
+ * the target. There are three cases:
+ *
+ * - if it is a hit, we are happy.
+ *
+ * - if it is strictly higher than the target, we set it to hi,
+ * and repeat the search.
+ *
+ * - if it is strictly lower than the target, we update lo to
+ * one slot after it, because we allow lo to be at the target.
+ *
+ * If the loop exits, there is no matching entry.
+ *
+ * When choosing 'mi', we do not have to take the "middle" but
+ * anywhere in between lo and hi, as long as lo <= mi < hi is
+ * satisfied. When we somehow know that the distance between the
+ * target and lo is much shorter than the target and hi, we could
+ * pick mi that is much closer to lo than the midway.
+ *
+ * Now, we can take advantage of the fact that SHA-1 is a good hash
+ * function, and as long as there are enough entries in the table, we
+ * can expect uniform distribution. An entry that begins with for
+ * example "deadbeef..." is much likely to appear much later than in
+ * the midway of the table. It can reasonably be expected to be near
+ * 87% (222/256) from the top of the table.
+ *
+ * However, we do not want to pick "mi" too precisely. If the entry at
+ * the 87% in the above example turns out to be higher than the target
+ * we are looking for, we would end up narrowing the search space down
+ * only by 13%, instead of 50% we would get if we did a simple binary
+ * search. So we would want to hedge our bets by being less aggressive.
+ *
+ * The table at "table" holds at least "nr" entries of "elem_size"
+ * bytes each. Each entry has the SHA-1 key at "key_offset". The
+ * table is sorted by the SHA-1 key of the entries. The caller wants
+ * to find the entry with "key", and knows that the entry at "lo" is
+ * not higher than the entry it is looking for, and that the entry at
+ * "hi" is higher than the entry it is looking for.
+ */
+int sha1_entry_pos(const void *table,
+ size_t elem_size,
+ size_t key_offset,
+ unsigned lo, unsigned hi, unsigned nr,
+ const unsigned char *key)
+{
+ const unsigned char *base = table;
+ const unsigned char *hi_key, *lo_key;
+ unsigned ofs_0;
+ static int debug_lookup = -1;
+
+ if (debug_lookup < 0)
+ debug_lookup = !!getenv("GIT_DEBUG_LOOKUP");
+
+ if (!nr || lo >= hi)
+ return -1;
+
+ if (nr == hi)
+ hi_key = NULL;
+ else
+ hi_key = base + elem_size * hi + key_offset;
+ lo_key = base + elem_size * lo + key_offset;
+
+ ofs_0 = 0;
+ do {
+ int cmp;
+ unsigned ofs, mi, range;
+ unsigned lov, hiv, kyv;
+ const unsigned char *mi_key;
+
+ range = hi - lo;
+ if (hi_key) {
+ for (ofs = ofs_0; ofs < 20; ofs++)
+ if (lo_key[ofs] != hi_key[ofs])
+ break;
+ ofs_0 = ofs;
+ /*
+ * byte 0 thru (ofs-1) are the same between
+ * lo and hi; ofs is the first byte that is
+ * different.
+ */
+ hiv = hi_key[ofs_0];
+ if (ofs_0 < 19)
+ hiv = (hiv << 8) | hi_key[ofs_0+1];
+ } else {
+ hiv = 256;
+ if (ofs_0 < 19)
+ hiv <<= 8;
+ }
+ lov = lo_key[ofs_0];
+ kyv = key[ofs_0];
+ if (ofs_0 < 19) {
+ lov = (lov << 8) | lo_key[ofs_0+1];
+ kyv = (kyv << 8) | key[ofs_0+1];
+ }
+ assert(lov < hiv);
+
+ if (kyv < lov)
+ return -1 - lo;
+ if (hiv < kyv)
+ return -1 - hi;
+
+ /*
+ * Even if we know the target is much closer to 'hi'
+ * than 'lo', if we pick too precisely and overshoot
+ * (e.g. when we know 'mi' is closer to 'hi' than to
+ * 'lo', pick 'mi' that is higher than the target), we
+ * end up narrowing the search space by a smaller
+ * amount (i.e. the distance between 'mi' and 'hi')
+ * than what we would have (i.e. about half of 'lo'
+ * and 'hi'). Hedge our bets to pick 'mi' less
+ * aggressively, i.e. make 'mi' a bit closer to the
+ * middle than we would otherwise pick.
+ */
+ kyv = (kyv * 6 + lov + hiv) / 8;
+ if (lov < hiv - 1) {
+ if (kyv == lov)
+ kyv++;
+ else if (kyv == hiv)
+ kyv--;
+ }
+ mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo;
+
+ if (debug_lookup) {
+ printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi);
+ printf("ofs %u lov %x, hiv %x, kyv %x\n",
+ ofs_0, lov, hiv, kyv);
+ }
+ if (!(lo <= mi && mi < hi))
+ die("assertion failure lo %u mi %u hi %u %s",
+ lo, mi, hi, sha1_to_hex(key));
+
+ mi_key = base + elem_size * mi + key_offset;
+ cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0);
+ if (!cmp)
+ return mi;
+ if (cmp > 0) {
+ hi = mi;
+ hi_key = mi_key;
+ } else {
+ lo = mi + 1;
+ lo_key = mi_key + elem_size;
+ }
+ } while (lo < hi);
+ return -lo-1;
+}
diff --git a/sha1-lookup.h b/sha1-lookup.h
new file mode 100644
index 0000000000..3249a81b3d
--- /dev/null
+++ b/sha1-lookup.h
@@ -0,0 +1,9 @@
+#ifndef SHA1_LOOKUP_H
+#define SHA1_LOOKUP_H
+
+extern int sha1_entry_pos(const void *table,
+ size_t elem_size,
+ size_t key_offset,
+ unsigned lo, unsigned hi, unsigned nr,
+ const unsigned char *key);
+#endif
diff --git a/sha1_file.c b/sha1_file.c
index 445a871db3..3516777bc7 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -15,6 +15,7 @@
#include "tree.h"
#include "refs.h"
#include "pack-revindex.h"
+#include "sha1-lookup.h"
#ifndef O_NOATIME
#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -1675,7 +1676,12 @@ off_t find_pack_entry_one(const unsigned char *sha1,
{
const uint32_t *level1_ofs = p->index_data;
const unsigned char *index = p->index_data;
- unsigned hi, lo;
+ unsigned hi, lo, stride;
+ static int use_lookup = -1;
+ static int debug_lookup = -1;
+
+ if (debug_lookup < 0)
+ debug_lookup = !!getenv("GIT_DEBUG_LOOKUP");
if (!index) {
if (open_pack_index(p))
@@ -1690,11 +1696,34 @@ off_t find_pack_entry_one(const unsigned char *sha1,
index += 4 * 256;
hi = ntohl(level1_ofs[*sha1]);
lo = ((*sha1 == 0x0) ? 0 : ntohl(level1_ofs[*sha1 - 1]));
+ if (p->index_version > 1) {
+ stride = 20;
+ } else {
+ stride = 24;
+ index += 4;
+ }
+
+ if (debug_lookup)
+ printf("%02x%02x%02x... lo %u hi %u nr %u\n",
+ sha1[0], sha1[1], sha1[2], lo, hi, p->num_objects);
+
+ if (use_lookup < 0)
+ use_lookup = !!getenv("GIT_USE_LOOKUP");
+ if (use_lookup) {
+ int pos = sha1_entry_pos(index, stride, 0,
+ lo, hi, p->num_objects, sha1);
+ if (pos < 0)
+ return 0;
+ return nth_packed_object_offset(p, pos);
+ }
do {
unsigned mi = (lo + hi) / 2;
- unsigned x = (p->index_version > 1) ? (mi * 20) : (mi * 24 + 4);
- int cmp = hashcmp(index + x, sha1);
+ int cmp = hashcmp(index + mi * stride, sha1);
+
+ if (debug_lookup)
+ printf("lo %u hi %u rg %u mi %u\n",
+ lo, hi, hi - lo, mi);
if (!cmp)
return nth_packed_object_offset(p, mi);
if (cmp > 0)
@@ -2437,16 +2466,10 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
int read_pack_header(int fd, struct pack_header *header)
{
- char *c = (char*)header;
- ssize_t remaining = sizeof(struct pack_header);
- do {
- ssize_t r = xread(fd, c, remaining);
- if (r <= 0)
- /* "eof before pack header was fully read" */
- return PH_ERROR_EOF;
- remaining -= r;
- c += r;
- } while (remaining > 0);
+ if (read_in_full(fd, header, sizeof(*header)) < sizeof(*header))
+ /* "eof before pack header was fully read" */
+ return PH_ERROR_EOF;
+
if (header->hdr_signature != htonl(PACK_SIGNATURE))
/* "protocol error (pack signature mismatch detected)" */
return PH_ERROR_PACK_SIGNATURE;
diff --git a/symlinks.c b/symlinks.c
index be9ace6c04..5a5e781a15 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -1,48 +1,64 @@
#include "cache.h"
-int has_symlink_leading_path(const char *name, char *last_symlink)
-{
+struct pathname {
+ int len;
char path[PATH_MAX];
- const char *sp, *ep;
- char *dp;
-
- sp = name;
- dp = path;
-
- if (last_symlink && *last_symlink) {
- size_t last_len = strlen(last_symlink);
- size_t len = strlen(name);
- if (last_len < len &&
- !strncmp(name, last_symlink, last_len) &&
- name[last_len] == '/')
- return 1;
- *last_symlink = '\0';
+};
+
+/* Return matching pathname prefix length, or zero if not matching */
+static inline int match_pathname(int len, const char *name, struct pathname *match)
+{
+ int match_len = match->len;
+ return (len > match_len &&
+ name[match_len] == '/' &&
+ !memcmp(name, match->path, match_len)) ? match_len : 0;
+}
+
+static inline void set_pathname(int len, const char *name, struct pathname *match)
+{
+ if (len < PATH_MAX) {
+ match->len = len;
+ memcpy(match->path, name, len);
+ match->path[len] = 0;
}
+}
+
+int has_symlink_leading_path(int len, const char *name)
+{
+ static struct pathname link, nonlink;
+ char path[PATH_MAX];
+ struct stat st;
+ char *sp;
+ int known_dir;
- while (1) {
- size_t len;
- struct stat st;
+ /*
+ * See if the last known symlink cache matches.
+ */
+ if (match_pathname(len, name, &link))
+ return 1;
- ep = strchr(sp, '/');
- if (!ep)
- break;
- len = ep - sp;
- if (PATH_MAX <= dp + len - path + 2)
- return 0; /* new name is longer than that??? */
- memcpy(dp, sp, len);
- dp[len] = 0;
+ /*
+ * Get rid of the last known directory part
+ */
+ known_dir = match_pathname(len, name, &nonlink);
+
+ while ((sp = strchr(name + known_dir + 1, '/')) != NULL) {
+ int thislen = sp - name ;
+ memcpy(path, name, thislen);
+ path[thislen] = 0;
if (lstat(path, &st))
return 0;
+ if (S_ISDIR(st.st_mode)) {
+ set_pathname(thislen, path, &nonlink);
+ known_dir = thislen;
+ continue;
+ }
if (S_ISLNK(st.st_mode)) {
- if (last_symlink)
- strcpy(last_symlink, path);
+ set_pathname(thislen, path, &link);
return 1;
}
-
- dp[len++] = '/';
- dp = dp + len;
- sp = ep + 1;
+ break;
}
return 0;
}
diff --git a/t/.gitignore b/t/.gitignore
index fad67c097b..11ffd910c1 100644
--- a/t/.gitignore
+++ b/t/.gitignore
@@ -1 +1 @@
-trash
+/trash directory
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 9decd2e1e8..5d3bd9dda9 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -20,12 +20,13 @@ then
fi
svnrepo=$PWD/svnrepo
+export svnrepo
perl -w -e "
use SVN::Core;
use SVN::Repos;
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
-system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
+system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
" >&3 2>&4
x=$?
if test $x -ne 0
@@ -73,11 +74,16 @@ for d in \
done
start_httpd () {
+ repo_base_path="$1"
if test -z "$SVN_HTTPD_PORT"
then
echo >&2 'SVN_HTTPD_PORT is not defined!'
return
fi
+ if test -z "$repo_base_path"
+ then
+ repo_base_path=svn
+ fi
mkdir "$GIT_DIR"/logs
@@ -90,13 +96,13 @@ LockFile logs/accept.lock
Listen 127.0.0.1:$SVN_HTTPD_PORT
LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so
LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so
-<Location /svn>
+<Location /$repo_base_path>
DAV svn
SVNPath $rawsvnrepo
</Location>
EOF
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start
- svnrepo=http://127.0.0.1:$SVN_HTTPD_PORT/svn
+ svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path"
}
stop_httpd () {
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 7f206c56cf..a5c4436fd1 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -61,7 +61,8 @@ prepare_httpd() {
-new -x509 -nodes \
-out $HTTPD_ROOT_PATH/httpd.pem \
-keyout $HTTPD_ROOT_PATH/httpd.pem
- export GIT_SSL_NO_VERIFY=t
+ GIT_SSL_NO_VERIFY=t
+ export GIT_SSL_NO_VERIFY
HTTPD_PARA="$HTTPD_PARA -DSSL"
else
HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 27b54cbb12..690f80ab27 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -305,10 +305,10 @@ test_expect_success 'absolute path works as expected' '
file="$dir"/index &&
test "$file" = "$(test-absolute-path $dir2/index)" &&
basename=blub &&
- test "$dir/$basename" = $(cd .git && test-absolute-path $basename) &&
+ test "$dir/$basename" = "$(cd .git && test-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-absolute-path "$dir2/syml")"
'
test_expect_success 'very long name in the index handled sanely' '
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
new file mode 100755
index 0000000000..c5dbc724b6
--- /dev/null
+++ b/t/t0002-gitfile.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+test_description='.git file
+
+Verify that plumbing commands work when .git is a file
+'
+. ./test-lib.sh
+
+objpath() {
+ echo "$1" | sed -e 's|\(..\)|\1/|'
+}
+
+objck() {
+ p=$(objpath "$1")
+ if test ! -f "$REAL/objects/$p"
+ then
+ echo "Object not found: $REAL/objects/$p"
+ false
+ fi
+}
+
+
+test_expect_success 'initial setup' '
+ REAL="$(pwd)/.real" &&
+ mv .git "$REAL"
+'
+
+test_expect_success 'bad setup: invalid .git file format' '
+ echo "gitdir $REAL" >.git &&
+ if git rev-parse 2>.err
+ then
+ echo "git rev-parse accepted an invalid .git file"
+ false
+ fi &&
+ if ! grep -qe "Invalid gitfile format" .err
+ then
+ echo "git rev-parse returned wrong error"
+ false
+ fi
+'
+
+test_expect_success 'bad setup: invalid .git file path' '
+ echo "gitdir: $REAL.not" >.git &&
+ if git rev-parse 2>.err
+ then
+ echo "git rev-parse accepted an invalid .git file path"
+ false
+ fi &&
+ if ! grep -qe "Not a git repository" .err
+ then
+ echo "git rev-parse returned wrong error"
+ false
+ fi
+'
+
+test_expect_success 'final setup + check rev-parse --git-dir' '
+ echo "gitdir: $REAL" >.git &&
+ test "$REAL" = "$(git rev-parse --git-dir)"
+'
+
+test_expect_success 'check hash-object' '
+ echo "foo" >bar &&
+ SHA=$(cat bar | git hash-object -w --stdin) &&
+ objck $SHA
+'
+
+test_expect_success 'check cat-file' '
+ git cat-file blob $SHA >actual &&
+ diff -u bar actual
+'
+
+test_expect_success 'check update-index' '
+ if test -f "$REAL/index"
+ then
+ echo "Hmm, $REAL/index exists?"
+ false
+ fi &&
+ rm -f "$REAL/objects/$(objpath $SHA)" &&
+ git update-index --add bar &&
+ if ! test -f "$REAL/index"
+ then
+ echo "$REAL/index not found"
+ false
+ fi &&
+ objck $SHA
+'
+
+test_expect_success 'check write-tree' '
+ SHA=$(git write-tree) &&
+ objck $SHA
+'
+
+test_expect_success 'check commit-tree' '
+ SHA=$(echo "commit bar" | git commit-tree $SHA) &&
+ objck $SHA
+'
+
+test_expect_success 'check rev-list' '
+ echo $SHA >"$REAL/HEAD" &&
+ test "$SHA" = "$(git rev-list HEAD)"
+'
+
+test_done
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index b9cef3422c..fc386ba033 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -21,7 +21,7 @@ LF='
'
test_expect_success 'update-index and ls-files' '
- cd $HERE &&
+ cd "$HERE" &&
git update-index --add one &&
case "`git ls-files`" in
one) echo ok one ;;
@@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' '
'
test_expect_success 'cat-file' '
- cd $HERE &&
+ cd "$HERE" &&
two=`git ls-files -s dir/two` &&
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
echo "$two" &&
@@ -54,7 +54,7 @@ test_expect_success 'cat-file' '
rm -f actual dir/actual
test_expect_success 'diff-files' '
- cd $HERE &&
+ cd "$HERE" &&
echo a >>one &&
echo d >>dir/two &&
case "`git diff-files --name-only`" in
@@ -74,7 +74,7 @@ test_expect_success 'diff-files' '
'
test_expect_success 'write-tree' '
- cd $HERE &&
+ cd "$HERE" &&
top=`git write-tree` &&
echo $top &&
cd dir &&
@@ -84,7 +84,7 @@ test_expect_success 'write-tree' '
'
test_expect_success 'checkout-index' '
- cd $HERE &&
+ cd "$HERE" &&
git checkout-index -f -u one &&
cmp one original.one &&
cd dir &&
@@ -93,7 +93,7 @@ test_expect_success 'checkout-index' '
'
test_expect_success 'read-tree' '
- cd $HERE &&
+ cd "$HERE" &&
rm -f one dir/two &&
tree=`git write-tree` &&
git read-tree --reset -u "$tree" &&
@@ -107,27 +107,27 @@ test_expect_success 'read-tree' '
'
test_expect_success 'no file/rev ambiguity check inside .git' '
- cd $HERE &&
+ cd "$HERE" &&
git commit -a -m 1 &&
- cd $HERE/.git &&
+ cd "$HERE"/.git &&
git show -s HEAD
'
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
- cd $HERE &&
+ cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && GIT_DIR=. git show -s HEAD
'
# This still does not work as it should...
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
- cd $HERE &&
+ cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && git show -s HEAD
'
test_expect_success 'detection should not be fooled by a symlink' '
- cd $HERE &&
+ cd "$HERE" &&
rm -fr foo.git &&
git clone -s .git another &&
ln -s another yetanother &&
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index b36a9012ec..a675cbb51b 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -595,6 +595,64 @@ test_expect_success 'set --int' '
rm .git/config
+cat >expect <<\EOF
+[bool]
+ true1 = true
+ true2 = true
+ false1 = false
+ false2 = false
+[int]
+ int1 = 0
+ int2 = 1
+ int3 = -1
+EOF
+
+test_expect_success 'get --bool-or-int' '
+ (
+ echo "[bool]"
+ echo true1
+ echo true2 = true
+ echo false = false
+ echo "[int]"
+ echo int1 = 0
+ echo int2 = 1
+ echo int3 = -1
+ ) >>.git/config &&
+ test $(git config --bool-or-int bool.true1) = true &&
+ test $(git config --bool-or-int bool.true2) = true &&
+ test $(git config --bool-or-int bool.false) = false &&
+ test $(git config --bool-or-int int.int1) = 0 &&
+ test $(git config --bool-or-int int.int2) = 1 &&
+ test $(git config --bool-or-int int.int3) = -1
+
+'
+
+rm .git/config
+cat >expect <<\EOF
+[bool]
+ true1 = true
+ false1 = false
+ true2 = true
+ false2 = false
+[int]
+ int1 = 0
+ int2 = 1
+ int3 = -1
+EOF
+
+test_expect_success 'set --bool-or-int' '
+ git config --bool-or-int bool.true1 true &&
+ git config --bool-or-int bool.false1 false &&
+ git config --bool-or-int bool.true2 yes &&
+ git config --bool-or-int bool.false2 no &&
+ git config --bool-or-int int.int1 0 &&
+ git config --bool-or-int int.int2 1 &&
+ git config --bool-or-int int.int3 -1 &&
+ test_cmp expect .git/config
+'
+
+rm .git/config
+
git config quote.leading " test"
git config quote.ending "test "
git config quote.semicolon "test;test"
diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
index 6bfe19a4e5..5e4252a320 100755
--- a/t/t1301-shared-repo.sh
+++ b/t/t1301-shared-repo.sh
@@ -7,6 +7,16 @@ test_description='Test shared repository initialization'
. ./test-lib.sh
+# User must have read permissions to the repo -> failure on --shared=0400
+test_expect_success 'shared = 0400 (faulty permission u-w)' '
+ mkdir sub && (
+ cd sub && git init --shared=0400
+ )
+ ret="$?"
+ rm -rf sub
+ test $ret != "0"
+'
+
test_expect_success 'shared=all' '
mkdir sub &&
cd sub &&
@@ -33,4 +43,44 @@ test_expect_success 'update-server-info honors core.sharedRepository' '
esac
'
+for u in 0660:rw-rw---- \
+ 0640:rw-r----- \
+ 0600:rw------- \
+ 0666:rw-rw-rw- \
+ 0664:rw-rw-r--
+do
+ x=$(expr "$u" : ".*:\([rw-]*\)") &&
+ y=$(echo "$x" | sed -e "s/w/-/g") &&
+ u=$(expr "$u" : "\([0-7]*\)") &&
+ git config core.sharedrepository "$u" &&
+ umask 0277 &&
+
+ test_expect_success "shared = $u ($y) ro" '
+
+ rm -f .git/info/refs &&
+ git update-server-info &&
+ actual="$(ls -l .git/info/refs)" &&
+ actual=${actual%% *} &&
+ test "x$actual" = "x-$y" || {
+ ls -lt .git/info
+ false
+ }
+ '
+
+ umask 077 &&
+ test_expect_success "shared = $u ($x) rw" '
+
+ rm -f .git/info/refs &&
+ git update-server-info &&
+ actual="$(ls -l .git/info/refs)" &&
+ actual=${actual%% *} &&
+ test "x$actual" = "x-$x" || {
+ ls -lt .git/info
+ false
+ }
+
+ '
+
+done
+
test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 99985dcd79..f366b53fb6 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -34,4 +34,10 @@ test_expect_success 'add key in different section' '
check section2.key bar
'
+SECTION="test.q\"s\\sq'sp e.key"
+test_expect_success 'make sure git-config escapes section names properly' '
+ git config "$SECTION" bar &&
+ check "$SECTION" bar
+'
+
test_done
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 38a2bf09af..85da4caa7e 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -51,8 +51,9 @@ test_rev_parse 'core.bare undefined' false false true
mkdir work || exit 1
cd work || exit 1
-export GIT_DIR=../.git
-export GIT_CONFIG="$(pwd)"/../.git/config
+GIT_DIR=../.git
+GIT_CONFIG="$(pwd)"/../.git/config
+export GIT_DIR GIT_CONFIG
git config core.bare false
test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
@@ -64,8 +65,8 @@ git config --unset core.bare
test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
mv ../.git ../repo.git || exit 1
-export GIT_DIR=../repo.git
-export GIT_CONFIG="$(pwd)"/../repo.git/config
+GIT_DIR=../repo.git
+GIT_CONFIG="$(pwd)"/../repo.git/config
git config core.bare false
test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 7ee3820ce9..2ee88d8a06 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -32,24 +32,25 @@ mkdir -p work/sub/dir || exit 1
mv .git repo.git || exit 1
say "core.worktree = relative path"
-export GIT_DIR=repo.git
-export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+GIT_DIR=repo.git
+GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+export GIT_DIR GIT_CONFIG
unset GIT_WORK_TREE
git config core.worktree ../work
test_rev_parse 'outside' false false false
cd work || exit 1
-export GIT_DIR=../repo.git
-export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+GIT_DIR=../repo.git
+GIT_CONFIG="$(pwd)"/$GIT_DIR/config
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
-export GIT_DIR=../../../repo.git
-export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+GIT_DIR=../../../repo.git
+GIT_CONFIG="$(pwd)"/$GIT_DIR/config
test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
say "core.worktree = absolute path"
-export GIT_DIR=$(pwd)/repo.git
-export GIT_CONFIG=$GIT_DIR/config
+GIT_DIR=$(pwd)/repo.git
+GIT_CONFIG=$GIT_DIR/config
git config core.worktree "$(pwd)/work"
test_rev_parse 'outside' false false false
cd work || exit 1
@@ -59,25 +60,26 @@ test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
say "GIT_WORK_TREE=relative path (override core.worktree)"
-export GIT_DIR=$(pwd)/repo.git
-export GIT_CONFIG=$GIT_DIR/config
+GIT_DIR=$(pwd)/repo.git
+GIT_CONFIG=$GIT_DIR/config
git config core.worktree non-existent
-export GIT_WORK_TREE=work
+GIT_WORK_TREE=work
+export GIT_WORK_TREE
test_rev_parse 'outside' false false false
cd work || exit 1
-export GIT_WORK_TREE=.
+GIT_WORK_TREE=.
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
-export GIT_WORK_TREE=../..
+GIT_WORK_TREE=../..
test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
mv work repo.git/work
say "GIT_WORK_TREE=absolute path, work tree below git dir"
-export GIT_DIR=$(pwd)/repo.git
-export GIT_CONFIG=$GIT_DIR/config
-export GIT_WORK_TREE=$(pwd)/repo.git/work
+GIT_DIR=$(pwd)/repo.git
+GIT_CONFIG=$GIT_DIR/config
+GIT_WORK_TREE=$(pwd)/repo.git/work
test_rev_parse 'outside' false false false
cd repo.git || exit 1
test_rev_parse 'in repo.git' false true false
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
new file mode 100755
index 0000000000..95244c9bcf
--- /dev/null
+++ b/t/t1503-rev-parse-verify.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Christian Couder
+#
+test_description='test git rev-parse --verify'
+
+exec </dev/null
+
+. ./test-lib.sh
+
+add_line_into_file()
+{
+ _line=$1
+ _file=$2
+
+ if [ -f "$_file" ]; then
+ echo "$_line" >> $_file || return $?
+ MSG="Add <$_line> into <$_file>."
+ else
+ echo "$_line" > $_file || return $?
+ git add $_file || return $?
+ MSG="Create file <$_file> with <$_line> inside."
+ fi
+
+ test_tick
+ git-commit --quiet -m "$MSG" $_file
+}
+
+HASH1=
+HASH2=
+HASH3=
+HASH4=
+
+test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' '
+ add_line_into_file "1: Hello World" hello &&
+ HASH1=$(git rev-parse --verify HEAD) &&
+ add_line_into_file "2: A new day for git" hello &&
+ HASH2=$(git rev-parse --verify HEAD) &&
+ add_line_into_file "3: Another new day for git" hello &&
+ HASH3=$(git rev-parse --verify HEAD) &&
+ add_line_into_file "4: Ciao for now" hello &&
+ HASH4=$(git rev-parse --verify HEAD)
+'
+
+test_expect_success 'works with one good rev' '
+ rev_hash1=$(git rev-parse --verify $HASH1) &&
+ test "$rev_hash1" = "$HASH1" &&
+ rev_hash2=$(git rev-parse --verify $HASH2) &&
+ test "$rev_hash2" = "$HASH2" &&
+ rev_hash3=$(git rev-parse --verify $HASH3) &&
+ test "$rev_hash3" = "$HASH3" &&
+ rev_hash4=$(git rev-parse --verify $HASH4) &&
+ test "$rev_hash4" = "$HASH4" &&
+ rev_master=$(git rev-parse --verify master) &&
+ test "$rev_master" = "$HASH4" &&
+ rev_head=$(git rev-parse --verify HEAD) &&
+ test "$rev_head" = "$HASH4"
+'
+
+test_expect_success 'fails with any bad rev or many good revs' '
+ test_must_fail git rev-parse --verify 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify foo 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify HEAD bar 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify baz HEAD 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify $HASH2 HEAD 2>error &&
+ grep "single revision" error
+'
+
+test_expect_success 'fails silently when using -q' '
+ test_must_fail git rev-parse --verify --quiet 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse -q --verify foo 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse --verify -q HEAD bar 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse --quiet --verify baz HEAD 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error &&
+ test -z "$(cat error)"
+'
+
+test_expect_success 'no stdout output on error' '
+ test -z "$(git rev-parse --verify)" &&
+ test -z "$(git rev-parse --verify foo)" &&
+ test -z "$(git rev-parse --verify baz HEAD)" &&
+ test -z "$(git rev-parse --verify HEAD bar)" &&
+ test -z "$(git rev-parse --verify $HASH2 HEAD)"
+'
+
+test_expect_success 'use --default' '
+ git rev-parse --verify --default master &&
+ git rev-parse --verify --default master HEAD &&
+ git rev-parse --default master --verify &&
+ git rev-parse --default master --verify HEAD &&
+ git rev-parse --verify HEAD --default master &&
+ test_must_fail git rev-parse --verify foo --default master &&
+ test_must_fail git rev-parse --default HEAD --verify bar &&
+ test_must_fail git rev-parse --verify --default HEAD baz &&
+ test_must_fail git rev-parse --default foo --verify &&
+ test_must_fail git rev-parse --verify --default bar
+'
+
+test_done
diff --git a/t/t2002-checkout-cache-u.sh b/t/t2002-checkout-cache-u.sh
index 0f441bcef7..70361c806e 100755
--- a/t/t2002-checkout-cache-u.sh
+++ b/t/t2002-checkout-cache-u.sh
@@ -21,13 +21,13 @@ test_expect_success \
rm -f path0 &&
git read-tree $t &&
git checkout-index -f -a &&
-! git diff-files | diff - /dev/null'
+test_must_fail git diff-files --exit-code'
test_expect_success \
'with -u, git checkout-index picks up stat information from new files.' '
rm -f path0 &&
git read-tree $t &&
git checkout-index -u -f -a &&
-git diff-files | diff - /dev/null'
+git diff-files --exit-code'
test_done
diff --git a/t/t3050-subprojects-fetch.sh b/t/t3050-subprojects-fetch.sh
index 2b21b1070d..4261e9641e 100755
--- a/t/t3050-subprojects-fetch.sh
+++ b/t/t3050-subprojects-fetch.sh
@@ -20,7 +20,7 @@ test_expect_success setup '
'
test_expect_success clone '
- git clone file://`pwd`/.git cloned &&
+ git clone "file://$(pwd)/.git" cloned &&
(git rev-parse HEAD; git ls-files -s) >expected &&
(
cd cloned &&
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index cb5f7a4441..8d8768688d 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -224,4 +224,238 @@ test_expect_success 'avoid ambiguous track' '
test -z "$(git config branch.all1.merge)"
'
+test_expect_success 'autosetuprebase local on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase local &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase &&
+ git branch --track myr1 mybase &&
+ test "$(git config branch.myr1.remote)" = . &&
+ test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
+ test "$(git config branch.myr1.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase always on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase always &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase2 &&
+ git branch --track myr2 mybase &&
+ test "$(git config branch.myr2.remote)" = . &&
+ test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
+ test "$(git config branch.myr2.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase remote on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase remote &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase3 &&
+ git branch --track myr3 mybase2 &&
+ test "$(git config branch.myr3.remote)" = . &&
+ test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
+ ! test "$(git config branch.myr3.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase never on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase never &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase4 &&
+ git branch --track myr4 mybase2 &&
+ test "$(git config branch.myr4.remote)" = . &&
+ test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
+ ! test "$(git config branch.myr4.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase local on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase local &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr5 local/master &&
+ test "$(git config branch.myr5.remote)" = local &&
+ test "$(git config branch.myr5.merge)" = refs/heads/master &&
+ ! test "$(git config branch.myr5.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase never on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase never &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr6 local/master &&
+ test "$(git config branch.myr6.remote)" = local &&
+ test "$(git config branch.myr6.merge)" = refs/heads/master &&
+ ! test "$(git config branch.myr6.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase remote on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase remote &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr7 local/master &&
+ test "$(git config branch.myr7.remote)" = local &&
+ test "$(git config branch.myr7.merge)" = refs/heads/master &&
+ test "$(git config branch.myr7.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase always on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase remote &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr8 local/master &&
+ test "$(git config branch.myr8.remote)" = local &&
+ test "$(git config branch.myr8.merge)" = refs/heads/master &&
+ test "$(git config branch.myr8.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
+ git config --unset branch.autosetuprebase &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr9 local/master &&
+ test "$(git config branch.myr9.remote)" = local &&
+ test "$(git config branch.myr9.merge)" = refs/heads/master &&
+ test "z$(git config branch.myr9.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase10 &&
+ git branch --track myr10 mybase2 &&
+ test "$(git config branch.myr10.remote)" = . &&
+ test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
+ test "z$(git config branch.myr10.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr11 mybase2 &&
+ test "z$(git config branch.myr11.remote)" = z &&
+ test "z$(git config branch.myr11.merge)" = z &&
+ test "z$(git config branch.myr11.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr12 local/master &&
+ test "z$(git config branch.myr12.remote)" = z &&
+ test "z$(git config branch.myr12.merge)" = z &&
+ test "z$(git config branch.myr12.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase never on an untracked local branch' '
+ git config branch.autosetuprebase never &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr13 mybase2 &&
+ test "z$(git config branch.myr13.remote)" = z &&
+ test "z$(git config branch.myr13.merge)" = z &&
+ test "z$(git config branch.myr13.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase local on an untracked local branch' '
+ git config branch.autosetuprebase local &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr14 mybase2 &&
+ test "z$(git config branch.myr14.remote)" = z &&
+ test "z$(git config branch.myr14.merge)" = z &&
+ test "z$(git config branch.myr14.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase remote on an untracked local branch' '
+ git config branch.autosetuprebase remote &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr15 mybase2 &&
+ test "z$(git config branch.myr15.remote)" = z &&
+ test "z$(git config branch.myr15.merge)" = z &&
+ test "z$(git config branch.myr15.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase always on an untracked local branch' '
+ git config branch.autosetuprebase always &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr16 mybase2 &&
+ test "z$(git config branch.myr16.remote)" = z &&
+ test "z$(git config branch.myr16.merge)" = z &&
+ test "z$(git config branch.myr16.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase never on an untracked remote branch' '
+ git config branch.autosetuprebase never &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr17 local/master &&
+ test "z$(git config branch.myr17.remote)" = z &&
+ test "z$(git config branch.myr17.merge)" = z &&
+ test "z$(git config branch.myr17.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase local on an untracked remote branch' '
+ git config branch.autosetuprebase local &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr18 local/master &&
+ test "z$(git config branch.myr18.remote)" = z &&
+ test "z$(git config branch.myr18.merge)" = z &&
+ test "z$(git config branch.myr18.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase remote on an untracked remote branch' '
+ git config branch.autosetuprebase remote &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr19 local/master &&
+ test "z$(git config branch.myr19.remote)" = z &&
+ test "z$(git config branch.myr19.merge)" = z &&
+ test "z$(git config branch.myr19.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase always on an untracked remote branch' '
+ git config branch.autosetuprebase always &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr20 local/master &&
+ test "z$(git config branch.myr20.remote)" = z &&
+ test "z$(git config branch.myr20.merge)" = z &&
+ test "z$(git config branch.myr20.rebase)" = z
+'
+
+test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
+ git config branch.autosetuprebase garbage &&
+ test_must_fail git branch
+'
+
+test_expect_success 'detect misconfigured autosetuprebase (no value)' '
+ git config --unset branch.autosetuprebase &&
+ echo "[branch] autosetuprebase" >> .git/config &&
+ test_must_fail git branch &&
+ git config --unset branch.autosetuprebase
+'
+
test_done
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index b4cf628d22..f86f4bc5eb 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='branch --contains <commit>'
+test_description='branch --contains <commit>, --merged, and --no-merged'
. ./test-lib.sh
@@ -55,4 +55,44 @@ test_expect_success 'branch --contains=side' '
'
+test_expect_success 'side: branch --merged' '
+
+ git branch --merged >actual &&
+ {
+ echo " master" &&
+ echo "* side"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'side: branch --no-merged' '
+
+ git branch --no-merged >actual &&
+ >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'master: branch --merged' '
+
+ git checkout master &&
+ git branch --merged >actual &&
+ {
+ echo "* master"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'master: branch --no-merged' '
+
+ git branch --no-merged >actual &&
+ {
+ echo " side"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 496f4ec172..91bb5e1d9e 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -9,7 +9,8 @@ This test runs git rebase and checks that the author information is not lost.
'
. ./test-lib.sh
-export GIT_AUTHOR_EMAIL=bogus_email_address
+GIT_AUTHOR_EMAIL=bogus_email_address
+export GIT_AUTHOR_EMAIL
test_expect_success \
'prepare repository with topic branches' \
@@ -44,13 +45,13 @@ test_expect_success 'rebase against master' '
test_expect_success \
'the rebase operation should not have destroyed author information' \
- '! git log | grep "Author:" | grep "<>"'
+ '! (git log | grep "Author:" | grep "<>")'
test_expect_success 'rebase after merge master' '
git reset --hard topic &&
git merge master &&
git rebase master &&
- ! git show | grep "^Merge:"
+ ! (git show | grep "^Merge:")
'
test_expect_success 'rebase of history with merges is linearized' '
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 9cf873f7eb..b9e3dbd242 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -91,9 +91,8 @@ for line in $FAKE_LINES; do
done
EOF
+test_set_editor "$(pwd)/fake-editor.sh"
chmod a+x fake-editor.sh
-VISUAL="$(pwd)/fake-editor.sh"
-export VISUAL
test_expect_success 'no changes are a nop' '
git rebase -i F &&
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index 37944c39a3..1777ffe8a2 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -4,7 +4,13 @@ test_description='git rebase --abort tests'
. ./test-lib.sh
+### Test that we handle space characters properly
+work_dir="$(pwd)/test dir"
+
test_expect_success setup '
+ mkdir -p "$work_dir" &&
+ cd "$work_dir" &&
+ git init &&
echo a > a &&
git add a &&
git commit -m a &&
@@ -28,32 +34,35 @@ testrebase() {
dotest=$2
test_expect_success "rebase$type --abort" '
+ cd "$work_dir" &&
# Clean up the state from the previous one
- git reset --hard pre-rebase
- test_must_fail git rebase'"$type"' master &&
- test -d '$dotest' &&
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test -d "$dotest" &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
- test ! -d '$dotest'
+ test ! -d "$dotest"
'
test_expect_success "rebase$type --abort after --skip" '
+ cd "$work_dir" &&
# Clean up the state from the previous one
- git reset --hard pre-rebase
- test_must_fail git rebase'"$type"' master &&
- test -d '$dotest' &&
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test -d "$dotest" &&
test_must_fail git rebase --skip &&
test $(git rev-parse HEAD) = $(git rev-parse master) &&
git-rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
- test ! -d '$dotest'
+ test ! -d "$dotest"
'
test_expect_success "rebase$type --abort after --continue" '
+ cd "$work_dir" &&
# Clean up the state from the previous one
- git reset --hard pre-rebase
- test_must_fail git rebase'"$type"' master &&
- test -d '$dotest' &&
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test -d "$dotest" &&
echo c > a &&
echo d >> a &&
git add a &&
@@ -61,7 +70,7 @@ testrebase() {
test $(git rev-parse HEAD) != $(git rev-parse master) &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
- test ! -d '$dotest'
+ test ! -d "$dotest"
'
}
diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
index d0a440feba..4911c48378 100755
--- a/t/t3500-cherry.sh
+++ b/t/t3500-cherry.sh
@@ -10,7 +10,8 @@ checks that git cherry only returns the second patch in the local branch
'
. ./test-lib.sh
-export GIT_AUTHOR_EMAIL=bogus_email_address
+GIT_AUTHOR_EMAIL=bogus_email_address
+export GIT_AUTHOR_EMAIL
test_expect_success \
'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 287e058e37..68c5ddebdf 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -81,17 +81,17 @@ test_expect_success '.gitignore test setup' '
test_expect_success '.gitignore is honored' '
git add . &&
- ! git ls-files | grep "\\.ig"
+ ! (git ls-files | grep "\\.ig")
'
test_expect_success 'error out when attempting to add ignored ones without -f' '
! git add a.?? &&
- ! git ls-files | grep "\\.ig"
+ ! (git ls-files | grep "\\.ig")
'
test_expect_success 'error out when attempting to add ignored ones without -f' '
! git add d.?? &&
- ! git ls-files | grep "\\.ig"
+ ! (git ls-files | grep "\\.ig")
'
test_expect_success 'add ignored ones with -f' '
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 77c90f6fa0..f15be93e77 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -66,4 +66,23 @@ test_expect_success 'revert works (commit)' '
grep "unchanged *+3/-0 file" output
'
+test_expect_success 'patch does not affect mode' '
+ git reset --hard &&
+ echo content >>file &&
+ chmod +x file &&
+ printf "n\\ny\\n" | git add -p &&
+ git show :file | grep content &&
+ git diff file | grep "new mode"
+'
+
+test_expect_success 'stage mode but not hunk' '
+ git reset --hard &&
+ echo content >>file &&
+ chmod +x file &&
+ printf "y\\nn\\n" | git add -p &&
+ git diff --cached file | grep "new mode" &&
+ git diff file | grep "+content"
+'
+
+
test_done
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 1fd3fb74d7..ba6679c6e4 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -50,4 +50,11 @@ test_expect_success 'git diff-files --raw' '
test_cmp expect actual.files
'
+test_expect_success 'git diff (empty submodule dir)' '
+ : >empty &&
+ rm -rf sub/* sub/.git &&
+ git diff > actual.empty &&
+ test_cmp empty actual.empty
+'
+
test_done
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index fa62b6aa21..9b0baac8db 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -67,10 +67,10 @@ test_expect_success \
test_expect_success \
'validate file modification time' \
- 'TZ=GMT $TAR tvf b.tar a/a |
- awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
- >b.mtime &&
- echo "2005-05-27 22:00:00" >expected.mtime &&
+ 'mkdir extract &&
+ $TAR xf b.tar -C extract a/a &&
+ perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime &&
+ echo "1117231200" >expected.mtime &&
diff expected.mtime b.mtime'
test_expect_success \
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index c955fe44f5..983a39398f 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -274,4 +274,99 @@ test_expect_success \
packname_4=$(git pack-objects test-4 <obj-list) &&
test 3 = $(ls test-4-*.pack | wc -l)'
+test_expect_success 'unpacking with --strict' '
+
+ git config --unset pack.packsizelimit &&
+ for j in a b c d e f g
+ do
+ for i in 0 1 2 3 4 5 6 7 8 9
+ do
+ o=$(echo $j$i | git hash-object -w --stdin) &&
+ echo "100644 $o 0 $j$i"
+ done
+ done >LIST &&
+ rm -f .git/index &&
+ git update-index --index-info <LIST &&
+ LIST=$(git write-tree) &&
+ rm -f .git/index &&
+ head -n 10 LIST | git update-index --index-info &&
+ LI=$(git write-tree) &&
+ rm -f .git/index &&
+ tail -n 10 LIST | git update-index --index-info &&
+ ST=$(git write-tree) &&
+ PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+ git pack-objects test-5 ) &&
+ PACK6=$( (
+ echo "$LIST"
+ echo "$LI"
+ echo "$ST"
+ ) | git pack-objects test-6 ) &&
+ test_create_repo test-5 &&
+ (
+ cd test-5 &&
+ git unpack-objects --strict <../test-5-$PACK5.pack &&
+ git ls-tree -r $LIST &&
+ git ls-tree -r $LI &&
+ git ls-tree -r $ST
+ ) &&
+ test_create_repo test-6 &&
+ (
+ # tree-only into empty repo -- many unreachables
+ cd test-6 &&
+ test_must_fail git unpack-objects --strict <../test-6-$PACK6.pack
+ ) &&
+ (
+ # already populated -- no unreachables
+ cd test-5 &&
+ git unpack-objects --strict <../test-6-$PACK6.pack
+ )
+'
+
+test_expect_success 'index-pack with --strict' '
+
+ for j in a b c d e f g
+ do
+ for i in 0 1 2 3 4 5 6 7 8 9
+ do
+ o=$(echo $j$i | git hash-object -w --stdin) &&
+ echo "100644 $o 0 $j$i"
+ done
+ done >LIST &&
+ rm -f .git/index &&
+ git update-index --index-info <LIST &&
+ LIST=$(git write-tree) &&
+ rm -f .git/index &&
+ head -n 10 LIST | git update-index --index-info &&
+ LI=$(git write-tree) &&
+ rm -f .git/index &&
+ tail -n 10 LIST | git update-index --index-info &&
+ ST=$(git write-tree) &&
+ PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+ git pack-objects test-5 ) &&
+ PACK6=$( (
+ echo "$LIST"
+ echo "$LI"
+ echo "$ST"
+ ) | git pack-objects test-6 ) &&
+ test_create_repo test-7 &&
+ (
+ cd test-7 &&
+ git index-pack --strict --stdin <../test-5-$PACK5.pack &&
+ git ls-tree -r $LIST &&
+ git ls-tree -r $LI &&
+ git ls-tree -r $ST
+ ) &&
+ test_create_repo test-8 &&
+ (
+ # tree-only into empty repo -- many unreachables
+ cd test-8 &&
+ test_must_fail git index-pack --strict --stdin <../test-6-$PACK6.pack
+ ) &&
+ (
+ # already populated -- no unreachables
+ cd test-7 &&
+ git index-pack --strict --stdin <../test-6-$PACK6.pack
+ )
+'
+
test_done
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index b88b5bbd02..09fd917672 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -65,7 +65,7 @@ test_expect_success \
have_64bits=
if msg=$(git verify-pack -v "test-3-${pack3}.pack" 2>&1) ||
- ! echo "$msg" | grep "pack too large .* off_t"
+ ! (echo "$msg" | grep "pack too large .* off_t")
then
have_64bits=t
else
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 788b4a5aae..140e874581 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -31,7 +31,7 @@ add () {
sec=$(($sec+1))
commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \
git commit-tree $tree $parents 2>>log2.txt)
- export $name=$commit
+ eval "$name=$commit; export $name"
echo $commit > .git/refs/heads/$branch
eval ${branch}TIP=$commit
}
@@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3))
pull_to_client 3rd "A" $((1*3)) # old fails
-test_expect_success "clone shallow" "git-clone --depth 2 file://`pwd`/. shallow"
+test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow'
(cd shallow; git count-objects -v) > count.shallow
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index c0dc94909b..1dd8eed5bb 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -17,7 +17,7 @@ test_expect_success setup '
git show-ref -d | sed -e "s/ / /"
) >expected.all &&
- git remote add self $(pwd)/.git
+ git remote add self "$(pwd)/.git"
'
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 0a757d5b9f..3af03d4827 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -105,7 +105,7 @@ test_expect_success 'fetch with insteadOf' '
(
TRASH=$(pwd)/ &&
cd testrepo &&
- git config url.$TRASH.insteadOf trash/
+ git config "url.$TRASH.insteadOf" trash/ &&
git config remote.up.url trash/. &&
git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
git fetch up &&
@@ -145,8 +145,8 @@ test_expect_success 'push with wildcard' '
test_expect_success 'push with insteadOf' '
mk_empty &&
- TRASH=$(pwd)/ &&
- git config url.$TRASH.insteadOf trash/ &&
+ TRASH="$(pwd)/" &&
+ git config "url./$TRASH/.insteadOf" trash/ &&
git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
(
cd testrepo &&
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
index ed3fec192a..ea49dedbf8 100755
--- a/t/t5517-push-mirror.sh
+++ b/t/t5517-push-mirror.sh
@@ -25,7 +25,7 @@ mk_repo_pair () {
(
cd master &&
git init &&
- git config remote.up.url ../mirror
+ git remote add $1 up ../mirror
)
}
@@ -225,4 +225,43 @@ test_expect_success 'push mirror adds, updates and removes tags together' '
'
+test_expect_success 'remote.foo.mirror adds and removes branches' '
+
+ mk_repo_pair --mirror &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch keep master &&
+ git branch remove master &&
+ git push up &&
+ git branch -D remove
+ git push up
+ ) &&
+ (
+ cd mirror &&
+ git show-ref -s --verify refs/heads/keep &&
+ invert git show-ref -s --verify refs/heads/remove
+ )
+
+'
+
+test_expect_success 'remote.foo.mirror=no has no effect' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git config --add remote.up.mirror no &&
+ git branch keep master &&
+ git push --mirror up &&
+ git branch -D keep &&
+ git push up
+ ) &&
+ (
+ cd mirror &&
+ git show-ref -s --verify refs/heads/keep
+ )
+
+'
+
test_done
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index b6a54867b4..e5619a9f5c 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -51,7 +51,7 @@ diff expected current'
cd "$base_dir"
test_expect_success 'cloning with reference (no -l -s)' \
-'git clone --reference B file://`pwd`/A D'
+'git clone --reference B "file://$(pwd)/A" D'
cd "$base_dir"
diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh
index 910ccb4fff..ef7127c1b3 100755
--- a/t/t5710-info-alternate.sh
+++ b/t/t5710-info-alternate.sh
@@ -81,9 +81,9 @@ test_valid_repo'
cd "$base_dir"
test_expect_success 'breaking of loops' \
-"echo '$base_dir/B/.git/objects' >> '$base_dir'/A/.git/objects/info/alternates&&
+'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
cd C &&
-test_valid_repo"
+test_valid_repo'
cd "$base_dir"
diff --git a/t/t6000lib.sh b/t/t6000lib.sh
index c0baaa5360..f55627b641 100755
--- a/t/t6000lib.sh
+++ b/t/t6000lib.sh
@@ -49,13 +49,15 @@ as_author()
shift 1
_save=$GIT_AUTHOR_EMAIL
- export GIT_AUTHOR_EMAIL="$_author"
+ GIT_AUTHOR_EMAIL="$_author"
+ export GIT_AUTHOR_EMAIL
"$@"
if test -z "$_save"
then
unset GIT_AUTHOR_EMAIL
else
- export GIT_AUTHOR_EMAIL="$_save"
+ GIT_AUTHOR_EMAIL="$_save"
+ export GIT_AUTHOR_EMAIL
fi
}
@@ -69,7 +71,8 @@ on_committer_date()
{
_date=$1
shift 1
- export GIT_COMMITTER_DATE="$_date"
+ GIT_COMMITTER_DATE="$_date"
+ export GIT_COMMITTER_DATE
"$@"
unset GIT_COMMITTER_DATE
}
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index 96f3d35530..b6e57b2426 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -13,10 +13,11 @@ T=$(git write-tree)
M=1130000000
Z=+0000
-export GIT_COMMITTER_EMAIL=git@comm.iter.xz
-export GIT_COMMITTER_NAME='C O Mmiter'
-export GIT_AUTHOR_NAME='A U Thor'
-export GIT_AUTHOR_EMAIL=git@au.thor.xz
+GIT_COMMITTER_EMAIL=git@comm.iter.xz
+GIT_COMMITTER_NAME='C O Mmiter'
+GIT_AUTHOR_NAME='A U Thor'
+GIT_AUTHOR_EMAIL=git@au.thor.xz
+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
doit() {
OFFSET=$1; shift
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 5e3e5445c7..933f567983 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -284,6 +284,31 @@ test_expect_success 'bisect starting with a detached HEAD' '
'
+test_expect_success 'bisect refuses to start if branch bisect exists' '
+ git bisect reset &&
+ git branch bisect &&
+ test_must_fail git bisect start &&
+ git branch -d bisect &&
+ git checkout -b bisect &&
+ test_must_fail git bisect start &&
+ git checkout master &&
+ git branch -d bisect
+'
+
+test_expect_success 'bisect refuses to start if branch new-bisect exists' '
+ git bisect reset &&
+ git branch new-bisect &&
+ test_must_fail git bisect start &&
+ git branch -d new-bisect
+'
+
+test_expect_success 'bisect errors out if bad and good are mistaken' '
+ git bisect reset &&
+ test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error &&
+ grep "mistake good and bad" rev_list_error &&
+ git bisect reset
+'
+
#
#
test_done
diff --git a/t/t6032-merge-large-rename.sh b/t/t6032-merge-large-rename.sh
new file mode 100755
index 0000000000..eac5ebac24
--- /dev/null
+++ b/t/t6032-merge-large-rename.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+test_description='merging with large rename matrix'
+. ./test-lib.sh
+
+count() {
+ i=1
+ while test $i -le $1; do
+ echo $i
+ i=$(($i + 1))
+ done
+}
+
+test_expect_success 'setup (initial)' '
+ touch file &&
+ git add . &&
+ git commit -m initial &&
+ git tag initial
+'
+
+make_text() {
+ echo $1: $2
+ for i in `count 20`; do
+ echo $1: $i
+ done
+ echo $1: $3
+}
+
+test_rename() {
+ test_expect_success "rename ($1, $2)" '
+ n='$1'
+ expect='$2'
+ git checkout -f master &&
+ git branch -D test$n || true &&
+ git reset --hard initial &&
+ for i in $(count $n); do
+ make_text $i initial initial >$i
+ done &&
+ git add . &&
+ git commit -m add=$n &&
+ for i in $(count $n); do
+ make_text $i changed initial >$i
+ done &&
+ git commit -a -m change=$n &&
+ git checkout -b test$n HEAD^ &&
+ for i in $(count $n); do
+ git rm $i
+ make_text $i initial changed >$i.moved
+ done &&
+ git add . &&
+ git commit -m change+rename=$n &&
+ case "$expect" in
+ ok) git merge master ;;
+ *) test_must_fail git merge master ;;
+ esac
+ '
+}
+
+test_rename 5 ok
+
+test_expect_success 'set diff.renamelimit to 4' '
+ git config diff.renamelimit 4
+'
+test_rename 4 ok
+test_rename 5 fail
+
+test_expect_success 'set merge.renamelimit to 5' '
+ git config merge.renamelimit 5
+'
+test_rename 5 ok
+test_rename 6 fail
+
+test_done
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 526d7d1c44..c9bf6fdba3 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -82,14 +82,14 @@ test_expect_success 'merge-msg test #1' '
git diff actual expected
'
-cat >expected <<\EOF
-Merge branch 'left' of ../trash
+cat >expected <<EOF
+Merge branch 'left' of ../$test
EOF
test_expect_success 'merge-msg test #2' '
git checkout master &&
- git fetch ../trash left &&
+ git fetch ../"$test" left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
git diff actual expected
@@ -106,8 +106,24 @@ Merge branch 'left'
Common #1
EOF
-test_expect_success 'merge-msg test #3' '
+test_expect_success 'merge-msg test #3-1' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
+ git config merge.log true &&
+
+ git checkout master &&
+ setdate &&
+ git fetch . left &&
+
+ git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+ git diff actual expected
+'
+
+test_expect_success 'merge-msg test #3-2' '
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
git config merge.summary true &&
git checkout master &&
@@ -136,8 +152,24 @@ Merge branches 'left' and 'right'
Common #1
EOF
-test_expect_success 'merge-msg test #4' '
+test_expect_success 'merge-msg test #4-1' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
+ git config merge.log true &&
+
+ git checkout master &&
+ setdate &&
+ git fetch . left right &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+ git diff actual expected
+'
+
+test_expect_success 'merge-msg test #4-2' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
git config merge.summary true &&
git checkout master &&
@@ -148,8 +180,24 @@ test_expect_success 'merge-msg test #4' '
git diff actual expected
'
-test_expect_success 'merge-msg test #5' '
+test_expect_success 'merge-msg test #5-1' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
+ git config merge.log yes &&
+
+ git checkout master &&
+ setdate &&
+ git fetch . left right &&
+
+ git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+ git diff actual expected
+'
+
+test_expect_success 'merge-msg test #5-2' '
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
git config merge.summary yes &&
git checkout master &&
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index efd658adb6..1639c7aa96 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -125,7 +125,7 @@ test_expect_success 'use index-filter to move into a subdirectory' '
"git ls-files -s | sed \"s-\\t-&newsubdir/-\" |
GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
git update-index --index-info &&
- mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved &&
+ mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved &&
test -z "$(git diff HEAD directorymoved:newsubdir)"'
test_expect_success 'stops when msg filter fails' '
@@ -219,4 +219,36 @@ test_expect_success 'Subdirectory filter with disappearing trees' '
test $(git rev-list master | wc -l) = 3
'
+test_expect_success 'Tag name filtering retains tag message' '
+ git tag -m atag T &&
+ git cat-file tag T > expect &&
+ git filter-branch -f --tag-name-filter cat &&
+ git cat-file tag T > actual &&
+ git diff expect actual
+'
+
+faux_gpg_tag='object XXXXXX
+type commit
+tag S
+tagger T A Gger <tagger@example.com> 1206026339 -0500
+
+This is a faux gpg signed tag.
+-----BEGIN PGP SIGNATURE-----
+Version: FauxGPG v0.0.0 (FAUX/Linux)
+
+gdsfoewhxu/6l06f1kxyxhKdZkrcbaiOMtkJUA9ITAc1mlamh0ooasxkH1XwMbYQ
+acmwXaWET20H0GeAGP+7vow=
+=agpO
+-----END PGP SIGNATURE-----
+'
+test_expect_success 'Tag name filtering strips gpg signature' '
+ sha1=$(git rev-parse HEAD) &&
+ sha1t=$(echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | git mktag) &&
+ git update-ref "refs/tags/S" "$sha1t" &&
+ echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | head -n 6 > expect &&
+ git filter-branch -f --tag-name-filter cat &&
+ git cat-file tag S > actual &&
+ git diff expect actual
+'
+
test_done
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 1a7141ecd7..2dcee7ccc5 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -626,7 +626,8 @@ esac
cp -R ../t7004 ./gpghome
chmod 0700 gpghome
-export GNUPGHOME="$(pwd)/gpghome"
+GNUPGHOME="$(pwd)/gpghome"
+export GNUPGHOME
get_tag_header signed-tag $commit commit $time >expect
echo 'A signed tag message' >>expect
diff --git a/t/t7010-setup.sh b/t/t7010-setup.sh
index 02cf7c5c9d..d8a7c79852 100755
--- a/t/t7010-setup.sh
+++ b/t/t7010-setup.sh
@@ -122,7 +122,7 @@ test_expect_success 'commit using absolute path names' '
test_expect_success 'log using absolute path names' '
echo bb >>a/b/c/d &&
- git commit -m "bb" $(pwd)/a/b/c/d &&
+ git commit -m "bb" "$(pwd)/a/b/c/d" &&
git log a/b/c/d >f1.txt &&
git log "$(pwd)/a/b/c/d" >f2.txt &&
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index a50492f7c0..bd77239708 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -112,7 +112,7 @@ test_expect_success 'git-clean with absolute path' '
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
would_clean=$(
cd docs &&
- git clean -n $(pwd)/../src |
+ git clean -n "$(pwd)/../src" |
sed -n -e "s|^Would remove ||p"
) &&
test "$would_clean" = ../src/part3.c || {
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index b9a22190e8..bf12dbdeef 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -192,4 +192,17 @@ test_expect_success 'given commit' "
EOF
"
+test_expect_success '--for-status' "
+ git submodule summary --for-status HEAD^ >actual &&
+ test_cmp actual - <<EOF
+# Modified submodules:
+#
+# * sm1 $head6...0000000:
+#
+# * sm2 0000000...$head7 (2):
+# > Add foo9
+#
+EOF
+"
+
test_done
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index c0288f345f..d3370ff7ff 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -41,7 +41,7 @@ test_expect_success \
test_expect_success \
"using paths with --interactive" \
"echo bong-o-bong >file &&
- ! echo 7 | git-commit -m foo --interactive file"
+ ! (echo 7 | git-commit -m foo --interactive file)"
test_expect_success \
"using invalid commit with -C" \
@@ -79,8 +79,8 @@ test_expect_success \
cat >editor <<\EOF
#!/bin/sh
-sed -e "s/a file/an amend commit/g" < $1 > $1-
-mv $1- $1
+sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
+mv "$1-" "$1"
EOF
chmod 755 editor
@@ -99,8 +99,8 @@ test_expect_success \
cat >editor <<\EOF
#!/bin/sh
-sed -e "s/amend/older/g" < $1 > $1-
-mv $1- $1
+sed -e "s/amend/older/g" < "$1" > "$1-"
+mv "$1-" "$1"
EOF
chmod 755 editor
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 284c941247..018060c60f 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -154,6 +154,33 @@ test_expect_success 'cleanup commit messages (strip,-F,-e)' '
'
+echo "#
+# Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+#" >> expect
+
+test_expect_success 'author different from committer' '
+
+ echo >>negative &&
+ git commit -e -m "sample"
+ head -n 7 .git/COMMIT_EDITMSG >actual &&
+ test_cmp expect actual
+'
+
+sed -i '$d' expect
+echo "# Committer:
+#" >> expect
+unset GIT_COMMITTER_EMAIL
+unset GIT_COMMITTER_NAME
+
+test_expect_success 'committer is automatic' '
+
+ echo >>negative &&
+ git commit -e -m "sample"
+ head -n 8 .git/COMMIT_EDITMSG | \
+ sed "s/^# Committer: .*/# Committer:/" >actual &&
+ test_cmp expect actual
+'
+
pwd=`pwd`
cat >> .git/FAKE_EDITOR << EOF
#! /bin/sh
diff --git a/t/t7502-status.sh b/t/t7502-status.sh
index cd08516e6d..e4bfcaece0 100755
--- a/t/t7502-status.sh
+++ b/t/t7502-status.sh
@@ -149,4 +149,138 @@ test_expect_success 'status of partial commit excluding new file in index' '
test_cmp expect output
'
+test_expect_success 'setup status submodule summary' '
+ test_create_repo sm && (
+ cd sm &&
+ >foo &&
+ git add foo &&
+ git commit -m "Add foo"
+ ) &&
+ git add sm
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+# new file: sm
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status submodule summary is disabled by default' '
+ git status >output &&
+ test_cmp expect output
+'
+
+head=$(cd sm && git rev-parse --short=7 --verify HEAD)
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+# new file: sm
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Modified submodules:
+#
+# * sm 0000000...$head (1):
+# > Add foo
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status submodule summary' '
+ git config status.submodulesummary 10 &&
+ git status >output &&
+ test_cmp expect output
+'
+
+
+cat >expect <<EOF
+# On branch master
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+test_expect_success 'status submodule summary (clean submodule)' '
+ git commit -m "commit submodule" &&
+ git config status.submodulesummary 10 &&
+ test_must_fail git status >output &&
+ test_cmp expect output
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD^1 <file>..." to unstage)
+#
+# new file: dir2/added
+# new file: sm
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Modified submodules:
+#
+# * sm 0000000...$head (1):
+# > Add foo
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status submodule summary (--amend)' '
+ git config status.submodulesummary 10 &&
+ git status --amend >output &&
+ test_cmp expect output
+'
+
test_done
diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh
index eff36aaee3..88577af953 100755
--- a/t/t7504-commit-msg-hook.sh
+++ b/t/t7504-commit-msg-hook.sh
@@ -19,6 +19,9 @@ cp FAKE_MSG "$1"
exit 0
EOF
chmod +x fake-editor
+
+## Not using test_set_editor here so we can easily ensure the editor variable
+## is only set for the editor tests
FAKE_EDITOR="$(pwd)/fake-editor"
export FAKE_EDITOR
@@ -27,7 +30,7 @@ test_expect_success 'with no hook (editor)' '
echo "more foo" >> file &&
git add file &&
echo "more foo" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit
'
@@ -44,7 +47,7 @@ test_expect_success '--no-verify with no hook (editor)' '
echo "more bar" > file &&
git add file &&
echo "more bar" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -71,7 +74,7 @@ test_expect_success 'with succeeding hook (editor)' '
echo "more more" >> file &&
git add file &&
echo "more more" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit
'
@@ -88,7 +91,7 @@ test_expect_success '--no-verify with succeeding hook (editor)' '
echo "even more more" >> file &&
git add file &&
echo "even more more" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -111,7 +114,7 @@ test_expect_success 'with failing hook (editor)' '
echo "more another" >> file &&
git add file &&
echo "more another" > FAKE_MSG &&
- ! (GIT_EDITOR="$FAKE_EDITOR" git commit)
+ ! (GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit)
'
@@ -128,7 +131,7 @@ test_expect_success '--no-verify with failing hook (editor)' '
echo "more stuff" >> file &&
git add file &&
echo "more stuff" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -146,7 +149,7 @@ test_expect_success 'with non-executable hook (editor)' '
echo "content again" >> file &&
git add file &&
echo "content again" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit -m "content again"
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -m "content again"
'
@@ -163,7 +166,7 @@ test_expect_success '--no-verify with non-executable hook (editor)' '
echo "even more content" >> file &&
git add file &&
echo "even more content" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -193,7 +196,7 @@ test_expect_success 'hook edits commit message (editor)' '
echo "additional content" >> file &&
git add file &&
echo "additional content" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
commit_msg_is "new message"
'
@@ -212,7 +215,7 @@ test_expect_success "hook doesn't edit commit message (editor)" '
echo "more plus" >> file &&
git add file &&
echo "more plus" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify &&
commit_msg_is "more plus"
'
diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
index 802aa624d0..cd6c7c8342 100755
--- a/t/t7505-prepare-commit-msg-hook.sh
+++ b/t/t7505-prepare-commit-msg-hook.sh
@@ -18,6 +18,9 @@ cat > fake-editor <<'EOF'
exit 0
EOF
chmod +x fake-editor
+
+## Not using test_set_editor here so we can easily ensure the editor variable
+## is only set for the editor tests
FAKE_EDITOR="$(pwd)/fake-editor"
export FAKE_EDITOR
@@ -58,7 +61,7 @@ test_expect_success 'with hook (-m editor)' '
echo "more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit -e -m "more more" &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -m "more more" &&
test "`git log -1 --pretty=format:%s`" = message
'
@@ -85,7 +88,7 @@ test_expect_success 'with hook (-F editor)' '
echo "more" >> file &&
git add file &&
- (echo more more | GIT_EDITOR="$FAKE_EDITOR" git commit -e -F -) &&
+ (echo more more | GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -F -) &&
test "`git log -1 --pretty=format:%s`" = message
'
@@ -104,7 +107,7 @@ test_expect_success 'with hook (editor)' '
echo "more more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
test "`git log -1 --pretty=format:%s`" = default
'
@@ -114,7 +117,7 @@ test_expect_success 'with hook (--amend)' '
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --amend &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --amend &&
test "`git log -1 --pretty=format:%s`" = "$head"
'
@@ -124,7 +127,7 @@ test_expect_success 'with hook (-c)' '
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- GIT_EDITOR="$FAKE_EDITOR" git commit -c $head &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head &&
test "`git log -1 --pretty=format:%s`" = "$head"
'
@@ -139,7 +142,7 @@ test_expect_success 'with failing hook' '
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- ! GIT_EDITOR="$FAKE_EDITOR" git commit -c $head
+ ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head
'
@@ -148,7 +151,7 @@ test_expect_success 'with failing hook (--no-verify)' '
head=`git rev-parse HEAD` &&
echo "more" >> file &&
git add file &&
- ! GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify -c $head
+ ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify -c $head
'
diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh
new file mode 100755
index 0000000000..a75130cdbb
--- /dev/null
+++ b/t/t7506-status-submodule.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='git-status for submodule'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_create_repo sub
+ cd sub &&
+ : >bar &&
+ git add bar &&
+ git commit -m " Add bar" &&
+ cd .. &&
+ git add sub &&
+ git commit -m "Add submodule sub"
+'
+
+test_expect_success 'status clean' '
+ git status |
+ grep "nothing to commit"
+'
+test_expect_success 'status -a clean' '
+ git status -a |
+ grep "nothing to commit"
+'
+test_expect_success 'rm submodule contents' '
+ rm -rf sub/* sub/.git
+'
+test_expect_success 'status clean (empty submodule dir)' '
+ git status |
+ grep "nothing to commit"
+'
+test_expect_success 'status -a clean (empty submodule dir)' '
+ git status -a |
+ grep "nothing to commit"
+'
+
+test_done
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 56869aceed..d21cd290d3 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -104,7 +104,11 @@ create_merge_msgs() {
git log --no-merges ^HEAD c2 >>squash.1-5 &&
echo "Squashed commit of the following:" >squash.1-5-9 &&
echo >>squash.1-5-9 &&
- git log --no-merges ^HEAD c2 c3 >>squash.1-5-9
+ git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 &&
+ echo > msg.nolog &&
+ echo "* commit 'c3':" >msg.log &&
+ echo " commit 3" >>msg.log &&
+ echo >>msg.log
}
verify_diff() {
@@ -364,7 +368,7 @@ test_expect_success 'merge c1 with c2 (squash in config)' '
test_debug 'gitk --all'
-test_expect_success 'override config option -n' '
+test_expect_success 'override config option -n with --summary' '
git reset --hard c1 &&
git config branch.master.mergeoptions "-n" &&
test_tick &&
@@ -373,15 +377,30 @@ test_expect_success 'override config option -n' '
verify_parents $c1 $c2 &&
if ! grep "^ file | *2 +-$" diffstat.txt
then
- echo "[OOPS] diffstat was not generated"
+ echo "[OOPS] diffstat was not generated with --summary"
+ false
+ fi
+'
+
+test_expect_success 'override config option -n with --stat' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "-n" &&
+ test_tick &&
+ git merge --stat c2 >diffstat.txt &&
+ verify_merge file result.1-5 msg.1-5 &&
+ verify_parents $c1 $c2 &&
+ if ! grep "^ file | *2 +-$" diffstat.txt
+ then
+ echo "[OOPS] diffstat was not generated with --stat"
+ false
fi
'
test_debug 'gitk --all'
-test_expect_success 'override config option --summary' '
+test_expect_success 'override config option --stat' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--summary" &&
+ git config branch.master.mergeoptions "--stat" &&
test_tick &&
git merge -n c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
@@ -441,6 +460,16 @@ test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
verify_head $c1
'
+test_expect_success 'merge log message' '
+ git reset --hard c0 &&
+ git merge --no-log c2 &&
+ git show -s --pretty=format:%b HEAD >msg.act &&
+ verify_diff msg.nolog msg.act "[OOPS] bad merge log message" &&
+ git merge --log c3 &&
+ git show -s --pretty=format:%b HEAD >msg.act &&
+ verify_diff msg.log msg.act "[OOPS] bad merge log message"
+'
+
test_debug 'gitk --all'
test_done
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index c0973b4e6e..04baa61c04 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -139,15 +139,16 @@ test_expect_success 'Valid In-Reply-To when prompting' '
test_expect_success 'setup fake editor' '
(echo "#!/bin/sh" &&
- echo "echo fake edit >>\$1"
+ echo "echo fake edit >>\"\$1\""
) >fake-editor &&
chmod +x fake-editor
'
+test_set_editor "$(pwd)/fake-editor"
+
test_expect_success '--compose works' '
clean_fake_sendmail &&
echo y | \
- GIT_EDITOR=$(pwd)/fake-editor \
GIT_SEND_EMAIL_NOTTY=1 \
git send-email \
--compose --subject foo \
@@ -166,4 +167,70 @@ test_expect_success 'second message is patch' '
grep "Subject:.*Second" msgtxt2
'
+cat >expected-show-all-headers <<\EOF
+0001-Second.patch
+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
+Dry-OK. Log says:
+Server: relay.example.com
+MAIL FROM:<from@example.com>
+RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>
+From: Example <from@example.com>
+To: to@example.com
+Cc: cc@example.com, A <author@example.com>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cc set' '
+ git config sendemail.cc cc@example.com &&
+ git send-email \
+ --dry-run \
+ --from="Example <from@example.com>" \
+ --to=to@example.com \
+ --smtp-server relay.example.com \
+ $patches |
+ sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
+ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+ >actual-show-all-headers &&
+ test_cmp expected-show-all-headers actual-show-all-headers
+'
+
+cat >expected-show-all-headers <<\EOF
+0001-Second.patch
+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
+Dry-OK. Log says:
+Server: relay.example.com
+MAIL FROM:<from@example.com>
+RCPT TO:<to@example.com>,<author@example.com>
+From: Example <from@example.com>
+To: to@example.com
+Cc: A <author@example.com>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cc unset' '
+ git config --unset sendemail.cc &&
+ git send-email \
+ --dry-run \
+ --from="Example <from@example.com>" \
+ --to=to@example.com \
+ --smtp-server relay.example.com \
+ $patches |
+ sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
+ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+ >actual-show-all-headers &&
+ test_cmp expected-show-all-headers actual-show-all-headers
+'
+
test_done
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 4e24ab3a7d..bdf29c1734 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -20,39 +20,39 @@ esac
echo 'define NO_SVN_TESTS to skip git-svn tests'
test_expect_success \
- 'initialize git-svn' "
+ 'initialize git-svn' '
mkdir import &&
cd import &&
echo foo > foo &&
ln -s foo foo.link
mkdir -p dir/a/b/c/d/e &&
- echo 'deep dir' > dir/a/b/c/d/e/file &&
+ echo "deep dir" > dir/a/b/c/d/e/file &&
mkdir bar &&
- echo 'zzz' > bar/zzz &&
- echo '#!/bin/sh' > exec.sh &&
+ echo "zzz" > bar/zzz &&
+ echo "#!/bin/sh" > exec.sh &&
chmod +x exec.sh &&
- svn import -m 'import for git-svn' . $svnrepo >/dev/null &&
+ svn import -m "import for git-svn" . "$svnrepo" >/dev/null &&
cd .. &&
rm -rf import &&
- git-svn init $svnrepo"
+ git-svn init "$svnrepo"'
test_expect_success \
'import an SVN revision into git' \
'git-svn fetch'
-test_expect_success "checkout from svn" "svn co $svnrepo '$SVN_TREE'"
+test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"'
name='try a deep --rmdir with a commit'
-test_expect_success "$name" "
+test_expect_success "$name" '
git checkout -f -b mybranch remotes/git-svn &&
mv dir/a/b/c/d/e/file dir/file &&
cp dir/file file &&
git update-index --add --remove dir/a/b/c/d/e/file dir/file file &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch &&
- svn up '$SVN_TREE' &&
- test -d '$SVN_TREE'/dir && test ! -d '$SVN_TREE'/dir/a"
+ svn up "$SVN_TREE" &&
+ test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a'
name='detect node change from file to directory #1'
@@ -68,108 +68,108 @@ test_expect_success "$name" "
name='detect node change from directory to file #1'
-test_expect_success "$name" "
- rm -rf dir '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -rf dir "$GIT_DIR"/index &&
git checkout -f -b mybranch2 remotes/git-svn &&
mv bar/zzz zzz &&
rm -rf bar &&
mv zzz bar &&
git update-index --remove -- bar/zzz &&
git update-index --add -- bar &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
! git-svn set-tree --find-copies-harder --rmdir \
- remotes/git-svn..mybranch2" || true
+ remotes/git-svn..mybranch2' || true
name='detect node change from file to directory #2'
-test_expect_success "$name" "
- rm -f '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -f "$GIT_DIR"/index &&
git checkout -f -b mybranch3 remotes/git-svn &&
rm bar/zzz &&
git update-index --remove bar/zzz &&
mkdir bar/zzz &&
echo yyy > bar/zzz/yyy &&
git update-index --add bar/zzz/yyy &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
! git-svn set-tree --find-copies-harder --rmdir \
- remotes/git-svn..mybranch3" || true
+ remotes/git-svn..mybranch3' || true
name='detect node change from directory to file #2'
-test_expect_success "$name" "
- rm -f '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -f "$GIT_DIR"/index &&
git checkout -f -b mybranch4 remotes/git-svn &&
rm -rf dir &&
git update-index --remove -- dir/file &&
touch dir &&
echo asdf > dir &&
git update-index --add -- dir &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
! git-svn set-tree --find-copies-harder --rmdir \
- remotes/git-svn..mybranch4" || true
+ remotes/git-svn..mybranch4' || true
name='remove executable bit from a file'
-test_expect_success "$name" "
- rm -f '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -f "$GIT_DIR"/index &&
git checkout -f -b mybranch5 remotes/git-svn &&
chmod -x exec.sh &&
git update-index exec.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test ! -x '$SVN_TREE'/exec.sh"
+ svn up "$SVN_TREE" &&
+ test ! -x "$SVN_TREE"/exec.sh'
name='add executable bit back file'
-test_expect_success "$name" "
+test_expect_success "$name" '
chmod +x exec.sh &&
git update-index exec.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -x '$SVN_TREE'/exec.sh"
+ svn up "$SVN_TREE" &&
+ test -x "$SVN_TREE"/exec.sh'
name='executable file becomes a symlink to bar/zzz (file)'
-test_expect_success "$name" "
+test_expect_success "$name" '
rm exec.sh &&
ln -s bar/zzz exec.sh &&
git update-index exec.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -L '$SVN_TREE'/exec.sh"
+ svn up "$SVN_TREE" &&
+ test -L "$SVN_TREE"/exec.sh'
name='new symlink is added to a file that was also just made executable'
-test_expect_success "$name" "
+test_expect_success "$name" '
chmod +x bar/zzz &&
ln -s bar/zzz exec-2.sh &&
git update-index --add bar/zzz exec-2.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -x '$SVN_TREE'/bar/zzz &&
- test -L '$SVN_TREE'/exec-2.sh"
+ svn up "$SVN_TREE" &&
+ test -x "$SVN_TREE"/bar/zzz &&
+ test -L "$SVN_TREE"/exec-2.sh'
name='modify a symlink to become a file'
-test_expect_success "$name" "
+test_expect_success "$name" '
echo git help > help || true &&
rm exec-2.sh &&
cp help exec-2.sh &&
git update-index exec-2.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -f '$SVN_TREE'/exec-2.sh &&
- test ! -L '$SVN_TREE'/exec-2.sh &&
- git diff help $SVN_TREE/exec-2.sh"
+ svn up "$SVN_TREE" &&
+ test -f "$SVN_TREE"/exec-2.sh &&
+ test ! -L "$SVN_TREE"/exec-2.sh &&
+ git diff help "$SVN_TREE"/exec-2.sh'
if test "$have_utf8" = t
then
@@ -190,10 +190,10 @@ name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
GIT_SVN_ID=alt
export GIT_SVN_ID
test_expect_success "$name" \
- "git-svn init $svnrepo && git-svn fetch &&
+ 'git-svn init "$svnrepo" && git-svn fetch &&
git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
- git diff a b"
+ git diff a b'
name='check imported tree checksums expected tree checksums'
rm -f expected
@@ -219,22 +219,22 @@ test_expect_success 'exit if remote refs are ambigious' "
! git-svn migrate
"
-test_expect_success 'exit if init-ing a would clobber a URL' "
- svnadmin create ${PWD}/svnrepo2 &&
- svn mkdir -m 'mkdir bar' ${svnrepo}2/bar &&
+test_expect_success 'exit if init-ing a would clobber a URL' '
+ svnadmin create "${PWD}/svnrepo2" &&
+ svn mkdir -m "mkdir bar" "${svnrepo}2/bar" &&
git config --unset svn-remote.svn.fetch \
- '^bar:refs/remotes/git-svn$' &&
- ! git-svn init ${svnrepo}2/bar
- "
+ "^bar:refs/remotes/git-svn$" &&
+ ! git-svn init "${svnrepo}2/bar"
+ '
test_expect_success \
- 'init allows us to connect to another directory in the same repo' "
- git-svn init --minimize-url -i bar $svnrepo/bar &&
+ 'init allows us to connect to another directory in the same repo' '
+ git-svn init --minimize-url -i bar "$svnrepo/bar" &&
git config --get svn-remote.svn.fetch \
- '^bar:refs/remotes/bar$' &&
+ "^bar:refs/remotes/bar$" &&
git config --get svn-remote.svn.fetch \
- '^:refs/remotes/git-svn$'
- "
+ "^:refs/remotes/git-svn$"
+ '
test_expect_success 'able to dcommit to a subdirectory' "
git-svn fetch -i bar &&
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index d7a704754e..f420796c31 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -52,7 +52,7 @@ EOF
cd ..
rm -rf import
-test_expect_success 'checkout working copy from svn' "svn co $svnrepo test_wc"
+test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc'
test_expect_success 'setup some commits to svn' \
'cd test_wc &&
echo Greetings >> kw.c &&
@@ -66,7 +66,7 @@ test_expect_success 'setup some commits to svn' \
svn commit -m "Propset Id" &&
cd ..'
-test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
+test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"'
test_expect_success 'fetch revisions from svn' 'git-svn fetch'
name='test svn:keywords ignoring'
@@ -90,9 +90,9 @@ test_expect_success "propset CR on crlf files" \
cd ..'
test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
- "git-svn fetch &&
+ 'git-svn fetch &&
git pull . remotes/git-svn &&
- svn co $svnrepo new_wc"
+ svn co "$svnrepo" new_wc'
for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
do
diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh
index 4e0808380f..0e7ce34b9b 100755
--- a/t/t9102-git-svn-deep-rmdir.sh
+++ b/t/t9102-git-svn-deep-rmdir.sh
@@ -2,29 +2,29 @@
test_description='git-svn rmdir'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
mkdir -p deeply/nested/directory/number/1 &&
mkdir -p deeply/nested/directory/number/2 &&
echo foo > deeply/nested/directory/number/1/file &&
echo foo > deeply/nested/directory/number/2/another &&
- svn import -m 'import for git-svn' . $svnrepo &&
+ svn import -m "import for git-svn" . "$svnrepo" &&
cd ..
- "
+ '
-test_expect_success 'mirror via git-svn' "
- git-svn init $svnrepo &&
+test_expect_success 'mirror via git-svn' '
+ git-svn init "$svnrepo" &&
git-svn fetch &&
git checkout -f -b test-rmdir remotes/git-svn
- "
+ '
-test_expect_success 'Try a commit on rmdir' "
+test_expect_success 'Try a commit on rmdir' '
git rm -f deeply/nested/directory/number/2/another &&
- git commit -a -m 'remove another' &&
+ git commit -a -m "remove another" &&
git-svn set-tree --rmdir HEAD &&
- svn ls -R $svnrepo | grep ^deeply/nested/directory/number/1
- "
+ svn ls -R "$svnrepo" | grep ^deeply/nested/directory/number/1
+ '
test_done
diff --git a/t/t9103-git-svn-tracked-directory-removed.sh b/t/t9103-git-svn-tracked-directory-removed.sh
index 0f0b0fd2c6..9ffd8458ef 100755
--- a/t/t9103-git-svn-tracked-directory-removed.sh
+++ b/t/t9103-git-svn-tracked-directory-removed.sh
@@ -10,30 +10,30 @@ test_expect_success 'make history for tracking' '
mkdir import &&
mkdir import/trunk &&
echo hello >> import/trunk/README &&
- svn import -m initial import $svnrepo &&
+ svn import -m initial import "$svnrepo" &&
rm -rf import &&
- svn co $svnrepo/trunk trunk &&
+ svn co "$svnrepo"/trunk trunk &&
echo bye bye >> trunk/README &&
- svn rm -m "gone" $svnrepo/trunk &&
+ svn rm -m "gone" "$svnrepo"/trunk &&
rm -rf trunk &&
mkdir trunk &&
echo "new" > trunk/FOLLOWME &&
- svn import -m "new trunk" trunk $svnrepo/trunk
+ svn import -m "new trunk" trunk "$svnrepo"/trunk
'
test_expect_success 'clone repo with git' '
- git svn clone -s $svnrepo x &&
+ git svn clone -s "$svnrepo" x &&
test -f x/FOLLOWME &&
test ! -f x/README
'
-test_expect_success 'make sure r2 still has old file' '
+test_expect_success 'make sure r2 still has old file' "
cd x &&
- test -n "$(git svn find-rev r1)" &&
- git reset --hard $(git svn find-rev r1) &&
+ test -n \"\$(git svn find-rev r1)\" &&
+ git reset --hard \$(git svn find-rev r1) &&
test -f README &&
test ! -f FOLLOWME &&
- test x$(git svn find-rev r2) = x
-'
+ test x\$(git svn find-rev r2) = x
+"
test_done
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 7ba76309ac..4d964e2db7 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -6,165 +6,165 @@
test_description='git-svn fetching'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
mkdir -p trunk &&
echo hello > trunk/readme &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
- svn co $svnrepo wc &&
+ svn co "$svnrepo" wc &&
cd wc &&
echo world >> trunk/readme &&
poke trunk/readme &&
- svn commit -m 'another commit' &&
+ svn commit -m "another commit" &&
svn up &&
svn mv trunk thunk &&
echo goodbye >> thunk/readme &&
poke thunk/readme &&
- svn commit -m 'bye now' &&
+ svn commit -m "bye now" &&
cd ..
- "
+ '
-test_expect_success 'init and fetch a moved directory' "
- git-svn init --minimize-url -i thunk $svnrepo/thunk &&
+test_expect_success 'init and fetch a moved directory' '
+ git-svn init --minimize-url -i thunk "$svnrepo"/thunk &&
git-svn fetch -i thunk &&
- test \"\`git rev-parse --verify refs/remotes/thunk@2\`\" \
- = \"\`git rev-parse --verify refs/remotes/thunk~1\`\" &&
- test \"\`git cat-file blob refs/remotes/thunk:readme |\
- sed -n -e '3p'\`\" = goodbye &&
- test -z \"\`git config --get svn-remote.svn.fetch \
- '^trunk:refs/remotes/thunk@2$'\`\"
- "
+ test "`git rev-parse --verify refs/remotes/thunk@2`" \
+ = "`git rev-parse --verify refs/remotes/thunk~1`" &&
+ test "`git cat-file blob refs/remotes/thunk:readme |\
+ sed -n -e "3p"`" = goodbye &&
+ test -z "`git config --get svn-remote.svn.fetch \
+ "^trunk:refs/remotes/thunk@2$"`"
+ '
-test_expect_success 'init and fetch from one svn-remote' "
- git config svn-remote.svn.url $svnrepo &&
+test_expect_success 'init and fetch from one svn-remote' '
+ git config svn-remote.svn.url "$svnrepo" &&
git config --add svn-remote.svn.fetch \
trunk:refs/remotes/svn/trunk &&
git config --add svn-remote.svn.fetch \
thunk:refs/remotes/svn/thunk &&
git-svn fetch -i svn/thunk &&
- test \"\`git rev-parse --verify refs/remotes/svn/trunk\`\" \
- = \"\`git rev-parse --verify refs/remotes/svn/thunk~1\`\" &&
- test \"\`git cat-file blob refs/remotes/svn/thunk:readme |\
- sed -n -e '3p'\`\" = goodbye
- "
+ test "`git rev-parse --verify refs/remotes/svn/trunk`" \
+ = "`git rev-parse --verify refs/remotes/svn/thunk~1`" &&
+ test "`git cat-file blob refs/remotes/svn/thunk:readme |\
+ sed -n -e "3p"`" = goodbye
+ '
-test_expect_success 'follow deleted parent' "
- (svn cp -m 'resurrecting trunk as junk' \
- $svnrepo/trunk@2 $svnrepo/junk ||
- svn cp -m 'resurrecting trunk as junk' \
- -r2 $svnrepo/trunk $svnrepo/junk) &&
+test_expect_success 'follow deleted parent' '
+ (svn cp -m "resurrecting trunk as junk" \
+ "$svnrepo"/trunk@2 "$svnrepo"/junk ||
+ svn cp -m "resurrecting trunk as junk" \
+ -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
git config --add svn-remote.svn.fetch \
junk:refs/remotes/svn/junk &&
git-svn fetch -i svn/thunk &&
git-svn fetch -i svn/junk &&
- test -z \"\`git diff svn/junk svn/trunk\`\" &&
- test \"\`git merge-base svn/junk svn/trunk\`\" \
- = \"\`git rev-parse svn/trunk\`\"
- "
+ test -z "`git diff svn/junk svn/trunk`" &&
+ test "`git merge-base svn/junk svn/trunk`" \
+ = "`git rev-parse svn/trunk`"
+ '
-test_expect_success 'follow larger parent' "
+test_expect_success 'follow larger parent' '
mkdir -p import/trunk/thunk/bump/thud &&
echo hi > import/trunk/thunk/bump/thud/file &&
- svn import -m 'import a larger parent' import $svnrepo/larger-parent &&
- svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger &&
+ svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
+ svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
git-svn init --minimize-url -i larger \
- $svnrepo/another-larger/trunk/thunk/bump/thud &&
+ "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
git-svn fetch -i larger &&
git rev-parse --verify refs/remotes/larger &&
git rev-parse --verify \
refs/remotes/larger-parent/trunk/thunk/bump/thud &&
- test \"\`git merge-base \
+ test "`git merge-base \
refs/remotes/larger-parent/trunk/thunk/bump/thud \
- refs/remotes/larger\`\" = \
- \"\`git rev-parse refs/remotes/larger\`\"
+ refs/remotes/larger`" = \
+ "`git rev-parse refs/remotes/larger`"
true
- "
+ '
-test_expect_success 'follow higher-level parent' "
- svn mkdir -m 'follow higher-level parent' $svnrepo/blob &&
- svn co $svnrepo/blob blob &&
+test_expect_success 'follow higher-level parent' '
+ svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
+ svn co "$svnrepo"/blob blob &&
cd blob &&
echo hi > hi &&
svn add hi &&
- svn commit -m 'hihi' &&
+ svn commit -m "hihi" &&
cd ..
- svn mkdir -m 'new glob at top level' $svnrepo/glob &&
- svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob &&
- git-svn init --minimize-url -i blob $svnrepo/glob/blob &&
+ svn mkdir -m "new glob at top level" "$svnrepo"/glob &&
+ svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob &&
+ git-svn init --minimize-url -i blob "$svnrepo"/glob/blob &&
git-svn fetch -i blob
- "
+ '
-test_expect_success 'follow deleted directory' "
- svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye &&
- svn rm -m 'remove glob' $svnrepo/glob &&
- git-svn init --minimize-url -i glob $svnrepo/glob &&
+test_expect_success 'follow deleted directory' '
+ svn mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
+ svn rm -m "remove glob" "$svnrepo"/glob &&
+ git-svn init --minimize-url -i glob "$svnrepo"/glob &&
git-svn fetch -i glob &&
- test \"\`git cat-file blob refs/remotes/glob:blob/bye\`\" = hi &&
- test \"\`git ls-tree refs/remotes/glob | wc -l \`\" -eq 1
- "
+ test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi &&
+ test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1
+ '
# ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
# in trunk/subversion/bindings/swig/perl
-test_expect_success 'follow-parent avoids deleting relevant info' "
+test_expect_success 'follow-parent avoids deleting relevant info' '
mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
for i in a b c ; do \
- echo \$i > import/trunk/subversion/bindings/swig/perl/\$i.pm &&
- echo _\$i > import/trunk/subversion/bindings/swig/perl/t/\$i.t; \
+ echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
+ echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \
done &&
- echo 'bad delete test' > \
+ echo "bad delete test" > \
import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
- echo 'bad delete test 2' > \
+ echo "bad delete test 2" > \
import/trunk/subversion/bindings/swig/perl/another-larger &&
cd import &&
- svn import -m 'r9270 test' . $svnrepo/r9270 &&
+ svn import -m "r9270 test" . "$svnrepo"/r9270 &&
cd .. &&
- svn co $svnrepo/r9270/trunk/subversion/bindings/swig/perl r9270 &&
+ svn co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
cd r9270 &&
svn mkdir native &&
svn mv t native/t &&
- for i in a b c; do svn mv \$i.pm native/\$i.pm; done &&
+ for i in a b c; do svn mv $i.pm native/$i.pm; done &&
echo z >> native/t/c.t &&
poke native/t/c.t &&
- svn commit -m 'reorg test' &&
+ svn commit -m "reorg test" &&
cd .. &&
git-svn init --minimize-url -i r9270-t \
- $svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t &&
+ "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
git-svn fetch -i r9270-t &&
- test \`git rev-list r9270-t | wc -l\` -eq 2 &&
- test \"\`git ls-tree --name-only r9270-t~1\`\" = \
- \"\`git ls-tree --name-only r9270-t\`\"
- "
+ test `git rev-list r9270-t | wc -l` -eq 2 &&
+ test "`git ls-tree --name-only r9270-t~1`" = \
+ "`git ls-tree --name-only r9270-t`"
+ '
-test_expect_success "track initial change if it was only made to parent" "
- svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk &&
+test_expect_success "track initial change if it was only made to parent" '
+ svn cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
git-svn init --minimize-url -i r9270-d \
- $svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t &&
+ "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
git-svn fetch -i r9270-d &&
- test \`git rev-list r9270-d | wc -l\` -eq 3 &&
- test \"\`git ls-tree --name-only r9270-t\`\" = \
- \"\`git ls-tree --name-only r9270-d\`\" &&
- test \"\`git rev-parse r9270-t\`\" = \
- \"\`git rev-parse r9270-d~1\`\"
- "
+ test `git rev-list r9270-d | wc -l` -eq 3 &&
+ test "`git ls-tree --name-only r9270-t`" = \
+ "`git ls-tree --name-only r9270-d`" &&
+ test "`git rev-parse r9270-t`" = \
+ "`git rev-parse r9270-d~1`"
+ '
-test_expect_success "track multi-parent paths" "
- svn cp -m 'resurrect /glob' $svnrepo/r9270 $svnrepo/glob &&
+test_expect_success "track multi-parent paths" '
+ svn cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
git-svn multi-fetch &&
- test \`git cat-file commit refs/remotes/glob | \
- grep '^parent ' | wc -l\` -eq 2
- "
+ test `git cat-file commit refs/remotes/glob | \
+ grep "^parent " | wc -l` -eq 2
+ '
test_expect_success "multi-fetch continues to work" "
git-svn multi-fetch
"
-test_expect_success "multi-fetch works off a 'clean' repository" "
- rm -r $GIT_DIR/svn $GIT_DIR/refs/remotes $GIT_DIR/logs &&
- mkdir $GIT_DIR/svn &&
+test_expect_success "multi-fetch works off a 'clean' repository" '
+ rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
+ mkdir "$GIT_DIR/svn" &&
git-svn multi-fetch
- "
+ '
test_debug 'gitk --all &'
diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh
index 318e172ef5..63230367bb 100755
--- a/t/t9105-git-svn-commit-diff.sh
+++ b/t/t9105-git-svn-commit-diff.sh
@@ -4,18 +4,18 @@
test_description='git-svn commit-diff'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
echo hello > readme &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
echo hello > readme &&
git update-index --add readme &&
- git commit -a -m 'initial' &&
+ git commit -a -m "initial" &&
echo world >> readme &&
- git commit -a -m 'another'
- "
+ git commit -a -m "another"
+ '
head=`git rev-parse --verify HEAD^0`
prev=`git rev-parse --verify HEAD^1`
@@ -24,20 +24,20 @@ prev=`git rev-parse --verify HEAD^1`
# commit, so only a basic test of functionality is needed since we've
# already tested commit extensively elsewhere
-test_expect_success 'test the commit-diff command' "
- test -n '$prev' && test -n '$head' &&
- git-svn commit-diff -r1 '$prev' '$head' '$svnrepo' &&
- svn co $svnrepo wc &&
+test_expect_success 'test the commit-diff command' '
+ test -n "$prev" && test -n "$head" &&
+ git-svn commit-diff -r1 "$prev" "$head" "$svnrepo" &&
+ svn co "$svnrepo" wc &&
cmp readme wc/readme
- "
+ '
-test_expect_success 'commit-diff to a sub-directory (with git-svn config)' "
- svn import -m 'sub-directory' import $svnrepo/subdir &&
- git-svn init --minimize-url $svnrepo/subdir &&
+test_expect_success 'commit-diff to a sub-directory (with git-svn config)' '
+ svn import -m "sub-directory" import "$svnrepo"/subdir &&
+ git-svn init --minimize-url "$svnrepo"/subdir &&
git-svn fetch &&
- git-svn commit-diff -r3 '$prev' '$head' &&
- svn cat $svnrepo/subdir/readme > readme.2 &&
+ git-svn commit-diff -r3 "$prev" "$head" &&
+ svn cat "$svnrepo"/subdir/readme > readme.2 &&
cmp readme readme.2
- "
+ '
test_done
diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh
index f74ab1269e..58a3a7b1c3 100755
--- a/t/t9106-git-svn-commit-diff-clobber.sh
+++ b/t/t9106-git-svn-commit-diff-clobber.sh
@@ -4,56 +4,56 @@
test_description='git-svn commit-diff clobber'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
echo initial > file &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
echo initial > file &&
git update-index --add file &&
- git commit -a -m 'initial'
- "
-test_expect_success 'commit change from svn side' "
- svn co $svnrepo t.svn &&
+ git commit -a -m "initial"
+ '
+test_expect_success 'commit change from svn side' '
+ svn co "$svnrepo" t.svn &&
cd t.svn &&
echo second line from svn >> file &&
poke file &&
- svn commit -m 'second line from svn' &&
+ svn commit -m "second line from svn" &&
cd .. &&
rm -rf t.svn
- "
+ '
-test_expect_success 'commit conflicting change from git' "
+test_expect_success 'commit conflicting change from git' '
echo second line from git >> file &&
- git commit -a -m 'second line from git' &&
- ! git-svn commit-diff -r1 HEAD~1 HEAD $svnrepo
-"
+ git commit -a -m "second line from git" &&
+ ! git-svn commit-diff -r1 HEAD~1 HEAD "$svnrepo"
+'
-test_expect_success 'commit complementing change from git' "
+test_expect_success 'commit complementing change from git' '
git reset --hard HEAD~1 &&
echo second line from svn >> file &&
- git commit -a -m 'second line from svn' &&
+ git commit -a -m "second line from svn" &&
echo third line from git >> file &&
- git commit -a -m 'third line from git' &&
- git-svn commit-diff -r2 HEAD~1 HEAD $svnrepo
- "
+ git commit -a -m "third line from git" &&
+ git-svn commit-diff -r2 HEAD~1 HEAD "$svnrepo"
+ '
-test_expect_success 'dcommit fails to commit because of conflict' "
- git-svn init $svnrepo &&
+test_expect_success 'dcommit fails to commit because of conflict' '
+ git-svn init "$svnrepo" &&
git-svn fetch &&
git reset --hard refs/remotes/git-svn &&
- svn co $svnrepo t.svn &&
+ svn co "$svnrepo" t.svn &&
cd t.svn &&
echo fourth line from svn >> file &&
poke file &&
- svn commit -m 'fourth line from svn' &&
+ svn commit -m "fourth line from svn" &&
cd .. &&
rm -rf t.svn &&
- echo 'fourth line from git' >> file &&
- git commit -a -m 'fourth line from git' &&
+ echo "fourth line from git" >> file &&
+ git commit -a -m "fourth line from git" &&
! git-svn dcommit
- "
+ '
test_expect_success 'dcommit does the svn equivalent of an index merge' "
git reset --hard refs/remotes/git-svn &&
@@ -66,15 +66,15 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' "
git-svn dcommit
"
-test_expect_success 'commit another change from svn side' "
- svn co $svnrepo t.svn &&
+test_expect_success 'commit another change from svn side' '
+ svn co "$svnrepo" t.svn &&
cd t.svn &&
echo third line from svn >> file &&
poke file &&
- svn commit -m 'third line from svn' &&
+ svn commit -m "third line from svn" &&
cd .. &&
rm -rf t.svn
- "
+ '
test_expect_success 'multiple dcommit from git-svn will not clobber svn' "
git reset --hard refs/remotes/git-svn &&
diff --git a/t/t9106-git-svn-dcommit-clobber-series.sh b/t/t9106-git-svn-dcommit-clobber-series.sh
index ca8a00ed0a..a400dc7966 100755
--- a/t/t9106-git-svn-dcommit-clobber-series.sh
+++ b/t/t9106-git-svn-dcommit-clobber-series.sh
@@ -4,30 +4,30 @@
test_description='git-svn dcommit clobber series'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
- awk 'BEGIN { for (i = 1; i < 64; i++) { print i } }' > file
- svn import -m 'initial' . $svnrepo &&
+ awk "BEGIN { for (i = 1; i < 64; i++) { print i } }" > file
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
- git svn init $svnrepo &&
+ git svn init "$svnrepo" &&
git svn fetch &&
test -e file
- "
+ '
-test_expect_success '(supposedly) non-conflicting change from SVN' "
- test x\"\`sed -n -e 58p < file\`\" = x58 &&
- test x\"\`sed -n -e 61p < file\`\" = x61 &&
- svn co $svnrepo tmp &&
+test_expect_success '(supposedly) non-conflicting change from SVN' '
+ test x"`sed -n -e 58p < file`" = x58 &&
+ test x"`sed -n -e 61p < file`" = x61 &&
+ svn co "$svnrepo" tmp &&
cd tmp &&
- perl -i -p -e 's/^58\$/5588/' file &&
- perl -i -p -e 's/^61\$/6611/' file &&
+ perl -i -p -e "s/^58$/5588/" file &&
+ perl -i -p -e "s/^61$/6611/" file &&
poke file &&
- test x\"\`sed -n -e 58p < file\`\" = x5588 &&
- test x\"\`sed -n -e 61p < file\`\" = x6611 &&
- svn commit -m '58 => 5588, 61 => 6611' &&
+ test x"`sed -n -e 58p < file`" = x5588 &&
+ test x"`sed -n -e 61p < file`" = x6611 &&
+ svn commit -m "58 => 5588, 61 => 6611" &&
cd ..
- "
+ '
test_expect_success 'some unrelated changes to git' "
echo hi > life &&
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
index 0a41d52c7a..d9b553ad55 100755
--- a/t/t9107-git-svn-migrate.sh
+++ b/t/t9107-git-svn-migrate.sh
@@ -3,61 +3,61 @@
test_description='git-svn metadata migrations from previous versions'
. ./lib-git-svn.sh
-test_expect_success 'setup old-looking metadata' "
- cp $GIT_DIR/config $GIT_DIR/config-old-git-svn &&
+test_expect_success 'setup old-looking metadata' '
+ cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn &&
mkdir import &&
cd import &&
for i in trunk branches/a branches/b \
tags/0.1 tags/0.2 tags/0.3; do
- mkdir -p \$i && \
- echo hello >> \$i/README || exit 1
+ mkdir -p $i && \
+ echo hello >> $i/README || exit 1
done && \
- svn import -m test . $svnrepo
+ svn import -m test . "$svnrepo"
cd .. &&
- git-svn init $svnrepo &&
+ git-svn init "$svnrepo" &&
git-svn fetch &&
- mv $GIT_DIR/svn/* $GIT_DIR/ &&
- mv $GIT_DIR/svn/.metadata $GIT_DIR/ &&
- rmdir $GIT_DIR/svn &&
+ mv "$GIT_DIR"/svn/* "$GIT_DIR"/ &&
+ mv "$GIT_DIR"/svn/.metadata "$GIT_DIR"/ &&
+ rmdir "$GIT_DIR"/svn &&
git update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn &&
git update-ref refs/heads/svn-HEAD refs/remotes/git-svn &&
git update-ref -d refs/remotes/git-svn refs/remotes/git-svn
- "
+ '
head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
-test_expect_success 'initialize old-style (v0) git-svn layout' "
- mkdir -p $GIT_DIR/git-svn/info $GIT_DIR/svn/info &&
- echo $svnrepo > $GIT_DIR/git-svn/info/url &&
- echo $svnrepo > $GIT_DIR/svn/info/url &&
+test_expect_success 'initialize old-style (v0) git-svn layout' '
+ mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info &&
+ echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url &&
+ echo "$svnrepo" > "$GIT_DIR"/svn/info/url &&
git-svn migrate &&
- ! test -d $GIT_DIR/git-svn &&
+ ! test -d "$GIT_DIR"/git-svn &&
git rev-parse --verify refs/remotes/git-svn^0 &&
git rev-parse --verify refs/remotes/svn^0 &&
- test \`git config --get svn-remote.svn.url\` = '$svnrepo' &&
- test \`git config --get svn-remote.svn.fetch\` = \
- ':refs/remotes/git-svn'
- "
+ test "$(git config --get svn-remote.svn.url)" = "$svnrepo" &&
+ test `git config --get svn-remote.svn.fetch` = \
+ ":refs/remotes/git-svn"
+ '
-test_expect_success 'initialize a multi-repository repo' "
- git-svn init $svnrepo -T trunk -t tags -b branches &&
+test_expect_success 'initialize a multi-repository repo' '
+ git-svn init "$svnrepo" -T trunk -t tags -b branches &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep '^trunk:refs/remotes/trunk$' fetch.out &&
- test -n \"\`git config --get svn-remote.svn.branches \
- '^branches/\*:refs/remotes/\*$'\`\" &&
- test -n \"\`git config --get svn-remote.svn.tags \
- '^tags/\*:refs/remotes/tags/\*$'\`\" &&
+ grep "^trunk:refs/remotes/trunk$" fetch.out &&
+ test -n "`git config --get svn-remote.svn.branches \
+ "^branches/\*:refs/remotes/\*$"`" &&
+ test -n "`git config --get svn-remote.svn.tags \
+ "^tags/\*:refs/remotes/tags/\*$"`" &&
git config --unset svn-remote.svn.branches \
- '^branches/\*:refs/remotes/\*$' &&
+ "^branches/\*:refs/remotes/\*$" &&
git config --unset svn-remote.svn.tags \
- '^tags/\*:refs/remotes/tags/\*$' &&
- git config --add svn-remote.svn.fetch 'branches/a:refs/remotes/a' &&
- git config --add svn-remote.svn.fetch 'branches/b:refs/remotes/b' &&
+ "^tags/\*:refs/remotes/tags/\*$" &&
+ git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
+ git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
for i in tags/0.1 tags/0.2 tags/0.3; do
git config --add svn-remote.svn.fetch \
- \$i:refs/remotes/\$i || exit 1; done
- "
+ $i:refs/remotes/$i || exit 1; done
+ '
# refs should all be different, but the trees should all be the same:
test_expect_success 'multi-fetch works on partial urls + paths' "
@@ -73,43 +73,43 @@ test_expect_success 'multi-fetch works on partial urls + paths' "
refs/remotes/\$j\`\" ||exit 1; done; done
"
-test_expect_success 'migrate --minimize on old inited layout' "
+test_expect_success 'migrate --minimize on old inited layout' '
git config --unset-all svn-remote.svn.fetch &&
git config --unset-all svn-remote.svn.url &&
- rm -rf $GIT_DIR/svn &&
- for i in \`cat fetch.out\`; do
- path=\`expr \$i : '\\([^:]*\\):.*$'\`
- ref=\`expr \$i : '[^:]*:refs/remotes/\\(.*\\)$'\`
- if test -z \"\$ref\"; then continue; fi
- if test -n \"\$path\"; then path=\"/\$path\"; fi
- ( mkdir -p $GIT_DIR/svn/\$ref/info/ &&
- echo $svnrepo\$path > $GIT_DIR/svn/\$ref/info/url ) || exit 1;
+ rm -rf "$GIT_DIR"/svn &&
+ for i in `cat fetch.out`; do
+ path=`expr $i : "\([^:]*\):.*$"`
+ ref=`expr $i : "[^:]*:refs/remotes/\(.*\)$"`
+ if test -z "$ref"; then continue; fi
+ if test -n "$path"; then path="/$path"; fi
+ ( mkdir -p "$GIT_DIR"/svn/$ref/info/ &&
+ echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1;
done &&
git-svn migrate --minimize &&
- test -z \"\`git config -l |grep -v '^svn-remote\.git-svn\.'\`\" &&
+ test -z "`git config -l |grep -v "^svn-remote\.git-svn\."`" &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep '^trunk:refs/remotes/trunk$' fetch.out &&
- grep '^branches/a:refs/remotes/a$' fetch.out &&
- grep '^branches/b:refs/remotes/b$' fetch.out &&
- grep '^tags/0\.1:refs/remotes/tags/0\.1$' fetch.out &&
- grep '^tags/0\.2:refs/remotes/tags/0\.2$' fetch.out &&
- grep '^tags/0\.3:refs/remotes/tags/0\.3$' fetch.out
- grep '^:refs/remotes/git-svn' fetch.out
- "
+ grep "^trunk:refs/remotes/trunk$" fetch.out &&
+ grep "^branches/a:refs/remotes/a$" fetch.out &&
+ grep "^branches/b:refs/remotes/b$" fetch.out &&
+ grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
+ grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
+ grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out
+ grep "^:refs/remotes/git-svn" fetch.out
+ '
-test_expect_success ".rev_db auto-converted to .rev_map.UUID" "
+test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
git-svn fetch -i trunk &&
- test -z \"\$(ls $GIT_DIR/svn/trunk/.rev_db.* 2>/dev/null)\" &&
- expect=\"\$(ls $GIT_DIR/svn/trunk/.rev_map.*)\" &&
- test -n \"\$expect\" &&
- rev_db=\$(echo \$expect | sed -e 's,_map,_db,') &&
- convert_to_rev_db \$expect \$rev_db &&
- rm -f \$expect &&
- test -f \$rev_db &&
+ test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" &&
+ expect="$(ls "$GIT_DIR"/svn/trunk/.rev_map.*)" &&
+ test -n "$expect" &&
+ rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
+ convert_to_rev_db "$expect" "$rev_db" &&
+ rm -f "$expect" &&
+ test -f "$rev_db" &&
git-svn fetch -i trunk &&
- test -z \"\$(ls $GIT_DIR/svn/trunk/.rev_db.* 2>/dev/null)\" &&
- test ! -e $GIT_DIR/svn/trunk/.rev_db &&
- test -f \$expect
- "
+ test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" &&
+ test ! -e "$GIT_DIR"/svn/trunk/.rev_db &&
+ test -f "$expect"
+ '
test_done
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index db4344cc84..f6f71d0545 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -10,77 +10,77 @@ start a new branch
initial
EOF
-test_expect_success 'test refspec globbing' "
+test_expect_success 'test refspec globbing' '
mkdir -p trunk/src/a trunk/src/b trunk/doc &&
- echo 'hello world' > trunk/src/a/readme &&
- echo 'goodbye world' > trunk/src/b/readme &&
- svn import -m 'initial' trunk $svnrepo/trunk &&
- svn co $svnrepo tmp &&
+ echo "hello world" > trunk/src/a/readme &&
+ echo "goodbye world" > trunk/src/b/readme &&
+ svn import -m "initial" trunk "$svnrepo"/trunk &&
+ svn co "$svnrepo" tmp &&
cd tmp &&
mkdir branches tags &&
svn add branches tags &&
svn cp trunk branches/start &&
- svn commit -m 'start a new branch' &&
+ svn commit -m "start a new branch" &&
svn up &&
- echo 'hi' >> branches/start/src/b/readme &&
+ echo "hi" >> branches/start/src/b/readme &&
poke branches/start/src/b/readme &&
- echo 'hey' >> branches/start/src/a/readme &&
+ echo "hey" >> branches/start/src/a/readme &&
poke branches/start/src/a/readme &&
- svn commit -m 'hi' &&
+ svn commit -m "hi" &&
svn up &&
svn cp branches/start tags/end &&
- echo 'bye' >> tags/end/src/b/readme &&
+ echo "bye" >> tags/end/src/b/readme &&
poke tags/end/src/b/readme &&
- echo 'aye' >> tags/end/src/a/readme &&
+ echo "aye" >> tags/end/src/a/readme &&
poke tags/end/src/a/readme &&
- svn commit -m 'the end' &&
- echo 'byebye' >> tags/end/src/b/readme &&
+ svn commit -m "the end" &&
+ echo "byebye" >> tags/end/src/b/readme &&
poke tags/end/src/b/readme &&
- svn commit -m 'nothing to see here'
+ svn commit -m "nothing to see here"
cd .. &&
- git config --add svn-remote.svn.url $svnrepo &&
+ git config --add svn-remote.svn.url "$svnrepo" &&
git config --add svn-remote.svn.fetch \
- 'trunk/src/a:refs/remotes/trunk' &&
+ "trunk/src/a:refs/remotes/trunk" &&
git config --add svn-remote.svn.branches \
- 'branches/*/src/a:refs/remotes/branches/*' &&
+ "branches/*/src/a:refs/remotes/branches/*" &&
git config --add svn-remote.svn.tags\
- 'tags/*/src/a:refs/remotes/tags/*' &&
+ "tags/*/src/a:refs/remotes/tags/*" &&
git-svn multi-fetch &&
git log --pretty=oneline refs/remotes/tags/end | \
- sed -e 's/^.\{41\}//' > output.end &&
+ sed -e "s/^.\{41\}//" > output.end &&
cmp expect.end output.end &&
- test \"\`git rev-parse refs/remotes/tags/end~1\`\" = \
- \"\`git rev-parse refs/remotes/branches/start\`\" &&
- test \"\`git rev-parse refs/remotes/branches/start~2\`\" = \
- \"\`git rev-parse refs/remotes/trunk\`\"
- "
+ test "`git rev-parse refs/remotes/tags/end~1`" = \
+ "`git rev-parse refs/remotes/branches/start`" &&
+ test "`git rev-parse refs/remotes/branches/start~2`" = \
+ "`git rev-parse refs/remotes/trunk`"
+ '
echo try to try > expect.two
echo nothing to see here >> expect.two
cat expect.end >> expect.two
-test_expect_success 'test left-hand-side only globbing' "
- git config --add svn-remote.two.url $svnrepo &&
+test_expect_success 'test left-hand-side only globbing' '
+ git config --add svn-remote.two.url "$svnrepo" &&
git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
git config --add svn-remote.two.branches \
- 'branches/*:refs/remotes/two/branches/*' &&
+ "branches/*:refs/remotes/two/branches/*" &&
git config --add svn-remote.two.tags \
- 'tags/*:refs/remotes/two/tags/*' &&
+ "tags/*:refs/remotes/two/tags/*" &&
cd tmp &&
- echo 'try try' >> tags/end/src/b/readme &&
+ echo "try try" >> tags/end/src/b/readme &&
poke tags/end/src/b/readme &&
- svn commit -m 'try to try'
+ svn commit -m "try to try"
cd .. &&
git-svn fetch two &&
- test \`git rev-list refs/remotes/two/tags/end | wc -l\` -eq 6 &&
- test \`git rev-list refs/remotes/two/branches/start | wc -l\` -eq 3 &&
- test \`git rev-parse refs/remotes/two/branches/start~2\` = \
- \`git rev-parse refs/remotes/two/trunk\` &&
- test \`git rev-parse refs/remotes/two/tags/end~3\` = \
- \`git rev-parse refs/remotes/two/branches/start\` &&
+ test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
+ test `git rev-list refs/remotes/two/branches/start | wc -l` -eq 3 &&
+ test `git rev-parse refs/remotes/two/branches/start~2` = \
+ `git rev-parse refs/remotes/two/trunk` &&
+ test `git rev-parse refs/remotes/two/tags/end~3` = \
+ `git rev-parse refs/remotes/two/branches/start` &&
git log --pretty=oneline refs/remotes/two/tags/end | \
- sed -e 's/^.\{41\}//' > output.two &&
+ sed -e "s/^.\{41\}//" > output.two &&
cmp expect.two output.two
- "
+ '
test_done
diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh
index 6235af4db8..047659fde1 100755
--- a/t/t9110-git-svn-use-svm-props.sh
+++ b/t/t9110-git-svn-use-svm-props.sh
@@ -7,15 +7,15 @@ test_description='git-svn useSvmProps test'
. ./lib-git-svn.sh
-test_expect_success 'load svm repo' "
- svnadmin load -q $rawsvnrepo < ../t9110/svm.dump &&
- git-svn init --minimize-url -R arr -i bar $svnrepo/mirror/arr &&
- git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh &&
+test_expect_success 'load svm repo' '
+ svnadmin load -q "$rawsvnrepo" < ../t9110/svm.dump &&
+ git-svn init --minimize-url -R arr -i bar "$svnrepo"/mirror/arr &&
+ git-svn init --minimize-url -R argh -i dir "$svnrepo"/mirror/argh &&
git-svn init --minimize-url -R argh -i e \
- $svnrepo/mirror/argh/a/b/c/d/e &&
+ "$svnrepo"/mirror/argh/a/b/c/d/e &&
git config svn.useSvmProps true &&
git-svn fetch --all
- "
+ '
uuid=161ce429-a9dd-4828-af4a-52023f968c89
diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh
index ec7dedd48b..a8d74dcd3a 100755
--- a/t/t9111-git-svn-use-svnsync-props.sh
+++ b/t/t9111-git-svn-use-svnsync-props.sh
@@ -7,14 +7,14 @@ test_description='git-svn useSvnsyncProps test'
. ./lib-git-svn.sh
-test_expect_success 'load svnsync repo' "
- svnadmin load -q $rawsvnrepo < ../t9111/svnsync.dump &&
- git-svn init --minimize-url -R arr -i bar $svnrepo/bar &&
- git-svn init --minimize-url -R argh -i dir $svnrepo/dir &&
- git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e &&
+test_expect_success 'load svnsync repo' '
+ svnadmin load -q "$rawsvnrepo" < ../t9111/svnsync.dump &&
+ git-svn init --minimize-url -R arr -i bar "$svnrepo"/bar &&
+ git-svn init --minimize-url -R argh -i dir "$svnrepo"/dir &&
+ git-svn init --minimize-url -R argh -i e "$svnrepo"/dir/a/b/c/d/e &&
git config svn.useSvnsyncProps true &&
git-svn fetch --all
- "
+ '
uuid=161ce429-a9dd-4828-af4a-52023f968c89
diff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh
index 646a5f0cdb..d470a920e4 100755
--- a/t/t9112-git-svn-md5less-file.sh
+++ b/t/t9112-git-svn-md5less-file.sh
@@ -40,8 +40,8 @@ PROPS-END
EOF
-test_expect_success 'load svn dumpfile' "svnadmin load $rawsvnrepo < dumpfile.svn"
+test_expect_success 'load svn dumpfile' 'svnadmin load "$rawsvnrepo" < dumpfile.svn'
-test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
+test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"'
test_expect_success 'fetch revisions from svn' 'git-svn fetch'
test_done
diff --git a/t/t9113-git-svn-dcommit-new-file.sh b/t/t9113-git-svn-dcommit-new-file.sh
index 9ef0db9044..31c929b573 100755
--- a/t/t9113-git-svn-dcommit-new-file.sh
+++ b/t/t9113-git-svn-dcommit-new-file.sh
@@ -15,18 +15,18 @@ test_description='git-svn dcommit new files over svn:// test'
start_svnserve () {
svnserve --listen-port $SVNSERVE_PORT \
- --root $rawsvnrepo \
+ --root "$rawsvnrepo" \
--listen-once \
--listen-host 127.0.0.1 &
}
-test_expect_success 'start tracking an empty repo' "
- svn mkdir -m 'empty dir' $svnrepo/empty-dir &&
- echo anon-access = write >> $rawsvnrepo/conf/svnserve.conf &&
+test_expect_success 'start tracking an empty repo' '
+ svn mkdir -m "empty dir" "$svnrepo"/empty-dir &&
+ echo anon-access = write >> "$rawsvnrepo"/conf/svnserve.conf &&
start_svnserve &&
git svn init svn://127.0.0.1:$SVNSERVE_PORT &&
git svn fetch
- "
+ '
test_expect_success 'create files in new directory with dcommit' "
mkdir git-new-dir &&
diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh
index 225060b88b..61d7781616 100755
--- a/t/t9114-git-svn-dcommit-merge.sh
+++ b/t/t9114-git-svn-dcommit-merge.sh
@@ -34,35 +34,35 @@ cat << EOF
EOF
}
-test_expect_success 'setup svn repository' "
- svn co $svnrepo mysvnwork &&
+test_expect_success 'setup svn repository' '
+ svn co "$svnrepo" mysvnwork &&
mkdir -p mysvnwork/trunk &&
cd mysvnwork &&
big_text_block >> trunk/README &&
svn add trunk &&
- svn ci -m 'first commit' trunk &&
+ svn ci -m "first commit" trunk &&
cd ..
- "
+ '
-test_expect_success 'setup git mirror and merge' "
- git svn init $svnrepo -t tags -T trunk -b branches &&
+test_expect_success 'setup git mirror and merge' '
+ git svn init "$svnrepo" -t tags -T trunk -b branches &&
git svn fetch &&
git checkout --track -b svn remotes/trunk &&
git checkout -b merge &&
echo new file > new_file &&
git add new_file &&
- git commit -a -m 'New file' &&
+ git commit -a -m "New file" &&
echo hello >> README &&
- git commit -a -m 'hello' &&
+ git commit -a -m "hello" &&
echo add some stuff >> new_file &&
- git commit -a -m 'add some stuff' &&
+ git commit -a -m "add some stuff" &&
git checkout svn &&
mv -f README tmp &&
echo friend > README &&
cat tmp >> README &&
- git commit -a -m 'friend' &&
+ git commit -a -m "friend" &&
git pull . merge
- "
+ '
test_debug 'gitk --all & sleep 1'
diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh
index 182299cbb5..f0fbd3aff7 100755
--- a/t/t9115-git-svn-dcommit-funky-renames.sh
+++ b/t/t9115-git-svn-dcommit-funky-renames.sh
@@ -7,16 +7,16 @@ test_description='git-svn dcommit can commit renames of files with ugly names'
. ./lib-git-svn.sh
-test_expect_success 'load repository with strange names' "
- svnadmin load -q $rawsvnrepo < ../t9115/funky-names.dump &&
- start_httpd
- "
+test_expect_success 'load repository with strange names' '
+ svnadmin load -q "$rawsvnrepo" < ../t9115/funky-names.dump &&
+ start_httpd gtk+
+ '
-test_expect_success 'init and fetch repository' "
- git svn init $svnrepo &&
+test_expect_success 'init and fetch repository' '
+ git svn init "$svnrepo" &&
git svn fetch &&
git reset --hard git-svn
- "
+ '
test_expect_success 'create file in existing ugly and empty dir' '
mkdir "#{bad_directory_name}" &&
@@ -49,6 +49,39 @@ test_expect_success 'rename pretty file into ugly one' '
git svn dcommit
'
+test_expect_success 'add a file with plus signs' '
+ echo .. > +_+ &&
+ git update-index --add +_+ &&
+ git commit -m plus &&
+ mkdir gtk+ &&
+ git mv +_+ gtk+/_+_ &&
+ git commit -m plus_dir &&
+ git svn dcommit
+ '
+
+test_expect_success 'clone the repository to test rebase' '
+ git svn clone "$svnrepo" test-rebase &&
+ cd test-rebase &&
+ echo test-rebase > test-rebase &&
+ git add test-rebase &&
+ git commit -m test-rebase &&
+ cd ..
+ '
+
+test_expect_success 'make a commit to test rebase' '
+ echo test-rebase-main > test-rebase-main &&
+ git add test-rebase-main &&
+ git commit -m test-rebase-main &&
+ git svn dcommit
+ '
+
+test_expect_success 'git-svn rebase works inside a fresh-cloned repository' '
+ cd test-rebase &&
+ git svn rebase &&
+ test -e test-rebase-main &&
+ test -e test-rebase
+ '
+
stop_httpd
test_done
diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
index e1e8bdf0e3..4b2cc878f6 100755
--- a/t/t9116-git-svn-log.sh
+++ b/t/t9116-git-svn-log.sh
@@ -6,17 +6,17 @@
test_description='git-svn log tests'
. ./lib-git-svn.sh
-test_expect_success 'setup repository and import' "
+test_expect_success 'setup repository and import' '
mkdir import &&
cd import &&
for i in trunk branches/a branches/b \
tags/0.1 tags/0.2 tags/0.3; do
- mkdir -p \$i && \
- echo hello >> \$i/README || exit 1
+ mkdir -p $i && \
+ echo hello >> $i/README || exit 1
done && \
- svn import -m test . $svnrepo
+ svn import -m test . "$svnrepo"
cd .. &&
- git-svn init $svnrepo -T trunk -b branches -t tags &&
+ git-svn init "$svnrepo" -T trunk -b branches -t tags &&
git-svn fetch &&
git reset --hard trunk &&
echo bye >> README &&
@@ -37,7 +37,7 @@ test_expect_success 'setup repository and import' "
echo try >> README &&
git commit -a -m try &&
git svn dcommit
- "
+ '
test_expect_success 'run log' "
git reset --hard a &&
diff --git a/t/t9117-git-svn-init-clone.sh b/t/t9117-git-svn-init-clone.sh
index d482b407f2..7a689bb1cd 100755
--- a/t/t9117-git-svn-init-clone.sh
+++ b/t/t9117-git-svn-init-clone.sh
@@ -13,43 +13,43 @@ rm -r .git
mkdir tmp
cd tmp
-test_expect_success 'setup svnrepo' "
+test_expect_success 'setup svnrepo' '
mkdir project project/trunk project/branches project/tags &&
echo foo > project/trunk/foo &&
- svn import -m '$test_description' project $svnrepo/project &&
+ svn import -m "$test_description" project "$svnrepo"/project &&
rm -rf project
- "
+ '
-test_expect_success 'basic clone' "
+test_expect_success 'basic clone' '
test ! -d trunk &&
- git svn clone $svnrepo/project/trunk &&
+ git svn clone "$svnrepo"/project/trunk &&
test -d trunk/.git/svn &&
test -e trunk/foo &&
rm -rf trunk
- "
+ '
-test_expect_success 'clone to target directory' "
+test_expect_success 'clone to target directory' '
test ! -d target &&
- git svn clone $svnrepo/project/trunk target &&
+ git svn clone "$svnrepo"/project/trunk target &&
test -d target/.git/svn &&
test -e target/foo &&
rm -rf target
- "
+ '
-test_expect_success 'clone with --stdlayout' "
+test_expect_success 'clone with --stdlayout' '
test ! -d project &&
- git svn clone -s $svnrepo/project &&
+ git svn clone -s "$svnrepo"/project &&
test -d project/.git/svn &&
test -e project/foo &&
rm -rf project
- "
+ '
-test_expect_success 'clone to target directory with --stdlayout' "
+test_expect_success 'clone to target directory with --stdlayout' '
test ! -d target &&
- git svn clone -s $svnrepo/project target &&
+ git svn clone -s "$svnrepo"/project target &&
test -d target/.git/svn &&
test -e target/foo &&
rm -rf target
- "
+ '
test_done
diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
index 640bb066f3..3281cbd347 100755
--- a/t/t9118-git-svn-funky-branch-names.sh
+++ b/t/t9118-git-svn-funky-branch-names.sh
@@ -6,25 +6,25 @@
test_description='git-svn funky branch names'
. ./lib-git-svn.sh
-test_expect_success 'setup svnrepo' "
+test_expect_success 'setup svnrepo' '
mkdir project project/trunk project/branches project/tags &&
echo foo > project/trunk/foo &&
- svn import -m '$test_description' project \"$svnrepo/pr ject\" &&
+ svn import -m "$test_description" project "$svnrepo/pr ject" &&
rm -rf project &&
- svn cp -m 'fun' \"$svnrepo/pr ject/trunk\" \
- \"$svnrepo/pr ject/branches/fun plugin\" &&
- svn cp -m 'more fun!' \"$svnrepo/pr ject/branches/fun plugin\" \
- \"$svnrepo/pr ject/branches/more fun plugin!\" &&
+ svn cp -m "fun" "$svnrepo/pr ject/trunk" \
+ "$svnrepo/pr ject/branches/fun plugin" &&
+ svn cp -m "more fun!" "$svnrepo/pr ject/branches/fun plugin" \
+ "$svnrepo/pr ject/branches/more fun plugin!" &&
start_httpd
- "
+ '
-test_expect_success 'test clone with funky branch names' "
- git svn clone -s \"$svnrepo/pr ject\" project &&
+test_expect_success 'test clone with funky branch names' '
+ git svn clone -s "$svnrepo/pr ject" project &&
cd project &&
- git rev-parse 'refs/remotes/fun%20plugin' &&
- git rev-parse 'refs/remotes/more%20fun%20plugin!' &&
+ git rev-parse "refs/remotes/fun%20plugin" &&
+ git rev-parse "refs/remotes/more%20fun%20plugin!" &&
cd ..
- "
+ '
test_expect_success 'test dcommit to funky branch' "
cd project &&
diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh
index 9a4eabe523..5979e133b9 100755
--- a/t/t9120-git-svn-clone-with-percent-escapes.sh
+++ b/t/t9120-git-svn-clone-with-percent-escapes.sh
@@ -6,13 +6,13 @@
test_description='git-svn clone with percent escapes'
. ./lib-git-svn.sh
-test_expect_success 'setup svnrepo' "
+test_expect_success 'setup svnrepo' '
mkdir project project/trunk project/branches project/tags &&
echo foo > project/trunk/foo &&
- svn import -m '$test_description' project '$svnrepo/pr ject' &&
+ svn import -m "$test_description" project "$svnrepo/pr ject" &&
rm -rf project &&
start_httpd
-"
+'
if test "$SVN_HTTPD_PORT" = ""
then
diff --git a/t/t9121-git-svn-fetch-renamed-dir.sh b/t/t9121-git-svn-fetch-renamed-dir.sh
index 5143ed6066..99230b0810 100755
--- a/t/t9121-git-svn-fetch-renamed-dir.sh
+++ b/t/t9121-git-svn-fetch-renamed-dir.sh
@@ -7,14 +7,14 @@ test_description='git-svn can fetch renamed directories'
. ./lib-git-svn.sh
-test_expect_success 'load repository with renamed directory' "
- svnadmin load -q $rawsvnrepo < ../t9121/renamed-dir.dump
- "
+test_expect_success 'load repository with renamed directory' '
+ svnadmin load -q "$rawsvnrepo" < ../t9121/renamed-dir.dump
+ '
-test_expect_success 'init and fetch repository' "
- git svn init $svnrepo/newname &&
+test_expect_success 'init and fetch repository' '
+ git svn init "$svnrepo/newname" &&
git svn fetch
- "
+ '
test_done
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 166b43f783..e97aaa6c2a 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -153,21 +153,21 @@ test_expect_success 'req_Root failure (conflicting roots)' \
tail log | grep "^error 1 Conflicting roots specified$"'
test_expect_success 'req_Root (strict paths)' \
- 'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 &&
+ 'cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (strict-paths)' '
! cat request-anonymous |
- git-cvsserver --strict-paths pserver $WORKDIR >log 2>&1
+ git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
'
test_expect_success 'req_Root (w/o strict-paths)' \
- 'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 &&
+ 'cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (w/o strict-paths)' '
! cat request-anonymous |
- git-cvsserver pserver $WORKDIR/gitcvs >log 2>&1
+ git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
'
cat >request-base <<EOF
@@ -180,25 +180,25 @@ Root /gitcvs.git
EOF
test_expect_success 'req_Root (base-path)' \
- 'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
+ 'cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (base-path)' '
! cat request-anonymous |
- git-cvsserver --strict-paths --base-path $WORKDIR pserver $SERVERDIR >log 2>&1
+ git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
test_expect_success 'req_Root (export-all)' \
- 'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
+ 'cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (export-all w/o whitelist)' \
'! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
test_expect_success 'req_Root (everything together)' \
- 'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
+ 'cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
sed -ne \$p log | grep "^I LOVE YOU$"'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 061a2596d3..ae7082be1d 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -10,6 +10,7 @@ commandline, and checks that it would not write any errors
or warnings to log.'
gitweb_init () {
+ safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')"
cat >gitweb_config.perl <<EOF
#!/usr/bin/perl
@@ -17,16 +18,16 @@ gitweb_init () {
our \$version = "current";
our \$GIT = "git";
-our \$projectroot = "$(pwd)";
+our \$projectroot = "$safe_pwd";
our \$project_maxdepth = 8;
our \$home_link_str = "projects";
our \$site_name = "[localhost]";
our \$site_header = "";
our \$site_footer = "";
our \$home_text = "indextext.html";
-our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css");
-our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png";
-our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png";
+our @stylesheets = ("file:///$safe_pwd/../../gitweb/gitweb.css");
+our \$logo = "file:///$safe_pwd/../../gitweb/git-logo.png";
+our \$favicon = "file:///$safe_pwd/../../gitweb/git-favicon.png";
our \$projects_list = "";
our \$export_ok = "";
our \$strict_export = "";
@@ -39,19 +40,21 @@ EOF
}
gitweb_run () {
- export GATEWAY_INTERFACE="CGI/1.1"
- export HTTP_ACCEPT="*/*"
- export REQUEST_METHOD="GET"
- export QUERY_STRING=""$1""
- export PATH_INFO=""$2""
+ GATEWAY_INTERFACE="CGI/1.1"
+ HTTP_ACCEPT="*/*"
+ REQUEST_METHOD="GET"
+ QUERY_STRING=""$1""
+ PATH_INFO=""$2""
+ export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD QUERY_STRING PATH_INFO
- export GITWEB_CONFIG=$(pwd)/gitweb_config.perl
+ GITWEB_CONFIG=$(pwd)/gitweb_config.perl
+ export GITWEB_CONFIG
# some of git commands write to STDERR on error, but this is not
# written to web server logs, so we are not interested in that:
# we are interested only in properly formatted errors/warnings
rm -f gitweb.log &&
- perl -- $(pwd)/../../gitweb/gitweb.perl \
+ perl -- "$(pwd)/../../gitweb/gitweb.perl" \
>/dev/null 2>gitweb.log &&
if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 00a74ee738..0b115a17ab 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -36,7 +36,7 @@ test_expect_success 'setup cvsroot' 'cvs init'
test_expect_success 'setup a cvs module' '
- mkdir $CVSROOT/module &&
+ mkdir "$CVSROOT/module" &&
cvs co -d module-cvs module &&
cd module-cvs &&
cat <<EOF >o_fortuna &&
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7c2a8ba77d..5002fb04b5 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -160,6 +160,22 @@ die () {
trap 'die' exit
+# The semantics of the editor variables are that of invoking
+# sh -c "$EDITOR \"$@\"" files ...
+#
+# If our trash directory contains shell metacharacters, they will be
+# interpreted if we just set $EDITOR directly, so do a little dance with
+# environment variables to work around this.
+#
+# In particular, quoting isn't enough, as the path may contain the same quote
+# that we're using.
+test_set_editor () {
+ FAKE_EDITOR="$1"
+ export FAKE_EDITOR
+ VISUAL='"$FAKE_EDITOR"'
+ export VISUAL
+}
+
test_tick () {
if test -z "${test_tick+set}"
then
@@ -329,7 +345,7 @@ test_create_repo () {
repo="$1"
mkdir "$repo"
cd "$repo" || error "Cannot setup test environment"
- "$GIT_EXEC_PATH/git" init --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 ||
+ "$GIT_EXEC_PATH/git" init "--template=$GIT_EXEC_PATH/templates/blt/" >/dev/null 2>&1 ||
error "cannot run git init -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
cd "$owd"
@@ -395,14 +411,14 @@ fi
. ../GIT-BUILD-OPTIONS
# Test repository
-test=trash
+test="trash directory"
rm -fr "$test" || {
trap - exit
echo >&5 "FATAL: Cannot prepare test area"
exit 1
}
-test_create_repo $test
+test_create_repo "$test"
cd "$test"
this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
diff --git a/transport.c b/transport.c
index 393e0e8fe2..1bc16f2b65 100644
--- a/transport.c
+++ b/transport.c
@@ -441,10 +441,14 @@ static struct ref *get_refs_via_curl(struct transport *transport)
struct ref *ref = NULL;
struct ref *last_ref = NULL;
+ struct walker *walker;
+
if (!transport->data)
transport->data = get_http_walker(transport->url,
transport->remote);
+ walker = transport->data;
+
refs_url = xmalloc(strlen(transport->url) + 11);
sprintf(refs_url, "%s/info/refs", transport->url);
@@ -500,6 +504,15 @@ static struct ref *get_refs_via_curl(struct transport *transport)
strbuf_release(&buffer);
+ ref = alloc_ref_from_str("HEAD");
+ if (!walker->fetch_ref(walker, ref) &&
+ !resolve_remote_symref(ref, refs)) {
+ ref->next = refs;
+ refs = ref;
+ } else {
+ free(ref);
+ }
+
return refs;
}
@@ -532,9 +545,8 @@ static struct ref *get_refs_from_bundle(struct transport *transport)
die ("Could not read bundle '%s'.", transport->url);
for (i = 0; i < data->header.references.nr; i++) {
struct ref_list_entry *e = data->header.references.list + i;
- struct ref *ref = alloc_ref(strlen(e->name) + 1);
+ struct ref *ref = alloc_ref_from_str(e->name);
hashcpy(ref->old_sha1, e->sha1);
- strcpy(ref->name, e->name);
ref->next = result;
result = ref;
}
diff --git a/unpack-trees.c b/unpack-trees.c
index a59f47557a..1ab28fda45 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -26,11 +26,12 @@ static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
* directories, in case this unlink is the removal of the
* last entry in the directory -- empty directories are removed.
*/
-static void unlink_entry(char *name, char *last_symlink)
+static void unlink_entry(struct cache_entry *ce)
{
char *cp, *prev;
+ char *name = ce->name;
- if (has_symlink_leading_path(name, last_symlink))
+ if (has_symlink_leading_path(ce_namelen(ce), ce->name))
return;
if (unlink(name))
return;
@@ -58,7 +59,6 @@ static int check_updates(struct unpack_trees_options *o)
{
unsigned cnt = 0, total = 0;
struct progress *progress = NULL;
- char last_symlink[PATH_MAX];
struct index_state *index = &o->result;
int i;
int errs = 0;
@@ -75,24 +75,27 @@ static int check_updates(struct unpack_trees_options *o)
cnt = 0;
}
- *last_symlink = '\0';
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
- if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
- display_progress(progress, ++cnt);
if (ce->ce_flags & CE_REMOVE) {
+ display_progress(progress, ++cnt);
if (o->update)
- unlink_entry(ce->name, last_symlink);
+ unlink_entry(ce);
remove_index_entry_at(&o->result, i);
i--;
continue;
}
+ }
+
+ for (i = 0; i < index->cache_nr; i++) {
+ struct cache_entry *ce = index->cache[i];
+
if (ce->ce_flags & CE_UPDATE) {
+ display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
if (o->update) {
errs |= checkout_entry(ce, &state, NULL);
- *last_symlink = '\0';
}
}
}
@@ -521,6 +524,22 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
}
/*
+ * This gets called when there was no index entry for the tree entry 'dst',
+ * but we found a file in the working tree that 'lstat()' said was fine,
+ * and we're on a case-insensitive filesystem.
+ *
+ * See if we can find a case-insensitive match in the index that also
+ * matches the stat information, and assume it's that other file!
+ */
+static int icase_exists(struct unpack_trees_options *o, struct cache_entry *dst, struct stat *st)
+{
+ struct cache_entry *src;
+
+ src = index_name_exists(o->src_index, dst->name, ce_namelen(dst), 1);
+ return src && !ie_match_stat(o->src_index, src, st, CE_MATCH_IGNORE_VALID);
+}
+
+/*
* We do not want to remove or overwrite a working tree file that
* is not tracked, unless it is ignored.
*/
@@ -532,12 +551,23 @@ static int verify_absent(struct cache_entry *ce, const char *action,
if (o->index_only || o->reset || !o->update)
return 0;
- if (has_symlink_leading_path(ce->name, NULL))
+ if (has_symlink_leading_path(ce_namelen(ce), ce->name))
return 0;
if (!lstat(ce->name, &st)) {
int cnt;
int dtype = ce_to_dtype(ce);
+ struct cache_entry *result;
+
+ /*
+ * It may be that the 'lstat()' succeeded even though
+ * target 'ce' was absent, because there is an old
+ * entry that is different only in case..
+ *
+ * Ignore that lstat() if it matches.
+ */
+ if (ignore_case && icase_exists(o, ce, &st))
+ return 0;
if (o->dir && excluded(o->dir, ce->name, &dtype))
/*
@@ -581,10 +611,9 @@ static int verify_absent(struct cache_entry *ce, const char *action,
* delete this path, which is in a subdirectory that
* is being replaced with a blob.
*/
- cnt = index_name_pos(&o->result, ce->name, strlen(ce->name));
- if (0 <= cnt) {
- struct cache_entry *ce = o->result.cache[cnt];
- if (ce->ce_flags & CE_REMOVE)
+ result = index_name_exists(&o->result, ce->name, ce_namelen(ce), 0);
+ if (result) {
+ if (result->ce_flags & CE_REMOVE)
return 0;
}
diff --git a/unpack-trees.h b/unpack-trees.h
index 50453ed20f..d436d6ced9 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -9,16 +9,16 @@ typedef int (*merge_fn_t)(struct cache_entry **src,
struct unpack_trees_options *options);
struct unpack_trees_options {
- int reset;
- int merge;
- int update;
- int index_only;
- int nontrivial_merge;
- int trivial_merges_only;
- int verbose_update;
- int aggressive;
- int skip_unmerged;
- int gently;
+ unsigned int reset:1,
+ merge:1,
+ update:1,
+ index_only:1,
+ nontrivial_merge:1,
+ trivial_merges_only:1,
+ verbose_update:1,
+ aggressive:1,
+ skip_unmerged:1,
+ gently:1;
const char *prefix;
int pos;
struct dir_struct *dir;
@@ -31,7 +31,7 @@ struct unpack_trees_options {
void *unpack_data;
struct index_state *dst_index;
- const struct index_state *src_index;
+ struct index_state *src_index;
struct index_state result;
};
diff --git a/var.c b/var.c
index 0de0efa2aa..c20ac919bd 100644
--- a/var.c
+++ b/var.c
@@ -51,11 +51,12 @@ static int show_config(const char *var, const char *value)
int main(int argc, char **argv)
{
const char *val;
+ int nongit;
if (argc != 2) {
usage(var_usage);
}
- setup_git_directory();
+ setup_git_directory_gently(&nongit);
val = NULL;
if (strcmp(argv[1], "-l") == 0) {
diff --git a/walker.c b/walker.c
index c10eca8826..31de6c16bd 100644
--- a/walker.c
+++ b/walker.c
@@ -190,9 +190,13 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
if (!get_sha1_hex(target, sha1))
return 0;
if (!check_ref_format(target)) {
- if (!walker->fetch_ref(walker, target, sha1)) {
+ struct ref *ref = alloc_ref_from_str(target);
+ if (!walker->fetch_ref(walker, ref)) {
+ hashcpy(sha1, ref->old_sha1);
+ free(ref);
return 0;
}
+ free(ref);
}
return -1;
}
diff --git a/walker.h b/walker.h
index e1d40deaff..8a149e1108 100644
--- a/walker.h
+++ b/walker.h
@@ -5,7 +5,7 @@
struct walker {
void *data;
- int (*fetch_ref)(struct walker *, char *ref, unsigned char *sha1);
+ int (*fetch_ref)(struct walker *, struct ref *ref);
void (*prefetch)(struct walker *, unsigned char *sha1);
int (*fetch)(struct walker *, unsigned char *sha1);
void (*cleanup)(struct walker *);
diff --git a/write_or_die.c b/write_or_die.c
index e125e11d3b..32f9914020 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -40,7 +40,7 @@ void maybe_flush_or_die(FILE *f, const char *desc)
}
}
-int read_in_full(int fd, void *buf, size_t count)
+ssize_t read_in_full(int fd, void *buf, size_t count)
{
char *p = buf;
ssize_t total = 0;
@@ -57,7 +57,7 @@ int read_in_full(int fd, void *buf, size_t count)
return total;
}
-int write_in_full(int fd, const void *buf, size_t count)
+ssize_t write_in_full(int fd, const void *buf, size_t count)
{
const char *p = buf;
ssize_t total = 0;
diff --git a/wt-status.c b/wt-status.c
index b3fd57b79d..a44c543375 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -8,9 +8,11 @@
#include "revision.h"
#include "diffcore.h"
#include "quote.h"
+#include "run-command.h"
int wt_status_relative_paths = 1;
int wt_status_use_color = -1;
+int wt_status_submodule_summary;
static char wt_status_colors[][COLOR_MAXLEN] = {
"", /* WT_STATUS_HEADER: normal */
"\033[32m", /* WT_STATUS_UPDATED: green */
@@ -204,7 +206,7 @@ static void wt_status_print_updated(struct wt_status *s)
rev.diffopt.format_callback = wt_status_print_updated_cb;
rev.diffopt.format_callback_data = s;
rev.diffopt.detect_rename = 1;
- rev.diffopt.rename_limit = 100;
+ rev.diffopt.rename_limit = 200;
rev.diffopt.break_opt = 0;
run_diff_index(&rev, 1);
}
@@ -220,6 +222,36 @@ static void wt_status_print_changed(struct wt_status *s)
run_diff_files(&rev, 0);
}
+static void wt_status_print_submodule_summary(struct wt_status *s)
+{
+ struct child_process sm_summary;
+ char summary_limit[64];
+ char index[PATH_MAX];
+ const char *env[] = { index, NULL };
+ const char *argv[] = {
+ "submodule",
+ "summary",
+ "--cached",
+ "--for-status",
+ "--summary-limit",
+ summary_limit,
+ s->amend ? "HEAD^" : "HEAD",
+ NULL
+ };
+
+ sprintf(summary_limit, "%d", wt_status_submodule_summary);
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
+
+ memset(&sm_summary, 0, sizeof(sm_summary));
+ sm_summary.argv = argv;
+ sm_summary.env = env;
+ sm_summary.git_cmd = 1;
+ sm_summary.no_stdin = 1;
+ fflush(s->fp);
+ sm_summary.out = dup(fileno(s->fp)); /* run_command closes it */
+ run_command(&sm_summary);
+}
+
static void wt_status_print_untracked(struct wt_status *s)
{
struct dir_struct dir;
@@ -308,6 +340,8 @@ void wt_status_print(struct wt_status *s)
}
wt_status_print_changed(s);
+ if (wt_status_submodule_summary)
+ wt_status_print_submodule_summary(s);
wt_status_print_untracked(s);
if (s->verbose && !s->is_initial)
@@ -330,6 +364,13 @@ void wt_status_print(struct wt_status *s)
int git_status_config(const char *k, const char *v)
{
+ if (!strcmp(k, "status.submodulesummary")) {
+ int is_bool;
+ wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
+ if (is_bool && wt_status_submodule_summary)
+ wt_status_submodule_summary = -1;
+ return 0;
+ }
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
wt_status_use_color = git_config_colorbool(k, v, -1);
return 0;