Merge branch 'master' of git://repo.or.cz/alt-git.git

This commit is contained in:
Johannes Sixt
2008-06-04 20:30:07 +02:00
146 changed files with 1829 additions and 1190 deletions

View File

@@ -4,7 +4,7 @@ MAN1_TXT= \
gitk.txt
MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt
MAN7_TXT=git.txt gitcli.txt gittutorial.txt gittutorial-2.txt \
gitcvs-migration.txt
gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt
MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
@@ -12,13 +12,11 @@ MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
DOC_HTML=$(MAN_HTML)
ARTICLES = core-tutorial
ARTICLES += diffcore
ARTICLES = diffcore
ARTICLES += howto-index
ARTICLES += repository-layout
ARTICLES += everyday
ARTICLES += git-tools
ARTICLES += glossary
# with their own formatting rules.
SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual
API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))

View File

@@ -0,0 +1,12 @@
GIT v1.5.5.3 Release Notes
==========================
Fixes since v1.5.5.2
--------------------
* "git send-email --compose" did not notice that non-ascii contents
needed some MIME magic.
* "git fast-export" did not export octopus merges correctly.
Also comes with various documentation updates.

View File

@@ -62,6 +62,8 @@ Updates since v1.5.5
changes (i.e. cannot be used to propagate the whole changes) meant only
for reviewing.
* "git init --bare" is a synonym for "git --bare init" now.
* "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,
@@ -84,6 +86,8 @@ Updates since v1.5.5
* "git svn" learned --add-author-from option to propagate the authorship
by munging the commit log message.
* new object creation and looking up in "git svn" has been optimized.
* "gitweb" can read from a system-wide configuration file.
(internal)
@@ -101,6 +105,6 @@ this release, unless otherwise noted.
--
exec >/var/tmp/1
O=v1.5.6-rc0
O=v1.5.6-rc1
echo O=`git describe refs/heads/master`
git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint

View File

@@ -205,10 +205,13 @@ Can be overridden by the 'GIT_PROXY_COMMAND' environment variable
handling).
core.ignoreStat::
The working copy files are assumed to stay unchanged until you
mark them otherwise manually - Git will not detect the file changes
by lstat() calls. This is useful on systems where those are very
slow, such as Microsoft Windows. See linkgit:git-update-index[1].
If true, commands which modify both the working tree and the index
will mark the updated paths with the "assume unchanged" bit in the
index. These marked files are then assumed to stay unchanged in the
working copy, until you mark them otherwise manually - Git will not
detect the file changes by lstat() calls. This is useful on systems
where those are very slow, such as Microsoft Windows.
See linkgit:git-update-index[1].
False by default.
core.preferSymlinkRefs::

View File

@@ -246,7 +246,7 @@ characters that need C-quoting. `core.quotepath` configuration can be
used to work this limitation around to some degree, but backslash,
double-quote and control characters will still have problems.
See Also
SEE ALSO
--------
linkgit:git-status[1]
linkgit:git-rm[1]

View File

@@ -9,7 +9,7 @@ git-bundle - Move objects and refs by archive
SYNOPSIS
--------
[verse]
'git-bundle' create <file> [git-rev-list args]
'git-bundle' create <file> <git-rev-list args>
'git-bundle' verify <file>
'git-bundle' list-heads <file> [refname...]
'git-bundle' unbundle <file> [refname...]

View File

@@ -13,6 +13,8 @@ DESCRIPTION
-----------
The changeset (or "diff") of each commit between the fork-point and <head>
is compared against each commit between the fork-point and <upstream>.
The commits are compared with their 'patch id', obtained from linkgit:git-patch-id[1]
program.
Every commit that doesn't exist in the <upstream> branch
has its id (sha1) reported, prefixed by a symbol. The ones that have
@@ -56,6 +58,10 @@ OPTIONS
<limit>::
Do not report commits up to (and including) limit.
SEE ALSO
--------
linkgit:git-patch-id[1]
Author
------
Written by Junio C Hamano <junkio@cox.net>

View File

@@ -88,7 +88,7 @@ Discussion
include::i18n.txt[]
See Also
SEE ALSO
--------
linkgit:git-write-tree[1]

View File

@@ -8,7 +8,7 @@ git-diff-files - Compares files in the working tree and the index
SYNOPSIS
--------
'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc|--no-index] [<common diff options>] [<path>...]
'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...]
DESCRIPTION
-----------
@@ -36,9 +36,6 @@ omit diff output for unmerged entries and just show "Unmerged".
diff, similar to the way 'diff-tree' shows a merge
commit with these flags.
--no-index::
Compare the two given files / directories.
-q::
Remain silent even on nonexistent files

View File

@@ -113,7 +113,7 @@ OPTIONS
stdin. The commit id is expected on stdout.
+
As a special extension, the commit filter may emit multiple
commit ids; in that case, ancestors of the original commit will
commit ids; in that case, the rewritten children of the original commit will
have all of them as parents.
+
You can use the 'map' convenience function in this filter, and other

View File

@@ -223,7 +223,7 @@ as e-mailable patches:
$ git format-patch -3
------------
See Also
SEE ALSO
--------
linkgit:git-am[1], linkgit:git-send-email[1]

View File

@@ -119,7 +119,7 @@ If you are expecting some objects to be collected and they aren't, check
all of those locations and decide whether it makes sense in your case to
remove those references.
See Also
SEE ALSO
--------
linkgit:git-prune[1]
linkgit:git-reflog[1]

View File

@@ -79,9 +79,9 @@ git gui browser maint::
selected in the browser can be viewed with the internal
blame viewer.
See Also
SEE ALSO
--------
'gitk(1)'::
linkgit:gitk[1]::
The git repository browser. Shows branches, commit history
and file differences. gitk is the utility started by
git-gui's Repository Visualize actions.

View File

@@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one
SYNOPSIS
--------
'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
'git-init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]]
OPTIONS
@@ -20,6 +20,11 @@ OPTIONS
Only print error and warning messages, all other output will be suppressed.
--bare::
Create a bare repository. If GIT_DIR environment is not set, it is set to the
current working directory.
--template=<template_directory>::
Provide the directory from which templates will be used. The default template

View File

@@ -177,7 +177,7 @@ top of the directory tree. A pattern read from a file specified
by --exclude-per-directory is relative to the directory that the
pattern file appears in.
See Also
SEE ALSO
--------
linkgit:git-read-tree[1], linkgit:gitignore[5]

View File

@@ -200,7 +200,7 @@ Documentation
-------------
Documentation by Junio C Hamano
See Also
SEE ALSO
--------
linkgit:git-rev-list[1]
linkgit:git-repack[1]

View File

@@ -46,7 +46,7 @@ Documentation
--------------
Documentation by Lukas Sandström <lukass@etek.chalmers.se>
See Also
SEE ALSO
--------
linkgit:git-pack-objects[1]
linkgit:git-repack[1]

View File

@@ -42,7 +42,7 @@ Documentation
--------------
Documentation by Ryan Anderson <ryan@michonline.com>
See Also
SEE ALSO
--------
linkgit:git-pack-objects[1]
linkgit:git-repack[1]

View File

@@ -66,7 +66,7 @@ many other housekeeping tasks.
For a description of which objects are considered for pruning, see
git-fsck's --unreachable option.
See Also
SEE ALSO
--------
linkgit:git-fsck[1],

View File

@@ -345,7 +345,7 @@ middle of doing, and when your working tree is ready (i.e. you
have finished your work-in-progress), attempt the merge again.
See Also
SEE ALSO
--------
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];
linkgit:gitignore[5]

View File

@@ -128,7 +128,7 @@ $ git merge origin
------------
See Also
SEE ALSO
--------
linkgit:git-fetch[1]
linkgit:git-branch[1]

View File

@@ -122,7 +122,7 @@ Documentation
--------------
Documentation by Ryan Anderson <ryan@michonline.com>
See Also
SEE ALSO
--------
linkgit:git-pack-objects[1]
linkgit:git-prune-packed[1]

View File

@@ -243,16 +243,18 @@ Here is an illustration, by Jon Loeliger. Both commit nodes B
and C are parents of commit node A. Parent commits are ordered
left-to-right.
G H I J
\ / \ /
D E F
\ | / \
\ | / |
\|/ |
B C
\ /
\ /
A
........................................
G H I J
\ / \ /
D E F
\ | / \
\ | / |
\|/ |
B C
\ /
\ /
A
........................................
A = = A^0
B = A^ = A^1 = A~1

View File

@@ -93,7 +93,7 @@ git-rm -f git-*.sh::
(i.e. you are listing the files explicitly), it
does not remove `subdir/git-foo.sh`.
See Also
SEE ALSO
--------
linkgit:git-add[1]

View File

@@ -57,7 +57,7 @@ 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
SEE ALSO
--------
linkgit:gitignore[5]

View File

@@ -365,11 +365,15 @@ Passed directly to git-rebase when using 'dcommit' if a
-n::
--dry-run::
This is only used with the 'dcommit' command.
This can be used with the 'dcommit' and 'rebase' commands.
Print out the series of git arguments that would show
For 'dcommit', print out the series of git arguments that would show
which diffs would be committed to SVN.
For 'rebase', display the local branch associated with the upstream svn
repository associated with the current branch and the URL of svn
repository that will be fetched from.
--
ADVANCED OPTIONS

View File

@@ -312,7 +312,7 @@ The command looks at `core.ignorestat` configuration variable. See
'Using "assume unchanged" bit' section above.
See Also
SEE ALSO
--------
linkgit:git-config[1],
linkgit:git-add[1]

View File

@@ -45,7 +45,7 @@ Your parents must have hated you!::
Your sysadmin must hate you!::
The password(5) name field is longer than a giant static buffer.
See Also
SEE ALSO
--------
linkgit:git-commit-tree[1]
linkgit:git-tag[1]

View File

@@ -46,11 +46,12 @@ Documentation for older releases are available here:
* link:v1.5.5/git.html[documentation for release 1.5.5]
* release notes for
link:RelNotes-1.5.5.3.txt[1.5.5.3],
link:RelNotes-1.5.5.2.txt[1.5.5.2],
link:RelNotes-1.5.5.1.txt[1.5.5.1],
link:RelNotes-1.5.5.txt[1.5.5].
* link:v1.5.5.2/git.html[documentation for release 1.5.5.2]
* link:v1.5.5.3/git.html[documentation for release 1.5.5.3]
* link:v1.5.4.5/git.html[documentation for release 1.5.4.5]
@@ -173,7 +174,7 @@ See the references above to get started using git. The following is
probably more detail than necessary for a first-time user.
The link:user-manual.html#git-concepts[git concepts chapter of the
user-manual] and the link:core-tutorial.html[Core tutorial] both provide
user-manual] and the linkgit:gitcore-tutorial[7][Core tutorial] both provide
introductions to the underlying git architecture.
See also the link:howto-index.html[howto] documents for some useful
@@ -373,7 +374,7 @@ Higher level SCMs may provide and manage additional information in the
Terminology
-----------
Please see the link:glossary.html[glossary] document.
Please see the linkgit:gitglossary[7][glossary] document.
Environment Variables
@@ -517,7 +518,7 @@ Discussion[[Discussion]]
More detail on the following is available from the
link:user-manual.html#git-concepts[git concepts chapter of the
user-manual] and the link:core-tutorial.html[Core tutorial].
user-manual] and the linkgit:gitcore-tutorial[7][Core tutorial].
A git project normally consists of a working directory with a ".git"
subdirectory at the top level. The .git directory contains, among other
@@ -578,6 +579,13 @@ The documentation for git suite was started by David Greaves
<david@dgreaves.com>, and later enhanced greatly by the
contributors on the git-list <git@vger.kernel.org>.
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
link:user-manual.html[The Git User's Manual]
GIT
---
Part of the linkgit:git[7] suite

View File

@@ -1,8 +1,16 @@
A git core tutorial for developers
==================================
gitcore-tutorial(7)
===================
Introduction
------------
NAME
----
gitcore-tutorial - A git core tutorial for developers
SYNOPSIS
--------
git *
DESCRIPTION
-----------
This tutorial explains how to use the "core" git programs to set up and
work with a git repository.
@@ -1679,3 +1687,13 @@ merge two at a time, documenting how you resolved the conflicts,
and the reason why you preferred changes made in one side over
the other. Otherwise it would make the project history harder
to follow, not easier.
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
link:user-manual.html[The Git User's Manual]
GIT
---
Part of the linkgit:git[7] suite.

View File

@@ -20,7 +20,7 @@ this document explains how to do that.
Some basic familiarity with git is required. This
linkgit:gittutorial[7][tutorial introduction to git] and the
link:glossary.html[git glossary] should be sufficient.
linkgit:gitglossary[7][git glossary] should be sufficient.
Developing against a shared repository
--------------------------------------
@@ -184,7 +184,10 @@ repositories without the need for a central maintainer.
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
linkgit:gittutorial[7],
linkgit:gittutorial-2[7],
linkgit:gitcore-tutorial[7],
linkgit:gitglossary[7],
link:everyday.html[Everyday Git],
link:user-manual.html[The Git User's Manual]

View File

@@ -0,0 +1,25 @@
gitglossary(7)
==============
NAME
----
gitglossary - A GIT Glossary
SYNOPSIS
--------
*
DESCRIPTION
-----------
include::glossary-content.txt[]
SEE ALSO
--------
linkgit:gittutorial[7], linkgit:gittutorial-2[7],
linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
link:user-manual.html[The Git User's Manual]
GIT
---
Part of the linkgit:git[7] suite.

View File

@@ -85,7 +85,7 @@ Files
Gitk creates the .gitk file in your $HOME directory to store preferences
such as display options, font, and colors.
See Also
SEE ALSO
--------
'qgit(1)'::
A repository browser written in C++ using Qt.

View File

@@ -390,7 +390,7 @@ in the index file is identical to the one in the working directory.
In addition to being the staging area for new commits, the index file
is also populated from the object database when checking out a
branch, and is used to hold the trees involved in a merge operation.
See the link:core-tutorial.html[core tutorial] and the relevant man
See the linkgit:gitcore-tutorial[7][core tutorial] and the relevant man
pages for details.
What next?
@@ -400,7 +400,7 @@ At this point you should know everything necessary to read the man
pages for any of the git commands; one good place to start would be
with the commands mentioned in link:everyday.html[Everyday git]. You
should be able to find any unknown jargon in the
link:glossary.html[Glossary].
linkgit:gitglossary[7][Glossary].
The link:user-manual.html[Git User's Manual] provides a more
comprehensive introduction to git.
@@ -412,7 +412,7 @@ CVS-like way.
For some interesting examples of git use, see the
link:howto-index.html[howtos].
For git developers, the link:core-tutorial.html[Core tutorial] goes
For git developers, the linkgit:gitcore-tutorial[7][Core tutorial] goes
into detail on the lower-level git mechanisms involved in, for
example, creating a new commit.
@@ -420,6 +420,8 @@ SEE ALSO
--------
linkgit:gittutorial[7],
linkgit:gitcvs-migration[7],
linkgit:gitcore-tutorial[7],
linkgit:gitglossary[7],
link:everyday.html[Everyday git],
link:user-manual.html[The Git User's Manual]

View File

@@ -598,6 +598,8 @@ SEE ALSO
--------
linkgit:gittutorial-2[7],
linkgit:gitcvs-migration[7],
linkgit:gitcore-tutorial[7],
linkgit:gitglossary[7],
link:everyday.html[Everyday git],
link:user-manual.html[The Git User's Manual]

View File

@@ -1,6 +1,3 @@
GIT Glossary
============
[[def_alternate_object_database]]alternate object database::
Via the alternates mechanism, a <<def_repository,repository>>
can inherit part of its <<def_object_database,object database>>
@@ -90,11 +87,10 @@ to point at the new commit.
source code management tools.
[[def_DAG]]DAG::
Directed acyclic graph. The <<def_commit,commit>> objects form a
Directed acyclic graph. The <<def_commit_object,commit objects>> form a
directed acyclic graph, because they have parents (directed), and the
graph of commit objects is acyclic (there is no
<<def_chain,chain>> which begins and ends with the same
<<def_object,object>>).
graph of commit objects is acyclic (there is no <<def_chain,chain>>
which begins and ends with the same <<def_object,object>>).
[[def_dangling_object]]dangling object::
An <<def_unreachable_object,unreachable object>> which is not
@@ -250,9 +246,10 @@ This commit is referred to as a "merge commit", or sometimes just a
the <<def_hash,hash>> of the object.
[[def_object_type]]object type::
One of the identifiers
"<<def_commit,commit>>","<<def_tree,tree>>","<<def_tag,tag>>" or "<<def_blob_object,blob>>"
describing the type of an <<def_object,object>>.
One of the identifiers "<<def_commit_object,commit>>",
"<<def_tree_object,tree>>", "<<def_tag_object,tag>>" or
"<<def_blob_object,blob>>" describing the type of an
<<def_object,object>>.
[[def_octopus]]octopus::
To <<def_merge,merge>> more than two <<def_branch,branches>>. Also denotes an

View File

@@ -1,6 +1,8 @@
<repository>::
The "remote" repository that is the source of a fetch
or pull operation. See the section <<URLS,GIT URLS>> below.
or pull operation. This parameter can be either a URL
(see the section <<URLS,GIT URLS>> below) or the name
of a remote (see the section <<REMOTES,REMOTES>> below).
<refspec>::
The canonical format of a <refspec> parameter is

View File

@@ -1,9 +1,67 @@
revision walking API
====================
The revision walking API offers functions to build a list of revisions
and then iterate over that list.
Calling sequence
----------------
The walking API has a given calling sequence: first you need to
initialize a rev_info structure, then add revisions to control what kind
of revision list do you want to get, finally you can iterate over the
revision list.
Functions
---------
`init_revisions`::
Initialize a rev_info structure with default values. The second
parameter may be NULL or can be prefix path, and then the `.prefix`
variable will be set to it. This is typically the first function you
want to call when you want to deal with a revision list. After calling
this function, you are free to customize options, like set
`.ignore_merges` to 0 if you don't want to ignore merges, and so on. See
`revision.h` for a complete list of available options.
`add_pending_object`::
This function can be used if you want to add commit objects as revision
information. You can use the `UNINTERESTING` object flag to indicate if
you want to include or exclude the given commit (and commits reachable
from the given commit) from the revision list.
+
NOTE: If you have the commits as a string list then you probably want to
use setup_revisions(), instead of parsing each string and using this
function.
`setup_revisions`::
Parse revision information, filling in the `rev_info` structure, and
removing the used arguments from the argument list. Returns the number
of arguments left that weren't recognized, which are also moved to the
head of the argument list. The last parameter is used in case no
parameter given by the first two arguments.
`prepare_revision_walk`::
Prepares the rev_info structure for a walk. You should check if it
returns any error (non-zero return code) and if it does not, you can
start using get_revision() to do the iteration.
`get_revision`::
Takes a pointer to a `rev_info` structure and iterates over it,
returning a `struct commit *` each time you call it. The end of the
revision list is indicated by returning a NULL pointer.
Data structures
---------------
Talk about <revision.h>, things like:
* two diff_options, one for path limiting, another for output;
* calling sequence: init_revisions(), setup_revsions(), get_revision();
* remaining functions;
(Linus, JC, Dscho)

View File

@@ -1,11 +1,46 @@
include::urls.txt[]
REMOTES
-------
REMOTES[[REMOTES]]
------------------
In addition to the above, as a short-hand, the name of a
file in `$GIT_DIR/remotes` directory can be given; the
named file should be in the following format:
The name of one of the following can be used instead
of a URL as `<repository>` argument:
* a remote in the git configuration file: `$GIT_DIR/config`,
* a file in the `$GIT_DIR/remotes` directory, or
* a file in the `$GIT_DIR/branches` directory.
All of these also allow you to omit the refspec from the command line
because they each contain a refspec which git will use by default.
Named remote in configuration file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can choose to provide the name of a remote which you had previously
configured using linkgit:git-remote[1], linkgit:git-config[1]
or even by a manual edit to the `$GIT_DIR/config` file. The URL of
this remote will be used to access the repository. The refspec
of this remote will be used by default when you do
not provide a refspec on the command line. The entry in the
config file would appear like this:
------------
[remote "<name>"]
url = <url>
push = <refspec>
fetch = <refspec>
------------
Named file in `$GIT_DIR/remotes`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can choose to provide the name of a
file in `$GIT_DIR/remotes`. The URL
in this file will be used to access the repository. The refspec
in this file will be used as default when you do not
provide a refspec on the command line. This file should have the
following format:
------------
URL: one of the above URL format
@@ -14,42 +49,34 @@ named file should be in the following format:
------------
Then such a short-hand is specified in place of
<repository> without <refspec> parameters on the command
line, <refspec> specified on `Push:` lines or `Pull:`
lines are used for `git-push` and `git-fetch`/`git-pull`,
respectively. Multiple `Push:` and `Pull:` lines may
`Push:` lines are used by `git-push` and
`Pull:` lines are used by `git-pull` and `git-fetch`.
Multiple `Push:` and `Pull:` lines may
be specified for additional branch mappings.
Or, equivalently, in the `$GIT_DIR/config` (note the use
of `fetch` instead of `Pull:`):
Named file in `$GIT_DIR/branches`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can choose to provide the name of a
file in `$GIT_DIR/branches`.
The URL in this file will be used to access the repository.
This file should have the following format:
------------
[remote "<remote>"]
url = <url>
push = <refspec>
fetch = <refspec>
<url>#<head>
------------
The name of a file in `$GIT_DIR/branches` directory can be
specified as an older notation short-hand; the named
file should contain a single line, a URL in one of the
above formats, optionally followed by a hash `#` and the
name of remote head (URL fragment notation).
`$GIT_DIR/branches/<remote>` file that stores a <url>
without the fragment is equivalent to have this in the
corresponding file in the `$GIT_DIR/remotes/` directory.
`<url>` is required; `#<head>` is optional.
When you do not provide a refspec on the command line,
git will use the following refspec, where `<head>` defaults to `master`,
and `<repository>` is the name of this file
you provided in the command line.
------------
URL: <url>
Pull: refs/heads/master:<remote>
refs/heads/<head>:<repository>
------------
while having `<url>#<head>` is equivalent to
------------
URL: <url>
Pull: refs/heads/<head>:<remote>
------------

View File

@@ -4252,7 +4252,10 @@ You see, Git is actually the best tool to find out about the source of Git
itself!
[[glossary]]
include::glossary.txt[]
GIT Glossary
============
include::glossary-content.txt[]
[[git-quick-start]]
Appendix A: Git Quick Reference

View File

@@ -374,6 +374,7 @@ LIB_H += tree.h
LIB_H += tree-walk.h
LIB_H += unpack-trees.h
LIB_H += utf8.h
LIB_H += wt-status.h
LIB_OBJS += alias.o
LIB_OBJS += alloc.o
@@ -403,6 +404,7 @@ LIB_OBJS += diffcore-order.o
LIB_OBJS += diffcore-pickaxe.o
LIB_OBJS += diffcore-rename.o
LIB_OBJS += diff-delta.o
LIB_OBJS += diff-no-index.o
LIB_OBJS += diff-lib.o
LIB_OBJS += diff.o
LIB_OBJS += dir.o

View File

@@ -84,6 +84,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
unsigned char rev[20];
int flag;
struct commit *head;
int errs = 0;
int newfd;
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
@@ -106,13 +107,14 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
if (report_path_error(ps_matched, pathspec, 0))
return 1;
/* Now we are committed to check them out */
memset(&state, 0, sizeof(state));
state.force = 1;
state.refresh_cache = 1;
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
if (pathspec_match(pathspec, NULL, ce->name, 0)) {
checkout_entry(ce, &state, NULL);
errs |= checkout_entry(ce, &state, NULL);
}
}
@@ -123,7 +125,8 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
resolve_ref("HEAD", rev, 0, &flag);
head = lookup_commit_reference_gently(rev, 1);
return post_checkout_hook(head, head, 0);
errs |= post_checkout_hook(head, head, 0);
return errs;
}
static void show_local_changes(struct object *head)
@@ -148,57 +151,50 @@ static void describe_detached_head(char *msg, struct commit *commit)
strbuf_release(&sb);
}
static int reset_to_new(struct tree *tree, int quiet)
{
struct unpack_trees_options opts;
struct tree_desc tree_desc;
memset(&opts, 0, sizeof(opts));
opts.head_idx = -1;
opts.update = 1;
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
opts.verbose_update = !quiet;
opts.src_index = &the_index;
opts.dst_index = &the_index;
parse_tree(tree);
init_tree_desc(&tree_desc, tree->buffer, tree->size);
if (unpack_trees(1, &tree_desc, &opts))
return 128;
return 0;
}
static void reset_clean_to_new(struct tree *tree, int quiet)
{
struct unpack_trees_options opts;
struct tree_desc tree_desc;
memset(&opts, 0, sizeof(opts));
opts.head_idx = -1;
opts.skip_unmerged = 1;
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
opts.verbose_update = !quiet;
opts.src_index = &the_index;
opts.dst_index = &the_index;
parse_tree(tree);
init_tree_desc(&tree_desc, tree->buffer, tree->size);
if (unpack_trees(1, &tree_desc, &opts))
exit(128);
}
struct checkout_opts {
int quiet;
int merge;
int force;
int writeout_error;
char *new_branch;
int new_branch_log;
enum branch_track track;
};
static int reset_tree(struct tree *tree, struct checkout_opts *o, int worktree)
{
struct unpack_trees_options opts;
struct tree_desc tree_desc;
memset(&opts, 0, sizeof(opts));
opts.head_idx = -1;
opts.update = worktree;
opts.skip_unmerged = !worktree;
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
opts.verbose_update = !o->quiet;
opts.src_index = &the_index;
opts.dst_index = &the_index;
parse_tree(tree);
init_tree_desc(&tree_desc, tree->buffer, tree->size);
switch (unpack_trees(1, &tree_desc, &opts)) {
case -2:
o->writeout_error = 1;
/*
* We return 0 nevertheless, as the index is all right
* and more importantly we have made best efforts to
* update paths in the work tree, and we cannot revert
* them.
*/
case 0:
return 0;
default:
return 128;
}
}
struct branch_info {
const char *name; /* The short name used */
const char *path; /* The full name of a real branch */
@@ -223,7 +219,7 @@ static int merge_working_tree(struct checkout_opts *opts,
read_cache();
if (opts->force) {
ret = reset_to_new(new->commit->tree, opts->quiet);
ret = reset_tree(new->commit->tree, opts, 1);
if (ret)
return ret;
} else {
@@ -259,7 +255,8 @@ static int merge_working_tree(struct checkout_opts *opts,
tree = parse_tree_indirect(new->commit->object.sha1);
init_tree_desc(&trees[1], tree->buffer, tree->size);
if (unpack_trees(2, trees, &topts)) {
ret = unpack_trees(2, trees, &topts);
if (ret == -1) {
/*
* Unpack couldn't do a trivial merge; either
* give up or do a real merge, depending on
@@ -287,12 +284,14 @@ static int merge_working_tree(struct checkout_opts *opts,
add_files_to_cache(NULL, NULL, 0);
work = write_tree_from_memory();
ret = reset_to_new(new->commit->tree, opts->quiet);
ret = reset_tree(new->commit->tree, opts, 1);
if (ret)
return ret;
merge_trees(new->commit->tree, work, old->commit->tree,
new->name, "local", &result);
reset_clean_to_new(new->commit->tree, opts->quiet);
ret = reset_tree(new->commit->tree, opts, 0);
if (ret)
return ret;
}
}
@@ -492,7 +491,8 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
update_refs_for_switch(opts, &old, new);
return post_checkout_hook(old.commit, new->commit, 1);
ret = post_checkout_hook(old.commit, new->commit, 1);
return ret || opts->writeout_error;
}
int cmd_checkout(int argc, const char **argv, const char *prefix)

View File

@@ -449,6 +449,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
struct remote *remote = remote_get(argv[0]);
struct transport *transport = transport_get(remote, argv[0]);
if (!transport->get_refs_list || !transport->fetch)
die("Don't know how to clone %s", transport->url);
transport_set_option(transport, TRANS_OPT_KEEP, "yes");
if (option_depth)

View File

@@ -223,6 +223,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
if (interactive) {
interactive_add(argc, argv, prefix);
if (read_cache() < 0)
die("index file corrupt");
commit_style = COMMIT_AS_IS;
return get_index_file();
}
@@ -881,10 +883,19 @@ static void add_parent(struct strbuf *sb, const unsigned char *sha1)
{
struct object *obj = parse_object(sha1);
const char *parent = sha1_to_hex(sha1);
const char *cp;
if (!obj)
die("Unable to find commit parent %s", parent);
if (obj->type != OBJ_COMMIT)
die("Parent %s isn't a proper commit", parent);
for (cp = sb->buf; cp && (cp = strstr(cp, "\nparent ")); cp += 8) {
if (!memcmp(cp + 8, parent, 40) && cp[48] == '\n') {
error("duplicate parent %s ignored", parent);
return;
}
}
strbuf_addf(sb, "parent %s\n", parent);
}

View File

@@ -10,26 +10,54 @@
#include "builtin.h"
static const char diff_files_usage[] =
"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|--no-index] [<common diff options>] [<path>...]"
"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
int cmd_diff_files(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
int nongit;
int result;
unsigned options = 0;
prefix = setup_git_directory_gently(&nongit);
init_revisions(&rev, prefix);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
rev.abbrev = 0;
if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
argc = 0;
else
argc = setup_revisions(argc, argv, &rev, NULL);
argc = setup_revisions(argc, argv, &rev, NULL);
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "--base"))
rev.max_count = 1;
else if (!strcmp(argv[1], "--ours"))
rev.max_count = 2;
else if (!strcmp(argv[1], "--theirs"))
rev.max_count = 3;
else if (!strcmp(argv[1], "-q"))
options |= DIFF_SILENT_ON_REMOVED;
else
usage(diff_files_usage);
argv++; argc--;
}
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
result = run_diff_files_cmd(&rev, argc, argv);
/*
* Make sure there are NO revision (i.e. pending object) parameter,
* rev.max_count is reasonable (0 <= n <= 3), and
* there is no other revision filtering parameters.
*/
if (rev.pending.nr ||
rev.min_age != -1 || rev.max_age != -1 ||
3 < rev.max_count)
usage(diff_files_usage);
if (rev.max_count == -1 &&
(rev.diffopt.output_format & DIFF_FORMAT_PATCH))
rev.combine_merges = rev.dense_combined_merges = 1;
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
result = run_diff_files(&rev, options);
return diff_result_code(&rev.diffopt, result);
}

View File

@@ -202,6 +202,37 @@ static void refresh_index_quietly(void)
rollback_lock_file(lock_file);
}
static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv)
{
int result;
unsigned int options = 0;
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "--base"))
revs->max_count = 1;
else if (!strcmp(argv[1], "--ours"))
revs->max_count = 2;
else if (!strcmp(argv[1], "--theirs"))
revs->max_count = 3;
else if (!strcmp(argv[1], "-q"))
options |= DIFF_SILENT_ON_REMOVED;
else
return error("invalid option: %s", argv[1]);
argv++; argc--;
}
if (revs->max_count == -1 &&
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
revs->combine_merges = revs->dense_combined_merges = 1;
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
result = run_diff_files(revs, options);
return diff_result_code(&revs->diffopt, result);
}
int cmd_diff(int argc, const char **argv, const char *prefix)
{
int i;
@@ -230,6 +261,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
* N=2, M=0:
* tree vs tree (diff-tree)
*
* N=0, M=0, P=2:
* compare two filesystem entities (aka --no-index).
*
* Other cases are errors.
*/
@@ -240,21 +274,21 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
diff_use_color_default = git_use_color_default;
init_revisions(&rev, prefix);
/* If this is a no-index diff, just run it and exit there. */
diff_no_index(&rev, argc, argv, nongit, prefix);
/* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
argc = 0;
else
argc = setup_revisions(argc, argv, &rev, NULL);
if (nongit)
die("Not a git repository");
argc = setup_revisions(argc, argv, &rev, NULL);
if (!rev.diffopt.output_format) {
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
if (diff_setup_done(&rev.diffopt) < 0)
die("diff_setup_done failed");
}
if (rev.diffopt.prefix && nongit) {
rev.diffopt.prefix = NULL;
rev.diffopt.prefix_length = 0;
}
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
@@ -265,7 +299,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
setup_pager();
/* Do we have --cached and not have a pending object, then
/*
* Do we have --cached and not have a pending object, then
* default to HEAD by hand. Eek.
*/
if (!rev.pending.nr) {
@@ -333,7 +368,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
if (!ents) {
switch (blobs) {
case 0:
result = run_diff_files_cmd(&rev, argc, argv);
result = builtin_diff_files(&rev, argc, argv);
break;
case 1:
if (paths != 1)

View File

@@ -286,7 +286,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
{
FILE *fp;
struct commit *commit;
int url_len, i, note_len, shown_url = 0;
int url_len, i, note_len, shown_url = 0, rc = 0;
char note[1024];
const char *what, *kind;
struct ref *rm;
@@ -353,7 +353,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
note);
if (ref)
update_local_ref(ref, what, verbose, note);
rc |= update_local_ref(ref, what, verbose, note);
else
sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
SUMMARY_WIDTH, *kind ? kind : "branch",
@@ -368,7 +368,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
}
}
fclose(fp);
return 0;
return rc;
}
/*

View File

@@ -364,7 +364,7 @@ static int guess_repository_type(const char *git_dir)
}
static const char init_db_usage[] =
"git-init [-q | --quiet] [--template=<template-directory>] [--shared]";
"git-init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]";
/*
* If you want to, you can share the DB area with any number of branches.
@@ -383,7 +383,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
const char *arg = argv[1];
if (!prefixcmp(arg, "--template="))
template_dir = arg+11;
else if (!strcmp(arg, "--shared"))
else if (!strcmp(arg, "--bare")) {
static char git_dir[PATH_MAX+1];
is_bare_repository_cfg = 1;
setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,
sizeof(git_dir)), 0);
} else if (!strcmp(arg, "--shared"))
shared_repository = PERM_GROUP;
else if (!prefixcmp(arg, "--shared="))
shared_repository = git_config_perm("arg", arg+9);

View File

@@ -514,11 +514,14 @@ static void write_pack_file(void)
* Did we write the wrong # entries in the header?
* If so, rewrite it like in fast-import
*/
if (pack_to_stdout || nr_written == nr_remaining) {
sha1close(f, sha1, 1);
if (pack_to_stdout) {
sha1close(f, sha1, CSUM_CLOSE);
} else if (nr_written == nr_remaining) {
sha1close(f, sha1, CSUM_FSYNC);
} else {
int fd = sha1close(f, NULL, 0);
fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);
fsync_or_die(fd, pack_tmp_name);
close(fd);
}

View File

@@ -85,7 +85,6 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
/* Handle arguments here .. */
usage(prune_packed_usage);
}
sync();
prune_packed_objects(opts);
return 0;
}

View File

@@ -156,7 +156,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
mark_reachable_objects(&revs, 1);
prune_object_dir(get_object_directory());
sync();
prune_packed_objects(show_only);
remove_temporary_files();
return 0;

View File

@@ -206,7 +206,6 @@ static void read_branches(void)
struct ref_states {
struct remote *remote;
struct strbuf remote_prefix;
struct path_list new, stale, tracked;
};
@@ -262,36 +261,72 @@ static int get_ref_states(const struct ref *ref, struct ref_states *states)
}
free_refs(fetch_map);
strbuf_addf(&states->remote_prefix,
"refs/remotes/%s/", states->remote->name);
for_each_ref(handle_one_branch, states);
sort_path_list(&states->stale);
return 0;
}
struct known_remote {
struct known_remote *next;
struct remote *remote;
};
struct known_remotes {
struct remote *to_delete;
struct known_remote *list;
};
static int add_known_remote(struct remote *remote, void *cb_data)
{
struct known_remotes *all = cb_data;
struct known_remote *r;
if (!strcmp(all->to_delete->name, remote->name))
return 0;
r = xmalloc(sizeof(*r));
r->remote = remote;
r->next = all->list;
all->list = r;
return 0;
}
struct branches_for_remote {
const char *prefix;
struct remote *remote;
struct path_list *branches;
struct known_remotes *keep;
};
static int add_branch_for_removal(const char *refname,
const unsigned char *sha1, int flags, void *cb_data)
{
struct branches_for_remote *branches = cb_data;
struct refspec refspec;
struct path_list_item *item;
struct known_remote *kr;
if (!prefixcmp(refname, branches->prefix)) {
struct path_list_item *item;
memset(&refspec, 0, sizeof(refspec));
refspec.dst = (char *)refname;
if (remote_find_tracking(branches->remote, &refspec))
return 0;
/* make sure that symrefs are deleted */
if (flags & REF_ISSYMREF)
return unlink(git_path(refname));
item = path_list_append(refname, branches->branches);
item->util = xmalloc(20);
hashcpy(item->util, sha1);
/* don't delete a branch if another remote also uses it */
for (kr = branches->keep->list; kr; kr = kr->next) {
memset(&refspec, 0, sizeof(refspec));
refspec.dst = (char *)refname;
if (!remote_find_tracking(kr->remote, &refspec))
return 0;
}
/* make sure that symrefs are deleted */
if (flags & REF_ISSYMREF)
return unlink(git_path(refname));
item = path_list_append(refname, branches->branches);
item->util = xmalloc(20);
hashcpy(item->util, sha1);
return 0;
}
@@ -316,8 +351,9 @@ static int rm(int argc, const char **argv)
};
struct remote *remote;
struct strbuf buf;
struct known_remotes known_remotes = { NULL, NULL };
struct path_list branches = { NULL, 0, 0, 1 };
struct branches_for_remote cb_data = { NULL, &branches };
struct branches_for_remote cb_data = { NULL, &branches, &known_remotes };
int i;
if (argc != 2)
@@ -327,6 +363,9 @@ static int rm(int argc, const char **argv)
if (!remote)
die("No such remote: %s", argv[1]);
known_remotes.to_delete = remote;
for_each_remote(add_known_remote, &known_remotes);
strbuf_init(&buf, 0);
strbuf_addf(&buf, "remote.%s", remote->name);
if (git_config_rename_section(buf.buf, NULL) < 1)
@@ -355,9 +394,7 @@ static int rm(int argc, const char **argv)
* the branches one by one, since for_each_ref() relies on cached
* refs, which are invalidated when deleting a branch.
*/
strbuf_reset(&buf);
strbuf_addf(&buf, "refs/remotes/%s/", remote->name);
cb_data.prefix = buf.buf;
cb_data.remote = remote;
i = for_each_ref(add_branch_for_removal, &cb_data);
strbuf_release(&buf);
@@ -422,27 +459,10 @@ static int show_or_prune(int argc, const char **argv, int prune)
states.remote->name);
if (prune) {
struct strbuf buf;
int prefix_len;
strbuf_init(&buf, 0);
if (states.remote->fetch_refspec_nr == 1 &&
states.remote->fetch->pattern &&
!strcmp(states.remote->fetch->src,
states.remote->fetch->dst))
/* handle --mirror remote */
strbuf_addstr(&buf, "refs/heads/");
else
strbuf_addf(&buf, "refs/remotes/%s/", *argv);
prefix_len = buf.len;
for (i = 0; i < states.stale.nr; i++) {
strbuf_setlen(&buf, prefix_len);
strbuf_addstr(&buf, states.stale.items[i].path);
result |= delete_ref(buf.buf, NULL);
const char *refname = states.stale.items[i].util;
result |= delete_ref(refname, NULL);
}
strbuf_release(&buf);
goto cleanup_states;
}

View File

@@ -49,13 +49,14 @@ static inline int is_merge(void)
return !access(git_path("MERGE_HEAD"), F_OK);
}
static int reset_index_file(const unsigned char *sha1, int is_hard_reset)
static int reset_index_file(const unsigned char *sha1, int is_hard_reset, int quiet)
{
int i = 0;
const char *args[6];
args[i++] = "read-tree";
args[i++] = "-v";
if (!quiet)
args[i++] = "-v";
args[i++] = "--reset";
if (is_hard_reset)
args[i++] = "-u";
@@ -182,7 +183,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
OPT_SET_INT(0, "hard", &reset_type,
"reset HEAD, index and working tree", HARD),
OPT_BOOLEAN('q', NULL, &quiet,
"disable showing new HEAD in hard reset"),
"disable showing new HEAD in hard reset and progress message"),
OPT_END()
};
@@ -231,7 +232,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
if (is_merge() || read_cache() < 0 || unmerged_cache())
die("Cannot do a soft reset in the middle of a merge.");
}
else if (reset_index_file(sha1, (reset_type == HARD)))
else if (reset_index_file(sha1, (reset_type == HARD), quiet))
die("Could not reset index file to revision '%s'.", rev);
/* Any resets update HEAD to the head being switched to,

View File

@@ -782,8 +782,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
has_head++;
}
if (!has_head) {
int pfxlen = strlen("refs/heads/");
append_one_rev(head + pfxlen);
int offset = !prefixcmp(head, "refs/heads/") ? 11 : 0;
append_one_rev(head + offset);
}
}

View File

@@ -761,6 +761,7 @@ 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);
extern void fsync_or_die(int fd, const char *);
/* pager.c */
extern void setup_pager(void);

View File

@@ -232,8 +232,10 @@ 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 (let ((process-environment (append (git-get-env-strings env)
process-environment)))
(unless (eq 0 (if env
(git-run-process-region
buffer start end "env"
(append (git-get-env-strings env) (list "git") args))
(git-run-process-region
buffer start end "git" args)))
(error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string))))
@@ -248,8 +250,9 @@ and returns the process output as a string, or nil if the git failed."
(erase-buffer)
(cd dir)
(setq status
(let ((process-environment (append (git-get-env-strings env)
process-environment)))
(if env
(apply #'call-process "env" nil (list buffer t) nil
(append (git-get-env-strings env) (list hook-name) args))
(apply #'call-process hook-name nil (list buffer t) nil args))))
(display-message-or-buffer buffer)
(eq 0 status)))))

View File

@@ -46,6 +46,7 @@ options:
for incrementals
-n, --nrepack=INT: number of changesets that will trigger
a repack (default=0, -1 to deactivate)
-v, --verbose: be verbose
required:
hgprj: name of the HG project to import (directory)
@@ -75,15 +76,18 @@ def getgitenv(user, date):
state = ''
opt_nrepack = 0
verbose = False
try:
opts, args = getopt.getopt(sys.argv[1:], 's:t:n:', ['gitstate=', 'tempdir=', 'nrepack='])
opts, args = getopt.getopt(sys.argv[1:], 's:t:n:v', ['gitstate=', 'tempdir=', 'nrepack=', 'verbose'])
for o, a in opts:
if o in ('-s', '--gitstate'):
state = a
state = os.path.abspath(state)
if o in ('-n', '--nrepack'):
opt_nrepack = int(a)
if o in ('-v', '--verbose'):
verbose = True
if len(args) != 1:
raise('params')
except:
@@ -95,17 +99,20 @@ os.chdir(hgprj)
if state:
if os.path.exists(state):
print 'State does exist, reading'
if verbose:
print 'State does exist, reading'
f = open(state, 'r')
hgvers = pickle.load(f)
else:
print 'State does not exist, first run'
tip = os.popen('hg tip --template "{rev}"').read()
print 'tip is', tip
if verbose:
print 'tip is', tip
# Calculate the branches
print 'analysing the branches...'
if verbose:
print 'analysing the branches...'
hgchildren["0"] = ()
hgparents["0"] = (None, None)
hgbranch["0"] = "master"
@@ -232,7 +239,8 @@ if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
# write the state for incrementals
if state:
print 'Writing state'
if verbose:
print 'Writing state'
f = open(state, 'w')
pickle.dump(hgvers, f)

View File

@@ -32,21 +32,24 @@ static void sha1flush(struct sha1file *f, unsigned int count)
}
}
int sha1close(struct sha1file *f, unsigned char *result, int final)
int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
{
int fd;
unsigned offset = f->offset;
if (offset) {
SHA1_Update(&f->ctx, f->buffer, offset);
sha1flush(f, offset);
f->offset = 0;
}
if (final) {
if (flags & (CSUM_CLOSE | CSUM_FSYNC)) {
/* write checksum and close fd */
SHA1_Final(f->buffer, &f->ctx);
if (result)
hashcpy(result, f->buffer);
sha1flush(f, 20);
if (flags & CSUM_FSYNC)
fsync_or_die(f->fd, f->name);
if (close(f->fd))
die("%s: sha1 file error on close (%s)",
f->name, strerror(errno));

View File

@@ -16,9 +16,13 @@ struct sha1file {
unsigned char buffer[8192];
};
/* sha1close flags */
#define CSUM_CLOSE 1
#define CSUM_FSYNC 2
extern struct sha1file *sha1fd(int fd, const char *name);
extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
extern int sha1close(struct sha1file *, unsigned char *, int);
extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
extern int sha1write(struct sha1file *, void *, unsigned int);
extern void crc32_begin(struct sha1file *);
extern uint32_t crc32_end(struct sha1file *);

View File

@@ -8,7 +8,6 @@
#include "diffcore.h"
#include "revision.h"
#include "cache-tree.h"
#include "path-list.h"
#include "unpack-trees.h"
#include "refs.h"
@@ -16,328 +15,6 @@
* diff-files
*/
static int read_directory(const char *path, struct path_list *list)
{
DIR *dir;
struct dirent *e;
if (!(dir = opendir(path)))
return error("Could not open directory %s", path);
while ((e = readdir(dir)))
if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
path_list_insert(e->d_name, list);
closedir(dir);
return 0;
}
static int get_mode(const char *path, int *mode)
{
struct stat st;
if (!path || !strcmp(path, "/dev/null"))
*mode = 0;
else if (!strcmp(path, "-"))
*mode = create_ce_mode(0666);
else if (stat(path, &st))
return error("Could not access '%s'", path);
else
*mode = st.st_mode;
return 0;
}
static int queue_diff(struct diff_options *o,
const char *name1, const char *name2)
{
int mode1 = 0, mode2 = 0;
if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
return -1;
if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
return error("file/directory conflict: %s, %s", name1, name2);
if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
char buffer1[PATH_MAX], buffer2[PATH_MAX];
struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
int len1 = 0, len2 = 0, i1, i2, ret = 0;
if (name1 && read_directory(name1, &p1))
return -1;
if (name2 && read_directory(name2, &p2)) {
path_list_clear(&p1, 0);
return -1;
}
if (name1) {
len1 = strlen(name1);
if (len1 > 0 && name1[len1 - 1] == '/')
len1--;
memcpy(buffer1, name1, len1);
buffer1[len1++] = '/';
}
if (name2) {
len2 = strlen(name2);
if (len2 > 0 && name2[len2 - 1] == '/')
len2--;
memcpy(buffer2, name2, len2);
buffer2[len2++] = '/';
}
for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) {
const char *n1, *n2;
int comp;
if (i1 == p1.nr)
comp = 1;
else if (i2 == p2.nr)
comp = -1;
else
comp = strcmp(p1.items[i1].path,
p2.items[i2].path);
if (comp > 0)
n1 = NULL;
else {
n1 = buffer1;
strncpy(buffer1 + len1, p1.items[i1++].path,
PATH_MAX - len1);
}
if (comp < 0)
n2 = NULL;
else {
n2 = buffer2;
strncpy(buffer2 + len2, p2.items[i2++].path,
PATH_MAX - len2);
}
ret = queue_diff(o, n1, n2);
}
path_list_clear(&p1, 0);
path_list_clear(&p2, 0);
return ret;
} else {
struct diff_filespec *d1, *d2;
if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
unsigned tmp;
const char *tmp_c;
tmp = mode1; mode1 = mode2; mode2 = tmp;
tmp_c = name1; name1 = name2; name2 = tmp_c;
}
if (!name1)
name1 = "/dev/null";
if (!name2)
name2 = "/dev/null";
d1 = alloc_filespec(name1);
d2 = alloc_filespec(name2);
fill_filespec(d1, null_sha1, mode1);
fill_filespec(d2, null_sha1, mode2);
diff_queue(&diff_queued_diff, d1, d2);
return 0;
}
}
/*
* Does the path name a blob in the working tree, or a directory
* in the working tree?
*/
static int is_in_index(const char *path)
{
int len, pos;
struct cache_entry *ce;
len = strlen(path);
while (path[len-1] == '/')
len--;
if (!len)
return 1; /* "." */
pos = cache_name_pos(path, len);
if (0 <= pos)
return 1;
pos = -1 - pos;
while (pos < active_nr) {
ce = active_cache[pos++];
if (ce_namelen(ce) <= len ||
strncmp(ce->name, path, len) ||
(ce->name[len] > '/'))
break; /* path cannot be a prefix */
if (ce->name[len] == '/')
return 1;
}
return 0;
}
static int handle_diff_files_args(struct rev_info *revs,
int argc, const char **argv,
unsigned int *options)
{
*options = 0;
/* revs->max_count == -2 means --no-index */
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "--base"))
revs->max_count = 1;
else if (!strcmp(argv[1], "--ours"))
revs->max_count = 2;
else if (!strcmp(argv[1], "--theirs"))
revs->max_count = 3;
else if (!strcmp(argv[1], "-n") ||
!strcmp(argv[1], "--no-index")) {
revs->max_count = -2;
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
}
else if (!strcmp(argv[1], "-q"))
*options |= DIFF_SILENT_ON_REMOVED;
else
return error("invalid option: %s", argv[1]);
argv++; argc--;
}
if (revs->max_count == -1 && revs->diffopt.nr_paths == 2) {
/*
* If two files are specified, and at least one is untracked,
* default to no-index.
*/
read_cache();
if (!is_in_index(revs->diffopt.paths[0]) ||
!is_in_index(revs->diffopt.paths[1])) {
revs->max_count = -2;
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
}
}
/*
* Make sure there are NO revision (i.e. pending object) parameter,
* rev.max_count is reasonable (0 <= n <= 3),
* there is no other revision filtering parameters.
*/
if (revs->pending.nr || revs->max_count > 3 ||
revs->min_age != -1 || revs->max_age != -1)
return error("no revision allowed with diff-files");
if (revs->max_count == -1 &&
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
revs->combine_merges = revs->dense_combined_merges = 1;
return 0;
}
static int is_outside_repo(const char *path, int nongit, const char *prefix)
{
int i;
if (nongit || !strcmp(path, "-") || is_absolute_path(path))
return 1;
if (prefixcmp(path, "../"))
return 0;
if (!prefix)
return 1;
for (i = strlen(prefix); !prefixcmp(path, "../"); ) {
while (i > 0 && prefix[i - 1] != '/')
i--;
if (--i < 0)
return 1;
path += 3;
}
return 0;
}
int setup_diff_no_index(struct rev_info *revs,
int argc, const char ** argv, int nongit, const char *prefix)
{
int i;
for (i = 1; i < argc; i++)
if (argv[i][0] != '-' || argv[i][1] == '\0')
break;
else if (!strcmp(argv[i], "--")) {
i++;
break;
} else if (i < argc - 3 && !strcmp(argv[i], "--no-index")) {
i = argc - 3;
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;
diff_setup(&revs->diffopt);
for (i = 1; i < argc - 2; )
if (!strcmp(argv[i], "--no-index"))
i++;
else {
int j = diff_opt_parse(&revs->diffopt,
argv + i, argc - i);
if (!j)
die("invalid diff option/value: %s", argv[i]);
i += j;
}
if (prefix) {
int len = strlen(prefix);
revs->diffopt.paths = xcalloc(2, sizeof(char*));
for (i = 0; i < 2; i++) {
const char *p = argv[argc - 2 + i];
/*
* stdin should be spelled as '-'; if you have
* path that is '-', spell it as ./-.
*/
p = (strcmp(p, "-")
? xstrdup(prefix_filename(prefix, len, p))
: p);
revs->diffopt.paths[i] = p;
}
}
else
revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
revs->max_count = -2;
if (diff_setup_done(&revs->diffopt) < 0)
die("diff_setup_done failed");
return 0;
}
int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
{
unsigned int options;
if (handle_diff_files_args(revs, argc, argv, &options))
return -1;
if (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {
if (revs->diffopt.nr_paths != 2)
return error("need two files/directories with --no-index");
if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
revs->diffopt.paths[1]))
return -1;
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
/*
* The return code for --no-index imitates diff(1):
* 0 = no changes, 1 = changes, else error
*/
return revs->diffopt.found_changes;
}
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
return run_diff_files(revs, options);
}
/*
* Has the work tree entity been removed?
*

263
diff-no-index.c Normal file
View File

@@ -0,0 +1,263 @@
/*
* "diff --no-index" support
* Copyright (c) 2007 by Johannes Schindelin
* Copyright (c) 2008 by Junio C Hamano
*/
#include "cache.h"
#include "color.h"
#include "commit.h"
#include "blob.h"
#include "tag.h"
#include "diff.h"
#include "diffcore.h"
#include "revision.h"
#include "log-tree.h"
#include "builtin.h"
#include "path-list.h"
static int read_directory(const char *path, struct path_list *list)
{
DIR *dir;
struct dirent *e;
if (!(dir = opendir(path)))
return error("Could not open directory %s", path);
while ((e = readdir(dir)))
if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
path_list_insert(e->d_name, list);
closedir(dir);
return 0;
}
static int get_mode(const char *path, int *mode)
{
struct stat st;
if (!path || !strcmp(path, "/dev/null"))
*mode = 0;
else if (!strcmp(path, "-"))
*mode = create_ce_mode(0666);
else if (stat(path, &st))
return error("Could not access '%s'", path);
else
*mode = st.st_mode;
return 0;
}
static int queue_diff(struct diff_options *o,
const char *name1, const char *name2)
{
int mode1 = 0, mode2 = 0;
if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
return -1;
if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
return error("file/directory conflict: %s, %s", name1, name2);
if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
char buffer1[PATH_MAX], buffer2[PATH_MAX];
struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
int len1 = 0, len2 = 0, i1, i2, ret = 0;
if (name1 && read_directory(name1, &p1))
return -1;
if (name2 && read_directory(name2, &p2)) {
path_list_clear(&p1, 0);
return -1;
}
if (name1) {
len1 = strlen(name1);
if (len1 > 0 && name1[len1 - 1] == '/')
len1--;
memcpy(buffer1, name1, len1);
buffer1[len1++] = '/';
}
if (name2) {
len2 = strlen(name2);
if (len2 > 0 && name2[len2 - 1] == '/')
len2--;
memcpy(buffer2, name2, len2);
buffer2[len2++] = '/';
}
for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) {
const char *n1, *n2;
int comp;
if (i1 == p1.nr)
comp = 1;
else if (i2 == p2.nr)
comp = -1;
else
comp = strcmp(p1.items[i1].path,
p2.items[i2].path);
if (comp > 0)
n1 = NULL;
else {
n1 = buffer1;
strncpy(buffer1 + len1, p1.items[i1++].path,
PATH_MAX - len1);
}
if (comp < 0)
n2 = NULL;
else {
n2 = buffer2;
strncpy(buffer2 + len2, p2.items[i2++].path,
PATH_MAX - len2);
}
ret = queue_diff(o, n1, n2);
}
path_list_clear(&p1, 0);
path_list_clear(&p2, 0);
return ret;
} else {
struct diff_filespec *d1, *d2;
if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
unsigned tmp;
const char *tmp_c;
tmp = mode1; mode1 = mode2; mode2 = tmp;
tmp_c = name1; name1 = name2; name2 = tmp_c;
}
if (!name1)
name1 = "/dev/null";
if (!name2)
name2 = "/dev/null";
d1 = alloc_filespec(name1);
d2 = alloc_filespec(name2);
fill_filespec(d1, null_sha1, mode1);
fill_filespec(d2, null_sha1, mode2);
diff_queue(&diff_queued_diff, d1, d2);
return 0;
}
}
static int path_outside_repo(const char *path)
{
/*
* We have already done setup_git_directory_gently() so we
* know we are inside a git work tree already.
*/
const char *work_tree;
size_t len;
if (!is_absolute_path(path))
return 0;
work_tree = get_git_work_tree();
len = strlen(work_tree);
if (strncmp(path, work_tree, len) ||
(path[len] != '\0' && path[len] != '/'))
return 1;
return 0;
}
void diff_no_index(struct rev_info *revs,
int argc, const char **argv,
int nongit, const char *prefix)
{
int i;
int no_index = 0;
unsigned options = 0;
/* Were we asked to do --no-index explicitly? */
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--"))
return;
if (!strcmp(argv[i], "--no-index"))
no_index = 1;
if (argv[i][0] != '-')
break;
}
if (!no_index && !nongit) {
/*
* Inside a git repository, without --no-index. Only
* when a path outside the repository is given,
* e.g. "git diff /var/tmp/[12]", or "git diff
* Makefile /var/tmp/Makefile", allow it to be used as
* a colourful "diff" replacement.
*/
if ((argc != i + 2) ||
(!path_outside_repo(argv[i]) &&
!path_outside_repo(argv[i+1])))
return;
}
if (argc != i + 2)
die("git diff %s takes two paths",
no_index ? "--no-index" : "[--no-index]");
/*
* If the user asked for our exit code then don't start a
* pager or we would end up reporting its exit code instead.
*/
if (!DIFF_OPT_TST(&revs->diffopt, EXIT_WITH_STATUS))
setup_pager();
diff_setup(&revs->diffopt);
if (!revs->diffopt.output_format)
revs->diffopt.output_format = DIFF_FORMAT_PATCH;
for (i = 1; i < argc - 2; ) {
int j;
if (!strcmp(argv[i], "--no-index"))
i++;
else if (!strcmp(argv[1], "-q"))
options |= DIFF_SILENT_ON_REMOVED;
else {
j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
if (!j)
die("invalid diff option/value: %s", argv[i]);
i += j;
}
}
if (prefix) {
int len = strlen(prefix);
revs->diffopt.paths = xcalloc(2, sizeof(char*));
for (i = 0; i < 2; i++) {
const char *p = argv[argc - 2 + i];
/*
* stdin should be spelled as '-'; if you have
* path that is '-', spell it as ./-.
*/
p = (strcmp(p, "-")
? xstrdup(prefix_filename(prefix, len, p))
: p);
revs->diffopt.paths[i] = p;
}
}
else
revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
revs->max_count = -2;
if (diff_setup_done(&revs->diffopt) < 0)
die("diff_setup_done failed");
if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
revs->diffopt.paths[1]))
exit(1);
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
/*
* The return code for --no-index imitates diff(1):
* 0 = no changes, 1 = changes, else error
*/
exit(revs->diffopt.found_changes);
}

6
diff.h
View File

@@ -251,10 +251,6 @@ extern const char *diff_unique_abbrev(const unsigned char *, int);
/* report racily-clean paths as modified */
#define DIFF_RACY_IS_MODIFIED 02
extern int run_diff_files(struct rev_info *revs, unsigned int option);
extern int setup_diff_no_index(struct rev_info *revs,
int argc, const char ** argv, int nongit, const char *prefix);
extern int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv);
extern int run_diff_index(struct rev_info *revs, int cached);
extern int do_diff_cache(const unsigned char *, struct diff_options *);
@@ -262,4 +258,6 @@ extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
extern int diff_result_code(struct diff_options *, int);
extern void diff_no_index(struct rev_info *, int, const char **, int, const char *);
#endif /* DIFF_H */

View File

@@ -890,7 +890,7 @@ static char *create_index(void)
SHA1_Update(&ctx, (*c)->sha1, 20);
}
sha1write(f, pack_data->sha1, sizeof(pack_data->sha1));
sha1close(f, NULL, 1);
sha1close(f, NULL, CSUM_FSYNC);
free(idx);
SHA1_Final(pack_data->sha1, &ctx);
return tmpfile;

View File

@@ -44,7 +44,7 @@ sq() {
}
bisect_autostart() {
test -f "$GIT_DIR/BISECT_NAMES" || {
test -s "$GIT_DIR/BISECT_START" || {
echo >&2 'You need to start by "git bisect start"'
if test -t 0
then
@@ -98,7 +98,7 @@ bisect_start() {
#
# Get rid of any old bisect state.
#
bisect_clean_state
bisect_clean_state || exit
#
# Check for one bad and then some good revisions.
@@ -146,8 +146,8 @@ bisect_start() {
#
# Write new start state.
#
sq "$@" >"$GIT_DIR/BISECT_NAMES" &&
echo "$start_head" >"$GIT_DIR/BISECT_START" &&
sq "$@" >"$GIT_DIR/BISECT_NAMES" &&
eval "$eval" &&
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
#
@@ -226,7 +226,7 @@ bisect_next_check() {
;;
*)
THEN=''
test -f "$GIT_DIR/BISECT_NAMES" || {
test -s "$GIT_DIR/BISECT_START" || {
echo >&2 'You need to start by "git bisect start".'
THEN='then '
}
@@ -392,16 +392,12 @@ bisect_visualize() {
}
bisect_reset() {
test -f "$GIT_DIR/BISECT_NAMES" || {
test -s "$GIT_DIR/BISECT_START" || {
echo "We are not bisecting."
return
}
case "$#" in
0) if [ -s "$GIT_DIR/BISECT_START" ]; then
branch=`cat "$GIT_DIR/BISECT_START"`
else
branch=master
fi ;;
0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
1) git show-ref --verify --quiet -- "refs/heads/$1" ||
die "$1 does not seem to be a valid branch"
branch="$1" ;;
@@ -416,14 +412,15 @@ bisect_clean_state() {
git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* |
while read ref hash
do
git update-ref -d $ref $hash
git update-ref -d $ref $hash || exit
done
rm -f "$GIT_DIR/BISECT_START"
rm -f "$GIT_DIR/BISECT_LOG"
rm -f "$GIT_DIR/BISECT_NAMES"
rm -f "$GIT_DIR/BISECT_RUN"
rm -f "$GIT_DIR/BISECT_LOG" &&
rm -f "$GIT_DIR/BISECT_NAMES" &&
rm -f "$GIT_DIR/BISECT_RUN" &&
# Cleanup head-name if it got left by an old version of git-bisect
rm -f "$GIT_DIR/head-name"
rm -f "$GIT_DIR/head-name" &&
rm -f "$GIT_DIR/BISECT_START"
}
bisect_replay () {

View File

@@ -234,7 +234,7 @@ case "$filter_subdir" in
;;
*)
git rev-list --reverse --topo-order --default HEAD \
--parents --full-history "$@" -- "$filter_subdir"
--parents "$@" -- "$filter_subdir"
esac > ../revs || die "Could not get the commits"
commits=$(wc -l <../revs | tr -d " ")

View File

@@ -122,6 +122,14 @@ set _reponame {}
set _iscygwin {}
set _search_path {}
set _trace [lsearch -exact $argv --trace]
if {$_trace >= 0} {
set argv [lreplace $argv $_trace $_trace]
set _trace 1
} else {
set _trace 0
}
proc appname {} {
global _appname
return $_appname
@@ -245,6 +253,21 @@ proc get_config {name} {
##
## handy utils
proc _trace_exec {cmd} {
if {!$::_trace} return
set d {}
foreach v $cmd {
if {$d ne {}} {
append d { }
}
if {[regexp {[ \t\r\n'"$?*]} $v]} {
set v [sq $v]
}
append d $v
}
puts stderr $d
}
proc _git_cmd {name} {
global _git_cmd_path
@@ -339,7 +362,7 @@ proc _lappend_nice {cmd_var} {
}
proc git {args} {
set opt [list exec]
set opt [list]
while {1} {
switch -- [lindex $args 0] {
@@ -359,12 +382,18 @@ proc git {args} {
set cmdp [_git_cmd [lindex $args 0]]
set args [lrange $args 1 end]
return [eval $opt $cmdp $args]
_trace_exec [concat $opt $cmdp $args]
set result [eval exec $opt $cmdp $args]
if {$::_trace} {
puts stderr "< $result"
}
return $result
}
proc _open_stdout_stderr {cmd} {
_trace_exec $cmd
if {[catch {
set fd [open $cmd r]
set fd [open [concat [list | ] $cmd] r]
} err]} {
if { [lindex $cmd end] eq {2>@1}
&& $err eq {can not find channel named "1"}
@@ -375,6 +404,7 @@ proc _open_stdout_stderr {cmd} {
# to try to start it a second time.
#
set fd [open [concat \
[list | ] \
[lrange $cmd 0 end-1] \
[list |& cat] \
] r]
@@ -387,7 +417,7 @@ proc _open_stdout_stderr {cmd} {
}
proc git_read {args} {
set opt [list |]
set opt [list]
while {1} {
switch -- [lindex $args 0] {
@@ -415,7 +445,7 @@ proc git_read {args} {
}
proc git_write {args} {
set opt [list |]
set opt [list]
while {1} {
switch -- [lindex $args 0] {
@@ -435,7 +465,8 @@ proc git_write {args} {
set cmdp [_git_cmd [lindex $args 0]]
set args [lrange $args 1 end]
return [open [concat $opt $cmdp $args] w]
_trace_exec [concat $opt $cmdp $args]
return [open [concat [list | ] $opt $cmdp $args] w]
}
proc githook_read {hook_name args} {
@@ -455,12 +486,12 @@ proc githook_read {hook_name args} {
}
set scr {if test -x "$1";then exec "$@";fi}
set sh_c [list | $interp -c $scr $interp $pchook]
set sh_c [list $interp -c $scr $interp $pchook]
return [_open_stdout_stderr [concat $sh_c $args]]
}
if {[file executable $pchook]} {
return [_open_stdout_stderr [concat [list | $pchook] $args]]
return [_open_stdout_stderr [concat [list $pchook] $args]]
}
return {}
@@ -1096,27 +1127,18 @@ proc rescan {after {honor_trustmtime 1}} {
}
if {[is_Cygwin]} {
set is_git_info_link {}
set is_git_info_exclude {}
proc have_info_exclude {} {
global is_git_info_link is_git_info_exclude
global is_git_info_exclude
if {$is_git_info_link eq {}} {
set is_git_info_link [file isfile [gitdir info.lnk]]
}
if {$is_git_info_link} {
if {$is_git_info_exclude eq {}} {
if {[catch {exec test -f [gitdir info exclude]}]} {
set is_git_info_exclude 0
} else {
set is_git_info_exclude 1
}
if {$is_git_info_exclude eq {}} {
if {[catch {exec test -f [gitdir info exclude]}]} {
set is_git_info_exclude 0
} else {
set is_git_info_exclude 1
}
return $is_git_info_exclude
} else {
return [file readable [gitdir info exclude]]
}
return $is_git_info_exclude
}
} else {
proc have_info_exclude {} {

View File

@@ -388,9 +388,7 @@ method _do_new {} {
-command [cb _new_local_path]
set w_localpath $w_body.where.t
pack $w_body.where.b -side right
pack $w_body.where.l -side left
pack $w_body.where.t -fill x
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
pack $w_body.where -fill x
trace add variable @local_path write [cb _write_local_path]
@@ -987,9 +985,7 @@ method _do_open {} {
-text [mc "Browse"] \
-command [cb _open_local_path]
pack $w_body.where.b -side right
pack $w_body.where.l -side left
pack $w_body.where.t -fill x
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
pack $w_body.where -fill x
trace add variable @local_path write [cb _write_local_path]

View File

@@ -475,6 +475,9 @@ do
require_clean_work_tree
UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
test -z "$ONTO" && ONTO=$UPSTREAM
if test ! -z "$2"
then
output git show-ref --verify --quiet "refs/heads/$2" ||
@@ -484,12 +487,8 @@ do
fi
HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
test -z "$ONTO" && ONTO=$UPSTREAM
: > "$DOTEST"/interactive || die "Could not mark as interactive"
git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
echo "detached HEAD" > "$DOTEST"/head-name

View File

@@ -125,7 +125,6 @@ then
# We know $existing are all redundant.
if [ -n "$existing" ]
then
sync
( cd "$PACKDIR" &&
for e in $existing
do

View File

@@ -177,6 +177,7 @@ my %cmd = (
'strategy|s=s' => \$_strategy,
'local|l' => \$_local,
'fetch-all|all' => \$_fetch_all,
'dry-run|n' => \$_dry_run,
%fc_opts } ],
'commit-diff' => [ \&cmd_commit_diff,
'Commit a diff between two trees',
@@ -557,6 +558,11 @@ sub cmd_rebase {
die "Unable to determine upstream SVN information from ",
"working tree history\n";
}
if ($_dry_run) {
print "Remote Branch: " . $gs->refname . "\n";
print "SVN URL: " . $url . "\n";
return;
}
if (command(qw/diff-index HEAD --/)) {
print STDERR "Cannot rebase with uncommited changes:\n";
command_noisy('status');
@@ -745,7 +751,7 @@ sub cmd_commit_diff {
my $usage = "Usage: $0 commit-diff -r<revision> ".
"<tree-ish> <tree-ish> [<URL>]";
fatal($usage) if (!defined $ta || !defined $tb);
my $svn_path;
my $svn_path = '';
if (!defined $url) {
my $gs = eval { Git::SVN->new };
if (!$gs) {
@@ -769,7 +775,6 @@ sub cmd_commit_diff {
$_message ||= get_commit_entry($tb)->{log};
}
my $ra ||= Git::SVN::Ra->new($url);
$svn_path ||= $ra->{svn_path};
my $r = $_revision;
if ($r eq 'HEAD') {
$r = $ra->get_latest_revnum;
@@ -1918,7 +1923,7 @@ sub prop_walk {
foreach (sort keys %$dirent) {
next if $dirent->{$_}->{kind} != $SVN::Node::dir;
$self->prop_walk($p . $_, $rev, $sub);
$self->prop_walk($self->{path} . $p . $_, $rev, $sub);
}
}
@@ -3191,7 +3196,7 @@ sub apply_textdelta {
if ($fb->{blob}) {
print $base 'link ' if ($fb->{mode_a} == 120000);
my $size = $::_repository->cat_blob($fb->{blob}, $base);
die "Failed to read object $fb->{blob}" unless $size;
die "Failed to read object $fb->{blob}" if ($size < 0);
if (defined $exp) {
seek $base, 0, 0 or croak $!;
@@ -3570,7 +3575,7 @@ sub chg_file {
$self->change_file_prop($fbat,'svn:special',undef);
}
my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
croak "Failed to read object $m->{sha1_b}" unless $size;
croak "Failed to read object $m->{sha1_b}" if ($size < 0);
$fh->flush == 0 or croak $!;
seek $fh, 0, 0 or croak $!;

2
git.c
View File

@@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "describe", cmd_describe, RUN_SETUP },
{ "diff", cmd_diff },
{ "diff-files", cmd_diff_files },
{ "diff-files", cmd_diff_files, RUN_SETUP },
{ "diff-index", cmd_diff_index, RUN_SETUP },
{ "diff-tree", cmd_diff_tree, RUN_SETUP },
{ "fast-export", cmd_fast_export, RUN_SETUP },

View File

@@ -2623,7 +2623,7 @@ EOF
print "</div>\n";
my ($have_search) = gitweb_check_feature('search');
if ((defined $project) && ($have_search)) {
if (defined $project && $have_search) {
if (!defined $searchtext) {
$searchtext = "";
}
@@ -2639,16 +2639,13 @@ EOF
my ($use_pathinfo) = gitweb_check_feature('pathinfo');
if ($use_pathinfo) {
$action .= "/".esc_url($project);
} else {
$cgi->param("p", $project);
}
$cgi->param("a", "search");
$cgi->param("h", $search_hash);
print $cgi->startform(-method => "get", -action => $action) .
"<div class=\"search\">\n" .
(!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .
$cgi->hidden(-name => "a") . "\n" .
$cgi->hidden(-name => "h") . "\n" .
(!$use_pathinfo &&
$cgi->input({-name=>"p", -value=>$project, -type=>"hidden"}) . "\n") .
$cgi->input({-name=>"a", -value=>"search", -type=>"hidden"}) . "\n" .
$cgi->input({-name=>"h", -value=>$search_hash, -type=>"hidden"}) . "\n" .
$cgi->popup_menu(-name => 'st', -default => 'commit',
-values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .
$cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) .
@@ -2756,7 +2753,7 @@ sub git_print_page_nav {
}
sub format_paging_nav {
my ($action, $hash, $head, $page, $nrevs) = @_;
my ($action, $hash, $head, $page, $has_next_link) = @_;
my $paging_nav;
@@ -2774,7 +2771,7 @@ sub format_paging_nav {
$paging_nav .= " &sdot; prev";
}
if ($nrevs >= (100 * ($page+1)-1)) {
if ($has_next_link) {
$paging_nav .= " &sdot; " .
$cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
@@ -4665,7 +4662,7 @@ sub git_log {
my @commitlist = parse_commits($hash, 101, (100 * $page));
my $paging_nav = format_paging_nav('log', $hash, $head, $page, (100 * ($page+1)));
my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
git_header_html();
git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
@@ -5585,7 +5582,7 @@ sub git_shortlog {
my @commitlist = parse_commits($hash, 101, (100 * $page));
my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, (100 * ($page+1)));
my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
my $next_link = '';
if ($#commitlist >= 100) {
$next_link =

View File

@@ -1,2 +0,0 @@
Märchen
M<EFBFBD>rchen

View File

@@ -1,4 +0,0 @@
This
filename
contains
spaces.

View File

@@ -1,6 +0,0 @@
This
filename
contains
+
plus
chars.

123
graph.c
View File

@@ -80,6 +80,27 @@ struct git_graph {
* This tells us what kind of line graph_next_line() should output.
*/
enum graph_state state;
/*
* The output state for the previous line of output.
* This is primarily used to determine how the first merge line
* should appear, based on the last line of the previous commit.
*/
enum graph_state prev_state;
/*
* The index of the column that refers to this commit.
*
* If none of the incoming columns refer to this commit,
* this will be equal to num_columns.
*/
int commit_index;
/*
* The commit_index for the previously displayed commit.
*
* This is used to determine how the first line of a merge
* graph output should appear, based on the last line of the
* previous commit.
*/
int prev_commit_index;
/*
* The maximum number of columns that can be stored in the columns
* and new_columns arrays. This is also half the number of entries
@@ -137,6 +158,9 @@ struct git_graph *graph_init(struct rev_info *opt)
graph->num_parents = 0;
graph->expansion_row = 0;
graph->state = GRAPH_PADDING;
graph->prev_state = GRAPH_PADDING;
graph->commit_index = 0;
graph->prev_commit_index = 0;
graph->num_columns = 0;
graph->num_new_columns = 0;
graph->mapping_size = 0;
@@ -164,6 +188,12 @@ void graph_release(struct git_graph *graph)
free(graph);
}
static void graph_update_state(struct git_graph *graph, enum graph_state s)
{
graph->prev_state = graph->state;
graph->state = s;
}
static void graph_ensure_capacity(struct git_graph *graph, int num_columns)
{
if (graph->column_capacity >= num_columns)
@@ -342,6 +372,7 @@ static void graph_update_columns(struct git_graph *graph)
if (col_commit == graph->commit) {
int old_mapping_idx = mapping_idx;
seen_this = 1;
graph->commit_index = i;
for (parent = graph->commit->parents;
parent;
parent = parent->next) {
@@ -394,6 +425,13 @@ void graph_update(struct git_graph *graph, struct commit *commit)
graph->num_parents++;
}
/*
* Store the old commit_index in prev_commit_index.
* graph_update_columns() will update graph->commit_index for this
* commit.
*/
graph->prev_commit_index = graph->commit_index;
/*
* Call graph_update_columns() to update
* columns, new_columns, and mapping.
@@ -404,21 +442,26 @@ void graph_update(struct git_graph *graph, struct commit *commit)
/*
* Update graph->state.
* Note that we don't call graph_update_state() here, since
* we don't want to update graph->prev_state. No line for
* graph->state was ever printed.
*
* If the previous commit didn't get to the GRAPH_PADDING state,
* it never finished its output. Goto GRAPH_SKIP, to print out
* a line to indicate that portion of the graph is missing.
*
* Otherwise, if there are 3 or more parents, we need to print
* extra rows before the commit, to expand the branch lines around
* it and make room for it.
* If there are 3 or more parents, we may need to print extra rows
* before the commit, to expand the branch lines around it and make
* room for it. We need to do this only if there is a branch row
* (or more) to the right of this commit.
*
* If there are less than 3 parents, we can immediately print the
* commit line.
*/
if (graph->state != GRAPH_PADDING)
graph->state = GRAPH_SKIP;
else if (graph->num_parents >= 3)
else if (graph->num_parents >= 3 &&
graph->commit_index < (graph->num_columns - 1))
graph->state = GRAPH_PRE_COMMIT;
else
graph->state = GRAPH_COMMIT;
@@ -497,10 +540,11 @@ static void graph_output_skip_line(struct git_graph *graph, struct strbuf *sb)
strbuf_addstr(sb, "...");
graph_pad_horizontally(graph, sb);
if (graph->num_parents >= 3)
graph->state = GRAPH_PRE_COMMIT;
if (graph->num_parents >= 3 &&
graph->commit_index < (graph->num_columns - 1))
graph_update_state(graph, GRAPH_PRE_COMMIT);
else
graph->state = GRAPH_COMMIT;
graph_update_state(graph, GRAPH_COMMIT);
}
static void graph_output_pre_commit_line(struct git_graph *graph,
@@ -535,7 +579,22 @@ static void graph_output_pre_commit_line(struct git_graph *graph,
if (col->commit == graph->commit) {
seen_this = 1;
strbuf_addf(sb, "| %*s", graph->expansion_row, "");
} else if (seen_this) {
} else if (seen_this && (graph->expansion_row == 0)) {
/*
* This is the first line of the pre-commit output.
* If the previous commit was a merge commit and
* ended in the GRAPH_POST_MERGE state, all branch
* lines after graph->prev_commit_index were
* printed as "\" on the previous line. Continue
* to print them as "\" on this line. Otherwise,
* print the branch lines as "|".
*/
if (graph->prev_state == GRAPH_POST_MERGE &&
graph->prev_commit_index < i)
strbuf_addstr(sb, "\\ ");
else
strbuf_addstr(sb, "| ");
} else if (seen_this && (graph->expansion_row > 0)) {
strbuf_addstr(sb, "\\ ");
} else {
strbuf_addstr(sb, "| ");
@@ -550,7 +609,7 @@ static void graph_output_pre_commit_line(struct git_graph *graph,
*/
graph->expansion_row++;
if (graph->expansion_row >= num_expansion_rows)
graph->state = GRAPH_COMMIT;
graph_update_state(graph, GRAPH_COMMIT);
}
static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
@@ -625,10 +684,8 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
seen_this = 1;
graph_output_commit_char(graph, sb);
if (graph->num_parents < 2)
if (graph->num_parents < 3)
strbuf_addch(sb, ' ');
else if (graph->num_parents == 2)
strbuf_addstr(sb, " ");
else {
int num_dashes =
((graph->num_parents - 2) * 2) - 1;
@@ -636,8 +693,27 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
strbuf_addch(sb, '-');
strbuf_addstr(sb, ". ");
}
} else if (seen_this && (graph->num_parents > 1)) {
} else if (seen_this && (graph->num_parents > 2)) {
strbuf_addstr(sb, "\\ ");
} else if (seen_this && (graph->num_parents == 2)) {
/*
* This is a 2-way merge commit.
* There is no GRAPH_PRE_COMMIT stage for 2-way
* merges, so this is the first line of output
* for this commit. Check to see what the previous
* line of output was.
*
* If it was GRAPH_POST_MERGE, the branch line
* coming into this commit may have been '\',
* and not '|' or '/'. If so, output the branch
* line as '\' on this line, instead of '|'. This
* makes the output look nicer.
*/
if (graph->prev_state == GRAPH_POST_MERGE &&
graph->prev_commit_index < i)
strbuf_addstr(sb, "\\ ");
else
strbuf_addstr(sb, "| ");
} else {
strbuf_addstr(sb, "| ");
}
@@ -649,11 +725,11 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
* Update graph->state
*/
if (graph->num_parents > 1)
graph->state = GRAPH_POST_MERGE;
graph_update_state(graph, GRAPH_POST_MERGE);
else if (graph_is_mapping_correct(graph))
graph->state = GRAPH_PADDING;
graph_update_state(graph, GRAPH_PADDING);
else
graph->state = GRAPH_COLLAPSING;
graph_update_state(graph, GRAPH_COLLAPSING);
}
void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb)
@@ -679,9 +755,7 @@ void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb)
strbuf_addch(sb, '|');
for (j = 0; j < graph->num_parents - 1; j++)
strbuf_addstr(sb, "\\ ");
if (graph->num_parents == 2)
strbuf_addch(sb, ' ');
} else if (seen_this && (graph->num_parents > 2)) {
} else if (seen_this) {
strbuf_addstr(sb, "\\ ");
} else {
strbuf_addstr(sb, "| ");
@@ -694,9 +768,9 @@ void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb)
* Update graph->state
*/
if (graph_is_mapping_correct(graph))
graph->state = GRAPH_PADDING;
graph_update_state(graph, GRAPH_PADDING);
else
graph->state = GRAPH_COLLAPSING;
graph_update_state(graph, GRAPH_COLLAPSING);
}
void graph_output_collapsing_line(struct git_graph *graph, struct strbuf *sb)
@@ -801,7 +875,7 @@ void graph_output_collapsing_line(struct git_graph *graph, struct strbuf *sb)
* Otherwise, we need to collapse some branch lines together.
*/
if (graph_is_mapping_correct(graph))
graph->state = GRAPH_PADDING;
graph_update_state(graph, GRAPH_PADDING);
}
int graph_next_line(struct git_graph *graph, struct strbuf *sb)
@@ -865,6 +939,11 @@ void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
}
graph_pad_horizontally(graph, sb);
/*
* Update graph->prev_state since we have output a padding line
*/
graph->prev_state = GRAPH_PADDING;
}
int graph_is_commit_finished(struct git_graph const *graph)

View File

@@ -2277,6 +2277,7 @@ int main(int argc, char **argv)
signal(SIGINT, remove_locks_on_signal);
signal(SIGHUP, remove_locks_on_signal);
signal(SIGQUIT, remove_locks_on_signal);
signal(SIGTERM, remove_locks_on_signal);
/* Check whether the remote has server info files */
remote->can_update_info_refs = 0;

View File

@@ -694,6 +694,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
if (!from_stdin) {
close(input_fd);
} else {
fsync_or_die(output_fd, curr_pack_name);
err = close(output_fd);
if (err)
die("error while closing pack file: %s", strerror(errno));

View File

@@ -135,6 +135,9 @@ static int lock_file(struct lock_file *lk, const char *path)
if (0 <= lk->fd) {
if (!lock_file_list) {
signal(SIGINT, remove_lock_file_on_signal);
signal(SIGHUP, remove_lock_file_on_signal);
signal(SIGTERM, remove_lock_file_on_signal);
signal(SIGQUIT, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
lk->owner = getpid();

View File

@@ -25,10 +25,10 @@ static int verify_packfile(struct packed_git *p,
off_t index_size = p->index_size;
const unsigned char *index_base = p->index_data;
SHA_CTX ctx;
unsigned char sha1[20];
off_t offset = 0, pack_sig = p->pack_size - 20;
unsigned char sha1[20], *pack_sig;
off_t offset = 0, pack_sig_ofs = p->pack_size - 20;
uint32_t nr_objects, i;
int err;
int err = 0;
struct idx_entry *entries;
/* Note that the pack header checks are actually performed by
@@ -38,21 +38,22 @@ static int verify_packfile(struct packed_git *p,
*/
SHA1_Init(&ctx);
while (offset < pack_sig) {
while (offset < pack_sig_ofs) {
unsigned int remaining;
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
offset += remaining;
if (offset > pack_sig)
remaining -= (unsigned int)(offset - pack_sig);
if (offset > pack_sig_ofs)
remaining -= (unsigned int)(offset - pack_sig_ofs);
SHA1_Update(&ctx, in, remaining);
}
SHA1_Final(sha1, &ctx);
if (hashcmp(sha1, use_pack(p, w_curs, pack_sig, NULL)))
return error("Packfile %s SHA1 mismatch with itself",
p->pack_name);
if (hashcmp(sha1, index_base + index_size - 40))
return error("Packfile %s SHA1 mismatch with idx",
p->pack_name);
pack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);
if (hashcmp(sha1, pack_sig))
err = error("%s SHA1 checksum mismatch",
p->pack_name);
if (hashcmp(index_base + index_size - 40, pack_sig))
err = error("%s SHA1 does not match its inddex",
p->pack_name);
unuse_pack(w_curs);
/* Make sure everything reachable from idx is valid. Since we
@@ -72,22 +73,23 @@ static int verify_packfile(struct packed_git *p,
}
qsort(entries, nr_objects, sizeof(*entries), compare_entries);
for (i = 0, err = 0; i < nr_objects; i++) {
for (i = 0; i < nr_objects; i++) {
void *data;
enum object_type type;
unsigned long size;
data = unpack_entry(p, entries[i].offset, &type, &size);
if (!data) {
err = error("cannot unpack %s from %s",
sha1_to_hex(entries[i].sha1), p->pack_name);
continue;
err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
sha1_to_hex(entries[i].sha1), p->pack_name,
(uintmax_t)entries[i].offset);
break;
}
if (check_sha1_signature(entries[i].sha1, data, size, typename(type))) {
err = error("packed %s from %s is corrupt",
sha1_to_hex(entries[i].sha1), p->pack_name);
free(data);
continue;
break;
}
free(data);
}
@@ -158,31 +160,28 @@ int verify_pack(struct packed_git *p, int verbose)
const unsigned char *index_base;
SHA_CTX ctx;
unsigned char sha1[20];
int ret;
int err = 0;
struct pack_window *w_curs = NULL;
if (open_pack_index(p))
return error("packfile %s index not opened", p->pack_name);
index_size = p->index_size;
index_base = p->index_data;
ret = 0;
/* Verify SHA1 sum of the index file */
SHA1_Init(&ctx);
SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));
SHA1_Final(sha1, &ctx);
if (hashcmp(sha1, index_base + index_size - 20))
ret = error("Packfile index for %s SHA1 mismatch",
err = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
if (!ret) {
/* Verify pack file */
struct pack_window *w_curs = NULL;
ret = verify_packfile(p, &w_curs);
unuse_pack(&w_curs);
}
/* Verify pack file */
err |= verify_packfile(p, &w_curs);
unuse_pack(&w_curs);
if (verbose) {
if (ret)
if (err)
printf("%s: bad\n", p->pack_name);
else {
show_pack_info(p);
@@ -190,5 +189,5 @@ int verify_pack(struct packed_git *p, int verbose)
}
}
return ret;
return err;
}

View File

@@ -139,7 +139,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
}
sha1write(f, sha1, 20);
sha1close(f, NULL, 1);
sha1close(f, NULL, CSUM_FSYNC);
SHA1_Final(sha1, &ctx);
return index_name;
}

View File

@@ -565,7 +565,7 @@ sub config {
my $E = shift;
if ($E->value() == 1) {
# Key not found.
return undef;
return;
} else {
throw $E;
}
@@ -719,9 +719,8 @@ sub ident_person {
=item hash_object ( TYPE, FILENAME )
Compute the SHA1 object id of the given C<FILENAME> (or data waiting in
C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>,
C<commit>, C<tree>).
Compute the SHA1 object id of the given C<FILENAME> considering it is
of the C<TYPE> object type (C<blob>, C<commit>, C<tree>).
The method can be called without any instance or on a specified Git repository,
it makes zero difference.
@@ -811,12 +810,12 @@ sub cat_blob {
my $description = <$in>;
if ($description =~ / missing$/) {
carp "$sha1 doesn't exist in the repository";
return 0;
return -1;
}
if ($description !~ /^[0-9a-fA-F]{40} \S+ (\d+)$/) {
carp "Unexpected result returned from git cat-file";
return 0;
return -1;
}
my $size = $1;

View File

@@ -893,6 +893,15 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
if (ce_uptodate(ce))
return ce;
/*
* CE_VALID means the user promised us that the change to
* the work tree does not matter and told us not to worry.
*/
if (!ignore_valid && (ce->ce_flags & CE_VALID)) {
ce_mark_uptodate(ce);
return ce;
}
if (lstat(ce->name, &st) < 0) {
if (err)
*err = errno;

View File

@@ -181,7 +181,7 @@ char *sha1_file_name(const unsigned char *sha1)
}
static char *sha1_get_pack_name(const unsigned char *sha1,
char **name, char **base)
char **name, char **base, const char *which)
{
static const char hex[] = "0123456789abcdef";
char *buf;
@@ -191,7 +191,8 @@ static char *sha1_get_pack_name(const unsigned char *sha1,
const char *sha1_file_directory = get_object_directory();
int len = strlen(sha1_file_directory);
*base = xmalloc(len + 60);
sprintf(*base, "%s/pack/pack-1234567890123456789012345678901234567890.pack", sha1_file_directory);
sprintf(*base, "%s/pack/pack-1234567890123456789012345678901234567890.%s",
sha1_file_directory, which);
*name = *base + len + 11;
}
@@ -210,14 +211,14 @@ char *sha1_pack_name(const unsigned char *sha1)
{
static char *name, *base;
return sha1_get_pack_name(sha1, &name, &base);
return sha1_get_pack_name(sha1, &name, &base, "pack");
}
char *sha1_pack_index_name(const unsigned char *sha1)
{
static char *name, *base;
return sha1_get_pack_name(sha1, &name, &base);
return sha1_get_pack_name(sha1, &name, &base, "idx");
}
struct alternate_object_database *alt_odb_list;

View File

@@ -11,7 +11,7 @@ compare_diff_raw () {
sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
@@ -23,7 +23,7 @@ compare_diff_raw_z () {
perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
compare_diff_patch () {
@@ -37,5 +37,5 @@ compare_diff_patch () {
/^[dis]*imilarity index [0-9]*%$/d
/^index [0-9a-f]*\.\.[0-9a-f]/d
' <"$2" >.tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}

View File

@@ -79,6 +79,17 @@ test_expect_success 'GIT_DIR bare' '
check_config git-dir-bare.git true unset
'
test_expect_success 'init --bare' '
(
unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
mkdir git-init-bare.git &&
cd git-init-bare.git &&
git init --bare
) &&
check_config git-init-bare.git true unset
'
test_expect_success 'GIT_DIR non-bare' '
(

View File

@@ -16,96 +16,96 @@ test_expect_success \
'long lines without spaces should be unchanged' '
echo "$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$ttt$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$ttt$ttt$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
'lines with spaces at the beginning should be unchanged' '
echo "$sss$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$sss$sss$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$sss$sss$sss$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
'lines with intermediate spaces should be unchanged' '
echo "$ttt$sss$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$sss$sss$ttt" >expect &&
git stripspace <expect >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
'consecutive blank lines should be unified' '
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
@@ -113,114 +113,114 @@ test_expect_success \
> expect &&
printf "\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
'consecutive blank lines at the beginning should be removed' '
printf "$ttt\n" > expect &&
printf "\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
'consecutive blank lines at the end should be removed' '
printf "$ttt\n" > expect &&
printf "$ttt\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n" > expect &&
printf "$ttt$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt$ttt\n" > expect &&
printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
@@ -257,27 +257,27 @@ test_expect_success \
'text plus spaces without newline should show the correct lines' '
printf "$ttt\n" >expect &&
printf "$ttt$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n" >expect &&
printf "$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n" >expect &&
printf "$ttt$sss$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n" >expect &&
printf "$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n" >expect &&
printf "$ttt$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt$ttt\n" >expect &&
printf "$ttt$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
@@ -294,27 +294,27 @@ test_expect_success \
'text plus spaces at end should be cleaned and newline must remain' '
echo "$ttt" >expect &&
echo "$ttt$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt" >expect &&
echo "$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt" >expect &&
echo "$ttt$sss$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$ttt" >expect &&
echo "$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$ttt" >expect &&
echo "$ttt$ttt$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$ttt$ttt$ttt" >expect &&
echo "$ttt$ttt$ttt$sss" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
# spaces only:
@@ -324,19 +324,19 @@ test_expect_success \
printf "" >expect &&
echo | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$sss$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
echo "$sss$sss$sss$sss" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
@@ -353,43 +353,43 @@ test_expect_success \
printf "" >expect &&
printf "" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss$sss" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$sss$sss$sss$sss" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success \
'consecutive text lines should be unchanged' '
printf "$ttt$ttt\n$ttt\n" >expect &&
printf "$ttt$ttt\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n$ttt$ttt\n$ttt\n" >expect &&
printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect &&
printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect &&
printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect &&
printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
git diff expect actual &&
test_cmp expect actual &&
printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect &&
printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual &&
git diff expect actual
test_cmp expect actual
'
test_expect_success 'strip comments, too' '

View File

@@ -29,7 +29,7 @@ EOF
test_expect_success 'test help' '
! test-parse-options -h > output 2> output.err &&
test ! -s output &&
git diff expect.err output.err
test_cmp expect.err output.err
'
cat > expect << EOF
@@ -40,7 +40,7 @@ EOF
test_expect_success 'short options' '
test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
git diff expect output &&
test_cmp expect output &&
test ! -s output.err
'
cat > expect << EOF
@@ -53,7 +53,7 @@ test_expect_success 'long options' '
test-parse-options --boolean --integer 1729 --boolean --string2=321 \
> output 2> output.err &&
test ! -s output.err &&
git diff expect output
test_cmp expect output
'
cat > expect << EOF
@@ -69,7 +69,7 @@ test_expect_success 'intermingled arguments' '
test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
> output 2> output.err &&
test ! -s output.err &&
git diff expect output
test_cmp expect output
'
cat > expect << EOF
@@ -81,13 +81,13 @@ EOF
test_expect_success 'unambiguously abbreviated option' '
test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
test ! -s output.err &&
git diff expect output
test_cmp expect output
'
test_expect_success 'unambiguously abbreviated option with "="' '
test-parse-options --int=2 > output 2> output.err &&
test ! -s output.err &&
git diff expect output
test_cmp expect output
'
test_expect_success 'ambiguously abbreviated option' '
@@ -104,7 +104,7 @@ EOF
test_expect_success 'non ambiguous option (after two options it abbreviates)' '
test-parse-options --st 123 > output 2> output.err &&
test ! -s output.err &&
git diff expect output
test_cmp expect output
'
cat > expect.err << EOF
@@ -114,7 +114,7 @@ EOF
test_expect_success 'detect possible typos' '
! test-parse-options -boolean > output 2> output.err &&
test ! -s output &&
git diff expect.err output.err
test_cmp expect.err output.err
'
cat > expect <<EOF
@@ -127,7 +127,7 @@ EOF
test_expect_success 'keep some options as arguments' '
test-parse-options --quux > output 2> output.err &&
test ! -s output.err &&
git diff expect output
test_cmp expect output
'
test_done

View File

@@ -131,7 +131,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
check_result () {
git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
git diff expected current
test_cmp expected current
}
# This is done on an empty work directory, which is the normal

View File

@@ -33,7 +33,7 @@ compare_change () {
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
"$1"
git diff expected current
test_cmp expected current
}
check_cache_at () {
@@ -86,7 +86,7 @@ test_expect_success \
'rm -f .git/index &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >1-3.out &&
git diff M.out 1-3.out &&
test_cmp M.out 1-3.out &&
check_cache_at bozbar dirty &&
check_cache_at frotz dirty &&
check_cache_at nitfol dirty'
@@ -101,7 +101,7 @@ test_expect_success \
git update-index --add yomin &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >4.out || return 1
git diff M.out 4.out >4diff.out
git diff --no-index M.out 4.out >4diff.out
compare_change 4diff.out expected &&
check_cache_at yomin clean'
@@ -115,7 +115,7 @@ test_expect_success \
echo yomin yomin >yomin &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >5.out || return 1
git diff M.out 5.out >5diff.out
git diff --no-index M.out 5.out >5diff.out
compare_change 5diff.out expected &&
check_cache_at yomin dirty'
@@ -127,7 +127,7 @@ test_expect_success \
git update-index --add frotz &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >6.out &&
git diff M.out 6.out &&
test_cmp M.out 6.out &&
check_cache_at frotz clean'
test_expect_success \
@@ -140,7 +140,7 @@ test_expect_success \
echo frotz frotz >frotz &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >7.out &&
git diff M.out 7.out &&
test_cmp M.out 7.out &&
check_cache_at frotz dirty'
test_expect_success \
@@ -171,7 +171,7 @@ test_expect_success \
git update-index --add rezrov &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >10.out &&
git diff M.out 10.out'
test_cmp M.out 10.out'
test_expect_success \
'11 - dirty path removed.' \
@@ -216,7 +216,7 @@ test_expect_success \
git update-index --add nitfol &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >14.out || return 1
git diff M.out 14.out >14diff.out
git diff --no-index M.out 14.out >14diff.out
compare_change 14diff.out expected &&
check_cache_at nitfol clean'
@@ -230,7 +230,7 @@ test_expect_success \
echo nitfol nitfol nitfol >nitfol &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >15.out || return 1
git diff M.out 15.out >15diff.out
git diff --no-index M.out 15.out >15diff.out
compare_change 15diff.out expected &&
check_cache_at nitfol dirty'
@@ -262,7 +262,7 @@ test_expect_success \
git update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >18.out &&
git diff M.out 18.out &&
test_cmp M.out 18.out &&
check_cache_at bozbar clean'
test_expect_success \
@@ -275,7 +275,7 @@ test_expect_success \
echo gnusto gnusto >bozbar &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >19.out &&
git diff M.out 19.out &&
test_cmp M.out 19.out &&
check_cache_at bozbar dirty'
test_expect_success \
@@ -287,7 +287,7 @@ test_expect_success \
git update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >20.out &&
git diff M.out 20.out &&
test_cmp M.out 20.out &&
check_cache_at bozbar dirty'
test_expect_success \
@@ -337,7 +337,7 @@ test_expect_success \
git update-index --add DF &&
read_tree_twoway $treeDF $treeDFDF &&
git ls-files --stage >DFDFcheck.out &&
git diff DFDF.out DFDFcheck.out &&
test_cmp DFDF.out DFDFcheck.out &&
check_cache_at DF/DF dirty &&
:'

View File

@@ -22,7 +22,7 @@ compare_change () {
sed >current \
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
git diff expected current
test_cmp expected current
}
check_cache_at () {

View File

@@ -427,13 +427,13 @@ cat > expect << EOF
weird
EOF
test_expect_success "rename succeeded" "git diff expect .git/config"
test_expect_success "rename succeeded" "test_cmp expect .git/config"
test_expect_success "rename non-existing section" '
! git config --rename-section branch."world domination" branch.drei
'
test_expect_success "rename succeeded" "git diff expect .git/config"
test_expect_success "rename succeeded" "test_cmp expect .git/config"
test_expect_success "rename another section" \
'git config --rename-section branch."1 234 blabl/a" branch.drei'
@@ -449,7 +449,7 @@ cat > expect << EOF
weird
EOF
test_expect_success "rename succeeded" "git diff expect .git/config"
test_expect_success "rename succeeded" "test_cmp expect .git/config"
cat >> .git/config << EOF
[branch "zwei"] a = 1 [branch "vier"]
@@ -465,7 +465,7 @@ weird
EOF
test_expect_success "section was removed properly" \
"git diff -u expect .git/config"
"test_cmp expect .git/config"
rm .git/config

View File

@@ -11,7 +11,7 @@ setup() {
check() {
echo "$2" >expected
git config --get "$1" >actual
git diff actual expected
test_cmp actual expected
}
test_expect_success 'modify same key' '

View File

@@ -32,6 +32,14 @@ test_expect_success \
"create $m" \
"git update-ref $m $B $A &&
test $B"' = $(cat .git/'"$m"')'
test_expect_success "fail to delete $m with stale ref" '
test_must_fail git update-ref -d $m $A &&
test $B = "$(cat .git/$m)"
'
test_expect_success "delete $m" '
git update-ref -d $m $B &&
! test -f .git/$m
'
rm -f .git/$m
test_expect_success \
@@ -49,6 +57,14 @@ test_expect_success \
"create $m (by HEAD)" \
"git update-ref HEAD $B $A &&
test $B"' = $(cat .git/'"$m"')'
test_expect_success "fail to delete $m (by HEAD) with stale ref" '
test_must_fail git update-ref -d HEAD $A &&
test $B = $(cat .git/$m)
'
test_expect_success "delete $m (by HEAD)" '
git update-ref -d HEAD $B &&
! test -f .git/$m
'
rm -f .git/$m
test_expect_success '(not) create HEAD with old sha1' "

View File

@@ -37,7 +37,7 @@ C? option C with an optional argument
Extras
extra1 line above used to cause a segfault but no longer does
EOF
git diff expect.err output.err
test_cmp expect.err output.err
'
test_done

View File

@@ -65,7 +65,7 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
git diff expect output'
test_cmp expect output'
# Test \r\n (MSDOS-like systems)
printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
@@ -77,7 +77,7 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
git diff expect output'
test_cmp expect output'
cat > excludes-file << EOF
*.[1-8]

View File

@@ -23,7 +23,7 @@ test_expect_success \
test_expect_success \
'git ls-files without path restriction.' \
'git ls-files --others >output &&
git diff output - <<EOF
test_cmp output - <<EOF
--
-foo
output
@@ -34,7 +34,7 @@ EOF
test_expect_success \
'git ls-files with path restriction.' \
'git ls-files --others path0 >output &&
git diff output - <<EOF
test_cmp output - <<EOF
path0
EOF
'
@@ -42,7 +42,7 @@ EOF
test_expect_success \
'git ls-files with path restriction with --.' \
'git ls-files --others -- path0 >output &&
git diff output - <<EOF
test_cmp output - <<EOF
path0
EOF
'
@@ -50,7 +50,7 @@ EOF
test_expect_success \
'git ls-files with path restriction with -- --.' \
'git ls-files --others -- -- >output &&
git diff output - <<EOF
test_cmp output - <<EOF
--
EOF
'
@@ -58,7 +58,7 @@ EOF
test_expect_success \
'git ls-files with no path restriction.' \
'git ls-files --others -- >output &&
git diff output - <<EOF
test_cmp output - <<EOF
--
-foo
output

View File

@@ -43,7 +43,7 @@ test_expect_success 'setup 1' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
test_expect_success 'setup 2' '
@@ -61,7 +61,7 @@ test_expect_success 'setup 2' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual &&
test_cmp expected actual &&
echo goodbye >>a &&
o2=$(git hash-object a) &&
@@ -82,7 +82,7 @@ test_expect_success 'setup 2' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
test_expect_success 'setup 3' '
@@ -100,7 +100,7 @@ test_expect_success 'setup 3' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual &&
test_cmp expected actual &&
rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
o3=$(git hash-object b/c) &&
@@ -119,7 +119,7 @@ test_expect_success 'setup 3' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
test_expect_success 'setup 4' '
@@ -137,7 +137,7 @@ test_expect_success 'setup 4' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual &&
test_cmp expected actual &&
rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
o4=$(git hash-object a/c) &&
@@ -156,7 +156,7 @@ test_expect_success 'setup 4' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
test_expect_success 'setup 5' '
@@ -174,7 +174,7 @@ test_expect_success 'setup 5' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual &&
test_cmp expected actual &&
rm -f b &&
echo remove-conflict >a &&
@@ -195,7 +195,7 @@ test_expect_success 'setup 5' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -214,7 +214,7 @@ test_expect_success 'setup 6' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
git diff -u expected actual &&
test_cmp expected actual &&
rm -fr d && echo df-3 >d && git add d &&
o6=$(git hash-object d) &&
@@ -233,7 +233,7 @@ test_expect_success 'setup 6' '
echo "100644 $o0 0 c"
echo "100644 $o6 0 d"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
test_expect_success 'merge-recursive simple' '
@@ -265,7 +265,7 @@ test_expect_success 'merge-recursive result' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -297,7 +297,7 @@ test_expect_success 'merge-recursive remove conflict' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -318,7 +318,7 @@ test_expect_success 'merge-recursive result' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -352,7 +352,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -386,7 +386,7 @@ test_expect_success 'merge-recursive d/f conflict result the other way' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -420,7 +420,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
echo "100644 $o0 1 d/e"
echo "100644 $o1 2 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -454,7 +454,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
echo "100644 $o0 1 d/e"
echo "100644 $o1 3 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'
@@ -480,7 +480,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual &&
test_cmp expected actual &&
git read-tree --prefix=a1/ master &&
git ls-files -s >actual &&
@@ -498,7 +498,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
git read-tree --prefix=z/ master &&
git ls-files -s >actual &&
@@ -520,7 +520,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 z/c"
echo "100644 $o1 0 z/d/e"
) >expected &&
git diff -u expected actual
test_cmp expected actual
'

View File

@@ -24,7 +24,7 @@ test_expect_success 'create subprojects' \
git add sub2 &&
git commit -q -m "subprojects added" &&
git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
git diff expected current'
test_cmp expected current'
git branch save HEAD
@@ -62,7 +62,7 @@ test_expect_success 'check if clone works' \
'git ls-files -s >expected &&
git clone -l -s . cloned &&
( cd cloned && git ls-files -s ) >current &&
git diff expected current'
test_cmp expected current'
test_expect_success 'removing and adding subproject' \
'git update-index --force-remove -- sub2 &&

View File

@@ -23,9 +23,9 @@ test "$no_symlinks" && {
test "$1" = -s && shift
date > "$2"
}
function diff () {
test_cmp () {
sed s/^120000/100644/ < "$1" > "$1".doof
git diff "$1".doof "$2"
diff "$1".doof "$2"
}
}
@@ -47,7 +47,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
test_output () {
sed -e "s/ $_x40 / X /" <current >check
diff expected check
test_cmp expected check
}
test_expect_success \

Some files were not shown because too many files have changed in this diff Show More