提交 7d555619 编写于 作者: J Junio C Hamano

Merge branch 'jc/dirwalk-n-cache-tree' into jc/cache-tree

* jc/dirwalk-n-cache-tree: (212 commits)
  builtin-rm: squelch compiler warnings.
  Add builtin "git rm" command
  Move pathspec matching from builtin-add.c into dir.c
  Prevent bogus paths from being added to the index.
  builtin-add: fix unmatched pathspec warnings.
  Remove old "git-add.sh" remnants
  builtin-add: warn on unmatched pathspecs
  Do "git add" as a builtin
  Clean up git-ls-file directory walking library interface
  libify git-ls-files directory traversal
  Add a conversion tool to migrate remote information into the config
  fetch, pull: ask config for remote information
  Fix build procedure for builtin-init-db
  read-tree -m -u: do not overwrite or remove untracked working tree files.
  apply --cached: do not check newly added file in the working tree
  Implement a --dry-run option to git-quiltimport
  Implement git-quiltimport
  Revert "builtin-grep: workaround for non GNU grep."
  builtin-grep: workaround for non GNU grep.
  builtin-grep: workaround for non GNU grep.
  ...
......@@ -79,7 +79,7 @@ clean:
asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<
%.1 %.7 : %.xml
xmlto man $<
xmlto -m callouts.xsl man $<
%.xml : %.txt
asciidoc -b docbook -d manpage -f asciidoc.conf $<
......
......@@ -266,8 +266,8 @@ This recipe appears to work with the current [*1*] Thunderbird from Suse.
The following Thunderbird extensions are needed:
AboutConfig 0.5
http://aboutconfig.mozdev.org/
External Editor 0.5.4
http://extensionroom.mozdev.org/more-info/exteditor
External Editor 0.7.2
http://globs.org/articles.php?lng=en&pg=8
1) Prepare the patch as a text file using your method of choice.
......
<!-- callout.xsl: converts asciidoc callouts to man page format -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="co">
<xsl:value-of select="concat('\fB(',substring-after(@id,'-'),')\fR')"/>
</xsl:template>
<xsl:template match="calloutlist">
<xsl:text>.sp&#10;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&#10;</xsl:text>
</xsl:template>
<xsl:template match="callout">
<xsl:value-of select="concat('\fB',substring-after(@arearefs,'-'),'. \fR')"/>
<xsl:apply-templates/>
<xsl:text>.br&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>
......@@ -64,9 +64,11 @@ core.ignoreStat::
slow, such as Microsoft Windows. See gitlink:git-update-index[1].
False by default.
core.onlyUseSymrefs::
Always use the "symref" format instead of symbolic links for HEAD
and other symbolic reference files. True by default.
core.preferSymlinkRefs::
Instead of the default "symref" format for HEAD
and other symbolic reference files, use symbolic links.
This is sometimes needed to work with old scripts that
expect HEAD to be a symbolic link.
core.repositoryFormatVersion::
Internal variable identifying the repository format and layout
......
......@@ -971,7 +971,7 @@ $ git show-branch --topo-order master mybranch
The first two lines indicate that it is showing the two branches
and the first line of the commit log message from their
top-of-the-tree commits, you are currently on `master` branch
(notice the asterisk `*` character), and the first column for
(notice the asterisk `\*` character), and the first column for
the later output lines is used to show commits contained in the
`master` branch, and the second column for the `mybranch`
branch. Three commits are shown along with their log messages.
......
......@@ -10,6 +10,10 @@
--stat::
Generate a diffstat instead of a patch.
--summary::
Output a condensed summary of extended header information
such as creations, renames and mode changes.
--patch-with-stat::
Generate patch and prepend its diffstat.
......
......@@ -61,7 +61,8 @@ $ git prune
$ git count-objects <2>
$ git repack <3>
$ git prune <4>
------------
+
<1> running without "--full" is usually cheap and assures the
repository health reasonably well.
<2> check how many loose objects there are and how much
......@@ -69,17 +70,16 @@ diskspace is wasted by not repacking.
<3> without "-a" repacks incrementally. repacking every 4-5MB
of loose objects accumulation may be a good rule of thumb.
<4> after repack, prune removes the duplicate loose objects.
------------
Repack a small project into single pack.::
+
------------
$ git repack -a -d <1>
$ git prune
------------
+
<1> pack all the objects reachable from the refs into one pack
and remove unneeded other packs
------------
Individual Developer (Standalone)[[Individual Developer (Standalone)]]
......@@ -129,10 +129,10 @@ $ git-init-db
$ git add . <1>
$ git commit -m 'import of frotz source tree.'
$ git tag v2.43 <2>
------------
+
<1> add everything under the current directory.
<2> make a lightweight, unannotated tag.
------------
Create a topic branch and develop.::
+
......@@ -153,7 +153,8 @@ $ git checkout master <9>
$ git pull . alsa-audio <10>
$ git log --since='3 days ago' <11>
$ git log v2.43.. curses/ <12>
------------
+
<1> create a new topic branch.
<2> revert your botched changes in "curses/ux_audio_oss.c".
<3> you need to tell git if you added a new file; removal and
......@@ -170,7 +171,6 @@ you originally wrote.
combined and include --max-count=10 (show 10 commits), --until='2005-12-10'.
<12> view only the changes that touch what's in curses/
directory, since v2.43 tag.
------------
Individual Developer (Participant)[[Individual Developer (Participant)]]
......@@ -208,7 +208,8 @@ $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5>
$ git reset --hard ORIG_HEAD <6>
$ git prune <7>
$ git fetch --tags <8>
------------
+
<1> repeat as needed.
<2> extract patches from your branch for e-mail submission.
<3> "pull" fetches from "origin" by default and merges into the
......@@ -221,7 +222,6 @@ area we are interested in.
<7> garbage collect leftover objects from reverted pull.
<8> from time to time, obtain official tags from the "origin"
and store them under .git/refs/tags/.
------------
Push into another repository.::
......@@ -239,7 +239,8 @@ satellite$ git push origin <4>
mothership$ cd frotz
mothership$ git checkout master
mothership$ git pull . satellite <5>
------------
+
<1> mothership machine has a frotz repository under your home
directory; clone from it to start a repository on the satellite
machine.
......@@ -252,7 +253,6 @@ to local "origin" branch.
mothership machine. You could use this as a back-up method.
<5> on mothership machine, merge the work done on the satellite
machine into the master branch.
------------
Branch off of a specific tag.::
+
......@@ -262,12 +262,12 @@ $ edit/compile/test; git commit -a
$ git checkout master
$ git format-patch -k -m --stdout v2.6.14..private2.6.14 |
git am -3 -k <2>
------------
+
<1> create a private branch based on a well known (but somewhat behind)
tag.
<2> forward port all changes in private2.6.14 branch to master branch
without a formal "merging".
------------
Integrator[[Integrator]]
......@@ -317,7 +317,8 @@ $ git tag -s -m 'GIT 0.99.9x' v0.99.9x <10>
$ git fetch ko && git show-branch master maint 'tags/ko-*' <11>
$ git push ko <12>
$ git push ko v0.99.9x <13>
------------
+
<1> see what I was in the middle of doing, if any.
<2> see what topic branches I have and think about how ready
they are.
......@@ -346,7 +347,6 @@ In the output from "git show-branch", "master" should have
everything "ko-master" has.
<12> push out the bleeding edge.
<13> push the tag out, too.
------------
Repository Administration[[Repository Administration]]
......@@ -367,7 +367,6 @@ example of managing a shared central repository.
Examples
~~~~~~~~
Run git-daemon to serve /pub/scm from inetd.::
+
------------
......@@ -388,13 +387,13 @@ cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell
david:x:1003:1003::/home/david:/usr/bin/git-shell
$ grep git /etc/shells <2>
/usr/bin/git-shell
------------
+
<1> log-in shell is set to /usr/bin/git-shell, which does not
allow anything but "git push" and "git pull". The users should
get an ssh access to the machine.
<2> in many distributions /etc/shells needs to list what is used
as the login shell.
------------
CVS-style shared repository.::
+
......@@ -419,7 +418,8 @@ $ cat info/allowed-users <4>
refs/heads/master alice\|cindy
refs/heads/doc-update bob
refs/tags/v[0-9]* david
------------
+
<1> place the developers into the same git group.
<2> and make the shared repository writable by the group.
<3> use update-hook example by Carl from Documentation/howto/
......@@ -427,7 +427,6 @@ for branch policy control.
<4> alice and cindy can push into master, only bob can push into doc-update.
david is the release manager and is the only person who can
create and push version tags.
------------
HTTP server to support dumb protocol transfer.::
+
......@@ -435,7 +434,7 @@ HTTP server to support dumb protocol transfer.::
dev$ git update-server-info <1>
dev$ ftp user@isp.example.com <2>
ftp> cp -r .git /home/user/myproject.git
------------
+
<1> make sure your info/refs and objects/info/packs are up-to-date
<2> upload to public HTTP server hosted by your ISP.
------------
......@@ -26,7 +26,7 @@ OPTIONS
-v::
Be verbose.
--::
\--::
This option can be used to separate command-line options from
the list of files, (useful when filenames might be mistaken
for command-line options).
......
......@@ -3,22 +3,27 @@ git-branch(1)
NAME
----
git-branch - Create a new branch, or remove an old one
git-branch - List, create, or delete branches.
SYNOPSIS
--------
[verse]
'git-branch' [[-f] <branchname> [<start-point>]]
'git-branch' (-d | -D) <branchname>
'git-branch' [-r]
'git-branch' [-f] <branchname> [<start-point>]
'git-branch' (-d | -D) <branchname>...
DESCRIPTION
-----------
If no argument is provided, show available branches and mark current
branch with star. Otherwise, create a new branch of name <branchname>.
If a starting point is also specified, that will be where the branch is
created, otherwise it will be created at the current HEAD.
With no arguments given (or just `-r`) a list of available branches
will be shown, the current branch will be highlighted with an asterisk.
With a `-d` or `-D` option, `<branchname>` will be deleted.
In its second form, a new branch named <branchname> will be created.
It will start out with a head equal to the one given as <start-point>.
If no <start-point> is given, the branch will be created with a head
equal to that of the currently checked out branch.
With a `-d` or `-D` option, `<branchname>` will be deleted. You may
specify more than one branch for deletion.
OPTIONS
......@@ -30,40 +35,56 @@ OPTIONS
Delete a branch irrespective of its index status.
-f::
Force a reset of <branchname> to <start-point> (or current head).
Force the creation of a new branch even if it means deleting
a branch that already exists with the same name.
-r::
List only the "remote" branches.
<branchname>::
The name of the branch to create or delete.
<start-point>::
Where to create the branch; defaults to HEAD. This
option has no meaning with -d and -D.
The new branch will be created with a HEAD equal to this. It may
be given as a branch name, a commit-id, or a tag. If this option
is omitted, the current branch is assumed.
Examples
~~~~~~~~
--------
Start development off of a known tag::
+
------------
$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
$ cd my2.6
$ git branch my2.6.14 v2.6.14 <1>
$ git branch my2.6.14 v2.6.14 <1>
$ git checkout my2.6.14
<1> These two steps are the same as "checkout -b my2.6.14 v2.6.14".
------------
+
<1> This step and the next one could be combined into a single step with
"checkout -b my2.6.14 v2.6.14".
Delete unneeded branch::
+
------------
$ git clone git://git.kernel.org/.../git.git my.git
$ cd my.git
$ git branch -D todo <1>
$ git branch -D todo <1>
------------
+
<1> delete todo branch even if the "master" branch does not have all
commits from todo branch.
------------
Notes
-----
If you are creating a branch that you want to immediately checkout, it's
easier to use the git checkout command with its `-b` option to create
a branch and check it out with a single command.
Author
------
......
......@@ -63,7 +63,7 @@ OPTIONS
Only meaningful with `--stdin`; paths are separated with
NUL character instead of LF.
--::
\--::
Do not interpret any more arguments as options.
The order of the flags used to matter, but not anymore.
......
......@@ -66,19 +66,19 @@ the `Makefile` to two revisions back, deletes hello.c by
mistake, and gets it back from the index.
+
------------
$ git checkout master <1>
$ git checkout master~2 Makefile <2>
$ git checkout master <1>
$ git checkout master~2 Makefile <2>
$ rm -f hello.c
$ git checkout hello.c <3>
$ git checkout hello.c <3>
------------
+
<1> switch branch
<2> take out a file out of other commit
<3> or "git checkout -- hello.c", as in the next example.
------------
<3> restore hello.c from HEAD of current branch
+
If you have an unfortunate branch that is named `hello.c`, the
last step above would be confused as an instruction to switch to
that branch. You should instead write:
If you have an unfortunate branch that is named `hello.c`, this
step would be confused as an instruction to switch to that branch.
You should instead write:
+
------------
$ git checkout -- hello.c
......
......@@ -11,11 +11,20 @@ SYNOPSIS
DESCRIPTION
-----------
Each commit between the fork-point and <head> is examined, and compared against
the change each commit between the fork-point and <upstream> introduces.
Commits already included in upstream are prefixed with '-' (meaning "drop from
my local pull"), while commits missing from upstream are prefixed with '+'
(meaning "add to the updated upstream").
The changeset (or "diff") of each commit between the fork-point and <head>
is compared against each commit between the fork-point and <upstream>.
Every commit with a changeset that doesn't exist in the other branch
has its id (sha1) reported, prefixed by a symbol. Those existing only
in the <upstream> branch are prefixed with a minus (-) sign, and those
that only exist in the <head> branch are prefixed with a plus (+) symbol.
Because git-cherry compares the changeset rather than the commit id
(sha1), you can use git-cherry to find out if a commit you made locally
has been applied <upstream> under a different commit id. For example,
this will happen if you're feeding patches <upstream> via email rather
than pushing or pulling commits directly.
OPTIONS
-------
......
......@@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
SYNOPSIS
--------
[verse]
'git-clean' [-d] [-n] [-q] [-x | -X]
'git-clean' [-d] [-n] [-q] [-x | -X] [--] <paths>...
DESCRIPTION
-----------
......@@ -16,6 +16,9 @@ Removes files unknown to git. This allows to clean the working tree
from files that are not under version control. If the '-x' option is
specified, ignored files are also removed, allowing to remove all
build products.
When optional `<paths>...` arguments are given, the paths
affected are further limited to those that match them.
OPTIONS
-------
......
......@@ -101,7 +101,7 @@ OPTIONS
is not allowed.
Examples
~~~~~~~~
--------
Clone from upstream::
+
......
......@@ -106,7 +106,7 @@ but can be used to amend a merge commit.
index and the latest commit does not match on the
specified paths to avoid confusion.
--::
\--::
Do not interpret any more arguments as options.
<file>...::
......
......@@ -7,13 +7,23 @@ git-count-objects - Reports on unpacked objects
SYNOPSIS
--------
'git-count-objects'
'git-count-objects' [-v]
DESCRIPTION
-----------
This counts the number of unpacked object files and disk space consumed by
them, to help you decide when it is a good time to repack.
OPTIONS
-------
-v::
In addition to the number of loose objects and disk
space consumed, it reports the number of in-pack
objects, and number of objects that can be removed by
running `git-prune-packed`.
Author
------
Written by Junio C Hamano <junkio@cox.net>
......
......@@ -8,7 +8,7 @@ git-cvsexportcommit - Export a commit to a CVS checkout
SYNOPSIS
--------
'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [PARENTCOMMIT] COMMITID
'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
DESCRIPTION
......@@ -39,6 +39,13 @@ OPTIONS
Be pedantic (paranoid) when applying patches. Invokes patch with
--fuzz=0
-f::
Force the merge even if the files are not up to date.
-m::
Prepend the commit message with the provided prefix.
Useful for patch series and the like.
-v::
Verbose.
......
......@@ -92,7 +92,7 @@ separated with a single space are given.
Furthermore, it lists only files which were modified
from all parents.
-cc::
--cc::
This flag changes the way a merge commit patch is displayed,
in a similar way to the '-c' option. It implies the '-c'
and '-p' options and further compresses the patch output
......
......@@ -46,40 +46,41 @@ EXAMPLES
Various ways to check your working tree::
+
------------
$ git diff <1>
$ git diff --cached <2>
$ git diff HEAD <3>
$ git diff <1>
$ git diff --cached <2>
$ git diff HEAD <3>
------------
+
<1> changes in the working tree since your last git-update-index.
<2> changes between the index and your last commit; what you
would be committing if you run "git commit" without "-a" option.
<3> changes in the working tree since your last commit; what you
would be committing if you run "git commit -a"
------------
Comparing with arbitrary commits::
+
------------
$ git diff test <1>
$ git diff HEAD -- ./test <2>
$ git diff HEAD^ HEAD <3>
$ git diff test <1>
$ git diff HEAD -- ./test <2>
$ git diff HEAD^ HEAD <3>
------------
+
<1> instead of using the tip of the current branch, compare with the
tip of "test" branch.
<2> instead of comparing with the tip of "test" branch, compare with
the tip of the current branch, but limit the comparison to the
file "test".
<3> compare the version before the last commit and the last commit.
------------
Limiting the diff output::
+
------------
$ git diff --diff-filter=MRC <1>
$ git diff --name-status -r <2>
$ git diff arch/i386 include/asm-i386 <3>
$ git diff --diff-filter=MRC <1>
$ git diff --name-status -r <2>
$ git diff arch/i386 include/asm-i386 <3>
------------
+
<1> show only modification, rename and copy, but not addition
nor deletion.
<2> show only names and the nature of change, but not actual
......@@ -88,18 +89,17 @@ which in turn also disables recursive behaviour, so without -r
you would only see the directory name if there is a change in a
file in a subdirectory.
<3> limit diff output to named subtrees.
------------
Munging the diff output::
+
------------
$ git diff --find-copies-harder -B -C <1>
$ git diff -R <2>
$ git diff --find-copies-harder -B -C <1>
$ git diff -R <2>
------------
+
<1> spend extra cycles to find renames, copies and complete
rewrites (very expensive).
<2> output diff in reverse.
------------
Author
......
......@@ -8,43 +8,82 @@ git-grep - Print lines matching a pattern
SYNOPSIS
--------
'git-grep' [<option>...] [-e] <pattern> [--] [<path>...]
[verse]
'git-grep' [--cached]
[-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
[-v | --invert-match]
[-E | --extended-regexp] [-G | --basic-regexp] [-F | --fixed-strings]
[-n] [-l | --files-with-matches] [-L | --files-without-match]
[-c | --count]
[-A <post-context>] [-B <pre-context>] [-C <context>]
[-f <file>] [-e <pattern>]
[<tree>...]
[--] [<path>...]
DESCRIPTION
-----------
Searches list of files `git-ls-files` produces for lines
containing a match to the given pattern.
Look for specified patterns in the working tree files, blobs
registered in the index file, or given tree objects.
OPTIONS
-------
`--`::
Signals the end of options; the rest of the parameters
are <path> limiters.
--cached::
Instead of searching in the working tree files, check
the blobs registerd in the index file.
-a | --text::
Process binary files as if they were text.
-i | --ignore-case::
Ignore case differences between the patterns and the
files.
-w | --word-regexp::
Match the pattern only at word boundary (either begin at the
beginning of a line, or preceded by a non-word character; end at
the end of a line or followed by a non-word character).
-v | --invert-match::
Select non-matching lines.
-E | --extended-regexp | -G | --basic-regexp::
Use POSIX extended/basic regexp for patterns. Default
is to use basic regexp.
<option>...::
Either an option to pass to `grep` or `git-ls-files`.
+
The following are the specific `git-ls-files` options
that may be given: `-o`, `--cached`, `--deleted`, `--others`,
`--killed`, `--ignored`, `--modified`, `--exclude=\*`,
`--exclude-from=\*`, and `--exclude-per-directory=\*`.
+
All other options will be passed to `grep`.
-n::
Prefix the line number to matching lines.
<pattern>::
The pattern to look for. The first non option is taken
as the pattern; if your pattern begins with a dash, use
`-e <pattern>`.
-l | --files-with-matches | -L | --files-without-match::
Instead of showing every matched line, show only the
names of files that contain (or do not contain) matches.
<path>...::
Optional paths to limit the set of files to be searched;
passed to `git-ls-files`.
-c | --count::
Instead of showing every matched line, show the number of
lines that match.
-[ABC] <context>::
Show `context` trailing (`A` -- after), or leading (`B`
-- before), or both (`C` -- context) lines, and place a
line containing `--` between continguous groups of
matches.
-f <file>::
Read patterns from <file>, one per line.
`<tree>...`::
Search blobs in the trees for specified patterns.
`--`::
Signals the end of options; the rest of the parameters
are <path> limiters.
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
Originally written by Linus Torvalds <torvalds@osdl.org>, later
revamped by Junio C Hamano.
Documentation
--------------
......
......@@ -29,6 +29,7 @@ CONFIGURATION
git-imap-send requires the following values in the repository
configuration file (shown with examples):
..........................
[imap]
Folder = "INBOX.Drafts"
......@@ -38,8 +39,9 @@ configuration file (shown with examples):
[imap]
Host = imap.server.com
User = bob
Password = pwd
Pass = pwd
Port = 143
..........................
BUGS
......
......@@ -60,12 +60,12 @@ Start a new git repository for an existing code base::
+
----------------
$ cd /path/to/my/codebase
$ git-init-db <1>
$ git-add . <2>
$ git-init-db <1>
$ git-add . <2>
----------------
+
<1> prepare /path/to/my/codebase/.git directory
<2> add all existing file to the index
----------------
Author
......
......@@ -14,13 +14,12 @@ DESCRIPTION
-----------
Shows the commit logs.
The command takes options applicable to the gitlink::git-rev-list[1]
The command takes options applicable to the gitlink:git-rev-list[1]
command to control what is shown and how, and options applicable to
the gitlink::git-diff-tree[1] commands to control how the change
the gitlink:git-diff-tree[1] commands to control how the change
each commit introduces are shown.
This manual page describes only the most frequently used
options.
This manual page describes only the most frequently used options.
OPTIONS
......@@ -52,7 +51,7 @@ git log v2.6.12.. include/scsi drivers/scsi::
Show all commits since version 'v2.6.12' that changed any file
in the include/scsi or drivers/scsi subdirectories
git log --since="2 weeks ago" -- gitk::
git log --since="2 weeks ago" \-- gitk::
Show the changes during the last two weeks to the file 'gitk'.
The "--" is necessary to avoid confusion with the *branch* named
......
......@@ -106,7 +106,7 @@ OPTIONS
lines, show only handful hexdigits prefix.
Non default number of digits can be specified with --abbrev=<n>.
--::
\--::
Do not interpret any more arguments as options.
<file>::
......
......@@ -8,16 +8,26 @@ git-merge-base - Finds as good a common ancestor as possible for a merge
SYNOPSIS
--------
'git-merge-base' <commit> <commit>
'git-merge-base' [--all] <commit> <commit>
DESCRIPTION
-----------
"git-merge-base" finds as good a common ancestor as possible. Given a
selection of equally good common ancestors it should not be relied on
to decide in any particular way.
"git-merge-base" finds as good a common ancestor as possible between
the two commits. That is, given two commits A and B 'git-merge-base A
B' will output a commit which is reachable from both A and B through
the parent relationship.
Given a selection of equally good common ancestors it should not be
relied on to decide in any particular way.
The "git-merge-base" algorithm is still in flux - use the source...
OPTIONS
-------
--all::
Output all common ancestors for the two commits instead of
just one.
Author
------
......
......@@ -8,7 +8,7 @@ git-merge-index - Runs a merge for files needing merging
SYNOPSIS
--------
'git-merge-index' [-o] [-q] <merge-program> (-a | -- | <file>\*)
'git-merge-index' [-o] [-q] <merge-program> (-a | \-- | <file>\*)
DESCRIPTION
-----------
......@@ -19,7 +19,7 @@ files are passed as arguments 5, 6 and 7.
OPTIONS
-------
--::
\--::
Do not interpret any more arguments as options.
-a::
......
......@@ -41,6 +41,7 @@ Enter git-name-rev:
------------
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a
33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99^0~940
------------
Now you are wiser, because you know that it happened 940 revisions before v0.99.
......
......@@ -28,7 +28,7 @@ OPTIONS
Do not remove anything; just report what it would
remove.
--::
\--::
Do not interpret any more arguments as options.
<head>...::
......
git-quiltimport(1)
================
NAME
----
git-quiltimport - Applies a quilt patchset onto the current branch
SYNOPSIS
--------
[verse]
'git-quiltimport' [--dry-run] [--author <author>] [--patches <dir>]
DESCRIPTION
-----------
Applies a quilt patchset onto the current git branch, preserving
the patch boundaries, patch order, and patch descriptions present
in the quilt patchset.
For each patch the code attempts to extract the author from the
patch description. If that fails it falls back to the author
specified with --author. If the --author flag was not given
the patch description is displayed and the user is asked to
interactively enter the author of the patch.
If a subject is not found in the patch description the patch name is
preserved as the 1 line subject in the git description.
OPTIONS
-------
--dry-run::
Walk through the patches in the series and warn
if we cannot find all of the necessary information to commit
a patch. At the time of this writing only missing author
information is warned about.
--author Author Name <Author Email>::
The author name and email address to use when no author
information can be found in the patch description.
--patches <dir>::
The directory to find the quilt patches and the
quilt series file.
The default for the patch directory is patches
or the value of the $QUILT_PATCHES environment
variable.
Author
------
Written by Eric Biederman <ebiederm@lnxi.com>
Documentation
--------------
Documentation by Eric Biederman <ebiederm@lnxi.com>
GIT
---
Part of the gitlink:git[7] suite
......@@ -3,38 +3,53 @@ git-rebase(1)
NAME
----
git-rebase - Rebase local commits to new upstream head
git-rebase - Rebase local commits to a new head
SYNOPSIS
--------
'git-rebase' [--onto <newbase>] <upstream> [<branch>]
'git-rebase' --continue | --skip | --abort
DESCRIPTION
-----------
git-rebase applies to <upstream> (or optionally to <newbase>) commits
from <branch> that do not appear in <upstream>. When <branch> is not
specified it defaults to the current branch (HEAD).
When git-rebase is complete, <branch> will be updated to point to the
newly created line of commit objects, so the previous line will not be
accessible unless there are other references to it already.
git-rebase replaces <branch> with a new branch of the same name. When
the --onto option is provided the new branch starts out with a HEAD equal
to <newbase>, otherwise it is equal to <upstream>. It then attempts to
create a new commit for each commit from the original <branch> that does
not exist in the <upstream> branch.
It is possible that a merge failure will prevent this process from being
completely automatic. You will have to resolve any such merge failure
and run `git rebase --continue`. Another option is to bypass the commit
that caused the merge failure with `git rebase --skip`. To restore the
original <branch> and remove the .dotest working files, use the command
`git rebase --abort` instead.
Note that if <branch> is not specified on the command line, the currently
checked out branch is used.
Assume the following history exists and the current branch is "topic":
------------
A---B---C topic
/
D---E---F---G master
------------
From this point, the result of either of the following commands:
git-rebase master
git-rebase master topic
would be:
------------
A'--B'--C' topic
/
D---E---F---G master
------------
While, starting from the same point, the result of either of the following
commands:
......@@ -44,21 +59,33 @@ commands:
would be:
------------
A'--B'--C' topic
/
D---E---F---G master
------------
In case of conflict, git-rebase will stop at the first problematic commit
and leave conflict markers in the tree. After resolving the conflict manually
and updating the index with the desired resolution, you can continue the
rebasing process with
and leave conflict markers in the tree. You can use git diff to locate
the markers (<<<<<<) and make edits to resolve the conflict. For each
file you edit, you need to tell git that the conflict has been resolved,
typically this would be done with
git update-index <filename>
After resolving the conflict manually and updating the index with the
desired resolution, you can continue the rebasing process with
git rebase --continue
git am --resolved --3way
Alternatively, you can undo the git-rebase with
git reset --hard ORIG_HEAD
rm -r .dotest
git rebase --abort
OPTIONS
-------
......@@ -73,6 +100,28 @@ OPTIONS
<branch>::
Working branch; defaults to HEAD.
--continue::
Restart the rebasing process after having resolved a merge conflict.
--abort::
Restore the original branch and abort the rebase operation.
NOTES
-----
When you rebase a branch, you are changing its history in a way that
will cause problems for anyone who already has a copy of the branch
in their repository and tries to pull updates from you. You should
understand the implications of using 'git rebase' on a repository that
you share.
When the git rebase command is run, it will first execute a "pre-rebase"
hook if one exists. You can use this hook to do sanity checks and
reject the rebase if it isn't appropriate. Please see the template
pre-rebase hook script for an example.
You must be in the top directory of your project to start (or continue)
a rebase. Upon completion, <branch> will be the current branch.
Author
------
Written by Junio C Hamano <junkio@cox.net>
......
......@@ -38,6 +38,7 @@ OPTIONS
-d::
After packing, if the newly created packs make some
existing packs redundant, remove the redundant packs.
Also runs gitlink:git-prune-packed[1].
-l::
Pass the `--local` option to `git pack-objects`, see
......
......@@ -15,6 +15,7 @@ SYNOPSIS
'git-repo-config' [type] --get-all name [value_regex]
'git-repo-config' [type] --unset name [value_regex]
'git-repo-config' [type] --unset-all name [value_regex]
'git-repo-config' -l | --list
DESCRIPTION
-----------
......@@ -22,10 +23,11 @@ You can query/set/replace/unset options with this command. The name is
actually the section and the key separated by a dot, and the value will be
escaped.
If you want to set/unset an option which can occur on multiple lines, you
should provide a POSIX regex for the value. If you want to handle the lines
*not* matching the regex, just prepend a single exclamation mark in front
(see EXAMPLES).
If you want to set/unset an option which can occur on multiple
lines, a POSIX regexp `value_regex` needs to be given. Only the
existing values that match the regexp are updated or unset. If
you want to handle the lines that do *not* match the regex, just
prepend a single exclamation mark in front (see EXAMPLES).
The type specifier can be either '--int' or '--bool', which will make
'git-repo-config' ensure that the variable(s) are of the given type and
......@@ -33,10 +35,10 @@ convert the value to the canonical form (simple decimal number for int,
a "true" or "false" string for bool). If no type specifier is passed,
no checks or transformations are performed on the value.
This command will fail if
This command will fail if:
. .git/config is invalid,
. .git/config can not be written to,
. The .git/config file is invalid,
. Can not write to .git/config,
. no section was provided,
. the section or key is invalid,
. you try to unset an option which does not exist, or
......@@ -48,7 +50,7 @@ OPTIONS
--replace-all::
Default behaviour is to replace at most one line. This replaces
all lines matching the key (and optionally the value_regex)
all lines matching the key (and optionally the value_regex).
--get::
Get the value for a given key (optionally filtered by a regex
......@@ -58,12 +60,18 @@ OPTIONS
Like get, but does not fail if the number of values for the key
is not exactly one.
--get-regexp::
Like --get-all, but interprets the name as a regular expression.
--unset::
Remove the line matching the key from .git/config.
--unset-all::
Remove all matching lines from .git/config.
-l, --list::
List all variables set in .git/config.
EXAMPLE
-------
......
......@@ -43,16 +43,17 @@ OPTIONS
Commit to make the current HEAD.
Examples
~~~~~~~~
--------
Undo a commit and redo::
+
------------
$ git commit ...
$ git reset --soft HEAD^ <1>
$ edit <2>
$ git commit -a -c ORIG_HEAD <3>
$ git reset --soft HEAD^ <1>
$ edit <2>
$ git commit -a -c ORIG_HEAD <3>
------------
+
<1> This is most often done when you remembered what you
just committed is incomplete, or you misspelled your commit
message, or both. Leaves working tree as it was before "reset".
......@@ -60,43 +61,43 @@ message, or both. Leaves working tree as it was before "reset".
<3> "reset" copies the old head to .git/ORIG_HEAD; redo the
commit by starting with its log message. If you do not need to
edit the message further, you can give -C option instead.
------------
Undo commits permanently::
+
------------
$ git commit ...
$ git reset --hard HEAD~3 <1>
$ git reset --hard HEAD~3 <1>
------------
+
<1> The last three commits (HEAD, HEAD^, and HEAD~2) were bad
and you do not want to ever see them again. Do *not* do this if
you have already given these commits to somebody else.
------------
Undo a commit, making it a topic branch::
+
------------
$ git branch topic/wip <1>
$ git reset --hard HEAD~3 <2>
$ git checkout topic/wip <3>
$ git branch topic/wip <1>
$ git reset --hard HEAD~3 <2>
$ git checkout topic/wip <3>
------------
+
<1> You have made some commits, but realize they were premature
to be in the "master" branch. You want to continue polishing
them in a topic branch, so create "topic/wip" branch off of the
current HEAD.
<2> Rewind the master branch to get rid of those three commits.
<3> Switch to "topic/wip" branch and keep working.
------------
Undo update-index::
+
------------
$ edit <1>
$ edit <1>
$ git-update-index frotz.c filfre.c
$ mailx <2>
$ git reset <3>
$ git pull git://info.example.com/ nitfol <4>
$ mailx <2>
$ git reset <3>
$ git pull git://info.example.com/ nitfol <4>
------------
+
<1> you are happily working on something, and find the changes
in these files are in good order. You do not want to see them
when you run "git diff", because you plan to work on other files
......@@ -109,12 +110,11 @@ index changes for these two files. Your changes in working tree
remain there.
<4> then you can pull and merge, leaving frotz.c and filfre.c
changes still in the working tree.
------------
Undo a merge or pull::
+
------------
$ git pull <1>
$ git pull <1>
Trying really trivial in-index merge...
fatal: Merge requires file-level merging
Nope.
......@@ -122,20 +122,19 @@ Nope.
Auto-merging nitfol
CONFLICT (content): Merge conflict in nitfol
Automatic merge failed/prevented; fix up by hand
$ git reset --hard <2>
$ git reset --hard <2>
$ git pull . topic/branch <3>
Updating from 41223... to 13134...
Fast forward
$ git reset --hard ORIG_HEAD <4>
------------
+
<1> try to update from the upstream resulted in a lot of
conflicts; you were not ready to spend a lot of time merging
right now, so you decide to do that later.
<2> "pull" has not made merge commit, so "git reset --hard"
which is a synonym for "git reset --hard HEAD" clears the mess
from the index file and the working tree.
$ git pull . topic/branch <3>
Updating from 41223... to 13134...
Fast forward
$ git reset --hard ORIG_HEAD <4>
<3> merge a topic branch into the current branch, which resulted
in a fast forward.
<4> but you decided that the topic branch is not ready for public
......@@ -143,7 +142,6 @@ consumption yet. "pull" or "merge" always leaves the original
tip of the current branch in ORIG_HEAD, so resetting hard to it
brings your index file and the working tree back to that state,
and resets the tip of the branch to that commit.
------------
Interrupted workflow::
+
......@@ -155,21 +153,21 @@ need to get to the other branch for a quick bugfix.
------------
$ git checkout feature ;# you were working in "feature" branch and
$ work work work ;# got interrupted
$ git commit -a -m 'snapshot WIP' <1>
$ git commit -a -m 'snapshot WIP' <1>
$ git checkout master
$ fix fix fix
$ git commit ;# commit with real log
$ git checkout feature
$ git reset --soft HEAD^ ;# go back to WIP state <2>
$ git reset <3>
$ git reset --soft HEAD^ ;# go back to WIP state <2>
$ git reset <3>
------------
+
<1> This commit will get blown away so a throw-away log message is OK.
<2> This removes the 'WIP' commit from the commit history, and sets
your working tree to the state just before you made that snapshot.
<3> After <2>, the index file still has all the WIP changes you
committed in <1>. This sets it to the last commit you were
basing the WIP changes on.
------------
<3> At this point the index file still has all the WIP changes you
committed as 'snapshot WIP'. This updates the index to show your
WIP files as uncommitted.
Author
------
......
......@@ -68,9 +68,10 @@ OPTIONS
--bisect::
Limit output to the one commit object which is roughly halfway
between the included and excluded commits. Thus, if 'git-rev-list
--bisect foo ^bar ^baz' outputs 'midpoint', the output
of 'git-rev-list foo ^midpoint' and 'git-rev-list midpoint
^bar ^baz' would be of roughly the same length. Finding the change
--bisect foo {caret}bar {caret}baz' outputs 'midpoint', the output
of 'git-rev-list foo {caret}midpoint' and 'git-rev-list midpoint
{caret}bar {caret}baz' would be of roughly the same length.
Finding the change
which introduces a regression is thus reduced to a binary search:
repeatedly generate and test new 'midpoint's until the commit chain
is of length one.
......
......@@ -67,6 +67,15 @@ OPTIONS
--all::
Show all refs found in `$GIT_DIR/refs`.
--branches::
Show branch refs found in `$GIT_DIR/refs/heads`.
--tags::
Show tag refs found in `$GIT_DIR/refs/tags`.
--remotes::
Show tag refs found in `$GIT_DIR/refs/remotes`.
--show-prefix::
When the command is invoked from a subdirectory, show the
path of the current directory relative to the top-level
......
......@@ -32,7 +32,7 @@ OPTIONS
-v::
Be verbose.
--::
\--::
This option can be used to separate command-line options from
the list of files, (useful when filenames might be mistaken
for command-line options).
......
......@@ -13,9 +13,16 @@ SYNOPSIS
DESCRIPTION
-----------
Reads a packed archive (.pack) from the standard input, and
expands the objects contained in the pack into "one-file
one-object" format in $GIT_OBJECT_DIRECTORY.
Read a packed archive (.pack) from the standard input, expanding
the objects contained within and writing them into the repository in
"loose" (one object per file) format.
Objects that already exist in the repository will *not* be unpacked
from the pack-file. Therefore, nothing will be unpacked if you use
this command on a pack-file that exists within the target repository.
Please see the `git-repack` documentation for options to generate
new packs and replace existing ones.
OPTIONS
-------
......
......@@ -10,12 +10,12 @@ SYNOPSIS
--------
[verse]
'git-update-index'
[--add] [--remove | --force-remove] [--replace]
[--refresh [-q] [--unmerged] [--ignore-missing]]
[--add] [--remove | --force-remove] [--replace]
[--refresh] [-q] [--unmerged] [--ignore-missing]
[--cacheinfo <mode> <object> <file>]\*
[--chmod=(+|-)x]
[--assume-unchanged | --no-assume-unchanged]
[--really-refresh]
[--really-refresh] [--unresolve] [--again]
[--info-only] [--index-info]
[-z] [--stdin]
[--verbose]
......@@ -80,6 +80,14 @@ OPTIONS
filesystem that has very slow lstat(2) system call
(e.g. cifs).
--again::
Runs `git-update-index` itself on the paths whose index
entries are different from those from the `HEAD` commit.
--unresolve::
Restores the 'unmerged' or 'needs updating' state of a
file during a merge if it was cleared by accident.
--info-only::
Do not create objects in the object database for all
<file> arguments that follow this flag; just insert
......@@ -109,7 +117,7 @@ OPTIONS
Only meaningful with `--stdin`; paths are separated with
NUL character instead of LF.
--::
\--::
Do not interpret any more arguments as options.
<file>::
......@@ -247,34 +255,33 @@ To update and refresh only the files already checked out:
$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
----------------
On an inefficient filesystem with `core.ignorestat` set:
On an inefficient filesystem with `core.ignorestat` set::
+
------------
$ git update-index --really-refresh <1>
$ git update-index --no-assume-unchanged foo.c <2>
$ git diff --name-only <3>
$ git update-index --really-refresh <1>
$ git update-index --no-assume-unchanged foo.c <2>
$ git diff --name-only <3>
$ edit foo.c
$ git diff --name-only <4>
$ git diff --name-only <4>
M foo.c
$ git update-index foo.c <5>
$ git diff --name-only <6>
$ git update-index foo.c <5>
$ git diff --name-only <6>
$ edit foo.c
$ git diff --name-only <7>
$ git update-index --no-assume-unchanged foo.c <8>
$ git diff --name-only <9>
$ git diff --name-only <7>
$ git update-index --no-assume-unchanged foo.c <8>
$ git diff --name-only <9>
M foo.c
<1> forces lstat(2) to set "assume unchanged" bits for paths
that match index.
------------
+
<1> forces lstat(2) to set "assume unchanged" bits for paths that match index.
<2> mark the path to be edited.
<3> this does lstat(2) and finds index matches the path.
<4> this does lstat(2) and finds index does not match the path.
<4> this does lstat(2) and finds index does *not* match the path.
<5> registering the new version to index sets "assume unchanged" bit.
<6> and it is assumed unchanged.
<7> even after you edit it.
<8> you can tell about the change after the fact.
<9> now it checks with lstat(2) and finds it has been changed.
------------
Configuration
......
......@@ -19,7 +19,8 @@ OPTIONS
-l::
Cause the logical variables to be listed. In addition, all the
variables of the git configuration file .git/config are listed
as well.
as well. (However, the configuration variables listing functionality
is deprecated in favor of `git-repo-config -l`.)
EXAMPLE
--------
......
......@@ -25,7 +25,7 @@ OPTIONS
-v::
After verifying the pack, show list of objects contained
in the pack.
--::
\--::
Do not interpret any more arguments as options.
OUTPUT FORMAT
......
......@@ -58,7 +58,7 @@ git-whatchanged -p v2.6.12.. include/scsi drivers/scsi::
Show as patches the commits since version 'v2.6.12' that changed
any file in the include/scsi or drivers/scsi subdirectories
git-whatchanged --since="2 weeks ago" -- gitk::
git-whatchanged --since="2 weeks ago" \-- gitk::
Show the changes during the last two weeks to the file 'gitk'.
The "--" is necessary to avoid confusion with the *branch* named
......
......@@ -31,7 +31,7 @@ gitk v2.6.12.. include/scsi drivers/scsi::
Show as the changes since version 'v2.6.12' that changed any
file in the include/scsi or drivers/scsi subdirectories
gitk --since="2 weeks ago" -- gitk::
gitk --since="2 weeks ago" \-- gitk::
Show the changes during the last two weeks to the file 'gitk'.
The "--" is necessary to avoid confusion with the *branch* named
......
object::
The unit of storage in git. It is uniquely identified by
the SHA1 of its contents. Consequently, an object can not
be changed.
object name::
The unique identifier of an object. The hash of the object's contents
using the Secure Hash Algorithm 1 and usually represented by the 40
character hexadecimal encoding of the hash of the object (possibly
followed by a white space).
SHA1::
Synonym for object name.
object identifier::
Synonym for object name.
hash::
In git's context, synonym to object name.
alternate object database::
Via the alternates mechanism, a repository can inherit part of its
object database from another object database, which is called
"alternate".
object database::
Stores a set of "objects", and an individual object is identified
by its object name. The objects usually live in `$GIT_DIR/objects/`.
bare repository::
A bare repository is normally an appropriately named
directory with a `.git` suffix that does not have a
locally checked-out copy of any of the files under revision
control. That is, all of the `git` administrative and
control files that would normally be present in the
hidden `.git` sub-directory are directly present in
the `repository.git` directory instead, and no other files
are present and checked out. Usually publishers of public
repositories make bare repositories available.
blob object::
Untyped object, e.g. the contents of a file.
tree object::
An object containing a list of file names and modes along with refs
to the associated blob and/or tree objects. A tree is equivalent
to a directory.
tree::
Either a working tree, or a tree object together with the
dependent blob and tree objects (i.e. a stored representation
of a working tree).
DAG::
Directed acyclic graph. The commit objects form a directed acyclic
graph, because they have parents (directed), and the graph of commit
objects is acyclic (there is no chain which begins and ends with the
same object).
index::
A collection of files with stat information, whose contents are
stored as objects. The index is a stored version of your working
tree. Truth be told, it can also contain a second, and even a third
version of a working tree, which are used when merging.
index entry::
The information regarding a particular file, stored in the index.
An index entry can be unmerged, if a merge was started, but not
yet finished (i.e. if the index contains multiple versions of
that file).
unmerged index:
An index which contains unmerged index entries.
branch::
A non-cyclical graph of revisions, i.e. the complete history of
a particular revision, which is called the branch head. The
branch heads are stored in `$GIT_DIR/refs/heads/`.
cache::
Obsolete for: index.
working tree::
The set of files and directories currently being worked on,
i.e. you can work in your working tree without using git at all.
directory::
The list you get with "ls" :-)
chain::
A list of objects, where each object in the list contains a
reference to its successor (for example, the successor of a commit
could be one of its parents).
revision::
A particular state of files and directories which was stored in
the object database. It is referenced by a commit object.
changeset::
BitKeeper/cvsps speak for "commit". Since git does not store
changes, but states, it really does not make sense to use
the term "changesets" with git.
checkout::
The action of updating the working tree to a revision which was
stored in the object database.
cherry-picking::
In SCM jargon, "cherry pick" means to choose a subset of
changes out of a series of changes (typically commits)
and record them as a new series of changes on top of
different codebase. In GIT, this is performed by
"git cherry-pick" command to extract the change
introduced by an existing commit and to record it based
on the tip of the current branch as a new commit.
clean::
A working tree is clean, if it corresponds to the revision
referenced by the current head. Also see "dirty".
commit::
As a verb: The action of storing the current state of the index in the
object database. The result is a revision.
......@@ -85,73 +63,90 @@ commit object::
tree object which corresponds to the top directory of the
stored revision.
parent::
A commit object contains a (possibly empty) list of the logical
predecessor(s) in the line of development, i.e. its parents.
core git::
Fundamental data structures and utilities of git. Exposes only
limited source code management tools.
changeset::
BitKeeper/cvsps speak for "commit". Since git does not store
changes, but states, it really does not make sense to use
the term "changesets" with git.
DAG::
Directed acyclic graph. The commit objects form a directed acyclic
graph, because they have parents (directed), and the graph of commit
objects is acyclic (there is no chain which begins and ends with the
same object).
clean::
A working tree is clean, if it corresponds to the revision
referenced by the current head.
dircache::
You are *waaaaay* behind.
dirty::
A working tree is said to be dirty if it contains modifications
which have not been committed to the current branch.
head::
The top of a branch. It contains a ref to the corresponding
commit object.
directory::
The list you get with "ls" :-)
branch::
A non-cyclical graph of revisions, i.e. the complete history of
a particular revision, which is called the branch head. The
branch heads are stored in `$GIT_DIR/refs/heads/`.
ent::
Favorite synonym to "tree-ish" by some total geeks. See
`http://en.wikipedia.org/wiki/Ent_(Middle-earth)` for an in-depth
explanation.
master::
The default branch. Whenever you create a git repository, a branch
named "master" is created, and becomes the active branch. In most
cases, this contains the local development.
fast forward::
A fast-forward is a special type of merge where you have
a revision and you are "merging" another branch's changes
that happen to be a descendant of what you have.
In such these cases, you do not make a new merge commit but
instead just update to his revision. This will happen
frequently on a tracking branch of a remote repository.
origin::
The default upstream branch. Most projects have one upstream
project which they track, and by default 'origin' is used for
that purpose. New updates from upstream will be fetched into
this branch; you should never commit to it yourself.
fetch::
Fetching a branch means to get the branch's head ref from a
remote repository, to find out which objects are missing from
the local object database, and to get them, too.
ref::
A 40-byte hex representation of a SHA1 pointing to a particular
object. These may be stored in `$GIT_DIR/refs/`.
file system::
Linus Torvalds originally designed git to be a user space file
system, i.e. the infrastructure to hold files and directories.
That ensured the efficiency and speed of git.
git archive::
Synonym for repository (for arch people).
hash::
In git's context, synonym to object name.
head::
The top of a branch. It contains a ref to the corresponding
commit object.
head ref::
A ref pointing to a head. Often, this is abbreviated to "head".
Head refs are stored in `$GIT_DIR/refs/heads/`.
tree-ish::
A ref pointing to either a commit object, a tree object, or a
tag object pointing to a tag or commit or tree object.
hook::
During the normal execution of several git commands,
call-outs are made to optional scripts that allow
a developer to add functionality or checking.
Typically, the hooks allow for a command to be pre-verified
and potentially aborted, and allow for a post-notification
after the operation is done.
The hook scripts are found in the `$GIT_DIR/hooks/` directory,
and are enabled by simply making them executable.
ent::
Favorite synonym to "tree-ish" by some total geeks. See
`http://en.wikipedia.org/wiki/Ent_(Middle-earth)` for an in-depth
explanation.
index::
A collection of files with stat information, whose contents are
stored as objects. The index is a stored version of your working
tree. Truth be told, it can also contain a second, and even a third
version of a working tree, which are used when merging.
tag object::
An object containing a ref pointing to another object, which can
contain a message just like a commit object. It can also
contain a (PGP) signature, in which case it is called a "signed
tag object".
index entry::
The information regarding a particular file, stored in the index.
An index entry can be unmerged, if a merge was started, but not
yet finished (i.e. if the index contains multiple versions of
that file).
tag::
A ref pointing to a tag or commit object. In contrast to a head,
a tag is not changed by a commit. Tags (not tag objects) are
stored in `$GIT_DIR/refs/tags/`. A git tag has nothing to do with
a Lisp tag (which is called object type in git's context).
A tag is most typically used to mark a particular point in the
commit ancestry chain.
master::
The default development branch. Whenever you create a git
repository, a branch named "master" is created, and becomes
the active branch. In most cases, this contains the local
development, though that is purely conventional and not required.
merge::
To merge branches means to try to accumulate the changes since a
......@@ -159,55 +154,65 @@ merge::
merge uses heuristics to accomplish that. Evidently, an automatic
merge can fail.
octopus::
To merge more than two branches. Also denotes an intelligent
predator.
object::
The unit of storage in git. It is uniquely identified by
the SHA1 of its contents. Consequently, an object can not
be changed.
resolve::
The action of fixing up manually what a failed automatic merge
left behind.
object database::
Stores a set of "objects", and an individual object is identified
by its object name. The objects usually live in `$GIT_DIR/objects/`.
rewind::
To throw away part of the development, i.e. to assign the head to
an earlier revision.
object identifier::
Synonym for object name.
rebase::
To clean a branch by starting from the head of the main line of
development ("master"), and reapply the (possibly cherry-picked)
changes from that branch.
object name::
The unique identifier of an object. The hash of the object's contents
using the Secure Hash Algorithm 1 and usually represented by the 40
character hexadecimal encoding of the hash of the object (possibly
followed by a white space).
repository::
A collection of refs together with an object database containing
all objects, which are reachable from the refs, possibly accompanied
by meta data from one or more porcelains. A repository can
share an object database with other repositories.
object type:
One of the identifiers "commit","tree","tag" and "blob" describing
the type of an object.
git archive::
Synonym for repository (for arch people).
octopus::
To merge more than two branches. Also denotes an intelligent
predator.
file system::
Linus Torvalds originally designed git to be a user space file
system, i.e. the infrastructure to hold files and directories.
That ensured the efficiency and speed of git.
origin::
The default upstream tracking branch. Most projects have at
least one upstream project which they track. By default
'origin' is used for that purpose. New upstream updates
will be fetched into this branch; you should never commit
to it yourself.
alternate object database::
Via the alternates mechanism, a repository can inherit part of its
object database from another object database, which is called
"alternate".
pack::
A set of objects which have been compressed into one file (to save
space or to transmit them efficiently).
reachable::
An object is reachable from a ref/commit/tree/tag, if there is a
chain leading from the latter to the former.
pack index::
The list of identifiers, and other information, of the objects in a
pack, to assist in efficiently accessing the contents of a pack.
chain::
A list of objects, where each object in the list contains a
reference to its successor (for example, the successor of a commit
could be one of its parents).
parent::
A commit object contains a (possibly empty) list of the logical
predecessor(s) in the line of development, i.e. its parents.
fetch::
Fetching a branch means to get the branch's head ref from a
remote repository, to find out which objects are missing from
the local object database, and to get them, too.
pickaxe::
The term pickaxe refers to an option to the diffcore routines
that help select changes that add or delete a given text string.
With the --pickaxe-all option, it can be used to view the
full changeset that introduced or removed, say, a particular
line of text. See gitlink:git-diff[1].
plumbing::
Cute name for core git.
porcelain::
Cute name for programs and program suites depending on core git,
presenting a high level access to core git. Porcelains expose
more of a SCM interface than the plumbing.
pull::
Pulling a branch means to fetch it and merge it.
......@@ -221,33 +226,101 @@ push::
the remote head ref. If the remote head is not an ancestor to the
local head, the push fails.
pack::
A set of objects which have been compressed into one file (to save
space or to transmit them efficiently).
reachable::
An object is reachable from a ref/commit/tree/tag, if there is a
chain leading from the latter to the former.
pack index::
The list of identifiers, and other information, of the objects in a
pack, to assist in efficiently accessing the contents of a pack.
rebase::
To clean a branch by starting from the head of the main line of
development ("master"), and reapply the (possibly cherry-picked)
changes from that branch.
core git::
Fundamental data structures and utilities of git. Exposes only
limited source code management tools.
ref::
A 40-byte hex representation of a SHA1 or a name that denotes
a particular object. These may be stored in `$GIT_DIR/refs/`.
refspec::
A refspec is used by fetch and push to describe the mapping
between remote ref and local ref. They are combined with
a colon in the format <src>:<dst>, preceded by an optional
plus sign, +. For example:
`git fetch $URL refs/heads/master:refs/heads/origin`
means "grab the master branch head from the $URL and store
it as my origin branch head".
And `git push $URL refs/heads/master:refs/heads/to-upstream`
means "publish my master branch head as to-upstream master head
at $URL". See also gitlink:git-push[1]
plumbing::
Cute name for core git.
repository::
A collection of refs together with an object database containing
all objects, which are reachable from the refs, possibly accompanied
by meta data from one or more porcelains. A repository can
share an object database with other repositories.
porcelain::
Cute name for programs and program suites depending on core git,
presenting a high level access to core git. Porcelains expose
more of a SCM interface than the plumbing.
resolve::
The action of fixing up manually what a failed automatic merge
left behind.
object type:
One of the identifiers "commit","tree","tag" and "blob" describing
the type of an object.
revision::
A particular state of files and directories which was stored in
the object database. It is referenced by a commit object.
rewind::
To throw away part of the development, i.e. to assign the head to
an earlier revision.
SCM::
Source code management (tool).
dircache::
You are *waaaaay* behind.
SHA1::
Synonym for object name.
topic branch::
A regular git branch that is used by a developer to
identify a conceptual line of development. Since branches
are very easy and inexpensive, it is often desirable to
have several small branches that each contain very well
defined concepts or small incremental yet related changes.
tracking branch::
A regular git branch that is used to follow changes from
another repository. A tracking branch should not contain
direct modifications or have local commits made to it.
A tracking branch can usually be identified as the
right-hand-side ref in a Pull: refspec.
tree object::
An object containing a list of file names and modes along with refs
to the associated blob and/or tree objects. A tree is equivalent
to a directory.
tree::
Either a working tree, or a tree object together with the
dependent blob and tree objects (i.e. a stored representation
of a working tree).
tree-ish::
A ref pointing to either a commit object, a tree object, or a
tag object pointing to a tag or commit or tree object.
tag object::
An object containing a ref pointing to another object, which can
contain a message just like a commit object. It can also
contain a (PGP) signature, in which case it is called a "signed
tag object".
tag::
A ref pointing to a tag or commit object. In contrast to a head,
a tag is not changed by a commit. Tags (not tag objects) are
stored in `$GIT_DIR/refs/tags/`. A git tag has nothing to do with
a Lisp tag (which is called object type in git's context).
A tag is most typically used to mark a particular point in the
commit ancestry chain.
unmerged index:
An index which contains unmerged index entries.
working tree::
The set of files and directories currently being worked on,
i.e. you can work in your working tree without using git at all.
......@@ -4,12 +4,16 @@ T="$1"
for h in *.html *.txt howto/*.txt howto/*.html
do
diff -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h" || {
if test -f "$T/$h" &&
diff -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h"
then
:; # up to date
else
echo >&2 "# install $h $T/$h"
rm -f "$T/$h"
mkdir -p `dirname "$T/$h"`
cp "$h" "$T/$h"
}
fi
done
strip_leading=`echo "$T/" | sed -e 's|.|.|g'`
for th in "$T"/*.html "$T"/*.txt "$T"/howto/*.txt "$T"/howto/*.html
......
......@@ -48,7 +48,7 @@ ($)
';
@keys=sort {uc($a) cmp uc($b)} keys %terms;
$pattern='(\b'.join('\b|\b',reverse @keys).'\b)';
$pattern='(\b(?<!link:git-)'.join('\b|\b(?<!link:git-)',reverse @keys).'\b)';
foreach $key (@keys) {
$terms{$key}=~s/$pattern/sprintf "<<ref_".no_spaces($1).",$1>>";/eg;
print '[[ref_'.no_spaces($key).']]'.$key."::\n"
......
......@@ -28,8 +28,8 @@ all:
#
# Define NO_SETENV if you don't have setenv in the C library.
#
# Define USE_SYMLINK_HEAD if you want .git/HEAD to be a symbolic link.
# Don't enable it on Windows.
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
# Enable it on Windows. By default, symrefs are still used.
#
# Define PPC_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for PowerPC.
......@@ -113,25 +113,26 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
### --- END CONFIGURATION SECTION ---
SCRIPT_SH = \
git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
git-bisect.sh git-branch.sh git-checkout.sh \
git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
git-count-objects.sh git-diff.sh git-fetch.sh \
git-fetch.sh \
git-format-patch.sh git-ls-remote.sh \
git-merge-one-file.sh git-parse-remote.sh \
git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
git-prune.sh git-pull.sh git-rebase.sh \
git-repack.sh git-request-pull.sh git-reset.sh \
git-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \
git-tag.sh git-verify-tag.sh git-whatchanged.sh \
git-resolve.sh git-revert.sh git-sh-setup.sh \
git-tag.sh git-verify-tag.sh \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
git-lost-found.sh
git-merge-resolve.sh git-merge-ours.sh \
git-lost-found.sh git-quiltimport.sh
SCRIPT_PERL = \
git-archimport.perl git-cvsimport.perl git-relink.perl \
git-shortlog.perl git-fmt-merge-msg.perl git-rerere.perl \
git-annotate.perl git-cvsserver.perl \
git-svnimport.perl git-mv.perl git-cvsexportcommit.perl
git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \
git-send-email.perl
SCRIPT_PYTHON = \
git-merge-recursive.py
......@@ -139,7 +140,7 @@ SCRIPT_PYTHON = \
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
$(patsubst %.py,%,$(SCRIPT_PYTHON)) \
git-cherry-pick git-show git-status
git-cherry-pick git-status
# The ones that do not have to link with lcrypto, lz nor xdiff.
SIMPLE_PROGRAMS = \
......@@ -153,21 +154,25 @@ PROGRAMS = \
git-convert-objects$X git-diff-files$X \
git-diff-index$X git-diff-stages$X \
git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
git-hash-object$X git-index-pack$X git-init-db$X git-local-fetch$X \
git-hash-object$X git-index-pack$X git-local-fetch$X \
git-ls-files$X git-ls-tree$X git-mailinfo$X git-merge-base$X \
git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
git-peek-remote$X git-prune-packed$X git-read-tree$X \
git-receive-pack$X git-rev-list$X git-rev-parse$X \
git-receive-pack$X git-rev-parse$X \
git-send-pack$X git-show-branch$X git-shell$X \
git-show-index$X git-ssh-fetch$X \
git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
git-unpack-objects$X git-update-index$X git-update-server-info$X \
git-upload-pack$X git-verify-pack$X git-write-tree$X \
git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
git-update-ref$X git-symbolic-ref$X \
git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
BUILT_INS = git-log$X
BUILT_INS = git-log$X git-whatchanged$X git-show$X \
git-count-objects$X git-diff$X git-push$X \
git-grep$X git-add$X git-rm$X git-rev-list$X \
git-check-ref-format$X \
git-init-db$X
# what 'all' will build and 'install' will install, in gitexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
......@@ -196,7 +201,7 @@ LIB_H = \
blob.h cache.h commit.h csum-file.h delta.h \
diff.h object.h pack.h pkt-line.h quote.h refs.h \
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
tree-walk.h log-tree.h
tree-walk.h log-tree.h dir.h
DIFF_OBJS = \
diff.o diff-lib.o diffcore-break.o diffcore-order.o \
......@@ -204,17 +209,19 @@ DIFF_OBJS = \
diffcore-delta.o log-tree.o
LIB_OBJS = \
blob.o commit.o connect.o csum-file.o cache-tree.o \
blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \
object.o pack-check.o patch-delta.o path.o pkt-line.o \
quote.o read-cache.o refs.o run-command.o \
quote.o read-cache.o refs.o run-command.o dir.o \
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
$(DIFF_OBJS)
BUILTIN_OBJS = \
builtin-log.o builtin-help.o
builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
builtin-rm.o builtin-init-db.o
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
LIBS = $(GITLIBS) -lz
......@@ -263,6 +270,7 @@ ifeq ($(uname_O),Cygwin)
NO_D_TYPE_IN_DIRENT = YesPlease
NO_D_INO_IN_DIRENT = YesPlease
NO_STRCASESTR = YesPlease
NO_SYMLINK_HEAD = YesPlease
NEEDS_LIBICONV = YesPlease
# There are conflicting reports about this.
# On some boxes NO_MMAP is needed, and not so elsewhere.
......@@ -283,7 +291,9 @@ ifeq ($(uname_S),OpenBSD)
ALL_LDFLAGS += -L/usr/local/lib
endif
ifeq ($(uname_S),NetBSD)
NEEDS_LIBICONV = YesPlease
ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
NEEDS_LIBICONV = YesPlease
endif
ALL_CFLAGS += -I/usr/pkg/include
ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
endif
......@@ -317,10 +327,6 @@ else
endif
endif
ifdef WITH_SEND_EMAIL
SCRIPT_PERL += git-send-email.perl
endif
ifndef NO_CURL
ifdef CURLDIR
# This is still problematic -- gcc does not always want -R.
......@@ -386,6 +392,9 @@ endif
ifdef NO_D_INO_IN_DIRENT
ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
endif
ifdef NO_SYMLINK_HEAD
ALL_CFLAGS += -DNO_SYMLINK_HEAD
endif
ifdef NO_STRCASESTR
COMPAT_CFLAGS += -DNO_STRCASESTR
COMPAT_OBJS += compat/strcasestr.o
......@@ -453,6 +462,7 @@ PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
ALL_CFLAGS += -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
LIB_OBJS += $(COMPAT_OBJS)
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
### Build rules
......@@ -505,9 +515,6 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
git-cherry-pick: git-revert
cp $< $@
git-show: git-whatchanged
cp $< $@
git-status: git-commit
cp $< $@
......@@ -562,14 +569,6 @@ git-http-push$X: revision.o http.o http-push.o $(LIB_FILE)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
git-rev-list$X: rev-list.o $(LIB_FILE)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(OPENSSL_LIBSSL)
init-db.o: init-db.c
$(CC) -c $(ALL_CFLAGS) \
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $*.c
$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(GITLIBS)
$(DIFF_OBJS): diffcore.h
......@@ -609,7 +608,7 @@ test-date$X: test-date.c date.o ctype.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
test-delta$X: test-delta.c diff-delta.o patch-delta.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^ -lz
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
......@@ -656,6 +655,25 @@ dist: git.spec git-tar-tree
rpm: dist
$(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
htmldocs = git-htmldocs-$(GIT_VERSION)
manpages = git-manpages-$(GIT_VERSION)
dist-doc:
rm -fr .doc-tmp-dir
mkdir .doc-tmp-dir
$(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
gzip -n -9 -f $(htmldocs).tar
:
rm -fr .doc-tmp-dir
mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
$(MAKE) -C Documentation DESTDIR=. \
man1=../.doc-tmp-dir/man1 \
man7=../.doc-tmp-dir/man7 \
install
cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
gzip -n -9 -f $(manpages).tar
rm -fr .doc-tmp-dir
### Cleaning rules
clean:
......@@ -663,8 +681,9 @@ clean:
$(LIB_FILE) $(XDIFF_LIB)
rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
rm -rf $(GIT_TARNAME)
rm -rf $(GIT_TARNAME) .doc-tmp-dir
rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
rm -f $(htmldocs).tar $(manpages).tar
$(MAKE) -C Documentation/ clean
$(MAKE) -C templates clean
$(MAKE) -C t/ clean
......
......@@ -11,20 +11,25 @@
#include "cache-tree.h"
#include "quote.h"
#include "blob.h"
#include "delta.h"
// --check turns on checking that the working tree matches the
// files that are being modified, but doesn't apply the patch
// --stat does just a diffstat, and doesn't actually apply
// --numstat does numeric diffstat, and doesn't actually apply
// --index-info shows the old and new index info for paths if available.
// --index updates the cache as well.
// --cached updates only the cache without ever touching the working tree.
//
static const char *prefix;
static int prefix_length = -1;
static int newfd = -1;
static int p_value = 1;
static int allow_binary_replacement = 0;
static int check_index = 0;
static int write_index = 0;
static int cached = 0;
static int diffstat = 0;
static int numstat = 0;
static int summary = 0;
......@@ -35,7 +40,7 @@ static int show_index_info = 0;
static int line_termination = '\n';
static unsigned long p_context = -1;
static const char apply_usage[] =
"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
static enum whitespace_eol {
nowarn_whitespace,
......@@ -114,6 +119,9 @@ struct patch {
char *new_name, *old_name, *def_name;
unsigned int old_mode, new_mode;
int is_rename, is_copy, is_new, is_delete, is_binary;
#define BINARY_DELTA_DEFLATED 1
#define BINARY_LITERAL_DEFLATED 2
unsigned long deflate_origlen;
int lines_added, lines_deleted;
int score;
struct fragment *fragments;
......@@ -967,6 +975,88 @@ static inline int metadata_changes(struct patch *patch)
patch->old_mode != patch->new_mode);
}
static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
{
/* We have read "GIT binary patch\n"; what follows is a line
* that says the patch method (currently, either "deflated
* literal" or "deflated delta") and the length of data before
* deflating; a sequence of 'length-byte' followed by base-85
* encoded data follows.
*
* Each 5-byte sequence of base-85 encodes up to 4 bytes,
* and we would limit the patch line to 66 characters,
* so one line can fit up to 13 groups that would decode
* to 52 bytes max. The length byte 'A'-'Z' corresponds
* to 1-26 bytes, and 'a'-'z' corresponds to 27-52 bytes.
* The end of binary is signalled with an empty line.
*/
int llen, used;
struct fragment *fragment;
char *data = NULL;
patch->fragments = fragment = xcalloc(1, sizeof(*fragment));
/* Grab the type of patch */
llen = linelen(buffer, size);
used = llen;
linenr++;
if (!strncmp(buffer, "delta ", 6)) {
patch->is_binary = BINARY_DELTA_DEFLATED;
patch->deflate_origlen = strtoul(buffer + 6, NULL, 10);
}
else if (!strncmp(buffer, "literal ", 8)) {
patch->is_binary = BINARY_LITERAL_DEFLATED;
patch->deflate_origlen = strtoul(buffer + 8, NULL, 10);
}
else
return error("unrecognized binary patch at line %d: %.*s",
linenr-1, llen-1, buffer);
buffer += llen;
while (1) {
int byte_length, max_byte_length, newsize;
llen = linelen(buffer, size);
used += llen;
linenr++;
if (llen == 1)
break;
/* Minimum line is "A00000\n" which is 7-byte long,
* and the line length must be multiple of 5 plus 2.
*/
if ((llen < 7) || (llen-2) % 5)
goto corrupt;
max_byte_length = (llen - 2) / 5 * 4;
byte_length = *buffer;
if ('A' <= byte_length && byte_length <= 'Z')
byte_length = byte_length - 'A' + 1;
else if ('a' <= byte_length && byte_length <= 'z')
byte_length = byte_length - 'a' + 27;
else
goto corrupt;
/* if the input length was not multiple of 4, we would
* have filler at the end but the filler should never
* exceed 3 bytes
*/
if (max_byte_length < byte_length ||
byte_length <= max_byte_length - 4)
goto corrupt;
newsize = fragment->size + byte_length;
data = xrealloc(data, newsize);
if (decode_85(data + fragment->size,
buffer + 1,
byte_length))
goto corrupt;
fragment->size = newsize;
buffer += llen;
size -= llen;
}
fragment->patch = data;
return used;
corrupt:
return error("corrupt binary patch at line %d: %.*s",
linenr-1, llen-1, buffer);
}
static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
{
int hdrsize, patchsize;
......@@ -983,19 +1073,34 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
"Files ",
NULL,
};
static const char git_binary[] = "GIT binary patch\n";
int i;
int hd = hdrsize + offset;
unsigned long llen = linelen(buffer + hd, size - hd);
if (!memcmp(" differ\n", buffer + hd + llen - 8, 8))
if (llen == sizeof(git_binary) - 1 &&
!memcmp(git_binary, buffer + hd, llen)) {
int used;
linenr++;
used = parse_binary(buffer + hd + llen,
size - hd - llen, patch);
if (used)
patchsize = used + llen;
else
patchsize = 0;
}
else if (!memcmp(" differ\n", buffer + hd + llen - 8, 8)) {
for (i = 0; binhdr[i]; i++) {
int len = strlen(binhdr[i]);
if (len < size - hd &&
!memcmp(binhdr[i], buffer + hd, len)) {
linenr++;
patch->is_binary = 1;
patchsize = llen;
break;
}
}
}
/* Empty patch cannot be applied if:
* - it is a binary patch and we do not do binary_replace, or
......@@ -1346,76 +1451,150 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
return offset;
}
static int apply_fragments(struct buffer_desc *desc, struct patch *patch)
static char *inflate_it(const void *data, unsigned long size,
unsigned long inflated_size)
{
z_stream stream;
void *out;
int st;
memset(&stream, 0, sizeof(stream));
stream.next_in = (unsigned char *)data;
stream.avail_in = size;
stream.next_out = out = xmalloc(inflated_size);
stream.avail_out = inflated_size;
inflateInit(&stream);
st = inflate(&stream, Z_FINISH);
if ((st != Z_STREAM_END) || stream.total_out != inflated_size) {
free(out);
return NULL;
}
return out;
}
static int apply_binary_fragment(struct buffer_desc *desc, struct patch *patch)
{
unsigned long dst_size;
struct fragment *fragment = patch->fragments;
void *data;
void *result;
data = inflate_it(fragment->patch, fragment->size,
patch->deflate_origlen);
if (!data)
return error("corrupt patch data");
switch (patch->is_binary) {
case BINARY_DELTA_DEFLATED:
result = patch_delta(desc->buffer, desc->size,
data,
patch->deflate_origlen,
&dst_size);
free(desc->buffer);
desc->buffer = result;
free(data);
break;
case BINARY_LITERAL_DEFLATED:
free(desc->buffer);
desc->buffer = data;
dst_size = patch->deflate_origlen;
break;
}
if (!desc->buffer)
return -1;
desc->size = desc->alloc = dst_size;
return 0;
}
static int apply_binary(struct buffer_desc *desc, struct patch *patch)
{
struct fragment *frag = patch->fragments;
const char *name = patch->old_name ? patch->old_name : patch->new_name;
unsigned char sha1[20];
unsigned char hdr[50];
int hdrlen;
if (patch->is_binary) {
unsigned char sha1[20];
if (!allow_binary_replacement)
return error("cannot apply binary patch to '%s' "
"without --allow-binary-replacement",
name);
if (!allow_binary_replacement)
return error("cannot apply binary patch to '%s' "
"without --allow-binary-replacement",
name);
/* For safety, we require patch index line to contain
* full 40-byte textual SHA1 for old and new, at least for now.
*/
if (strlen(patch->old_sha1_prefix) != 40 ||
strlen(patch->new_sha1_prefix) != 40 ||
get_sha1_hex(patch->old_sha1_prefix, sha1) ||
get_sha1_hex(patch->new_sha1_prefix, sha1))
return error("cannot apply binary patch to '%s' "
"without full index line", name);
/* For safety, we require patch index line to contain
* full 40-byte textual SHA1 for old and new, at least for now.
if (patch->old_name) {
/* See if the old one matches what the patch
* applies to.
*/
if (strlen(patch->old_sha1_prefix) != 40 ||
strlen(patch->new_sha1_prefix) != 40 ||
get_sha1_hex(patch->old_sha1_prefix, sha1) ||
get_sha1_hex(patch->new_sha1_prefix, sha1))
return error("cannot apply binary patch to '%s' "
"without full index line", name);
if (patch->old_name) {
unsigned char hdr[50];
int hdrlen;
/* See if the old one matches what the patch
* applies to.
*/
write_sha1_file_prepare(desc->buffer, desc->size,
blob_type, sha1, hdr, &hdrlen);
if (strcmp(sha1_to_hex(sha1), patch->old_sha1_prefix))
return error("the patch applies to '%s' (%s), "
"which does not match the "
"current contents.",
name, sha1_to_hex(sha1));
}
else {
/* Otherwise, the old one must be empty. */
if (desc->size)
return error("the patch applies to an empty "
"'%s' but it is not empty", name);
}
write_sha1_file_prepare(desc->buffer, desc->size,
blob_type, sha1, hdr, &hdrlen);
if (strcmp(sha1_to_hex(sha1), patch->old_sha1_prefix))
return error("the patch applies to '%s' (%s), "
"which does not match the "
"current contents.",
name, sha1_to_hex(sha1));
}
else {
/* Otherwise, the old one must be empty. */
if (desc->size)
return error("the patch applies to an empty "
"'%s' but it is not empty", name);
}
get_sha1_hex(patch->new_sha1_prefix, sha1);
if (!memcmp(sha1, null_sha1, 20)) {
free(desc->buffer);
desc->alloc = desc->size = 0;
desc->buffer = NULL;
return 0; /* deletion patch */
}
if (has_sha1_file(sha1)) {
/* We already have the postimage */
char type[10];
unsigned long size;
/* For now, we do not record post-image data in the patch,
* and require the object already present in the recipient's
* object database.
free(desc->buffer);
desc->buffer = read_sha1_file(sha1, type, &size);
if (!desc->buffer)
return error("the necessary postimage %s for "
"'%s' cannot be read",
patch->new_sha1_prefix, name);
desc->alloc = desc->size = size;
}
else {
/* We have verified desc matches the preimage;
* apply the patch data to it, which is stored
* in the patch->fragments->{patch,size}.
*/
if (desc->buffer) {
free(desc->buffer);
desc->alloc = desc->size = 0;
}
get_sha1_hex(patch->new_sha1_prefix, sha1);
if (memcmp(sha1, null_sha1, 20)) {
char type[10];
unsigned long size;
desc->buffer = read_sha1_file(sha1, type, &size);
if (!desc->buffer)
return error("the necessary postimage %s for "
"'%s' does not exist",
patch->new_sha1_prefix, name);
desc->alloc = desc->size = size;
}
if (apply_binary_fragment(desc, patch))
return error("binary patch does not apply to '%s'",
name);
return 0;
/* verify that the result matches */
write_sha1_file_prepare(desc->buffer, desc->size, blob_type,
sha1, hdr, &hdrlen);
if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
return error("binary patch to '%s' creates incorrect result", name);
}
return 0;
}
static int apply_fragments(struct buffer_desc *desc, struct patch *patch)
{
struct fragment *frag = patch->fragments;
const char *name = patch->old_name ? patch->old_name : patch->new_name;
if (patch->is_binary)
return apply_binary(desc, patch);
while (frag) {
if (apply_one_fragment(desc, frag) < 0)
return error("patch failed: %s:%ld",
......@@ -1425,7 +1604,7 @@ static int apply_fragments(struct buffer_desc *desc, struct patch *patch)
return 0;
}
static int apply_data(struct patch *patch, struct stat *st)
static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)
{
char *buf;
unsigned long size, alloc;
......@@ -1434,7 +1613,17 @@ static int apply_data(struct patch *patch, struct stat *st)
size = 0;
alloc = 0;
buf = NULL;
if (patch->old_name) {
if (cached) {
if (ce) {
char type[20];
buf = read_sha1_file(ce->sha1, type, &size);
if (!buf)
return error("read of %s failed",
patch->old_name);
alloc = size;
}
}
else if (patch->old_name) {
size = st->st_size;
alloc = size + 8192;
buf = xmalloc(alloc);
......@@ -1462,16 +1651,21 @@ static int check_patch(struct patch *patch)
const char *old_name = patch->old_name;
const char *new_name = patch->new_name;
const char *name = old_name ? old_name : new_name;
struct cache_entry *ce = NULL;
if (old_name) {
int changed;
int stat_ret = lstat(old_name, &st);
int changed = 0;
int stat_ret = 0;
unsigned st_mode = 0;
if (!cached)
stat_ret = lstat(old_name, &st);
if (check_index) {
int pos = cache_name_pos(old_name, strlen(old_name));
if (pos < 0)
return error("%s: does not exist in index",
old_name);
ce = active_cache[pos];
if (stat_ret < 0) {
struct checkout costate;
if (errno != ENOENT)
......@@ -1484,40 +1678,46 @@ static int check_patch(struct patch *patch)
costate.quiet = 0;
costate.not_new = 0;
costate.refresh_cache = 1;
if (checkout_entry(active_cache[pos],
if (checkout_entry(ce,
&costate,
NULL) ||
lstat(old_name, &st))
return -1;
}
changed = ce_match_stat(active_cache[pos], &st, 1);
if (!cached)
changed = ce_match_stat(ce, &st, 1);
if (changed)
return error("%s: does not match index",
old_name);
if (cached)
st_mode = ntohl(ce->ce_mode);
}
else if (stat_ret < 0)
return error("%s: %s", old_name, strerror(errno));
if (!cached)
st_mode = ntohl(create_ce_mode(st.st_mode));
if (patch->is_new < 0)
patch->is_new = 0;
st.st_mode = ntohl(create_ce_mode(st.st_mode));
if (!patch->old_mode)
patch->old_mode = st.st_mode;
if ((st.st_mode ^ patch->old_mode) & S_IFMT)
patch->old_mode = st_mode;
if ((st_mode ^ patch->old_mode) & S_IFMT)
return error("%s: wrong type", old_name);
if (st.st_mode != patch->old_mode)
if (st_mode != patch->old_mode)
fprintf(stderr, "warning: %s has type %o, expected %o\n",
old_name, st.st_mode, patch->old_mode);
old_name, st_mode, patch->old_mode);
}
if (new_name && (patch->is_new | patch->is_rename | patch->is_copy)) {
if (check_index && cache_name_pos(new_name, strlen(new_name)) >= 0)
return error("%s: already exists in index", new_name);
if (!lstat(new_name, &st))
return error("%s: already exists in working directory", new_name);
if (errno != ENOENT)
return error("%s: %s", new_name, strerror(errno));
if (!cached) {
if (!lstat(new_name, &st))
return error("%s: already exists in working directory", new_name);
if (errno != ENOENT)
return error("%s: %s", new_name, strerror(errno));
}
if (!patch->new_mode) {
if (patch->is_new)
patch->new_mode = S_IFREG | 0644;
......@@ -1534,9 +1734,9 @@ static int check_patch(struct patch *patch)
return error("new mode (%o) of %s does not match old mode (%o)%s%s",
patch->new_mode, new_name, patch->old_mode,
same ? "" : " of ", same ? "" : old_name);
}
}
if (apply_data(patch, &st) < 0)
if (apply_data(patch, &st, ce) < 0)
return error("%s: patch does not apply", name);
return 0;
}
......@@ -1603,7 +1803,7 @@ static void numstat_patch_list(struct patch *patch)
{
for ( ; patch; patch = patch->next) {
const char *name;
name = patch->old_name ? patch->old_name : patch->new_name;
name = patch->new_name ? patch->new_name : patch->old_name;
printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
if (line_termination && quote_c_style(name, NULL, NULL, 0))
quote_c_style(name, NULL, stdout, 0);
......@@ -1720,7 +1920,8 @@ static void remove_file(struct patch *patch)
die("unable to remove %s from index", patch->old_name);
cache_tree_invalidate_path(active_cache_tree, patch->old_name);
}
unlink(patch->old_name);
if (!cached)
unlink(patch->old_name);
}
static void add_index_file(const char *path, unsigned mode, void *buf, unsigned long size)
......@@ -1737,9 +1938,11 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
memcpy(ce->name, path, namelen);
ce->ce_mode = create_ce_mode(mode);
ce->ce_flags = htons(namelen);
if (lstat(path, &st) < 0)
die("unable to stat newly created file %s", path);
fill_stat_cache_info(ce, &st);
if (!cached) {
if (lstat(path, &st) < 0)
die("unable to stat newly created file %s", path);
fill_stat_cache_info(ce, &st);
}
if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
die("unable to create backing store for newly created file %s", path);
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
......@@ -1776,6 +1979,8 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
*/
static void create_one_file(char *path, unsigned mode, const char *buf, unsigned long size)
{
if (cached)
return;
if (!try_create_file(path, mode, buf, size))
return;
......@@ -1876,7 +2081,6 @@ static int use_patch(struct patch *p)
static int apply_patch(int fd, const char *filename)
{
int newfd;
unsigned long offset, size;
char *buffer = read_patch_file(fd, &size);
struct patch *list = NULL, **listp = &list;
......@@ -1907,12 +2111,11 @@ static int apply_patch(int fd, const char *filename)
size -= nr;
}
newfd = -1;
if (whitespace_error && (new_whitespace == error_on_whitespace))
apply = 0;
write_index = check_index && apply;
if (write_index)
if (write_index && newfd < 0)
newfd = hold_index_file_for_update(&cache_file, get_index_file());
if (check_index) {
if (read_cache() < 0)
......@@ -1925,12 +2128,6 @@ static int apply_patch(int fd, const char *filename)
if (apply)
write_out_results(list, skipped_patch);
if (write_index) {
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))
die("Unable to write new cachefile");
}
if (show_index_info)
show_index_list(list);
......@@ -1993,7 +2190,8 @@ int main(int argc, char **argv)
diffstat = 1;
continue;
}
if (!strcmp(arg, "--allow-binary-replacement")) {
if (!strcmp(arg, "--allow-binary-replacement") ||
!strcmp(arg, "--binary")) {
allow_binary_replacement = 1;
continue;
}
......@@ -2016,6 +2214,11 @@ int main(int argc, char **argv)
check_index = 1;
continue;
}
if (!strcmp(arg, "--cached")) {
check_index = 1;
cached = 1;
continue;
}
if (!strcmp(arg, "--apply")) {
apply = 1;
continue;
......@@ -2088,5 +2291,12 @@ int main(int argc, char **argv)
whitespace_error == 1 ? "" : "s",
whitespace_error == 1 ? "s" : "");
}
if (write_index) {
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))
die("Unable to write new cachefile");
}
return 0;
}
#include "cache.h"
#undef DEBUG_85
#ifdef DEBUG_85
#define say(a) fprintf(stderr, a)
#define say1(a,b) fprintf(stderr, a, b)
#define say2(a,b,c) fprintf(stderr, a, b, c)
#else
#define say(a) do {} while(0)
#define say1(a,b) do {} while(0)
#define say2(a,b,c) do {} while(0)
#endif
static const char en85[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z',
'!', '#', '$', '%', '&', '(', ')', '*', '+', '-',
';', '<', '=', '>', '?', '@', '^', '_', '`', '{',
'|', '}', '~'
};
static char de85[256];
static void prep_base85(void)
{
int i;
if (de85['Z'])
return;
for (i = 0; i < ARRAY_SIZE(en85); i++) {
int ch = en85[i];
de85[ch] = i + 1;
}
}
int decode_85(char *dst, char *buffer, int len)
{
prep_base85();
say2("decode 85 <%.*s>", len/4*5, buffer);
while (len) {
unsigned acc = 0;
int de, cnt = 4;
unsigned char ch;
do {
ch = *buffer++;
de = de85[ch];
if (--de < 0)
return error("invalid base85 alphabet %c", ch);
acc = acc * 85 + de;
} while (--cnt);
ch = *buffer++;
de = de85[ch];
if (--de < 0)
return error("invalid base85 alphabet %c", ch);
/*
* Detect overflow. The largest
* 5-letter possible is "|NsC0" to
* encode 0xffffffff, and "|NsC" gives
* 0x03030303 at this point (i.e.
* 0xffffffff = 0x03030303 * 85).
*/
if (0x03030303 < acc ||
0xffffffff - de < (acc *= 85))
error("invalid base85 sequence %.5s", buffer-5);
acc += de;
say1(" %08x", acc);
cnt = (len < 4) ? len : 4;
len -= cnt;
do {
acc = (acc << 8) | (acc >> 24);
*dst++ = acc;
} while (--cnt);
}
say("\n");
return 0;
}
void encode_85(char *buf, unsigned char *data, int bytes)
{
prep_base85();
say("encode 85");
while (bytes) {
unsigned acc = 0;
int cnt;
for (cnt = 24; cnt >= 0; cnt -= 8) {
int ch = *data++;
acc |= ch << cnt;
if (--bytes == 0)
break;
}
say1(" %08x", acc);
for (cnt = 4; cnt >= 0; cnt--) {
int val = acc % 85;
acc /= 85;
buf[cnt] = en85[val];
}
buf += 5;
}
say("\n");
*buf = 0;
}
#ifdef DEBUG_85
int main(int ac, char **av)
{
char buf[1024];
if (!strcmp(av[1], "-e")) {
int len = strlen(av[2]);
encode_85(buf, av[2], len);
if (len <= 26) len = len + 'A' - 1;
else len = len + 'a' - 26 + 1;
printf("encoded: %c%s\n", len, buf);
return 0;
}
if (!strcmp(av[1], "-d")) {
int len = *av[2];
if ('A' <= len && len <= 'Z') len = len - 'A' + 1;
else len = len - 'a' + 26 + 1;
decode_85(buf, av[2]+1, len);
printf("decoded: %.*s\n", len, buf);
return 0;
}
if (!strcmp(av[1], "-t")) {
char t[4] = { -1,-1,-1,-1 };
encode_85(buf, t, 4);
printf("encoded: D%s\n", buf);
return 0;
}
}
#endif
......@@ -515,9 +515,9 @@ static int compare_tree_path(struct rev_info* revs,
paths[1] = NULL;
diff_tree_setup_paths(get_pathspec(revs->prefix, paths),
&revs->diffopt);
&revs->pruning);
ret = rev_compare_tree(revs, c1->tree, c2->tree);
diff_tree_release_paths(&revs->diffopt);
diff_tree_release_paths(&revs->pruning);
return ret;
}
......@@ -531,9 +531,9 @@ static int same_tree_as_empty_path(struct rev_info *revs, struct tree* t1,
paths[1] = NULL;
diff_tree_setup_paths(get_pathspec(revs->prefix, paths),
&revs->diffopt);
&revs->pruning);
ret = rev_same_tree_as_empty(revs, t1);
diff_tree_release_paths(&revs->diffopt);
diff_tree_release_paths(&revs->pruning);
return ret;
}
......@@ -834,7 +834,7 @@ int main(int argc, const char **argv)
args[0] = filename;
args[1] = NULL;
diff_tree_setup_paths(args, &rev.diffopt);
diff_tree_setup_paths(args, &rev.pruning);
prepare_revision_walk(&rev);
process_commits(&rev, filename, &initial);
......
/*
* "git add" builtin command
*
* Copyright (C) 2006 Linus Torvalds
*/
#include <fnmatch.h>
#include "cache.h"
#include "builtin.h"
#include "dir.h"
#include "cache-tree.h"
static const char builtin_add_usage[] =
"git-add [-n] [-v] <filepattern>...";
static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
{
char *seen;
int i, specs;
struct dir_entry **src, **dst;
for (specs = 0; pathspec[specs]; specs++)
/* nothing */;
seen = xmalloc(specs);
memset(seen, 0, specs);
src = dst = dir->entries;
i = dir->nr;
while (--i >= 0) {
struct dir_entry *entry = *src++;
if (!match_pathspec(pathspec, entry->name, entry->len, prefix, seen)) {
free(entry);
continue;
}
*dst++ = entry;
}
dir->nr = dst - dir->entries;
for (i = 0; i < specs; i++) {
struct stat st;
const char *match;
if (seen[i])
continue;
/* Existing file? We must have ignored it */
match = pathspec[i];
if (!match[0] || !lstat(match, &st))
continue;
die("pathspec '%s' did not match any files", match);
}
}
static void fill_directory(struct dir_struct *dir, const char **pathspec)
{
const char *path, *base;
int baselen;
/* Set up the default git porcelain excludes */
memset(dir, 0, sizeof(*dir));
dir->exclude_per_dir = ".gitignore";
path = git_path("info/exclude");
if (!access(path, R_OK))
add_excludes_from_file(dir, path);
/*
* Calculate common prefix for the pathspec, and
* use that to optimize the directory walk
*/
baselen = common_prefix(pathspec);
path = ".";
base = "";
if (baselen) {
char *common = xmalloc(baselen + 1);
common = xmalloc(baselen + 1);
memcpy(common, *pathspec, baselen);
common[baselen] = 0;
path = base = common;
}
/* Read the directory and prune it */
read_directory(dir, path, base, baselen);
if (pathspec)
prune_directory(dir, pathspec, baselen);
}
static int add_file_to_index(const char *path, int verbose)
{
int size, namelen;
struct stat st;
struct cache_entry *ce;
if (lstat(path, &st))
die("%s: unable to stat (%s)", path, strerror(errno));
if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode))
die("%s: can only add regular files or symbolic links", path);
namelen = strlen(path);
size = cache_entry_size(namelen);
ce = xcalloc(1, size);
memcpy(ce->name, path, namelen);
ce->ce_flags = htons(namelen);
fill_stat_cache_info(ce, &st);
ce->ce_mode = create_ce_mode(st.st_mode);
if (!trust_executable_bit) {
/* If there is an existing entry, pick the mode bits
* from it.
*/
int pos = cache_name_pos(path, namelen);
if (pos >= 0)
ce->ce_mode = active_cache[pos]->ce_mode;
}
if (index_path(ce->sha1, path, &st, 1))
die("unable to index file %s", path);
if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD))
die("unable to add %s to index",path);
if (verbose)
printf("add '%s'\n", path);
cache_tree_invalidate_path(active_cache_tree, path);
return 0;
}
static struct cache_file cache_file;
int cmd_add(int argc, const char **argv, char **envp)
{
int i, newfd;
int verbose = 0, show_only = 0;
const char *prefix = setup_git_directory();
const char **pathspec;
struct dir_struct dir;
git_config(git_default_config);
newfd = hold_index_file_for_update(&cache_file, get_index_file());
if (newfd < 0)
die("unable to create new cachefile");
if (read_cache() < 0)
die("index file corrupt");
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (arg[0] != '-')
break;
if (!strcmp(arg, "--")) {
i++;
break;
}
if (!strcmp(arg, "-n")) {
show_only = 1;
continue;
}
if (!strcmp(arg, "-v")) {
verbose = 1;
continue;
}
die(builtin_add_usage);
}
git_config(git_default_config);
pathspec = get_pathspec(prefix, argv + i);
fill_directory(&dir, pathspec);
if (show_only) {
const char *sep = "", *eof = "";
for (i = 0; i < dir.nr; i++) {
printf("%s%s", sep, dir.entries[i]->name);
sep = " ";
eof = "\n";
}
fputs(eof, stdout);
return 0;
}
for (i = 0; i < dir.nr; i++)
add_file_to_index(dir.entries[i]->name, verbose);
if (active_cache_changed) {
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))
die("Unable to write new index file");
}
return 0;
}
......@@ -4,14 +4,11 @@
#include "cache.h"
#include "refs.h"
#include "builtin.h"
#include <stdio.h>
int main(int ac, char **av)
int cmd_check_ref_format(int argc, const char **argv, char **envp)
{
if (ac != 2)
usage("git-check-ref-format refname");
if (check_ref_format(av[1]))
exit(1);
return 0;
if (argc != 2)
usage("git check-ref-format refname");
return !!check_ref_format(argv[1]);
}
/*
* Builtin "git count-objects".
*
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
#include "builtin.h"
static const char count_objects_usage[] = "git-count-objects [-v]";
static void count_objects(DIR *d, char *path, int len, int verbose,
unsigned long *loose,
unsigned long *loose_size,
unsigned long *packed_loose,
unsigned long *garbage)
{
struct dirent *ent;
while ((ent = readdir(d)) != NULL) {
char hex[41];
unsigned char sha1[20];
const char *cp;
int bad = 0;
if ((ent->d_name[0] == '.') &&
(ent->d_name[1] == 0 ||
((ent->d_name[1] == '.') && (ent->d_name[2] == 0))))
continue;
for (cp = ent->d_name; *cp; cp++) {
int ch = *cp;
if (('0' <= ch && ch <= '9') ||
('a' <= ch && ch <= 'f'))
continue;
bad = 1;
break;
}
if (cp - ent->d_name != 38)
bad = 1;
else {
struct stat st;
memcpy(path + len + 3, ent->d_name, 38);
path[len + 2] = '/';
path[len + 41] = 0;
if (lstat(path, &st) || !S_ISREG(st.st_mode))
bad = 1;
else
(*loose_size) += st.st_blocks;
}
if (bad) {
if (verbose) {
error("garbage found: %.*s/%s",
len + 2, path, ent->d_name);
(*garbage)++;
}
continue;
}
(*loose)++;
if (!verbose)
continue;
memcpy(hex, path+len, 2);
memcpy(hex+2, ent->d_name, 38);
hex[40] = 0;
if (get_sha1_hex(hex, sha1))
die("internal error");
if (has_sha1_pack(sha1))
(*packed_loose)++;
}
}
int cmd_count_objects(int ac, const char **av, char **ep)
{
int i;
int verbose = 0;
const char *objdir = get_object_directory();
int len = strlen(objdir);
char *path = xmalloc(len + 50);
unsigned long loose = 0, packed = 0, packed_loose = 0, garbage = 0;
unsigned long loose_size = 0;
for (i = 1; i < ac; i++) {
const char *arg = av[i];
if (*arg != '-')
break;
else if (!strcmp(arg, "-v"))
verbose = 1;
else
usage(count_objects_usage);
}
/* we do not take arguments other than flags for now */
if (i < ac)
usage(count_objects_usage);
memcpy(path, objdir, len);
if (len && objdir[len-1] != '/')
path[len++] = '/';
for (i = 0; i < 256; i++) {
DIR *d;
sprintf(path + len, "%02x", i);
d = opendir(path);
if (!d)
continue;
count_objects(d, path, len, verbose,
&loose, &loose_size, &packed_loose, &garbage);
closedir(d);
}
if (verbose) {
struct packed_git *p;
if (!packed_git)
prepare_packed_git();
for (p = packed_git; p; p = p->next) {
if (!p->pack_local)
continue;
packed += num_packed_objects(p);
}
printf("count: %lu\n", loose);
printf("size: %lu\n", loose_size / 2);
printf("in-pack: %lu\n", packed);
printf("prune-packable: %lu\n", packed_loose);
printf("garbage: %lu\n", garbage);
}
else
printf("%lu objects, %lu kilobytes\n",
loose, loose_size / 2);
return 0;
}
/*
* Builtin "git diff"
*
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.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"
/* NEEDSWORK: struct object has place for name but we _do_
* know mode when we extracted the blob out of a tree, which
* we currently lose.
*/
struct blobinfo {
unsigned char sha1[20];
const char *name;
};
static const char builtin_diff_usage[] =
"diff <options> <rev>{0,2} -- <path>*";
static int builtin_diff_files(struct rev_info *revs,
int argc, const char **argv)
{
int silent = 0;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--base"))
revs->max_count = 1;
else if (!strcmp(arg, "--ours"))
revs->max_count = 2;
else if (!strcmp(arg, "--theirs"))
revs->max_count = 3;
else if (!strcmp(arg, "-q"))
silent = 1;
else if (!strcmp(arg, "--raw"))
revs->diffopt.output_format = DIFF_FORMAT_RAW;
else
usage(builtin_diff_usage);
argv++; argc--;
}
/*
* Make sure there are NO revision (i.e. pending object) parameter,
* specified rev.max_count is reasonable (0 <= n <= 3), and
* there is no other revision filtering parameter.
*/
if (revs->pending_objects ||
revs->min_age != -1 ||
revs->max_age != -1 ||
3 < revs->max_count)
usage(builtin_diff_usage);
if (revs->max_count < 0 &&
(revs->diffopt.output_format == DIFF_FORMAT_PATCH))
revs->combine_merges = revs->dense_combined_merges = 1;
/*
* Backward compatibility wart - "diff-files -s" used to
* defeat the common diff option "-s" which asked for
* DIFF_FORMAT_NO_OUTPUT.
*/
if (revs->diffopt.output_format == DIFF_FORMAT_NO_OUTPUT)
revs->diffopt.output_format = DIFF_FORMAT_RAW;
return run_diff_files(revs, silent);
}
static void stuff_change(struct diff_options *opt,
unsigned old_mode, unsigned new_mode,
const unsigned char *old_sha1,
const unsigned char *new_sha1,
const char *old_name,
const char *new_name)
{
struct diff_filespec *one, *two;
if (memcmp(null_sha1, old_sha1, 20) &&
memcmp(null_sha1, new_sha1, 20) &&
!memcmp(old_sha1, new_sha1, 20))
return;
if (opt->reverse_diff) {
unsigned tmp;
const unsigned char *tmp_u;
const char *tmp_c;
tmp = old_mode; old_mode = new_mode; new_mode = tmp;
tmp_u = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_u;
tmp_c = old_name; old_name = new_name; new_name = tmp_c;
}
one = alloc_filespec(old_name);
two = alloc_filespec(new_name);
fill_filespec(one, old_sha1, old_mode);
fill_filespec(two, new_sha1, new_mode);
/* NEEDSWORK: shouldn't this part of diffopt??? */
diff_queue(&diff_queued_diff, one, two);
}
static int builtin_diff_b_f(struct rev_info *revs,
int argc, const char **argv,
struct blobinfo *blob,
const char *path)
{
/* Blob vs file in the working tree*/
struct stat st;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--raw"))
revs->diffopt.output_format = DIFF_FORMAT_RAW;
else
usage(builtin_diff_usage);
argv++; argc--;
}
if (lstat(path, &st))
die("'%s': %s", path, strerror(errno));
if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
die("'%s': not a regular file or symlink", path);
stuff_change(&revs->diffopt,
canon_mode(st.st_mode), canon_mode(st.st_mode),
blob[0].sha1, null_sha1,
path, path);
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
return 0;
}
static int builtin_diff_blobs(struct rev_info *revs,
int argc, const char **argv,
struct blobinfo *blob)
{
/* Blobs: the arguments are reversed when setup_revisions()
* picked them up.
*/
unsigned mode = canon_mode(S_IFREG | 0644);
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--raw"))
revs->diffopt.output_format = DIFF_FORMAT_RAW;
else
usage(builtin_diff_usage);
argv++; argc--;
}
stuff_change(&revs->diffopt,
mode, mode,
blob[1].sha1, blob[0].sha1,
blob[0].name, blob[0].name);
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
return 0;
}
static int builtin_diff_index(struct rev_info *revs,
int argc, const char **argv)
{
int cached = 0;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--cached"))
cached = 1;
else if (!strcmp(arg, "--raw"))
revs->diffopt.output_format = DIFF_FORMAT_RAW;
else
usage(builtin_diff_usage);
argv++; argc--;
}
/*
* Make sure there is one revision (i.e. pending object),
* and there is no revision filtering parameters.
*/
if (!revs->pending_objects || revs->pending_objects->next ||
revs->max_count != -1 || revs->min_age != -1 ||
revs->max_age != -1)
usage(builtin_diff_usage);
return run_diff_index(revs, cached);
}
static int builtin_diff_tree(struct rev_info *revs,
int argc, const char **argv,
struct object_list *ent)
{
const unsigned char *(sha1[2]);
int swap = 1;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--raw"))
revs->diffopt.output_format = DIFF_FORMAT_RAW;
else
usage(builtin_diff_usage);
argv++; argc--;
}
/* We saw two trees, ent[0] and ent[1].
* unless ent[0] is unintesting, they are swapped
*/
if (ent[0].item->flags & UNINTERESTING)
swap = 0;
sha1[swap] = ent[0].item->sha1;
sha1[1-swap] = ent[1].item->sha1;
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
log_tree_diff_flush(revs);
return 0;
}
static int builtin_diff_combined(struct rev_info *revs,
int argc, const char **argv,
struct object_list *ent,
int ents)
{
const unsigned char (*parent)[20];
int i;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--raw"))
revs->diffopt.output_format = DIFF_FORMAT_RAW;
else
usage(builtin_diff_usage);
argv++; argc--;
}
if (!revs->dense_combined_merges && !revs->combine_merges)
revs->dense_combined_merges = revs->combine_merges = 1;
parent = xmalloc(ents * sizeof(*parent));
/* Again, the revs are all reverse */
for (i = 0; i < ents; i++)
memcpy(parent + i, ent[ents - 1 - i].item->sha1, 20);
diff_tree_combined(parent[0], parent + 1, ents - 1,
revs->dense_combined_merges, revs);
return 0;
}
static void add_head(struct rev_info *revs)
{
unsigned char sha1[20];
struct object *obj;
if (get_sha1("HEAD", sha1))
return;
obj = parse_object(sha1);
if (!obj)
return;
add_object(obj, &revs->pending_objects, NULL, "HEAD");
}
int cmd_diff(int argc, const char **argv, char **envp)
{
struct rev_info rev;
struct object_list *list, ent[100];
int ents = 0, blobs = 0, paths = 0;
const char *path = NULL;
struct blobinfo blob[2];
/*
* We could get N tree-ish in the rev.pending_objects list.
* Also there could be M blobs there, and P pathspecs.
*
* N=0, M=0:
* cache vs files (diff-files)
* N=0, M=2:
* compare two random blobs. P must be zero.
* N=0, M=1, P=1:
* compare a blob with a working tree file.
*
* N=1, M=0:
* tree vs cache (diff-index --cached)
*
* N=2, M=0:
* tree vs tree (diff-tree)
*
* Other cases are errors.
*/
git_config(git_diff_config);
init_revisions(&rev);
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
argc = setup_revisions(argc, argv, &rev, NULL);
/* Do we have --cached and not have a pending object, then
* default to HEAD by hand. Eek.
*/
if (!rev.pending_objects) {
int i;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--"))
break;
else if (!strcmp(arg, "--cached")) {
add_head(&rev);
break;
}
}
}
for (list = rev.pending_objects; list; list = list->next) {
struct object *obj = list->item;
const char *name = list->name;
int flags = (obj->flags & UNINTERESTING);
if (!obj->parsed)
obj = parse_object(obj->sha1);
obj = deref_tag(obj, NULL, 0);
if (!obj)
die("invalid object '%s' given.", name);
if (!strcmp(obj->type, commit_type))
obj = &((struct commit *)obj)->tree->object;
if (!strcmp(obj->type, tree_type)) {
if (ARRAY_SIZE(ent) <= ents)
die("more than %d trees given: '%s'",
(int) ARRAY_SIZE(ent), name);
obj->flags |= flags;
ent[ents].item = obj;
ent[ents].name = name;
ents++;
continue;
}
if (!strcmp(obj->type, blob_type)) {
if (2 <= blobs)
die("more than two blobs given: '%s'", name);
memcpy(blob[blobs].sha1, obj->sha1, 20);
blob[blobs].name = name;
blobs++;
continue;
}
die("unhandled object '%s' given.", name);
}
if (rev.prune_data) {
const char **pathspec = rev.prune_data;
while (*pathspec) {
if (!path)
path = *pathspec;
paths++;
pathspec++;
}
}
/*
* Now, do the arguments look reasonable?
*/
if (!ents) {
switch (blobs) {
case 0:
return builtin_diff_files(&rev, argc, argv);
break;
case 1:
if (paths != 1)
usage(builtin_diff_usage);
return builtin_diff_b_f(&rev, argc, argv, blob, path);
break;
case 2:
if (paths)
usage(builtin_diff_usage);
return builtin_diff_blobs(&rev, argc, argv, blob);
break;
default:
usage(builtin_diff_usage);
}
}
else if (blobs)
usage(builtin_diff_usage);
else if (ents == 1)
return builtin_diff_index(&rev, argc, argv);
else if (ents == 2)
return builtin_diff_tree(&rev, argc, argv, ent);
else
return builtin_diff_combined(&rev, argc, argv, ent, ents);
usage(builtin_diff_usage);
}
此差异已折叠。
......@@ -3,6 +3,7 @@
*
* Builtin help-related commands (help, usage, version)
*/
#include <sys/ioctl.h>
#include "cache.h"
#include "builtin.h"
#include "exec_cmd.h"
......
......@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
#include "builtin.h"
#ifndef DEFAULT_GIT_TEMPLATE_DIR
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/"
......@@ -116,7 +117,7 @@ static void copy_templates_1(char *path, int baselen,
}
}
static void copy_templates(const char *git_dir, int len, char *template_dir)
static void copy_templates(const char *git_dir, int len, const char *template_dir)
{
char path[PATH_MAX];
char template_path[PATH_MAX];
......@@ -163,7 +164,7 @@ static void copy_templates(const char *git_dir, int len, char *template_dir)
closedir(dir);
}
static void create_default_files(const char *git_dir, char *template_path)
static void create_default_files(const char *git_dir, const char *template_path)
{
unsigned len = strlen(git_dir);
static char path[PATH_MAX];
......@@ -234,15 +235,16 @@ static const char init_db_usage[] =
* On the other hand, it might just make lookup slower and messier. You
* be the judge. The default case is to have one DB per managed directory.
*/
int main(int argc, char **argv)
int cmd_init_db(int argc, const char **argv, char **envp)
{
const char *git_dir;
const char *sha1_dir;
char *path, *template_dir = NULL;
const char *template_dir = NULL;
char *path;
int len, i;
for (i = 1; i < argc; i++, argv++) {
char *arg = argv[1];
const char *arg = argv[1];
if (!strncmp(arg, "--template=", 11))
template_dir = arg+11;
else if (!strcmp(arg, "--shared"))
......
......@@ -19,6 +19,13 @@ static int cmd_log_wc(int argc, const char **argv, char **envp,
rev->commit_format = CMIT_FMT_DEFAULT;
rev->verbose_header = 1;
argc = setup_revisions(argc, argv, rev, "HEAD");
if (rev->always_show_header) {
if (rev->diffopt.pickaxe || rev->diffopt.filter) {
rev->always_show_header = 0;
if (rev->diffopt.output_format == DIFF_FORMAT_RAW)
rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
}
}
if (argc > 1)
die("unrecognized argument: %s", argv[1]);
......
/*
* "git push"
*/
#include "cache.h"
#include "refs.h"
#include "run-command.h"
#include "builtin.h"
#define MAX_URI (16)
static const char push_usage[] = "git push [--all] [--tags] [--force] <repository> [<refspec>...]";
static int all = 0, tags = 0, force = 0, thin = 1;
static const char *execute = NULL;
#define BUF_SIZE (2084)
static char buffer[BUF_SIZE];
static const char **refspec = NULL;
static int refspec_nr = 0;
static void add_refspec(const char *ref)
{
int nr = refspec_nr + 1;
refspec = xrealloc(refspec, nr * sizeof(char *));
refspec[nr-1] = ref;
refspec_nr = nr;
}
static int expand_one_ref(const char *ref, const unsigned char *sha1)
{
/* Ignore the "refs/" at the beginning of the refname */
ref += 5;
if (strncmp(ref, "tags/", 5))
return 0;
add_refspec(strdup(ref));
return 0;
}
static void expand_refspecs(void)
{
if (all) {
if (refspec_nr)
die("cannot mix '--all' and a refspec");
/*
* No need to expand "--all" - we'll just use
* the "--all" flag to send-pack
*/
return;
}
if (!tags)
return;
for_each_ref(expand_one_ref);
}
static void set_refspecs(const char **refs, int nr)
{
if (nr) {
size_t bytes = nr * sizeof(char *);
refspec = xrealloc(refspec, bytes);
memcpy(refspec, refs, bytes);
refspec_nr = nr;
}
expand_refspecs();
}
static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
{
int n = 0;
FILE *f = fopen(git_path("remotes/%s", repo), "r");
int has_explicit_refspec = refspec_nr || all || tags;
if (!f)
return -1;
while (fgets(buffer, BUF_SIZE, f)) {
int is_refspec;
char *s, *p;
if (!strncmp("URL: ", buffer, 5)) {
is_refspec = 0;
s = buffer + 5;
} else if (!strncmp("Push: ", buffer, 6)) {
is_refspec = 1;
s = buffer + 6;
} else
continue;
/* Remove whitespace at the head.. */
while (isspace(*s))
s++;
if (!*s)
continue;
/* ..and at the end */
p = s + strlen(s);
while (isspace(p[-1]))
*--p = 0;
if (!is_refspec) {
if (n < MAX_URI)
uri[n++] = strdup(s);
else
error("more than %d URL's specified, ignoreing the rest", MAX_URI);
}
else if (is_refspec && !has_explicit_refspec)
add_refspec(strdup(s));
}
fclose(f);
if (!n)
die("remote '%s' has no URL", repo);
return n;
}
static const char **config_uri;
static const char *config_repo;
static int config_repo_len;
static int config_current_uri;
static int config_get_refspecs;
static int get_remote_config(const char* key, const char* value)
{
if (!strncmp(key, "remote.", 7) &&
!strncmp(key + 7, config_repo, config_repo_len)) {
if (!strcmp(key + 7 + config_repo_len, ".url")) {
if (config_current_uri < MAX_URI)
config_uri[config_current_uri++] = strdup(value);
else
error("more than %d URL's specified, ignoring the rest", MAX_URI);
}
else if (config_get_refspecs &&
!strcmp(key + 7 + config_repo_len, ".push"))
add_refspec(strdup(value));
}
return 0;
}
static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI])
{
config_repo_len = strlen(repo);
config_repo = repo;
config_current_uri = 0;
config_uri = uri;
config_get_refspecs = !(refspec_nr || all || tags);
git_config(get_remote_config);
return config_current_uri;
}
static int get_branches_uri(const char *repo, const char *uri[MAX_URI])
{
const char *slash = strchr(repo, '/');
int n = slash ? slash - repo : 1000;
FILE *f = fopen(git_path("branches/%.*s", n, repo), "r");
char *s, *p;
int len;
if (!f)
return 0;
s = fgets(buffer, BUF_SIZE, f);
fclose(f);
if (!s)
return 0;
while (isspace(*s))
s++;
if (!*s)
return 0;
p = s + strlen(s);
while (isspace(p[-1]))
*--p = 0;
len = p - s;
if (slash)
len += strlen(slash);
p = xmalloc(len + 1);
strcpy(p, s);
if (slash)
strcat(p, slash);
uri[0] = p;
return 1;
}
/*
* Read remotes and branches file, fill the push target URI
* list. If there is no command line refspecs, read Push: lines
* to set up the *refspec list as well.
* return the number of push target URIs
*/
static int read_config(const char *repo, const char *uri[MAX_URI])
{
int n;
if (*repo != '/') {
n = get_remotes_uri(repo, uri);
if (n > 0)
return n;
n = get_config_remotes_uri(repo, uri);
if (n > 0)
return n;
n = get_branches_uri(repo, uri);
if (n > 0)
return n;
}
uri[0] = repo;
return 1;
}
static int do_push(const char *repo)
{
const char *uri[MAX_URI];
int i, n;
int remote;
const char **argv;
int argc;
n = read_config(repo, uri);
if (n <= 0)
die("bad repository '%s'", repo);
argv = xmalloc((refspec_nr + 10) * sizeof(char *));
argv[0] = "dummy-send-pack";
argc = 1;
if (all)
argv[argc++] = "--all";
if (force)
argv[argc++] = "--force";
if (execute)
argv[argc++] = execute;
if (thin)
argv[argc++] = "--thin";
remote = argc;
argv[argc++] = "dummy-remote";
while (refspec_nr--)
argv[argc++] = *refspec++;
argv[argc] = NULL;
for (i = 0; i < n; i++) {
int error;
const char *dest = uri[i];
const char *sender = "git-send-pack";
if (!strncmp(dest, "http://", 7) ||
!strncmp(dest, "https://", 8))
sender = "git-http-push";
argv[0] = sender;
argv[remote] = dest;
error = run_command_v(argc, argv);
if (!error)
continue;
switch (error) {
case -ERR_RUN_COMMAND_FORK:
die("unable to fork for %s", sender);
case -ERR_RUN_COMMAND_EXEC:
die("unable to exec %s", sender);
case -ERR_RUN_COMMAND_WAITPID:
case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
die("%s died with strange error", sender);
default:
return -error;
}
}
return 0;
}
int cmd_push(int argc, const char **argv, char **envp)
{
int i;
const char *repo = "origin"; // default repository
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (arg[0] != '-') {
repo = arg;
i++;
break;
}
if (!strcmp(arg, "--all")) {
all = 1;
continue;
}
if (!strcmp(arg, "--tags")) {
tags = 1;
continue;
}
if (!strcmp(arg, "--force")) {
force = 1;
continue;
}
if (!strcmp(arg, "--thin")) {
thin = 1;
continue;
}
if (!strcmp(arg, "--no-thin")) {
thin = 0;
continue;
}
if (!strncmp(arg, "--exec=", 7)) {
execute = arg;
continue;
}
usage(push_usage);
}
set_refspecs(argv + i, argc - i);
return do_push(repo);
}
......@@ -7,6 +7,7 @@
#include "tree-walk.h"
#include "diff.h"
#include "revision.h"
#include "builtin.h"
/* bits #0-15 in revision.h */
......@@ -36,7 +37,7 @@ static const char rev_list_usage[] =
" --bisect"
;
struct rev_info revs;
static struct rev_info revs;
static int bisect_list = 0;
static int show_timestamp = 0;
......@@ -291,7 +292,7 @@ static void mark_edges_uninteresting(struct commit_list *list)
}
}
int main(int argc, const char **argv)
int cmd_rev_list(int argc, const char **argv, char **envp)
{
struct commit_list *list;
int i;
......
此差异已折叠。
......@@ -19,5 +19,15 @@ extern int cmd_version(int argc, const char **argv, char **envp);
extern int cmd_whatchanged(int argc, const char **argv, char **envp);
extern int cmd_show(int argc, const char **argv, char **envp);
extern int cmd_log(int argc, const char **argv, char **envp);
extern int cmd_diff(int argc, const char **argv, char **envp);
extern int cmd_count_objects(int argc, const char **argv, char **envp);
extern int cmd_push(int argc, const char **argv, char **envp);
extern int cmd_grep(int argc, const char **argv, char **envp);
extern int cmd_rm(int argc, const char **argv, char **envp);
extern int cmd_add(int argc, const char **argv, char **envp);
extern int cmd_rev_list(int argc, const char **argv, char **envp);
extern int cmd_check_ref_format(int argc, const char **argv, char **envp);
extern int cmd_init_db(int argc, const char **argv, char **envp);
#endif
......@@ -136,12 +136,14 @@ extern const char *setup_git_directory(void);
extern const char *prefix_path(const char *prefix, int len, const char *path);
extern const char *prefix_filename(const char *prefix, int len, const char *path);
extern void verify_filename(const char *prefix, const char *name);
extern void verify_non_filename(const char *prefix, const char *name);
#define alloc_nr(x) (((x)+16)*3/2)
/* Initialize and use the cache information */
extern int read_cache(void);
extern int write_cache(int newfd, struct cache_entry **cache, int entries);
extern int verify_path(const char *path);
extern int cache_name_pos(const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
......@@ -158,6 +160,12 @@ extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_o
extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
#define REFRESH_REALLY 0x0001 /* ignore_valid */
#define REFRESH_UNMERGED 0x0002 /* allow unmerged */
#define REFRESH_QUIET 0x0004 /* be quiet about it */
#define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */
extern int refresh_cache(unsigned int flags);
struct cache_file {
struct cache_file *next;
char lockfile[PATH_MAX];
......@@ -169,7 +177,7 @@ extern void rollback_index_file(struct cache_file *);
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
extern int assume_unchanged;
extern int only_use_symrefs;
extern int prefer_symlink_refs;
extern int warn_ambiguous_refs;
extern int diff_rename_limit_default;
extern int shared_repository;
......@@ -363,4 +371,8 @@ extern int receive_keep_pack(int fd[2], const char *me, int quiet);
/* pager.c */
extern void setup_pager(void);
/* base85 */
int decode_85(char *dst, char *line, int linelen);
void encode_85(char *buf, unsigned char *data, int bytes);
#endif /* CACHE_H */
......@@ -103,8 +103,10 @@ int main(int argc, char **argv)
setup_git_directory();
git_config(git_default_config);
if (argc != 3 || get_sha1(argv[2], sha1))
if (argc != 3)
usage("git-cat-file [-t|-s|-e|-p|<type>] <sha1>");
if (get_sha1(argv[2], sha1))
die("Not a valid object name %s", argv[2]);
opt = 0;
if ( argv[1][0] == '-' ) {
......@@ -133,8 +135,7 @@ int main(int argc, char **argv)
return !has_sha1_file(sha1);
case 'p':
if (get_sha1(argv[2], sha1) ||
sha1_object_info(sha1, type, NULL))
if (sha1_object_info(sha1, type, NULL))
die("Not a valid object name %s", argv[2]);
/* custom pretty-print here */
......
......@@ -270,12 +270,16 @@ int main(int argc, char **argv)
/* Check out named files first */
for ( ; i < argc; i++) {
const char *arg = argv[i];
const char *p;
if (all)
die("git-checkout-index: don't mix '--all' and explicit filenames");
if (read_from_stdin)
die("git-checkout-index: don't mix '--stdin' and explicit filenames");
checkout_file(prefix_path(prefix, prefix_length, arg));
p = prefix_path(prefix, prefix_length, arg);
checkout_file(p);
if (p < arg || p > arg + strlen(arg))
free((char*)p);
}
if (read_from_stdin) {
......@@ -285,6 +289,8 @@ int main(int argc, char **argv)
strbuf_init(&buf);
while (1) {
char *path_name;
const char *p;
read_line(&buf, stdin, line_termination);
if (buf.eof)
break;
......@@ -292,7 +298,10 @@ int main(int argc, char **argv)
path_name = unquote_c_style(buf.buf, NULL);
else
path_name = buf.buf;
checkout_file(prefix_path(prefix, prefix_length, path_name));
p = prefix_path(prefix, prefix_length, path_name);
checkout_file(p);
if (p < path_name || p > path_name + strlen(path_name))
free((char *)p);
if (path_name != buf.buf)
free(path_name);
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -321,8 +321,10 @@ int main(int argc, char **argv)
setup_git_directory();
if (argc != 2 || get_sha1(argv[1], sha1))
if (argc != 2)
usage("git-convert-objects <sha1>");
if (get_sha1(argv[1], sha1))
die("Not a valid object name %s", argv[1]);
entry = convert_entry(sha1);
printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册