diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-01-30 19:07:24 +0300 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-01-30 19:07:24 +0300 |
commit | 76db9dec8132d4377f6c32e4d45eb75fa0cc7a9a (patch) | |
tree | 80a6b54d21978b5c3879662bdc4f5951f804b808 | |
parent | b715cfbba4083d25ec0d0f94e440ad734607ddb0 (diff) | |
parent | 73a2acc0a09829f887fdf2dbcfba217102227932 (diff) |
Merge branch 'master' into sp/gfi
git-fast-import requires use of inttypes.h, but the master branch has
added it to git-compat-util differently than git-fast-import originally
had used it. This merge back of master to the fast-import topic is to
get (and use) inttypes.h the way master is using it.
This is a partially evil merge to remove the call to setup_ident(),
as the master branch now contains a change which makes this implicit
and therefore removed the function declaration. (commit 01754769).
Conflicts:
git-compat-util.h
252 files changed, 5440 insertions, 2661 deletions
diff --git a/.gitignore b/.gitignore index a9dc462cb5..d49994903e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ git-clean git-clone git-commit git-commit-tree +git-config git-convert-objects git-count-objects git-cvsexportcommit @@ -42,6 +43,7 @@ git-findtags git-fmt-merge-msg git-for-each-ref git-format-patch +git-fsck git-fsck-objects git-gc git-get-tar-commit-id @@ -30,7 +30,9 @@ Robert Fitzsimons <robfitz@273k.net> Santi Béjar <sbejar@gmail.com> Sean Estabrooks <seanlkml@sympatico.ca> Shawn O. Pearce <spearce@spearce.org> +Theodore Ts'o <tytso@mit.edu> Tony Luck <tony.luck@intel.com> +Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de> Ville Skyttä <scop@xemacs.org> YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> anonymous <linux@horizon.com> diff --git a/Documentation/.gitignore b/Documentation/.gitignore index c87c61af00..6a51331b2f 100644 --- a/Documentation/.gitignore +++ b/Documentation/.gitignore @@ -4,4 +4,4 @@ *.7 howto-index.txt doc.dep -README +cmds-*.txt diff --git a/Documentation/Makefile b/Documentation/Makefile index 93c7024b48..5314068d32 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -71,14 +71,24 @@ doc.dep : $(wildcard *.txt) build-docdep.perl -include doc.dep -git.7: README +cmds_txt = cmds-ancillaryinterrogators.txt \ + cmds-ancillarymanipulators.txt \ + cmds-mainporcelain.txt \ + cmds-plumbinginterrogators.txt \ + cmds-plumbingmanipulators.txt \ + cmds-synchingrepositories.txt \ + cmds-synchelpers.txt \ + cmds-purehelpers.txt \ + cmds-foreignscminterface.txt -README: ../README - cp $< $@ +$(cmds_txt): cmd-list.perl $(MAN1_TXT) + perl ./cmd-list.perl +git.7 git.html: git.txt core-intro.txt clean: - rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep README + rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep + rm -f $(cmds_txt) %.html : %.txt asciidoc -b xhtml11 -d manpage -f asciidoc.conf $< @@ -89,8 +99,6 @@ clean: %.xml : %.txt asciidoc -b docbook -d manpage -f asciidoc.conf $< -git.html: git.txt README - glossary.html : glossary.txt sort_glossary.pl cat $< | \ perl sort_glossary.pl | \ diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 646b6e7331..ce85d06c62 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -23,7 +23,8 @@ probably need to split up your commit to finer grained pieces. Oh, another thing. I am picky about whitespaces. Make sure your changes do not trigger errors with the sample pre-commit hook shipped -in templates/hooks--pre-commit. +in templates/hooks--pre-commit. To help ensure this does not happen, +run git diff --check on your changes before you commit. (2) Generate your patch using git tools out of your commits. @@ -72,7 +73,9 @@ other than the commit message itself. Place such "cover letter" material between the three dash lines and the diffstat. Do not attach the patch as a MIME attachment, compressed or not. -Do not let your e-mail client send quoted-printable. Many +Do not let your e-mail client send quoted-printable. Do not let +your e-mail client send format=flowed which would destroy +whitespaces in your patches. Many popular e-mail applications will not always transmit a MIME attachment as plain text, making it impossible to comment on your code. A MIME attachment also takes a bit more time to @@ -312,3 +315,19 @@ settings but I haven't tried, yet. mail.identity.default.compose_html => false mail.identity.id?.compose_html => false + + +Gnus +---- + +'|' in the *Summary* buffer can be used to pipe the current +message to an external program, and this is a handy way to drive +"git am". However, if the message is MIME encoded, what is +piped into the program is the representation you see in your +*Article* buffer after unwrapping MIME. This is often not what +you would want for two reasons. It tends to screw up non ASCII +characters (most notably in people's names), and also +whitespaces (fatal in patches). Running 'C-u g' to display the +message in raw form before using '|' to run the pipe can work +this problem around. + diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl new file mode 100755 index 0000000000..6dba8d8fe0 --- /dev/null +++ b/Documentation/cmd-list.perl @@ -0,0 +1,186 @@ +# + +sub format_one { + my ($out, $name) = @_; + my ($state, $description); + open I, '<', "$name.txt" or die "No such file $name.txt"; + while (<I>) { + if (/^NAME$/) { + $state = 1; + next; + } + if ($state == 1 && /^----$/) { + $state = 2; + next; + } + next if ($state != 2); + chomp; + $description = $_; + last; + } + close I; + if (!defined $description) { + die "No description found in $name.txt"; + } + if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) { + print $out "gitlink:$name\[1\]::\n"; + print $out "\t$text.\n\n"; + } + else { + die "Description does not match $name: $description"; + } +} + +my %cmds = (); +while (<DATA>) { + next if /^#/; + + chomp; + my ($name, $cat) = /^(\S+)\s+(.*)$/; + push @{$cmds{$cat}}, $name; +} + +for my $cat (qw(ancillaryinterrogators + ancillarymanipulators + mainporcelain + plumbinginterrogators + plumbingmanipulators + synchingrepositories + foreignscminterface + purehelpers + synchelpers)) { + my $out = "cmds-$cat.txt"; + open O, '>', "$out+" or die "Cannot open output file $out+"; + for (@{$cmds{$cat}}) { + format_one(\*O, $_); + } + close O; + rename "$out+", "$out"; +} + +__DATA__ +git-add mainporcelain +git-am mainporcelain +git-annotate ancillaryinterrogators +git-applymbox ancillaryinterrogators +git-applypatch purehelpers +git-apply plumbingmanipulators +git-archimport foreignscminterface +git-archive mainporcelain +git-bisect mainporcelain +git-blame ancillaryinterrogators +git-branch mainporcelain +git-cat-file plumbinginterrogators +git-checkout-index plumbingmanipulators +git-checkout mainporcelain +git-check-ref-format purehelpers +git-cherry ancillaryinterrogators +git-cherry-pick mainporcelain +git-clean mainporcelain +git-clone mainporcelain +git-commit mainporcelain +git-commit-tree plumbingmanipulators +git-convert-objects ancillarymanipulators +git-count-objects ancillaryinterrogators +git-cvsexportcommit foreignscminterface +git-cvsimport foreignscminterface +git-cvsserver foreignscminterface +git-daemon synchingrepositories +git-describe mainporcelain +git-diff-files plumbinginterrogators +git-diff-index plumbinginterrogators +git-diff mainporcelain +git-diff-stages plumbinginterrogators +git-diff-tree plumbinginterrogators +git-fetch mainporcelain +git-fetch-pack synchingrepositories +git-fmt-merge-msg purehelpers +git-for-each-ref plumbinginterrogators +git-format-patch mainporcelain +git-fsck ancillaryinterrogators +git-gc mainporcelain +git-get-tar-commit-id ancillaryinterrogators +git-grep mainporcelain +git-hash-object plumbingmanipulators +git-http-fetch synchelpers +git-http-push synchelpers +git-imap-send foreignscminterface +git-index-pack plumbingmanipulators +git-init mainporcelain +git-instaweb ancillaryinterrogators +gitk mainporcelain +git-local-fetch synchingrepositories +git-log mainporcelain +git-lost-found ancillarymanipulators +git-ls-files plumbinginterrogators +git-ls-remote plumbinginterrogators +git-ls-tree plumbinginterrogators +git-mailinfo purehelpers +git-mailsplit purehelpers +git-merge-base plumbinginterrogators +git-merge-file plumbingmanipulators +git-merge-index plumbingmanipulators +git-merge mainporcelain +git-merge-one-file purehelpers +git-merge-tree ancillaryinterrogators +git-mktag plumbingmanipulators +git-mktree plumbingmanipulators +git-mv mainporcelain +git-name-rev plumbinginterrogators +git-pack-objects plumbingmanipulators +git-pack-redundant plumbinginterrogators +git-pack-refs ancillarymanipulators +git-parse-remote synchelpers +git-patch-id purehelpers +git-peek-remote purehelpers +git-prune ancillarymanipulators +git-prune-packed plumbingmanipulators +git-pull mainporcelain +git-push mainporcelain +git-quiltimport foreignscminterface +git-read-tree plumbingmanipulators +git-rebase mainporcelain +git-receive-pack synchelpers +git-reflog ancillarymanipulators +git-relink ancillarymanipulators +git-repack ancillarymanipulators +git-config ancillarymanipulators +git-request-pull foreignscminterface +git-rerere ancillaryinterrogators +git-reset mainporcelain +git-resolve mainporcelain +git-revert mainporcelain +git-rev-list plumbinginterrogators +git-rev-parse ancillaryinterrogators +git-rm mainporcelain +git-runstatus ancillaryinterrogators +git-send-email foreignscminterface +git-send-pack synchingrepositories +git-shell synchelpers +git-shortlog mainporcelain +git-show mainporcelain +git-show-branch ancillaryinterrogators +git-show-index plumbinginterrogators +git-show-ref plumbinginterrogators +git-sh-setup purehelpers +git-ssh-fetch synchingrepositories +git-ssh-upload synchingrepositories +git-status mainporcelain +git-stripspace purehelpers +git-svn foreignscminterface +git-svnimport foreignscminterface +git-symbolic-ref plumbingmanipulators +git-tag mainporcelain +git-tar-tree plumbinginterrogators +git-unpack-file plumbinginterrogators +git-unpack-objects plumbingmanipulators +git-update-index plumbingmanipulators +git-update-ref plumbingmanipulators +git-update-server-info synchingrepositories +git-upload-archive synchelpers +git-upload-pack synchelpers +git-var plumbinginterrogators +git-verify-pack plumbinginterrogators +git-verify-tag ancillaryinterrogators +git-whatchanged ancillaryinterrogators +git-write-tree plumbingmanipulators diff --git a/Documentation/config.txt b/Documentation/config.txt index f7dba8977f..e5e019fedd 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2,21 +2,84 @@ CONFIGURATION FILE ------------------ The git configuration file contains a number of variables that affect -the git command's behavior. They can be used by both the git plumbing +the git command's behavior. `.git/config` file for each repository +is used to store the information for that repository, and +`$HOME/.gitconfig` is used to store per user information to give +fallback values for `.git/config` file. + +They can be used by both the git plumbing and the porcelains. The variables are divided into sections, where in the fully qualified variable name the variable itself is the last dot-separated segment and the section name is everything before the last dot. The variable names are case-insensitive and only alphanumeric characters are allowed. Some variables may appear multiple times. +Syntax +~~~~~~ + The syntax is fairly flexible and permissive; whitespaces are mostly -ignored. The '#' and ';' characters begin comments to the end of line, -blank lines are ignored, lines containing strings enclosed in square -brackets start sections and all the other lines are recognized -as setting variables, in the form 'name = value'. If there is no equal -sign on the line, the entire line is taken as 'name' and the variable -is recognized as boolean "true". String values may be entirely or partially -enclosed in double quotes; some variables may require special value format. +ignored. The '#' and ';' characters begin comments to the end of line, +blank lines are ignored. + +The file consists of sections and variables. A section begins with +the name of the section in square brackets and continues until the next +section begins. Section names are not case sensitive. Only alphanumeric +characters, '`-`' and '`.`' are allowed in section names. Each variable +must belong to some section, which means that there must be section +header before first setting of a variable. + +Sections can be further divided into subsections. To begin a subsection +put its name in double quotes, separated by space from the section name, +in the section header, like in example below: + +-------- + [section "subsection"] + +-------- + +Subsection names can contain any characters except newline (doublequote +'`"`' and backslash have to be escaped as '`\"`' and '`\\`', +respecitvely) and are case sensitive. Section header cannot span multiple +lines. Variables may belong directly to a section or to a given subsection. +You can have `[section]` if you have `[section "subsection"]`, but you +don't need to. + +There is also (case insensitive) alternative `[section.subsection]` syntax. +In this syntax subsection names follow the same restrictions as for section +name. + +All the other lines are recognized as setting variables, in the form +'name = value'. If there is no equal sign on the line, the entire line +is taken as 'name' and the variable is recognized as boolean "true". +The variable names are case-insensitive and only alphanumeric +characters and '`-`' are allowed. There can be more than one value +for a given variable; we say then that variable is multivalued. + +Leading and trailing whitespace in a variable value is discarded. +Internal whitespace within a variable value is retained verbatim. + +The values following the equals sign in variable assign are all either +a string, an integer, or a boolean. Boolean values may be given as yes/no, +0/1 or true/false. Case is not significant in boolean values, when +converting value to the canonical form using '--bool' type specifier; +`git-config` will ensure that the output is "true" or "false". + +String values may be entirely or partially enclosed in double quotes. +You need to enclose variable value in double quotes if you want to +preserve leading or trailing whitespace, or if variable value contains +beginning of comment characters (if it contains '#' or ';'). +Double quote '`"`' and backslash '`\`' characters in variable value must +be escaped: use '`\"`' for '`"`' and '`\\`' for '`\`'. + +The following escape sequences (beside '`\"`' and '`\\`') are recognized: +'`\n`' for newline character (NL), '`\t`' for horizontal tabulation (HT, TAB) +and '`\b`' for backspace (BS). No other char escape sequence, nor octal +char sequences are valid. + +Variable value ending in a '`\`' is continued on the next line in the +customary UNIX fashion. + +Some variables may require special value format. Example ~~~~~~~ @@ -35,6 +98,10 @@ Example remote = origin merge = refs/heads/devel + # Proxy settings + [core] + gitProxy="ssh" for "ssh://kernel.org/" + gitProxy=default-proxy ; for the rest Variables ~~~~~~~~~ @@ -183,10 +250,15 @@ color.branch.<slot>:: Use customized color for branch coloration. `<slot>` is one of `current` (the current branch), `local` (a local branch), `remote` (a tracking branch in refs/remotes/), `plain` (other - refs), or `reset` (the normal terminal color). The value for - these configuration variables can be one of: `normal`, `bold`, - `dim`, `ul`, `blink`, `reverse`, `reset`, `black`, `red`, - `green`, `yellow`, `blue`, `magenta`, `cyan`, or `white`. + refs). ++ +The value for these configuration variables is a list of colors (at most +two) and attributes (at most one), separated by spaces. The colors +accepted are `normal`, `black`, `red`, `green`, `yellow`, `blue`, +`magenta`, `cyan` and `white`; the attributes are `bold`, `dim`, `ul`, +`blink` and `reverse`. The first color given is the foreground; the +second is the background. The position of the attribute, if any, +doesn't matter. color.diff:: When true (or `always`), always use colors in patch. @@ -194,12 +266,13 @@ color.diff:: colors only when the output is to the terminal. color.diff.<slot>:: - Use customized color for diff colorization. `<slot>` - specifies which part of the patch to use the specified - color, and is one of `plain` (context text), `meta` - (metainformation), `frag` (hunk header), `old` (removed - lines), or `new` (added lines). The values of these - variables may be specified as in color.branch.<slot>. + Use customized color for diff colorization. `<slot>` specifies + which part of the patch to use the specified color, and is one + of `plain` (context text), `meta` (metainformation), `frag` + (hunk header), `old` (removed lines), `new` (added lines), + `commit` (commit headers), or `whitespace` (highlighting dubious + whitespace). The values of these variables may be specified as + in color.branch.<slot>. color.pager:: A boolean to enable/disable colored output when the pager is in @@ -228,6 +301,16 @@ diff.renames:: will enable basic rename detection. If set to "copies" or "copy", it will detect copies, as well. +fetch.unpackLimit:: + If the number of objects fetched over the git native + transfer is below this + limit, then the objects will be unpacked into loose object + files. However if the number of received objects equals or + exceeds this limit then the received pack will be stored as + a pack, after adding any missing delta bases. Storing the + pack from a push can make the push operation complete faster, + especially on slow filesystems. + format.headers:: Additional email headers to include in a patch to be submitted by mail. See gitlink:git-format-patch[1]. @@ -321,6 +404,13 @@ merge.summary:: Whether to include summaries of merged commits in newly created merge commit messages. False by default. +merge.verbosity:: + Controls the amount of output shown by the recursive merge + strategy. Level 0 outputs nothing except a final error + message if conflicts were detected. Level 1 outputs only + conflicts, 2 outputs conflicts and file changes. Level 5 and + above outputs debugging information. The default is level 2. + pack.window:: The size of the window used by gitlink:git-pack-objects[1] when no window size is given on the command line. Defaults to 10. @@ -344,6 +434,14 @@ remote.<name>.push:: The default set of "refspec" for gitlink:git-push[1]. See gitlink:git-push[1]. +remote.<name>.receivepack:: + The default program to execute on the remote side when pushing. See + option \--exec of gitlink:git-push[1]. + +remote.<name>.uploadpack:: + The default program to execute on the remote side when fetching. See + option \--exec of gitlink:git-fetch-pack[1]. + repack.usedeltabaseoffset:: Allow gitlink:git-repack[1] to create packs that uses delta-base offset. Defaults to false. @@ -377,6 +475,13 @@ user.name:: Can be overridden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME' environment variables. See gitlink:git-commit-tree[1]. +user.signingkey:: + If gitlink:git-tag[1] is not selecting the key you want it to + automatically when creating a signed tag, you can override the + default selection with this variable. This option is passed + unchanged to gpg's --local-user parameter, so you may specify a key + using any method that gpg supports. + whatchanged.difftree:: The default gitlink:git-diff-tree[1] arguments to be used for gitlink:git-whatchanged[1]. @@ -400,3 +505,8 @@ receive.denyNonFastForwards:: even if that push is forced. This configuration variable is set when initializing a shared repository. +transfer.unpackLimit:: + When `fetch.unpackLimit` or `receive.unpackLimit` are + not set, the value of this variable is used instead. + + diff --git a/Documentation/core-intro.txt b/Documentation/core-intro.txt new file mode 100644 index 0000000000..abafefc71c --- /dev/null +++ b/Documentation/core-intro.txt @@ -0,0 +1,590 @@ +//////////////////////////////////////////////////////////////// + + GIT - the stupid content tracker + +//////////////////////////////////////////////////////////////// + +"git" can mean anything, depending on your mood. + + - random three-letter combination that is pronounceable, and not + actually used by any common UNIX command. The fact that it is a + mispronunciation of "get" may or may not be relevant. + - stupid. contemptible and despicable. simple. Take your pick from the + dictionary of slang. + - "global information tracker": you're in a good mood, and it actually + works for you. Angels sing, and a light suddenly fills the room. + - "goddamn idiotic truckload of sh*t": when it breaks + +This is a (not so) stupid but extremely fast directory content manager. +It doesn't do a whole lot at its core, but what it 'does' do is track +directory contents efficiently. + +There are two object abstractions: the "object database", and the +"current directory cache" aka "index". + +The Object Database +~~~~~~~~~~~~~~~~~~~ +The object database is literally just a content-addressable collection +of objects. All objects are named by their content, which is +approximated by the SHA1 hash of the object itself. Objects may refer +to other objects (by referencing their SHA1 hash), and so you can +build up a hierarchy of objects. + +All objects have a statically determined "type" aka "tag", which is +determined at object creation time, and which identifies the format of +the object (i.e. how it is used, and how it can refer to other +objects). There are currently four different object types: "blob", +"tree", "commit" and "tag". + +A "blob" object cannot refer to any other object, and is, like the type +implies, a pure storage object containing some user data. It is used to +actually store the file data, i.e. a blob object is associated with some +particular version of some file. + +A "tree" object is an object that ties one or more "blob" objects into a +directory structure. In addition, a tree object can refer to other tree +objects, thus creating a directory hierarchy. + +A "commit" object ties such directory hierarchies together into +a DAG of revisions - each "commit" is associated with exactly one tree +(the directory hierarchy at the time of the commit). In addition, a +"commit" refers to one or more "parent" commit objects that describe the +history of how we arrived at that directory hierarchy. + +As a special case, a commit object with no parents is called the "root" +object, and is the point of an initial project commit. Each project +must have at least one root, and while you can tie several different +root objects together into one project by creating a commit object which +has two or more separate roots as its ultimate parents, that's probably +just going to confuse people. So aim for the notion of "one root object +per project", even if git itself does not enforce that. + +A "tag" object symbolically identifies and can be used to sign other +objects. It contains the identifier and type of another object, a +symbolic name (of course!) and, optionally, a signature. + +Regardless of object type, all objects share the following +characteristics: they are all deflated with zlib, and have a header +that not only specifies their type, but also provides size information +about the data in the object. It's worth noting that the SHA1 hash +that is used to name the object is the hash of the original data +plus this header, so `sha1sum` 'file' does not match the object name +for 'file'. +(Historical note: in the dawn of the age of git the hash +was the sha1 of the 'compressed' object.) + +As a result, the general consistency of an object can always be tested +independently of the contents or the type of the object: all objects can +be validated by verifying that (a) their hashes match the content of the +file and (b) the object successfully inflates to a stream of bytes that +forms a sequence of <ascii type without space> + <space> + <ascii decimal +size> + <byte\0> + <binary object data>. + +The structured objects can further have their structure and +connectivity to other objects verified. This is generally done with +the `git-fsck` program, which generates a full dependency graph +of all objects, and verifies their internal consistency (in addition +to just verifying their superficial consistency through the hash). + +The object types in some more detail: + +Blob Object +~~~~~~~~~~~ +A "blob" object is nothing but a binary blob of data, and doesn't +refer to anything else. There is no signature or any other +verification of the data, so while the object is consistent (it 'is' +indexed by its sha1 hash, so the data itself is certainly correct), it +has absolutely no other attributes. No name associations, no +permissions. It is purely a blob of data (i.e. normally "file +contents"). + +In particular, since the blob is entirely defined by its data, if two +files in a directory tree (or in multiple different versions of the +repository) have the same contents, they will share the same blob +object. The object is totally independent of its location in the +directory tree, and renaming a file does not change the object that +file is associated with in any way. + +A blob is typically created when gitlink:git-update-index[1] +is run, and its data can be accessed by gitlink:git-cat-file[1]. + +Tree Object +~~~~~~~~~~~ +The next hierarchical object type is the "tree" object. A tree object +is a list of mode/name/blob data, sorted by name. Alternatively, the +mode data may specify a directory mode, in which case instead of +naming a blob, that name is associated with another TREE object. + +Like the "blob" object, a tree object is uniquely determined by the +set contents, and so two separate but identical trees will always +share the exact same object. This is true at all levels, i.e. it's +true for a "leaf" tree (which does not refer to any other trees, only +blobs) as well as for a whole subdirectory. + +For that reason a "tree" object is just a pure data abstraction: it +has no history, no signatures, no verification of validity, except +that since the contents are again protected by the hash itself, we can +trust that the tree is immutable and its contents never change. + +So you can trust the contents of a tree to be valid, the same way you +can trust the contents of a blob, but you don't know where those +contents 'came' from. + +Side note on trees: since a "tree" object is a sorted list of +"filename+content", you can create a diff between two trees without +actually having to unpack two trees. Just ignore all common parts, +and your diff will look right. In other words, you can effectively +(and efficiently) tell the difference between any two random trees by +O(n) where "n" is the size of the difference, rather than the size of +the tree. + +Side note 2 on trees: since the name of a "blob" depends entirely and +exclusively on its contents (i.e. there are no names or permissions +involved), you can see trivial renames or permission changes by +noticing that the blob stayed the same. However, renames with data +changes need a smarter "diff" implementation. + +A tree is created with gitlink:git-write-tree[1] and +its data can be accessed by gitlink:git-ls-tree[1]. +Two trees can be compared with gitlink:git-diff-tree[1]. + +Commit Object +~~~~~~~~~~~~~ +The "commit" object is an object that introduces the notion of +history into the picture. In contrast to the other objects, it +doesn't just describe the physical state of a tree, it describes how +we got there, and why. + +A "commit" is defined by the tree-object that it results in, the +parent commits (zero, one or more) that led up to that point, and a +comment on what happened. Again, a commit is not trusted per se: +the contents are well-defined and "safe" due to the cryptographically +strong signatures at all levels, but there is no reason to believe +that the tree is "good" or that the merge information makes sense. +The parents do not have to actually have any relationship with the +result, for example. + +Note on commits: unlike real SCM's, commits do not contain +rename information or file mode change information. All of that is +implicit in the trees involved (the result tree, and the result trees +of the parents), and describing that makes no sense in this idiotic +file manager. + +A commit is created with gitlink:git-commit-tree[1] and +its data can be accessed by gitlink:git-cat-file[1]. + +Trust +~~~~~ +An aside on the notion of "trust". Trust is really outside the scope +of "git", but it's worth noting a few things. First off, since +everything is hashed with SHA1, you 'can' trust that an object is +intact and has not been messed with by external sources. So the name +of an object uniquely identifies a known state - just not a state that +you may want to trust. + +Furthermore, since the SHA1 signature of a commit refers to the +SHA1 signatures of the tree it is associated with and the signatures +of the parent, a single named commit specifies uniquely a whole set +of history, with full contents. You can't later fake any step of the +way once you have the name of a commit. + +So to introduce some real trust in the system, the only thing you need +to do is to digitally sign just 'one' special note, which includes the +name of a top-level commit. Your digital signature shows others +that you trust that commit, and the immutability of the history of +commits tells others that they can trust the whole history. + +In other words, you can easily validate a whole archive by just +sending out a single email that tells the people the name (SHA1 hash) +of the top commit, and digitally sign that email using something +like GPG/PGP. + +To assist in this, git also provides the tag object... + +Tag Object +~~~~~~~~~~ +Git provides the "tag" object to simplify creating, managing and +exchanging symbolic and signed tokens. The "tag" object at its +simplest simply symbolically identifies another object by containing +the sha1, type and symbolic name. + +However it can optionally contain additional signature information +(which git doesn't care about as long as there's less than 8k of +it). This can then be verified externally to git. + +Note that despite the tag features, "git" itself only handles content +integrity; the trust framework (and signature provision and +verification) has to come from outside. + +A tag is created with gitlink:git-mktag[1], +its data can be accessed by gitlink:git-cat-file[1], +and the signature can be verified by +gitlink:git-verify-tag[1]. + + +The "index" aka "Current Directory Cache" +----------------------------------------- +The index is a simple binary file, which contains an efficient +representation of a virtual directory content at some random time. It +does so by a simple array that associates a set of names, dates, +permissions and content (aka "blob") objects together. The cache is +always kept ordered by name, and names are unique (with a few very +specific rules) at any point in time, but the cache has no long-term +meaning, and can be partially updated at any time. + +In particular, the index certainly does not need to be consistent with +the current directory contents (in fact, most operations will depend on +different ways to make the index 'not' be consistent with the directory +hierarchy), but it has three very important attributes: + +'(a) it can re-generate the full state it caches (not just the +directory structure: it contains pointers to the "blob" objects so +that it can regenerate the data too)' + +As a special case, there is a clear and unambiguous one-way mapping +from a current directory cache to a "tree object", which can be +efficiently created from just the current directory cache without +actually looking at any other data. So a directory cache at any one +time uniquely specifies one and only one "tree" object (but has +additional data to make it easy to match up that tree object with what +has happened in the directory) + +'(b) it has efficient methods for finding inconsistencies between that +cached state ("tree object waiting to be instantiated") and the +current state.' + +'(c) it can additionally efficiently represent information about merge +conflicts between different tree objects, allowing each pathname to be +associated with sufficient information about the trees involved that +you can create a three-way merge between them.' + +Those are the three ONLY things that the directory cache does. It's a +cache, and the normal operation is to re-generate it completely from a +known tree object, or update/compare it with a live tree that is being +developed. If you blow the directory cache away entirely, you generally +haven't lost any information as long as you have the name of the tree +that it described. + +At the same time, the index is at the same time also the +staging area for creating new trees, and creating a new tree always +involves a controlled modification of the index file. In particular, +the index file can have the representation of an intermediate tree that +has not yet been instantiated. So the index can be thought of as a +write-back cache, which can contain dirty information that has not yet +been written back to the backing store. + + + +The Workflow +------------ +Generally, all "git" operations work on the index file. Some operations +work *purely* on the index file (showing the current state of the +index), but most operations move data to and from the index file. Either +from the database or from the working directory. Thus there are four +main combinations: + +1) working directory -> index +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You update the index with information from the working directory with +the gitlink:git-update-index[1] command. You +generally update the index information by just specifying the filename +you want to update, like so: + + git-update-index filename + +but to avoid common mistakes with filename globbing etc, the command +will not normally add totally new entries or remove old entries, +i.e. it will normally just update existing cache entries. + +To tell git that yes, you really do realize that certain files no +longer exist, or that new files should be added, you +should use the `--remove` and `--add` flags respectively. + +NOTE! A `--remove` flag does 'not' mean that subsequent filenames will +necessarily be removed: if the files still exist in your directory +structure, the index will be updated with their new status, not +removed. The only thing `--remove` means is that update-cache will be +considering a removed file to be a valid thing, and if the file really +does not exist any more, it will update the index accordingly. + +As a special case, you can also do `git-update-index --refresh`, which +will refresh the "stat" information of each index to match the current +stat information. It will 'not' update the object status itself, and +it will only update the fields that are used to quickly test whether +an object still matches its old backing store object. + +2) index -> object database +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You write your current index file to a "tree" object with the program + + git-write-tree + +that doesn't come with any options - it will just write out the +current index into the set of tree objects that describe that state, +and it will return the name of the resulting top-level tree. You can +use that tree to re-generate the index at any time by going in the +other direction: + +3) object database -> index +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You read a "tree" file from the object database, and use that to +populate (and overwrite - don't do this if your index contains any +unsaved state that you might want to restore later!) your current +index. Normal operation is just + + git-read-tree <sha1 of tree> + +and your index file will now be equivalent to the tree that you saved +earlier. However, that is only your 'index' file: your working +directory contents have not been modified. + +4) index -> working directory +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You update your working directory from the index by "checking out" +files. This is not a very common operation, since normally you'd just +keep your files updated, and rather than write to your working +directory, you'd tell the index files about the changes in your +working directory (i.e. `git-update-index`). + +However, if you decide to jump to a new version, or check out somebody +else's version, or just restore a previous tree, you'd populate your +index file with read-tree, and then you need to check out the result +with + + git-checkout-index filename + +or, if you want to check out all of the index, use `-a`. + +NOTE! git-checkout-index normally refuses to overwrite old files, so +if you have an old version of the tree already checked out, you will +need to use the "-f" flag ('before' the "-a" flag or the filename) to +'force' the checkout. + + +Finally, there are a few odds and ends which are not purely moving +from one representation to the other: + +5) Tying it all together +~~~~~~~~~~~~~~~~~~~~~~~~ +To commit a tree you have instantiated with "git-write-tree", you'd +create a "commit" object that refers to that tree and the history +behind it - most notably the "parent" commits that preceded it in +history. + +Normally a "commit" has one parent: the previous state of the tree +before a certain change was made. However, sometimes it can have two +or more parent commits, in which case we call it a "merge", due to the +fact that such a commit brings together ("merges") two or more +previous states represented by other commits. + +In other words, while a "tree" represents a particular directory state +of a working directory, a "commit" represents that state in "time", +and explains how we got there. + +You create a commit object by giving it the tree that describes the +state at the time of the commit, and a list of parents: + + git-commit-tree <tree> -p <parent> [-p <parent2> ..] + +and then giving the reason for the commit on stdin (either through +redirection from a pipe or file, or by just typing it at the tty). + +git-commit-tree will return the name of the object that represents +that commit, and you should save it away for later use. Normally, +you'd commit a new `HEAD` state, and while git doesn't care where you +save the note about that state, in practice we tend to just write the +result to the file pointed at by `.git/HEAD`, so that we can always see +what the last committed state was. + +Here is an ASCII art by Jon Loeliger that illustrates how +various pieces fit together. + +------------ + + commit-tree + commit obj + +----+ + | | + | | + V V + +-----------+ + | Object DB | + | Backing | + | Store | + +-----------+ + ^ + write-tree | | + tree obj | | + | | read-tree + | | tree obj + V + +-----------+ + | Index | + | "cache" | + +-----------+ + update-index ^ + blob obj | | + | | + checkout-index -u | | checkout-index + stat | | blob obj + V + +-----------+ + | Working | + | Directory | + +-----------+ + +------------ + + +6) Examining the data +~~~~~~~~~~~~~~~~~~~~~ + +You can examine the data represented in the object database and the +index with various helper tools. For every object, you can use +gitlink:git-cat-file[1] to examine details about the +object: + + git-cat-file -t <objectname> + +shows the type of the object, and once you have the type (which is +usually implicit in where you find the object), you can use + + git-cat-file blob|tree|commit|tag <objectname> + +to show its contents. NOTE! Trees have binary content, and as a result +there is a special helper for showing that content, called +`git-ls-tree`, which turns the binary content into a more easily +readable form. + +It's especially instructive to look at "commit" objects, since those +tend to be small and fairly self-explanatory. In particular, if you +follow the convention of having the top commit name in `.git/HEAD`, +you can do + + git-cat-file commit HEAD + +to see what the top commit was. + +7) Merging multiple trees +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Git helps you do a three-way merge, which you can expand to n-way by +repeating the merge procedure arbitrary times until you finally +"commit" the state. The normal situation is that you'd only do one +three-way merge (two parents), and commit it, but if you like to, you +can do multiple parents in one go. + +To do a three-way merge, you need the two sets of "commit" objects +that you want to merge, use those to find the closest common parent (a +third "commit" object), and then use those commit objects to find the +state of the directory ("tree" object) at these points. + +To get the "base" for the merge, you first look up the common parent +of two commits with + + git-merge-base <commit1> <commit2> + +which will return you the commit they are both based on. You should +now look up the "tree" objects of those commits, which you can easily +do with (for example) + + git-cat-file commit <commitname> | head -1 + +since the tree object information is always the first line in a commit +object. + +Once you know the three trees you are going to merge (the one +"original" tree, aka the common case, and the two "result" trees, aka +the branches you want to merge), you do a "merge" read into the +index. This will complain if it has to throw away your old index contents, so you should +make sure that you've committed those - in fact you would normally +always do a merge against your last commit (which should thus match +what you have in your current index anyway). + +To do the merge, do + + git-read-tree -m -u <origtree> <yourtree> <targettree> + +which will do all trivial merge operations for you directly in the +index file, and you can just write the result out with +`git-write-tree`. + +Historical note. We did not have `-u` facility when this +section was first written, so we used to warn that +the merge is done in the index file, not in your +working tree, and your working tree will not match your +index after this step. +This is no longer true. The above command, thanks to `-u` +option, updates your working tree with the merge results for +paths that have been trivially merged. + + +8) Merging multiple trees, continued +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sadly, many merges aren't trivial. If there are files that have +been added.moved or removed, or if both branches have modified the +same file, you will be left with an index tree that contains "merge +entries" in it. Such an index tree can 'NOT' be written out to a tree +object, and you will have to resolve any such merge clashes using +other tools before you can write out the result. + +You can examine such index state with `git-ls-files --unmerged` +command. An example: + +------------------------------------------------ +$ git-read-tree -m $orig HEAD $target +$ git-ls-files --unmerged +100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c +100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c +100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c +------------------------------------------------ + +Each line of the `git-ls-files --unmerged` output begins with +the blob mode bits, blob SHA1, 'stage number', and the +filename. The 'stage number' is git's way to say which tree it +came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD` +tree, and stage3 `$target` tree. + +Earlier we said that trivial merges are done inside +`git-read-tree -m`. For example, if the file did not change +from `$orig` to `HEAD` nor `$target`, or if the file changed +from `$orig` to `HEAD` and `$orig` to `$target` the same way, +obviously the final outcome is what is in `HEAD`. What the +above example shows is that file `hello.c` was changed from +`$orig` to `HEAD` and `$orig` to `$target` in a different way. +You could resolve this by running your favorite 3-way merge +program, e.g. `diff3` or `merge`, on the blob objects from +these three stages yourself, like this: + +------------------------------------------------ +$ git-cat-file blob 263414f... >hello.c~1 +$ git-cat-file blob 06fa6a2... >hello.c~2 +$ git-cat-file blob cc44c73... >hello.c~3 +$ merge hello.c~2 hello.c~1 hello.c~3 +------------------------------------------------ + +This would leave the merge result in `hello.c~2` file, along +with conflict markers if there are conflicts. After verifying +the merge result makes sense, you can tell git what the final +merge result for this file is by: + + mv -f hello.c~2 hello.c + git-update-index hello.c + +When a path is in unmerged state, running `git-update-index` for +that path tells git to mark the path resolved. + +The above is the description of a git merge at the lowest level, +to help you understand what conceptually happens under the hood. +In practice, nobody, not even git itself, uses three `git-cat-file` +for this. There is `git-merge-index` program that extracts the +stages to temporary files and calls a "merge" script on it: + + git-merge-index git-merge-one-file hello.c + +and that is what higher level `git resolve` is implemented with. diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt index 0cd33fb5b7..86a9c7521a 100644 --- a/Documentation/core-tutorial.txt +++ b/Documentation/core-tutorial.txt @@ -906,18 +906,13 @@ of it as it can automatically (which in this case is just merge the `example` file, which had no differences in the `mybranch` branch), and say: ---------------- - Trying really trivial in-index merge... - fatal: Merge requires file-level merging - Nope. - ... Auto-merging hello CONFLICT (content): Merge conflict in hello Automatic merge failed; fix up by hand ---------------- -which is way too verbose, but it basically tells you that it failed the -really trivial merge ("Simple merge") and did an "Automatic merge" -instead, but that too failed due to conflicts in `hello`. +It tells you that it did an "Automatic merge", which +failed due to conflicts in `hello`. Not to worry. It left the (trivial) conflict in `hello` in the same form you should already be well used to if you've ever used CVS, so let's just @@ -1129,46 +1124,26 @@ juggle multiple lines of development simultaneously. Of course, you will pay the price of more disk usage to hold multiple working trees, but disk space is cheap these days. -[NOTE] -You could even pull from your own repository by -giving '.' as <remote-repository> parameter to `git pull`. This -is useful when you want to merge a local branch (or more, if you -are making an Octopus) into the current branch. - It is likely that you will be pulling from the same remote repository from time to time. As a short hand, you can store -the remote repository URL in a file under .git/remotes/ -directory, like this: - ------------------------------------------------- -$ mkdir -p .git/remotes/ -$ cat >.git/remotes/linus <<\EOF -URL: http://www.kernel.org/pub/scm/git/git.git/ -EOF ------------------------------------------------- - -and use the filename to `git pull` instead of the full URL. -The URL specified in such file can even be a prefix -of a full URL, like this: +the remote repository URL in the local repository's config file +like this: ------------------------------------------------ -$ cat >.git/remotes/jgarzik <<\EOF -URL: http://www.kernel.org/pub/scm/linux/git/jgarzik/ -EOF +$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/ ------------------------------------------------ +and use the "linus" keyword with `git pull` instead of the full URL. Examples. . `git pull linus` . `git pull linus tag v0.99.1` -. `git pull jgarzik/netdev-2.6.git/ e100` the above are equivalent to: . `git pull http://www.kernel.org/pub/scm/git/git.git/ HEAD` . `git pull http://www.kernel.org/pub/scm/git/git.git/ tag v0.99.1` -. `git pull http://www.kernel.org/pub/.../jgarzik/netdev-2.6.git e100` How does the merge work? @@ -1546,7 +1521,8 @@ on that project and has an own "public repository" goes like this: 1. Prepare your work repository, by `git clone` the public repository of the "project lead". The URL used for the - initial cloning is stored in `.git/remotes/origin`. + initial cloning is stored in the remote.origin.url + configuration variable. 2. Prepare a public repository accessible to others, just like the "project lead" person does. @@ -1586,14 +1562,15 @@ like this: 1. Prepare your work repository, by `git clone` the public repository of the "project lead" (or a "subsystem maintainer", if you work on a subsystem). The URL used for - the initial cloning is stored in `.git/remotes/origin`. + the initial cloning is stored in the remote.origin.url + configuration variable. 2. Do your work in your repository on 'master' branch. 3. Run `git fetch origin` from the public repository of your upstream every once in a while. This does only the first half of `git pull` but does not merge. The head of the - public repository is stored in `.git/refs/heads/origin`. + public repository is stored in `.git/refs/remotes/origin/master`. 4. Use `git cherry origin` to see which ones of your patches were accepted, and/or use `git rebase origin` to port your @@ -1681,11 +1658,11 @@ $ git reset --hard master~2 You can make sure 'git show-branch' matches the state before those two 'git merge' you just did. Then, instead of running -two 'git merge' commands in a row, you would pull these two +two 'git merge' commands in a row, you would merge these two branch heads (this is known as 'making an Octopus'): ------------ -$ git pull . commit-fix diff-fix +$ git merge commit-fix diff-fix $ git show-branch ! [commit-fix] Fix commit message normalization. ! [diff-fix] Fix rename detection. @@ -1701,7 +1678,7 @@ $ git show-branch Note that you should not do Octopus because you can. An octopus is a valid thing to do and often makes it easier to view the -commit history if you are pulling more than two independent +commit history if you are merging more than two independent changes at the same time. However, if you have merge conflicts with any of the branches you are merging in and need to hand resolve, that is an indication that the development happened in diff --git a/Documentation/cvs-migration.txt b/Documentation/cvs-migration.txt index 775bf4266a..764cc560b4 100644 --- a/Documentation/cvs-migration.txt +++ b/Documentation/cvs-migration.txt @@ -36,7 +36,7 @@ them first before running git pull. ================================ The `pull` command knows where to get updates from because of certain configuration variables that were set by the first `git clone` -command; see `git repo-config -l` and the gitlink:git-repo-config[1] man +command; see `git config -l` and the gitlink:git-config[1] man page for details. ================================ diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index da1cc60e97..019a39f2bf 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -58,6 +58,10 @@ Turn off rename detection, even when the configuration file gives the default to do so. +--check:: + Warn if changes introduce trailing whitespace + or an indent that uses a space before a tab. + --full-index:: Instead of the first handful characters, show full object name of pre- and post-image blob on the "index" diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 4e83994c58..08c61b1f1a 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -28,7 +28,7 @@ Everybody uses these commands to maintain git repositories. * gitlink:git-init[1] or gitlink:git-clone[1] to create a new repository. - * gitlink:git-fsck-objects[1] to check the repository for errors. + * gitlink:git-fsck[1] to check the repository for errors. * gitlink:git-prune[1] to remove unused objects in the repository. @@ -43,7 +43,7 @@ Examples Check health and remove cruft.:: + ------------ -$ git fsck-objects <1> +$ git fsck <1> $ git count-objects <2> $ git repack <3> $ git gc <4> @@ -148,8 +148,7 @@ modification will be caught if you do `git commit -a` later. <8> redo the commit undone in the previous step, using the message you originally wrote. <9> switch to the master branch. -<10> merge a topic branch into your master branch. You can also use -`git pull . alsa-audio`, i.e. pull from the local repository. +<10> merge a topic branch into your master branch. <11> review commit logs; other forms to limit output can be combined and include `\--max-count=10` (show 10 commits), `\--until=2005-12-10`, etc. @@ -213,12 +212,12 @@ Push into another repository.:: ------------ satellite$ git clone mothership:frotz frotz <1> satellite$ cd frotz -satellite$ git repo-config --get-regexp '^(remote|branch)\.' <2> +satellite$ git config --get-regexp '^(remote|branch)\.' <2> remote.origin.url mothership:frotz remote.origin.fetch refs/heads/*:refs/remotes/origin/* branch.master.remote origin branch.master.merge refs/heads/master -satellite$ git repo-config remote.origin.push \ +satellite$ git config remote.origin.push \ master:refs/remotes/satellite/master <3> satellite$ edit/compile/test/commit satellite$ git push origin <4> diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 95bea66374..b73a99d61f 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -7,7 +7,7 @@ git-add - Add file contents to the changeset to be committed next SYNOPSIS -------- -'git-add' [-n] [-v] [-f] [--interactive] [--] <file>... +'git-add' [-n] [-v] [-f] [--interactive | -i] [--] <file>... DESCRIPTION ----------- @@ -52,7 +52,7 @@ OPTIONS -f:: Allow adding otherwise ignored files. -\--interactive:: +\i, \--interactive:: Add modified contents in the working tree interactively to the index. @@ -83,7 +83,7 @@ git-add git-*.sh:: Interactive mode ---------------- When the command enters the interactive mode, it shows the -output of the 'status' subcommand, and then goes into ints +output of the 'status' subcommand, and then goes into its interactive command loop. The command loop shows the list of subcommands available, and diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 53e81cb103..aa4ce1ddb0 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -3,7 +3,7 @@ git-am(1) NAME ---- -git-am - Apply a series of patches in a mailbox +git-am - Apply a series of patches from a mailbox SYNOPSIS diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt index 33b93db508..065ba1bf24 100644 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@ -3,7 +3,7 @@ git-apply(1) NAME ---- -git-apply - Apply patch on a git index file and a work tree +git-apply - Apply a patch on a git index file and a working tree SYNOPSIS diff --git a/Documentation/git-applypatch.txt b/Documentation/git-applypatch.txt index 2b1ff1454b..451434a757 100644 --- a/Documentation/git-applypatch.txt +++ b/Documentation/git-applypatch.txt @@ -12,6 +12,9 @@ SYNOPSIS DESCRIPTION ----------- +This is usually not what an end user wants to run directly. See +gitlink:git-am[1] instead. + Takes three files <msg>, <patch>, and <info> prepared from an e-mail message by 'git-mailinfo', and creates a commit. It is usually not necessary to use this command directly. diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt index 031fcd5190..493474b2ee 100644 --- a/Documentation/git-archive.txt +++ b/Documentation/git-archive.txt @@ -3,7 +3,7 @@ git-archive(1) NAME ---- -git-archive - Creates a archive of the files in the named tree +git-archive - Creates an archive of files from a named tree SYNOPSIS diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt index ac4b4965a9..16ec7269b2 100644 --- a/Documentation/git-bisect.txt +++ b/Documentation/git-bisect.txt @@ -3,7 +3,7 @@ git-bisect(1) NAME ---- -git-bisect - Find the change that introduced a bug +git-bisect - Find the change that introduced a bug by binary search SYNOPSIS diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt index bdfc666928..0ee887d73c 100644 --- a/Documentation/git-blame.txt +++ b/Documentation/git-blame.txt @@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file SYNOPSIS -------- [verse] -'git-blame' [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] +'git-blame' [-c] [-l] [-t] [-f] [-n] [-p] [--incremental] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--since=<date>] [<rev>] [--] <file> DESCRIPTION @@ -24,7 +24,7 @@ replaced; you need to use a tool such as gitlink:git-diff[1] or the "pickaxe" interface briefly mentioned in the following paragraph. Apart from supporting file annotation, git also supports searching the -development history for when a code snippet occured in a change. This makes it +development history for when a code snippet occurred in a change. This makes it possible to track when a code snippet was added to a file, moved or copied between files, and eventually deleted or replaced. It works by searching for a text string in the diff. A small example: @@ -63,6 +63,10 @@ OPTIONS -p, --porcelain:: Show in a format designed for machine consumption. +--incremental:: + Show the result incrementally in a format designed for + machine consumption. + -M:: Detect moving lines in the file as well. When a commit moves a block of lines in a file (e.g. the original file @@ -89,7 +93,7 @@ THE PORCELAIN FORMAT -------------------- In this format, each line is output after a header; the -header at the minumum has the first line which has: +header at the minimum has the first line which has: - 40-byte SHA-1 of the commit the line is attributed to; - the line number of the line in the original file; @@ -112,15 +116,18 @@ header, prefixed by a TAB. This is to allow adding more header elements later. -SPECIFIYING RANGES ------------------- +SPECIFYING RANGES +----------------- Unlike `git-blame` and `git-annotate` in older git, the extent of annotation can be limited to both line ranges and revision ranges. When you are interested in finding the origin for -ll. 40-60 for file `foo`, you can use `-L` option like this: +ll. 40-60 for file `foo`, you can use `-L` option like these +(they mean the same thing -- both ask for 21 lines starting at +line 40): git blame -L 40,60 foo + git blame -L 40,+21 foo Also you can use regular expression to specify the line range. @@ -155,6 +162,47 @@ parents, using `commit{caret}!` notation: git blame -C -C -f $commit^! -- foo +INCREMENTAL OUTPUT +------------------ + +When called with `--incremental` option, the command outputs the +result as it is built. The output generally will talk about +lines touched by more recent commits first (i.e. the lines will +be annotated out of order) and is meant to be used by +interactive viewers. + +The output format is similar to the Porcelain format, but it +does not contain the actual lines from the file that is being +annotated. + +. Each blame entry always starts with a line of: + + <40-byte hex sha1> <sourceline> <resultline> <num_lines> ++ +Line numbers count from 1. + +. The first time that commit shows up in the stream, it has various + other information about it printed out with a one-word tag at the + beginning of each line about that "extended commit info" (author, + email, committer, dates, summary etc). + +. Unlike Porcelain format, the filename information is always + given and terminates the entry: + + "filename" <whitespace-quoted-filename-goes-here> ++ +and thus it's really quite easy to parse for some line- and word-oriented +parser (which should be quite natural for most scripting languages). ++ +[NOTE] +For people who do parsing: to make it more robust, just ignore any +lines in between the first and last one ("<sha1>" and "filename" lines) +where you don't recognize the tag-words (or care about that particular +one) at the beginning of the "extended information" lines. That way, if +there is ever added information (like the commit encoding or extended +commit commentary), a blame viewer won't ever care. + + SEE ALSO -------- gitlink:git-annotate[1] diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index e872fc89fc..aa1fdd402a 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -3,7 +3,7 @@ git-branch(1) NAME ---- -git-branch - List, create, or delete branches. +git-branch - List, create, or delete branches SYNOPSIS -------- @@ -74,7 +74,7 @@ OPTIONS List both remote-tracking branches and local branches. -v:: - Show sha1 and commit subjectline for each head. + Show sha1 and commit subject line for each head. --abbrev=<length>:: Alter minimum display length for sha1 in output listing, diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt index 5e9cbf875d..7e90ce91bc 100644 --- a/Documentation/git-cat-file.txt +++ b/Documentation/git-cat-file.txt @@ -3,7 +3,7 @@ git-cat-file(1) NAME ---- -git-cat-file - Provide content or type information for repository objects +git-cat-file - Provide content or type/size information for repository objects SYNOPSIS diff --git a/Documentation/git-checkout-index.txt b/Documentation/git-checkout-index.txt index 765c173e15..6dd6db04bb 100644 --- a/Documentation/git-checkout-index.txt +++ b/Documentation/git-checkout-index.txt @@ -3,7 +3,7 @@ git-checkout-index(1) NAME ---- -git-checkout-index - Copy files from the index to the working directory +git-checkout-index - Copy files from the index to the working tree SYNOPSIS diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index fbdbadc74f..c44a4a8004 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git-checkout' [-f] [-b <new_branch> [-l]] [-m] [<branch>] -'git-checkout' [-m] [<branch>] <paths>... +'git-checkout' [<branch>] <paths>... DESCRIPTION ----------- @@ -63,7 +63,57 @@ and mark the resolved paths with `git update-index`. <branch>:: Branch to checkout; may be any object ID that resolves to a - commit. Defaults to HEAD. + commit. Defaults to HEAD. ++ +When this parameter names a non-branch (but still a valid commit object), +your HEAD becomes 'detached'. + + +Detached HEAD +------------- + +It is sometimes useful to be able to 'checkout' a commit that is +not at the tip of one of your branches. The most obvious +example is to check out the commit at a tagged official release +point, like this: + +------------ +$ git checkout v2.6.18 +------------ + +Earlier versions of git did not allow this and asked you to +create a temporary branch using `-b` option, but starting from +version 1.5.0, the above command 'detaches' your HEAD from the +current branch and directly point at the commit named by the tag +(`v2.6.18` in the above example). + +You can use usual git commands while in this state. You can use +`git-reset --hard $othercommit` to further move around, for +example. You can make changes and create a new commit on top of +a detached HEAD. You can even create a merge by using `git +merge $othercommit`. + +The state you are in while your HEAD is detached is not recorded +by any branch (which is natural --- you are not on any branch). +What this means is that you can discard your temporary commits +and merges by switching back to an existing branch (e.g. `git +checkout master`), and a later `git prune` or `git gc` would +garbage-collect them. + +The command would refuse to switch back to make sure that you do +not discard your temporary state by mistake when your detached +HEAD is not pointed at by any existing ref. If you did want to +save your state (e.g. "I was interested in the fifth commit from +the top of 'master' branch", or "I made two commits to fix minor +bugs while on a detached HEAD" -- and if you do not want to lose +these facts), you can create a new branch and switch to it with +`git checkout -b newbranch` so that you can keep building on +that state, or tag it first so that you can come back to it +later and switch to the branch you wanted to switch to with `git +tag that_state; git checkout master`. On the other hand, if you +did want to discard the temporary state, you can give `-f` +option (e.g. `git checkout -f master`) to override this +behaviour. EXAMPLES diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt index 875edb6b9f..3149d08da8 100644 --- a/Documentation/git-cherry-pick.txt +++ b/Documentation/git-cherry-pick.txt @@ -19,6 +19,8 @@ OPTIONS ------- <commit>:: Commit to cherry-pick. + For a more complete list of ways to spell commits, see + "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1]. -e|--edit:: With this option, `git-cherry-pick` will let you edit the commit diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index a78207461d..707376f22c 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -3,7 +3,7 @@ git-clone(1) NAME ---- -git-clone - Clones a repository +git-clone - Clones a repository into a new directory SYNOPSIS diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt index 77ba96ed8a..cf25507f8f 100644 --- a/Documentation/git-commit-tree.txt +++ b/Documentation/git-commit-tree.txt @@ -3,7 +3,7 @@ git-commit-tree(1) NAME ---- -git-commit-tree - Creates a new commit object +git-commit-tree - Create a new commit object SYNOPSIS @@ -12,6 +12,9 @@ SYNOPSIS DESCRIPTION ----------- +This is usually not what an end user wants to run directly. See +gitlink:git-commit[1] instead. + Creates a new commit object based on the provided tree object and emits the new commit object id on stdout. If no parent is given then it is considered to be an initial tree. diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index b4528d72ba..2187eee416 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -3,13 +3,13 @@ git-commit(1) NAME ---- -git-commit - Record your changes +git-commit - Record changes to the repository SYNOPSIS -------- [verse] -'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg>] - [--no-verify] [--amend] [-e] [--author <author>] +'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg> | + --amend] [--no-verify] [-e] [--author <author>] [--] [[-i | -o ]<file>...] DESCRIPTION @@ -111,7 +111,7 @@ but can be used to amend a merge commit. are concluding a conflicted merge. -q|--quiet:: - Supress commit summary message. + Suppress commit summary message. \--:: Do not interpret any more arguments as options. @@ -142,11 +142,6 @@ $ git add hello.c $ git commit ------------ -//////////// -We should fix 'git rm' to remove goodbye.c from both index and -working tree for the above example. -//////////// - Instead of staging files after each individual change, you can tell `git commit` to notice the changes to the files whose contents are tracked in @@ -223,6 +218,12 @@ refuses to run when given pathnames (but see `-i` option). DISCUSSION ---------- +Though not required, it's a good idea to begin the commit message +with a single short (less than 50 character) line summarizing the +change, followed by a blank line and then a more thorough description. +Tools that turn commits into email, for example, use the first line +on the Subject: line and the rest of the commit in the body. + include::i18n.txt[] ENVIRONMENT VARIABLES diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt new file mode 100644 index 0000000000..6624484fe1 --- /dev/null +++ b/Documentation/git-config.txt @@ -0,0 +1,227 @@ +git-config(1) +============= + +NAME +---- +git-config - Get and set repository or global options + + +SYNOPSIS +-------- +[verse] +'git-config' [--global] [type] name [value [value_regex]] +'git-config' [--global] [type] --add name value +'git-config' [--global] [type] --replace-all name [value [value_regex]] +'git-config' [--global] [type] --get name [value_regex] +'git-config' [--global] [type] --get-all name [value_regex] +'git-config' [--global] [type] --unset name [value_regex] +'git-config' [--global] [type] --unset-all name [value_regex] +'git-config' [--global] -l | --list + +DESCRIPTION +----------- +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. + +Multiple lines can be added to an option by using the '--add' option. +If you want to update or 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-config' ensure that the variable(s) are of the given type and +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: + +. 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, +. you try to unset/set an option for which multiple lines match, or +. you use --global option without $HOME being properly set. + + +OPTIONS +------- + +--replace-all:: + Default behavior is to replace at most one line. This replaces + all lines matching the key (and optionally the value_regex). + +--add:: + Adds a new line to the option without altering any existing + values. This is the same as providing '^$' as the value_regex. + +--get:: + Get the value for a given key (optionally filtered by a regex + matching the value). Returns error code 1 if the key was not + found and error code 2 if multiple key values were found. + +--get-all:: + 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. + +--global:: + Use global ~/.gitconfig file rather than the repository .git/config. + +--unset:: + Remove the line matching the key from config file. + +--unset-all:: + Remove all matching lines from config file. + +-l, --list:: + List all variables set in config file. + +--bool:: + git-config will ensure that the output is "true" or "false" + +--int:: + git-config will ensure that the output is a simple + decimal number. An optional value suffix of 'k', 'm', or 'g' + in the config file will cause the value to be multiplied + by 1024, 1048576, or 1073741824 prior to output. + + +ENVIRONMENT +----------- + +GIT_CONFIG:: + Take the configuration from the given file instead of .git/config. + Using the "--global" option forces this to ~/.gitconfig. + +GIT_CONFIG_LOCAL:: + Currently the same as $GIT_CONFIG; when Git will support global + configuration files, this will cause it to take the configuration + from the global configuration file in addition to the given file. + + +EXAMPLE +------- + +Given a .git/config like this: + + # + # This is the config file, and + # a '#' or ';' character indicates + # a comment + # + + ; core variables + [core] + ; Don't trust file modes + filemode = false + + ; Our diff algorithm + [diff] + external = "/usr/local/bin/gnu-diff -u" + renames = true + + ; Proxy settings + [core] + gitproxy="ssh" for "ssh://kernel.org/" + gitproxy="proxy-command" for kernel.org + gitproxy="myprotocol-command" for "my://" + gitproxy=default-proxy ; for all the rest + +you can set the filemode to true with + +------------ +% git config core.filemode true +------------ + +The hypothetical proxy command entries actually have a postfix to discern +what URL they apply to. Here is how to change the entry for kernel.org +to "ssh". + +------------ +% git config core.gitproxy '"ssh" for kernel.org' 'for kernel.org$' +------------ + +This makes sure that only the key/value pair for kernel.org is replaced. + +To delete the entry for renames, do + +------------ +% git config --unset diff.renames +------------ + +If you want to delete an entry for a multivar (like core.gitproxy above), +you have to provide a regex matching the value of exactly one line. + +To query the value for a given key, do + +------------ +% git config --get core.filemode +------------ + +or + +------------ +% git config core.filemode +------------ + +or, to query a multivar: + +------------ +% git config --get core.gitproxy "for kernel.org$" +------------ + +If you want to know all the values for a multivar, do: + +------------ +% git config --get-all core.gitproxy +------------ + +If you like to live dangerous, you can replace *all* core.gitproxy by a +new one with + +------------ +% git config --replace-all core.gitproxy ssh +------------ + +However, if you really only want to replace the line for the default proxy, +i.e. the one without a "for ..." postfix, do something like this: + +------------ +% git config core.gitproxy ssh '! for ' +------------ + +To actually match only values with an exclamation mark, you have to + +------------ +% git config section.key value '[!]' +------------ + +To add a new proxy, without altering any of the existing ones, use + +------------ +% git config core.gitproxy '"proxy" for example.com' +------------ + + +include::config.txt[] + + +Author +------ +Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> + +Documentation +-------------- +Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.kernel.org>. + +GIT +--- +Part of the gitlink:git[7] suite + diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt index c59df6438c..91c8c92c76 100644 --- a/Documentation/git-count-objects.txt +++ b/Documentation/git-count-objects.txt @@ -3,7 +3,7 @@ git-count-objects(1) NAME ---- -git-count-objects - Reports on unpacked objects +git-count-objects - Count unpacked number of objects and their disk consumption SYNOPSIS -------- diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt index 092d0d6730..347cbcec35 100644 --- a/Documentation/git-cvsexportcommit.txt +++ b/Documentation/git-cvsexportcommit.txt @@ -3,7 +3,7 @@ git-cvsexportcommit(1) NAME ---- -git-cvsexportcommit - Export a commit to a CVS checkout +git-cvsexportcommit - Export a single commit to a CVS checkout SYNOPSIS diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt index 5c402de267..f5450de74a 100644 --- a/Documentation/git-cvsimport.txt +++ b/Documentation/git-cvsimport.txt @@ -3,7 +3,7 @@ git-cvsimport(1) NAME ---- -git-cvsimport - Import a CVS repository into git +git-cvsimport - Salvage your data out of another SCM people love to hate SYNOPSIS @@ -97,7 +97,7 @@ If you need to pass multiple options, separate them with a comma. Substitute the character "/" in branch names with <subst> -A <author-conv-file>:: - CVS by default uses the unix username when writing its + CVS by default uses the Unix username when writing its commit logs. Using this option and an author-conv-file in this format diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index 993adc7c5a..9ddab71203 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -131,14 +131,14 @@ Giving these options is an error when used with `--inetd`; use the facility of inet daemon to achieve the same before spawning `git-daemon` if needed. ---enable-service, --disable-service:: +--enable=service, --disable=service:: Enable/disable the service site-wide per default. Note that a service disabled site-wide can still be enabled per repository if it is marked overridable and the repository enables the service with an configuration item. ---allow-override, --forbid-override:: +--allow-override=service, --forbid-override=service:: Allow/forbid overriding the site-wide default with per repository configuration. By default, all the services are overridable. diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index 2700f35bdb..47a583d3a6 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -14,8 +14,8 @@ DESCRIPTION ----------- The command finds the most recent tag that is reachable from a commit, and if the commit itself is pointed at by the tag, shows -the tag. Otherwise, it suffixes the tag name with abbreviated -object name of the commit. +the tag. Otherwise, it suffixes the tag name with the number of +additional commits and the abbreviated object name of the commit. OPTIONS @@ -35,6 +35,16 @@ OPTIONS Instead of using the default 8 hexadecimal digits as the abbreviated object name, use <n> digits. +--candidates=<n>:: + Instead of considering only the 10 most recent tags as + candidates to describe the input committish consider + up to <n> candidates. Increasing <n> above 10 will take + slightly longer but may produce a more accurate result. + +--debug:: + Verbosely display information about the searching strategy + being employed to standard error. The tag name will still + be printed to standard out. EXAMPLES -------- @@ -42,12 +52,18 @@ EXAMPLES With something like git.git current tree, I get: [torvalds@g5 git]$ git-describe parent - v1.0.4-g2414721b + v1.0.4-14-g2414721 i.e. the current head of my "parent" branch is based on v1.0.4, -but since it has a few commits on top of that, it has added the -git hash of the thing to the end: "-g" + 8-char shorthand for -the commit `2414721b194453f058079d897d13c4e377f92dc6`. +but since it has a handful commits on top of that, +describe has added the number of additional commits ("14") and +an abbreviated object name for the commit itself ("2414721") +at the end. + +The number of additional commits is the number +of commits which would be displayed by "git log v1.0.4..parent". +The hash suffix is "-g" + 7-char abbreviation for the tip commit +of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). Doing a "git-describe" on a tag-name will just show the tag name: @@ -58,16 +74,43 @@ With --all, the command can use branch heads as references, so the output shows the reference path as well: [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 - tags/v1.0.0-g975b + tags/v1.0.0-21-g975b [torvalds@g5 git]$ git describe --all HEAD^ - heads/lt/describe-g975b + heads/lt/describe-7-g975b + +With --abbrev set to 0, the command can be used to find the +closest tagname without any suffix: + + [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 + tags/v1.0.0 + +SEARCH STRATEGY +--------------- + +For each committish supplied "git describe" will first look for +a tag which tags exactly that commit. Annotated tags will always +be preferred over lightweight tags, and tags with newer dates will +always be preferred over tags with older dates. If an exact match +is found, its name will be output and searching will stop. + +If an exact match was not found "git describe" will walk back +through the commit history to locate an ancestor commit which +has been tagged. The ancestor's tag will be output along with an +abbreviation of the input committish's SHA1. + +If multiple tags were found during the walk then the tag which +has the fewest commits different from the input committish will be +selected and output. Here fewest commits different is defined as +the number of commits which would be shown by "git log tag..input" +will be the smallest number of commits possible. Author ------ Written by Linus Torvalds <torvalds@osdl.org>, but somewhat -butchered by Junio C Hamano <junkio@cox.net> +butchered by Junio C Hamano <junkio@cox.net>. Later significantly +updated by Shawn Pearce <spearce@spearce.org>. Documentation -------------- diff --git a/Documentation/git-diff-stages.txt b/Documentation/git-diff-stages.txt index 3273918627..120d14e87e 100644 --- a/Documentation/git-diff-stages.txt +++ b/Documentation/git-diff-stages.txt @@ -3,7 +3,7 @@ git-diff-stages(1) NAME ---- -git-diff-stages - Compares content and mode of blobs between stages in an unmerged index file +git-diff-stages - Compares two merge stages in the index SYNOPSIS diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index 8977877b21..6a098df26b 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -47,6 +47,9 @@ Just in case if you are doing something exotic, it should be noted that all of the <commit> in the above description can be any <tree-ish>. +For a more complete list of ways to spell <commit>, see +"SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1]. + OPTIONS ------- diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt index 3e6cd880b0..105d76b0ba 100644 --- a/Documentation/git-fetch-pack.txt +++ b/Documentation/git-fetch-pack.txt @@ -8,10 +8,13 @@ git-fetch-pack - Receive missing objects from another repository SYNOPSIS -------- -'git-fetch-pack' [-q] [-k] [--exec=<git-upload-pack>] [<host>:]<directory> [<refs>...] +'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...] DESCRIPTION ----------- +Usually you would want to use gitlink:git-fetch[1] which is a +higher level wrapper of this command instead. + Invokes 'git-upload-pack' on a potentially remote repository, and asks it to send objects missing from this repository, to update the named heads. The list of commits available locally @@ -25,17 +28,24 @@ have a common ancestor commit. OPTIONS ------- --q:: +\--all:: + Fetch all remote refs. + +\--quiet, \-q:: Pass '-q' flag to 'git-unpack-objects'; this makes the cloning process less verbose. --k:: +\--keep, \-k:: Do not invoke 'git-unpack-objects' on received data, but create a single packfile out of it instead, and store it in the object database. If provided twice then the pack is locked against repacking. ---exec=<git-upload-pack>:: +\--thin:: + Spend extra cycles to minimize the number of objects to be sent. + Use it on slower connection. + +\--upload-pack=<git-upload-pack>:: Use this to specify the path to 'git-upload-pack' on the remote side, if is not found on your $PATH. Installations of sshd ignores the user's environment @@ -47,6 +57,15 @@ OPTIONS shells by having a lean .bashrc file (they set most of the things up in .bash_profile). +\--exec=<git-upload-pack>:: + Same as \--upload-pack=<git-upload-pack>. + +\--depth=<n>:: + Limit fetching to ancestor-chains not longer than n. + +\-v:: + Run verbosely. + <host>:: A remote host that houses the repository. When this part is specified, 'git-upload-pack' is invoked via diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt index a9e86fd26b..7ecf2408d6 100644 --- a/Documentation/git-fetch.txt +++ b/Documentation/git-fetch.txt @@ -3,7 +3,7 @@ git-fetch(1) NAME ---- -git-fetch - Download objects and a head from another repository +git-fetch - Download objects and refs from another repository SYNOPSIS diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 2bf6aef735..da52eba7b3 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -7,7 +7,7 @@ git-for-each-ref - Output information on each ref SYNOPSIS -------- -'git-for-each-ref' [--count=<count>]\* [--shell|--perl|--python] [--sort=<key>]\* [--format=<format>] [<pattern>] +'git-for-each-ref' [--count=<count>]\* [--shell|--perl|--python|--tcl] [--sort=<key>]\* [--format=<format>] [<pattern>] DESCRIPTION ----------- @@ -15,7 +15,7 @@ DESCRIPTION Iterate over all refs that match `<pattern>` and show them according to the given `<format>`, after sorting them according to the given set of `<key>`. If `<max>` is given, stop after -showing that many refs. The interporated values in `<format>` +showing that many refs. The interpolated values in `<format>` can optionally be quoted as string literals in the specified host language allowing their direct evaluation in that language. @@ -49,7 +49,7 @@ OPTIONS using fnmatch(3). Refs that do not match the pattern are not shown. ---shell, --perl, --python:: +--shell, --perl, --python, --tcl:: If given, strings that substitute `%(fieldname)` placeholders are quoted as string literals suitable for the specified host language. This is meant to produce diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 67425dc035..59f34b9f0d 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -11,7 +11,8 @@ SYNOPSIS [verse] 'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread] [-s | --signoff] [--diff-options] [--start-number <n>] - [--in-reply-to=Message-Id] + [--in-reply-to=Message-Id] [--suffix=.<sfx>] + [--ignore-if-in-upstream] <since>[..<until>] DESCRIPTION @@ -20,7 +21,9 @@ DESCRIPTION Prepare each commit between <since> and <until> with its patch in one file per commit, formatted to resemble UNIX mailbox format. If ..<until> is not specified, the head of the current working -tree is implied. +tree is implied. For a more complete list of ways to spell +<since> and <until>, see "SPECIFYING REVISIONS" section in +gitlink:git-rev-parse[1]. The output of this command is convenient for e-mail submission or for use with gitlink:git-am[1]. @@ -78,13 +81,34 @@ OPTIONS reply to the given Message-Id, which avoids breaking threads to provide a new patch series. +--ignore-if-in-upstream:: + Do not include a patch that matches a commit in + <until>..<since>. This will examine all patches reachable + from <since> but not from <until> and compare them with the + patches being generated, and any patch that matches is + ignored. + +--suffix=.<sfx>:: + Instead of using `.patch` as the suffix for generated + filenames, use specifed suffix. A common alternative is + `--suffix=.txt`. ++ +Note that you would need to include the leading dot `.` if you +want a filename like `0001-description-of-my-change.patch`, and +the first letter does not have to be a dot. Leaving it empty would +not add any suffix. + CONFIGURATION ------------- You can specify extra mail header lines to be added to each -message in the repository configuration as follows: +message in the repository configuration. Also you can specify +the default suffix different from the built-in one: +------------ [format] headers = "Organization: git-foo\n" + suffix = .txt +------------ EXAMPLES @@ -109,6 +133,9 @@ git-format-patch -M -B origin:: understand renaming patches, so use it only when you know the recipient uses git to apply your patch. +git-format-patch -3:: + Extract three topmost commits from the current branch + and format them as e-mailable patches. See Also -------- diff --git a/Documentation/git-fsck-objects.txt b/Documentation/git-fsck-objects.txt index d0af99d351..f21061ecfe 100644 --- a/Documentation/git-fsck-objects.txt +++ b/Documentation/git-fsck-objects.txt @@ -8,132 +8,10 @@ git-fsck-objects - Verifies the connectivity and validity of the objects in the SYNOPSIS -------- -[verse] -'git-fsck-objects' [--tags] [--root] [--unreachable] [--cache] - [--full] [--strict] [<object>*] +'git-fsck-objects' ... DESCRIPTION ----------- -Verifies the connectivity and validity of the objects in the database. - -OPTIONS -------- -<object>:: - An object to treat as the head of an unreachability trace. -+ -If no objects are given, git-fsck-objects defaults to using the -index file and all SHA1 references in .git/refs/* as heads. - ---unreachable:: - Print out objects that exist but that aren't readable from any - of the reference nodes. - ---root:: - Report root nodes. - ---tags:: - Report tags. - ---cache:: - Consider any object recorded in the index also as a head node for - an unreachability trace. - ---full:: - Check not just objects in GIT_OBJECT_DIRECTORY - ($GIT_DIR/objects), but also the ones found in alternate - object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES - or $GIT_DIR/objects/info/alternates, - and in packed git archives found in $GIT_DIR/objects/pack - and corresponding pack subdirectories in alternate - object pools. - ---strict:: - Enable more strict checking, namely to catch a file mode - recorded with g+w bit set, which was created by older - versions of git. Existing repositories, including the - Linux kernel, git itself, and sparse repository have old - objects that triggers this check, but it is recommended - to check new projects with this flag. - -It tests SHA1 and general object sanity, and it does full tracking of -the resulting reachability and everything else. It prints out any -corruption it finds (missing or bad objects), and if you use the -'--unreachable' flag it will also print out objects that exist but -that aren't readable from any of the specified head nodes. - -So for example - - git-fsck-objects --unreachable HEAD $(cat .git/refs/heads/*) - -will do quite a _lot_ of verification on the tree. There are a few -extra validity tests to be added (make sure that tree objects are -sorted properly etc), but on the whole if "git-fsck-objects" is happy, you -do have a valid tree. - -Any corrupt objects you will have to find in backups or other archives -(i.e., you can just remove them and do an "rsync" with some other site in -the hopes that somebody else has the object you have corrupted). - -Of course, "valid tree" doesn't mean that it wasn't generated by some -evil person, and the end result might be crap. git is a revision -tracking system, not a quality assurance system ;) - -Extracted Diagnostics ---------------------- - -expect dangling commits - potential heads - due to lack of head information:: - You haven't specified any nodes as heads so it won't be - possible to differentiate between un-parented commits and - root nodes. - -missing sha1 directory '<dir>':: - The directory holding the sha1 objects is missing. - -unreachable <type> <object>:: - The <type> object <object>, isn't actually referred to directly - or indirectly in any of the trees or commits seen. This can - mean that there's another root node that you're not specifying - or that the tree is corrupt. If you haven't missed a root node - then you might as well delete unreachable nodes since they - can't be used. - -missing <type> <object>:: - The <type> object <object>, is referred to but isn't present in - the database. - -dangling <type> <object>:: - The <type> object <object>, is present in the database but never - 'directly' used. A dangling commit could be a root node. - -warning: git-fsck-objects: tree <tree> has full pathnames in it:: - And it shouldn't... - -sha1 mismatch <object>:: - The database has an object who's sha1 doesn't match the - database value. - This indicates a serious data integrity problem. - -Environment Variables ---------------------- - -GIT_OBJECT_DIRECTORY:: - used to specify the object database root (usually $GIT_DIR/objects) - -GIT_INDEX_FILE:: - used to specify the index file of the index - -GIT_ALTERNATE_OBJECT_DIRECTORIES:: - used to specify additional object database roots (usually unset) - -Author ------- -Written by Linus Torvalds <torvalds@osdl.org> - -Documentation --------------- -Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. - -GIT ---- -Part of the gitlink:git[7] suite +This is a synonym for gitlink:git-fsck[1]. Please refer to the +documentation of that command. diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt new file mode 100644 index 0000000000..058009d2fa --- /dev/null +++ b/Documentation/git-fsck.txt @@ -0,0 +1,139 @@ +git-fsck(1) +=========== + +NAME +---- +git-fsck - Verifies the connectivity and validity of the objects in the database + + +SYNOPSIS +-------- +[verse] +'git-fsck' [--tags] [--root] [--unreachable] [--cache] + [--full] [--strict] [<object>*] + +DESCRIPTION +----------- +Verifies the connectivity and validity of the objects in the database. + +OPTIONS +------- +<object>:: + An object to treat as the head of an unreachability trace. ++ +If no objects are given, git-fsck defaults to using the +index file and all SHA1 references in .git/refs/* as heads. + +--unreachable:: + Print out objects that exist but that aren't readable from any + of the reference nodes. + +--root:: + Report root nodes. + +--tags:: + Report tags. + +--cache:: + Consider any object recorded in the index also as a head node for + an unreachability trace. + +--full:: + Check not just objects in GIT_OBJECT_DIRECTORY + ($GIT_DIR/objects), but also the ones found in alternate + object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES + or $GIT_DIR/objects/info/alternates, + and in packed git archives found in $GIT_DIR/objects/pack + and corresponding pack subdirectories in alternate + object pools. + +--strict:: + Enable more strict checking, namely to catch a file mode + recorded with g+w bit set, which was created by older + versions of git. Existing repositories, including the + Linux kernel, git itself, and sparse repository have old + objects that triggers this check, but it is recommended + to check new projects with this flag. + +It tests SHA1 and general object sanity, and it does full tracking of +the resulting reachability and everything else. It prints out any +corruption it finds (missing or bad objects), and if you use the +'--unreachable' flag it will also print out objects that exist but +that aren't readable from any of the specified head nodes. + +So for example + + git-fsck --unreachable HEAD $(cat .git/refs/heads/*) + +will do quite a _lot_ of verification on the tree. There are a few +extra validity tests to be added (make sure that tree objects are +sorted properly etc), but on the whole if "git-fsck" is happy, you +do have a valid tree. + +Any corrupt objects you will have to find in backups or other archives +(i.e., you can just remove them and do an "rsync" with some other site in +the hopes that somebody else has the object you have corrupted). + +Of course, "valid tree" doesn't mean that it wasn't generated by some +evil person, and the end result might be crap. git is a revision +tracking system, not a quality assurance system ;) + +Extracted Diagnostics +--------------------- + +expect dangling commits - potential heads - due to lack of head information:: + You haven't specified any nodes as heads so it won't be + possible to differentiate between un-parented commits and + root nodes. + +missing sha1 directory '<dir>':: + The directory holding the sha1 objects is missing. + +unreachable <type> <object>:: + The <type> object <object>, isn't actually referred to directly + or indirectly in any of the trees or commits seen. This can + mean that there's another root node that you're not specifying + or that the tree is corrupt. If you haven't missed a root node + then you might as well delete unreachable nodes since they + can't be used. + +missing <type> <object>:: + The <type> object <object>, is referred to but isn't present in + the database. + +dangling <type> <object>:: + The <type> object <object>, is present in the database but never + 'directly' used. A dangling commit could be a root node. + +warning: git-fsck: tree <tree> has full pathnames in it:: + And it shouldn't... + +sha1 mismatch <object>:: + The database has an object who's sha1 doesn't match the + database value. + This indicates a serious data integrity problem. + +Environment Variables +--------------------- + +GIT_OBJECT_DIRECTORY:: + used to specify the object database root (usually $GIT_DIR/objects) + +GIT_INDEX_FILE:: + used to specify the index file of the index + +GIT_ALTERNATE_OBJECT_DIRECTORIES:: + used to specify additional object database roots (usually unset) + +Author +------ +Written by Linus Torvalds <torvalds@osdl.org> + +Documentation +-------------- +Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>. + +GIT +--- +Part of the gitlink:git[7] suite + diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt index 73d78c15e8..e37758ad15 100644 --- a/Documentation/git-gc.txt +++ b/Documentation/git-gc.txt @@ -8,7 +8,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository SYNOPSIS -------- -'git-gc' +'git-gc' [--prune] DESCRIPTION ----------- @@ -21,6 +21,21 @@ Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance. +OPTIONS +------- + +--prune:: + Usually `git-gc` packs refs, expires old reflog entries, + packs loose objects, + and removes old 'rerere' records. Removal + of unreferenced loose objects is an unsafe operation + while other git operations are in progress, so it is not + done by default. Pass this option if you want it, and only + when you know nobody else is creating new objects in the + repository at the same time (e.g. never use this option + in a cron script). + + Configuration ------------- @@ -35,7 +50,7 @@ can be set to indicate how long historical reflog entries which are not part of the current branch should remain available in this repository. These types of entries are generally created as a result of using `git commit \--amend` or `git rebase` and are the -commits prior to the amend or rebase occuring. Since these changes +commits prior to the amend or rebase occurring. Since these changes are not part of the current project most users will want to expire them sooner. This option defaults to '30 days'. diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index bfbece9864..0140c8e358 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -91,7 +91,7 @@ OPTIONS combined by 'or'. --and | --or | --not | ( | ):: - Specify how multiple patterns are combined using boolean + Specify how multiple patterns are combined using Boolean expressions. `--or` is the default operator. `--and` has higher precedence than `--or`. `-e` has to be used for all patterns. diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index 04e8d00436..5edc36f060 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -3,7 +3,7 @@ git-hash-object(1) NAME ---- -git-hash-object - Computes object ID and optionally creates a blob from a file +git-hash-object - Compute object ID and optionally creates a blob from a file SYNOPSIS diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt index 3d508094af..7dc2df3044 100644 --- a/Documentation/git-http-fetch.txt +++ b/Documentation/git-http-fetch.txt @@ -3,7 +3,7 @@ git-http-fetch(1) NAME ---- -git-http-fetch - downloads a remote git repository via HTTP +git-http-fetch - Download from a remote git repository via HTTP SYNOPSIS diff --git a/Documentation/git-http-push.txt b/Documentation/git-http-push.txt index c2485c6e9c..4b4a46169c 100644 --- a/Documentation/git-http-push.txt +++ b/Documentation/git-http-push.txt @@ -3,7 +3,7 @@ git-http-push(1) NAME ---- -git-http-push - Push missing objects using HTTP/DAV +git-http-push - Push objects over HTTP/DAV to another repository SYNOPSIS diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 596b567c90..1b64d3ab03 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -3,7 +3,7 @@ git-init(1) NAME ---- -git-init - Creates an empty git repository +git-init - Create an empty git repository or reinitialize an existing one SYNOPSIS diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt index 7dd393b97f..52a6aa6e82 100644 --- a/Documentation/git-instaweb.txt +++ b/Documentation/git-instaweb.txt @@ -3,7 +3,7 @@ git-instaweb(1) NAME ---- -git-instaweb - instantly browse your working repository in gitweb +git-instaweb - Instantly browse your working repository in gitweb SYNOPSIS -------- diff --git a/Documentation/git-local-fetch.txt b/Documentation/git-local-fetch.txt index 2fbdfe086a..22048d82bd 100644 --- a/Documentation/git-local-fetch.txt +++ b/Documentation/git-local-fetch.txt @@ -3,7 +3,7 @@ git-local-fetch(1) NAME ---- -git-local-fetch - Duplicates another git repository on a local system +git-local-fetch - Duplicate another git repository on a local system SYNOPSIS diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index e9f746bbd4..b8029463d9 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -27,13 +27,16 @@ OPTIONS include::pretty-formats.txt[] ---max-count=<n>:: +-<n>:: Limits the number of commits to show. <since>..<until>:: Show only commits between the named two commits. When either <since> or <until> is omitted, it defaults to `HEAD`, i.e. the tip of the current branch. + For a more complete list of ways to spell <since> + and <until>, see "SPECIFYING REVISIONS" section in + gitlink:git-rev-parse[1]. -p:: Show the change the commit introduces in a patch form. diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 8520b97111..79e0b7b71a 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -3,7 +3,7 @@ git-ls-files(1) NAME ---- -git-ls-files - Information about files in the index/working directory +git-ls-files - Show information about files in the index and the working tree SYNOPSIS diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index c8a4c5a4d9..c254005ca3 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -29,7 +29,7 @@ OPTIONS -u <exec>, --upload-pack=<exec>:: Specify the full path of gitlink:git-upload-pack[1] on the remote host. This allows listing references from repositories accessed via - SSH and where the SSH deamon does not use the PATH configured by the + SSH and where the SSH daemon does not use the PATH configured by the user. Also see the '--exec' option for gitlink:git-peek-remote[1]. <repository>:: diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt index f283bacb65..7899394081 100644 --- a/Documentation/git-ls-tree.txt +++ b/Documentation/git-ls-tree.txt @@ -3,7 +3,7 @@ git-ls-tree(1) NAME ---- -git-ls-tree - Lists the contents of a tree object +git-ls-tree - List the contents of a tree object SYNOPSIS diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt index 5088bbea84..ba18133ead 100644 --- a/Documentation/git-mailinfo.txt +++ b/Documentation/git-mailinfo.txt @@ -3,7 +3,7 @@ git-mailinfo(1) NAME ---- -git-mailinfo - Extracts patch from a single e-mail message +git-mailinfo - Extracts patch and authorship from a single e-mail message SYNOPSIS @@ -18,7 +18,7 @@ writes the commit log message in <msg> file, and the patches in <patch> file. The author name, e-mail and e-mail subject are written out to the standard output to be used by git-applypatch to create a commit. It is usually not necessary to use this -command directly. +command directly. See gitlink:git-am[1] instead. OPTIONS diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt index 5a17801f6a..c11d6a530f 100644 --- a/Documentation/git-mailsplit.txt +++ b/Documentation/git-mailsplit.txt @@ -3,7 +3,7 @@ git-mailsplit(1) NAME ---- -git-mailsplit - Totally braindamaged mbox splitter program +git-mailsplit - Simple UNIX mbox splitter program SYNOPSIS -------- diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 6099be2add..3190aed108 100644 --- a/Documentation/git-merge-base.txt +++ b/Documentation/git-merge-base.txt @@ -3,7 +3,7 @@ git-merge-base(1) NAME ---- -git-merge-base - Finds as good a common ancestor as possible for a merge +git-merge-base - Find as good common ancestors as possible for a merge SYNOPSIS diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt index 29d3faa556..31882abb87 100644 --- a/Documentation/git-merge-file.txt +++ b/Documentation/git-merge-file.txt @@ -3,7 +3,7 @@ git-merge-file(1) NAME ---- -git-merge-file - three-way file merge +git-merge-file - Run a three-way file merge SYNOPSIS diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt index 0cf505ea84..b8ee1ff2b0 100644 --- a/Documentation/git-merge-index.txt +++ b/Documentation/git-merge-index.txt @@ -3,7 +3,7 @@ git-merge-index(1) NAME ---- -git-merge-index - Runs a merge for files needing merging +git-merge-index - Run a merge for files needing merging SYNOPSIS diff --git a/Documentation/git-merge-one-file.txt b/Documentation/git-merge-one-file.txt index 86aad37c6a..f80ab3b8c4 100644 --- a/Documentation/git-merge-one-file.txt +++ b/Documentation/git-merge-one-file.txt @@ -3,7 +3,7 @@ git-merge-one-file(1) NAME ---- -git-merge-one-file - The standard helper program to use with "git-merge-index" +git-merge-one-file - The standard helper program to use with git-merge-index SYNOPSIS diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 0f79665ea6..3c08a6f7db 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -3,7 +3,7 @@ git-merge(1) NAME ---- -git-merge - Grand Unified Merge Driver +git-merge - Join two or more development histories together SYNOPSIS diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt index 207c43a631..6756b76bb1 100644 --- a/Documentation/git-mv.txt +++ b/Documentation/git-mv.txt @@ -3,7 +3,7 @@ git-mv(1) NAME ---- -git-mv - Move or rename a file, directory or symlink +git-mv - Move or rename a file, a directory, or a symlink SYNOPSIS diff --git a/Documentation/git-pack-redundant.txt b/Documentation/git-pack-redundant.txt index 7d54b17e37..94bbea0db2 100644 --- a/Documentation/git-pack-redundant.txt +++ b/Documentation/git-pack-redundant.txt @@ -3,7 +3,7 @@ git-pack-redundant(1) NAME ---- -git-pack-redundant - Program used to find redundant pack files +git-pack-redundant - Find redundant pack files SYNOPSIS @@ -21,7 +21,7 @@ given will be ignored when checking which packs are required. This makes the following command useful when wanting to remove packs which contain unreachable objects. -git-fsck-objects --full --unreachable | cut -d ' ' -f3 | \ +git-fsck --full --unreachable | cut -d ' ' -f3 | \ git-pack-redundant --all | xargs rm OPTIONS diff --git a/Documentation/git-pack-refs.txt b/Documentation/git-pack-refs.txt index 464269fbb9..a20fc7de40 100644 --- a/Documentation/git-pack-refs.txt +++ b/Documentation/git-pack-refs.txt @@ -29,12 +29,23 @@ file and used if found. Subsequent updates to branches always creates new file under `$GIT_DIR/refs` hierarchy. +A recommended practice to deal with a repository with too many +refs is to pack its refs with `--all --prune` once, and +occasionally run `git-pack-refs \--prune`. Tags are by +definition stationary and are not expected to change. Branch +heads will be packed with the initial `pack-refs --all`, but +only the currently active branch heads will become unpacked, +and next `pack-refs` (without `--all`) will leave them +unpacked. + + OPTIONS ------- \--all:: -The command by default packs all tags and leaves branch tips +The command by default packs all tags and refs that are already +packed, and leaves other refs alone. This is because branches are expected to be actively developed and packing their tips does not help performance. This option causes branch tips to be packed as well. Useful for diff --git a/Documentation/git-parse-remote.txt b/Documentation/git-parse-remote.txt index fc27afe26d..11b1f4d2e2 100644 --- a/Documentation/git-parse-remote.txt +++ b/Documentation/git-parse-remote.txt @@ -3,7 +3,7 @@ git-parse-remote(1) NAME ---- -git-parse-remote - Routines to help parsing $GIT_DIR/remotes/ +git-parse-remote - Routines to help parsing remote repository access parameters SYNOPSIS @@ -14,7 +14,8 @@ DESCRIPTION ----------- This script is included in various scripts to supply routines to parse files under $GIT_DIR/remotes/ and -$GIT_DIR/branches/. +$GIT_DIR/branches/ and configuration variables that are related +to fetching, pulling and pushing. The primary entry points are: @@ -25,7 +26,8 @@ get_remote_refs_for_fetch:: (e.g. `refs/heads/foo`). When `<refspec>...` is empty the returned list of refs consists of the defaults for the given `<repo>`, if specified in - `$GIT_DIR/remotes/` or `$GIT_DIR/branches/`. + `$GIT_DIR/remotes/`, `$GIT_DIR/branches/`, or `remote.*.fetch` + configuration. get_remote_refs_for_push:: Given the list of user-supplied `<repo> <refspec>...`, diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt index 5389097f73..a7e9fd021a 100644 --- a/Documentation/git-patch-id.txt +++ b/Documentation/git-patch-id.txt @@ -3,7 +3,7 @@ git-patch-id(1) NAME ---- -git-patch-id - Generate a patch ID +git-patch-id - Compute unique ID for a patch SYNOPSIS -------- diff --git a/Documentation/git-peek-remote.txt b/Documentation/git-peek-remote.txt index a00060c507..74f37bd904 100644 --- a/Documentation/git-peek-remote.txt +++ b/Documentation/git-peek-remote.txt @@ -3,12 +3,12 @@ git-peek-remote(1) NAME ---- -git-peek-remote - Lists the references in a remote repository +git-peek-remote - List the references in a remote repository SYNOPSIS -------- -'git-peek-remote' [--exec=<git-upload-pack>] [<host>:]<directory> +'git-peek-remote' [--upload-pack=<git-upload-pack>] [<host>:]<directory> DESCRIPTION ----------- @@ -17,7 +17,7 @@ stores them in the local repository under the same name. OPTIONS ------- ---exec=<git-upload-pack>:: +\--upload-pack=<git-upload-pack>:: Use this to specify the path to 'git-upload-pack' on the remote side, if it is not found on your $PATH. Some installations of sshd ignores the user's environment @@ -29,6 +29,9 @@ OPTIONS shells, but prefer having a lean .bashrc file (they set most of the things up in .bash_profile). +\--exec=<git-upload-pack>:: + Same \--upload-pack=<git-upload-pack>. + <host>:: A remote host that houses the repository. When this part is specified, 'git-upload-pack' is invoked via diff --git a/Documentation/git-prune-packed.txt b/Documentation/git-prune-packed.txt index a79193fb00..310033e460 100644 --- a/Documentation/git-prune-packed.txt +++ b/Documentation/git-prune-packed.txt @@ -3,8 +3,7 @@ git-prune-packed(1) NAME ---- -git-prune-packed - Program used to remove the extra object files that are now -residing in a pack file. +git-prune-packed - Remove extra objects that are already in pack files SYNOPSIS diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt index a11e303094..0b44f3015d 100644 --- a/Documentation/git-prune.txt +++ b/Documentation/git-prune.txt @@ -13,7 +13,7 @@ SYNOPSIS DESCRIPTION ----------- -This runs `git-fsck-objects --unreachable` using all the refs +This runs `git-fsck --unreachable` using all the refs available in `$GIT_DIR/refs`, optionally with additional set of objects specified on the command line, and prunes all objects unreachable from any of these head objects from the object database. diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 13be992006..a81d68ccef 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -3,7 +3,7 @@ git-pull(1) NAME ---- -git-pull - Pull and merge from another repository or a local branch +git-pull - Fetch from and merge with another repository or a local branch SYNOPSIS @@ -42,7 +42,7 @@ git pull, git pull origin:: current branch. Normally the branch merged in is the HEAD of the remote repository, but the choice is determined by the branch.<name>.remote and - branch.<name>.merge options; see gitlink:git-repo-config[1] + branch.<name>.merge options; see gitlink:git-config[1] for details. git pull origin next:: @@ -52,7 +52,8 @@ git pull origin next:: git pull . fixes enhancements:: Bundle local branch `fixes` and `enhancements` on top of - the current branch, making an Octopus merge. + the current branch, making an Octopus merge. This `git pull .` + syntax is equivalent to `git merge`. git pull -s ours . obsolete:: Merge local branch `obsolete` into the current branch, @@ -93,7 +94,7 @@ gitlink:git-reset[1]. SEE ALSO -------- -gitlink:git-fetch[1], gitlink:git-merge[1], gitlink:git-repo-config[1] +gitlink:git-fetch[1], gitlink:git-merge[1], gitlink:git-config[1] Author diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index 197f4b512f..f8cc2b5432 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -8,7 +8,7 @@ git-push - Update remote refs along with associated objects SYNOPSIS -------- -'git-push' [--all] [--tags] [-f | --force] <repository> <refspec>... +'git-push' [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...] DESCRIPTION ----------- @@ -67,12 +67,33 @@ the remote repository. addition to refspecs explicitly listed on the command line. +\--receive-pack=<git-receive-pack>:: + Path to the 'git-receive-pack' program on the remote + end. Sometimes useful when pushing to a remote + repository over ssh, and you do not have the program in + a directory on the default $PATH. + +\--exec=<git-receive-pack>:: + Same as \--receive-pack=<git-receive-pack>. + -f, \--force:: Usually, the command refuses to update a remote ref that is not a descendant of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care. +\--repo=<repo>:: + When no repository is specified the command defaults to + "origin"; this overrides it. + +\--thin, \--no-thin:: + These options are passed to `git-send-pack`. Thin + transfer spends extra cycles to minimize the number of + objects to be sent and meant to be used on slower connection. + +-v:: + Run verbosely. + include::urls.txt[] Author diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 03e867a403..0cb9e1f10a 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -3,7 +3,7 @@ git-rebase(1) NAME ---- -git-rebase - Rebase local commits to a new head +git-rebase - Forward-port local commits to the updated upstream head SYNOPSIS -------- diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt index 0dfadc2a32..10e8c46c4c 100644 --- a/Documentation/git-receive-pack.txt +++ b/Documentation/git-receive-pack.txt @@ -3,7 +3,7 @@ git-receive-pack(1) NAME ---- -git-receive-pack - Receive what is pushed into it +git-receive-pack - Receive what is pushed into the repository SYNOPSIS diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt index 55a24d3266..1138865896 100644 --- a/Documentation/git-reflog.txt +++ b/Documentation/git-reflog.txt @@ -9,7 +9,7 @@ git-reflog - Manage reflog information SYNOPSIS -------- [verse] -'git-reflog' expire [--dry-run] +'git-reflog' expire [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>... diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index 5b93a8c8be..358c1acfc3 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -28,7 +28,7 @@ In the third form, gives some information about the remote <name>. The remote configuration is achieved using the `remote.origin.url` and `remote.origin.fetch` configuration variables. (See -gitlink:git-repo-config[1]). +gitlink:git-config[1]). Examples -------- @@ -58,7 +58,7 @@ See Also -------- gitlink:git-fetch[1] gitlink:git-branch[1] -gitlink:git-repo-config[1] +gitlink:git-config[1] Author ------ diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt index 0fa47e3b01..4a57ce8601 100644 --- a/Documentation/git-repack.txt +++ b/Documentation/git-repack.txt @@ -3,8 +3,7 @@ git-repack(1) NAME ---- -git-repack - Script used to pack a repository from a collection of -objects into pack files. +git-repack - Pack unpacked objects in a repository SYNOPSIS diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt index c55a8ba0dc..2deba31763 100644 --- a/Documentation/git-repo-config.txt +++ b/Documentation/git-repo-config.txt @@ -3,225 +3,16 @@ git-repo-config(1) NAME ---- -git-repo-config - Get and set repository or global options. +git-repo-config - Get and set repository or global options SYNOPSIS -------- -[verse] -'git-repo-config' [--global] [type] name [value [value_regex]] -'git-repo-config' [--global] [type] --add name value -'git-repo-config' [--global] [type] --replace-all name [value [value_regex]] -'git-repo-config' [--global] [type] --get name [value_regex] -'git-repo-config' [--global] [type] --get-all name [value_regex] -'git-repo-config' [--global] [type] --unset name [value_regex] -'git-repo-config' [--global] [type] --unset-all name [value_regex] -'git-repo-config' [--global] -l | --list +'git-repo-config' ... -DESCRIPTION ------------ -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. - -Multiple lines can be added to an option by using the '--add' option. -If you want to update or 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 -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: - -. 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, -. you try to unset/set an option for which multiple lines match, or -. you use --global option without $HOME being properly set. - - -OPTIONS -------- - ---replace-all:: - Default behavior is to replace at most one line. This replaces - all lines matching the key (and optionally the value_regex). - ---add:: - Adds a new line to the option without altering any existing - values. This is the same as providing '^$' as the value_regex. - ---get:: - Get the value for a given key (optionally filtered by a regex - matching the value). Returns error code 1 if the key was not - found and error code 2 if multiple key values were found. - ---get-all:: - 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. - ---global:: - Use global ~/.gitconfig file rather than the repository .git/config. - ---unset:: - Remove the line matching the key from config file. ---unset-all:: - Remove all matching lines from config file. - --l, --list:: - List all variables set in config file. - ---bool:: - git-repo-config will ensure that the output is "true" or "false" - ---int:: - git-repo-config will ensure that the output is a simple - decimal number. An optional value suffix of 'k', 'm', or 'g' - in the config file will cause the value to be multiplied - by 1024, 1048576, or 1073741824 prior to output. - - -ENVIRONMENT +DESCRIPTION ----------- -GIT_CONFIG:: - Take the configuration from the given file instead of .git/config. - Using the "--global" option forces this to ~/.gitconfig. - -GIT_CONFIG_LOCAL:: - Currently the same as $GIT_CONFIG; when Git will support global - configuration files, this will cause it to take the configuration - from the global configuration file in addition to the given file. - - -EXAMPLE -------- - -Given a .git/config like this: - - # - # This is the config file, and - # a '#' or ';' character indicates - # a comment - # - - ; core variables - [core] - ; Don't trust file modes - filemode = false - - ; Our diff algorithm - [diff] - external = "/usr/local/bin/gnu-diff -u" - renames = true - - ; Proxy settings - [core] - gitproxy="ssh" for "ssh://kernel.org/" - gitproxy="proxy-command" for kernel.org - gitproxy="myprotocol-command" for "my://" - gitproxy=default-proxy ; for all the rest - -you can set the filemode to true with - ------------- -% git repo-config core.filemode true ------------- - -The hypothetical proxy command entries actually have a postfix to discern -what URL they apply to. Here is how to change the entry for kernel.org -to "ssh". - ------------- -% git repo-config core.gitproxy '"ssh" for kernel.org' 'for kernel.org$' ------------- - -This makes sure that only the key/value pair for kernel.org is replaced. - -To delete the entry for renames, do - ------------- -% git repo-config --unset diff.renames ------------- - -If you want to delete an entry for a multivar (like core.gitproxy above), -you have to provide a regex matching the value of exactly one line. - -To query the value for a given key, do - ------------- -% git repo-config --get core.filemode ------------- - -or - ------------- -% git repo-config core.filemode ------------- - -or, to query a multivar: - ------------- -% git repo-config --get core.gitproxy "for kernel.org$" ------------- - -If you want to know all the values for a multivar, do: - ------------- -% git repo-config --get-all core.gitproxy ------------- - -If you like to live dangerous, you can replace *all* core.gitproxy by a -new one with - ------------- -% git repo-config --replace-all core.gitproxy ssh ------------- - -However, if you really only want to replace the line for the default proxy, -i.e. the one without a "for ..." postfix, do something like this: - ------------- -% git repo-config core.gitproxy ssh '! for ' ------------- - -To actually match only values with an exclamation mark, you have to - ------------- -% git repo-config section.key value '[!]' ------------- - -To add a new proxy, without altering any of the existing ones, use - ------------- -% git repo-config core.gitproxy '"proxy" for example.com' ------------- - - -include::config.txt[] - - -Author ------- -Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> - -Documentation --------------- -Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.kernel.org>. - -GIT ---- -Part of the gitlink:git[7] suite - +This is a synonym for gitlink:git-config[1]. Please refer to the +documentation of that command. diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt index b57a72bdd7..139b6eb773 100644 --- a/Documentation/git-rerere.txt +++ b/Documentation/git-rerere.txt @@ -3,7 +3,7 @@ git-rerere(1) NAME ---- -git-rerere - Reuse recorded resolve +git-rerere - Reuse recorded resolution of conflicted merges SYNOPSIS -------- @@ -38,7 +38,7 @@ its working state. This resets the metadata used by rerere if a merge resolution is to be is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1] -[--skip|--abort] will automatcally invoke this command. +[--skip|--abort] will automatically invoke this command. 'diff':: @@ -81,7 +81,7 @@ One way to do it is to pull master into the topic branch: ------------ $ git checkout topic - $ git pull . master + $ git merge master o---*---o---+ topic / / @@ -103,10 +103,10 @@ in which case the final commit graph would look like this: ------------ $ git checkout topic - $ git pull . master + $ git merge master $ ... work on both topic and master branches $ git checkout master - $ git pull . topic + $ git merge topic o---*---o---+---o---o topic / / \ @@ -126,11 +126,11 @@ top of the tip before the test merge: ------------ $ git checkout topic - $ git pull . master + $ git merge master $ git reset --hard HEAD^ ;# rewind the test merge $ ... work on both topic and master branches $ git checkout master - $ git pull . topic + $ git merge topic o---*---o-------o---o topic / \ diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index 4f424782eb..04475a9216 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -121,10 +121,6 @@ Undo a merge or pull:: + ------------ $ git pull <1> -Trying really trivial in-index merge... -fatal: Merge requires file-level merging -Nope. -... Auto-merging nitfol CONFLICT (content): Merge conflict in nitfol Automatic merge failed/prevented; fix up by hand diff --git a/Documentation/git-resolve.txt b/Documentation/git-resolve.txt index 4e57c2b287..0925973f12 100644 --- a/Documentation/git-resolve.txt +++ b/Documentation/git-resolve.txt @@ -12,6 +12,8 @@ SYNOPSIS DESCRIPTION ----------- +DEPRECATED. Use `git-merge` instead. + Given two commits and a merge message, merge the <merged> commit into <current> commit, with the commit log message <message>. diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 86c94e7dfd..c742117595 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -27,6 +27,7 @@ SYNOPSIS [ \--pretty | \--header ] [ \--bisect ] [ \--merge ] + [ \--walk-reflogs ] <commit>... [ \-- <paths>... ] DESCRIPTION @@ -190,6 +191,22 @@ limiting may be applied. In addition to the '<commit>' listed on the command line, read them from the standard input. +-g, --walk-reflogs:: + + Instead of walking the commit ancestry chain, walk + reflog entries from the most recent one to older ones. + When this option is used you cannot specify commits to + exclude (that is, '{caret}commit', 'commit1..commit2', + nor 'commit1...commit2' notations cannot be used). ++ +With '\--pretty' format other than oneline (for obvious reasons), +this causes the output to have two extra lines of information +taken from the reflog. By default, 'commit@{Nth}' notation is +used in the output. When the starting commit is specified as +'commit@{now}', output also uses 'commit@{timestamp}' notation +instead. Under '\--pretty=oneline', the commit message is +prefixed with this information on the same line. + --merge:: After a failed merge, show refs that touch files having a diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 4eaf5a0d1e..aeb37b65d2 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -152,6 +152,14 @@ blobs contained in a commit. used immediately following a ref name and the ref must have an existing log ($GIT_DIR/logs/<ref>). +* A ref followed by the suffix '@' with an ordinal specification + enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify + the n-th prior value of that ref. For example 'master@\{1\}' + is the immediate prior value of 'master' while 'master@\{5\}' + is the 5th prior value of 'master'. This suffix may only be used + immediately following a ref name and the ref must have an existing + log ($GIT_DIR/logs/<ref>). + * A suffix '{caret}' to a revision parameter means the first parent of that commit object. '{caret}<n>' means the <n>th parent (i.e. 'rev{caret}' diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt index 71f7815d65..8081bbaffa 100644 --- a/Documentation/git-revert.txt +++ b/Documentation/git-revert.txt @@ -19,6 +19,8 @@ OPTIONS ------- <commit>:: Commit to revert. + For a more complete list of ways to spell commit names, see + "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1]. -e|--edit:: With this option, `git-revert` will let you edit the commit diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt index 3a8f279e1a..6feebc0400 100644 --- a/Documentation/git-rm.txt +++ b/Documentation/git-rm.txt @@ -60,21 +60,17 @@ a file that you have not told git about does not remove that file. EXAMPLES -------- git-rm Documentation/\\*.txt:: - Removes all `\*.txt` files from the index that are under the - `Documentation` directory and any of its subdirectories. The - files are not removed from the working tree. + `Documentation` directory and any of its subdirectories. + Note that the asterisk `\*` is quoted from the shell in this example; this lets the command include the files from subdirectories of `Documentation/` directory. git-rm -f git-*.sh:: - - Remove all git-*.sh scripts that are in the index. The files - are removed from the index, and from the working - tree. Because this example lets the shell expand the - asterisk (i.e. you are listing the files explicitly), it + Remove all git-*.sh scripts that are in the index. + Because this example lets the shell expand the asterisk + (i.e. you are listing the files explicitly), it does not remove `subdir/git-foo.sh`. See Also diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt index 5376f68548..2f6267ce60 100644 --- a/Documentation/git-send-pack.txt +++ b/Documentation/git-send-pack.txt @@ -3,38 +3,51 @@ git-send-pack(1) NAME ---- -git-send-pack - Push missing objects packed +git-send-pack - Push objects over git protocol to another reposiotory SYNOPSIS -------- -'git-send-pack' [--all] [--force] [--exec=<git-receive-pack>] [<host>:]<directory> [<ref>...] +'git-send-pack' [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...] DESCRIPTION ----------- +Usually you would want to use gitlink:git-push[1] which is a +higher level wrapper of this command instead. + Invokes 'git-receive-pack' on a possibly remote repository, and updates it from the current repository, sending named refs. OPTIONS ------- ---exec=<git-receive-pack>:: +\--receive-pack=<git-receive-pack>:: Path to the 'git-receive-pack' program on the remote end. Sometimes useful when pushing to a remote repository over ssh, and you do not have the program in a directory on the default $PATH. ---all:: +\--exec=<git-receive-pack>:: + Same as \--receive-pack=<git-receive-pack>. + +\--all:: Instead of explicitly specifying which refs to update, update all refs that locally exist. ---force:: +\--force:: Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. What this means is that the remote repository can lose commits; use it with care. +\--verbose:: + Run verbosely. + +\--thin:: + Spend extra cycles to minimize the number of objects to be sent. + Use it on slower connection. + <host>:: A remote host to house the repository. When this part is specified, 'git-receive-pack' is invoked via diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt index 79217d8a56..2b2abebd60 100644 --- a/Documentation/git-sh-setup.txt +++ b/Documentation/git-sh-setup.txt @@ -12,14 +12,51 @@ SYNOPSIS DESCRIPTION ----------- -Sets up the normal git environment variables and a few helper functions -(currently just "die()"), and returns OK if it all looks like a git archive. -So, to make the rest of the git scripts more careful and readable, -use it as follows: - -------------------------------------------------- -. git-sh-setup || die "Not a git archive" -------------------------------------------------- +This is not a command the end user would want to run. Ever. +This documentation is meant for people who are studying the +Porcelain-ish scripts and/or are writing new ones. + +The `git-sh-setup` scriptlet is designed to be sourced (using +`.`) by other shell scripts to set up some variables pointing at +the normal git directories and a few helper shell functions. + +Before sourcing it, your script should set up a few variables; +`USAGE` (and `LONG_USAGE`, if any) is used to define message +given by `usage()` shell function. `SUBDIRECTORY_OK` can be set +if the script can run from a subdirectory of the working tree +(some commands do not). + +The scriptlet sets `GIT_DIR` and `GIT_OBJECT_DIRECTORY` shell +variables, but does *not* export them to the environment. + +FUNCTIONS +--------- + +die:: + exit after emitting the supplied error message to the + standard error stream. + +usage:: + die with the usage message. + +set_reflog_action:: + set the message that will be recorded to describe the + end-user action in the reflog, when the script updates a + ref. + +is_bare_repository:: + outputs `true` or `false` to the standard output stream + to indicate if the repository is a bare repository + (i.e. without an associated working tree). + +cd_to_toplevel:: + runs chdir to the toplevel of the working tree. + +require_work_tree:: + checks if the repository is a bare repository, and dies + if so. Used by scripts that require working tree + (e.g. `checkout`). + Author ------ diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt index cc4266d83b..228b9f14f3 100644 --- a/Documentation/git-shell.txt +++ b/Documentation/git-shell.txt @@ -3,7 +3,7 @@ git-shell(1) NAME ---- -git-shell - Restricted login shell for GIT over SSH only +git-shell - Restricted login shell for GIT-only SSH access SYNOPSIS diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt index 95fa9010c1..b0df92e819 100644 --- a/Documentation/git-shortlog.txt +++ b/Documentation/git-shortlog.txt @@ -29,7 +29,7 @@ OPTIONS of author alphabetic order. -s:: - Supress commit description and provide a commit count summary only. + Suppress commit description and provide a commit count summary only. FILES ----- diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index 912e15bcba..b38633c397 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -11,7 +11,7 @@ SYNOPSIS 'git-show-branch' [--all] [--remotes] [--topo-order] [--current] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [<rev> | <glob>]... -'git-show-branch' --reflog[=<n>] <ref> +'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] <ref> DESCRIPTION ----------- @@ -97,9 +97,11 @@ OPTIONS will show the revisions given by "git rev-list {caret}master topic1 topic2" ---reflog[=<n>] <ref>:: - Shows <n> most recent ref-log entries for the given ref. - +--reflog[=<n>[,<base>]] <ref>:: + Shows <n> most recent ref-log entries for the given + ref. If <base> is given, <n> entries going back from + that entry. <base> can be specified as count or date. + `-g` can be used as a short-hand for this option. Note that --more, --list, --independent and --merge-base options are mutually exclusive. @@ -165,6 +167,13 @@ With this, `git show-branch` without extra parameters would show only the primary branches. In addition, if you happen to be on your topic branch, it is shown as well. +------------ +$ git show-branch --reflog='10,1 hour ago' --list master +------------ + +shows 10 reflog entries going back from the tip as of 1 hour ago. +Without `--list`, the output also shows how these tips are +topologically related with each other. Author diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt index c210b9af6b..9051951c34 100644 --- a/Documentation/git-show.txt +++ b/Documentation/git-show.txt @@ -32,6 +32,8 @@ OPTIONS ------- <object>:: The name of the object to show. + For a more complete list of ways to spell object names, see + "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1]. include::pretty-formats.txt[] diff --git a/Documentation/git-ssh-fetch.txt b/Documentation/git-ssh-fetch.txt index b7116b30e0..192b1f15a9 100644 --- a/Documentation/git-ssh-fetch.txt +++ b/Documentation/git-ssh-fetch.txt @@ -3,7 +3,7 @@ git-ssh-fetch(1) NAME ---- -git-ssh-fetch - Pulls from a remote repository over ssh connection +git-ssh-fetch - Fetch from a remote repository over ssh connection diff --git a/Documentation/git-ssh-upload.txt b/Documentation/git-ssh-upload.txt index 702674e45d..a9b7e9f974 100644 --- a/Documentation/git-ssh-upload.txt +++ b/Documentation/git-ssh-upload.txt @@ -3,7 +3,7 @@ git-ssh-upload(1) NAME ---- -git-ssh-upload - Pushes to a remote repository over ssh connection +git-ssh-upload - Push to a remote repository over ssh connection SYNOPSIS diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index ce7857e5a9..03871e5d73 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -3,7 +3,7 @@ git-status(1) NAME ---- -git-status - Show working tree status +git-status - Show the working tree status SYNOPSIS @@ -34,6 +34,15 @@ The output from this command is designed to be used as a commit template comments, and all the output lines are prefixed with '#'. +CONFIGURATION +------------- + +The command honors `color.status` (or `status.color` -- they +mean the same thing and the latter is kept for backward +compatibility) and `color.status.<slot>` configuration variables +to colorize its output. + + Author ------ Written by Linus Torvalds <torvalds@osdl.org> and diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index 9ed721118b..aea4a6bf5f 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -3,7 +3,7 @@ git-svn(1) NAME ---- -git-svn - bidirectional operation between Subversion and git +git-svn - Bidirectional operation between a single Subversion branch and git SYNOPSIS -------- @@ -113,7 +113,7 @@ manually joining branches on commit. 'commit-diff':: Commits the diff of two tree-ish arguments from the - command-line. This command is intended for interopability with + command-line. This command is intended for interoperability with git-svnimport and does not rely on being inside an git-svn init-ed repository. This command takes three arguments, (a) the original tree to diff against, (b) the new tree result, (c) the @@ -204,7 +204,7 @@ removed by default if there are no files left in them. git cannot version empty directories. Enabling this flag will make the commit to SVN act like git. -repo-config key: svn.rmdir +config key: svn.rmdir -e:: --edit:: @@ -215,7 +215,7 @@ Edit the commit message before committing to SVN. This is off by default for objects that are commits, and forced on when committing tree objects. -repo-config key: svn.edit +config key: svn.edit -l<num>:: --find-copies-harder:: @@ -226,8 +226,8 @@ They are both passed directly to git-diff-tree see gitlink:git-diff-tree[1] for more information. [verse] -repo-config key: svn.l -repo-config key: svn.findcopiesharder +config key: svn.l +config key: svn.findcopiesharder -A<filename>:: --authors-file=<filename>:: @@ -245,7 +245,7 @@ will abort operation. The user will then have to add the appropriate entry. Re-running the previous git-svn command after the authors-file is modified should continue operation. -repo-config key: svn.authorsfile +config key: svn.authorsfile -q:: --quiet:: @@ -262,8 +262,8 @@ repo-config key: svn.authorsfile --repack-flags are passed directly to gitlink:git-repack[1]. -repo-config key: svn.repack -repo-config key: svn.repackflags +config key: svn.repack +config key: svn.repackflags -m:: --merge:: @@ -304,7 +304,7 @@ used to track branches across multiple SVN _repositories_. This option may be specified multiple times, once for each branch. -repo-config key: svn.branch +config key: svn.branch -i<GIT_SVN_ID>:: --id <GIT_SVN_ID>:: @@ -320,7 +320,7 @@ for more information on using GIT_SVN_ID. started tracking a branch and never tracked the trunk it was descended from. -repo-config key: svn.followparent +config key: svn.followparent --no-metadata:: This gets rid of the git-svn-id: lines at the end of every commit. @@ -332,7 +332,7 @@ repo-config key: svn.followparent The 'git-svn log' command will not work on repositories using this, either. -repo-config key: svn.nometadata +config key: svn.nometadata -- diff --git a/Documentation/git-symbolic-ref.txt b/Documentation/git-symbolic-ref.txt index 4bc35a1d4b..f93b79a85e 100644 --- a/Documentation/git-symbolic-ref.txt +++ b/Documentation/git-symbolic-ref.txt @@ -3,11 +3,11 @@ git-symbolic-ref(1) NAME ---- -git-symbolic-ref - read and modify symbolic refs +git-symbolic-ref - Read and modify symbolic refs SYNOPSIS -------- -'git-symbolic-ref' <name> [<ref>] +'git-symbolic-ref' [-q] <name> [<ref>] DESCRIPTION ----------- @@ -23,6 +23,14 @@ A symbolic ref is a regular file that stores a string that begins with `ref: refs/`. For example, your `.git/HEAD` is a regular file whose contents is `ref: refs/heads/master`. +OPTIONS +------- + +-q:: + Do not issue an error message if the <name> is not a + symbolic ref but a detached HEAD; instead exit with + non-zero status silently. + NOTES ----- In the past, `.git/HEAD` was a symbolic link pointing at @@ -36,6 +44,10 @@ cumbersome. On some platforms, `ln -sf` does not even work as advertised (horrors). Therefore symbolic links are now deprecated and symbolic refs are used by default. +git-symbolic-ref will exit with status 0 if the contents of the +symbolic ref were printed correctly, with status 1 if the requested +name is not a symbolic ref, or 128 if another error occurs. + Author ------ Written by Junio C Hamano <junkio@cox.net> diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt index 80bece0775..3f01e0bfc5 100644 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@ -3,14 +3,14 @@ git-tag(1) NAME ---- -git-tag - Create a tag object signed with GPG +git-tag - Create, list, delete or verify a tag object signed with GPG SYNOPSIS -------- [verse] -'git-tag' [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg> | -F <file>] - <name> [<head>] +'git-tag' [-a | -s | -u <key-id>] [-f | -v] [-m <msg> | -F <file>] <name> [<head>] +'git-tag' -d <name>... 'git-tag' -l [<pattern>] DESCRIPTION @@ -55,7 +55,7 @@ OPTIONS Replace an existing tag with the given name (instead of failing) -d:: - Delete an existing tag with the given name + Delete existing tags with the given names. -v:: Verify the gpg signature of given the tag @@ -70,6 +70,16 @@ OPTIONS Take the tag message from the given file. Use '-' to read the message from the standard input. +CONFIGURATION +------------- +By default, git-tag in sign-with-default mode (-s) will use your +committer identity (of the form "Your Name <your@email.address>") to +find a key. If you want to use a different default key, you can specify +it in the repository configuration as follows: + +[user] + signingkey = <gpg-key-id> + Author ------ Written by Linus Torvalds <torvalds@osdl.org>, diff --git a/Documentation/git-tar-tree.txt b/Documentation/git-tar-tree.txt index 74a6fddd9a..595940524e 100644 --- a/Documentation/git-tar-tree.txt +++ b/Documentation/git-tar-tree.txt @@ -3,7 +3,7 @@ git-tar-tree(1) NAME ---- -git-tar-tree - Creates a tar archive of the files in the named tree +git-tar-tree - Create a tar archive of the files in the named tree object SYNOPSIS @@ -50,7 +50,7 @@ repository configuration as follows : umask = 002 ;# group friendly The special umask value "user" indicates that the user's current umask -will be used instead. The default value remains 0, which means world +will be used instead. The default value is 002, which means group readable/writable files and directories. EXAMPLES diff --git a/Documentation/git-tools.txt b/Documentation/git-tools.txt index 0914cbb0ba..6b407f9adf 100644 --- a/Documentation/git-tools.txt +++ b/Documentation/git-tools.txt @@ -50,7 +50,7 @@ History Viewers gitview is a GTK based repository browser for git - - *gitweb* (ftp://ftp.kernel.org/pub/software/scm/gitweb/) + - *gitweb* (shipped with git-core) GITweb provides full-fledged web interface for GIT repositories. @@ -63,12 +63,18 @@ History Viewers Currently it is the fastest and most feature rich among the git viewers and commit tools. + - *tig* (http://jonas.nitro.dk/tig/) + + tig by Jonas Fonseca is a simple git repository browser + written using ncurses. Basically, it just acts as a front-end + for git-log and git-show/git-diff. Additionally, you can also + use it as a pager for git commands. Foreign SCM interface --------------------- - - *git-svn* (contrib/) + - *git-svn* (shipped with git-core) git-svn is a simple conduit for changesets between a single Subversion branch and git. @@ -95,3 +101,7 @@ Others This is an Emacs interface for git. The user interface is modeled on pcl-cvs. It has been developed on Emacs 21 and will probably need some tweaking to work on XEmacs. + + +http://git.or.cz/gitwiki/InterfacesFrontendsAndTools has more +comprehensive list. diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt index 0e0a3af1be..b161c8b32b 100644 --- a/Documentation/git-update-index.txt +++ b/Documentation/git-update-index.txt @@ -3,7 +3,7 @@ git-update-index(1) NAME ---- -git-update-index - Modifies the index or directory cache +git-update-index - Register file contents in the working tree to the index SYNOPSIS @@ -289,7 +289,7 @@ Configuration The command honors `core.filemode` configuration variable. If your repository is on an filesystem whose executable bits are -unreliable, this should be set to 'false' (see gitlink:git-repo-config[1]). +unreliable, this should be set to 'false' (see gitlink:git-config[1]). This causes the command to ignore differences in file modes recorded in the index and the file mode on the filesystem if they differ only on executable bit. On such an unfortunate filesystem, you may @@ -301,7 +301,7 @@ The command looks at `core.ignorestat` configuration variable. See See Also -------- -gitlink:git-repo-config[1] +gitlink:git-config[1] Author diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt index 71bcb7954f..9424feab32 100644 --- a/Documentation/git-update-ref.txt +++ b/Documentation/git-update-ref.txt @@ -3,7 +3,7 @@ git-update-ref(1) NAME ---- -git-update-ref - update the object name stored in a ref safely +git-update-ref - Update the object name stored in a ref safely SYNOPSIS -------- diff --git a/Documentation/git-upload-archive.txt b/Documentation/git-upload-archive.txt index 388bb53d29..403871d7c6 100644 --- a/Documentation/git-upload-archive.txt +++ b/Documentation/git-upload-archive.txt @@ -3,7 +3,7 @@ git-upload-archive(1) NAME ---- -git-upload-archive - Send archive +git-upload-archive - Send archive back to git-archive SYNOPSIS diff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt index b2c9307661..9da062d5c9 100644 --- a/Documentation/git-upload-pack.txt +++ b/Documentation/git-upload-pack.txt @@ -3,7 +3,7 @@ git-upload-pack(1) NAME ---- -git-upload-pack - Send missing objects packed +git-upload-pack - Send objects packed back to git-fetch-pack SYNOPSIS diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt index a5b1a0dbab..9b0de1c111 100644 --- a/Documentation/git-var.txt +++ b/Documentation/git-var.txt @@ -3,7 +3,7 @@ git-var(1) NAME ---- -git-var - Print the git users identity +git-var - Show a git logical variable SYNOPSIS @@ -20,7 +20,7 @@ OPTIONS Cause the logical variables to be listed. In addition, all the variables of the git configuration file .git/config are listed as well. (However, the configuration variables listing functionality - is deprecated in favor of `git-repo-config -l`.) + is deprecated in favor of `git-config -l`.) EXAMPLE -------- @@ -49,7 +49,7 @@ See Also -------- gitlink:git-commit-tree[1] gitlink:git-tag[1] -gitlink:git-repo-config[1] +gitlink:git-config[1] Author ------ diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt index e8f21d02f7..399bff3bbc 100644 --- a/Documentation/git-whatchanged.txt +++ b/Documentation/git-whatchanged.txt @@ -27,7 +27,7 @@ OPTIONS output format that is useful only to tell the changed paths and their nature of changes. ---max-count=<n>:: +-<n>:: Limit output to <n> commits. <since>..<until>:: diff --git a/Documentation/git-write-tree.txt b/Documentation/git-write-tree.txt index c85fa89c30..96d5e07b11 100644 --- a/Documentation/git-write-tree.txt +++ b/Documentation/git-write-tree.txt @@ -3,7 +3,7 @@ git-write-tree(1) NAME ---- -git-write-tree - Creates a tree object from the current index +git-write-tree - Create a tree object from the current index SYNOPSIS diff --git a/Documentation/git.txt b/Documentation/git.txt index f89d745efa..7cd3467986 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -24,7 +24,7 @@ link:everyday.html[Everyday Git] for a useful minimum set of commands, and also want to read link:cvs-migration.html[CVS migration]. The COMMAND is either a name of a Git command (see below) or an alias -as defined in the configuration file (see gitlink:git-repo-config[1]). +as defined in the configuration file (see gitlink:git-config[1]). OPTIONS ------- @@ -81,244 +81,26 @@ ancillary user utilities. Main porcelain commands ~~~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-add[1]:: - Add paths to the index. - -gitlink:git-am[1]:: - Apply patches from a mailbox, but cooler. - -gitlink:git-applymbox[1]:: - Apply patches from a mailbox, original version by Linus. - -gitlink:git-archive[1]:: - Creates an archive of files from a named tree. - -gitlink:git-bisect[1]:: - Find the change that introduced a bug by binary search. - -gitlink:git-branch[1]:: - Create and Show branches. - -gitlink:git-checkout[1]:: - Checkout and switch to a branch. - -gitlink:git-cherry-pick[1]:: - Cherry-pick the effect of an existing commit. - -gitlink:git-clean[1]:: - Remove untracked files from the working tree. - -gitlink:git-clone[1]:: - Clones a repository into a new directory. - -gitlink:git-commit[1]:: - Record changes to the repository. - -gitlink:git-diff[1]:: - Show changes between commits, commit and working tree, etc. - -gitlink:git-fetch[1]:: - Download from a remote repository via various protocols. - -gitlink:git-format-patch[1]:: - Prepare patches for e-mail submission. - -gitlink:git-grep[1]:: - Print lines matching a pattern. - -gitlink:gitk[1]:: - The git repository browser. - -gitlink:git-log[1]:: - Shows commit logs. - -gitlink:git-ls-remote[1]:: - Shows references in a remote or local repository. - -gitlink:git-merge[1]:: - Grand unified merge driver. - -gitlink:git-mv[1]:: - Move or rename a file, a directory, or a symlink. - -gitlink:git-pack-refs[1]:: - Pack heads and tags for efficient repository access. - -gitlink:git-pull[1]:: - Fetch from and merge with a remote repository or a local branch. - -gitlink:git-push[1]:: - Update remote refs along with associated objects. - -gitlink:git-rebase[1]:: - Rebase local commits to the updated upstream head. - -gitlink:git-repack[1]:: - Pack unpacked objects in a repository. - -gitlink:git-rerere[1]:: - Reuse recorded resolution of conflicted merges. - -gitlink:git-reset[1]:: - Reset current HEAD to the specified state. - -gitlink:git-resolve[1]:: - Merge two commits. - -gitlink:git-revert[1]:: - Revert an existing commit. - -gitlink:git-rm[1]:: - Remove files from the working tree and from the index. - -gitlink:git-shortlog[1]:: - Summarizes 'git log' output. - -gitlink:git-show[1]:: - Show one commit log and its diff. - -gitlink:git-show-branch[1]:: - Show branches and their commits. - -gitlink:git-status[1]:: - Shows the working tree status. - -gitlink:git-verify-tag[1]:: - Check the GPG signature of tag. - -gitlink:git-whatchanged[1]:: - Shows commit logs and differences they introduce. - +include::cmds-mainporcelain.txt[] Ancillary Commands ~~~~~~~~~~~~~~~~~~ Manipulators: -gitlink:git-applypatch[1]:: - Apply one patch extracted from an e-mail. - -gitlink:git-archimport[1]:: - Import an arch repository into git. - -gitlink:git-convert-objects[1]:: - Converts old-style git repository. - -gitlink:git-cvsimport[1]:: - Salvage your data out of another SCM people love to hate. - -gitlink:git-cvsexportcommit[1]:: - Export a single commit to a CVS checkout. - -gitlink:git-cvsserver[1]:: - A CVS server emulator for git. - -gitlink:git-gc[1]:: - Cleanup unnecessary files and optimize the local repository. - -gitlink:git-lost-found[1]:: - Recover lost refs that luckily have not yet been pruned. - -gitlink:git-merge-one-file[1]:: - The standard helper program to use with `git-merge-index`. - -gitlink:git-prune[1]:: - Prunes all unreachable objects from the object database. - -gitlink:git-quiltimport[1]:: - Applies a quilt patchset onto the current branch. - -gitlink:git-reflog[1]:: - Manage reflog information. - -gitlink:git-relink[1]:: - Hardlink common objects in local repositories. - -gitlink:git-svn[1]:: - Bidirectional operation between a single Subversion branch and git. - -gitlink:git-svnimport[1]:: - Import a SVN repository into git. - -gitlink:git-sh-setup[1]:: - Common git shell script setup code. - -gitlink:git-symbolic-ref[1]:: - Read and modify symbolic refs. - -gitlink:git-tag[1]:: - An example script to create a tag object signed with GPG. - -gitlink:git-update-ref[1]:: - Update the object name stored in a ref safely. - +include::cmds-ancillarymanipulators.txt[] Interrogators: -gitlink:git-annotate[1]:: - Annotate file lines with commit info. - -gitlink:git-blame[1]:: - Find out where each line in a file came from. - -gitlink:git-check-ref-format[1]:: - Make sure ref name is well formed. +include::cmds-ancillaryinterrogators.txt[] -gitlink:git-cherry[1]:: - Find commits not merged upstream. -gitlink:git-count-objects[1]:: - Count unpacked number of objects and their disk consumption. - -gitlink:git-daemon[1]:: - A really simple server for git repositories. - -gitlink:git-fmt-merge-msg[1]:: - Produce a merge commit message. - -gitlink:git-get-tar-commit-id[1]:: - Extract commit ID from an archive created using git-tar-tree. - -gitlink:git-imap-send[1]:: - Dump a mailbox from stdin into an imap folder. - -gitlink:git-instaweb[1]:: - Instantly browse your working repository in gitweb. - -gitlink:git-mailinfo[1]:: - Extracts patch and authorship information from a single - e-mail message, optionally transliterating the commit - message into utf-8. - -gitlink:git-mailsplit[1]:: - A stupid program to split UNIX mbox format mailbox into - individual pieces of e-mail. - -gitlink:git-merge-tree[1]:: - Show three-way merge without touching index. - -gitlink:git-patch-id[1]:: - Compute unique ID for a patch. - -gitlink:git-parse-remote[1]:: - Routines to help parsing `$GIT_DIR/remotes/` files. - -gitlink:git-request-pull[1]:: - git-request-pull. - -gitlink:git-rev-parse[1]:: - Pick out and massage parameters. - -gitlink:git-runstatus[1]:: - A helper for git-status and git-commit. - -gitlink:git-send-email[1]:: - Send patch e-mails out of "format-patch --mbox" output. +Interacting with Others +~~~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-symbolic-ref[1]:: - Read and modify symbolic refs. +These commands are to interact with foreign SCM and with other +people via patch over e-mail. -gitlink:git-stripspace[1]:: - Filter out empty lines. +include::cmds-foreignscminterface.txt[] Low-level commands (plumbing) @@ -330,129 +112,30 @@ development of alternative porcelains. Developers of such porcelains might start by reading about gitlink:git-update-index[1] and gitlink:git-read-tree[1]. -We divide the low-level commands into commands that manipulate objects (in +The interface (input, output, set of options and the semantics) +to these low-level commands are meant to be a lot more stable +than Porcelain level commands, because these commands are +primarily for scripted use. The interface to Porcelain commands +on the other hand are subject to change in order to improve the +end user experience. + +The following description divides +the low-level commands into commands that manipulate objects (in the repository, index, and working tree), commands that interrogate and compare objects, and commands that move objects and references between repositories. + Manipulation commands ~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-apply[1]:: - Reads a "diff -up1" or git generated patch file and - applies it to the working tree. - -gitlink:git-checkout-index[1]:: - Copy files from the index to the working tree. - -gitlink:git-commit-tree[1]:: - Creates a new commit object. - -gitlink:git-hash-object[1]:: - Computes the object ID from a file. - -gitlink:git-index-pack[1]:: - Build pack idx file for an existing packed archive. - -gitlink:git-init[1]:: - Creates an empty git repository, or reinitialize an - existing one. - -gitlink:git-merge-file[1]:: - Runs a threeway merge. - -gitlink:git-merge-index[1]:: - Runs a merge for files needing merging. - -gitlink:git-mktag[1]:: - Creates a tag object. - -gitlink:git-mktree[1]:: - Build a tree-object from ls-tree formatted text. - -gitlink:git-pack-objects[1]:: - Creates a packed archive of objects. - -gitlink:git-prune-packed[1]:: - Remove extra objects that are already in pack files. - -gitlink:git-read-tree[1]:: - Reads tree information into the index. -gitlink:git-repo-config[1]:: - Get and set options in .git/config. - -gitlink:git-unpack-objects[1]:: - Unpacks objects out of a packed archive. - -gitlink:git-update-index[1]:: - Registers files in the working tree to the index. - -gitlink:git-write-tree[1]:: - Creates a tree from the index. +include::cmds-plumbingmanipulators.txt[] Interrogation commands ~~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-cat-file[1]:: - Provide content or type/size information for repository objects. - -gitlink:git-describe[1]:: - Show the most recent tag that is reachable from a commit. - -gitlink:git-diff-index[1]:: - Compares content and mode of blobs between the index and repository. - -gitlink:git-diff-files[1]:: - Compares files in the working tree and the index. - -gitlink:git-diff-stages[1]:: - Compares two "merge stages" in the index. - -gitlink:git-diff-tree[1]:: - Compares the content and mode of blobs found via two tree objects. - -gitlink:git-for-each-ref[1]:: - Output information on each ref. - -gitlink:git-fsck-objects[1]:: - Verifies the connectivity and validity of the objects in the database. - -gitlink:git-ls-files[1]:: - Information about files in the index and the working tree. - -gitlink:git-ls-tree[1]:: - Displays a tree object in human readable form. - -gitlink:git-merge-base[1]:: - Finds as good common ancestors as possible for a merge. - -gitlink:git-name-rev[1]:: - Find symbolic names for given revs. - -gitlink:git-pack-redundant[1]:: - Find redundant pack files. - -gitlink:git-rev-list[1]:: - Lists commit objects in reverse chronological order. - -gitlink:git-show-index[1]:: - Displays contents of a pack idx file. - -gitlink:git-show-ref[1]:: - List references in a local repository. - -gitlink:git-tar-tree[1]:: - Creates a tar archive of the files in the named tree object. - -gitlink:git-unpack-file[1]:: - Creates a temporary file with a blob's contents. - -gitlink:git-var[1]:: - Displays a git logical variable. - -gitlink:git-verify-pack[1]:: - Validates packed git archive files. +include::cmds-plumbinginterrogators.txt[] In general, the interrogate commands do not touch the files in the working tree. @@ -461,52 +144,21 @@ the working tree. Synching repositories ~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-fetch-pack[1]:: - Updates from a remote repository (engine for ssh and - local transport). - -gitlink:git-http-fetch[1]:: - Downloads a remote git repository via HTTP by walking - commit chain. - -gitlink:git-local-fetch[1]:: - Duplicates another git repository on a local system by - walking commit chain. - -gitlink:git-peek-remote[1]:: - Lists references on a remote repository using - upload-pack protocol (engine for ssh and local - transport). - -gitlink:git-receive-pack[1]:: - Invoked by 'git-send-pack' to receive what is pushed to it. - -gitlink:git-send-pack[1]:: - Pushes to a remote repository, intelligently. - -gitlink:git-http-push[1]:: - Push missing objects using HTTP/DAV. +include::cmds-synchingrepositories.txt[] -gitlink:git-shell[1]:: - Restricted shell for GIT-only SSH access. +The following are helper programs used by the above; end users +typically do not use them directly. -gitlink:git-ssh-fetch[1]:: - Pulls from a remote repository over ssh connection by - walking commit chain. +include::cmds-synchelpers.txt[] -gitlink:git-ssh-upload[1]:: - Helper "server-side" program used by git-ssh-fetch. -gitlink:git-update-server-info[1]:: - Updates auxiliary information on a dumb server to help - clients discover references and packs on it. +Internal helper commands +~~~~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-upload-archive[1]:: - Invoked by 'git-archive' to send a generated archive. +These are internal helper commands used by other commands; end +users typically do not use them directly. -gitlink:git-upload-pack[1]:: - Invoked by 'git-fetch-pack' to push - what are asked for. +include::cmds-purehelpers.txt[] Configuration Mechanism @@ -699,7 +351,7 @@ other Discussion[[Discussion]] ------------------------ -include::README[] +include::core-intro.txt[] Authors ------- diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt index f1aeb07f64..5bdaa601f0 100644 --- a/Documentation/gitk.txt +++ b/Documentation/gitk.txt @@ -3,7 +3,7 @@ gitk(1) NAME ---- -gitk - git repository browser +gitk - The git repository browser SYNOPSIS -------- @@ -47,6 +47,8 @@ frequently used options. meaning show from the given revision and back, or it can be a range in the form "'<from>'..'<to>'" to show all revisions between '<from>' and back to '<to>'. Note, more advanced revision selection can be applied. + For a more complete list of ways to spell object names, see + "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1]. <path>:: diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt index bc917bbac3..d20eb6270c 100644 --- a/Documentation/glossary.txt +++ b/Documentation/glossary.txt @@ -286,6 +286,18 @@ SCM:: SHA1:: Synonym for object name. +shallow repository:: + A shallow repository has an incomplete history some of + whose commits have parents cauterized away (in other + words, git is told to pretend that these commits do not + have the parents, even though they are recorded in the + commit object). This is sometimes useful when you are + interested only in the recent history of a project even + though the real history recorded in the upstream is + much larger. A shallow repository is created by giving + `--depth` option to gitlink:git-clone[1], and its + history can be later deepened with gitlink:git-fetch[1]. + symref:: Symbolic reference: instead of containing the SHA1 id itself, it is of the format 'ref: refs/some/thing' and when referenced, it diff --git a/Documentation/howto/dangling-objects.txt b/Documentation/howto/dangling-objects.txt new file mode 100644 index 0000000000..e82ddae3cf --- /dev/null +++ b/Documentation/howto/dangling-objects.txt @@ -0,0 +1,109 @@ +From: Linus Torvalds <torvalds@linux-foundation.org> +Subject: Re: Question about fsck-objects output +Date: Thu, 25 Jan 2007 12:01:06 -0800 (PST) +Message-ID: <Pine.LNX.4.64.0701251144290.25027@woody.linux-foundation.org> +Archived-At: <http://permalink.gmane.org/gmane.comp.version-control.git/37754> +Abstract: Linus describes what dangling objects are, when they + are left behind, and how to view their relationship with branch + heads in gitk + +On Thu, 25 Jan 2007, Larry Streepy wrote: + +> Sorry to ask such a basic question, but I can't quite decipher the output of +> fsck-objects. When I run it, I get this: +> +> git fsck-objects +> dangling commit 2213f6d4dd39ca8baebd0427723723e63208521b +> dangling commit f0d4e00196bd5ee54463e9ea7a0f0e8303da767f +> dangling blob 6a6d0b01b3e96d49a8f2c7addd4ef8c3bd1f5761 +> +> +> Even after a "repack -a -d" they still exist. The man page has a short +> explanation, but, at least for me, it wasn't fully enlightening. :-) +> +> The man page says that dangling commits could be "root" commits, but since my +> repo started as a clone of another repo, I don't see how I could have any root +> commits. Also, the page doesn't really describe what a dangling blob is. +> +> So, can someone explain what these artifacts are and if they are a problem +> that I should be worried about? + +The most common situation is that you've rebased a branch (or you have +pulled from somebody else who rebased a branch, like the "pu" branch in +the git.git archive itself). + +What happens is that the old head of the original branch still exists, as +does obviously everything it pointed to. The branch pointer itself just +doesn't, since you replaced it with another one. + +However, there are certainly other situations too that cause dangling +objects. For example, the "dangling blob" situation you have tends to be +because you did a "git add" of a file, but then, before you actually +committed it and made it part of the bigger picture, you changed something +else in that file and committed that *updated* thing - the old state that +you added originally ends up not being pointed to by any commit/tree, so +it's now a dangling blob object. + +Similarly, when the "recursive" merge strategy runs, and finds that there +are criss-cross merges and thus more than one merge base (which is fairly +unusual, but it does happen), it will generate one temporary midway tree +(or possibly even more, if you had lots of criss-crossing merges and +more than two merge bases) as a temporary internal merge base, and again, +those are real objects, but the end result will not end up pointing to +them, so they end up "dangling" in your repository. + +Generally, dangling objects aren't anything to worry about. They can even +be very useful: if you screw something up, the dangling objects can be how +you recover your old tree (say, you did a rebase, and realized that you +really didn't want to - you can look at what dangling objects you have, +and decide to reset your head to some old dangling state). + +For commits, the most useful thing to do with dangling objects tends to be +to do a simple + + gitk <dangling-commit-sha-goes-here> --not --all + +which means exactly what it sounds like: it says that you want to see the +commit history that is described by the dangling commit(s), but you do NOT +want to see the history that is described by all your branches and tags +(which are the things you normally reach). That basically shows you in a +nice way what the danglign commit was (and notice that it might not be +just one commit: we only report the "tip of the line" as being dangling, +but there might be a whole deep and complex commit history that has gotten +dropped - rebasing will do that). + +For blobs and trees, you can't do the same, but you can examine them. You +can just do + + git show <dangling-blob/tree-sha-goes-here> + +to show what the contents of the blob were (or, for a tree, basically what +the "ls" for that directory was), and that may give you some idea of what +the operation was that left that dangling object. + +Usually, dangling blobs and trees aren't very interesting. They're almost +always the result of either being a half-way mergebase (the blob will +often even have the conflict markers from a merge in it, if you have had +conflicting merges that you fixed up by hand), or simply because you +interrupted a "git fetch" with ^C or something like that, leaving _some_ +of the new objects in the object database, but just dangling and useless. + +Anyway, once you are sure that you're not interested in any dangling +state, you can just prune all unreachable objects: + + git prune + +and they'll be gone. But you should only run "git prune" on a quiescent +repository - it's kind of like doing a filesystem fsck recovery: you don't +want to do that while the filesystem is mounted. + +(The same is true of "git-fsck-objects" itself, btw - but since +git-fsck-objects never actually *changes* the repository, it just reports +on what it found, git-fsck-objects itself is never "dangerous" to run. +Running it while somebody is actually changing the repository can cause +confusing and scary messages, but it won't actually do anything bad. In +contrast, running "git prune" while somebody is actively changing the +repository is a *BAD* idea). + + Linus + diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt index fcd64e9b9b..3b3a5c2e69 100644 --- a/Documentation/howto/rebase-from-internal-branch.txt +++ b/Documentation/howto/rebase-from-internal-branch.txt @@ -106,7 +106,7 @@ prepare #2 and #3 for e-mail submission. $ git format-patch master^^ master -This creates two files, 0001-XXXX.txt and 0002-XXXX.txt. Send +This creates two files, 0001-XXXX.patch and 0002-XXXX.patch. Send them out "To: " your project maintainer and "Cc: " your mailing list. You could use contributed script git-send-email if your host has necessary perl modules for this, but your usual diff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt index a202f3a460..8eadc20494 100644 --- a/Documentation/howto/setup-git-server-over-http.txt +++ b/Documentation/howto/setup-git-server-over-http.txt @@ -205,7 +205,7 @@ To check whether all is OK, do: Now, add the remote in your existing repository which contains the project you want to export: - $ git-repo-config remote.upload.url \ + $ git-config remote.upload.url \ http://<username>@<servername>/my-new-repo.git/ It is important to put the last '/'; Without it, the server will send @@ -222,7 +222,7 @@ From your client repository, do This pushes branch 'master' (which is assumed to be the branch you want to export) to repository called 'upload', which we previously -defined with git-repo-config. +defined with git-config. Troubleshooting: diff --git a/Documentation/repository-layout.txt b/Documentation/repository-layout.txt index 0fdd36614d..863cb6710a 100644 --- a/Documentation/repository-layout.txt +++ b/Documentation/repository-layout.txt @@ -18,6 +18,8 @@ could have only commit objects without associated blobs and trees this way, for example. A repository with this kind of incomplete object store is not suitable to be published to the outside world but sometimes useful for private repository. +. You also could have an incomplete but locally usable repository +by cloning shallowly. See gitlink:git-clone[1]. . You can be using `objects/info/alternates` mechanism, or `$GIT_ALTERNATE_OBJECT_DIRECTORIES` mechanism to 'borrow' objects from other object stores. A repository with this kind @@ -32,7 +34,7 @@ objects/[0-9a-f][0-9a-f]:: two letters from its object name to keep the number of directory entries `objects` directory itself needs to hold. Objects found here are often called 'unpacked' - objects. + (or 'loose') objects. objects/pack:: Packs (files that store many object in compressed form, @@ -80,6 +82,15 @@ refs/tags/`name`:: records any object name (not necessarily a commit object, or a tag object that points at a commit object). +refs/remotes/`name`:: + records tip-of-the-tree commit objects of branches copied + from a remote repository. + +packed-refs:: + records the same information as refs/heads/, refs/tags/, + and friends record in a more efficient way. See + gitlink:git-pack-refs[1]. + HEAD:: A symref (see glossary) to the `refs/heads/` namespace describing the currently active branch. It does not mean @@ -91,6 +102,12 @@ HEAD:: 'name' does not (yet) exist. In some legacy setups, it is a symbolic link instead of a symref that points at the current branch. ++ +HEAD can also record a specific commit directly, instead of +being a symref to point at the current branch. Such a state +is often called 'detached HEAD', and almost all commands work +identically as normal. See gitlink:git-checkout[1] for +details. branches:: A slightly deprecated way to store shorthands to be used @@ -156,3 +173,9 @@ logs/refs/heads/`name`:: logs/refs/tags/`name`:: Records all changes made to the tag named `name`. + +shallow:: + This is similar to `info/grafts` but is internally used + and maintained by shallow clone mechanism. See `--depth` + option to gitlink:git-clone[1] and gitlink:git-fetch[1]. + diff --git a/Documentation/tutorial-2.txt b/Documentation/tutorial-2.txt index f48894c9a2..f363d17f0b 100644 --- a/Documentation/tutorial-2.txt +++ b/Documentation/tutorial-2.txt @@ -343,8 +343,8 @@ And, as you can see with cat-file, this new entry refers to the current contents of the file: ------------------------------------------------ -$ git cat-file blob a6b11f7a -goodbye, word +$ git cat-file blob 8b9743b2 +goodbye, world ------------------------------------------------ The "status" command is a useful way to get a quick summary of the diff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt index d2bf0b905a..adb1e32750 100644 --- a/Documentation/tutorial.txt +++ b/Documentation/tutorial.txt @@ -11,15 +11,13 @@ diff" with: $ man git-diff ------------------------------------------------ -It is a good idea to introduce yourself to git before doing any -operation. The easiest way to do so is: +It is a good idea to introduce yourself to git with your name and +public email address before doing any operation. The easiest +way to do so is: ------------------------------------------------ -$ cat >~/.gitconfig <<\EOF -[user] - name = Your Name Comes Here - email = you@yourdomain.example.com -EOF +$ git config --global user.name "Your Name Comes Here" +$ git config --global user.email you@yourdomain.example.com ------------------------------------------------ @@ -211,7 +209,7 @@ at this point the two branches have diverged, with different changes made in each. To merge the changes made in experimental into master, run ------------------------------------------------ -$ git pull . experimental +$ git merge experimental ------------------------------------------------ If the changes don't conflict, you're done. If there are conflicts, @@ -297,46 +295,51 @@ is the default.) The "pull" command thus performs two operations: it fetches changes from a remote branch, then merges them into the current branch. -You can perform the first operation alone using the "git fetch" -command. For example, Alice could create a temporary branch just to -track Bob's changes, without merging them with her own, using: +When you are working in a small closely knit group, it is not +unusual to interact with the same repository over and over +again. By defining 'remote' repository shorthand, you can make +it easier: + +------------------------------------------------ +$ git remote add bob /home/bob/myrepo +------------------------------------------------ + +With this, you can perform the first operation alone using the +"git fetch" command without merging them with her own branch, +using: ------------------------------------- -$ git fetch /home/bob/myrepo master:bob-incoming +$ git fetch bob ------------------------------------- -which fetches the changes from Bob's master branch into a new branch -named bob-incoming. Then +Unlike the longhand form, when Alice fetches from Bob using a +remote repository shorthand set up with `git remote`, what was +fetched is stored in a remote tracking branch, in this case +`bob/master`. So after this: ------------------------------------- -$ git log -p master..bob-incoming +$ git log -p master..bob/master ------------------------------------- shows a list of all the changes that Bob made since he branched from Alice's master branch. -After examining those changes, and possibly fixing things, Alice -could pull the changes into her master branch: +After examining those changes, Alice +could merge the changes into her master branch: ------------------------------------- -$ git checkout master -$ git pull . bob-incoming +$ git merge bob/master ------------------------------------- -The last command is a pull from the "bob-incoming" branch in Alice's -own repository. - -Alice could also perform both steps at once with: +This `merge` can also be done by 'pulling from her own remote +tracking branch', like this: ------------------------------------- -$ git pull /home/bob/myrepo master:bob-incoming +$ git pull . remotes/bob/master ------------------------------------- -This is just like the "git pull /home/bob/myrepo master" that we saw -before, except that it also stores the unmerged changes from bob's -master branch in bob-incoming before merging them into Alice's -current branch. Note that git pull always merges into the current -branch, regardless of what else is given on the commandline. +Note that git pull always merges into the current branch, +regardless of what else is given on the commandline. Later, Bob can update his repo with Alice's latest changes using @@ -350,12 +353,12 @@ repository in the repository configuration, and that location is used for pulls: ------------------------------------- -$ git repo-config --get remote.origin.url +$ git config --get remote.origin.url /home/bob/myrepo ------------------------------------- (The complete configuration created by git-clone is visible using -"git repo-config -l", and the gitlink:git-repo-config[1] man page +"git config -l", and the gitlink:git-config[1] man page explains the meaning of each option.) Git also keeps a pristine copy of Alice's master branch under the diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 8502e4c5b2..e0adc340d3 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.5.0-rc1.GIT +DEF_VER=v1.5.0-rc2.GIT LF=' ' @@ -192,7 +192,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS = \ - git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \ + git-convert-objects$X git-fetch-pack$X git-fsck$X \ git-hash-object$X git-index-pack$X git-local-fetch$X \ git-fast-import$X \ git-merge-base$X \ @@ -214,7 +214,8 @@ EXTRA_PROGRAMS = BUILT_INS = \ git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \ - git-get-tar-commit-id$X git-init$X \ + git-get-tar-commit-id$X git-init$X git-repo-config$X \ + git-fsck-objects$X \ $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS)) # what 'all' will build and 'install' will install, in gitexecdir @@ -242,7 +243,7 @@ LIB_H = \ diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \ run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \ tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \ - utf8.h + utf8.h reflog-walk.h DIFF_OBJS = \ diff.o diff-lib.o diffcore-break.o diffcore-order.o \ @@ -255,7 +256,7 @@ LIB_OBJS = \ interpolate.o \ lockfile.o \ object.o pack-check.o patch-delta.o path.o pkt-line.o sideband.o \ - reachable.o \ + reachable.o reflog-walk.o \ quote.o read-cache.o refs.o run-command.o dir.o object-refs.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 \ @@ -284,6 +285,7 @@ BUILTIN_OBJS = \ builtin-diff-tree.o \ builtin-fmt-merge-msg.o \ builtin-for-each-ref.o \ + builtin-fsck.o \ builtin-grep.o \ builtin-init-db.o \ builtin-log.o \ @@ -300,7 +302,7 @@ BUILTIN_OBJS = \ builtin-push.o \ builtin-read-tree.o \ builtin-reflog.o \ - builtin-repo-config.o \ + builtin-config.o \ builtin-rerere.o \ builtin-rev-list.o \ builtin-rev-parse.o \ @@ -3,6 +3,7 @@ GIT - the stupid content tracker //////////////////////////////////////////////////////////////// + "git" can mean anything, depending on your mood. - random three-letter combination that is pronounceable, and not @@ -11,579 +12,29 @@ - stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang. - "global information tracker": you're in a good mood, and it actually - works for you. Angels sing, and a light suddenly fills the room. + works for you. Angels sing, and a light suddenly fills the room. - "goddamn idiotic truckload of sh*t": when it breaks -This is a stupid (but extremely fast) directory content manager. It -doesn't do a whole lot, but what it 'does' do is track directory -contents efficiently. - -There are two object abstractions: the "object database", and the -"current directory cache" aka "index". - -The Object Database -~~~~~~~~~~~~~~~~~~~ -The object database is literally just a content-addressable collection -of objects. All objects are named by their content, which is -approximated by the SHA1 hash of the object itself. Objects may refer -to other objects (by referencing their SHA1 hash), and so you can -build up a hierarchy of objects. - -All objects have a statically determined "type" aka "tag", which is -determined at object creation time, and which identifies the format of -the object (i.e. how it is used, and how it can refer to other -objects). There are currently four different object types: "blob", -"tree", "commit" and "tag". - -A "blob" object cannot refer to any other object, and is, like the type -implies, a pure storage object containing some user data. It is used to -actually store the file data, i.e. a blob object is associated with some -particular version of some file. - -A "tree" object is an object that ties one or more "blob" objects into a -directory structure. In addition, a tree object can refer to other tree -objects, thus creating a directory hierarchy. - -A "commit" object ties such directory hierarchies together into -a DAG of revisions - each "commit" is associated with exactly one tree -(the directory hierarchy at the time of the commit). In addition, a -"commit" refers to one or more "parent" commit objects that describe the -history of how we arrived at that directory hierarchy. - -As a special case, a commit object with no parents is called the "root" -object, and is the point of an initial project commit. Each project -must have at least one root, and while you can tie several different -root objects together into one project by creating a commit object which -has two or more separate roots as its ultimate parents, that's probably -just going to confuse people. So aim for the notion of "one root object -per project", even if git itself does not enforce that. - -A "tag" object symbolically identifies and can be used to sign other -objects. It contains the identifier and type of another object, a -symbolic name (of course!) and, optionally, a signature. - -Regardless of object type, all objects share the following -characteristics: they are all deflated with zlib, and have a header -that not only specifies their type, but also provides size information -about the data in the object. It's worth noting that the SHA1 hash -that is used to name the object is the hash of the original data -plus this header, so `sha1sum` 'file' does not match the object name -for 'file'. -(Historical note: in the dawn of the age of git the hash -was the sha1 of the 'compressed' object.) - -As a result, the general consistency of an object can always be tested -independently of the contents or the type of the object: all objects can -be validated by verifying that (a) their hashes match the content of the -file and (b) the object successfully inflates to a stream of bytes that -forms a sequence of <ascii type without space> + <space> + <ascii decimal -size> + <byte\0> + <binary object data>. - -The structured objects can further have their structure and -connectivity to other objects verified. This is generally done with -the `git-fsck-objects` program, which generates a full dependency graph -of all objects, and verifies their internal consistency (in addition -to just verifying their superficial consistency through the hash). - -The object types in some more detail: - -Blob Object -~~~~~~~~~~~ -A "blob" object is nothing but a binary blob of data, and doesn't -refer to anything else. There is no signature or any other -verification of the data, so while the object is consistent (it 'is' -indexed by its sha1 hash, so the data itself is certainly correct), it -has absolutely no other attributes. No name associations, no -permissions. It is purely a blob of data (i.e. normally "file -contents"). - -In particular, since the blob is entirely defined by its data, if two -files in a directory tree (or in multiple different versions of the -repository) have the same contents, they will share the same blob -object. The object is totally independent of its location in the -directory tree, and renaming a file does not change the object that -file is associated with in any way. - -A blob is typically created when gitlink:git-update-index[1] -is run, and its data can be accessed by gitlink:git-cat-file[1]. - -Tree Object -~~~~~~~~~~~ -The next hierarchical object type is the "tree" object. A tree object -is a list of mode/name/blob data, sorted by name. Alternatively, the -mode data may specify a directory mode, in which case instead of -naming a blob, that name is associated with another TREE object. - -Like the "blob" object, a tree object is uniquely determined by the -set contents, and so two separate but identical trees will always -share the exact same object. This is true at all levels, i.e. it's -true for a "leaf" tree (which does not refer to any other trees, only -blobs) as well as for a whole subdirectory. - -For that reason a "tree" object is just a pure data abstraction: it -has no history, no signatures, no verification of validity, except -that since the contents are again protected by the hash itself, we can -trust that the tree is immutable and its contents never change. - -So you can trust the contents of a tree to be valid, the same way you -can trust the contents of a blob, but you don't know where those -contents 'came' from. - -Side note on trees: since a "tree" object is a sorted list of -"filename+content", you can create a diff between two trees without -actually having to unpack two trees. Just ignore all common parts, -and your diff will look right. In other words, you can effectively -(and efficiently) tell the difference between any two random trees by -O(n) where "n" is the size of the difference, rather than the size of -the tree. - -Side note 2 on trees: since the name of a "blob" depends entirely and -exclusively on its contents (i.e. there are no names or permissions -involved), you can see trivial renames or permission changes by -noticing that the blob stayed the same. However, renames with data -changes need a smarter "diff" implementation. - -A tree is created with gitlink:git-write-tree[1] and -its data can be accessed by gitlink:git-ls-tree[1]. -Two trees can be compared with gitlink:git-diff-tree[1]. - -Commit Object -~~~~~~~~~~~~~ -The "commit" object is an object that introduces the notion of -history into the picture. In contrast to the other objects, it -doesn't just describe the physical state of a tree, it describes how -we got there, and why. - -A "commit" is defined by the tree-object that it results in, the -parent commits (zero, one or more) that led up to that point, and a -comment on what happened. Again, a commit is not trusted per se: -the contents are well-defined and "safe" due to the cryptographically -strong signatures at all levels, but there is no reason to believe -that the tree is "good" or that the merge information makes sense. -The parents do not have to actually have any relationship with the -result, for example. - -Note on commits: unlike real SCM's, commits do not contain -rename information or file mode change information. All of that is -implicit in the trees involved (the result tree, and the result trees -of the parents), and describing that makes no sense in this idiotic -file manager. - -A commit is created with gitlink:git-commit-tree[1] and -its data can be accessed by gitlink:git-cat-file[1]. - -Trust -~~~~~ -An aside on the notion of "trust". Trust is really outside the scope -of "git", but it's worth noting a few things. First off, since -everything is hashed with SHA1, you 'can' trust that an object is -intact and has not been messed with by external sources. So the name -of an object uniquely identifies a known state - just not a state that -you may want to trust. - -Furthermore, since the SHA1 signature of a commit refers to the -SHA1 signatures of the tree it is associated with and the signatures -of the parent, a single named commit specifies uniquely a whole set -of history, with full contents. You can't later fake any step of the -way once you have the name of a commit. - -So to introduce some real trust in the system, the only thing you need -to do is to digitally sign just 'one' special note, which includes the -name of a top-level commit. Your digital signature shows others -that you trust that commit, and the immutability of the history of -commits tells others that they can trust the whole history. - -In other words, you can easily validate a whole archive by just -sending out a single email that tells the people the name (SHA1 hash) -of the top commit, and digitally sign that email using something -like GPG/PGP. - -To assist in this, git also provides the tag object... - -Tag Object -~~~~~~~~~~ -Git provides the "tag" object to simplify creating, managing and -exchanging symbolic and signed tokens. The "tag" object at its -simplest simply symbolically identifies another object by containing -the sha1, type and symbolic name. - -However it can optionally contain additional signature information -(which git doesn't care about as long as there's less than 8k of -it). This can then be verified externally to git. - -Note that despite the tag features, "git" itself only handles content -integrity; the trust framework (and signature provision and -verification) has to come from outside. - -A tag is created with gitlink:git-mktag[1], -its data can be accessed by gitlink:git-cat-file[1], -and the signature can be verified by -gitlink:git-verify-tag[1]. - - -The "index" aka "Current Directory Cache" ------------------------------------------ -The index is a simple binary file, which contains an efficient -representation of a virtual directory content at some random time. It -does so by a simple array that associates a set of names, dates, -permissions and content (aka "blob") objects together. The cache is -always kept ordered by name, and names are unique (with a few very -specific rules) at any point in time, but the cache has no long-term -meaning, and can be partially updated at any time. - -In particular, the index certainly does not need to be consistent with -the current directory contents (in fact, most operations will depend on -different ways to make the index 'not' be consistent with the directory -hierarchy), but it has three very important attributes: - -'(a) it can re-generate the full state it caches (not just the -directory structure: it contains pointers to the "blob" objects so -that it can regenerate the data too)' - -As a special case, there is a clear and unambiguous one-way mapping -from a current directory cache to a "tree object", which can be -efficiently created from just the current directory cache without -actually looking at any other data. So a directory cache at any one -time uniquely specifies one and only one "tree" object (but has -additional data to make it easy to match up that tree object with what -has happened in the directory) - -'(b) it has efficient methods for finding inconsistencies between that -cached state ("tree object waiting to be instantiated") and the -current state.' - -'(c) it can additionally efficiently represent information about merge -conflicts between different tree objects, allowing each pathname to be -associated with sufficient information about the trees involved that -you can create a three-way merge between them.' - -Those are the three ONLY things that the directory cache does. It's a -cache, and the normal operation is to re-generate it completely from a -known tree object, or update/compare it with a live tree that is being -developed. If you blow the directory cache away entirely, you generally -haven't lost any information as long as you have the name of the tree -that it described. - -At the same time, the index is at the same time also the -staging area for creating new trees, and creating a new tree always -involves a controlled modification of the index file. In particular, -the index file can have the representation of an intermediate tree that -has not yet been instantiated. So the index can be thought of as a -write-back cache, which can contain dirty information that has not yet -been written back to the backing store. - - - -The Workflow ------------- -Generally, all "git" operations work on the index file. Some operations -work *purely* on the index file (showing the current state of the -index), but most operations move data to and from the index file. Either -from the database or from the working directory. Thus there are four -main combinations: - -1) working directory -> index -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You update the index with information from the working directory with -the gitlink:git-update-index[1] command. You -generally update the index information by just specifying the filename -you want to update, like so: - - git-update-index filename - -but to avoid common mistakes with filename globbing etc, the command -will not normally add totally new entries or remove old entries, -i.e. it will normally just update existing cache entries. - -To tell git that yes, you really do realize that certain files no -longer exist, or that new files should be added, you -should use the `--remove` and `--add` flags respectively. - -NOTE! A `--remove` flag does 'not' mean that subsequent filenames will -necessarily be removed: if the files still exist in your directory -structure, the index will be updated with their new status, not -removed. The only thing `--remove` means is that update-cache will be -considering a removed file to be a valid thing, and if the file really -does not exist any more, it will update the index accordingly. - -As a special case, you can also do `git-update-index --refresh`, which -will refresh the "stat" information of each index to match the current -stat information. It will 'not' update the object status itself, and -it will only update the fields that are used to quickly test whether -an object still matches its old backing store object. - -2) index -> object database -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You write your current index file to a "tree" object with the program - - git-write-tree - -that doesn't come with any options - it will just write out the -current index into the set of tree objects that describe that state, -and it will return the name of the resulting top-level tree. You can -use that tree to re-generate the index at any time by going in the -other direction: - -3) object database -> index -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You read a "tree" file from the object database, and use that to -populate (and overwrite - don't do this if your index contains any -unsaved state that you might want to restore later!) your current -index. Normal operation is just - - git-read-tree <sha1 of tree> - -and your index file will now be equivalent to the tree that you saved -earlier. However, that is only your 'index' file: your working -directory contents have not been modified. - -4) index -> working directory -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You update your working directory from the index by "checking out" -files. This is not a very common operation, since normally you'd just -keep your files updated, and rather than write to your working -directory, you'd tell the index files about the changes in your -working directory (i.e. `git-update-index`). - -However, if you decide to jump to a new version, or check out somebody -else's version, or just restore a previous tree, you'd populate your -index file with read-tree, and then you need to check out the result -with - - git-checkout-index filename - -or, if you want to check out all of the index, use `-a`. - -NOTE! git-checkout-index normally refuses to overwrite old files, so -if you have an old version of the tree already checked out, you will -need to use the "-f" flag ('before' the "-a" flag or the filename) to -'force' the checkout. - - -Finally, there are a few odds and ends which are not purely moving -from one representation to the other: - -5) Tying it all together -~~~~~~~~~~~~~~~~~~~~~~~~ -To commit a tree you have instantiated with "git-write-tree", you'd -create a "commit" object that refers to that tree and the history -behind it - most notably the "parent" commits that preceded it in -history. - -Normally a "commit" has one parent: the previous state of the tree -before a certain change was made. However, sometimes it can have two -or more parent commits, in which case we call it a "merge", due to the -fact that such a commit brings together ("merges") two or more -previous states represented by other commits. - -In other words, while a "tree" represents a particular directory state -of a working directory, a "commit" represents that state in "time", -and explains how we got there. - -You create a commit object by giving it the tree that describes the -state at the time of the commit, and a list of parents: - - git-commit-tree <tree> -p <parent> [-p <parent2> ..] - -and then giving the reason for the commit on stdin (either through -redirection from a pipe or file, or by just typing it at the tty). - -git-commit-tree will return the name of the object that represents -that commit, and you should save it away for later use. Normally, -you'd commit a new `HEAD` state, and while git doesn't care where you -save the note about that state, in practice we tend to just write the -result to the file pointed at by `.git/HEAD`, so that we can always see -what the last committed state was. - -Here is an ASCII art by Jon Loeliger that illustrates how -various pieces fit together. - ------------- - - commit-tree - commit obj - +----+ - | | - | | - V V - +-----------+ - | Object DB | - | Backing | - | Store | - +-----------+ - ^ - write-tree | | - tree obj | | - | | read-tree - | | tree obj - V - +-----------+ - | Index | - | "cache" | - +-----------+ - update-index ^ - blob obj | | - | | - checkout-index -u | | checkout-index - stat | | blob obj - V - +-----------+ - | Working | - | Directory | - +-----------+ - ------------- - - -6) Examining the data -~~~~~~~~~~~~~~~~~~~~~ - -You can examine the data represented in the object database and the -index with various helper tools. For every object, you can use -gitlink:git-cat-file[1] to examine details about the -object: - - git-cat-file -t <objectname> - -shows the type of the object, and once you have the type (which is -usually implicit in where you find the object), you can use - - git-cat-file blob|tree|commit|tag <objectname> - -to show its contents. NOTE! Trees have binary content, and as a result -there is a special helper for showing that content, called -`git-ls-tree`, which turns the binary content into a more easily -readable form. - -It's especially instructive to look at "commit" objects, since those -tend to be small and fairly self-explanatory. In particular, if you -follow the convention of having the top commit name in `.git/HEAD`, -you can do - - git-cat-file commit HEAD - -to see what the top commit was. - -7) Merging multiple trees -~~~~~~~~~~~~~~~~~~~~~~~~~ - -Git helps you do a three-way merge, which you can expand to n-way by -repeating the merge procedure arbitrary times until you finally -"commit" the state. The normal situation is that you'd only do one -three-way merge (two parents), and commit it, but if you like to, you -can do multiple parents in one go. - -To do a three-way merge, you need the two sets of "commit" objects -that you want to merge, use those to find the closest common parent (a -third "commit" object), and then use those commit objects to find the -state of the directory ("tree" object) at these points. - -To get the "base" for the merge, you first look up the common parent -of two commits with - - git-merge-base <commit1> <commit2> - -which will return you the commit they are both based on. You should -now look up the "tree" objects of those commits, which you can easily -do with (for example) - - git-cat-file commit <commitname> | head -1 - -since the tree object information is always the first line in a commit -object. - -Once you know the three trees you are going to merge (the one -"original" tree, aka the common case, and the two "result" trees, aka -the branches you want to merge), you do a "merge" read into the -index. This will complain if it has to throw away your old index contents, so you should -make sure that you've committed those - in fact you would normally -always do a merge against your last commit (which should thus match -what you have in your current index anyway). - -To do the merge, do - - git-read-tree -m -u <origtree> <yourtree> <targettree> - -which will do all trivial merge operations for you directly in the -index file, and you can just write the result out with -`git-write-tree`. - -Historical note. We did not have `-u` facility when this -section was first written, so we used to warn that -the merge is done in the index file, not in your -working tree, and your working tree will not match your -index after this step. -This is no longer true. The above command, thanks to `-u` -option, updates your working tree with the merge results for -paths that have been trivially merged. - - -8) Merging multiple trees, continued -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Sadly, many merges aren't trivial. If there are files that have -been added.moved or removed, or if both branches have modified the -same file, you will be left with an index tree that contains "merge -entries" in it. Such an index tree can 'NOT' be written out to a tree -object, and you will have to resolve any such merge clashes using -other tools before you can write out the result. - -You can examine such index state with `git-ls-files --unmerged` -command. An example: - ------------------------------------------------- -$ git-read-tree -m $orig HEAD $target -$ git-ls-files --unmerged -100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c -100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c -100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c ------------------------------------------------- - -Each line of the `git-ls-files --unmerged` output begins with -the blob mode bits, blob SHA1, 'stage number', and the -filename. The 'stage number' is git's way to say which tree it -came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD` -tree, and stage3 `$target` tree. - -Earlier we said that trivial merges are done inside -`git-read-tree -m`. For example, if the file did not change -from `$orig` to `HEAD` nor `$target`, or if the file changed -from `$orig` to `HEAD` and `$orig` to `$target` the same way, -obviously the final outcome is what is in `HEAD`. What the -above example shows is that file `hello.c` was changed from -`$orig` to `HEAD` and `$orig` to `$target` in a different way. -You could resolve this by running your favorite 3-way merge -program, e.g. `diff3` or `merge`, on the blob objects from -these three stages yourself, like this: - ------------------------------------------------- -$ git-cat-file blob 263414f... >hello.c~1 -$ git-cat-file blob 06fa6a2... >hello.c~2 -$ git-cat-file blob cc44c73... >hello.c~3 -$ merge hello.c~2 hello.c~1 hello.c~3 ------------------------------------------------- - -This would leave the merge result in `hello.c~2` file, along -with conflict markers if there are conflicts. After verifying -the merge result makes sense, you can tell git what the final -merge result for this file is by: - - mv -f hello.c~2 hello.c - git-update-index hello.c - -When a path is in unmerged state, running `git-update-index` for -that path tells git to mark the path resolved. - -The above is the description of a git merge at the lowest level, -to help you understand what conceptually happens under the hood. -In practice, nobody, not even git itself, uses three `git-cat-file` -for this. There is `git-merge-index` program that extracts the -stages to temporary files and calls a "merge" script on it: - - git-merge-index git-merge-one-file hello.c - -and that is what higher level `git resolve` is implemented with. +Git is a fast, scalable, distributed revision control system with an +unusually rich command set that provides both high-level operations +and full access to internals. + +Git is an Open Source project covered by the GNU General Public License. +It was originally written by Linus Torvalds with help of a group of +hackers around the net. It is currently maintained by Junio C Hamano. + +Please read the file INSTALL for installation instructions. +See Documentation/tutorial.txt to get started, then see +Documentation/everyday.txt for a useful minimum set of commands, +and "man git-commandname" for documentation of each command. +CVS users may also want to read Documentation/cvs-migration.txt. + +Many Git online resources are accessible from http://git.or.cz/ +including full documentation and Git related tools. + +The user discussion and development of Git take place on the Git +mailing list -- everyone is welcome to post bug reports, feature +requests, comments and patches to git@vger.kernel.org. To subscribe +to the list, send an email with just "subscribe git" in the body to +majordomo@vger.kernel.org. The mailing list archives are available at +http://marc.theaimsgroup.com/?l=git and other archival sites. diff --git a/builtin-add.c b/builtin-add.c index e7a1b4d9ab..87e16aa220 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -10,7 +10,7 @@ #include "cache-tree.h" static const char builtin_add_usage[] = -"git-add [-n] [-v] [-f] [--interactive] [--] <filepattern>..."; +"git-add [-n] [-v] [-f] [--interactive | -i] [--] <filepattern>..."; static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { @@ -102,7 +102,8 @@ int cmd_add(int argc, const char **argv, const char *prefix) int add_interactive = 0; for (i = 1; i < argc; i++) { - if (!strcmp("--interactive", argv[i])) + if (!strcmp("--interactive", argv[i]) || + !strcmp("-i", argv[i])) add_interactive++; } if (add_interactive) { diff --git a/builtin-apply.c b/builtin-apply.c index 54fd2cb0c7..3fefdacd94 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -2589,7 +2589,7 @@ static int git_apply_config(const char *var, const char *value) } -int cmd_apply(int argc, const char **argv, const char *prefix) +int cmd_apply(int argc, const char **argv, const char *unused_prefix) { int i; int read_stdin = 1; diff --git a/builtin-archive.c b/builtin-archive.c index 32737d3162..f613ac2516 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -74,6 +74,7 @@ static int run_remote_archiver(const char *remote, int argc, /* Now, start reading from fd[0] and spit it out to stdout */ rv = recv_sideband("archive", fd[0], 1, 2); close(fd[0]); + close(fd[1]); rv |= finish_connect(pid); return !!rv; diff --git a/builtin-blame.c b/builtin-blame.c index 4a1accf13c..3033e9bdad 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -13,6 +13,7 @@ #include "diff.h" #include "diffcore.h" #include "revision.h" +#include "quote.h" #include "xdiff-interface.h" static char blame_usage[] = @@ -27,6 +28,7 @@ static char blame_usage[] = " -p, --porcelain Show in a format designed for machine consumption\n" " -L n,m Process only line range n,m, counting from 1\n" " -M, -C Find line movements within and across files\n" +" --incremental Show blame entries as we find them, incrementally\n" " -S revs-file Use revisions from revs-file instead of calling git-rev-list\n"; static int longest_file; @@ -36,6 +38,7 @@ static int max_digits; static int max_score_digits; static int show_root; static int blank_boundary; +static int incremental; #ifndef DEBUG #define DEBUG 0 @@ -74,6 +77,10 @@ struct origin { char path[FLEX_ARRAY]; }; +/* + * Given an origin, prepare mmfile_t structure to be used by the + * diff machinery + */ static char *fill_origin_blob(struct origin *o, mmfile_t *file) { if (!o->file.ptr) { @@ -88,6 +95,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file) return file->ptr; } +/* + * Origin is refcounted and usually we keep the blob contents to be + * reused. + */ static inline struct origin *origin_incref(struct origin *o) { if (o) @@ -105,6 +116,11 @@ static void origin_decref(struct origin *o) } } +/* + * Each group of lines is described by a blame_entry; it can be split + * as we pass blame to the parents. They form a linked list in the + * scoreboard structure, sorted by the target line number. + */ struct blame_entry { struct blame_entry *prev; struct blame_entry *next; @@ -131,19 +147,24 @@ struct blame_entry { int s_lno; /* how significant this entry is -- cached to avoid - * scanning the lines over and over + * scanning the lines over and over. */ unsigned score; }; +/* + * The current state of the blame assignment. + */ struct scoreboard { /* the final commit (i.e. where we started digging from) */ struct commit *final; const char *path; - /* the contents in the final; pointed into by buf pointers of - * blame_entries + /* + * The contents in the final image. + * Used by many functions to obtain contents of the nth line, + * indexed with scoreboard.lineno[blame_entry.lno]. */ const char *final_buf; unsigned long final_buf_size; @@ -168,6 +189,11 @@ static int cmp_suspect(struct origin *a, struct origin *b) static void sanity_check_refcnt(struct scoreboard *); +/* + * If two blame entries that are next to each other came from + * contiguous lines in the same origin (i.e. <commit, path> pair), + * merge them together. + */ static void coalesce(struct scoreboard *sb) { struct blame_entry *ent, *next; @@ -191,6 +217,12 @@ static void coalesce(struct scoreboard *sb) sanity_check_refcnt(sb); } +/* + * Given a commit and a path in it, create a new origin structure. + * The callers that add blame to the scoreboard should use + * get_origin() to obtain shared, refcounted copy instead of calling + * this function directly. + */ static struct origin *make_origin(struct commit *commit, const char *path) { struct origin *o; @@ -201,6 +233,9 @@ static struct origin *make_origin(struct commit *commit, const char *path) return o; } +/* + * Locate an existing origin or create a new one. + */ static struct origin *get_origin(struct scoreboard *sb, struct commit *commit, const char *path) @@ -215,6 +250,13 @@ static struct origin *get_origin(struct scoreboard *sb, return make_origin(commit, path); } +/* + * Fill the blob_sha1 field of an origin if it hasn't, so that later + * call to fill_origin_blob() can use it to locate the data. blob_sha1 + * for an origin is also used to pass the blame for the entire file to + * the parent to detect the case where a child's blob is identical to + * that of its parent's. + */ static int fill_blob_sha1(struct origin *origin) { unsigned mode; @@ -235,6 +277,10 @@ static int fill_blob_sha1(struct origin *origin) return -1; } +/* + * We have an origin -- check if the same path exists in the + * parent and return an origin structure to represent it. + */ static struct origin *find_origin(struct scoreboard *sb, struct commit *parent, struct origin *origin) @@ -244,12 +290,26 @@ static struct origin *find_origin(struct scoreboard *sb, const char *paths[2]; if (parent->util) { - /* This is a freestanding copy of origin and not - * refcounted. + /* + * Each commit object can cache one origin in that + * commit. This is a freestanding copy of origin and + * not refcounted. */ struct origin *cached = parent->util; if (!strcmp(cached->path, origin->path)) { + /* + * The same path between origin and its parent + * without renaming -- the most common case. + */ porigin = get_origin(sb, parent, cached->path); + + /* + * If the origin was newly created (i.e. get_origin + * would call make_origin if none is found in the + * scoreboard), it does not know the blob_sha1, + * so copy it. Otherwise porigin was in the + * scoreboard and already knows blob_sha1. + */ if (porigin->refcnt == 1) hashcpy(porigin->blob_sha1, cached->blob_sha1); return porigin; @@ -306,7 +366,13 @@ static struct origin *find_origin(struct scoreboard *sb, } diff_flush(&diff_opts); if (porigin) { + /* + * Create a freestanding copy that is not part of + * the refcounted origin found in the scoreboard, and + * cache it in the commit. + */ struct origin *cached; + cached = make_origin(porigin->commit, porigin->path); hashcpy(cached->blob_sha1, porigin->blob_sha1); parent->util = cached; @@ -314,6 +380,10 @@ static struct origin *find_origin(struct scoreboard *sb, return porigin; } +/* + * We have an origin -- find the path that corresponds to it in its + * parent and return an origin structure to represent it. + */ static struct origin *find_rename(struct scoreboard *sb, struct commit *parent, struct origin *origin) @@ -350,6 +420,9 @@ static struct origin *find_rename(struct scoreboard *sb, return porigin; } +/* + * Parsing of patch chunks... + */ struct chunk { /* line number in postimage; up to but not including this * line is the same as preimage @@ -451,6 +524,11 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o, return state.ret; } +/* + * Run diff between two origins and grab the patch output, so that + * we can pass blame for lines origin is currently suspected for + * to its parent. + */ static struct patch *get_patch(struct origin *parent, struct origin *origin) { mmfile_t file_p, file_o; @@ -471,6 +549,10 @@ static void free_patch(struct patch *p) free(p); } +/* + * Link in a new blame entry to the scorebord. Entries that cover the + * same line range have been removed from the scoreboard previously. + */ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e) { struct blame_entry *ent, *prev = NULL; @@ -494,6 +576,12 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e) e->next->prev = e; } +/* + * src typically is on-stack; we want to copy the information in it to + * an malloced blame_entry that is already on the linked list of the + * scoreboard. The origin of dst loses a refcnt while the origin of src + * gains one. + */ static void dup_entry(struct blame_entry *dst, struct blame_entry *src) { struct blame_entry *p, *n; @@ -513,25 +601,25 @@ static const char *nth_line(struct scoreboard *sb, int lno) return sb->final_buf + sb->lineno[lno]; } +/* + * It is known that lines between tlno to same came from parent, and e + * has an overlap with that range. it also is known that parent's + * line plno corresponds to e's line tlno. + * + * <---- e -----> + * <------> + * <------------> + * <------------> + * <------------------> + * + * Split e into potentially three parts; before this chunk, the chunk + * to be blamed for the parent, and after that portion. + */ static void split_overlap(struct blame_entry *split, struct blame_entry *e, int tlno, int plno, int same, struct origin *parent) { - /* it is known that lines between tlno to same came from - * parent, and e has an overlap with that range. it also is - * known that parent's line plno corresponds to e's line tlno. - * - * <---- e -----> - * <------> - * <------------> - * <------------> - * <------------------> - * - * Potentially we need to split e into three parts; before - * this chunk, the chunk to be blamed for parent, and after - * that portion. - */ int chunk_end_lno; memset(split, 0, sizeof(struct blame_entry [3])); @@ -561,11 +649,20 @@ static void split_overlap(struct blame_entry *split, chunk_end_lno = e->lno + e->num_lines; split[1].num_lines = chunk_end_lno - split[1].lno; + /* + * if it turns out there is nothing to blame the parent for, + * forget about the splitting. !split[1].suspect signals this. + */ if (split[1].num_lines < 1) return; split[1].suspect = origin_incref(parent); } +/* + * split_overlap() divided an existing blame e into up to three parts + * in split. Adjust the linked list of blames in the scoreboard to + * reflect the split. + */ static void split_blame(struct scoreboard *sb, struct blame_entry *split, struct blame_entry *e) @@ -573,21 +670,27 @@ static void split_blame(struct scoreboard *sb, struct blame_entry *new_entry; if (split[0].suspect && split[2].suspect) { - /* we need to split e into two and add another for parent */ + /* The first part (reuse storage for the existing entry e) */ dup_entry(e, &split[0]); + /* The last part -- me */ new_entry = xmalloc(sizeof(*new_entry)); memcpy(new_entry, &(split[2]), sizeof(struct blame_entry)); add_blame_entry(sb, new_entry); + /* ... and the middle part -- parent */ new_entry = xmalloc(sizeof(*new_entry)); memcpy(new_entry, &(split[1]), sizeof(struct blame_entry)); add_blame_entry(sb, new_entry); } else if (!split[0].suspect && !split[2].suspect) - /* parent covers the entire area */ + /* + * The parent covers the entire area; reuse storage for + * e and replace it with the parent. + */ dup_entry(e, &split[1]); else if (split[0].suspect) { + /* me and then parent */ dup_entry(e, &split[0]); new_entry = xmalloc(sizeof(*new_entry)); @@ -595,6 +698,7 @@ static void split_blame(struct scoreboard *sb, add_blame_entry(sb, new_entry); } else { + /* parent and then me */ dup_entry(e, &split[1]); new_entry = xmalloc(sizeof(*new_entry)); @@ -625,6 +729,10 @@ static void split_blame(struct scoreboard *sb, } } +/* + * After splitting the blame, the origins used by the + * on-stack blame_entry should lose one refcnt each. + */ static void decref_split(struct blame_entry *split) { int i; @@ -633,6 +741,10 @@ static void decref_split(struct blame_entry *split) origin_decref(split[i].suspect); } +/* + * Helper for blame_chunk(). blame_entry e is known to overlap with + * the patch hunk; split it and pass blame to the parent. + */ static void blame_overlap(struct scoreboard *sb, struct blame_entry *e, int tlno, int plno, int same, struct origin *parent) @@ -645,6 +757,9 @@ static void blame_overlap(struct scoreboard *sb, struct blame_entry *e, decref_split(split); } +/* + * Find the line number of the last line the target is suspected for. + */ static int find_last_in_target(struct scoreboard *sb, struct origin *target) { struct blame_entry *e; @@ -659,6 +774,11 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target) return last_in_target; } +/* + * Process one hunk from the patch between the current suspect for + * blame_entry e and its parent. Find and split the overlap, and + * pass blame to the overlapping part to the parent. + */ static void blame_chunk(struct scoreboard *sb, int tlno, int plno, int same, struct origin *target, struct origin *parent) @@ -675,6 +795,11 @@ static void blame_chunk(struct scoreboard *sb, } } +/* + * We are looking at the origin 'target' and aiming to pass blame + * for the lines it is suspected to its parent. Run diff to find + * which lines came from parent and pass blame for them. + */ static int pass_blame_to_parent(struct scoreboard *sb, struct origin *target, struct origin *parent) @@ -695,13 +820,22 @@ static int pass_blame_to_parent(struct scoreboard *sb, plno = chunk->p_next; tlno = chunk->t_next; } - /* rest (i.e. anything above tlno) are the same as parent */ + /* The rest (i.e. anything after tlno) are the same as the parent */ blame_chunk(sb, tlno, plno, last_in_target, target, parent); free_patch(patch); return 0; } +/* + * The lines in blame_entry after splitting blames many times can become + * very small and trivial, and at some point it becomes pointless to + * blame the parents. E.g. "\t\t}\n\t}\n\n" appears everywhere in any + * ordinary C program, and it is not worth to say it was copied from + * totally unrelated file in the parent. + * + * Compute how trivial the lines in the blame_entry are. + */ static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e) { unsigned score; @@ -723,6 +857,12 @@ static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e) return score; } +/* + * best_so_far[] and this[] are both a split of an existing blame_entry + * that passes blame to the parent. Maintain best_so_far the best split + * so far, by comparing this and best_so_far and copying this into + * bst_so_far as needed. + */ static void copy_split_if_better(struct scoreboard *sb, struct blame_entry *best_so_far, struct blame_entry *this) @@ -742,6 +882,11 @@ static void copy_split_if_better(struct scoreboard *sb, memcpy(best_so_far, this, sizeof(struct blame_entry [3])); } +/* + * Find the lines from parent that are the same as ent so that + * we can pass blames to it. file_p has the blob contents for + * the parent. + */ static void find_copy_in_blob(struct scoreboard *sb, struct blame_entry *ent, struct origin *parent, @@ -754,6 +899,9 @@ static void find_copy_in_blob(struct scoreboard *sb, struct patch *patch; int i, plno, tlno; + /* + * Prepare mmfile that contains only the lines in ent. + */ cp = nth_line(sb, ent->lno); file_o.ptr = (char*) cp; cnt = ent->num_lines; @@ -789,6 +937,10 @@ static void find_copy_in_blob(struct scoreboard *sb, free_patch(patch); } +/* + * See if lines currently target is suspected for can be attributed to + * parent. + */ static int find_move_in_parent(struct scoreboard *sb, struct origin *target, struct origin *parent) @@ -823,12 +975,15 @@ static int find_move_in_parent(struct scoreboard *sb, return 0; } - struct blame_list { struct blame_entry *ent; struct blame_entry split[3]; }; +/* + * Count the number of entries the target is suspected for, + * and prepare a list of entry and the best split. + */ static struct blame_list *setup_blame_list(struct scoreboard *sb, struct origin *target, int *num_ents_p) @@ -837,9 +992,6 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb, int num_ents, i; struct blame_list *blame_list = NULL; - /* Count the number of entries the target is suspected for, - * and prepare a list of entry and the best split. - */ for (e = sb->ent, num_ents = 0; e; e = e->next) if (!e->guilty && !cmp_suspect(e->suspect, target)) num_ents++; @@ -853,6 +1005,11 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb, return blame_list; } +/* + * For lines target is suspected for, see if we can find code movement + * across file boundary from the parent commit. porigin is the path + * in the parent we already tried. + */ static int find_copy_in_parent(struct scoreboard *sb, struct origin *target, struct commit *parent, @@ -953,7 +1110,8 @@ static int find_copy_in_parent(struct scoreboard *sb, return retval; } -/* The blobs of origin and porigin exactly match, so everything +/* + * The blobs of origin and porigin exactly match, so everything * origin is suspected for can be blamed on the parent. */ static void pass_whole_blame(struct scoreboard *sb, @@ -1038,7 +1196,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt) } /* - * Optionally run "miff" to find moves in parents' files here. + * Optionally find moves in parents' files. */ if (opt & PICKAXE_BLAME_MOVE) for (i = 0, parent = commit->parents; @@ -1052,7 +1210,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt) } /* - * Optionally run "ciff" to find copies from parents' files here. + * Optionally find copies from parents' files. */ if (opt & PICKAXE_BLAME_COPY) for (i = 0, parent = commit->parents; @@ -1069,72 +1227,9 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt) origin_decref(parent_origin[i]); } -static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt) -{ - while (1) { - struct blame_entry *ent; - struct commit *commit; - struct origin *suspect = NULL; - - /* find one suspect to break down */ - for (ent = sb->ent; !suspect && ent; ent = ent->next) - if (!ent->guilty) - suspect = ent->suspect; - if (!suspect) - return; /* all done */ - - origin_incref(suspect); - commit = suspect->commit; - if (!commit->object.parsed) - parse_commit(commit); - if (!(commit->object.flags & UNINTERESTING) && - !(revs->max_age != -1 && commit->date < revs->max_age)) - pass_blame(sb, suspect, opt); - else { - commit->object.flags |= UNINTERESTING; - if (commit->object.parsed) - mark_parents_uninteresting(commit); - } - /* treat root commit as boundary */ - if (!commit->parents && !show_root) - commit->object.flags |= UNINTERESTING; - - /* Take responsibility for the remaining entries */ - for (ent = sb->ent; ent; ent = ent->next) - if (!cmp_suspect(ent->suspect, suspect)) - ent->guilty = 1; - origin_decref(suspect); - - if (DEBUG) /* sanity */ - sanity_check_refcnt(sb); - } -} - -static const char *format_time(unsigned long time, const char *tz_str, - int show_raw_time) -{ - static char time_buf[128]; - time_t t = time; - int minutes, tz; - struct tm *tm; - - if (show_raw_time) { - sprintf(time_buf, "%lu %s", time, tz_str); - return time_buf; - } - - tz = atoi(tz_str); - minutes = tz < 0 ? -tz : tz; - minutes = (minutes / 100)*60 + (minutes % 100); - minutes = tz < 0 ? -minutes : minutes; - t = time + minutes * 60; - tm = gmtime(&t); - - strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm); - strcat(time_buf, tz_str); - return time_buf; -} - +/* + * Information on commits, used for output. + */ struct commit_info { char *author; @@ -1151,6 +1246,9 @@ struct commit_info char *summary; }; +/* + * Parse author/committer line in the commit object buffer + */ static void get_ac_line(const char *inbuf, const char *what, int bufsz, char *person, char **mail, unsigned long *time, char **tz) @@ -1205,7 +1303,8 @@ static void get_commit_info(struct commit *commit, static char committer_buf[1024]; static char summary_buf[1024]; - /* We've operated without save_commit_buffer, so + /* + * We've operated without save_commit_buffer, so * we now need to populate them for output. */ if (!commit->buffer) { @@ -1245,6 +1344,127 @@ static void get_commit_info(struct commit *commit, summary_buf[len] = 0; } +/* + * To allow LF and other nonportable characters in pathnames, + * they are c-style quoted as needed. + */ +static void write_filename_info(const char *path) +{ + printf("filename "); + write_name_quoted(NULL, 0, path, 1, stdout); + putchar('\n'); +} + +/* + * The blame_entry is found to be guilty for the range. Mark it + * as such, and show it in incremental output. + */ +static void found_guilty_entry(struct blame_entry *ent) +{ + if (ent->guilty) + return; + ent->guilty = 1; + if (incremental) { + struct origin *suspect = ent->suspect; + + printf("%s %d %d %d\n", + sha1_to_hex(suspect->commit->object.sha1), + ent->s_lno + 1, ent->lno + 1, ent->num_lines); + if (!(suspect->commit->object.flags & METAINFO_SHOWN)) { + struct commit_info ci; + suspect->commit->object.flags |= METAINFO_SHOWN; + get_commit_info(suspect->commit, &ci, 1); + printf("author %s\n", ci.author); + printf("author-mail %s\n", ci.author_mail); + printf("author-time %lu\n", ci.author_time); + printf("author-tz %s\n", ci.author_tz); + printf("committer %s\n", ci.committer); + printf("committer-mail %s\n", ci.committer_mail); + printf("committer-time %lu\n", ci.committer_time); + printf("committer-tz %s\n", ci.committer_tz); + printf("summary %s\n", ci.summary); + if (suspect->commit->object.flags & UNINTERESTING) + printf("boundary\n"); + } + write_filename_info(suspect->path); + } +} + +/* + * The main loop -- while the scoreboard has lines whose true origin + * is still unknown, pick one brame_entry, and allow its current + * suspect to pass blames to its parents. + */ +static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt) +{ + while (1) { + struct blame_entry *ent; + struct commit *commit; + struct origin *suspect = NULL; + + /* find one suspect to break down */ + for (ent = sb->ent; !suspect && ent; ent = ent->next) + if (!ent->guilty) + suspect = ent->suspect; + if (!suspect) + return; /* all done */ + + /* + * We will use this suspect later in the loop, + * so hold onto it in the meantime. + */ + origin_incref(suspect); + commit = suspect->commit; + if (!commit->object.parsed) + parse_commit(commit); + if (!(commit->object.flags & UNINTERESTING) && + !(revs->max_age != -1 && commit->date < revs->max_age)) + pass_blame(sb, suspect, opt); + else { + commit->object.flags |= UNINTERESTING; + if (commit->object.parsed) + mark_parents_uninteresting(commit); + } + /* treat root commit as boundary */ + if (!commit->parents && !show_root) + commit->object.flags |= UNINTERESTING; + + /* Take responsibility for the remaining entries */ + for (ent = sb->ent; ent; ent = ent->next) + if (!cmp_suspect(ent->suspect, suspect)) + found_guilty_entry(ent); + origin_decref(suspect); + + if (DEBUG) /* sanity */ + sanity_check_refcnt(sb); + } +} + +static const char *format_time(unsigned long time, const char *tz_str, + int show_raw_time) +{ + static char time_buf[128]; + time_t t = time; + int minutes, tz; + struct tm *tm; + + if (show_raw_time) { + sprintf(time_buf, "%lu %s", time, tz_str); + return time_buf; + } + + tz = atoi(tz_str); + minutes = tz < 0 ? -tz : tz; + minutes = (minutes / 100)*60 + (minutes % 100); + minutes = tz < 0 ? -minutes : minutes; + t = time + minutes * 60; + tm = gmtime(&t); + + strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm); + strcat(time_buf, tz_str); + return time_buf; +} + #define OUTPUT_ANNOTATE_COMPAT 001 #define OUTPUT_LONG_OBJECT_NAME 002 #define OUTPUT_RAW_TIMESTAMP 004 @@ -1279,13 +1499,13 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent) printf("committer-mail %s\n", ci.committer_mail); printf("committer-time %lu\n", ci.committer_time); printf("committer-tz %s\n", ci.committer_tz); - printf("filename %s\n", suspect->path); + write_filename_info(suspect->path); printf("summary %s\n", ci.summary); if (suspect->commit->object.flags & UNINTERESTING) printf("boundary\n"); } else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH) - printf("filename %s\n", suspect->path); + write_filename_info(suspect->path); cp = nth_line(sb, ent->lno); for (cnt = 0; cnt < ent->num_lines; cnt++) { @@ -1390,6 +1610,10 @@ static void output(struct scoreboard *sb, int option) } } +/* + * To allow quick access to the contents of nth line in the + * final image, prepare an index in the scoreboard. + */ static int prepare_lines(struct scoreboard *sb) { const char *buf = sb->final_buf; @@ -1417,6 +1641,11 @@ static int prepare_lines(struct scoreboard *sb) return sb->num_lines; } +/* + * Add phony grafts for use with -S; this is primarily to + * support git-cvsserver that wants to give a linear history + * to its clients. + */ static int read_ancestry(const char *graft_file) { FILE *fp = fopen(graft_file, "r"); @@ -1434,6 +1663,9 @@ static int read_ancestry(const char *graft_file) return 0; } +/* + * How many columns do we need to show line numbers in decimal? + */ static int lineno_width(int lines) { int i, width; @@ -1443,6 +1675,10 @@ static int lineno_width(int lines) return width; } +/* + * How many columns do we need to show line numbers, authors, + * and filenames? + */ static void find_alignment(struct scoreboard *sb, int *option) { int longest_src_lines = 0; @@ -1481,6 +1717,10 @@ static void find_alignment(struct scoreboard *sb, int *option) max_score_digits = lineno_width(largest_score); } +/* + * For debugging -- origin is refcounted, and this asserts that + * we do not underflow. + */ static void sanity_check_refcnt(struct scoreboard *sb) { int baa = 0; @@ -1502,8 +1742,9 @@ static void sanity_check_refcnt(struct scoreboard *sb) ent->suspect->refcnt = -ent->suspect->refcnt; } for (ent = sb->ent; ent; ent = ent->next) { - /* then pick each and see if they have the the correct - * refcnt. + /* + * ... then pick each and see if they have the the + * correct refcnt. */ int found; struct blame_entry *e; @@ -1533,6 +1774,10 @@ static void sanity_check_refcnt(struct scoreboard *sb) } } +/* + * Used for the command line parsing; check if the path exists + * in the working tree. + */ static int has_path_in_work_tree(const char *path) { struct stat st; @@ -1555,6 +1800,9 @@ static const char *add_prefix(const char *prefix, const char *path) return prefix_path(prefix, strlen(prefix), path); } +/* + * Parsing of (comma separated) one item in the -L option + */ static const char *parse_loc(const char *spec, struct scoreboard *sb, long lno, long begin, long *ret) @@ -1629,6 +1877,9 @@ static const char *parse_loc(const char *spec, } } +/* + * Parsing of -L option + */ static void prepare_blame_range(struct scoreboard *sb, const char *bottomtop, long lno, @@ -1717,6 +1968,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) die("More than one '-L n,m' option given"); bottomtop = arg; } + else if (!strcmp("--incremental", arg)) + incremental = 1; else if (!strcmp("--score-debug", arg)) output_option |= OUTPUT_SHOW_SCORE; else if (!strcmp("-f", arg) || @@ -1737,12 +1990,16 @@ int cmd_blame(int argc, const char **argv, const char *prefix) argv[unk++] = arg; } + if (!incremental) + setup_pager(); + if (!blame_move_score) blame_move_score = BLAME_DEFAULT_MOVE_SCORE; if (!blame_copy_score) blame_copy_score = BLAME_DEFAULT_COPY_SCORE; - /* We have collected options unknown to us in argv[1..unk] + /* + * We have collected options unknown to us in argv[1..unk] * which are to be passed to revision machinery if we are * going to do the "bottom" procesing. * @@ -1822,7 +2079,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) if (final_commit_name) argv[unk++] = final_commit_name; - /* Now we got rev and path. We do not want the path pruning + /* + * Now we got rev and path. We do not want the path pruning * but we may want "bottom" processing. */ argv[unk++] = "--"; /* terminate the rev name */ @@ -1832,7 +2090,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) setup_revisions(unk, argv, &revs, "HEAD"); memset(&sb, 0, sizeof(sb)); - /* There must be one and only one positive commit in the + /* + * There must be one and only one positive commit in the * revs->pending array. */ for (i = 0; i < revs.pending.nr; i++) { @@ -1853,7 +2112,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix) } if (!sb.final) { - /* "--not A B -- path" without anything positive */ + /* + * "--not A B -- path" without anything positive; + * default to HEAD. + */ unsigned char head_sha1[20]; final_commit_name = "HEAD"; @@ -1863,7 +2125,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) add_pending_object(&revs, &(sb.final->object), "HEAD"); } - /* If we have bottom, this will mark the ancestors of the + /* + * If we have bottom, this will mark the ancestors of the * bottom commits we would reach while traversing as * uninteresting. */ @@ -1907,6 +2170,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix) assign_blame(&sb, &revs, opt); + if (incremental) + return 0; + coalesce(&sb); if (!(output_option & OUTPUT_PORCELAIN)) diff --git a/builtin-branch.c b/builtin-branch.c index c760e188ea..d60690bb08 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -324,7 +324,7 @@ static void create_branch(const char *name, const char *start_name, if (resolve_ref(ref, sha1, 1, NULL)) { if (!force) die("A branch named '%s' already exists.", name); - else if (!strcmp(head, name)) + else if (!is_bare_repository() && !strcmp(head, name)) die("Cannot force update the current branch."); } @@ -394,7 +394,6 @@ int cmd_branch(int argc, const char **argv, const char *prefix) int kinds = REF_LOCAL_BRANCH; int i; - setup_ident(); git_config(git_branch_config); for (i = 1; i < argc; i++) { diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index 0651e5927e..2a818a0a2c 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -94,7 +94,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) unsigned int size; int encoding_is_utf8; - setup_ident(); git_config(git_default_config); if (argc < 2) diff --git a/builtin-repo-config.c b/builtin-config.c index 90633119d4..0f9051da17 100644 --- a/builtin-repo-config.c +++ b/builtin-config.c @@ -2,7 +2,7 @@ #include "cache.h" static const char git_config_set_usage[] = -"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list"; +"git-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list"; static char *key; static regex_t *key_regexp; @@ -126,7 +126,7 @@ free_strings: return ret; } -int cmd_repo_config(int argc, const char **argv, const char *prefix) +int cmd_config(int argc, const char **argv, const char *prefix) { int nongit = 0; setup_git_directory_gently(&nongit); diff --git a/builtin-describe.c b/builtin-describe.c index a8c98cea16..bcc645622a 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -2,57 +2,41 @@ #include "commit.h" #include "tag.h" #include "refs.h" -#include "diff.h" -#include "diffcore.h" -#include "revision.h" #include "builtin.h" +#define SEEN (1u<<0) +#define MAX_TAGS (FLAG_BITS - 1) + static const char describe_usage[] = "git-describe [--all] [--tags] [--abbrev=<n>] <committish>*"; +static int debug; /* Display lots of verbose info */ static int all; /* Default to annotated tags only */ static int tags; /* But allow any tags if --tags is specified */ - static int abbrev = DEFAULT_ABBREV; +static int max_candidates = 10; -static int names, allocs; -static struct commit_name { - struct commit *commit; +struct commit_name { int prio; /* annotated tag = 2, tag = 1, head = 0 */ char path[FLEX_ARRAY]; /* more */ -} **name_array = NULL; - -static struct commit_name *match(struct commit *cmit) -{ - int i = names; - struct commit_name **p = name_array; - - while (i-- > 0) { - struct commit_name *n = *p++; - if (n->commit == cmit) - return n; - } - return NULL; -} +}; +static const char *prio_names[] = { + "head", "lightweight", "annotated", +}; static void add_to_known_names(const char *path, struct commit *commit, int prio) { - int idx; - int len = strlen(path)+1; - struct commit_name *name = xmalloc(sizeof(struct commit_name) + len); - - name->commit = commit; - name->prio = prio; - memcpy(name->path, path, len); - idx = names; - if (idx >= allocs) { - allocs = (idx + 50) * 3 / 2; - name_array = xrealloc(name_array, allocs*sizeof(*name_array)); + struct commit_name *e = commit->util; + if (!e || e->prio < prio) { + size_t len = strlen(path)+1; + free(e); + e = xmalloc(sizeof(struct commit_name) + len); + e->prio = prio; + memcpy(e->path, path, len); + commit->util = e; } - name_array[idx] = name; - names = ++idx; } static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data) @@ -87,32 +71,69 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void return 0; } -static int compare_names(const void *_a, const void *_b) -{ - struct commit_name *a = *(struct commit_name **)_a; - struct commit_name *b = *(struct commit_name **)_b; - unsigned long a_date = a->commit->date; - unsigned long b_date = b->commit->date; - - if (a->prio != b->prio) - return b->prio - a->prio; - return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; -} - struct possible_tag { - struct possible_tag *next; struct commit_name *name; - unsigned long depth; + int depth; + int found_order; + unsigned flag_within; }; +static int compare_pt(const void *a_, const void *b_) +{ + struct possible_tag *a = (struct possible_tag *)a_; + struct possible_tag *b = (struct possible_tag *)b_; + if (a->name->prio != b->name->prio) + return b->name->prio - a->name->prio; + if (a->depth != b->depth) + return a->depth - b->depth; + if (a->found_order != b->found_order) + return a->found_order - b->found_order; + return 0; +} + +static unsigned long finish_depth_computation( + struct commit_list **list, + struct possible_tag *best) +{ + unsigned long seen_commits = 0; + while (*list) { + struct commit *c = pop_commit(list); + struct commit_list *parents = c->parents; + seen_commits++; + if (c->object.flags & best->flag_within) { + struct commit_list *a = *list; + while (a) { + struct commit *i = a->item; + if (!(i->object.flags & best->flag_within)) + break; + a = a->next; + } + if (!a) + break; + } else + best->depth++; + while (parents) { + struct commit *p = parents->item; + parse_commit(p); + if (!(p->object.flags & SEEN)) + insert_by_date(p, list); + p->object.flags |= c->object.flags; + parents = parents->next; + } + } + return seen_commits; +} + static void describe(const char *arg, int last_one) { unsigned char sha1[20]; - struct commit *cmit; + struct commit *cmit, *gave_up_on = NULL; struct commit_list *list; static int initialized = 0; struct commit_name *n; - struct possible_tag *all_matches, *min_match, *cur_match; + struct possible_tag all_matches[MAX_TAGS]; + unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; + unsigned long seen_commits = 0; if (get_sha1(arg, sha1)) die("Not a valid object name %s", arg); @@ -123,78 +144,99 @@ static void describe(const char *arg, int last_one) if (!initialized) { initialized = 1; for_each_ref(get_name, NULL); - qsort(name_array, names, sizeof(*name_array), compare_names); } - n = match(cmit); + n = cmit->util; if (n) { printf("%s\n", n->path); return; } + if (debug) + fprintf(stderr, "searching to describe %s\n", arg); + list = NULL; - all_matches = NULL; - cur_match = NULL; + cmit->object.flags = SEEN; commit_list_insert(cmit, &list); while (list) { struct commit *c = pop_commit(&list); - n = match(c); + struct commit_list *parents = c->parents; + seen_commits++; + n = c->util; if (n) { - struct possible_tag *p = xmalloc(sizeof(*p)); - p->name = n; - p->next = NULL; - if (cur_match) - cur_match->next = p; - else - all_matches = p; - cur_match = p; - } else { - struct commit_list *parents = c->parents; - while (parents) { - struct commit *p = parents->item; - parse_commit(p); - if (!(p->object.flags & SEEN)) { - p->object.flags |= SEEN; - insert_by_date(p, &list); - } - parents = parents->next; + if (match_cnt < max_candidates) { + struct possible_tag *t = &all_matches[match_cnt++]; + t->name = n; + t->depth = seen_commits - 1; + t->flag_within = 1u << match_cnt; + t->found_order = match_cnt; + c->object.flags |= t->flag_within; + if (n->prio == 2) + annotated_cnt++; + } + else { + gave_up_on = c; + break; } } + for (cur_match = 0; cur_match < match_cnt; cur_match++) { + struct possible_tag *t = &all_matches[cur_match]; + if (!(c->object.flags & t->flag_within)) + t->depth++; + } + if (annotated_cnt && !list) { + if (debug) + fprintf(stderr, "finished search at %s\n", + sha1_to_hex(c->object.sha1)); + break; + } + while (parents) { + struct commit *p = parents->item; + parse_commit(p); + if (!(p->object.flags & SEEN)) + insert_by_date(p, &list); + p->object.flags |= c->object.flags; + parents = parents->next; + } } - if (!all_matches) + if (!match_cnt) die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1)); - min_match = NULL; - for (cur_match = all_matches; cur_match; cur_match = cur_match->next) { - struct rev_info revs; - struct commit *tagged = cur_match->name->commit; + qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt); - clear_commit_marks(cmit, -1); - init_revisions(&revs, NULL); - tagged->object.flags |= UNINTERESTING; - add_pending_object(&revs, &tagged->object, NULL); - add_pending_object(&revs, &cmit->object, NULL); - - prepare_revision_walk(&revs); - cur_match->depth = 0; - while ((!min_match || cur_match->depth < min_match->depth) - && get_revision(&revs)) - cur_match->depth++; - if (!min_match || cur_match->depth < min_match->depth) - min_match = cur_match; - free_commit_list(revs.commits); + if (gave_up_on) { + insert_by_date(gave_up_on, &list); + seen_commits--; } - printf("%s-g%s\n", min_match->name->path, - find_unique_abbrev(cmit->object.sha1, abbrev)); + seen_commits += finish_depth_computation(&list, &all_matches[0]); + free_commit_list(list); - if (!last_one) { - for (cur_match = all_matches; cur_match; cur_match = min_match) { - min_match = cur_match->next; - free(cur_match); + if (debug) { + for (cur_match = 0; cur_match < match_cnt; cur_match++) { + struct possible_tag *t = &all_matches[cur_match]; + fprintf(stderr, " %-11s %8d %s\n", + prio_names[t->name->prio], + t->depth, t->name->path); + } + fprintf(stderr, "traversed %lu commits\n", seen_commits); + if (gave_up_on) { + fprintf(stderr, + "more than %i tags found; listed %i most recent\n" + "gave up search at %s\n", + max_candidates, max_candidates, + sha1_to_hex(gave_up_on->object.sha1)); } - clear_commit_marks(cmit, SEEN); } + if (abbrev == 0) + printf("%s\n", all_matches[0].name->path ); + else + printf("%s-%d-g%s\n", all_matches[0].name->path, + all_matches[0].depth, + find_unique_abbrev(cmit->object.sha1, abbrev)); + + if (!last_one) + clear_commit_marks(cmit, -1); } int cmd_describe(int argc, const char **argv, const char *prefix) @@ -206,15 +248,24 @@ int cmd_describe(int argc, const char **argv, const char *prefix) if (*arg != '-') break; + else if (!strcmp(arg, "--debug")) + debug = 1; else if (!strcmp(arg, "--all")) all = 1; else if (!strcmp(arg, "--tags")) tags = 1; else if (!strncmp(arg, "--abbrev=", 9)) { abbrev = strtoul(arg + 9, NULL, 10); - if (abbrev < MINIMUM_ABBREV || 40 < abbrev) + if (abbrev != 0 && (abbrev < MINIMUM_ABBREV || 40 < abbrev)) abbrev = DEFAULT_ABBREV; } + else if (!strncmp(arg, "--candidates=", 13)) { + max_candidates = strtoul(arg + 13, NULL, 10); + if (max_candidates < 1) + max_candidates = 1; + else if (max_candidates > MAX_TAGS) + max_candidates = MAX_TAGS; + } else usage(describe_usage); } diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index af72a12a57..9d5f266dc4 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -12,6 +12,7 @@ #define QUOTE_SHELL 1 #define QUOTE_PERL 2 #define QUOTE_PYTHON 3 +#define QUOTE_TCL 4 typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type; @@ -723,6 +724,9 @@ static void print_value(struct refinfo *ref, int atom, int quote_style) case QUOTE_PYTHON: python_quote_print(stdout, v->s); break; + case QUOTE_TCL: + tcl_quote_print(stdout, v->s); + break; } } @@ -834,6 +838,12 @@ int cmd_for_each_ref(int ac, const char **av, char *prefix) quote_style = QUOTE_PYTHON; continue; } + if (!strcmp(arg, "--tcl") ) { + if (0 <= quote_style) + die("more than one quoting style?"); + quote_style = QUOTE_TCL; + continue; + } if (!strncmp(arg, "--count=", 8)) { if (maxcount) die("more than one --count?"); diff --git a/fsck-objects.c b/builtin-fsck.c index 81f00db90b..fec1cbd784 100644 --- a/fsck-objects.c +++ b/builtin-fsck.c @@ -54,6 +54,99 @@ static int objwarning(struct object *obj, const char *err, ...) return -1; } +/* + * Check a single reachable object + */ +static void check_reachable_object(struct object *obj) +{ + const struct object_refs *refs; + + /* + * We obviously want the object to be parsed, + * except if it was in a pack-file and we didn't + * do a full fsck + */ + if (!obj->parsed) { + if (has_sha1_file(obj->sha1)) + return; /* it is in pack - forget about it */ + printf("missing %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1)); + return; + } + + /* + * Check that everything that we try to reference is also good. + */ + refs = lookup_object_refs(obj); + if (refs) { + unsigned j; + for (j = 0; j < refs->count; j++) { + struct object *ref = refs->ref[j]; + if (ref->parsed || + (has_sha1_file(ref->sha1))) + continue; + printf("broken link from %7s %s\n", + typename(obj->type), sha1_to_hex(obj->sha1)); + printf(" to %7s %s\n", + typename(ref->type), sha1_to_hex(ref->sha1)); + } + } +} + +/* + * Check a single unreachable object + */ +static void check_unreachable_object(struct object *obj) +{ + /* + * Missing unreachable object? Ignore it. It's not like + * we miss it (since it can't be reached), nor do we want + * to complain about it being unreachable (since it does + * not exist). + */ + if (!obj->parsed) + return; + + /* + * Unreachable object that exists? Show it if asked to, + * since this is something that is prunable. + */ + if (show_unreachable) { + printf("unreachable %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1)); + return; + } + + /* + * "!used" means that nothing at all points to it, including + * other unreacahble objects. In other words, it's the "tip" + * of some set of unreachable objects, usually a commit that + * got dropped. + * + * Such starting points are more interesting than some random + * set of unreachable objects, so we show them even if the user + * hasn't asked for _all_ unreachable objects. If you have + * deleted a branch by mistake, this is a prime candidate to + * start looking at, for example. + */ + if (!obj->used) { + printf("dangling %s %s\n", typename(obj->type), + sha1_to_hex(obj->sha1)); + return; + } + + /* + * Otherwise? It's there, it's unreachable, and some other unreachable + * object points to it. Ignore it - it's not interesting, and we showed + * all the interesting cases above. + */ +} + +static void check_object(struct object *obj) +{ + if (obj->flags & REACHABLE) + check_reachable_object(obj); + else + check_unreachable_object(obj); +} static void check_connectivity(void) { @@ -62,46 +155,10 @@ static void check_connectivity(void) /* Look up all the requirements, warn about missing objects.. */ max = get_max_object_index(); for (i = 0; i < max; i++) { - const struct object_refs *refs; struct object *obj = get_indexed_object(i); - if (!obj) - continue; - - if (!obj->parsed) { - if (has_sha1_file(obj->sha1)) - ; /* it is in pack */ - else - printf("missing %s %s\n", - typename(obj->type), sha1_to_hex(obj->sha1)); - continue; - } - - refs = lookup_object_refs(obj); - if (refs) { - unsigned j; - for (j = 0; j < refs->count; j++) { - struct object *ref = refs->ref[j]; - if (ref->parsed || - (has_sha1_file(ref->sha1))) - continue; - printf("broken link from %7s %s\n", - typename(obj->type), sha1_to_hex(obj->sha1)); - printf(" to %7s %s\n", - typename(ref->type), sha1_to_hex(ref->sha1)); - } - } - - if (show_unreachable && !(obj->flags & REACHABLE)) { - printf("unreachable %s %s\n", - typename(obj->type), sha1_to_hex(obj->sha1)); - continue; - } - - if (!obj->used) { - printf("dangling %s %s\n", typename(obj->type), - sha1_to_hex(obj->sha1)); - } + if (obj) + check_object(obj); } } @@ -514,12 +571,11 @@ static int fsck_cache_tree(struct cache_tree *it) return err; } -int main(int argc, char **argv) +int cmd_fsck(int argc, char **argv, const char *prefix) { int i, heads; track_object_refs = 1; - setup_git_directory(); for (i = 1; i < argc; i++) { const char *arg = argv[i]; @@ -549,7 +605,7 @@ int main(int argc, char **argv) continue; } if (*arg == '-') - usage("git-fsck-objects [--tags] [--root] [[--unreachable] [--cache] [--full] [--strict] <head-sha1>*]"); + usage("git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] [--strict] <head-sha1>*]"); } fsck_head_link(); diff --git a/builtin-init-db.c b/builtin-init-db.c index 8e7540b692..1865489381 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -257,7 +257,9 @@ static int create_default_files(const char *git_dir, const char *template_path) } else { git_config_set("core.bare", "false"); - git_config_set("core.logallrefupdates", "true"); + /* allow template config file to override the default */ + if (log_all_ref_updates == -1) + git_config_set("core.logallrefupdates", "true"); } return reinit; } diff --git a/builtin-log.c b/builtin-log.c index a59b4acef1..982d871887 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -50,8 +50,11 @@ static int cmd_log_walk(struct rev_info *rev) prepare_revision_walk(rev); while ((commit = get_revision(rev)) != NULL) { log_tree_commit(rev, commit); - free(commit->buffer); - commit->buffer = NULL; + if (!rev->reflog_info) { + /* we allow cycles in reflog ancestry */ + free(commit->buffer); + commit->buffer = NULL; + } free_commit_list(commit->parents); commit->parents = NULL; } @@ -197,17 +200,28 @@ static int istitlechar(char c) static char *extra_headers = NULL; static int extra_headers_size = 0; +static const char *fmt_patch_suffix = ".patch"; static int git_format_config(const char *var, const char *value) { if (!strcmp(var, "format.headers")) { - int len = strlen(value); + int len; + + if (!value) + die("format.headers without value"); + len = strlen(value); extra_headers_size += len + 1; extra_headers = xrealloc(extra_headers, extra_headers_size); extra_headers[extra_headers_size - len - 1] = 0; strcat(extra_headers, value); return 0; } + if (!strcmp(var, "format.suffix")) { + if (!value) + die("format.suffix without value"); + fmt_patch_suffix = xstrdup(value); + return 0; + } if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) { return 0; } @@ -223,9 +237,10 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject) char filename[1024]; char *sol; int len = 0; + int suffix_len = strlen(fmt_patch_suffix) + 10; /* ., NUL and slop */ if (output_directory) { - strlcpy(filename, output_directory, 1010); + strlcpy(filename, output_directory, 1000); len = strlen(filename); if (filename[len - 1] != '/') filename[len++] = '/'; @@ -249,7 +264,10 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject) } } - for (j = 0; len < 1024 - 6 && sol[j] && sol[j] != '\n'; j++) { + for (j = 0; + len < sizeof(filename) - suffix_len && + sol[j] && sol[j] != '\n'; + j++) { if (istitlechar(sol[j])) { if (space) { filename[len++] = '-'; @@ -265,7 +283,7 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject) while (filename[len - 1] == '.' || filename[len - 1] == '-') len--; } - strcpy(filename + len, ".txt"); + strcpy(filename + len, fmt_patch_suffix); fprintf(realstdout, "%s\n", filename); freopen(filename, "w", stdout); } @@ -334,7 +352,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options, co static void gen_message_id(char *dest, unsigned int length, char *base) { - const char *committer = git_committer_info(1); + const char *committer = git_committer_info(-1); const char *email_start = strrchr(committer, '<'); const char *email_end = strrchr(committer, '>'); if(!email_start || !email_end || email_start > email_end - 1) @@ -362,7 +380,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) char message_id[1024]; char ref_message_id[1024]; - setup_ident(); git_config(git_format_config); init_revisions(&rev, prefix); rev.commit_format = CMIT_FMT_EMAIL; @@ -436,6 +453,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) die("Need a Message-Id for --in-reply-to"); in_reply_to = argv[i]; } + else if (!strncmp(argv[i], "--suffix=", 9)) + fmt_patch_suffix = argv[i] + 9; else argv[j++] = argv[i]; } @@ -451,9 +470,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) die ("unrecognized argument: %s", argv[1]); if (!rev.diffopt.output_format) - rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH; + rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH; + + if (!rev.diffopt.text) + rev.diffopt.binary = 1; - if (!output_directory) + if (!output_directory && !use_stdout) output_directory = prefix; if (output_directory) { @@ -465,8 +487,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) } if (rev.pending.nr == 1) { - rev.pending.objects[0].item->flags |= UNINTERESTING; - add_head(&rev); + if (rev.max_count < 0) { + rev.pending.objects[0].item->flags |= UNINTERESTING; + add_head(&rev); + } + /* Otherwise, it is "format-patch -22 HEAD", and + * get_revision() would return only the specified count. + */ } if (ignore_if_in_upstream) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 42dd8c87a2..3824ee33ac 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -569,7 +569,7 @@ static void write_index_file(void) sha1_to_hex(object_list_sha1), "idx"); struct object_entry **list = sorted_by_sha; struct object_entry **last = list + nr_result; - unsigned int array[256]; + uint32_t array[256]; /* * Write the first-level table (the list is sorted, @@ -587,7 +587,7 @@ static void write_index_file(void) array[i] = htonl(next - sorted_by_sha); list = next; } - sha1write(f, array, 256 * sizeof(int)); + sha1write(f, array, 256 * 4); /* * Write the actual SHA1 entries.. @@ -595,7 +595,7 @@ static void write_index_file(void) list = sorted_by_sha; for (i = 0; i < nr_result; i++) { struct object_entry *entry = *list++; - unsigned int offset = htonl(entry->offset); + uint32_t offset = htonl(entry->offset); sha1write(f, &offset, 4); sha1write(f, entry->sha1, 20); } diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c index 6de7128b9d..3de9b3eefd 100644 --- a/builtin-pack-refs.c +++ b/builtin-pack-refs.c @@ -37,7 +37,9 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, if ((flags & REF_ISSYMREF)) return 0; is_tag_ref = !strncmp(path, "refs/tags/", 10); - if (!cb->all && !is_tag_ref) + + /* ALWAYS pack refs that were already packed or are tags */ + if (!cb->all && !is_tag_ref && !(flags & REF_ISPACKED)) return 0; fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path); diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c index a57b76d7b7..977730064b 100644 --- a/builtin-prune-packed.c +++ b/builtin-prune-packed.c @@ -2,7 +2,7 @@ #include "cache.h" static const char prune_packed_usage[] = -"git-prune-packed [-n]"; +"git-prune-packed [-n] [-q]"; #define DRY_RUN 01 #define VERBOSE 02 diff --git a/builtin-push.c b/builtin-push.c index 7a3d2bb064..5f4d7d34d3 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -8,10 +8,10 @@ #define MAX_URI (16) -static const char push_usage[] = "git-push [--all] [--tags] [-f | --force] <repository> [<refspec>...]"; +static const char push_usage[] = "git-push [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]"; static int all, tags, force, thin = 1, verbose; -static const char *execute; +static const char *receivepack; #define BUF_SIZE (2084) static char buffer[BUF_SIZE]; @@ -143,6 +143,7 @@ static const char *config_repo; static int config_repo_len; static int config_current_uri; static int config_get_refspecs; +static int config_get_receivepack; static int get_remote_config(const char* key, const char* value) { @@ -157,6 +158,15 @@ static int get_remote_config(const char* key, const char* value) else if (config_get_refspecs && !strcmp(key + 7 + config_repo_len, ".push")) add_refspec(xstrdup(value)); + else if (config_get_receivepack && + !strcmp(key + 7 + config_repo_len, ".receivepack")) { + if (!receivepack) { + char *rp = xmalloc(strlen(value) + 16); + sprintf(rp, "--receive-pack=%s", value); + receivepack = rp; + } else + error("more than one receivepack given, using the first"); + } } return 0; } @@ -168,6 +178,7 @@ static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI]) config_current_uri = 0; config_uri = uri; config_get_refspecs = !(refspec_nr || all || tags); + config_get_receivepack = (receivepack == NULL); git_config(get_remote_config); return config_current_uri; @@ -252,8 +263,8 @@ static int do_push(const char *repo) argv[argc++] = "--all"; if (force) argv[argc++] = "--force"; - if (execute) - argv[argc++] = execute; + if (receivepack) + argv[argc++] = receivepack; common_argc = argc; for (i = 0; i < n; i++) { @@ -336,8 +347,12 @@ int cmd_push(int argc, const char **argv, const char *prefix) thin = 0; continue; } + if (!strncmp(arg, "--receive-pack=", 15)) { + receivepack = arg; + continue; + } if (!strncmp(arg, "--exec=", 7)) { - execute = arg; + receivepack = arg; continue; } usage(push_usage); diff --git a/builtin-reflog.c b/builtin-reflog.c index 7206b7a013..b443ed9ef6 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -13,7 +13,7 @@ */ static const char reflog_expire_usage[] = -"git-reflog expire [--verbose] [--dry-run] [--fix-stale] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; +"git-reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; static unsigned long default_reflog_expire; static unsigned long default_reflog_expire_unreachable; @@ -263,9 +263,6 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, } cb.ref_commit = lookup_commit_reference_gently(sha1, 1); - if (!cb.ref_commit) - fprintf(stderr, - "warning: ref '%s' does not point at a commit\n", ref); cb.ref = ref; cb.cmd = cmd; for_each_reflog_ent(ref, expire_reflog_ent, &cb); diff --git a/builtin-rm.c b/builtin-rm.c index d81f289c3c..00dbe39960 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -10,7 +10,7 @@ #include "tree-walk.h" static const char builtin_rm_usage[] = -"git-rm [-n] [-f] [--cached] <filepattern>..."; +"git-rm [-f] [-n] [-r] [--cached] [--] <file>..."; static struct { int nr, alloc; diff --git a/builtin-show-branch.c b/builtin-show-branch.c index c67f2fa2fe..fa62e487b1 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -4,7 +4,9 @@ #include "builtin.h" static const char show_branch_usage[] = -"git-show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n] <branch>"; +"git-show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n[,b]] <branch>"; +static const char show_branch_usage_reflog[] = +"--reflog is incompatible with --all, --remotes, --independent or --merge-base"; static int default_num; static int default_alloc; @@ -346,18 +348,21 @@ static void sort_ref_range(int bottom, int top) compare_ref_name); } -static int append_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int append_ref(const char *refname, const unsigned char *sha1, + int allow_dups) { struct commit *commit = lookup_commit_reference_gently(sha1, 1); int i; if (!commit) return 0; - /* Avoid adding the same thing twice */ - for (i = 0; i < ref_name_cnt; i++) - if (!strcmp(refname, ref_name[i])) - return 0; + if (!allow_dups) { + /* Avoid adding the same thing twice */ + for (i = 0; i < ref_name_cnt; i++) + if (!strcmp(refname, ref_name[i])) + return 0; + } if (MAX_REVS <= ref_name_cnt) { fprintf(stderr, "warning: ignoring %s; " "cannot handle more than %d refs\n", @@ -380,7 +385,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f */ if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1)) ofs = 5; - return append_ref(refname + ofs, sha1, flag, cb_data); + return append_ref(refname + ofs, sha1, 0); } static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) @@ -394,14 +399,14 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int */ if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1)) ofs = 5; - return append_ref(refname + ofs, sha1, flag, cb_data); + return append_ref(refname + ofs, sha1, 0); } static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { if (strncmp(refname, "refs/tags/", 10)) return 0; - return append_ref(refname + 5, sha1, flag, cb_data); + return append_ref(refname + 5, sha1, 0); } static const char *match_ref_pattern = NULL; @@ -434,7 +439,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i return append_head_ref(refname, sha1, flag, cb_data); if (!strncmp("refs/tags/", refname, 10)) return append_tag_ref(refname, sha1, flag, cb_data); - return append_ref(refname, sha1, flag, cb_data); + return append_ref(refname, sha1, 0); } static void snarf_refs(int head, int remotes) @@ -507,7 +512,7 @@ static void append_one_rev(const char *av) { unsigned char revkey[20]; if (!get_sha1(av, revkey)) { - append_ref(av, revkey, 0, NULL); + append_ref(av, revkey, 0); return; } if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) { @@ -562,9 +567,24 @@ static int omit_in_dense(struct commit *commit, struct commit **rev, int n) return 0; } +static void parse_reflog_param(const char *arg, int *cnt, const char **base) +{ + char *ep; + *cnt = strtoul(arg, &ep, 10); + if (*ep == ',') + *base = ep + 1; + else if (*ep) + die("unrecognized reflog param '%s'", arg + 9); + else + *base = NULL; + if (*cnt <= 0) + *cnt = DEFAULT_REFLOG; +} + int cmd_show_branch(int ac, const char **av, const char *prefix) { struct commit *rev[MAX_REVS], *commit; + char *reflog_msg[MAX_REVS]; struct commit_list *list = NULL, *seen = NULL; unsigned int rev_mask[MAX_REVS]; int num_rev, i, extra = 0; @@ -585,6 +605,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) int topics = 0; int dense = 1; int reflog = 0; + const char *reflog_base = NULL; git_config(git_show_branch_config); @@ -628,42 +649,101 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) dense = 0; else if (!strcmp(arg, "--date-order")) lifo = 0; - else if (!strcmp(arg, "--reflog")) { + else if (!strcmp(arg, "--reflog") || !strcmp(arg, "-g")) { reflog = DEFAULT_REFLOG; } - else if (!strncmp(arg, "--reflog=", 9)) { - char *end; - reflog = strtoul(arg + 9, &end, 10); - if (*end != '\0') - die("unrecognized reflog count '%s'", arg + 9); - } + else if (!strncmp(arg, "--reflog=", 9)) + parse_reflog_param(arg + 9, &reflog, &reflog_base); + else if (!strncmp(arg, "-g=", 3)) + parse_reflog_param(arg + 3, &reflog, &reflog_base); else usage(show_branch_usage); ac--; av++; } ac--; av++; - /* Only one of these is allowed */ - if (1 < independent + merge_base + (extra != 0) + (!!reflog)) - usage(show_branch_usage); + if (extra || reflog) { + /* "listing" mode is incompatible with + * independent nor merge-base modes. + */ + if (independent || merge_base) + usage(show_branch_usage); + if (reflog && ((0 < extra) || all_heads || all_remotes)) + /* + * Asking for --more in reflog mode does not + * make sense. --list is Ok. + * + * Also --all and --remotes do not make sense either. + */ + usage(show_branch_usage_reflog); + } /* If nothing is specified, show all branches by default */ if (ac + all_heads + all_remotes == 0) all_heads = 1; - if (all_heads + all_remotes) - snarf_refs(all_heads, all_remotes); if (reflog) { - int reflen; - if (!ac) + unsigned char sha1[20]; + char nth_desc[256]; + char *ref; + int base = 0; + + if (ac == 0) { + static const char *fake_av[2]; + fake_av[0] = "HEAD"; + fake_av[1] = NULL; + av = fake_av; + ac = 1; + } + if (ac != 1) die("--reflog option needs one branch name"); - reflen = strlen(*av); + + if (MAX_REVS < reflog) + die("Only %d entries can be shown at one time.", + MAX_REVS); + if (!dwim_ref(*av, strlen(*av), sha1, &ref)) + die("No such ref %s", *av); + + /* Has the base been specified? */ + if (reflog_base) { + char *ep; + base = strtoul(reflog_base, &ep, 10); + if (*ep) { + /* Ah, that is a date spec... */ + unsigned long at; + at = approxidate(reflog_base); + read_ref_at(ref, at, -1, sha1, NULL, + NULL, NULL, &base); + } + } + for (i = 0; i < reflog; i++) { - char *name = xmalloc(reflen + 20); - sprintf(name, "%s@{%d}", *av, i); - append_one_rev(name); + char *logmsg, *msg, *m; + unsigned long timestamp; + int tz; + + if (read_ref_at(ref, 0, base+i, sha1, &logmsg, + ×tamp, &tz, NULL)) { + reflog = i; + break; + } + msg = strchr(logmsg, '\t'); + if (!msg) + msg = "(none)"; + else + msg++; + m = xmalloc(strlen(msg) + 200); + sprintf(m, "(%s) %s", + show_date(timestamp, tz, 1), + msg); + reflog_msg[i] = m; + free(logmsg); + sprintf(nth_desc, "%s@{%d}", *av, base+i); + append_ref(nth_desc, sha1, 1); } } + else if (all_heads + all_remotes) + snarf_refs(all_heads, all_remotes); else { while (0 < ac) { append_one_rev(*av); @@ -760,8 +840,14 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) printf("%c [%s] ", is_head ? '*' : '!', ref_name[i]); } - /* header lines never need name */ - show_one_commit(rev[i], 1); + + if (!reflog) { + /* header lines never need name */ + show_one_commit(rev[i], 1); + } + else + puts(reflog_msg[i]); + if (is_head) head_at = i; } diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c index d8be0527f4..227c9d4a62 100644 --- a/builtin-symbolic-ref.c +++ b/builtin-symbolic-ref.c @@ -3,9 +3,9 @@ #include "refs.h" static const char git_symbolic_ref_usage[] = -"git-symbolic-ref name [ref]"; +"git-symbolic-ref [-q] name [ref]"; -static void check_symref(const char *HEAD) +static void check_symref(const char *HEAD, int quiet) { unsigned char sha1[20]; int flag; @@ -13,17 +13,41 @@ static void check_symref(const char *HEAD) if (!refs_heads_master) die("No such ref: %s", HEAD); - else if (!(flag & REF_ISSYMREF)) - die("ref %s is not a symbolic ref", HEAD); + else if (!(flag & REF_ISSYMREF)) { + if (!quiet) + die("ref %s is not a symbolic ref", HEAD); + else + exit(1); + } puts(refs_heads_master); } int cmd_symbolic_ref(int argc, const char **argv, const char *prefix) { + int quiet = 0; + git_config(git_default_config); + + while (1 < argc) { + const char *arg = argv[1]; + if (arg[0] != '-') + break; + else if (!strcmp("-q", arg)) + quiet = 1; + else if (!strcmp("--", arg)) { + argc--; + argv++; + break; + } + else + die("unknown option %s", arg); + argc--; + argv++; + } + switch (argc) { case 2: - check_symref(argv[1]); + check_symref(argv[1], quiet); break; case 3: create_symref(argv[1], argv[2]); diff --git a/builtin-update-ref.c b/builtin-update-ref.c index b34e5987dd..5ee960bf41 100644 --- a/builtin-update-ref.c +++ b/builtin-update-ref.c @@ -13,7 +13,6 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) int i, delete; delete = 0; - setup_ident(); git_config(git_default_config); for (i = 1; i < argc; i++) { @@ -62,10 +61,8 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL); if (!lock) - return 1; + die("%s: cannot lock the ref", refname); if (write_ref_sha1(lock, sha1, msg) < 0) - return 1; - - /* write_ref_sha1 always unlocks the ref, no need to do it explicitly */ + die("%s: cannot update the ref", refname); return 0; } @@ -34,6 +34,7 @@ extern int cmd_diff_tree(int argc, const char **argv, const char *prefix); extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix); extern int cmd_for_each_ref(int argc, const char **argv, const char *prefix); extern int cmd_format_patch(int argc, const char **argv, const char *prefix); +extern int cmd_fsck(int argc, const char **argv, const char *prefix); extern int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix); extern int cmd_grep(int argc, const char **argv, const char *prefix); extern int cmd_help(int argc, const char **argv, const char *prefix); @@ -53,7 +54,7 @@ extern int cmd_prune_packed(int argc, const char **argv, const char *prefix); extern int cmd_push(int argc, const char **argv, const char *prefix); extern int cmd_read_tree(int argc, const char **argv, const char *prefix); extern int cmd_reflog(int argc, const char **argv, const char *prefix); -extern int cmd_repo_config(int argc, const char **argv, const char *prefix); +extern int cmd_config(int argc, const char **argv, const char *prefix); extern int cmd_rerere(int argc, const char **argv, const char *prefix); extern int cmd_rev_list(int argc, const char **argv, const char *prefix); extern int cmd_rev_parse(int argc, const char **argv, const char *prefix); @@ -129,6 +129,7 @@ extern int cache_errno; extern int is_bare_repository_cfg; extern int is_bare_repository(void); +extern int is_inside_git_dir(void); extern const char *get_git_dir(void); extern char *get_object_directory(void); extern char *get_refs_directory(void); @@ -299,6 +300,8 @@ extern int get_sha1_hex(const char *hex, unsigned char *sha1); extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */ extern int read_ref(const char *filename, unsigned char *sha1); extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *); +extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref); + extern int create_symref(const char *ref, const char *refs_heads_master); extern int validate_headref(const char *ref); @@ -316,8 +319,6 @@ int parse_date(const char *date, char *buf, int bufsize); void datestamp(char *buf, int bufsize); unsigned long approxidate(const char *); -extern int setup_ident(void); -extern void ignore_missing_committer_name(); extern const char *git_author_info(int); extern const char *git_committer_info(int); @@ -351,7 +352,7 @@ struct pack_window { extern struct packed_git { struct packed_git *next; struct pack_window *windows; - unsigned int *index_base; + uint32_t *index_base; off_t index_size; off_t pack_size; int pack_fd; @@ -400,7 +401,7 @@ extern void install_packed_git(struct packed_git *pack); extern struct packed_git *find_sha1_pack(const unsigned char *sha1, struct packed_git *packs); -extern void pack_report(); +extern void pack_report(void); extern unsigned char* use_pack(struct packed_git *, struct pack_window **, unsigned long, unsigned int *); extern void unuse_pack(struct pack_window **); extern struct packed_git *add_packed_git(char *, int, int); @@ -434,7 +435,6 @@ extern char *git_log_output_encoding; extern int copy_fd(int ifd, int ofd); extern int read_in_full(int fd, void *buf, size_t count); -extern void read_or_die(int fd, void *buf, size_t count); extern int write_in_full(int fd, const void *buf, size_t count); extern void write_or_die(int fd, const void *buf, size_t count); extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg); @@ -464,20 +464,29 @@ static int get_one_line(const char *msg, unsigned long len) return ret; } +/* High bit set, or ISO-2022-INT */ +static int non_ascii(int ch) +{ + ch = (ch & 0xff); + return ((ch & 0x80) || (ch == 0x1b)); +} + static int is_rfc2047_special(char ch) { - return ((ch & 0x80) || (ch == '=') || (ch == '?') || (ch == '_')); + return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_')); } -static int add_rfc2047(char *buf, const char *line, int len) +static int add_rfc2047(char *buf, const char *line, int len, + const char *encoding) { char *bp = buf; int i, needquote; - static const char q_utf8[] = "=?utf-8?q?"; + char q_encoding[128]; + const char *q_encoding_fmt = "=?%s?q?"; for (i = needquote = 0; !needquote && i < len; i++) { - unsigned ch = line[i]; - if (ch & 0x80) + int ch = line[i]; + if (non_ascii(ch)) needquote++; if ((i + 1 < len) && (ch == '=' && line[i+1] == '?')) @@ -486,8 +495,11 @@ static int add_rfc2047(char *buf, const char *line, int len) if (!needquote) return sprintf(buf, "%.*s", len, line); - memcpy(bp, q_utf8, sizeof(q_utf8)-1); - bp += sizeof(q_utf8)-1; + i = snprintf(q_encoding, sizeof(q_encoding), q_encoding_fmt, encoding); + if (sizeof(q_encoding) < i) + die("Insanely long encoding name %s", encoding); + memcpy(bp, q_encoding, i); + bp += i; for (i = 0; i < len; i++) { unsigned ch = line[i] & 0xFF; if (is_rfc2047_special(ch)) { @@ -505,7 +517,8 @@ static int add_rfc2047(char *buf, const char *line, int len) } static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, - const char *line, int relative_date) + const char *line, int relative_date, + const char *encoding) { char *date; int namelen; @@ -533,7 +546,8 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf, filler = ""; strcpy(buf, "From: "); ret = strlen(buf); - ret += add_rfc2047(buf + ret, line, display_name_length); + ret += add_rfc2047(buf + ret, line, display_name_length, + encoding); memcpy(buf + ret, name_tail, namelen - display_name_length); ret += namelen - display_name_length; buf[ret++] = '\n'; @@ -668,21 +682,18 @@ static char *replace_encoding_header(char *buf, char *encoding) return buf; } -static char *logmsg_reencode(const struct commit *commit) +static char *logmsg_reencode(const struct commit *commit, + char *output_encoding) { char *encoding; char *out; - char *output_encoding = (git_log_output_encoding - ? git_log_output_encoding - : git_commit_encoding); + char *utf8 = "utf-8"; - if (!output_encoding) - output_encoding = "utf-8"; - else if (!*output_encoding) + if (!*output_encoding) return NULL; encoding = get_header(commit, "encoding"); if (!encoding) - return NULL; + encoding = utf8; if (!strcmp(encoding, output_encoding)) out = strdup(commit->buffer); else @@ -691,7 +702,8 @@ static char *logmsg_reencode(const struct commit *commit) if (out) out = replace_encoding_header(out, output_encoding); - free(encoding); + if (encoding != utf8) + free(encoding); if (!out) return NULL; return out; @@ -711,8 +723,15 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, int parents_shown = 0; const char *msg = commit->buffer; int plain_non_ascii = 0; - char *reencoded = logmsg_reencode(commit); + char *reencoded; + char *encoding; + encoding = (git_log_output_encoding + ? git_log_output_encoding + : git_commit_encoding); + if (!encoding) + encoding = "utf-8"; + reencoded = logmsg_reencode(commit, encoding); if (reencoded) msg = reencoded; @@ -738,7 +757,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, i + 1 < len && msg[i+1] == '\n') in_body = 1; } - else if (ch & 0x80) { + else if (non_ascii(ch)) { plain_non_ascii = 1; break; } @@ -797,13 +816,15 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, offset += add_user_info("Author", fmt, buf + offset, line + 7, - relative_date); + relative_date, + encoding); if (!memcmp(line, "committer ", 10) && (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) offset += add_user_info("Commit", fmt, buf + offset, line + 10, - relative_date); + relative_date, + encoding); continue; } @@ -826,7 +847,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, int slen = strlen(subject); memcpy(buf + offset, subject, slen); offset += slen; - offset += add_rfc2047(buf + offset, line, linelen); + offset += add_rfc2047(buf + offset, line, linelen, + encoding); } else { memset(buf + offset, ' ', indent); @@ -837,11 +859,17 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, if (fmt == CMIT_FMT_ONELINE) break; if (subject && plain_non_ascii) { - static const char header[] = - "Content-Type: text/plain; charset=UTF-8\n" + int sz; + char header[512]; + const char *header_fmt = + "Content-Type: text/plain; charset=%s\n" "Content-Transfer-Encoding: 8bit\n"; - memcpy(buf + offset, header, sizeof(header)-1); - offset += sizeof(header)-1; + sz = snprintf(header, sizeof(header), header_fmt, + encoding); + if (sizeof(header) < sz) + die("Encoding name %s too long", encoding); + memcpy(buf + offset, header, sz); + offset += sz; } if (after_subject) { int slen = strlen(after_subject); @@ -110,7 +110,7 @@ extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *r extern int register_shallow(const unsigned char *sha1); extern int unregister_shallow(const unsigned char *sha1); extern int write_shallow_commits(int fd, int use_pack_protocol); -extern int is_repository_shallow(); +extern int is_repository_shallow(void); extern struct commit_list *get_shallow_commits(struct object_array *heads, int depth, int shallow_flag, int not_shallow_flag); @@ -661,6 +661,11 @@ int git_config_set_multivar(const char* key, const char* value, goto out_free; } c = tolower(c); + } else if (c == '\n') { + fprintf(stderr, "invalid key (newline): %s\n", key); + free(store.key); + ret = 1; + goto out_free; } store.key[i] = c; } @@ -529,7 +529,7 @@ static void git_tcp_connect(int fd[2], char *host) int sockfd = git_tcp_connect_sock(host); fd[0] = sockfd; - fd[1] = sockfd; + fd[1] = dup(sockfd); } diff --git a/contrib/blameview/README b/contrib/blameview/README new file mode 100644 index 0000000000..50a6f67fd6 --- /dev/null +++ b/contrib/blameview/README @@ -0,0 +1,10 @@ +This is a sample program to use 'git-blame --incremental', based +on this message. + +From: Jeff King <peff@peff.net> +Subject: Re: More precise tag following +To: Linus Torvalds <torvalds@linux-foundation.org> +Cc: git@vger.kernel.org +Date: Sat, 27 Jan 2007 18:52:38 -0500 +Message-ID: <20070127235238.GA28706@coredump.intra.peff.net> + diff --git a/contrib/blameview/blameview.perl b/contrib/blameview/blameview.perl new file mode 100755 index 0000000000..5e9a67c123 --- /dev/null +++ b/contrib/blameview/blameview.perl @@ -0,0 +1,119 @@ +#!/usr/bin/perl + +use Gtk2 -init; +use Gtk2::SimpleList; + +my $fn = shift or die "require filename to blame"; + +Gtk2::Rc->parse_string(<<'EOS'); +style "treeview_style" +{ + GtkTreeView::vertical-separator = 0 +} +class "GtkTreeView" style "treeview_style" +EOS + +my $window = Gtk2::Window->new('toplevel'); +$window->signal_connect(destroy => sub { Gtk2->main_quit }); +my $scrolled_window = Gtk2::ScrolledWindow->new; +$window->add($scrolled_window); +my $fileview = Gtk2::SimpleList->new( + 'Commit' => 'text', + 'CommitInfo' => 'text', + 'FileLine' => 'text', + 'Data' => 'text' +); +$scrolled_window->add($fileview); +$fileview->get_column(0)->set_spacing(0); +$fileview->set_size_request(1024, 768); +$fileview->set_rules_hint(1); + +my $fh; +open($fh, '-|', "git cat-file blob HEAD:$fn") + or die "unable to open $fn: $!"; +while(<$fh>) { + chomp; + $fileview->{data}->[$.] = ['HEAD', '?', "$fn:$.", $_]; +} + +my $blame; +open($blame, '-|', qw(git blame --incremental --), $fn) + or die "cannot start git-blame $fn"; + +Glib::IO->add_watch(fileno($blame), 'in', \&read_blame_line); + +$window->show_all; +Gtk2->main; +exit 0; + +my %commitinfo = (); + +sub flush_blame_line { + my ($attr) = @_; + + return unless defined $attr; + + my ($commit, $s_lno, $lno, $cnt) = + @{$attr}{qw(COMMIT S_LNO LNO CNT)}; + + my ($filename, $author, $author_time, $author_tz) = + @{$commitinfo{$commit}}{qw(FILENAME AUTHOR AUTHOR-TIME AUTHOR-TZ)}; + my $info = $author . ' ' . format_time($author_time, $author_tz); + + for(my $i = 0; $i < $cnt; $i++) { + @{$fileview->{data}->[$lno+$i-1]}[0,1,2] = + (substr($commit, 0, 8), $info, + $filename . ':' . ($s_lno+$i)); + } +} + +my $buf; +my $current; +sub read_blame_line { + + my $r = sysread($blame, $buf, 1024, length($buf)); + die "I/O error" unless defined $r; + + if ($r == 0) { + flush_blame_line($current); + $current = undef; + return 0; + } + + while ($buf =~ s/([^\n]*)\n//) { + my $line = $1; + + if (($commit, $s_lno, $lno, $cnt) = + ($line =~ /^([0-9a-f]{40}) (\d+) (\d+) (\d+)$/)) { + flush_blame_line($current); + $current = +{ + COMMIT => $1, + S_LNO => $2, + LNO => $3, + CNT => $4, + }; + next; + } + + # extended attribute values + if ($line =~ /^(author|author-mail|author-time|author-tz|committer|committer-mail|committer-time|committer-tz|summary|filename) (.*)$/) { + my $commit = $current->{COMMIT}; + $commitinfo{$commit}{uc($1)} = $2; + next; + } + } + return 1; +} + +sub format_time { + my $time = shift; + my $tz = shift; + + my $minutes = $tz < 0 ? 0-$tz : $tz; + $minutes = ($minutes / 100)*60 + ($minutes % 100); + $minutes = $tz < 0 ? 0-$minutes : $minutes; + $time += $minutes * 60; + my @t = gmtime($time); + return sprintf('%04d-%02d-%02d %02d:%02d:%02d %s', + $t[5] + 1900, @t[4,3,2,1,0], $tz); +} diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 7c7520ea29..83c69ecf48 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -145,7 +145,7 @@ __git_remotes () echo ${i#$d/remotes/} done [ "$ngoff" ] && shopt -u nullglob - for i in $(git --git-dir="$d" repo-config --list); do + for i in $(git --git-dir="$d" config --list); do case "$i" in remote.*.url=*) i="${i#remote.}" @@ -286,7 +286,7 @@ __git_commandlist="$(__git_commands 2>/dev/null)" __git_aliases () { local i IFS=$'\n' - for i in $(git --git-dir="$(__gitdir)" repo-config --list); do + for i in $(git --git-dir="$(__gitdir)" config --list); do case "$i" in alias.*) i="${i#alias.}" @@ -299,7 +299,7 @@ __git_aliases () __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" \ - repo-config --get "alias.$1") + config --get "alias.$1") for word in $cmdline; do if [ "${word##-*}" ]; then echo $word @@ -629,7 +629,7 @@ _git_rebase () COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur")) } -_git_repo_config () +_git_config () { local cur="${COMP_WORDS[COMP_CWORD]}" local prv="${COMP_WORDS[COMP_CWORD-1]}" @@ -806,6 +806,7 @@ _git () checkout) _git_checkout ;; cherry-pick) _git_cherry_pick ;; commit) _git_commit ;; + config) _git_config ;; diff) _git_diff ;; diff-tree) _git_diff_tree ;; fetch) _git_fetch ;; @@ -819,7 +820,7 @@ _git () pull) _git_pull ;; push) _git_push ;; rebase) _git_rebase ;; - repo-config) _git_repo_config ;; + repo-config) _git_config ;; reset) _git_reset ;; show) _git_show ;; show-branch) _git_log ;; @@ -856,7 +857,7 @@ complete -o default -F _git_name_rev git-name-rev complete -o default -o nospace -F _git_pull git-pull complete -o default -o nospace -F _git_push git-push complete -o default -F _git_rebase git-rebase -complete -o default -F _git_repo_config git-repo-config +complete -o default -F _git_config git-config complete -o default -F _git_reset git-reset complete -o default -o nospace -F _git_show git-show complete -o default -o nospace -F _git_log git-show-branch @@ -879,7 +880,7 @@ complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe complete -o default -F _git_merge_base git-merge-base.exe complete -o default -F _git_name_rev git-name-rev.exe complete -o default -o nospace -F _git_push git-push.exe -complete -o default -F _git_repo_config git-repo-config +complete -o default -F _git_config git-config complete -o default -o nospace -F _git_show git-show.exe complete -o default -o nospace -F _git_log git-show-branch.exe complete -o default -o nospace -F _git_log git-whatchanged.exe diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index d90ba816e0..24629eb3e2 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -222,7 +222,7 @@ and returns the process output as a string." "Return the name to use as GIT_COMMITTER_NAME." ; copied from log-edit (or git-committer-name - (git-repo-config "user.name") + (git-config "user.name") (and (boundp 'add-log-full-name) add-log-full-name) (and (fboundp 'user-full-name) (user-full-name)) (and (boundp 'user-full-name) user-full-name))) @@ -231,7 +231,7 @@ and returns the process output as a string." "Return the email address to use as GIT_COMMITTER_EMAIL." ; copied from log-edit (or git-committer-email - (git-repo-config "user.email") + (git-config "user.email") (and (boundp 'add-log-mailing-address) add-log-mailing-address) (and (fboundp 'user-mail-address) (user-mail-address)) (and (boundp 'user-mail-address) user-mail-address))) @@ -298,9 +298,9 @@ and returns the process output as a string." (git-get-string-sha1 (git-call-process-env-string nil "rev-parse" rev))) -(defun git-repo-config (key) +(defun git-config (key) "Retrieve the value associated to KEY in the git repository config file." - (let ((str (git-call-process-env-string nil "repo-config" key))) + (let ((str (git-call-process-env-string nil "config" key))) (and str (car (split-string str "\n"))))) (defun git-symbolic-ref (ref) diff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el index 3eb4bd19e9..e456ab9712 100644 --- a/contrib/emacs/vc-git.el +++ b/contrib/emacs/vc-git.el @@ -120,7 +120,16 @@ (vc-git--run-command file "commit" "-m" comment "--only" "--"))) (defun vc-git-checkout (file &optional editable rev destfile) - (vc-git--run-command file "checkout" (or rev "HEAD"))) + (if destfile + (let ((fullname (substring + (vc-git--run-command-string file "ls-files" "-z" "--full-name" "--") + 0 -1)) + (coding-system-for-read 'no-conversion) + (coding-system-for-write 'no-conversion)) + (with-temp-file destfile + (eq 0 (call-process "git" nil t nil "cat-file" "blob" + (concat (or rev "HEAD") ":" fullname))))) + (vc-git--run-command file "checkout" (or rev "HEAD")))) (defun vc-git-annotate-command (file buf &optional rev) ; FIXME: rev is ignored diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview index 3b6bdceeeb..521b2fcd32 100755 --- a/contrib/gitview/gitview +++ b/contrib/gitview/gitview @@ -497,7 +497,7 @@ class GitView: fp.close() def get_encoding(self): - fp = os.popen("git repo-config --get i18n.commitencoding") + fp = os.popen("git config --get i18n.commitencoding") self.encoding=string.strip(fp.readline()) fp.close() if (self.encoding == ""): diff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh index 25901e2b3b..dc09eae972 100644 --- a/contrib/remotes2config.sh +++ b/contrib/remotes2config.sh @@ -11,7 +11,7 @@ if [ -d "$GIT_DIR"/remotes ]; then { cd "$GIT_DIR"/remotes ls | while read f; do - name=$(echo -n "$f" | tr -c "A-Za-z0-9" ".") + name=$(printf "$f" | tr -c "A-Za-z0-9" ".") sed -n \ -e "s/^URL: \(.*\)$/remote.$name.url \1 ./p" \ -e "s/^Pull: \(.*\)$/remote.$name.fetch \1 ^$ /p" \ @@ -26,8 +26,8 @@ if [ -d "$GIT_DIR"/remotes ]; then mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old fi ;; *) - echo "git-repo-config $key "$value" $regex" - git-repo-config $key "$value" $regex || error=1 ;; + echo "git-config $key "$value" $regex" + git-config $key "$value" $regex || error=1 ;; esac done fi diff --git a/contrib/vim/syntax/gitcommit.vim b/contrib/vim/syntax/gitcommit.vim index d911efbb4b..332121b40e 100644 --- a/contrib/vim/syntax/gitcommit.vim +++ b/contrib/vim/syntax/gitcommit.vim @@ -1,7 +1,7 @@ syn region gitLine start=/^#/ end=/$/ -syn region gitCommit start=/^# Added but not yet committed:$/ end=/^#$/ contains=gitHead,gitCommitFile +syn region gitCommit start=/^# Changes to be committed:$/ end=/^#$/ contains=gitHead,gitCommitFile syn region gitHead contained start=/^# (.*)/ end=/^#$/ -syn region gitChanged start=/^# Changed but not added:/ end=/^#$/ contains=gitHead,gitChangedFile +syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile syn match gitCommitFile contained /^#\t.*/hs=s+2 @@ -372,9 +372,16 @@ static int upload_archive(void) return -1; } +static int receive_pack(void) +{ + execl_git_cmd("receive-pack", ".", NULL); + return -1; +} + static struct daemon_service daemon_service[] = { { "upload-archive", "uploadarch", upload_archive, 0, 1 }, { "upload-pack", "uploadpack", upload_pack, 1, 1 }, + { "receive-pack", "receivepack", receive_pack, 0, 1 }, }; static void enable_service(const char *name, int ena) { @@ -62,12 +62,11 @@ const char *show_date(unsigned long time, int tz, int relative) if (relative) { unsigned long diff; - time_t t = gm_time_t(time, tz); struct timeval now; gettimeofday(&now, NULL); - if (now.tv_sec < t) + if (now.tv_sec < time) return "in the future"; - diff = now.tv_sec - t; + diff = now.tv_sec - time; if (diff < 90) { snprintf(timebuf, sizeof(timebuf), "%lu seconds ago", diff); return timebuf; diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index de44adabf0..286919e714 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -14,6 +14,8 @@ static unsigned int contains(struct diff_filespec *one, const char *data; if (diff_populate_filespec(one, 0)) return 0; + if (!len) + return 0; sz = one->size; data = one->data; diff --git a/fast-import.c b/fast-import.c index 487a91a4ee..f62a5a9f6c 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1927,7 +1927,6 @@ int main(int argc, const char **argv) int i; uintmax_t total_count, duplicate_count; - setup_ident(); git_config(git_default_config); for (i = 1; i < argc; i++) { diff --git a/fetch-pack.c b/fetch-pack.c index 1530a94794..c787106764 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -4,16 +4,20 @@ #include "commit.h" #include "tag.h" #include "exec_cmd.h" +#include "pack.h" #include "sideband.h" static int keep_pack; +static int transfer_unpack_limit = -1; +static int fetch_unpack_limit = -1; +static int unpack_limit = 100; static int quiet; static int verbose; static int fetch_all; static int depth; static const char fetch_pack_usage[] = -"git-fetch-pack [--all] [-q] [-v] [-k] [--thin] [--exec=upload-pack] [--depth=<n>] [host:]directory <refs>..."; -static const char *exec = "git-upload-pack"; +"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]"; +static const char *uploadpack = "git-upload-pack"; #define COMPLETE (1U << 0) #define COMMON (1U << 1) @@ -486,13 +490,58 @@ static pid_t setup_sideband(int fd[2], int xd[2]) return side_pid; } -static int get_pack(int xd[2], const char **argv) +static int get_pack(int xd[2]) { int status; pid_t pid, side_pid; int fd[2]; + const char *argv[20]; + char keep_arg[256]; + char hdr_arg[256]; + const char **av; + int do_keep = keep_pack; side_pid = setup_sideband(fd, xd); + + av = argv; + *hdr_arg = 0; + if (unpack_limit) { + struct pack_header header; + + if (read_pack_header(fd[0], &header)) + die("protocol error: bad pack header"); + snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u", + ntohl(header.hdr_version), ntohl(header.hdr_entries)); + if (ntohl(header.hdr_entries) < unpack_limit) + do_keep = 0; + else + do_keep = 1; + } + + if (do_keep) { + *av++ = "index-pack"; + *av++ = "--stdin"; + if (!quiet) + *av++ = "-v"; + if (use_thin_pack) + *av++ = "--fix-thin"; + if (keep_pack > 1 || unpack_limit) { + int s = sprintf(keep_arg, + "--keep=fetch-pack %d on ", getpid()); + if (gethostname(keep_arg + s, sizeof(keep_arg) - s)) + strcpy(keep_arg + s, "localhost"); + *av++ = keep_arg; + } + } + else { + *av++ = "unpack-objects"; + if (quiet) + *av++ = "-q"; + } + if (*hdr_arg) + *av++ = hdr_arg; + *av++ = NULL; + pid = fork(); if (pid < 0) die("fetch-pack: unable to fork off %s", argv[0]); @@ -522,39 +571,10 @@ static int get_pack(int xd[2], const char **argv) die("%s died of unnatural causes %d", argv[0], status); } -static int explode_rx_pack(int xd[2]) -{ - const char *argv[3] = { "unpack-objects", quiet ? "-q" : NULL, NULL }; - return get_pack(xd, argv); -} - -static int keep_rx_pack(int xd[2]) -{ - const char *argv[6]; - char keep_arg[256]; - int n = 0; - - argv[n++] = "index-pack"; - argv[n++] = "--stdin"; - if (!quiet) - argv[n++] = "-v"; - if (use_thin_pack) - argv[n++] = "--fix-thin"; - if (keep_pack > 1) { - int s = sprintf(keep_arg, "--keep=fetch-pack %i on ", getpid()); - if (gethostname(keep_arg + s, sizeof(keep_arg) - s)) - strcpy(keep_arg + s, "localhost"); - argv[n++] = keep_arg; - } - argv[n] = NULL; - return get_pack(xd, argv); -} - static int fetch_pack(int fd[2], int nr_match, char **match) { struct ref *ref; unsigned char sha1[20]; - int status; get_remote_heads(fd[0], &ref, 0, NULL, 0); if (is_repository_shallow() && !server_supports("shallow")) @@ -589,8 +609,7 @@ static int fetch_pack(int fd[2], int nr_match, char **match) */ fprintf(stderr, "warning: no common commits\n"); - status = (keep_pack) ? keep_rx_pack(fd) : explode_rx_pack(fd); - if (status) + if (get_pack(fd)) die("git-fetch-pack: fetch failed."); all_done: @@ -625,6 +644,21 @@ static int remove_duplicates(int nr_heads, char **heads) return dst; } +static int fetch_pack_config(const char *var, const char *value) +{ + if (strcmp(var, "fetch.unpacklimit") == 0) { + fetch_unpack_limit = git_config_int(var, value); + return 0; + } + + if (strcmp(var, "transfer.unpacklimit") == 0) { + transfer_unpack_limit = git_config_int(var, value); + return 0; + } + + return git_default_config(var, value); +} + static struct lock_file lock; int main(int argc, char **argv) @@ -636,6 +670,12 @@ int main(int argc, char **argv) struct stat st; setup_git_directory(); + git_config(fetch_pack_config); + + if (0 <= transfer_unpack_limit) + unpack_limit = transfer_unpack_limit; + else if (0 <= fetch_unpack_limit) + unpack_limit = fetch_unpack_limit; nr_heads = 0; heads = NULL; @@ -643,8 +683,12 @@ int main(int argc, char **argv) char *arg = argv[i]; if (*arg == '-') { + if (!strncmp("--upload-pack=", arg, 14)) { + uploadpack = arg + 14; + continue; + } if (!strncmp("--exec=", arg, 7)) { - exec = arg + 7; + uploadpack = arg + 7; continue; } if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) { @@ -653,6 +697,7 @@ int main(int argc, char **argv) } if (!strcmp("--keep", arg) || !strcmp("-k", arg)) { keep_pack++; + unpack_limit = 0; continue; } if (!strcmp("--thin", arg)) { @@ -682,7 +727,7 @@ int main(int argc, char **argv) } if (!dest) usage(fetch_pack_usage); - pid = git_connect(fd, dest, exec); + pid = git_connect(fd, dest, uploadpack); if (pid < 0) return 1; if (heads && nr_heads) diff --git a/git-checkout.sh b/git-checkout.sh index a2b8e4fa4a..8500f51ea2 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -135,11 +135,7 @@ fi # We are switching branches and checking out trees, so # we *NEED* to be at the toplevel. -cdup=$(git-rev-parse --show-cdup) -if test ! -z "$cdup" -then - cd "$cdup" -fi +cd_to_toplevel [ -z "$new" ] && new=$old && new_name="$old_name" @@ -160,9 +156,9 @@ then if test -n "$oldbranch" then detach_warn="warning: you are not on ANY branch anymore. -If you meant to create a new branch from the commit, you need -b to -associate a new branch with the wanted checkout. Example: - git checkout -b <new_branch_name> $arg" +If you meant to create a new branch from this checkout, you may still do +so (now or later) by using -b with the checkout command again. Example: + git checkout -b <new_branch_name>" fi elif test -z "$oldbranch" && test -n "$branch" then @@ -204,16 +200,12 @@ else # Match the index to the working tree, and do a three-way. git diff-files --name-only | git update-index --remove --stdin && work=`git write-tree` && - git read-tree --reset -u $new && - git read-tree -m -u --aggressive --exclude-per-directory=.gitignore $old $new $work || - exit + git read-tree --reset -u $new || exit - if result=`git write-tree 2>/dev/null` - then - echo >&2 "Trivially automerged." - else - git merge-index -o git-merge-one-file -a - fi + eval GITHEAD_$new=${new_name:-${branch:-$new}} && + eval GITHEAD_$work=local && + export GITHEAD_$new GITHEAD_$work && + git merge-recursive $old -- $new $work # Do not register the cleanly merged paths in the index yet. # this is not a real merge before committing, but just carrying diff --git a/git-clone.sh b/git-clone.sh index 0f7bbbfb39..3d83acbfc8 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -36,7 +36,7 @@ clone_dumb_http () { clone_tmp="$GIT_DIR/clone-tmp" && mkdir -p "$clone_tmp" || exit 1 if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ - "`git-repo-config --bool http.noEPSV`" = true ]; then + "`git-config --bool http.noEPSV`" = true ]; then curl_extra_args="${curl_extra_args} --disable-epsv" fi http_fetch "$1/info/refs" "$clone_tmp/refs" || @@ -66,48 +66,6 @@ Perhaps git-update-server-info needs to be run there?" rm -f "$GIT_DIR/REMOTE_HEAD" } -# Read git-fetch-pack -k output and store the remote branches. -copy_refs=' -use File::Path qw(mkpath); -use File::Basename qw(dirname); -my $git_dir = $ARGV[0]; -my $use_separate_remote = $ARGV[1]; -my $origin = $ARGV[2]; - -my $branch_top = ($use_separate_remote ? "remotes/$origin" : "heads"); -my $tag_top = "tags"; - -sub store { - my ($sha1, $name, $top) = @_; - $name = "$git_dir/refs/$top/$name"; - mkpath(dirname($name)); - open O, ">", "$name"; - print O "$sha1\n"; - close O; -} - -open FH, "<", "$git_dir/CLONE_HEAD"; -while (<FH>) { - my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/; - next if ($name =~ /\^\173/); - if ($name eq "HEAD") { - open O, ">", "$git_dir/REMOTE_HEAD"; - print O "$sha1\n"; - close O; - next; - } - if ($name =~ s/^refs\/heads\///) { - store($sha1, $name, $branch_top); - next; - } - if ($name =~ s/^refs\/tags\///) { - store($sha1, $name, $tag_top); - next; - } -} -close FH; -' - quiet= local=no use_local=no @@ -163,7 +121,9 @@ while 1,-u|1,--upload-pack) usage ;; *,-u|*,--upload-pack) shift - upload_pack="--exec=$1" ;; + upload_pack="--upload-pack=$1" ;; + *,--upload-pack=*) + upload_pack=--upload-pack=$(expr "$1" : '-[^=]*=\(.*\)') ;; 1,--depth) usage;; *,--depth) shift @@ -330,8 +290,29 @@ test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp" if test -f "$GIT_DIR/CLONE_HEAD" then # Read git-fetch-pack -k output and store the remote branches. - @@PERL@@ -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" || - exit + if [ -n "$use_separate_remote" ] + then + branch_top="remotes/$origin" + else + branch_top="heads" + fi + tag_top="tags" + while read sha1 name + do + case "$name" in + *'^{}') + continue ;; + HEAD) + destname="REMOTE_HEAD" ;; + refs/heads/*) + destname="refs/$branch_top/${name#refs/heads/}" ;; + refs/tags/*) + destname="refs/$tag_top/${name#refs/tags/}" ;; + *) + continue ;; + esac + git-update-ref -m "clone: from $repo" "$destname" "$sha1" "" + done < "$GIT_DIR/CLONE_HEAD" fi cd "$D" || exit @@ -384,17 +365,17 @@ then git-update-ref HEAD "$head_sha1" && # Upstream URL - git-repo-config remote."$origin".url "$repo" && + git-config remote."$origin".url "$repo" && # Set up the mappings to track the remote branches. - git-repo-config remote."$origin".fetch \ + git-config remote."$origin".fetch \ "+refs/heads/*:$remote_top/*" '^$' && rm -f "refs/remotes/$origin/HEAD" git-symbolic-ref "refs/remotes/$origin/HEAD" \ "refs/remotes/$origin/$head_points_at" && - git-repo-config branch."$head_points_at".remote "$origin" && - git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at" + git-config branch."$head_points_at".remote "$origin" && + git-config branch."$head_points_at".merge "refs/heads/$head_points_at" esac case "$no_checkout" in diff --git a/git-commit.sh b/git-commit.sh index eddd863015..dc0fc3b679 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Linus Torvalds # Copyright (c) 2006 Junio C Hamano -USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-u] [--amend] [-e] [--author <author>] [[-i | -o] <path>...]' +USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]' SUBDIRECTORY_OK=Yes . git-sh-setup require_work_tree @@ -284,9 +284,9 @@ esac case "$log_given" in tt*) - die "Only one of -c/-C/-F can be used." ;; + die "Only one of -c/-C/-F/--amend can be used." ;; *tm*|*mt*) - die "Option -m cannot be combined with -c/-C/-F." ;; + die "Option -m cannot be combined with -c/-C/-F/--amend." ;; esac case "$#,$also,$only,$amend" in @@ -316,22 +316,16 @@ esac ################################################################ # Prepare index to have a tree to be committed -TOP=`git-rev-parse --show-cdup` -if test -z "$TOP" -then - TOP=./ -fi - case "$all,$also" in t,) save_index && ( - cd "$TOP" - GIT_INDEX_FILE="$NEXT_INDEX" - export GIT_INDEX_FILE + cd_to_toplevel && + GIT_INDEX_FILE="$NEXT_INDEX" && + export GIT_INDEX_FILE && git-diff-files --name-only -z | git-update-index --remove -z --stdin - ) + ) || exit ;; ,t) save_index && @@ -339,11 +333,11 @@ t,) git-diff-files --name-only -z -- "$@" | ( - cd "$TOP" - GIT_INDEX_FILE="$NEXT_INDEX" - export GIT_INDEX_FILE + cd_to_toplevel && + GIT_INDEX_FILE="$NEXT_INDEX" && + export GIT_INDEX_FILE && git-update-index --remove -z --stdin - ) + ) || exit ;; ,) case "$#" in @@ -435,7 +429,9 @@ then fi elif test "$use_commit" != "" then - git-cat-file commit "$use_commit" | sed -e '1,/^$/d' + encoding=$(git config i18n.commitencoding || echo UTF-8) + git show -s --pretty=raw --encoding="$encoding" "$use_commit" | + sed -e '1,/^$/d' -e 's/^ //' elif test -f "$GIT_DIR/MERGE_MSG" then cat "$GIT_DIR/MERGE_MSG" @@ -446,8 +442,11 @@ fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG case "$signoff" in t) + need_blank_before_signoff= + tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG | + grep 'Signed-off-by:' >/dev/null || need_blank_before_signoff=yes { - echo + test -z "$need_blank_before_signoff" || echo git-var GIT_COMMITTER_IDENT | sed -e ' s/>.*/>/ s/^/Signed-off-by: / @@ -466,15 +465,7 @@ if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then fi >>"$GIT_DIR"/COMMIT_EDITMSG # Author -if test '' != "$force_author" -then - GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` && - GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` && - test '' != "$GIT_AUTHOR_NAME" && - test '' != "$GIT_AUTHOR_EMAIL" || - die "malformed --author parameter" - export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL -elif test '' != "$use_commit" +if test '' != "$use_commit" then pick_author_script=' /^author /{ @@ -497,13 +488,23 @@ then q } ' - set_author_env=`git-cat-file commit "$use_commit" | + encoding=$(git config i18n.commitencoding || echo UTF-8) + set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" | LANG=C LC_ALL=C sed -ne "$pick_author_script"` eval "$set_author_env" export GIT_AUTHOR_NAME export GIT_AUTHOR_EMAIL export GIT_AUTHOR_DATE fi +if test '' != "$force_author" +then + GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` && + GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` && + test '' != "$GIT_AUTHOR_NAME" && + test '' != "$GIT_AUTHOR_EMAIL" || + die "malformed --author parameter" + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL +fi PARENTS="-p HEAD" if test -z "$initial_commit" diff --git a/git-compat-util.h b/git-compat-util.h index ac06963e8d..c1bcb001a5 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -15,8 +15,9 @@ #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif -#define _GNU_SOURCE -#define _BSD_SOURCE +#define _ALL_SOURCE 1 +#define _GNU_SOURCE 1 +#define _BSD_SOURCE 1 #include <unistd.h> #include <stdio.h> @@ -28,7 +29,6 @@ #include <string.h> #include <errno.h> #include <limits.h> -#include <inttypes.h> #include <sys/param.h> #include <sys/types.h> #include <dirent.h> @@ -46,8 +46,10 @@ #include <arpa/inet.h> #include <netdb.h> #include <pwd.h> -#include <stdint.h> +#include <inttypes.h> +#undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */ #include <grp.h> +#define _ALL_SOURCE 1 #ifndef NO_ICONV #include <iconv.h> diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 35ef0c0ee5..6c9fbfec3a 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -85,7 +85,7 @@ sub write_author_info($) { close ($f); } -getopts("hivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage(); +getopts("haivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage(); usage if $opt_h; @ARGV <= 1 or usage(); diff --git a/git-cvsserver.perl b/git-cvsserver.perl index a33a876ff6..9371788fab 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -172,11 +172,11 @@ sub req_Root return 0; } - my @gitvars = `git-repo-config -l`; + my @gitvars = `git-config -l`; if ($?) { - print "E problems executing git-repo-config on the server -- this is not a git repository or the PATH is not set correctly.\n"; + print "E problems executing git-config on the server -- this is not a git repository or the PATH is not set correctly.\n"; print "E \n"; - print "error 1 - problem executing git-repo-config\n"; + print "error 1 - problem executing git-config\n"; return 0; } foreach my $line ( @gitvars ) @@ -876,9 +876,9 @@ sub req_update print "MT newline\n"; next; } - elsif ( !defined($wrev) || $wrev == 0 ) + elsif ( (!defined($wrev) || $wrev == 0) && (!defined($meta->{revision}) || $meta->{revision} == 0) ) { - $log->info("Tell the client the file will be added"); + $log->info("Tell the client the file is scheduled for addition"); print "MT text A \n"; print "MT fname $filename\n"; print "MT newline\n"; @@ -886,7 +886,7 @@ sub req_update } else { - $log->info("Updating '$filename' $wrev"); + $log->info("Updating '$filename' to ".$meta->{revision}); print "MT +updated\n"; print "MT text U \n"; print "MT fname $filename\n"; diff --git a/git-fetch.sh b/git-fetch.sh index c58704d794..c1f6e1e841 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -5,12 +5,8 @@ USAGE='<fetch-options> <repository> <refspec>...' SUBDIRECTORY_OK=Yes . git-sh-setup set_reflog_action "fetch $*" +cd_to_toplevel ;# probably unnecessary... -TOP=$(git-rev-parse --show-cdup) -if test ! -z "$TOP" -then - cd "$TOP" -fi . git-parse-remote _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" @@ -26,7 +22,6 @@ force= verbose= update_head_ok= exec= -upload_pack= keep= shallow_depth= while case "$#" in 0) break ;; esac @@ -38,8 +33,12 @@ do --upl|--uplo|--uploa|--upload|--upload-|--upload-p|\ --upload-pa|--upload-pac|--upload-pack) shift - exec="--exec=$1" - upload_pack="-u $1" + exec="--upload-pack=$1" + ;; + --upl=*|--uplo=*|--uploa=*|--upload=*|\ + --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*) + exec=--upload-pack=$(expr "$1" : '-[^=]*=\(.*\)') + shift ;; -f|--f|--fo|--for|--forc|--force) force=t @@ -86,6 +85,12 @@ case "$#" in set x $origin ; shift ;; esac +if test -z "$exec" +then + # No command line override and we have configuration for the remote. + exec="--upload-pack=$(get_uploadpack $1)" +fi + remote_nick="$1" remote=$(get_remote_url "$@") refs= @@ -98,7 +103,7 @@ then fi # Global that is reused later -ls_remote_result=$(git ls-remote $upload_pack "$remote") || +ls_remote_result=$(git ls-remote $exec "$remote") || die "Cannot get the repository state from $remote" append_fetch_head () { @@ -316,7 +321,7 @@ fetch_main () { curl_extra_args="-k" fi if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ - "`git-repo-config --bool http.noEPSV`" = true ]; then + "`git-config --bool http.noEPSV`" = true ]; then noepsv_opt="--disable-epsv" fi @@ -4,12 +4,26 @@ # # Cleanup unreachable files and optimize the repository. -USAGE='' +USAGE='git-gc [--prune]' SUBDIRECTORY_OK=Yes . git-sh-setup +no_prune=: +while case $# in 0) break ;; esac +do + case "$1" in + --prune) + no_prune= + ;; + --) + usage + ;; + esac + shift +done + git-pack-refs --prune && git-reflog expire --all && git-repack -a -d -l && -git-prune && +$no_prune git-prune && git-rerere gc || exit diff --git a/git-instaweb.sh b/git-instaweb.sh index 80adc8307b..cbc7418e35 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -15,11 +15,11 @@ case "$GIT_DIR" in fqgitdir="$PWD/$GIT_DIR" ;; esac -local="`git repo-config --bool --get instaweb.local`" -httpd="`git repo-config --get instaweb.httpd`" -browser="`git repo-config --get instaweb.browser`" -port=`git repo-config --get instaweb.port` -module_path="`git repo-config --get instaweb.modulepath`" +local="`git config --bool --get instaweb.local`" +httpd="`git config --get instaweb.httpd`" +browser="`git config --get instaweb.browser`" +port=`git config --get instaweb.port` +module_path="`git config --get instaweb.modulepath`" conf=$GIT_DIR/gitweb/httpd.conf diff --git a/git-lost-found.sh b/git-lost-found.sh index b928f2ca52..9360804711 100755 --- a/git-lost-found.sh +++ b/git-lost-found.sh @@ -12,7 +12,7 @@ fi laf="$GIT_DIR/lost-found" rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit -git fsck-objects --full | +git fsck --full | while read dangling type sha1 do case "$dangling" in diff --git a/git-ls-remote.sh b/git-ls-remote.sh index 03b624ef33..e6f574b99b 100755 --- a/git-ls-remote.sh +++ b/git-ls-remote.sh @@ -23,7 +23,11 @@ do -u|--u|--up|--upl|--uploa|--upload|--upload-|--upload-p|--upload-pa|\ --upload-pac|--upload-pack) shift - exec="--exec=$1" + exec="--upload-pack=$1" + shift;; + -u=*|--u=*|--up=*|--upl=*|--uplo=*|--uploa=*|--upload=*|\ + --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*) + exec=--upload-pack=$(expr "$1" : '-[^=]*=\(.*\)') shift;; --) shift; break ;; @@ -54,7 +58,7 @@ http://* | https://* | ftp://* ) curl_extra_args="-k" fi if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ - "`git-repo-config --bool http.noEPSV`" = true ]; then + "`git-config --bool http.noEPSV`" = true ]; then curl_extra_args="${curl_extra_args} --disable-epsv" fi curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" || diff --git a/git-merge.sh b/git-merge.sh index 3eef048efc..04a5eb0f29 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -5,12 +5,13 @@ USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+' +SUBDIRECTORY_OK=Yes . git-sh-setup -set_reflog_action "merge $*" require_work_tree +cd_to_toplevel test -z "$(git ls-files -u)" || - die "You are in a middle of conflicted merge." + die "You are in the middle of a conflicted merge." LF=' ' @@ -215,6 +216,7 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage # All the rest are remote heads test "$#" = 0 && usage ;# we need at least one remote head. +set_reflog_action "merge $*" remoteheads= for remote @@ -231,7 +233,7 @@ case "$use_strategies" in '') case "$#" in 1) - var="`git-repo-config --get pull.twohead`" + var="`git-config --get pull.twohead`" if test -n "$var" then use_strategies="$var" @@ -239,7 +241,7 @@ case "$use_strategies" in use_strategies="$default_twohead_strategies" fi ;; *) - var="`git-repo-config --get pull.octopus`" + var="`git-config --get pull.octopus`" if test -n "$var" then use_strategies="$var" @@ -299,24 +301,30 @@ f,*) ;; ?,1,*,) # We are not doing octopus, not fast forward, and have only - # one common. See if it is really trivial. - git var GIT_COMMITTER_IDENT >/dev/null || exit - - echo "Trying really trivial in-index merge..." + # one common. git-update-index --refresh 2>/dev/null - if git-read-tree --trivial -m -u -v $common $head "$1" && - result_tree=$(git-write-tree) - then - echo "Wonderful." - result_commit=$( - echo "$merge_msg" | - git-commit-tree $result_tree -p HEAD -p "$1" - ) || exit - finish "$result_commit" "In-index merge" - dropsave - exit 0 - fi - echo "Nope." + case " $use_strategies " in + *' recursive '*|*' recur '*) + : run merge later + ;; + *) + # See if it is really trivial. + git var GIT_COMMITTER_IDENT >/dev/null || exit + echo "Trying really trivial in-index merge..." + if git-read-tree --trivial -m -u -v $common $head "$1" && + result_tree=$(git-write-tree) + then + echo "Wonderful." + result_commit=$( + echo "$merge_msg" | + git-commit-tree $result_tree -p HEAD -p "$1" + ) || exit + finish "$result_commit" "In-index merge" + dropsave + exit 0 + fi + echo "Nope." + esac ;; *) # An octopus. If we can reach all the remote we are up to date. diff --git a/git-p4import.py b/git-p4import.py index 5c56cace0e..60a758bfe3 100644 --- a/git-p4import.py +++ b/git-p4import.py @@ -193,13 +193,13 @@ class git_command: def get_config(self, variable): try: - return self.git("repo-config --get %s" % variable)[0].rstrip() + return self.git("config --get %s" % variable)[0].rstrip() except: return None def set_config(self, variable, value): try: - self.git("repo-config %s %s"%(variable, value) ) + self.git("config %s %s"%(variable, value) ) except: die("Could not set %s to " % variable, value) diff --git a/git-parse-remote.sh b/git-parse-remote.sh index d2e4c2b9ae..3e783b7b05 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -10,7 +10,7 @@ get_data_source () { echo '' ;; *) - if test "$(git-repo-config --get "remote.$1.url")" + if test "$(git-config --get "remote.$1.url")" then echo config elif test -f "$GIT_DIR/remotes/$1" @@ -32,7 +32,7 @@ get_remote_url () { echo "$1" ;; config) - git-repo-config --get "remote.$1.url" + git-config --get "remote.$1.url" ;; remotes) sed -ne '/^URL: */{ @@ -49,8 +49,8 @@ get_remote_url () { } get_default_remote () { - curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||') - origin=$(git-repo-config --get "branch.$curr_branch.remote") + curr_branch=$(git-symbolic-ref -q HEAD | sed -e 's|^refs/heads/||') + origin=$(git-config --get "branch.$curr_branch.remote") echo ${origin:-origin} } @@ -60,7 +60,7 @@ get_remote_default_refs_for_push () { '' | branches) ;; # no default push mapping, just send matching refs. config) - git-repo-config --get-all "remote.$1.push" ;; + git-config --get-all "remote.$1.push" ;; remotes) sed -ne '/^Push: */{ s///p @@ -81,7 +81,14 @@ get_remote_default_refs_for_push () { # is to help prevent randomly "globbed" ref from being chosen as # a merge candidate expand_refs_wildcard () { + remote="$1" + shift first_one=yes + if test "$#" = 0 + then + echo empty + echo >&2 "Nothing specified for fetching with remote.$remote.fetch" + fi for ref do lref=${ref#'+'} @@ -132,14 +139,14 @@ canon_refs_list_for_fetch () { if test "$1" = "-d" then shift ; remote="$1" ; shift - set $(expand_refs_wildcard "$@") + set $(expand_refs_wildcard "$remote" "$@") is_explicit="$1" shift if test "$remote" = "$(get_default_remote)" then - curr_branch=$(git-symbolic-ref HEAD | \ + curr_branch=$(git-symbolic-ref -q HEAD | \ sed -e 's|^refs/heads/||') - merge_branches=$(git-repo-config \ + merge_branches=$(git-config \ --get-all "branch.${curr_branch}.merge") fi if test -z "$merge_branches" && test $is_explicit != explicit @@ -176,7 +183,7 @@ canon_refs_list_for_fetch () { done fi case "$remote" in - '') remote=HEAD ;; + '' | HEAD ) remote=HEAD ;; refs/heads/* | refs/tags/* | refs/remotes/*) ;; heads/* | tags/* | remotes/* ) remote="refs/$remote" ;; *) remote="refs/heads/$remote" ;; @@ -205,7 +212,7 @@ get_remote_default_refs_for_fetch () { echo "HEAD:" ;; config) canon_refs_list_for_fetch -d "$1" \ - $(git-repo-config --get-all "remote.$1.fetch") ;; + $(git-config --get-all "remote.$1.fetch") ;; branches) remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1") case "$remote_branch" in '') remote_branch=master ;; esac @@ -279,3 +286,16 @@ resolve_alternates () { esac done } + +get_uploadpack () { + data_source=$(get_data_source "$1") + case "$data_source" in + config) + uplp=$(git-config --get "remote.$1.uploadpack") + echo ${uplp:-git-upload-pack} + ;; + *) + echo "git-upload-pack" + ;; + esac +} diff --git a/git-pull.sh b/git-pull.sh index e9826fc4ce..a3665d7751 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -6,12 +6,14 @@ USAGE='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...' LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.' +SUBDIRECTORY_OK=Yes . git-sh-setup set_reflog_action "pull $*" require_work_tree +cd_to_toplevel test -z "$(git ls-files -u)" || - die "You are in a middle of conflicted merge." + die "You are in the middle of a conflicted merge." strategy_args= no_summary= no_commit= squash= while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac @@ -81,8 +83,17 @@ merge_head=$(sed -e '/ not-for-merge /d' \ case "$merge_head" in '') - curr_branch=$(git-symbolic-ref HEAD | \ - sed -e 's|^refs/heads/||') + curr_branch=$(git-symbolic-ref -q HEAD) + case $? in + 0) ;; + 1) echo >&2 "You are not currently on a branch; you must explicitly" + echo >&2 "specify which branch you wish to merge:" + echo >&2 " git pull <remote> <branch>" + exit 1;; + *) exit $?;; + esac + curr_branch=${curr_branch#refs/heads/} + echo >&2 "Warning: No merge candidate found because value of config option \"branch.${curr_branch}.merge\" does not match any remote branch fetched." echo >&2 "No changes." diff --git a/git-quiltimport.sh b/git-quiltimport.sh index 10135da3ac..2ae1f20c2e 100755 --- a/git-quiltimport.sh +++ b/git-quiltimport.sh @@ -89,7 +89,7 @@ for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do echo "No author found in $patch_name" >&2; echo "---" cat $tmp_msg - echo -n "Author: "; + printf "Author: "; read patch_author echo "$patch_author" diff --git a/git-rebase.sh b/git-rebase.sh index 98f9558145..99cedadda1 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -27,9 +27,12 @@ Example: git-rebase master~1 topic / --> / D---E---F---G master D---E---F---G master ' + +SUBDIRECTORY_OK=Yes . git-sh-setup set_reflog_action rebase require_work_tree +cd_to_toplevel RESOLVEMSG=" When you have resolved this problem run \"git rebase --continue\". @@ -272,8 +275,12 @@ case "$#" in git-checkout "$2" || usage ;; *) - branch_name=`git symbolic-ref HEAD` || die "No current branch" - branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'` + if branch_name=`git symbolic-ref -q HEAD` + then + branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'` + else + branch_name=HEAD ;# detached + fi ;; esac branch=$(git-rev-parse --verify "${branch_name}^0") || exit diff --git a/git-remote.perl b/git-remote.perl index fc055b6d95..c813fe1451 100755 --- a/git-remote.perl +++ b/git-remote.perl @@ -64,7 +64,7 @@ sub list_remote { my ($git) = @_; my %seen = (); my @remotes = eval { - $git->command(qw(repo-config --get-regexp), '^remote\.'); + $git->command(qw(config --get-regexp), '^remote\.'); }; for (@remotes) { if (/^remote\.([^.]*)\.(\S*)\s+(.*)$/) { @@ -103,7 +103,7 @@ sub list_branch { my ($git) = @_; my %seen = (); my @branches = eval { - $git->command(qw(repo-config --get-regexp), '^branch\.'); + $git->command(qw(config --get-regexp), '^branch\.'); }; for (@branches) { if (/^branch\.([^.]*)\.(\S*)\s+(.*)$/) { @@ -238,8 +238,8 @@ sub add_remote { print STDERR "remote $name already exists.\n"; exit(1); } - $git->command('repo-config', "remote.$name.url", $url); - $git->command('repo-config', "remote.$name.fetch", + $git->command('config', "remote.$name.url", $url); + $git->command('config', "remote.$name.fetch", "+refs/heads/*:refs/remotes/$name/*"); } diff --git a/git-repack.sh b/git-repack.sh index da8e67f7a5..ddfa8b44a1 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -28,7 +28,7 @@ done # Later we will default repack.UseDeltaBaseOffset to true default_dbo=false -case "`git repo-config --bool repack.usedeltabaseoffset || +case "`git config --bool repack.usedeltabaseoffset || echo $default_dbo`" in true) extra="$extra --delta-base-offset" ;; diff --git a/git-reset.sh b/git-reset.sh index b9045bc762..fee6d98d9c 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -43,7 +43,7 @@ case "$1" in --) shift ;; esac # affecting the working tree nor HEAD. if test $# != 0 then - test "$reset_type" == "--mixed" || + test "$reset_type" = "--mixed" || die "Cannot do partial $reset_type reset." git-diff-index --cached $rev -- "$@" | @@ -53,11 +53,7 @@ then exit fi -TOP=$(git-rev-parse --show-cdup) -if test ! -z "$TOP" -then - cd "$TOP" -fi +cd_to_toplevel if test "$reset_type" = "--hard" then @@ -91,7 +87,7 @@ update_ref_status=$? case "$reset_type" in --hard ) test $update_ref_status = 0 && { - echo -n "HEAD is now at " + printf "HEAD is now at " GIT_PAGER= git log --max-count=1 --pretty=oneline \ --abbrev-commit HEAD } diff --git a/git-revert.sh b/git-revert.sh index fcca3ebb90..866d622d23 100755 --- a/git-revert.sh +++ b/git-revert.sh @@ -19,8 +19,11 @@ case "$0" in echo >&2 "What are you talking about?" exit 1 ;; esac + +SUBDIRECTORY_OK=Yes ;# we will cd up . git-sh-setup require_work_tree +cd_to_toplevel no_commit= while case "$#" in 0) break ;; esac @@ -78,6 +81,8 @@ prev=$(git-rev-parse --verify "$commit^1" 2>/dev/null) || git-rev-parse --verify "$commit^2" >/dev/null 2>&1 && die "Cannot run $me a multi-parent commit." +encoding=$(git config i18n.commitencoding || echo UTF-8) + # "commit" is an existing commit. We would want to apply # the difference it introduces since its first parent "prev" # on top of the current HEAD if we are cherry-pick. Or the @@ -85,10 +90,11 @@ git-rev-parse --verify "$commit^2" >/dev/null 2>&1 && case "$me" in revert) - git-rev-list --pretty=oneline --max-count=1 $commit | + git show -s --pretty=oneline --encoding="$encoding" $commit | sed -e ' s/^[^ ]* /Revert "/ - s/$/"/' + s/$/"/ + ' echo echo "This reverts commit $commit." test "$rev" = "$commit" || @@ -117,14 +123,17 @@ cherry-pick) q }' - set_author_env=`git-cat-file commit "$commit" | + + logmsg=`git show -s --pretty=raw --encoding="$encoding" "$commit"` + set_author_env=`echo "$logmsg" | LANG=C LC_ALL=C sed -ne "$pick_author_script"` eval "$set_author_env" export GIT_AUTHOR_NAME export GIT_AUTHOR_EMAIL export GIT_AUTHOR_DATE - git-cat-file commit $commit | sed -e '1,/^$/d' + echo "$logmsg" | + sed -e '1,/^$/d' -e 's/^ //' case "$replay" in '') echo "(cherry picked from commit $commit)" @@ -137,37 +146,38 @@ cherry-pick) esac >.msg +eval GITHEAD_$head=HEAD +eval GITHEAD_$next='`git show -s \ + --pretty=oneline --encoding="$encoding" "$commit" | + sed -e "s/^[^ ]* //"`' +export GITHEAD_$head GITHEAD_$next + # This three way merge is an interesting one. We are at # $head, and would want to apply the change between $commit # and $prev on top of us (when reverting), or the change between # $prev and $commit on top of us (when cherry-picking or replaying). -echo >&2 "First trying simple merge strategy to $me." -git-read-tree -m -u --aggressive $base $head $next && +git-merge-recursive $base -- $head $next && result=$(git-write-tree 2>/dev/null) || { - echo >&2 "Simple $me fails; trying Automatic $me." - git-merge-index -o git-merge-one-file -a || { - mv -f .msg "$GIT_DIR/MERGE_MSG" - { - echo ' + mv -f .msg "$GIT_DIR/MERGE_MSG" + { + echo ' Conflicts: ' git ls-files --unmerged | sed -e 's/^[^ ]* / /' | uniq - } >>"$GIT_DIR/MERGE_MSG" - echo >&2 "Automatic $me failed. After resolving the conflicts," - echo >&2 "mark the corrected paths with 'git-add <paths>'" - echo >&2 "and commit the result." - case "$me" in - cherry-pick) + } >>"$GIT_DIR/MERGE_MSG" + echo >&2 "Automatic $me failed. After resolving the conflicts," + echo >&2 "mark the corrected paths with 'git-add <paths>'" + echo >&2 "and commit the result." + case "$me" in + cherry-pick) echo >&2 "You may choose to use the following when making" echo >&2 "the commit:" echo >&2 "$set_author_env" - esac - exit 1 - } - result=$(git-write-tree) || exit + esac + exit 1 } echo >&2 "Finished one $me." diff --git a/git-send-email.perl b/git-send-email.perl index 8dc2ee0cf7..6a285bfd21 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -408,7 +408,7 @@ sub unquote_rfc2047 { s/_/ /g; s/=([0-9A-F]{2})/chr(hex($1))/eg; } - return "$_ - unquoted"; + return "$_"; } sub send_message diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 57f7f77776..b4aa4b2f4e 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -29,13 +29,24 @@ set_reflog_action() { } is_bare_repository () { - git-repo-config --bool --get core.bare || + git-config --bool --get core.bare || case "$GIT_DIR" in .git | */.git) echo false ;; *) echo true ;; esac } +cd_to_toplevel () { + cdup=$(git-rev-parse --show-cdup) + if test ! -z "$cdup" + then + cd "$cdup" || { + echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree" + exit 1 + } + fi +} + require_work_tree () { test $(is_bare_repository) = false || die "fatal: $0 cannot be used without a working tree." diff --git a/git-svn.perl b/git-svn.perl index 9986a0c9bb..68156fc8a5 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -593,7 +593,7 @@ sub multi_init { "$trunk_url ($_trunk)\n"; } init($trunk_url); - command_noisy('repo-config', 'svn.trunk', $trunk_url); + command_noisy('config', 'svn.trunk', $trunk_url); } } $_prefix = '' unless defined $_prefix; @@ -772,22 +772,22 @@ sub log_use_color { return 1 if $_color; my ($dc, $dcvar); $dcvar = 'color.diff'; - $dc = `git-repo-config --get $dcvar`; + $dc = `git-config --get $dcvar`; if ($dc eq '') { # nothing at all; fallback to "diff.color" $dcvar = 'diff.color'; - $dc = `git-repo-config --get $dcvar`; + $dc = `git-config --get $dcvar`; } chomp($dc); if ($dc eq 'auto') { my $pc; - $pc = `git-repo-config --get color.pager`; + $pc = `git-config --get color.pager`; if ($pc eq '') { # does not have it -- fallback to pager.color - $pc = `git-repo-config --bool --get pager.color`; + $pc = `git-config --bool --get pager.color`; } else { - $pc = `git-repo-config --bool --get color.pager`; + $pc = `git-config --bool --get color.pager`; if ($?) { $pc = 'false'; } @@ -800,7 +800,7 @@ sub log_use_color { } return 0 if $dc eq 'never'; return 1 if $dc eq 'always'; - chomp($dc = `git-repo-config --bool --get $dcvar`); + chomp($dc = `git-config --bool --get $dcvar`); return ($dc eq 'true'); } @@ -919,7 +919,7 @@ sub complete_url_ls_init { waitpid $pid, 0; croak $? if $?; my ($n) = ($switch =~ /^--(\w+)/); - command_noisy('repo-config', "svn.$n", $full_url); + command_noisy('config', "svn.$n", $full_url); } sub common_prefix { @@ -1594,7 +1594,7 @@ sub init_vars { %tree_map = (); } -# convert GetOpt::Long specs for use by git-repo-config +# convert GetOpt::Long specs for use by git-config sub read_repo_config { return unless -d $GIT_DIR; my $opts = shift; @@ -1602,7 +1602,7 @@ sub read_repo_config { my $v = $opts->{$o}; my ($key) = ($o =~ /^([a-z\-]+)/); $key =~ s/-//g; - my $arg = 'git-repo-config'; + my $arg = 'git-config'; $arg .= ' --int' if ($o =~ /[:=]i$/); $arg .= ' --bool' if ($o !~ /[:=][sfi]$/); if (ref $v eq 'ARRAY') { @@ -1918,7 +1918,8 @@ sub _simple_prompt { $default_username = $_username if defined $_username; if (defined $default_username && length $default_username) { if (defined $realm && length $realm) { - print "Authentication realm: $realm\n"; + print STDERR "Authentication realm: $realm\n"; + STDERR->flush; } $cred->username($default_username); } else { @@ -1933,36 +1934,38 @@ sub _simple_prompt { sub _ssl_server_trust_prompt { my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_; $may_save = undef if $_no_auth_cache; - print "Error validating server certificate for '$realm':\n"; + print STDERR "Error validating server certificate for '$realm':\n"; if ($failures & $SVN::Auth::SSL::UNKNOWNCA) { - print " - The certificate is not issued by a trusted ", + print STDERR " - The certificate is not issued by a trusted ", "authority. Use the\n", " fingerprint to validate the certificate manually!\n"; } if ($failures & $SVN::Auth::SSL::CNMISMATCH) { - print " - The certificate hostname does not match.\n"; + print STDERR " - The certificate hostname does not match.\n"; } if ($failures & $SVN::Auth::SSL::NOTYETVALID) { - print " - The certificate is not yet valid.\n"; + print STDERR " - The certificate is not yet valid.\n"; } if ($failures & $SVN::Auth::SSL::EXPIRED) { - print " - The certificate has expired.\n"; + print STDERR " - The certificate has expired.\n"; } if ($failures & $SVN::Auth::SSL::OTHER) { - print " - The certificate has an unknown error.\n"; + print STDERR " - The certificate has an unknown error.\n"; } - printf( "Certificate information:\n". + printf STDERR + "Certificate information:\n". " - Hostname: %s\n". " - Valid: from %s until %s\n". " - Issuer: %s\n". " - Fingerprint: %s\n", map $cert_info->$_, qw(hostname valid_from valid_until - issuer_dname fingerprint) ); + issuer_dname fingerprint); my $choice; prompt: - print $may_save ? + print STDERR $may_save ? "(R)eject, accept (t)emporarily or accept (p)ermanently? " : "(R)eject or accept (t)emporarily? "; + STDERR->flush; $choice = lc(substr(<STDIN> || 'R', 0, 1)); if ($choice =~ /^t$/i) { $cred->may_save(undef); @@ -1980,7 +1983,8 @@ prompt: sub _ssl_client_cert_prompt { my ($cred, $realm, $may_save, $pool) = @_; $may_save = undef if $_no_auth_cache; - print "Client certificate filename: "; + print STDERR "Client certificate filename: "; + STDERR->flush; chomp(my $filename = <STDIN>); $cred->cert_file($filename); $cred->may_save($may_save); @@ -1999,13 +2003,14 @@ sub _username_prompt { my ($cred, $realm, $may_save, $pool) = @_; $may_save = undef if $_no_auth_cache; if (defined $realm && length $realm) { - print "Authentication realm: $realm\n"; + print STDERR "Authentication realm: $realm\n"; } my $username; if (defined $_username) { $username = $_username; } else { - print "Username: "; + print STDERR "Username: "; + STDERR->flush; chomp($username = <STDIN>); } $cred->username($username); @@ -2015,7 +2020,8 @@ sub _username_prompt { sub _read_password { my ($prompt, $realm) = @_; - print $prompt; + print STDERR $prompt; + STDERR->flush; require Term::ReadKey; Term::ReadKey::ReadMode('noecho'); my $password = ''; @@ -2024,7 +2030,8 @@ sub _read_password { $password .= $key; } Term::ReadKey::ReadMode('restore'); - print "\n"; + print STDERR "\n"; + STDERR->flush; $password; } @@ -2849,7 +2856,7 @@ sub rmdirs { foreach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) { $self->close_directory($bat->{$d}, $p); my ($dn) = ($d =~ m#^(.*?)/?(?:[^/]+)$#); - print "\tD+\t/$d/\n" unless $q; + print "\tD+\t$d/\n" unless $q; $self->SUPER::delete_entry($d, $r, $bat->{$dn}, $p); delete $bat->{$d}; } diff --git a/git-tag.sh b/git-tag.sh index ecb9100e4b..988bf4c6a6 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -63,12 +63,21 @@ do ;; -d) shift - tag_name="$1" - tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") || - die "Seriously, what tag are you talking about?" - git-update-ref -m 'tag: delete' -d "refs/tags/$tag_name" "$tag" && - echo "Deleted tag $tag_name." - exit $? + had_error=0 + for tag + do + cur=$(git-show-ref --verify --hash -- "refs/tags/$tag") || { + echo >&2 "Seriously, what tag are you talking about?" + had_error=1 + continue + } + git-update-ref -m 'tag: delete' -d "refs/tags/$tag" "$cur" || { + had_error=1 + continue + } + echo "Deleted tag $tag." + done + exit $had_error ;; -v) shift @@ -103,7 +112,9 @@ git-check-ref-format "tags/$name" || object=$(git-rev-parse --verify --default HEAD "$@") || exit 1 type=$(git-cat-file -t $object) || exit 1 tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1 -: ${username:=$(expr "z$tagger" : 'z\(.*>\)')} + +keyid=$(git-repo-config user.signingkey) || + keyid=$(expr "z$tagger" : 'z\(.*>\)') trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0 @@ -130,7 +141,7 @@ if [ "$annotate" ]; then cat "$GIT_DIR"/TAG_FINALMSG ) >"$GIT_DIR"/TAG_TMP rm -f "$GIT_DIR"/TAG_TMP.asc "$GIT_DIR"/TAG_FINALMSG if [ "$signed" ]; then - gpg -bsa -u "$username" "$GIT_DIR"/TAG_TMP && + gpg -bsa -u "$keyid" "$GIT_DIR"/TAG_TMP && cat "$GIT_DIR"/TAG_TMP.asc >>"$GIT_DIR"/TAG_TMP || die "failed to sign the tag with GPG." fi @@ -214,16 +214,17 @@ static void handle_internal_command(int argc, const char **argv, char **envp) int option; } commands[] = { { "add", cmd_add, RUN_SETUP | NOT_BARE }, - { "annotate", cmd_annotate, }, + { "annotate", cmd_annotate, USE_PAGER }, { "apply", cmd_apply }, { "archive", cmd_archive }, - { "blame", cmd_blame, RUN_SETUP | USE_PAGER }, + { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP }, { "cat-file", cmd_cat_file, RUN_SETUP }, { "checkout-index", cmd_checkout_index, RUN_SETUP }, { "check-ref-format", cmd_check_ref_format }, { "cherry", cmd_cherry, RUN_SETUP }, { "commit-tree", cmd_commit_tree, RUN_SETUP }, + { "config", cmd_config }, { "count-objects", cmd_count_objects, RUN_SETUP }, { "describe", cmd_describe, RUN_SETUP }, { "diff", cmd_diff, RUN_SETUP | USE_PAGER }, @@ -234,6 +235,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP }, { "for-each-ref", cmd_for_each_ref, RUN_SETUP }, { "format-patch", cmd_format_patch, RUN_SETUP }, + { "fsck", cmd_fsck, RUN_SETUP }, + { "fsck-objects", cmd_fsck, RUN_SETUP }, { "get-tar-commit-id", cmd_get_tar_commit_id }, { "grep", cmd_grep, RUN_SETUP }, { "help", cmd_help }, @@ -254,7 +257,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "push", cmd_push, RUN_SETUP }, { "read-tree", cmd_read_tree, RUN_SETUP }, { "reflog", cmd_reflog, RUN_SETUP }, - { "repo-config", cmd_repo_config }, + { "repo-config", cmd_config }, { "rerere", cmd_rerere, RUN_SETUP }, { "rev-list", cmd_rev_list, RUN_SETUP }, { "rev-parse", cmd_rev_parse, RUN_SETUP }, @@ -12,7 +12,7 @@ proc gitdir {} { if {[info exists env(GIT_DIR)]} { return $env(GIT_DIR) } else { - return ".git" + return [exec git rev-parse --git-dir] } } @@ -6193,7 +6193,7 @@ set wrcomcmd "git diff-tree --stdin -p --pretty" set gitencoding {} catch { - set gitencoding [exec git repo-config --get i18n.commitencoding] + set gitencoding [exec git config --get i18n.commitencoding] } if {$gitencoding == ""} { set gitencoding "utf-8" @@ -6293,6 +6293,7 @@ set stuffsaved 0 set patchnum 0 setcoords makewindow +wm title . "[file tail $argv0]: [file tail [pwd]]" readrefs if {$cmdline_files ne {} || $revtreeargs ne {}} { diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 88af2e6380..b606c1d3e7 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -986,7 +986,7 @@ sub git_get_project_config { $key =~ s/^gitweb\.//; return if ($key =~ m/\W/); - my @x = (git_cmd(), 'repo-config'); + my @x = (git_cmd(), 'config'); if (defined $type) { push @x, $type; } push @x, "--get"; push @x, "gitweb.$key"; diff --git a/http-fetch.c b/http-fetch.c index 67dfb0a033..9f790a08e5 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1003,7 +1003,6 @@ int main(int argc, const char **argv) int arg = 1; int rc = 0; - setup_ident(); setup_git_directory(); git_config(git_default_config); @@ -1070,7 +1069,7 @@ int main(int argc, const char **argv) fprintf(stderr, "Some loose object were found to be corrupt, but they might be just\n" "a false '404 Not Found' error message sent with incorrect HTTP\n" -"status code. Suggest running git fsck-objects.\n"); +"status code. Suggest running git-fsck.\n"); } return rc; } diff --git a/http-push.c b/http-push.c index 0a15f53782..b128c0146c 100644 --- a/http-push.c +++ b/http-push.c @@ -2299,7 +2299,6 @@ int main(int argc, char **argv) struct ref *ref; setup_git_directory(); - setup_ident(); remote = xcalloc(sizeof(*remote), 1); @@ -43,19 +43,13 @@ static void copy_gecos(struct passwd *w, char *name, int sz) } -int setup_ident(void) +static void copy_email(struct passwd *pw) { - int len; - struct passwd *pw = getpwuid(getuid()); - - if (!pw) - die("You don't exist. Go away!"); - - /* Get the name ("gecos") */ - copy_gecos(pw, git_default_name, sizeof(git_default_name)); - - /* Make up a fake email address (name + '@' + hostname [+ '.' + domainname]) */ - len = strlen(pw->pw_name); + /* + * Make up a fake email address + * (name + '@' + hostname [+ '.' + domainname]) + */ + int len = strlen(pw->pw_name); if (len > sizeof(git_default_email)/2) die("Your sysadmin must hate you!"); memcpy(git_default_email, pw->pw_name, len); @@ -68,13 +62,37 @@ int setup_ident(void) len = strlen(git_default_email); git_default_email[len++] = '.'; if (he && (domainname = strchr(he->h_name, '.'))) - strlcpy(git_default_email + len, domainname + 1, sizeof(git_default_email) - len); + strlcpy(git_default_email + len, domainname + 1, + sizeof(git_default_email) - len); else - strlcpy(git_default_email + len, "(none)", sizeof(git_default_email) - len); + strlcpy(git_default_email + len, "(none)", + sizeof(git_default_email) - len); + } +} + +static void setup_ident(void) +{ + struct passwd *pw = NULL; + + /* Get the name ("gecos") */ + if (!git_default_name[0]) { + pw = getpwuid(getuid()); + if (!pw) + die("You don't exist. Go away!"); + copy_gecos(pw, git_default_name, sizeof(git_default_name)); } + + if (!git_default_email[0]) { + if (!pw) + pw = getpwuid(getuid()); + if (!pw) + die("You don't exist. Go away!"); + copy_email(pw); + } + /* And set the default date */ - datestamp(git_default_date, sizeof(git_default_date)); - return 0; + if (!git_default_date[0]) + datestamp(git_default_date, sizeof(git_default_date)); } static int add_raw(char *buf, int size, int offset, const char *str) @@ -160,8 +178,8 @@ static const char *env_hint = "\n" "Run\n" "\n" -" git repo-config user.email \"you@email.com\"\n" -" git repo-config user.name \"Your Name\"\n" +" git config user.email \"you@email.com\"\n" +" git config user.name \"Your Name\"\n" "\n" "To set the identity in this repository.\n" "Add --global to set your account\'s default\n" @@ -174,18 +192,28 @@ static const char *get_ident(const char *name, const char *email, char date[50]; int i; + setup_ident(); if (!name) name = git_default_name; if (!email) email = git_default_email; if (!*name) { - if (name == git_default_name && env_hint) { + struct passwd *pw; + + if (0 <= error_on_no_name && + name == git_default_name && env_hint) { fprintf(stderr, env_hint, au_env, co_env); env_hint = NULL; /* warn only once, for "git-var -l" */ } - if (error_on_no_name) + if (0 < error_on_no_name) die("empty ident %s <%s> not allowed", name, email); + pw = getpwuid(getuid()); + if (!pw) + die("You don't exist. Go away!"); + strlcpy(git_default_name, pw->pw_name, + sizeof(git_default_name)); + name = git_default_name; } strcpy(date, git_default_date); @@ -218,18 +246,3 @@ const char *git_committer_info(int error_on_no_name) getenv("GIT_COMMITTER_DATE"), error_on_no_name); } - -void ignore_missing_committer_name() -{ - /* If we did not get a name from the user's gecos entry then - * git_default_name is empty; so instead load the username - * into it as a 'good enough for now' approximation of who - * this user is. - */ - if (!*git_default_name) { - struct passwd *pw = getpwuid(getuid()); - if (!pw) - die("You don't exist. Go away!"); - strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name)); - } -} diff --git a/local-fetch.c b/local-fetch.c index cf99cb72dd..7cfe8b3587 100644 --- a/local-fetch.c +++ b/local-fetch.c @@ -210,7 +210,6 @@ int main(int argc, const char **argv) char **commit_id; int arg = 1; - setup_ident(); setup_git_directory(); git_config(git_default_config); diff --git a/log-tree.c b/log-tree.c index 35be33aaf7..d8ca36bbdd 100644 --- a/log-tree.c +++ b/log-tree.c @@ -2,6 +2,7 @@ #include "diff.h" #include "commit.h" #include "log-tree.h" +#include "reflog-walk.h" static void show_parents(struct commit *commit, int abbrev) { @@ -223,6 +224,14 @@ void show_log(struct rev_info *opt, const char *sep) printf("%s", diff_get_color(opt->diffopt.color_diff, DIFF_RESET)); putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n'); + if (opt->reflog_info) { + show_reflog_message(opt->reflog_info, + opt->commit_format == CMIT_FMT_ONELINE);; + if (opt->commit_format == CMIT_FMT_ONELINE) { + printf("%s", sep); + return; + } + } } /* diff --git a/merge-recursive.c b/merge-recursive.c index b4acbb7408..fa320eb6b1 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -67,27 +67,75 @@ struct stage_data unsigned processed:1; }; +struct output_buffer +{ + struct output_buffer *next; + char *str; +}; + static struct path_list current_file_set = {NULL, 0, 0, 1}; static struct path_list current_directory_set = {NULL, 0, 0, 1}; -static int output_indent = 0; +static int call_depth = 0; +static int verbosity = 2; +static int buffer_output = 1; +static int do_progress = 1; +static unsigned last_percent; +static unsigned merged_cnt; +static unsigned total_cnt; +static volatile sig_atomic_t progress_update; +static struct output_buffer *output_list, *output_end; + +static int show (int v) +{ + return (!call_depth && verbosity >= v) || verbosity >= 5; +} -static void output(const char *fmt, ...) +static void output(int v, const char *fmt, ...) { va_list args; - int i; - for (i = output_indent; i--;) - fputs(" ", stdout); va_start(args, fmt); - vfprintf(stdout, fmt, args); + if (buffer_output && show(v)) { + struct output_buffer *b = xmalloc(sizeof(*b)); + nfvasprintf(&b->str, fmt, args); + b->next = NULL; + if (output_end) + output_end->next = b; + else + output_list = b; + output_end = b; + } else if (show(v)) { + int i; + for (i = call_depth; i--;) + fputs(" ", stdout); + vfprintf(stdout, fmt, args); + fputc('\n', stdout); + } va_end(args); - fputc('\n', stdout); +} + +static void flush_output() +{ + struct output_buffer *b, *n; + for (b = output_list; b; b = n) { + int i; + for (i = call_depth; i--;) + fputs(" ", stdout); + fputs(b->str, stdout); + fputc('\n', stdout); + n = b->next; + free(b->str); + free(b); + } + output_list = NULL; + output_end = NULL; } static void output_commit_title(struct commit *commit) { int i; - for (i = output_indent; i--;) + flush_output(); + for (i = call_depth; i--;) fputs(" ", stdout); if (commit->util) printf("virtual %s\n", (char *)commit->util); @@ -110,6 +158,39 @@ static void output_commit_title(struct commit *commit) } } +static void progress_interval(int signum) +{ + progress_update = 1; +} + +static void setup_progress_signal(void) +{ + struct sigaction sa; + struct itimerval v; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = progress_interval; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sigaction(SIGALRM, &sa, NULL); + + v.it_interval.tv_sec = 1; + v.it_interval.tv_usec = 0; + v.it_value = v.it_interval; + setitimer(ITIMER_REAL, &v, NULL); +} + +static void display_progress() +{ + unsigned percent = total_cnt ? merged_cnt * 100 / total_cnt : 0; + if (progress_update || percent != last_percent) { + fprintf(stderr, "%4u%% (%u/%u) done\r", + percent, merged_cnt, total_cnt); + progress_update = 0; + last_percent = percent; + } +} + static struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh) { @@ -272,11 +353,14 @@ static struct path_list *get_unmerged(void) int i; unmerged->strdup_paths = 1; + total_cnt += active_nr; - for (i = 0; i < active_nr; i++) { + for (i = 0; i < active_nr; i++, merged_cnt++) { struct path_list_item *item; struct stage_data *e; struct cache_entry *ce = active_cache[i]; + if (do_progress) + display_progress(); if (!ce_stage(ce)) continue; @@ -640,13 +724,13 @@ static void conflict_rename_rename(struct rename *ren1, const char *dst_name2 = ren2_dst; if (path_list_has_path(¤t_directory_set, ren1_dst)) { dst_name1 = del[delp++] = unique_path(ren1_dst, branch1); - output("%s is a directory in %s adding as %s instead", + output(1, "%s is a directory in %s added as %s instead", ren1_dst, branch2, dst_name1); remove_file(0, ren1_dst, 0); } if (path_list_has_path(¤t_directory_set, ren2_dst)) { dst_name2 = del[delp++] = unique_path(ren2_dst, branch2); - output("%s is a directory in %s adding as %s instead", + output(1, "%s is a directory in %s added as %s instead", ren2_dst, branch1, dst_name2); remove_file(0, ren2_dst, 0); } @@ -660,7 +744,7 @@ static void conflict_rename_dir(struct rename *ren1, const char *branch1) { char *new_path = unique_path(ren1->pair->two->path, branch1); - output("Renaming %s to %s instead", ren1->pair->one->path, new_path); + output(1, "Renamed %s to %s instead", ren1->pair->one->path, new_path); remove_file(0, ren1->pair->two->path, 0); update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, new_path); free(new_path); @@ -673,7 +757,7 @@ static void conflict_rename_rename_2(struct rename *ren1, { char *new_path1 = unique_path(ren1->pair->two->path, branch1); char *new_path2 = unique_path(ren2->pair->two->path, branch2); - output("Renaming %s to %s and %s to %s instead", + output(1, "Renamed %s to %s and %s to %s instead", ren1->pair->one->path, new_path1, ren2->pair->one->path, new_path2); remove_file(0, ren1->pair->two->path, 0); @@ -766,7 +850,7 @@ static int process_renames(struct path_list *a_renames, ren2->processed = 1; if (strcmp(ren1_dst, ren2_dst) != 0) { clean_merge = 0; - output("CONFLICT (rename/rename): " + output(1, "CONFLICT (rename/rename): " "Rename %s->%s in branch %s " "rename %s->%s in %s", src, ren1_dst, branch1, @@ -781,13 +865,13 @@ static int process_renames(struct path_list *a_renames, branch1, branch2); if (mfi.merge || !mfi.clean) - output("Renaming %s->%s", src, ren1_dst); + output(1, "Renamed %s->%s", src, ren1_dst); if (mfi.merge) - output("Auto-merging %s", ren1_dst); + output(2, "Auto-merged %s", ren1_dst); if (!mfi.clean) { - output("CONFLICT (content): merge conflict in %s", + output(1, "CONFLICT (content): merge conflict in %s", ren1_dst); clean_merge = 0; @@ -818,14 +902,14 @@ static int process_renames(struct path_list *a_renames, if (path_list_has_path(¤t_directory_set, ren1_dst)) { clean_merge = 0; - output("CONFLICT (rename/directory): Rename %s->%s in %s " + output(1, "CONFLICT (rename/directory): Renamed %s->%s in %s " " directory %s added in %s", ren1_src, ren1_dst, branch1, ren1_dst, branch2); conflict_rename_dir(ren1, branch1); } else if (sha_eq(src_other.sha1, null_sha1)) { clean_merge = 0; - output("CONFLICT (rename/delete): Rename %s->%s in %s " + output(1, "CONFLICT (rename/delete): Renamed %s->%s in %s " "and deleted in %s", ren1_src, ren1_dst, branch1, branch2); @@ -834,19 +918,19 @@ static int process_renames(struct path_list *a_renames, const char *new_path; clean_merge = 0; try_merge = 1; - output("CONFLICT (rename/add): Rename %s->%s in %s. " + output(1, "CONFLICT (rename/add): Renamed %s->%s in %s. " "%s added in %s", ren1_src, ren1_dst, branch1, ren1_dst, branch2); new_path = unique_path(ren1_dst, branch2); - output("Adding as %s instead", new_path); + output(1, "Added as %s instead", new_path); update_file(0, dst_other.sha1, dst_other.mode, new_path); } else if ((item = path_list_lookup(ren1_dst, renames2Dst))) { ren2 = item->util; clean_merge = 0; ren2->processed = 1; - output("CONFLICT (rename/rename): Rename %s->%s in %s. " - "Rename %s->%s in %s", + output(1, "CONFLICT (rename/rename): Renamed %s->%s in %s. " + "Renamed %s->%s in %s", ren1_src, ren1_dst, branch1, ren2->pair->one->path, ren2->pair->two->path, branch2); conflict_rename_rename_2(ren1, branch1, ren2, branch2); @@ -870,11 +954,11 @@ static int process_renames(struct path_list *a_renames, a_branch, b_branch); if (mfi.merge || !mfi.clean) - output("Renaming %s => %s", ren1_src, ren1_dst); + output(1, "Renamed %s => %s", ren1_src, ren1_dst); if (mfi.merge) - output("Auto-merging %s", ren1_dst); + output(2, "Auto-merged %s", ren1_dst); if (!mfi.clean) { - output("CONFLICT (rename/modify): Merge conflict in %s", + output(1, "CONFLICT (rename/modify): Merge conflict in %s", ren1_dst); clean_merge = 0; @@ -922,20 +1006,20 @@ static int process_entry(const char *path, struct stage_data *entry, /* Deleted in both or deleted in one and * unchanged in the other */ if (a_sha) - output("Removing %s", path); + output(2, "Removed %s", path); /* do not touch working file if it did not exist */ remove_file(1, path, !a_sha); } else { /* Deleted in one and changed in the other */ clean_merge = 0; if (!a_sha) { - output("CONFLICT (delete/modify): %s deleted in %s " + output(1, "CONFLICT (delete/modify): %s deleted in %s " "and modified in %s. Version %s of %s left in tree.", path, branch1, branch2, branch2, path); update_file(0, b_sha, b_mode, path); } else { - output("CONFLICT (delete/modify): %s deleted in %s " + output(1, "CONFLICT (delete/modify): %s deleted in %s " "and modified in %s. Version %s of %s left in tree.", path, branch2, branch1, branch1, path); @@ -968,13 +1052,13 @@ static int process_entry(const char *path, struct stage_data *entry, if (path_list_has_path(¤t_directory_set, path)) { const char *new_path = unique_path(path, add_branch); clean_merge = 0; - output("CONFLICT (%s): There is a directory with name %s in %s. " - "Adding %s as %s", + output(1, "CONFLICT (%s): There is a directory with name %s in %s. " + "Added %s as %s", conf, path, other_branch, path, new_path); remove_file(0, path, 0); update_file(0, sha, mode, new_path); } else { - output("Adding %s", path); + output(2, "Added %s", path); update_file(1, sha, mode, path); } } else if (a_sha && b_sha) { @@ -988,7 +1072,7 @@ static int process_entry(const char *path, struct stage_data *entry, reason = "add/add"; o_sha = (unsigned char *)null_sha1; } - output("Auto-merging %s", path); + output(2, "Auto-merged %s", path); o.path = a.path = b.path = (char *)path; hashcpy(o.sha1, o_sha); o.mode = o_mode; @@ -1004,7 +1088,7 @@ static int process_entry(const char *path, struct stage_data *entry, update_file(1, mfi.sha, mfi.mode, path); else { clean_merge = 0; - output("CONFLICT (%s): Merge conflict in %s", + output(1, "CONFLICT (%s): Merge conflict in %s", reason, path); if (index_only) @@ -1028,7 +1112,7 @@ static int merge_trees(struct tree *head, { int code, clean; if (sha_eq(common->object.sha1, merge->object.sha1)) { - output("Already uptodate!"); + output(0, "Already uptodate!"); *result = head; return 1; } @@ -1053,13 +1137,15 @@ static int merge_trees(struct tree *head, re_merge = get_renames(merge, common, head, merge, entries); clean = process_renames(re_head, re_merge, branch1, branch2); - for (i = 0; i < entries->nr; i++) { + total_cnt += entries->nr; + for (i = 0; i < entries->nr; i++, merged_cnt++) { const char *path = entries->items[i].path; struct stage_data *e = entries->items[i].util; - if (e->processed) - continue; - if (!process_entry(path, e, branch1, branch2)) + if (!e->processed + && !process_entry(path, e, branch1, branch2)) clean = 0; + if (do_progress) + display_progress(); } path_list_clear(re_merge, 0); @@ -1095,7 +1181,6 @@ static int merge(struct commit *h1, struct commit *h2, const char *branch1, const char *branch2, - int call_depth /* =0 */, struct commit_list *ca, struct commit **result) { @@ -1104,18 +1189,22 @@ static int merge(struct commit *h1, struct tree *mrtree; int clean; - output("Merging:"); - output_commit_title(h1); - output_commit_title(h2); + if (show(4)) { + output(4, "Merging:"); + output_commit_title(h1); + output_commit_title(h2); + } if (!ca) { ca = get_merge_bases(h1, h2, 1); ca = reverse_commit_list(ca); } - output("found %u common ancestor(s):", commit_list_count(ca)); - for (iter = ca; iter; iter = iter->next) - output_commit_title(iter->item); + if (show(5)) { + output(5, "found %u common ancestor(s):", commit_list_count(ca)); + for (iter = ca; iter; iter = iter->next) + output_commit_title(iter->item); + } merged_common_ancestors = pop_commit(&ca); if (merged_common_ancestors == NULL) { @@ -1129,7 +1218,7 @@ static int merge(struct commit *h1, } for (iter = ca; iter; iter = iter->next) { - output_indent = call_depth + 1; + call_depth++; /* * When the merge fails, the result contains files * with conflict markers. The cleanness flag is @@ -1141,17 +1230,16 @@ static int merge(struct commit *h1, merge(merged_common_ancestors, iter->item, "Temporary merge branch 1", "Temporary merge branch 2", - call_depth + 1, NULL, &merged_common_ancestors); - output_indent = call_depth; + call_depth--; if (!merged_common_ancestors) die("merge returned no commit"); } discard_cache(); - if (call_depth == 0) { + if (!call_depth) { read_cache(); index_only = 0; } else @@ -1165,6 +1253,16 @@ static int merge(struct commit *h1, commit_list_insert(h1, &(*result)->parents); commit_list_insert(h2, &(*result)->parents->next); } + if (!call_depth && do_progress) { + /* Make sure we end at 100% */ + if (!total_cnt) + total_cnt = 1; + merged_cnt = total_cnt; + progress_update = 1; + display_progress(); + fputc('\n', stderr); + } + flush_output(); return clean; } @@ -1198,6 +1296,15 @@ static struct commit *get_ref(const char *ref) return (struct commit *)object; } +static int merge_config(const char *var, const char *value) +{ + if (!strcasecmp(var, "merge.verbosity")) { + verbosity = git_config_int(var, value); + return 0; + } + return git_default_config(var, value); +} + int main(int argc, char *argv[]) { static const char *bases[20]; @@ -1209,7 +1316,9 @@ int main(int argc, char *argv[]) struct lock_file *lock = xcalloc(1, sizeof(struct lock_file)); int index_fd; - git_config(git_default_config); /* core.filemode */ + git_config(merge_config); + if (getenv("GIT_MERGE_VERBOSITY")) + verbosity = strtol(getenv("GIT_MERGE_VERBOSITY"), NULL, 10); if (argc < 4) die("Usage: %s <base>... -- <head> <remote> ...\n", argv[0]); @@ -1222,6 +1331,12 @@ int main(int argc, char *argv[]) } if (argc - i != 3) /* "--" "<head>" "<remote>" */ die("Not handling anything other than two heads merge."); + if (verbosity >= 5) { + buffer_output = 0; + do_progress = 0; + } + else + do_progress = isatty(1); branch1 = argv[++i]; branch2 = argv[++i]; @@ -1231,7 +1346,11 @@ int main(int argc, char *argv[]) branch1 = better_branch_name(branch1); branch2 = better_branch_name(branch2); - printf("Merging %s with %s\n", branch1, branch2); + + if (do_progress) + setup_progress_signal(); + if (show(3)) + printf("Merging %s with %s\n", branch1, branch2); index_fd = hold_lock_file_for_update(lock, get_index_file(), 1); @@ -1239,7 +1358,7 @@ int main(int argc, char *argv[]) struct commit *ancestor = get_ref(bases[i]); ca = commit_list_insert(ancestor, &ca); } - clean = merge(h1, h2, branch1, branch2, 0, ca, &result); + clean = merge(h1, h2, branch1, branch2, ca, &result); if (active_cache_changed && (write_cache(index_fd, active_cache, active_nr) || @@ -10,10 +10,43 @@ #define PACK_VERSION 2 #define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3)) struct pack_header { - unsigned int hdr_signature; - unsigned int hdr_version; - unsigned int hdr_entries; + uint32_t hdr_signature; + uint32_t hdr_version; + uint32_t hdr_entries; }; +/* + * Packed object index header + * + * struct pack_idx_header { + * uint32_t idx_signature; + * uint32_t idx_version; + * }; + * + * Note: this header isn't active yet. In future versions of git + * we may change the index file format. At that time we would start + * the first four bytes of the new index format with this signature, + * as all older git binaries would find this value illegal and abort + * reading the file. + * + * This is the case because the number of objects in a packfile + * cannot exceed 1,431,660,000 as every object would need at least + * 3 bytes of data and the overall packfile cannot exceed 4 GiB due + * to the 32 bit offsets used by the index. Clearly the signature + * exceeds this maximum. + * + * Very old git binaries will also compare the first 4 bytes to the + * next 4 bytes in the index and abort with a "non-monotonic index" + * error if the second 4 byte word is smaller than the first 4 + * byte word. This would be true in the proposed future index + * format as idx_signature would be greater than idx_version. + */ +#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */ + extern int verify_pack(struct packed_git *, int); + +#define PH_ERROR_EOF (-1) +#define PH_ERROR_PACK_SIGNATURE (-2) +#define PH_ERROR_PROTOCOL (-3) +extern int read_pack_header(int fd, struct pack_header *); #endif diff --git a/peek-remote.c b/peek-remote.c index 353da002b4..ef3c76ce52 100644 --- a/peek-remote.c +++ b/peek-remote.c @@ -3,8 +3,8 @@ #include "pkt-line.h" static const char peek_remote_usage[] = -"git-peek-remote [--exec=upload-pack] [host:]directory"; -static const char *exec = "git-upload-pack"; +"git-peek-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>"; +static const char *uploadpack = "git-upload-pack"; static int peek_remote(int fd[2], unsigned flags) { @@ -35,8 +35,12 @@ int main(int argc, char **argv) char *arg = argv[i]; if (*arg == '-') { + if (!strncmp("--upload-pack=", arg, 14)) { + uploadpack = arg + 14; + continue; + } if (!strncmp("--exec=", arg, 7)) { - exec = arg + 7; + uploadpack = arg + 7; continue; } if (!strcmp("--tags", arg)) { @@ -60,7 +64,7 @@ int main(int argc, char **argv) if (!dest || i != argc - 1) usage(peek_remote_usage); - pid = git_connect(fd, dest, exec); + pid = git_connect(fd, dest, uploadpack); if (pid < 0) return 1; ret = peek_remote(fd, flags); diff --git a/perl/Git.pm b/perl/Git.pm index 3474ad320f..5d1ccaa125 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -275,7 +275,7 @@ sub command { } else { my @lines = <$fh>; - chomp @lines; + defined and chomp for @lines; try { _cmd_close($fh, $ctx); } catch Git::Error::Command with { @@ -482,14 +482,14 @@ sub wc_chdir { =item config ( VARIABLE ) -Retrieve the configuration C<VARIABLE> in the same manner as C<repo-config> +Retrieve the configuration C<VARIABLE> in the same manner as C<config> does. In scalar context requires the variable to be set only one time (exception is thrown otherwise), in array context returns allows the variable to be set multiple times and returns all the values. Must be called on a repository instance. -This currently wraps command('repo-config') so it is not so fast. +This currently wraps command('config') so it is not so fast. =cut @@ -500,9 +500,9 @@ sub config { try { if (wantarray) { - return $self->command('repo-config', '--get-all', $var); + return $self->command('config', '--get-all', $var); } else { - return $self->command_oneline('repo-config', '--get', $var); + return $self->command_oneline('config', '--get', $var); } } catch Git::Error::Command with { my $E = shift; @@ -736,13 +736,19 @@ sub _command_common_pipe { _check_valid_cmd($cmd); my $fh; - if ($^O eq '##INSERT_ACTIVESTATE_STRING_HERE##') { + if ($^O eq 'MSWin32') { # ActiveState Perl #defined $opts{STDERR} and # warn 'ignoring STDERR option - running w/ ActiveState'; $direction eq '-|' or die 'input pipe for ActiveState not implemented'; - tie ($fh, 'Git::activestate_pipe', $cmd, @args); + # the strange construction with *ACPIPE is just to + # explain the tie below that we want to bind to + # a handle class, not scalar. It is not known if + # it is something specific to ActiveState Perl or + # just a Perl quirk. + tie (*ACPIPE, 'Git::activestate_pipe', $cmd, @args); + $fh = *ACPIPE; } else { my $pid = open($fh, $direction); @@ -809,8 +815,9 @@ sub TIEHANDLE { # FIXME: This is probably horrible idea and the thing will explode # at the moment you give it arguments that require some quoting, # but I have no ActiveState clue... --pasky - my $cmdline = join " ", @params; - my @data = qx{$cmdline}; + # Let's just hope ActiveState Perl does at least the quoting + # correctly. + my @data = qx{git @params}; bless { i => 0, data => \@data }, $class; } diff --git a/perl/Makefile.PL b/perl/Makefile.PL index 41687757a7..9b117fd0d7 100644 --- a/perl/Makefile.PL +++ b/perl/Makefile.PL @@ -20,6 +20,10 @@ if ($@) { my %extra; $extra{DESTDIR} = $ENV{DESTDIR} if $ENV{DESTDIR}; +# redirect stdout, otherwise the message "Writing perl.mak for Git" +# disrupts the output for the target 'instlibdir' +open STDOUT, ">&STDERR"; + WriteMakefile( NAME => 'Git', VERSION_FROM => 'Git.pm', @@ -387,3 +387,37 @@ void python_quote_print(FILE *stream, const char *src) } fputc(sq, stream); } + +void tcl_quote_print(FILE *stream, const char *src) +{ + char c; + + fputc('"', stream); + while ((c = *src++)) { + switch (c) { + case '[': case ']': + case '{': case '}': + case '$': case '\\': case '"': + fputc('\\', stream); + default: + fputc(c, stream); + break; + case '\f': + fputs("\\f", stream); + break; + case '\r': + fputs("\\r", stream); + break; + case '\n': + fputs("\\n", stream); + break; + case '\t': + fputs("\\t", stream); + break; + case '\v': + fputs("\\v", stream); + break; + } + } + fputc('"', stream); +} @@ -55,5 +55,6 @@ extern void write_name_quoted(const char *prefix, int prefix_len, /* quoting as a string literal for other languages */ extern void perl_quote_print(FILE *stream, const char *src); extern void python_quote_print(FILE *stream, const char *src); +extern void tcl_quote_print(FILE *stream, const char *src); #endif diff --git a/receive-pack.c b/receive-pack.c index c176d8fd00..7311c822dd 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -10,6 +10,8 @@ static const char receive_pack_usage[] = "git-receive-pack <git-dir>"; static int deny_non_fast_forwards = 0; +static int receive_unpack_limit = -1; +static int transfer_unpack_limit = -1; static int unpack_limit = 100; static int report_status; @@ -18,21 +20,22 @@ static int capabilities_sent; static int receive_pack_config(const char *var, const char *value) { - git_default_config(var, value); - - if (strcmp(var, "receive.denynonfastforwards") == 0) - { + if (strcmp(var, "receive.denynonfastforwards") == 0) { deny_non_fast_forwards = git_config_bool(var, value); return 0; } - if (strcmp(var, "receive.unpacklimit") == 0) - { - unpack_limit = git_config_int(var, value); + if (strcmp(var, "receive.unpacklimit") == 0) { + receive_unpack_limit = git_config_int(var, value); return 0; } - return 0; + if (strcmp(var, "transfer.unpacklimit") == 0) { + transfer_unpack_limit = git_config_int(var, value); + return 0; + } + + return git_default_config(var, value); } static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) @@ -250,20 +253,22 @@ static void read_head_info(void) static const char *parse_pack_header(struct pack_header *hdr) { - char *c = (char*)hdr; - ssize_t remaining = sizeof(struct pack_header); - do { - ssize_t r = xread(0, c, remaining); - if (r <= 0) - return "eof before pack header was fully read"; - remaining -= r; - c += r; - } while (remaining > 0); - if (hdr->hdr_signature != htonl(PACK_SIGNATURE)) + switch (read_pack_header(0, hdr)) { + case PH_ERROR_EOF: + return "eof before pack header was fully read"; + + case PH_ERROR_PACK_SIGNATURE: return "protocol error (pack signature mismatch detected)"; - if (!pack_version_ok(hdr->hdr_version)) + + case PH_ERROR_PROTOCOL: return "protocol error (pack version unsupported)"; - return NULL; + + default: + return "unknown error in parse_pack_header"; + + case 0: + return NULL; + } } static const char *pack_lockfile; @@ -421,11 +426,16 @@ int main(int argc, char **argv) if (!enter_repo(dir, 0)) die("'%s': unable to chdir or not a git archive", dir); - setup_ident(); - /* don't die if gecos is empty */ - ignore_missing_committer_name(); + if (is_repository_shallow()) + die("attempt to push into a shallow repository"); + git_config(receive_pack_config); + if (0 <= transfer_unpack_limit) + unpack_limit = transfer_unpack_limit; + else if (0 <= receive_unpack_limit) + unpack_limit = receive_unpack_limit; + write_head_info(); /* EOF */ diff --git a/reflog-walk.c b/reflog-walk.c new file mode 100644 index 0000000000..82621601d6 --- /dev/null +++ b/reflog-walk.c @@ -0,0 +1,250 @@ +#include "cache.h" +#include "commit.h" +#include "refs.h" +#include "diff.h" +#include "revision.h" +#include "path-list.h" +#include "reflog-walk.h" + +struct complete_reflogs { + char *ref; + struct reflog_info { + unsigned char osha1[20], nsha1[20]; + char *email; + unsigned long timestamp; + int tz; + char *message; + } *items; + int nr, alloc; +}; + +static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1, + const char *email, unsigned long timestamp, int tz, + const char *message, void *cb_data) +{ + struct complete_reflogs *array = cb_data; + struct reflog_info *item; + + if (array->nr >= array->alloc) { + array->alloc = alloc_nr(array->nr + 1); + array->items = xrealloc(array->items, array->alloc * + sizeof(struct reflog_info)); + } + item = array->items + array->nr; + memcpy(item->osha1, osha1, 20); + memcpy(item->nsha1, nsha1, 20); + item->email = xstrdup(email); + item->timestamp = timestamp; + item->tz = tz; + item->message = xstrdup(message); + array->nr++; + return 0; +} + +static struct complete_reflogs *read_complete_reflog(const char *ref) +{ + struct complete_reflogs *reflogs = + xcalloc(sizeof(struct complete_reflogs), 1); + reflogs->ref = xstrdup(ref); + for_each_reflog_ent(ref, read_one_reflog, reflogs); + if (reflogs->nr == 0) { + unsigned char sha1[20]; + const char *name = resolve_ref(ref, sha1, 1, NULL); + if (name) + for_each_reflog_ent(name, read_one_reflog, reflogs); + } + if (reflogs->nr == 0) { + int len = strlen(ref); + char *refname = xmalloc(len + 12); + sprintf(refname, "refs/%s", ref); + for_each_reflog_ent(refname, read_one_reflog, reflogs); + if (reflogs->nr == 0) { + sprintf(refname, "refs/heads/%s", ref); + for_each_reflog_ent(refname, read_one_reflog, reflogs); + } + free(refname); + } + return reflogs; +} + +static int get_reflog_recno_by_time(struct complete_reflogs *array, + unsigned long timestamp) +{ + int i; + for (i = array->nr - 1; i >= 0; i--) + if (timestamp >= array->items[i].timestamp) + return i; + return -1; +} + +struct commit_info_lifo { + struct commit_info { + struct commit *commit; + void *util; + } *items; + int nr, alloc; +}; + +static struct commit_info *get_commit_info(struct commit *commit, + struct commit_info_lifo *lifo, int pop) +{ + int i; + for (i = 0; i < lifo->nr; i++) + if (lifo->items[i].commit == commit) { + struct commit_info *result = &lifo->items[i]; + if (pop) { + if (i + 1 < lifo->nr) + memmove(lifo->items + i, + lifo->items + i + 1, + (lifo->nr - i) * + sizeof(struct commit_info)); + lifo->nr--; + } + return result; + } + return NULL; +} + +static void add_commit_info(struct commit *commit, void *util, + struct commit_info_lifo *lifo) +{ + struct commit_info *info; + if (lifo->nr >= lifo->alloc) { + lifo->alloc = alloc_nr(lifo->nr + 1); + lifo->items = xrealloc(lifo->items, + lifo->alloc * sizeof(struct commit_info)); + } + info = lifo->items + lifo->nr; + info->commit = commit; + info->util = util; + lifo->nr++; +} + +struct commit_reflog { + int flag, recno; + struct complete_reflogs *reflogs; +}; + +struct reflog_walk_info { + struct commit_info_lifo reflogs; + struct path_list complete_reflogs; + struct commit_reflog *last_commit_reflog; +}; + +void init_reflog_walk(struct reflog_walk_info** info) +{ + *info = xcalloc(sizeof(struct reflog_walk_info), 1); +} + +void add_reflog_for_walk(struct reflog_walk_info *info, + struct commit *commit, const char *name) +{ + unsigned long timestamp = 0; + int recno = -1; + struct path_list_item *item; + struct complete_reflogs *reflogs; + char *branch, *at = strchr(name, '@'); + struct commit_reflog *commit_reflog; + + if (commit->object.flags & UNINTERESTING) + die ("Cannot walk reflogs for %s", name); + + branch = xstrdup(name); + if (at && at[1] == '{') { + char *ep; + branch[at - name] = '\0'; + recno = strtoul(at + 2, &ep, 10); + if (*ep != '}') { + recno = -1; + timestamp = approxidate(at + 2); + } + } else + recno = 0; + + item = path_list_lookup(branch, &info->complete_reflogs); + if (item) + reflogs = item->util; + else { + reflogs = read_complete_reflog(branch); + if (!reflogs || reflogs->nr == 0) + die("No reflogs found for '%s'", branch); + path_list_insert(branch, &info->complete_reflogs)->util + = reflogs; + } + + commit_reflog = xcalloc(sizeof(struct commit_reflog), 1); + if (recno < 0) { + commit_reflog->flag = 1; + commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp); + if (commit_reflog->recno < 0) { + free(branch); + free(commit_reflog); + return; + } + } else + commit_reflog->recno = reflogs->nr - recno - 1; + commit_reflog->reflogs = reflogs; + + add_commit_info(commit, commit_reflog, &info->reflogs); +} + +void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit) +{ + struct commit_info *commit_info = + get_commit_info(commit, &info->reflogs, 0); + struct commit_reflog *commit_reflog; + struct reflog_info *reflog; + + info->last_commit_reflog = NULL; + if (!commit_info) + return; + + commit_reflog = commit_info->util; + if (commit_reflog->recno < 0) { + commit->parents = NULL; + return; + } + + reflog = &commit_reflog->reflogs->items[commit_reflog->recno]; + info->last_commit_reflog = commit_reflog; + commit_reflog->recno--; + commit_info->commit = (struct commit *)parse_object(reflog->osha1); + if (!commit_info->commit) { + commit->parents = NULL; + return; + } + + commit->parents = xcalloc(sizeof(struct commit_list), 1); + commit->parents->item = commit_info->commit; + commit->object.flags &= ~(ADDED | SEEN | SHOWN); +} + +void show_reflog_message(struct reflog_walk_info* info, int oneline) +{ + if (info && info->last_commit_reflog) { + struct commit_reflog *commit_reflog = info->last_commit_reflog; + struct reflog_info *info; + + info = &commit_reflog->reflogs->items[commit_reflog->recno+1]; + if (oneline) { + printf("%s@{", commit_reflog->reflogs->ref); + if (commit_reflog->flag) + printf("%s", show_date(info->timestamp, 0, 1)); + else + printf("%d", commit_reflog->reflogs->nr + - 2 - commit_reflog->recno); + printf("}: %s", info->message); + } + else { + printf("Reflog: %s@{", commit_reflog->reflogs->ref); + if (commit_reflog->flag) + printf("%s", show_rfc2822_date(info->timestamp, + info->tz)); + else + printf("%d", commit_reflog->reflogs->nr + - 2 - commit_reflog->recno); + printf("} (%s)\nReflog message: %s", + info->email, info->message); + } + } +} diff --git a/reflog-walk.h b/reflog-walk.h new file mode 100644 index 0000000000..e63d86778b --- /dev/null +++ b/reflog-walk.h @@ -0,0 +1,11 @@ +#ifndef REFLOG_WALK_H +#define REFLOG_WALK_H + +extern void init_reflog_walk(struct reflog_walk_info** info); +extern void add_reflog_for_walk(struct reflog_walk_info *info, + struct commit *commit, const char *name); +extern void fake_reflog_parent(struct reflog_walk_info *info, + struct commit *commit); +extern void show_reflog_message(struct reflog_walk_info *info, int); + +#endif @@ -331,7 +331,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master) return -1; } lockpath = mkpath("%s.lock", git_HEAD); - fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666); + fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666); + if (fd < 0) { + error("Unable to open %s for writing", lockpath); + return -5; + } written = write_in_full(fd, ref, len); close(fd); if (written != len) { @@ -706,6 +710,8 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1) struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1) { + if (check_ref_format(ref) == -1) + return NULL; return lock_ref_sha1_basic(ref, old_sha1, NULL); } @@ -837,7 +843,12 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) retry: if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) { - if (errno==EISDIR) { + if (errno==EISDIR || errno==ENOTDIR) { + /* + * rename(a, b) when b is an existing + * directory ought to result in ISDIR, but + * Solaris 5.8 gives ENOTDIR. Sheesh. + */ if (remove_empty_directories(git_path("logs/%s", newref))) { error("Directory not empty: logs/%s", newref); goto rollback; @@ -920,6 +931,7 @@ static int log_ref_write(struct ref_lock *lock, { int logfd, written, oflags = O_APPEND | O_WRONLY; unsigned maxlen, len; + int msglen; char *logrec; const char *committer; @@ -953,24 +965,30 @@ static int log_ref_write(struct ref_lock *lock, lock->log_file, strerror(errno)); } - committer = git_committer_info(1); + msglen = 0; if (msg) { - maxlen = strlen(committer) + strlen(msg) + 2*40 + 5; - logrec = xmalloc(maxlen); - len = snprintf(logrec, maxlen, "%s %s %s\t%s\n", - sha1_to_hex(lock->old_sha1), - sha1_to_hex(sha1), - committer, - msg); - } - else { - maxlen = strlen(committer) + 2*40 + 4; - logrec = xmalloc(maxlen); - len = snprintf(logrec, maxlen, "%s %s %s\n", - sha1_to_hex(lock->old_sha1), - sha1_to_hex(sha1), - committer); + /* clean up the message and make sure it is a single line */ + for ( ; *msg; msg++) + if (!isspace(*msg)) + break; + if (*msg) { + const char *ep = strchr(msg, '\n'); + if (ep) + msglen = ep - msg; + else + msglen = strlen(msg); + } } + + committer = git_committer_info(-1); + maxlen = strlen(committer) + msglen + 100; + logrec = xmalloc(maxlen); + len = sprintf(logrec, "%s %s %s\n", + sha1_to_hex(lock->old_sha1), + sha1_to_hex(sha1), + committer); + if (msglen) + len += sprintf(logrec + len - 1, "\t%.*s\n", msglen, msg) - 1; written = len <= maxlen ? write_in_full(logfd, logrec, len) : -1; free(logrec); close(logfd); @@ -1012,7 +1030,21 @@ int write_ref_sha1(struct ref_lock *lock, return 0; } -int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1) +static char *ref_msg(const char *line, const char *endp) +{ + const char *ep; + char *msg; + + line += 82; + for (ep = line; ep < endp && *ep != '\n'; ep++) + ; + msg = xmalloc(ep - line + 1); + memcpy(msg, line, ep - line); + msg[ep - line] = 0; + return msg; +} + +int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt) { const char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec; char *tz_c; @@ -1020,6 +1052,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * struct stat st; unsigned long date; unsigned char logged_sha1[20]; + void *log_mapped; logfile = git_path("logs/%s", ref); logfd = open(logfile, O_RDONLY, 0); @@ -1028,7 +1061,8 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * fstat(logfd, &st); if (!st.st_size) die("Log %s is empty.", logfile); - logdata = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, logfd, 0); + log_mapped = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, logfd, 0); + logdata = log_mapped; close(logfd); lastrec = NULL; @@ -1047,13 +1081,21 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * die("Log %s is corrupt.", logfile); date = strtoul(lastgt + 1, &tz_c, 10); if (date <= at_time || cnt == 0) { + tz = strtoul(tz_c, NULL, 10); + if (msg) + *msg = ref_msg(rec, logend); + if (cutoff_time) + *cutoff_time = date; + if (cutoff_tz) + *cutoff_tz = tz; + if (cutoff_cnt) + *cutoff_cnt = reccnt - 1; if (lastrec) { if (get_sha1_hex(lastrec, logged_sha1)) die("Log %s is corrupt.", logfile); if (get_sha1_hex(rec + 41, sha1)) die("Log %s is corrupt.", logfile); if (hashcmp(logged_sha1, sha1)) { - tz = strtoul(tz_c, NULL, 10); fprintf(stderr, "warning: Log %s has gap after %s.\n", logfile, show_rfc2822_date(date, tz)); @@ -1067,13 +1109,12 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * if (get_sha1_hex(rec + 41, logged_sha1)) die("Log %s is corrupt.", logfile); if (hashcmp(logged_sha1, sha1)) { - tz = strtoul(tz_c, NULL, 10); fprintf(stderr, "warning: Log %s unexpectedly ended on %s.\n", logfile, show_rfc2822_date(date, tz)); } } - munmap((void*)logdata, st.st_size); + munmap(log_mapped, st.st_size); return 0; } lastrec = rec; @@ -1090,14 +1131,17 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * tz = strtoul(tz_c, NULL, 10); if (get_sha1_hex(logdata, sha1)) die("Log %s is corrupt.", logfile); - munmap((void*)logdata, st.st_size); - if (at_time) - fprintf(stderr, "warning: Log %s only goes back to %s.\n", - logfile, show_rfc2822_date(date, tz)); - else - fprintf(stderr, "warning: Log %s only has %d entries.\n", - logfile, reccnt); - return 0; + if (msg) + *msg = ref_msg(logdata, logend); + munmap(log_mapped, st.st_size); + + if (cutoff_time) + *cutoff_time = date; + if (cutoff_tz) + *cutoff_tz = tz; + if (cutoff_cnt) + *cutoff_cnt = reccnt; + return 1; } int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data) @@ -1105,6 +1149,7 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data) const char *logfile; FILE *logfp; char buf[1024]; + int ret = 0; logfile = git_path("logs/%s", ref); logfp = fopen(logfile, "r"); @@ -1114,7 +1159,7 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data) unsigned char osha1[20], nsha1[20]; char *email_end, *message; unsigned long timestamp; - int len, ret, tz; + int len, tz; /* old SP new SP name <email> SP time TAB msg LF */ len = strlen(buf); @@ -1135,9 +1180,9 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data) message += 7; ret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data); if (ret) - return ret; + break; } fclose(logfp); - return 0; + return ret; } @@ -42,7 +42,7 @@ extern void unlock_ref(struct ref_lock *lock); extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg); /** Reads log for the value of ref during at_time. **/ -extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1); +extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt); /* iterate over reflog entries */ typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *); diff --git a/revision.c b/revision.c index f2ddd95e29..5bcd155e21 100644 --- a/revision.c +++ b/revision.c @@ -7,6 +7,7 @@ #include "refs.h" #include "revision.h" #include "grep.h" +#include "reflog-walk.h" static char *path_name(struct name_path *path, const char *name) { @@ -116,6 +117,9 @@ void mark_parents_uninteresting(struct commit *commit) void add_pending_object(struct rev_info *revs, struct object *obj, const char *name) { add_object_array(obj, name, &revs->pending); + if (revs->reflog_info && obj->type == OBJ_COMMIT) + add_reflog_for_walk(revs->reflog_info, + (struct commit *)obj, name); } static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags) @@ -864,6 +868,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch handle_reflog(revs, flags); continue; } + if (!strcmp(arg, "-g") || + !strcmp(arg, "--walk-reflogs")) { + init_reflog_walk(&revs->reflog_info); + continue; + } if (!strcmp(arg, "--not")) { flags ^= UNINTERESTING; continue; @@ -1210,6 +1219,9 @@ static struct commit *get_revision_1(struct rev_info *revs) revs->commits = entry->next; free(entry); + if (revs->reflog_info) + fake_reflog_parent(revs->reflog_info, commit); + /* * If we haven't done the list limiting, we need to look at * the parents here. We also need to do the date-based limiting diff --git a/revision.h b/revision.h index 8f7907d7ab..d93481f68f 100644 --- a/revision.h +++ b/revision.h @@ -89,6 +89,8 @@ struct rev_info { topo_sort_set_fn_t topo_setter; topo_sort_get_fn_t topo_getter; + + struct reflog_walk_info *reflog_info; }; #define REV_TREE_SAME 0 diff --git a/send-pack.c b/send-pack.c index 6756264b29..33e69dbe18 100644 --- a/send-pack.c +++ b/send-pack.c @@ -6,9 +6,9 @@ #include "exec_cmd.h" static const char send_pack_usage[] = -"git-send-pack [--all] [--exec=git-receive-pack] <remote> [<head>...]\n" -" --all and explicit <head> specification are mutually exclusive."; -static const char *exec = "git-receive-pack"; +"git-send-pack [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n" +" --all and explicit <ref> specification are mutually exclusive."; +static const char *receivepack = "git-receive-pack"; static int verbose; static int send_all; static int force_update; @@ -25,6 +25,8 @@ static int pack_objects(int fd, struct ref *refs) if (pipe(pipe_fd) < 0) return error("send-pack: pipe failed"); pid = fork(); + if (pid < 0) + return error("send-pack: unable to fork git-pack-objects"); if (!pid) { /* * The child becomes pack-objects --revs; we feed @@ -377,8 +379,12 @@ int main(int argc, char **argv) char *arg = *argv; if (*arg == '-') { + if (!strncmp(arg, "--receive-pack=", 15)) { + receivepack = arg + 15; + continue; + } if (!strncmp(arg, "--exec=", 7)) { - exec = arg + 7; + receivepack = arg + 7; continue; } if (!strcmp(arg, "--all")) { @@ -413,7 +419,7 @@ int main(int argc, char **argv) usage(send_pack_usage); verify_remote_names(nr_heads, heads); - pid = git_connect(fd, dest, exec); + pid = git_connect(fd, dest, receivepack); if (pid < 0) return 1; ret = send_pack(fd[0], fd[1], nr_heads, heads); @@ -95,6 +95,8 @@ void verify_non_filename(const char *prefix, const char *arg) const char *name; struct stat st; + if (is_inside_git_dir()) + return; if (*arg == '-') return; /* flag */ name = prefix ? prefix_filename(prefix, strlen(prefix), arg) : arg; @@ -168,6 +170,28 @@ static int is_git_directory(const char *suspect) return 1; } +static int inside_git_dir = -1; + +int is_inside_git_dir(void) +{ + if (inside_git_dir < 0) { + char buffer[1024]; + + if (is_bare_repository()) + return (inside_git_dir = 1); + if (getcwd(buffer, sizeof(buffer))) { + const char *git_dir = get_git_dir(), *cwd = buffer; + while (*git_dir && *git_dir == *cwd) { + git_dir++; + cwd++; + } + inside_git_dir = !*git_dir; + } else + inside_git_dir = 0; + } + return inside_git_dir; +} + const char *setup_git_directory_gently(int *nongit_ok) { static char cwd[PATH_MAX+1]; @@ -206,6 +230,7 @@ const char *setup_git_directory_gently(int *nongit_ok) if (chdir(cwd)) die("Cannot come back to cwd"); setenv(GIT_DIR_ENVIRONMENT, cwd, 1); + inside_git_dir = 1; return NULL; } if (nongit_ok) { @@ -226,6 +251,7 @@ const char *setup_git_directory_gently(int *nongit_ok) offset++; cwd[len++] = '/'; cwd[len] = 0; + inside_git_dir = !strncmp(cwd + offset, ".git/", 5); return cwd + offset; } diff --git a/sha1_file.c b/sha1_file.c index 2a5be53fac..498665e50c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -435,7 +435,7 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_, void **idx_map_) { void *idx_map; - unsigned int *index; + uint32_t *index; unsigned long idx_size; int nr, i; int fd = open(path, O_RDONLY); @@ -456,12 +456,23 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_, /* check index map */ if (idx_size < 4*256 + 20 + 20) - return error("index file too small"); + return error("index file %s is too small", path); + + /* a future index format would start with this, as older git + * binaries would fail the non-monotonic index check below. + * give a nicer warning to the user if we can. + */ + if (index[0] == htonl(PACK_IDX_SIGNATURE)) + return error("index file %s is a newer version" + " and is not supported by this binary" + " (try upgrading GIT to a newer version)", + path); + nr = 0; for (i = 0; i < 256; i++) { unsigned int n = ntohl(index[i]); if (n < nr) - return error("non-monotonic index"); + return error("non-monotonic index %s", path); nr = n; } @@ -473,7 +484,7 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_, * - 20-byte SHA1 file checksum */ if (idx_size != 4*256 + nr * 24 + 20 + 20) - return error("wrong index file size"); + return error("wrong index file size in %s", path); return 0; } @@ -572,7 +583,8 @@ static void open_packed_git(struct packed_git *p) die("cannot set FD_CLOEXEC"); /* Verify we recognize this pack file format. */ - read_or_die(p->pack_fd, &hdr, sizeof(hdr)); + if (read_in_full(p->pack_fd, &hdr, sizeof(hdr)) != sizeof(hdr)) + die("file %s is far too short to be a packfile", p->pack_name); if (hdr.hdr_signature != htonl(PACK_SIGNATURE)) die("file %s is not a GIT packfile", p->pack_name); if (!pack_version_ok(hdr.hdr_version)) @@ -588,7 +600,8 @@ static void open_packed_git(struct packed_git *p) num_packed_objects(p)); if (lseek(p->pack_fd, p->pack_size - sizeof(sha1), SEEK_SET) == -1) die("end of packfile %s is unavailable", p->pack_name); - read_or_die(p->pack_fd, sha1, sizeof(sha1)); + if (read_in_full(p->pack_fd, sha1, sizeof(sha1)) != sizeof(sha1)) + die("packfile %s signature is unavailable", p->pack_name); idx_sha1 = ((unsigned char *)p->index_base) + p->index_size - 40; if (hashcmp(sha1, idx_sha1)) die("packfile %s does not match index", p->pack_name); @@ -1338,7 +1351,7 @@ int nth_packed_object_sha1(const struct packed_git *p, int n, unsigned long find_pack_entry_one(const unsigned char *sha1, struct packed_git *p) { - unsigned int *level1_ofs = p->index_base; + uint32_t *level1_ofs = p->index_base; int hi = ntohl(level1_ofs[*sha1]); int lo = ((*sha1 == 0x0) ? 0 : ntohl(level1_ofs[*sha1 - 1])); void *index = p->index_base + 256; @@ -1347,7 +1360,7 @@ unsigned long find_pack_entry_one(const unsigned char *sha1, int mi = (lo + hi) / 2; int cmp = hashcmp((unsigned char *)index + (24 * mi) + 4, sha1); if (!cmp) - return ntohl(*((unsigned int *) ((char *) index + (24 * mi)))); + return ntohl(*((uint32_t *)((char *)index + (24 * mi)))); if (cmp > 0) hi = mi; else @@ -1456,21 +1469,20 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo { struct pack_entry e; - if (!find_pack_entry(sha1, &e, NULL)) { - error("cannot read sha1_file for %s", sha1_to_hex(sha1)); + if (!find_pack_entry(sha1, &e, NULL)) return NULL; - } - return unpack_entry(e.p, e.offset, type, size); + else + return unpack_entry(e.p, e.offset, type, size); } void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size) { unsigned long mapsize; void *map, *buf; - struct pack_entry e; - if (find_pack_entry(sha1, &e, NULL)) - return read_packed_sha1(sha1, type, size); + buf = read_packed_sha1(sha1, type, size); + if (buf) + return buf; map = map_sha1_file(sha1, &mapsize); if (map) { buf = unpack_sha1_file(map, mapsize, type, size); @@ -1478,9 +1490,7 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size return buf; } reprepare_packed_git(); - if (find_pack_entry(sha1, &e, NULL)) - return read_packed_sha1(sha1, type, size); - return NULL; + return read_packed_sha1(sha1, type, size); } void *read_object_with_reference(const unsigned char *sha1, @@ -1768,6 +1778,8 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize) /* need to unpack and recompress it by itself */ unpacked = read_packed_sha1(sha1, type, &len); + if (!unpacked) + error("cannot read sha1_file for %s", sha1_to_hex(sha1)); hdrlen = sprintf(hdr, "%s %lu", type, len) + 1; @@ -2036,3 +2048,24 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write } return 0; } + +int read_pack_header(int fd, struct pack_header *header) +{ + char *c = (char*)header; + ssize_t remaining = sizeof(struct pack_header); + do { + ssize_t r = xread(fd, c, remaining); + if (r <= 0) + /* "eof before pack header was fully read" */ + return PH_ERROR_EOF; + remaining -= r; + c += r; + } while (remaining > 0); + if (header->hdr_signature != htonl(PACK_SIGNATURE)) + /* "protocol error (pack signature mismatch detected)" */ + return PH_ERROR_PACK_SIGNATURE; + if (!pack_version_ok(header->hdr_version)) + /* "protocol error (pack version unsupported)" */ + return PH_ERROR_PROTOCOL; + return 0; +} diff --git a/sha1_name.c b/sha1_name.c index 6d7cd78381..9dfb3ac574 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -235,7 +235,7 @@ static int ambiguous_path(const char *path, int len) return slash; } -static int get_sha1_basic(const char *str, int len, unsigned char *sha1) +int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref) { static const char *fmt[] = { "%.*s", @@ -246,13 +246,32 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) "refs/remotes/%.*s/HEAD", NULL }; + const char **p, *r; + int refs_found = 0; + + *ref = NULL; + for (p = fmt; *p; p++) { + unsigned char sha1_from_ref[20]; + unsigned char *this_result; + + this_result = refs_found ? sha1_from_ref : sha1; + r = resolve_ref(mkpath(*p, len, str), this_result, 1, NULL); + if (r) { + if (!refs_found++) + *ref = xstrdup(r); + if (!warn_ambiguous_refs) + break; + } + } + return refs_found; +} + +static int get_sha1_basic(const char *str, int len, unsigned char *sha1) +{ static const char *warning = "warning: refname '%.*s' is ambiguous.\n"; - const char **p, *ref; char *real_ref = NULL; int refs_found = 0; int at, reflog_len; - unsigned char *this_result; - unsigned char sha1_from_ref[20]; if (len == 40 && !get_sha1_hex(str, sha1)) return 0; @@ -273,16 +292,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) if (ambiguous_path(str, len)) return -1; - for (p = fmt; *p; p++) { - this_result = refs_found ? sha1_from_ref : sha1; - ref = resolve_ref(mkpath(*p, len, str), this_result, 1, NULL); - if (ref) { - if (!refs_found++) - real_ref = xstrdup(ref); - if (!warn_ambiguous_refs) - break; - } - } + refs_found = dwim_ref(str, len, sha1, &real_ref); if (!refs_found) return -1; @@ -294,6 +304,9 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) /* Is it asking for N-th entry, or approxidate? */ int nth, i; unsigned long at_time; + unsigned long co_time; + int co_tz, co_cnt; + for (i = nth = 0; 0 <= nth && i < reflog_len; i++) { char ch = str[at+2+i]; if ('0' <= ch && ch <= '9') @@ -305,7 +318,18 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) at_time = 0; else at_time = approxidate(str + at + 2); - read_ref_at(real_ref, at_time, nth, sha1); + if (read_ref_at(real_ref, at_time, nth, sha1, NULL, + &co_time, &co_tz, &co_cnt)) { + if (at_time) + fprintf(stderr, + "warning: Log for '%.*s' only goes " + "back to %s.\n", len, str, + show_rfc2822_date(co_time, co_tz)); + else + fprintf(stderr, + "warning: Log for '%.*s' only has " + "%d entries.\n", len, str, co_cnt); + } } free(real_ref); @@ -17,7 +17,7 @@ int register_shallow(const unsigned char *sha1) return register_commit_graft(graft, 0); } -int is_repository_shallow() +int is_repository_shallow(void) { FILE *fp; char buf[1024]; diff --git a/ssh-fetch.c b/ssh-fetch.c index 4c172b6824..bdf51a7a14 100644 --- a/ssh-fetch.c +++ b/ssh-fetch.c @@ -124,7 +124,6 @@ int main(int argc, char **argv) prog = getenv("GIT_SSH_PUSH"); if (!prog) prog = "git-ssh-upload"; - setup_ident(); setup_git_directory(); git_config(git_default_config); diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index a0f2814083..bb1d7b84bc 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -26,7 +26,7 @@ use SVN::Core; use SVN::Repos; \$SVN::Core::VERSION gt '1.1.0' or exit(42); system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41); -" +" >&3 2>&4 x=$? if test $x -ne 0 then diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 4409b87f8d..c090c96185 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -106,4 +106,33 @@ test_expect_success 'read-tree' ' cmp ../one ../original.one ' +test_expect_success 'no file/rev ambuguity check inside .git' ' + cd $HERE && + git commit -a -m 1 && + cd $HERE/.git && + git show -s HEAD +' + +test_expect_success 'no file/rev ambuguity check inside a bare repo' ' + cd $HERE && + git clone -s --bare .git foo.git && + cd foo.git && GIT_DIR=. git show -s HEAD +' + +# This still does not work as it should... +: test_expect_success 'no file/rev ambuguity check inside a bare repo' ' + cd $HERE && + git clone -s --bare .git foo.git && + cd foo.git && git show -s HEAD +' + +test_expect_success 'detection should not be fooled by a symlink' ' + cd $HERE && + rm -fr foo.git && + git clone -s .git another && + ln -s another yetanother && + cd yetanother/.git && + git show -s HEAD +' + test_done diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 60acdd368b..49b5666b33 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -3,13 +3,13 @@ # Copyright (c) 2005 Johannes Schindelin # -test_description='Test git-repo-config in different settings' +test_description='Test git-config in different settings' . ./test-lib.sh test -f .git/config && rm .git/config -git-repo-config core.penguin "little blue" +git-config core.penguin "little blue" cat > expect << EOF [core] @@ -18,7 +18,7 @@ EOF test_expect_success 'initial' 'cmp .git/config expect' -git-repo-config Core.Movie BadPhysics +git-config Core.Movie BadPhysics cat > expect << EOF [core] @@ -28,7 +28,7 @@ EOF test_expect_success 'mixed case' 'cmp .git/config expect' -git-repo-config Cores.WhatEver Second +git-config Cores.WhatEver Second cat > expect << EOF [core] @@ -40,7 +40,7 @@ EOF test_expect_success 'similar section' 'cmp .git/config expect' -git-repo-config CORE.UPPERCASE true +git-config CORE.UPPERCASE true cat > expect << EOF [core] @@ -54,10 +54,10 @@ EOF test_expect_success 'similar section' 'cmp .git/config expect' test_expect_success 'replace with non-match' \ - 'git-repo-config core.penguin kingpin !blue' + 'git-config core.penguin kingpin !blue' test_expect_success 'replace with non-match (actually matching)' \ - 'git-repo-config core.penguin "very blue" !kingpin' + 'git-config core.penguin "very blue" !kingpin' cat > expect << EOF [core] @@ -86,7 +86,7 @@ EOF cp .git/config .git/config2 test_expect_success 'multiple unset' \ - 'git-repo-config --unset-all beta.haha' + 'git-config --unset-all beta.haha' cat > expect << EOF [beta] ; silly comment # another comment @@ -102,7 +102,7 @@ test_expect_success 'multiple unset is correct' 'cmp .git/config expect' mv .git/config2 .git/config test_expect_success '--replace-all' \ - 'git-repo-config --replace-all beta.haha gamma' + 'git-config --replace-all beta.haha gamma' cat > expect << EOF [beta] ; silly comment # another comment @@ -116,7 +116,7 @@ EOF test_expect_success 'all replaced' 'cmp .git/config expect' -git-repo-config beta.haha alpha +git-config beta.haha alpha cat > expect << EOF [beta] ; silly comment # another comment @@ -130,7 +130,7 @@ EOF test_expect_success 'really mean test' 'cmp .git/config expect' -git-repo-config nextsection.nonewline wow +git-config nextsection.nonewline wow cat > expect << EOF [beta] ; silly comment # another comment @@ -145,8 +145,8 @@ EOF test_expect_success 'really really mean test' 'cmp .git/config expect' -test_expect_success 'get value' 'test alpha = $(git-repo-config beta.haha)' -git-repo-config --unset beta.haha +test_expect_success 'get value' 'test alpha = $(git-config beta.haha)' +git-config --unset beta.haha cat > expect << EOF [beta] ; silly comment # another comment @@ -160,7 +160,7 @@ EOF test_expect_success 'unset' 'cmp .git/config expect' -git-repo-config nextsection.NoNewLine "wow2 for me" "for me$" +git-config nextsection.NoNewLine "wow2 for me" "for me$" cat > expect << EOF [beta] ; silly comment # another comment @@ -176,18 +176,18 @@ EOF test_expect_success 'multivar' 'cmp .git/config expect' test_expect_success 'non-match' \ - 'git-repo-config --get nextsection.nonewline !for' + 'git-config --get nextsection.nonewline !for' test_expect_success 'non-match value' \ - 'test wow = $(git-repo-config --get nextsection.nonewline !for)' + 'test wow = $(git-config --get nextsection.nonewline !for)' test_expect_failure 'ambiguous get' \ - 'git-repo-config --get nextsection.nonewline' + 'git-config --get nextsection.nonewline' test_expect_success 'get multivar' \ - 'git-repo-config --get-all nextsection.nonewline' + 'git-config --get-all nextsection.nonewline' -git-repo-config nextsection.nonewline "wow3" "wow$" +git-config nextsection.nonewline "wow3" "wow$" cat > expect << EOF [beta] ; silly comment # another comment @@ -202,15 +202,15 @@ EOF test_expect_success 'multivar replace' 'cmp .git/config expect' -test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline' +test_expect_failure 'ambiguous value' 'git-config nextsection.nonewline' test_expect_failure 'ambiguous unset' \ - 'git-repo-config --unset nextsection.nonewline' + 'git-config --unset nextsection.nonewline' test_expect_failure 'invalid unset' \ - 'git-repo-config --unset somesection.nonewline' + 'git-config --unset somesection.nonewline' -git-repo-config --unset nextsection.nonewline "wow3$" +git-config --unset nextsection.nonewline "wow3$" cat > expect << EOF [beta] ; silly comment # another comment @@ -224,12 +224,12 @@ EOF test_expect_success 'multivar unset' 'cmp .git/config expect' -test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla' +test_expect_failure 'invalid key' 'git-config inval.2key blabla' -test_expect_success 'correct key' 'git-repo-config 123456.a123 987' +test_expect_success 'correct key' 'git-config 123456.a123 987' test_expect_success 'hierarchical section' \ - 'git-repo-config Version.1.2.3eX.Alpha beta' + 'git-config Version.1.2.3eX.Alpha beta' cat > expect << EOF [beta] ; silly comment # another comment @@ -255,7 +255,7 @@ version.1.2.3eX.alpha=beta EOF test_expect_success 'working --list' \ - 'git-repo-config --list > output && cmp output expect' + 'git-config --list > output && cmp output expect' cat > expect << EOF beta.noindent sillyValue @@ -263,9 +263,9 @@ nextsection.nonewline wow2 for me EOF test_expect_success '--get-regexp' \ - 'git-repo-config --get-regexp in > output && cmp output expect' + 'git-config --get-regexp in > output && cmp output expect' -git-repo-config --add nextsection.nonewline "wow4 for you" +git-config --add nextsection.nonewline "wow4 for you" cat > expect << EOF wow2 for me @@ -273,7 +273,7 @@ wow4 for you EOF test_expect_success '--add' \ - 'git-repo-config --get-all nextsection.nonewline > output && cmp output expect' + 'git-config --get-all nextsection.nonewline > output && cmp output expect' cat > .git/config << EOF [novalue] @@ -281,9 +281,9 @@ cat > .git/config << EOF EOF test_expect_success 'get variable with no value' \ - 'git-repo-config --get novalue.variable ^$' + 'git-config --get novalue.variable ^$' -git-repo-config > output 2>&1 +git-config > output 2>&1 test_expect_success 'no arguments, but no crash' \ "test $? = 129 && grep usage output" @@ -293,7 +293,7 @@ cat > .git/config << EOF c = d EOF -git-repo-config a.x y +git-config a.x y cat > expect << EOF [a.b] @@ -304,8 +304,8 @@ EOF test_expect_success 'new section is partial match of another' 'cmp .git/config expect' -git-repo-config b.x y -git-repo-config a.b c +git-config b.x y +git-config a.b c cat > expect << EOF [a.b] @@ -328,11 +328,11 @@ cat > expect << EOF ein.bahn=strasse EOF -GIT_CONFIG=other-config git-repo-config -l > output +GIT_CONFIG=other-config git-config -l > output test_expect_success 'alternative GIT_CONFIG' 'cmp output expect' -GIT_CONFIG=other-config git-repo-config anwohner.park ausweis +GIT_CONFIG=other-config git-config anwohner.park ausweis cat > expect << EOF [ein] @@ -355,7 +355,7 @@ weird EOF test_expect_success "rename section" \ - "git-repo-config --rename-section branch.eins branch.zwei" + "git-config --rename-section branch.eins branch.zwei" cat > expect << EOF # Hallo @@ -371,12 +371,12 @@ EOF test_expect_success "rename succeeded" "diff -u expect .git/config" test_expect_failure "rename non-existing section" \ - 'git-repo-config --rename-section branch."world domination" branch.drei' + 'git-config --rename-section branch."world domination" branch.drei' test_expect_success "rename succeeded" "diff -u expect .git/config" test_expect_success "rename another section" \ - 'git-repo-config --rename-section branch."1 234 blabl/a" branch.drei' + 'git-config --rename-section branch."1 234 blabl/a" branch.drei' cat > expect << EOF # Hallo @@ -393,20 +393,20 @@ test_expect_success "rename succeeded" "diff -u expect .git/config" test_expect_success numbers ' - git-repo-config kilo.gram 1k && - git-repo-config mega.ton 1m && - k=$(git-repo-config --int --get kilo.gram) && + git-config kilo.gram 1k && + git-config mega.ton 1m && + k=$(git-config --int --get kilo.gram) && test z1024 = "z$k" && - m=$(git-repo-config --int --get mega.ton) && + m=$(git-config --int --get mega.ton) && test z1048576 = "z$m" ' rm .git/config -git-repo-config quote.leading " test" -git-repo-config quote.ending "test " -git-repo-config quote.semicolon "test;test" -git-repo-config quote.hash "test#test" +git-config quote.leading " test" +git-config quote.ending "test " +git-config quote.semicolon "test;test" +git-config quote.hash "test#test" cat > expect << EOF [quote] @@ -418,5 +418,31 @@ EOF test_expect_success 'quoting' 'cmp .git/config expect' +test_expect_failure 'key with newline' 'git config key.with\\\ +newline 123' + +test_expect_success 'value with newline' 'git config key.sub value.with\\\ +newline' + +cat > .git/config <<\EOF +[section] + ; comment \ + continued = cont\ +inued + noncont = not continued ; \ + quotecont = "cont;\ +inued" +EOF + +cat > expect <<\EOF +section.continued=continued +section.noncont=not continued +section.quotecont=cont;inued +EOF + +git config --list > result + +test_expect_success 'value continued on next line' 'cmp result expect' + test_done diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 5637cb5eac..d0aba2c2ae 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -93,8 +93,8 @@ rm -rf .git/$m .git/logs expect test_expect_success \ 'enable core.logAllRefUpdates' \ - 'git-repo-config core.logAllRefUpdates true && - test true = $(git-repo-config --bool --get core.logAllRefUpdates)' + 'git-config core.logAllRefUpdates true && + test true = $(git-config --bool --get core.logAllRefUpdates)' test_expect_success \ "create $m (logged by config)" \ @@ -138,19 +138,19 @@ test_expect_success \ 'rm -f o e git-rev-parse --verify "master@{May 25 2005}" >o 2>e && test '"$C"' = $(cat o) && - test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"' + test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' test_expect_success \ "Query master@{2005-05-25} (before history)" \ 'rm -f o e git-rev-parse --verify master@{2005-05-25} >o 2>e && test '"$C"' = $(cat o) && - echo test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"' + echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' test_expect_success \ 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \ 'rm -f o e git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && test '"$C"' = $(cat o) && - test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"' + test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"' test_expect_success \ 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \ 'rm -f o e diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 8e8d526ef2..e5bbc384f7 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -20,7 +20,7 @@ check_have () { } check_fsck () { - output=$(git fsck-objects --full) + output=$(git fsck --full) case "$1" in '') test -z "$output" ;; @@ -71,7 +71,7 @@ test_expect_success setup ' check_fsck && chmod +x C && - ( test "`git repo-config --bool core.filemode`" != false || + ( test "`git config --bool core.filemode`" != false || echo executable >>C ) && git add C && test_tick && git commit -m dragon && diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index bb80e4286a..5565c27033 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -94,7 +94,7 @@ test_expect_failure \ git-branch r && git-branch -m q r/q' -git-repo-config branch.s/s.dummy Hello +git-config branch.s/s.dummy Hello test_expect_success \ 'git branch -m s/s s should work when s/t is deleted' \ @@ -107,8 +107,8 @@ test_expect_success \ test -f .git/logs/refs/heads/s' test_expect_success 'config information was renamed, too' \ - "test $(git-repo-config branch.s.dummy) = Hello && - ! git-repo-config branch.s/s/dummy" + "test $(git-config branch.s.dummy) = Hello && + ! git-config branch.s/s/dummy" test_expect_failure \ 'git-branch -m u v should fail when the reflog for u is a symlink' \ diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 16bdae4f23..f0c7e22b36 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -96,4 +96,13 @@ test_expect_success \ git-branch -d n/o/p && git-branch n' +test_expect_success 'pack, prune and repack' ' + git-tag foo && + git-pack-refs --all --prune && + git-show-ref >all-of-them && + git-pack-refs && + git-show-ref >again && + diff all-of-them again +' + test_done diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh new file mode 100755 index 0000000000..552af1c4d2 --- /dev/null +++ b/t/t3501-revert-cherry-pick.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +test_description='test cherry-pick and revert with renames + + -- + + rename2: renames oops to opos + + rename1: renames oops to spoo + + added: adds extra line to oops + ++ initial: has lines in oops + +' + +. ./test-lib.sh + +test_expect_success setup ' + + for l in a b c d e f g h i j k l m n o + do + echo $l$l$l$l$l$l$l$l$l + done >oops && + + test_tick && + git add oops && + git commit -m initial && + git tag initial && + + test_tick && + echo "Add extra line at the end" >>oops && + git commit -a -m added && + git tag added && + + test_tick && + git mv oops spoo && + git commit -m rename1 && + git tag rename1 && + + test_tick && + git checkout -b side initial && + git mv oops opos && + git commit -m rename2 && + git tag rename2 +' + +test_expect_success 'cherry-pick after renaming branch' ' + + git checkout rename2 && + EDITOR=: VISUAL=: git cherry-pick added && + test -f opos && + grep "Add extra line at the end" opos + +' + +test_expect_success 'revert after renaming branch' ' + + git checkout rename1 && + EDITOR=: VISUAL=: git revert added && + test -f spoo && + ! grep "Add extra line at the end" spoo + +' + +test_done diff --git a/t/t3700-add.sh b/t/t3700-add.sh index e98786de32..caaab26c2f 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -21,7 +21,7 @@ test_expect_success \ test_expect_success \ 'git-add: Test that executable bit is not used if core.filemode=0' \ - 'git repo-config core.filemode 0 && + 'git config core.filemode 0 && echo foo >xfoo1 && chmod 755 xfoo1 && git-add xfoo1 && @@ -32,7 +32,7 @@ test_expect_success \ test_expect_success \ 'git-update-index --add: Test that executable bit is not used...' \ - 'git repo-config core.filemode 0 && + 'git config core.filemode 0 && echo foo >xfoo2 && chmod 755 xfoo2 && git-update-index --add xfoo2 && @@ -43,7 +43,7 @@ test_expect_success \ test_expect_success \ 'git-update-index --add: Test that executable bit is not used...' \ - 'git repo-config core.filemode 0 && + 'git config core.filemode 0 && ln -s xfoo2 xfoo3 && git-update-index --add xfoo3 && case "`git-ls-files --stage xfoo3`" in diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 5b23b7769d..ede4d42495 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -88,7 +88,7 @@ check_verify_failure '"type" line label check' # 5. type line eol check echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig -echo -n "type tagsssssssssssssssssssssssssssssss" >>tag.sig +printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig cat >expect.pat <<EOF ^error: char48: .*"[\]n"$ diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index 6714b0dd6e..e54fe0f401 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -29,7 +29,7 @@ test_expect_success 'no encoding header for base case' ' for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "$H setup" ' - git-repo-config i18n.commitencoding $H && + git-config i18n.commitencoding $H && git-checkout -b $H C0 && echo $H >F && git-commit -a -F ../t3900/$H.txt @@ -44,16 +44,16 @@ do ' done -test_expect_success 'repo-config to remove customization' ' - git-repo-config --unset-all i18n.commitencoding && - if Z=$(git-repo-config --get-all i18n.commitencoding) +test_expect_success 'config to remove customization' ' + git-config --unset-all i18n.commitencoding && + if Z=$(git-config --get-all i18n.commitencoding) then echo Oops, should have failed. false else test z = "z$Z" fi && - git-repo-config i18n.commitencoding utf-8 + git-config i18n.commitencoding utf-8 ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' @@ -67,9 +67,9 @@ do ' done -test_expect_success 'repo-config to add customization' ' - git-repo-config --unset-all i18n.commitencoding && - if Z=$(git-repo-config --get-all i18n.commitencoding) +test_expect_success 'config to add customization' ' + git-config --unset-all i18n.commitencoding && + if Z=$(git-config --get-all i18n.commitencoding) then echo Oops, should have failed. false @@ -81,13 +81,13 @@ test_expect_success 'repo-config to add customization' ' for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "$H should be shown in itself now" ' - git-repo-config i18n.commitencoding '$H' && + git-config i18n.commitencoding '$H' && compare_with '$H' ../t3900/'$H'.txt ' done -test_expect_success 'repo-config to tweak customization' ' - git-repo-config i18n.logoutputencoding utf-8 +test_expect_success 'config to tweak customization' ' + git-config i18n.logoutputencoding utf-8 ' test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' @@ -103,7 +103,7 @@ done for J in EUCJP ISO-2022-JP do - git-repo-config i18n.logoutputencoding $J + git-config i18n.logoutputencoding $J for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in $J now" ' diff --git a/t/t3901-8859-1.txt b/t/t3901-8859-1.txt new file mode 100755 index 0000000000..38c21a6a7f --- /dev/null +++ b/t/t3901-8859-1.txt @@ -0,0 +1,4 @@ +: to be sourced in t3901 -- this is latin-1 +GIT_AUTHOR_NAME="Áéí óú" && +GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME && +export GIT_AUTHOR_NAME GIT_COMMITTER_NAME diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh new file mode 100755 index 0000000000..a881797bc7 --- /dev/null +++ b/t/t3901-i18n-patch.sh @@ -0,0 +1,255 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='i18n settings and format-patch | am pipe' + +. ./test-lib.sh + +check_encoding () { + # Make sure characters are not corrupted + cnt="$1" header="$2" i=1 j=0 bad=0 + while test "$i" -le $cnt + do + git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j | + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" && + git-cat-file commit HEAD~$j | + case "$header" in + 8859) + grep "^encoding ISO-8859-1" ;; + *) + ! grep "^encoding ISO-8859-1" ;; + esac || { + bad=1 + break + } + j=$i + i=$(($i+1)) + done + (exit $bad) +} + +test_expect_success setup ' + git-config i18n.commitencoding UTF-8 && + + # use UTF-8 in author and committer name to match the + # i18n.commitencoding settings + . ../t3901-utf8.txt && + + test_tick && + echo "$GIT_AUTHOR_NAME" >mine && + git add mine && + git commit -s -m "Initial commit" && + + test_tick && + echo Hello world >mine && + git add mine && + git commit -s -m "Second on main" && + + # the first commit on the side branch is UTF-8 + test_tick && + git checkout -b side master^ && + echo Another file >yours && + git add yours && + git commit -s -m "Second on side" && + + # the second one on the side branch is ISO-8859-1 + git-config i18n.commitencoding ISO-8859-1 && + # use author and committer name in ISO-8859-1 to match it. + . ../t3901-8859-1.txt && + test_tick && + echo Yet another >theirs && + git add theirs && + git commit -s -m "Third on side" && + + # Back to default + git-config i18n.commitencoding UTF-8 +' + +test_expect_success 'format-patch output (ISO-8859-1)' ' + git-config i18n.logoutputencoding ISO-8859-1 && + + git format-patch --stdout master..HEAD^ >out-l1 && + git format-patch --stdout HEAD^ >out-l2 && + grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 && + grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l1 && + grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 && + grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l2 +' + +test_expect_success 'format-patch output (UTF-8)' ' + git config i18n.logoutputencoding UTF-8 && + + git format-patch --stdout master..HEAD^ >out-u1 && + git format-patch --stdout HEAD^ >out-u2 && + grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u1 && + grep "^Content-Type: text/plain; charset=UTF-8" out-u2 && + grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u2 +' + +test_expect_success 'rebase (U/U)' ' + # We want the result of rebase in UTF-8 + git-config i18n.commitencoding UTF-8 && + + # The test is about logoutputencoding not affecting the + # final outcome -- it is used internally to generate the + # patch and the log. + + git config i18n.logoutputencoding UTF-8 && + + # The result will be committed by GIT_COMMITTER_NAME -- + # we want UTF-8 encoded name. + . ../t3901-utf8.txt && + git checkout -b test && + git-rebase master && + + check_encoding 2 +' + +test_expect_success 'rebase (U/L)' ' + git-config i18n.commitencoding UTF-8 && + git config i18n.logoutputencoding ISO-8859-1 && + . ../t3901-utf8.txt && + + git reset --hard side && + git-rebase master && + + check_encoding 2 +' + +test_expect_success 'rebase (L/L)' ' + # In this test we want ISO-8859-1 encoded commits as the result + git-config i18n.commitencoding ISO-8859-1 && + git config i18n.logoutputencoding ISO-8859-1 && + . ../t3901-8859-1.txt && + + git reset --hard side && + git-rebase master && + + check_encoding 2 8859 +' + +test_expect_success 'rebase (L/U)' ' + # This is pathological -- use UTF-8 as intermediate form + # to get ISO-8859-1 results. + git-config i18n.commitencoding ISO-8859-1 && + git config i18n.logoutputencoding UTF-8 && + . ../t3901-8859-1.txt && + + git reset --hard side && + git-rebase master && + + check_encoding 2 8859 +' + +test_expect_success 'cherry-pick(U/U)' ' + # Both the commitencoding and logoutputencoding is set to UTF-8. + + git-config i18n.commitencoding UTF-8 && + git config i18n.logoutputencoding UTF-8 && + . ../t3901-utf8.txt && + + git reset --hard master && + git cherry-pick side^ && + git cherry-pick side && + EDITOR=: VISUAL=: git revert HEAD && + + check_encoding 3 +' + +test_expect_success 'cherry-pick(L/L)' ' + # Both the commitencoding and logoutputencoding is set to ISO-8859-1 + + git-config i18n.commitencoding ISO-8859-1 && + git config i18n.logoutputencoding ISO-8859-1 && + . ../t3901-8859-1.txt && + + git reset --hard master && + git cherry-pick side^ && + git cherry-pick side && + EDITOR=: VISUAL=: git revert HEAD && + + check_encoding 3 8859 +' + +test_expect_success 'cherry-pick(U/L)' ' + # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1 + + git-config i18n.commitencoding UTF-8 && + git config i18n.logoutputencoding ISO-8859-1 && + . ../t3901-utf8.txt && + + git reset --hard master && + git cherry-pick side^ && + git cherry-pick side && + EDITOR=: VISUAL=: git revert HEAD && + + check_encoding 3 +' + +test_expect_success 'cherry-pick(L/U)' ' + # Again, the commitencoding is set to ISO-8859-1 but + # logoutputencoding is set to UTF-8. + + git-config i18n.commitencoding ISO-8859-1 && + git config i18n.logoutputencoding UTF-8 && + . ../t3901-8859-1.txt && + + git reset --hard master && + git cherry-pick side^ && + git cherry-pick side && + EDITOR=: VISUAL=: git revert HEAD && + + check_encoding 3 8859 +' + +test_expect_success 'rebase --merge (U/U)' ' + git-config i18n.commitencoding UTF-8 && + git config i18n.logoutputencoding UTF-8 && + . ../t3901-utf8.txt && + + git reset --hard side && + git-rebase --merge master && + + check_encoding 2 +' + +test_expect_success 'rebase --merge (U/L)' ' + git-config i18n.commitencoding UTF-8 && + git config i18n.logoutputencoding ISO-8859-1 && + . ../t3901-utf8.txt && + + git reset --hard side && + git-rebase --merge master && + + check_encoding 2 +' + +test_expect_success 'rebase --merge (L/L)' ' + # In this test we want ISO-8859-1 encoded commits as the result + git-config i18n.commitencoding ISO-8859-1 && + git config i18n.logoutputencoding ISO-8859-1 && + . ../t3901-8859-1.txt && + + git reset --hard side && + git-rebase --merge master && + + check_encoding 2 8859 +' + +test_expect_success 'rebase --merge (L/U)' ' + # This is pathological -- use UTF-8 as intermediate form + # to get ISO-8859-1 results. + git-config i18n.commitencoding ISO-8859-1 && + git config i18n.logoutputencoding UTF-8 && + . ../t3901-8859-1.txt && + + git reset --hard side && + git-rebase --merge master && + + check_encoding 2 8859 +' + +test_done diff --git a/t/t3901-utf8.txt b/t/t3901-utf8.txt new file mode 100755 index 0000000000..5f5205cd02 --- /dev/null +++ b/t/t3901-utf8.txt @@ -0,0 +1,4 @@ +: to be sourced in t3901 -- this is utf8 +GIT_AUTHOR_NAME="Ãéà óú" && +GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME && +export GIT_AUTHOR_NAME GIT_COMMITTER_NAME diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index 67b9681d36..9c58d77cc2 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -28,7 +28,7 @@ test_expect_success \ 'git-diff-files -p >current' # that's as far as it comes -if [ "$(git repo-config --get core.filemode)" = false ] +if [ "$(git config --get core.filemode)" = false ] then say 'filemode disabled on the filesystem' test_done diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index 8ad69d1115..ca342f48a1 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -15,7 +15,7 @@ test_expect_success \ tree=`git-write-tree` && echo $tree' -if [ "$(git repo-config --get core.filemode)" = false ] +if [ "$(git config --get core.filemode)" = false ] then say 'filemode disabled on the filesystem, using update-index --chmod=+x' test_expect_success \ diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index ed37141b6e..3d85ceaae9 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -73,7 +73,7 @@ test_expect_success setup ' for i in 1 2; do echo $i; done >>dir/sub && git update-index file0 dir/sub && - git repo-config log.showroot false && + git config log.showroot false && git commit --amend && git show-branch ' diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master b/t/t4013/diff.format-patch_--attach_--stdout_initial..master index b4745e1001..e5ddd6fcbb 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master @@ -19,6 +19,7 @@ This is the second commit. file0 | 3 +++ file2 | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 --------------g-i-t--v-e-r-s-i-o-n Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" @@ -77,6 +78,7 @@ Content-Transfer-Encoding: 8bit dir/sub | 2 ++ file1 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 --------------g-i-t--v-e-r-s-i-o-n Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" @@ -126,6 +128,7 @@ Content-Transfer-Encoding: 8bit file0 | 3 +++ file3 | 4 ++++ 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 --------------g-i-t--v-e-r-s-i-o-n Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ index a9d1cd368b..d0dd19b623 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ @@ -19,6 +19,7 @@ This is the second commit. file0 | 3 +++ file2 | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 --------------g-i-t--v-e-r-s-i-o-n Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" @@ -77,6 +78,7 @@ Content-Transfer-Encoding: 8bit dir/sub | 2 ++ file1 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 --------------g-i-t--v-e-r-s-i-o-n Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..side b/t/t4013/diff.format-patch_--attach_--stdout_initial..side index 57b9d0bdc1..67a95c5cba 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..side +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..side @@ -17,6 +17,7 @@ Content-Transfer-Encoding: 8bit file0 | 3 +++ file3 | 4 ++++ 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 --------------g-i-t--v-e-r-s-i-o-n Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" diff --git a/t/t4013/diff.format-patch_--stdout_initial..master b/t/t4013/diff.format-patch_--stdout_initial..master index c33302e92f..8b88ca4927 100644 --- a/t/t4013/diff.format-patch_--stdout_initial..master +++ b/t/t4013/diff.format-patch_--stdout_initial..master @@ -10,6 +10,7 @@ This is the second commit. file0 | 3 +++ file2 | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 diff --git a/dir/sub b/dir/sub index 35d242b..8422d40 100644 @@ -53,6 +54,7 @@ Subject: [PATCH] Third dir/sub | 2 ++ file1 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 diff --git a/dir/sub b/dir/sub index 8422d40..cead32e 100644 @@ -87,6 +89,7 @@ Subject: [PATCH] Side file0 | 3 +++ file3 | 4 ++++ 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 diff --git a/dir/sub b/dir/sub index 35d242b..7289e35 100644 diff --git a/t/t4013/diff.format-patch_--stdout_initial..master^ b/t/t4013/diff.format-patch_--stdout_initial..master^ index 03d0f9693c..47a4b88637 100644 --- a/t/t4013/diff.format-patch_--stdout_initial..master^ +++ b/t/t4013/diff.format-patch_--stdout_initial..master^ @@ -10,6 +10,7 @@ This is the second commit. file0 | 3 +++ file2 | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 diff --git a/dir/sub b/dir/sub index 35d242b..8422d40 100644 @@ -53,6 +54,7 @@ Subject: [PATCH] Third dir/sub | 2 ++ file1 | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 diff --git a/dir/sub b/dir/sub index 8422d40..cead32e 100644 diff --git a/t/t4013/diff.format-patch_--stdout_initial..side b/t/t4013/diff.format-patch_--stdout_initial..side index d10a46523b..e765088475 100644 --- a/t/t4013/diff.format-patch_--stdout_initial..side +++ b/t/t4013/diff.format-patch_--stdout_initial..side @@ -9,6 +9,7 @@ Subject: [PATCH] Side file0 | 3 +++ file3 | 4 ++++ 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 diff --git a/dir/sub b/dir/sub index 35d242b..7289e35 100644 diff --git a/t/t4102-apply-rename.sh b/t/t4102-apply-rename.sh index 22da6a00cc..b4662b0364 100755 --- a/t/t4102-apply-rename.sh +++ b/t/t4102-apply-rename.sh @@ -31,7 +31,7 @@ test_expect_success setup \ test_expect_success apply \ 'git-apply --index --stat --summary --apply test-patch' -if [ "$(git repo-config --get core.filemode)" = false ] +if [ "$(git config --get core.filemode)" = false ] then say 'filemode disabled on the filesystem' else diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 5ee5b23095..91be272ac4 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -120,29 +120,29 @@ case "$(date -d @11111111 +%s 2>/dev/null)" in just_over_15_days_ago=$(($now-1-15*86400)) almost_60_days_ago=$(($now+60-60*86400)) just_over_60_days_ago=$(($now-1-60*86400)) - predate1="$(date -d "@$almost_60_days_ago" +%c)" - predate2="$(date -d "@$almost_15_days_ago" +%c)" - postdate1="$(date -d "@$just_over_60_days_ago" +%c)" - postdate2="$(date -d "@$just_over_15_days_ago" +%c)" + predate1="$(date -d "@$almost_60_days_ago" +%Y%m%d%H%M.%S)" + predate2="$(date -d "@$almost_15_days_ago" +%Y%m%d%H%M.%S)" + postdate1="$(date -d "@$just_over_60_days_ago" +%Y%m%d%H%M.%S)" + postdate2="$(date -d "@$just_over_15_days_ago" +%Y%m%d%H%M.%S)" ;; *) # it is not GNU date. oh, well. - predate1="$(date)" - predate2="$(date)" - postdate1='1 Oct 2006 00:00:00' - postdate2='1 Dec 2006 00:00:00' + predate1="$(date +%Y%m%d%H%M.%S)" + predate2="$(date +%Y%m%d%H%M.%S)" + postdate1='200610010000.00' + postdate2='200612010000.00' esac -touch -m -d "$predate1" $rr/preimage -touch -m -d "$predate2" $rr2/preimage +touch -m -t "$predate1" $rr/preimage +touch -m -t "$predate2" $rr2/preimage test_expect_success 'garbage collection (part1)' 'git rerere gc' test_expect_success 'young records still live' \ "test -f $rr/preimage -a -f $rr2/preimage" -touch -m -d "$postdate1" $rr/preimage -touch -m -d "$postdate2" $rr2/preimage +touch -m -t "$postdate1" $rr/preimage +touch -m -t "$postdate2" $rr2/preimage test_expect_success 'garbage collection (part2)' 'git rerere gc' diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh index 5a7232a577..a6dbb04a86 100755 --- a/t/t5301-sliding-window.sh +++ b/t/t5301-sliding-window.sh @@ -30,19 +30,19 @@ test_expect_success \ test_expect_success \ 'verify-pack -v, packedGitWindowSize == 1 page' \ - 'git-repo-config core.packedGitWindowSize 512 && + 'git-config core.packedGitWindowSize 512 && git-verify-pack -v "$pack1"' test_expect_success \ 'verify-pack -v, packedGit{WindowSize,Limit} == 1 page' \ - 'git-repo-config core.packedGitWindowSize 512 && - git-repo-config core.packedGitLimit 512 && + 'git-config core.packedGitWindowSize 512 && + git-config core.packedGitLimit 512 && git-verify-pack -v "$pack1"' test_expect_success \ 'repack -a -d, packedGit{WindowSize,Limit} == 1 page' \ - 'git-repo-config core.packedGitWindowSize 512 && - git-repo-config core.packedGitLimit 512 && + 'git-config core.packedGitWindowSize 512 && + git-config core.packedGitLimit 512 && commit2=`git-commit-tree $tree -p $commit1 </dev/null` && git-update-ref HEAD $commit2 && git-repack -a -d && @@ -53,8 +53,8 @@ test_expect_success \ test_expect_success \ 'verify-pack -v, defaults' \ - 'git-repo-config --unset core.packedGitWindowSize && - git-repo-config --unset core.packedGitLimit && + 'git-config --unset core.packedGitWindowSize && + git-config --unset core.packedGitLimit && git-verify-pack -v "$pack2"' test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 2c151912a3..7d93d0d7c9 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -106,7 +106,7 @@ export HOME ;# this way we force the victim/.git/config to be used. test_expect_success \ 'pushing with --force should be denied with denyNonFastforwards' ' cd victim && - git-repo-config receive.denyNonFastforwards true && + git-config receive.denyNonFastforwards true && cd .. && git-update-ref refs/heads/master master^ && git-send-pack --force ./victim/.git/ master && diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh index cd8cee6ae8..0514056ca6 100755 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@ -23,7 +23,7 @@ test_expect_success setup ' cat >victim/.git/hooks/update <<'EOF' #!/bin/sh echo "$@" >$GIT_DIR/update.args -read x; echo -n "$x" >$GIT_DIR/update.stdin +read x; printf "$x" >$GIT_DIR/update.stdin echo STDOUT update echo STDERR update >&2 EOF @@ -32,7 +32,7 @@ chmod u+x victim/.git/hooks/update cat >victim/.git/hooks/post-update <<'EOF' #!/bin/sh echo "$@" >$GIT_DIR/post-update.args -read x; echo -n "$x" >$GIT_DIR/post-update.stdin +read x; printf "$x" >$GIT_DIR/post-update.stdin echo STDOUT post-update echo STDERR post-update >&2 EOF diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index ef78df67ea..48e3d1705f 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -63,13 +63,13 @@ pull_to_client () { case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac git-symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'` - test_expect_success "fsck" 'git-fsck-objects --full > fsck.txt 2>&1' + test_expect_success "fsck" 'git-fsck --full > fsck.txt 2>&1' test_expect_success 'check downloaded results' \ 'mv .git/objects/pack/pack-* . && p=`ls -1 pack-*.pack` && git-unpack-objects <$p && - git-fsck-objects --full' + git-fsck --full' test_expect_success "new object count after $number pull" \ 'idx=`echo pack-*.idx` && @@ -97,7 +97,8 @@ pull_to_client () { ( mkdir client && cd client && - git-init 2>> log2.txt + git-init 2>> log2.txt && + git config transfer.unpacklimit 0 ) add A1 @@ -144,7 +145,7 @@ test_expect_success "clone shallow object count (part 2)" ' ' test_expect_success "fsck in shallow repo" \ - "(cd shallow; git-fsck-objects --full)" + "(cd shallow; git-fsck --full)" #test_done; exit diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 3ce9446210..50c64856f0 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -22,14 +22,14 @@ test_expect_success "clone and setup child repos" ' cd .. && git clone . two && cd two && - git repo-config branch.master.remote one && - git repo-config remote.one.url ../one/.git/ && - git repo-config remote.one.fetch refs/heads/master:refs/heads/one && + git config branch.master.remote one && + git config remote.one.url ../one/.git/ && + git config remote.one.fetch refs/heads/master:refs/heads/one && cd .. && git clone . three && cd three && - git repo-config branch.master.remote two && - git repo-config branch.master.merge refs/heads/one && + git config branch.master.remote two && + git config branch.master.merge refs/heads/one && mkdir -p .git/remotes && { echo "URL: ../two/.git/" diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh index b9f6d96363..2f8e97cb7e 100755 --- a/t/t5710-info-alternate.sh +++ b/t/t5710-info-alternate.sh @@ -17,7 +17,7 @@ reachable_via() { } test_valid_repo() { - git fsck-objects --full > fsck.log && + git fsck --full > fsck.log && test `wc -l < fsck.log` = 0 } diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 1c21d8c986..f3cd3dba4d 100644 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -52,7 +52,7 @@ super aquam refectionis educavit me; animam meam convertit, deduxit me super semitas jusitiae, EOF -echo -n "propter nomen suum." >> new4.txt +printf "propter nomen suum." >> new4.txt cp new1.txt test.txt test_expect_success "merge without conflict" \ diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh new file mode 100755 index 0000000000..3e9edda1ca --- /dev/null +++ b/t/t6120-describe.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +test_description='test describe + + B + .--------------o----o----o----x + / / / + o----o----o----o----o----. / + \ A c / + .------------o---o---o + D e +' +. ./test-lib.sh + +check_describe () { + expect="$1" + shift + R=$(git describe "$@") && + test_expect_success "describe $*" ' + case "$R" in + $expect) echo happy ;; + *) echo "Oops - $R is not $expect"; + false ;; + esac + ' +} + +test_expect_success setup ' + + test_tick && + echo one >file && git-add file && git-commit -m initial && + one=$(git-rev-parse HEAD) && + + test_tick && + echo two >file && git-add file && git-commit -m second && + two=$(git-rev-parse HEAD) && + + test_tick && + echo three >file && git-add file && git-commit -m third && + + test_tick && + echo A >file && git-add file && git-commit -m A && + test_tick && + git-tag -a -m A A && + + test_tick && + echo c >file && git-add file && git-commit -m c && + test_tick && + git-tag c && + + git reset --hard $two && + test_tick && + echo B >side && git-add side && git-commit -m B && + test_tick && + git-tag -a -m B B && + + test_tick && + git-merge -m Merged c && + merged=$(git-rev-parse HEAD) && + + git reset --hard $two && + test_tick && + echo D >another && git-add another && git-commit -m D && + test_tick && + git-tag -a -m D D && + + test_tick && + echo DD >another && git commit -a -m another && + + test_tick && + git-tag e && + + test_tick && + echo DDD >another && git commit -a -m "yet another" && + + test_tick && + git-merge -m Merged $merged && + + test_tick && + echo X >file && echo X >side && git-add file side && + git-commit -m x + +' + +check_describe A-* HEAD +check_describe A-* HEAD^ +check_describe D-* HEAD^^ +check_describe A-* HEAD^^2 +check_describe B HEAD^^2^ + +check_describe A-* --tags HEAD +check_describe A-* --tags HEAD^ +check_describe D-* --tags HEAD^^ +check_describe A-* --tags HEAD^^2 +check_describe B --tags HEAD^^2^ + +test_done diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index 63e49f310c..ea14023616 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -108,7 +108,7 @@ EOF test_expect_success 'merge-msg test #3' ' - git repo-config merge.summary true && + git config merge.summary true && git checkout master && setdate && @@ -138,7 +138,7 @@ EOF test_expect_success 'merge-msg test #4' ' - git repo-config merge.summary true && + git config merge.summary true && git checkout master && setdate && @@ -150,7 +150,7 @@ test_expect_success 'merge-msg test #4' ' test_expect_success 'merge-msg test #5' ' - git repo-config merge.summary yes && + git config merge.summary yes && git checkout master && setdate && diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 085d4a096b..867bbd26cb 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -14,15 +14,23 @@ fill () { done } + test_expect_success setup ' - fill 1 2 3 4 5 >one && + fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add one two && git commit -m "Initial A one, A two" && - git checkout -b side && - fill 1 2 3 >one && + git checkout -b renamer && + rm -f one && + fill 1 3 4 5 6 7 8 >uno && + git add uno && + fill a b c d e f >two && + git commit -a -m "Renamer R one->uno, M two" && + + git checkout -b side master && + fill 1 2 3 4 5 6 7 >one && fill A B C D E >three && rm -f two && git update-index --add --remove one two three && @@ -42,7 +50,7 @@ test_expect_success "checkout from non-existing branch" ' test_expect_success "checkout with dirty tree without -m" ' - fill 0 1 2 3 4 5 >one && + fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then echo Not happy @@ -58,12 +66,10 @@ test_expect_success "checkout -m with dirty tree" ' git checkout -f master && git clean && - fill 0 1 2 3 4 5 >one && + fill 0 1 2 3 4 5 6 7 8 >one && git checkout -m side && - fill " master" "* side" >expect.branch && - git branch >current.branch && - diff expect.branch current.branch && + test "$(git symbolic-ref HEAD)" = "refs/heads/side" && fill "M one" "A three" "D two" >expect.master && git diff --name-status master >current.master && @@ -78,4 +84,49 @@ test_expect_success "checkout -m with dirty tree" ' diff expect.index current.index ' +test_expect_success "checkout -m with dirty tree, renamed" ' + + git checkout -f master && git clean && + + fill 1 2 3 4 5 7 8 >one && + if git checkout renamer + then + echo Not happy + false + else + echo "happy - failed correctly" + fi && + + git checkout -m renamer && + fill 1 3 4 5 7 8 >expect && + diff expect uno && + ! test -f one && + git diff --cached >current && + ! test -s current + +' + +test_expect_success 'checkout -m with merge conflict' ' + + git checkout -f master && git clean && + + fill 1 T 3 4 5 6 S 8 >one && + if git checkout renamer + then + echo Not happy + false + else + echo "happy - failed correctly" + fi && + + git checkout -m renamer && + + git diff master:one :3:uno | + sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current && + fill d2 aT d7 aS >expect && + diff current expect && + git diff --cached two >current && + ! test -s current +' + test_done diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh index 572aaedc06..4e0808380f 100755 --- a/t/t9102-git-svn-deep-rmdir.sh +++ b/t/t9102-git-svn-deep-rmdir.sh @@ -1,3 +1,4 @@ +#!/bin/sh test_description='git-svn rmdir' . ./lib-git-svn.sh diff --git a/t/t9103-git-svn-graft-branches.sh b/t/t9103-git-svn-graft-branches.sh index b5f7677021..4e55778a47 100755 --- a/t/t9103-git-svn-graft-branches.sh +++ b/t/t9103-git-svn-graft-branches.sh @@ -1,3 +1,4 @@ +#!/bin/sh test_description='git-svn graft-branches' . ./lib-git-svn.sh diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index 315119abff..fd0a5549fe 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright (c) Robin Rosenberg # diff --git a/templates/hooks--update b/templates/hooks--update index 9863a800c8..4bd9d96ff9 100644 --- a/templates/hooks--update +++ b/templates/hooks--update @@ -1,89 +1,285 @@ #!/bin/sh # # An example hook script to mail out commit update information. -# It also blocks tags that aren't annotated. +# It can also blocks tags that aren't annotated. # Called by git-receive-pack with arguments: refname sha1-old sha1-new # -# To enable this hook: -# (1) change the recipient e-mail address -# (2) make this file executable by "chmod +x update". +# To enable this hook, make this file executable by "chmod +x update". # +# Config +# ------ +# hooks.mailinglist +# This is the list that all pushes will go to; leave it blank to not send +# emails frequently. The log email will list every log entry in full between +# the old ref value and the new ref value. +# hooks.announcelist +# This is the list that all pushes of annotated tags will go to. Leave it +# blank to just use the mailinglist field. The announce emails list the +# short log summary of the changes since the last annotated tag +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# +# Notes +# ----- +# All emails have their subjects prefixed with "[SCM]" to aid filtering. +# All emails include the headers "X-Git-Refname", "X-Git-Oldrev", +# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and info. -project=$(cat $GIT_DIR/description) -recipients="commit-list@somewhere.com commit-list@somewhereelse.com" - -ref_type=$(git cat-file -t "$3") - -# Only allow annotated tags in a shared repo -# Remove this code to treat dumb tags the same as everything else -case "$1","$ref_type" in -refs/tags/*,commit) - echo "*** Un-annotated tags are not allowed in this repo" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1;; -refs/tags/*,tag) - echo "### Pushing version '${1##refs/tags/}' to the masses" >&2 - # recipients="release-announce@somwehere.com announce@somewhereelse.com" - ;; -esac +# --- Constants +EMAILPREFIX="[SCM] " +LOGBEGIN="- Log -----------------------------------------------------------------" +LOGEND="-----------------------------------------------------------------------" +DATEFORMAT="%F %R %z" + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 <ref> <oldrev> <newrev>)" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "Usage: $0 <ref> <oldrev> <newrev>" >&2 + exit 1 +fi + +# --- Config +projectdesc=$(cat $GIT_DIR/description) +recipients=$(git-repo-config hooks.mailinglist) +announcerecipients=$(git-repo-config hooks.announcelist) +allowunannotated=$(git-repo-config --bool hooks.allowunannotated) -# set this to 'cat' to get a very detailed listing. -# short only kicks in when an annotated tag is added -short='git shortlog' - -# see 'date --help' for info on how to write this -# The default is a human-readable iso8601-like format with minute -# precision ('2006-01-25 15:58 +0100' for example) -date_format="%F %R %z" - -(if expr "$2" : '0*$' >/dev/null -then - # new ref - case "$1" in - refs/tags/*) - # a pushed and annotated tag (usually) means a new version - tag="${1##refs/tags/}" - if [ "$ref_type" = tag ]; then - eval $(git cat-file tag $3 | \ - sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p') - date=$(date --date="1970-01-01 00:00:00 $ts seconds" +"$date_format") - echo "Tag '$tag' created by $tagger at $date" - git cat-file tag $3 | sed -n '5,$p' - echo +# --- Check types +newrev_type=$(git-cat-file -t "$newrev") + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annoted tag + refname_type="tag" + short_refname=${refname##refs/tags/} + if [ $allowunannotated != "true" ]; then + echo "*** The un-annotated tag, $short_refname is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 fi - prev=$(git describe "$3^" | sed 's/-g.*//') - # the first tag in a repo will yield no $prev - if [ -z "$prev" ]; then - echo "Changes since the dawn of time:" - git rev-list --pretty $3 | $short - else - echo "Changes since $prev:" - git rev-list --pretty $prev..$3 | $short - echo --- - git diff --stat $prev..$3 - echo --- + ;; + refs/tags/*,tag) + # annotated tag + refname_type="annotated tag" + short_refname=${refname##refs/tags/} + # change recipients + if [ -n "$announcerecipients" ]; then + recipients="$announcerecipients" fi ;; + refs/heads/*,commit) + # branch + refname_type="branch" + short_refname=${refname##refs/heads/} + ;; + refs/remotes/*,commit) + # tracking branch + refname_type="tracking branch" + short_refname=${refname##refs/remotes/} + # Should this even be allowed? + echo "*** Push-update of tracking branch, $refname. No email generated." >&2 + exit 0 + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update, \"$newrev_type\", to ref $refname" >&2 + exit 1 + ;; +esac + +# Check if we've got anyone to send to +if [ -z "$recipients" ]; then + # If the email isn't sent, then at least give the user some idea of what command + # would generate the email at a later date + echo "*** No recipients found - no email will be sent, but the push will continue" >&2 + echo "*** for $0 $1 $2 $3" >&2 + exit 0 +fi + +# --- Email parameters +committer=$(git show --pretty=full -s $newrev | grep "^Commit: " | sed -e "s/^Commit: //") +describe=$(git describe $newrev 2>/dev/null) +if [ -z "$describe" ]; then + describe=$newrev +fi - refs/heads/*) - branch="${1##refs/heads/}" - echo "New branch '$branch' available with the following commits:" - git-rev-list --pretty "$3" $(git-rev-parse --not --all) +# --- Email (all stdout will be the email) +( +# Generate header +cat <<-EOF +From: $committer +To: $recipients +Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname now at $describe +X-Git-Refname: $refname +X-Git-Reftype: $refname_type +X-Git-Oldrev: $oldrev +X-Git-Newrev: $newrev + +Hello, + +This is an automated email from the git hooks/update script, it was +generated because a ref change was pushed to the repository. + +Updating $refname_type, $short_refname, +EOF + +case "$refname_type" in + "tracking branch"|branch) + if expr "$oldrev" : '0*$' >/dev/null + then + # If the old reference is "0000..0000" then this is a new branch + # and so oldrev is not valid + echo " as a new $refname_type" + echo " to $newrev ($newrev_type)" + echo "" + echo $LOGBEGIN + # This shows all log entries that are not already covered by + # another ref - i.e. commits that are now accessible from this + # ref that were previously not accessible + git-rev-list --pretty $newref $(git-rev-parse --not --all) + echo $LOGEND + else + # oldrev is valid + oldrev_type=$(git-cat-file -t "$oldrev") + + # Now the problem is for cases like this: + # * --- * --- * --- * (oldrev) + # \ + # * --- * --- * (newrev) + # i.e. there is no guarantee that newrev is a strict subset + # of oldrev - (would have required a force, but that's allowed). + # So, we can't simply say rev-list $oldrev..$newrev. Instead + # we find the common base of the two revs and list from there + baserev=$(git-merge-base $oldrev $newrev) + + # Commit with a parent + for rev in $(git-rev-list $newrev ^$baserev) + do + revtype=$(git-cat-file -t "$rev") + echo " via $rev ($revtype)" + done + if [ "$baserev" = "$oldrev" ]; then + echo " from $oldrev ($oldrev_type)" + else + echo " based on $baserev" + echo " from $oldrev ($oldrev_type)" + echo "" + echo "This ref update crossed a branch point; i.e. the old rev is not a strict subset" + echo "of the new rev. This occurs, when you --force push a change in a situation" + echo "like this:" + echo "" + echo " * -- * -- B -- O -- O -- O ($oldrev)" + echo " \\" + echo " N -- N -- N ($newrev)" + echo "" + echo "Therefore, we assume that you've already had alert emails for all of the O" + echo "revisions, and now give you all the revisions in the N branch from the common" + echo "base, B ($baserev), up to the new revision." + fi + echo "" + echo $LOGBEGIN + git-rev-list --pretty $newrev ^$baserev + echo $LOGEND + echo "" + echo "Diffstat:" + git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev ^$baserev + fi ;; - esac -else - base=$(git-merge-base "$2" "$3") - case "$base" in - "$2") - git diff --stat "$3" "^$base" - echo - echo "New commits:" + "annotated tag") + # Should we allow changes to annotated tags? + if expr "$oldrev" : '0*$' >/dev/null + then + # If the old reference is "0000..0000" then this is a new atag + # and so oldrev is not valid + echo " to $newrev ($newrev_type)" + else + echo " to $newrev ($newrev_type)" + echo " from $oldrev" + fi + + # If this tag succeeds another, then show which tag it replaces + prevtag=$(git describe $newrev^ 2>/dev/null | sed 's/-g.*//') + if [ -n "$prevtag" ]; then + echo " replaces $prevtag" + fi + + # Read the tag details + eval $(git cat-file tag $newrev | \ + sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p') + tagged=$(date --date="1970-01-01 00:00:00 +0000 $ts seconds" +"$DATEFORMAT") + + echo " tagged by $tagger" + echo " on $tagged" + + echo "" + echo $LOGBEGIN + echo "" + + if [ -n "$prevtag" ]; then + git rev-list --pretty=short "$prevtag..$newrev" | git shortlog + else + git rev-list --pretty=short $newrev | git shortlog + fi + + echo $LOGEND + echo "" ;; *) - echo "Rebased ref, commits from common ancestor:" + # By default, unannotated tags aren't allowed in; if + # they are though, it's debatable whether we would even want an + # email to be generated; however, I don't want to add another config + # option just for that. + # + # Unannotated tags are more about marking a point than releasing + # a version; therefore we don't do the shortlog summary that we + # do for annotated tags above - we simply show that the point has + # been marked, and print the log message for the marked point for + # reference purposes + # + # Note this section also catches any other reference type (although + # there aren't any) and deals with them in the same way. + if expr "$oldrev" : '0*$' >/dev/null + then + # If the old reference is "0000..0000" then this is a new tag + # and so oldrev is not valid + echo " as a new $refname_type" + echo " to $newrev ($newrev_type)" + else + echo " to $newrev ($newrev_type)" + echo " from $oldrev" + fi + echo "" + echo $LOGBEGIN + git-show --no-color --root -s $newrev + echo $LOGEND + echo "" ;; - esac - git-rev-list --pretty "$3" "^$base" -fi) | -mail -s "$project: Changes to '${1##refs/heads/}'" $recipients +esac + +# Footer +cat <<-EOF + +hooks/update +--- +Git Source Code Management System +$0 $1 \\ + $2 \\ + $3 +EOF +#) | cat >&2 +) | /usr/sbin/sendmail -t + +# --- Finished exit 0 diff --git a/upload-pack.c b/upload-pack.c index 3a466c6a3e..3648aae1a7 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -672,7 +672,8 @@ int main(int argc, char **argv) if (!enter_repo(dir, strict)) die("'%s': unable to chdir or not a git archive", dir); - + if (is_repository_shallow()) + die("attempt to fetch/clone from a shallow repository"); upload_pack(); return 0; } @@ -56,7 +56,6 @@ int main(int argc, char **argv) } setup_git_directory(); - setup_ident(); val = NULL; if (strcmp(argv[1], "-l") == 0) { diff --git a/write_or_die.c b/write_or_die.c index 4e8183e93e..5c4bc8515a 100644 --- a/write_or_die.c +++ b/write_or_die.c @@ -17,25 +17,13 @@ int read_in_full(int fd, void *buf, size_t count) return total; } -void read_or_die(int fd, void *buf, size_t count) -{ - ssize_t loaded; - - loaded = read_in_full(fd, buf, count); - if (loaded != count) { - if (loaded < 0) - die("read error (%s)", strerror(errno)); - die("read error: end of file"); - } -} - int write_in_full(int fd, const void *buf, size_t count) { const char *p = buf; ssize_t total = 0; while (count > 0) { - size_t written = xwrite(fd, p, count); + ssize_t written = xwrite(fd, p, count); if (written < 0) return -1; if (!written) { diff --git a/wt-status.c b/wt-status.c index daba9a6105..5567868008 100644 --- a/wt-status.c +++ b/wt-status.c @@ -335,7 +335,7 @@ void wt_status_print(struct wt_status *s) if (s->amend) printf("# No changes\n"); else if (s->workdir_dirty) - printf("no changes added to commit (use \"git add\" and/or \"git commit [-a|-i|-o]\")\n"); + printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"); else if (s->workdir_untracked) printf("nothing added to commit but untracked files present (use \"git add\" to track)\n"); else if (s->is_initial) @@ -351,7 +351,7 @@ int git_status_config(const char *k, const char *v) wt_status_use_color = git_config_colorbool(k, v); return 0; } - if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status", 13)) { + if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status.", 13)) { int slot = parse_status_slot(k, 13); color_parse(v, k, wt_status_colors[slot]); } |