diff options
254 files changed, 6492 insertions, 1998 deletions
diff --git a/.gitignore b/.gitignore index 847f40a54e..e8d2731ee5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ git-archive git-bisect git-blame git-branch +git-bundle git-cat-file git-check-ref-format git-checkout @@ -75,6 +76,7 @@ git-merge-ours git-merge-recursive git-merge-resolve git-merge-stupid +git-mergetool git-mktag git-mktree git-name-rev diff --git a/Documentation/Makefile b/Documentation/Makefile index 9e7f2a7880..7c1c9e1918 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -37,6 +37,7 @@ INSTALL?=install DOC_REF = origin/man -include ../config.mak.autogen +-include ../config.mak # # Please note that there is a minor bug in asciidoc. @@ -104,8 +105,11 @@ clean: user-manual.xml: user-manual.txt user-manual.conf $(ASCIIDOC) -b docbook -d book $< +XSLT = http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl +XSLTOPTS = --nonet --xinclude --stringparam html.stylesheet docbook-xsl.css + user-manual.html: user-manual.xml - xmlto html-nochunks $< + xsltproc $(XSLTOPTS) -o $@ $(XSLT) $< glossary.html : glossary.txt sort_glossary.pl cat $< | \ diff --git a/Documentation/RelNotes-1.5.0.3.txt b/Documentation/RelNotes-1.5.0.3.txt new file mode 100644 index 0000000000..cd500f96bf --- /dev/null +++ b/Documentation/RelNotes-1.5.0.3.txt @@ -0,0 +1,58 @@ +GIT v1.5.0.3 Release Notes +========================== + +Fixes since v1.5.0.2 +-------------------- + +* Bugfixes + + - 'git.el' honors the commit coding system from the configuration. + + - 'blameview' in contrib/ correctly digs deeper when a line is + clicked. + + - 'http-push' correctly makes sure the remote side has leading + path. Earlier it started in the middle of the path, and + incorrectly. + + - 'git-merge' did not exit with non-zero status when the + working tree was dirty and cannot fast forward. It does + now. + + - 'cvsexportcommit' does not lose yet-to-be-used message file. + + - int-vs-size_t typefix when running combined diff on files + over 2GB long. + + - 'git apply --whitespace=strip' should not touch unmodified + lines. + + - 'git-mailinfo' choke when a logical header line was too long. + + - 'git show A..B' did not error out. Negative ref ("not A" in + this example) does not make sense for the purpose of the + command, so now it errors out. + + - 'git fmt-merge-msg --file' without file parameter did not + correctly error out. + + - 'git archimport' barfed upon encountering a commit without + summary. + + - 'git index-pack' did not protect itself from getting a short + read out of pread(2). + + - 'git http-push' had a few buffer overruns. + + - Build dependency fixes to rebuild fetch.o when other headers + change. + +* Documentation updates + + - user-manual updates. + + - Options to 'git remote add' were described insufficiently. + + - Configuration format.suffix was not documented. + + - Other formatting and spelling fixes. diff --git a/Documentation/RelNotes-1.5.1.txt b/Documentation/RelNotes-1.5.1.txt index 4d371866c3..f374e1c2c7 100644 --- a/Documentation/RelNotes-1.5.1.txt +++ b/Documentation/RelNotes-1.5.1.txt @@ -19,17 +19,86 @@ Updates since v1.5.0 - "git diff" learned --ignore-space-at-eol. This is a weaker form of --ignore-space-change. + - "git diff --no-index pathA pathB" can be used as diff + replacement with git specific enhancements. + + - "git diff --pretty=format:<string>" to allow more flexible + custom log output. + - "git name-rev" learned --refs=<pattern>, to limit the tags used for naming the given revisions only to the ones matching the given pattern. + - "git remote update" is to run "git fetch" for defined remotes + to update tracking branches. + + - "git cvsimport" can now take '-d' to talk with a CVS + repository different from what are recorded in CVS/Root + (overriding it with environment CVSROOT does not work). + + - "git bundle" can help sneaker-netting your changes between + repositories. + + - A new configuration "core.symlinks" can be used to disable + symlinks on filesystems that do not support them; they are + checked out as regular files instead. + + * Updated behaviour of existing commands. + - git-svn got almost a rewrite. + + - core.autocrlf configuration, when set to 'true', makes git + to convert CRLF at the end of lines in text files to LF when + reading from the filesystem, and convert in reverse when + writing to the filesystem. The variable can be set to + 'input', in which case the conversion happens only while + reading from the filesystem but files are written out with + LF at the end of lines. Currently, which paths to consider + 'text' (i.e. be subjected to the autocrlf mechanism) is + decided purely based on the contents, but the plan is to + allow users to explicitly override this heuristic based on + paths. + + - The behaviour of 'git-apply', when run in a subdirectory, + without --index nor --cached were inconsistent with that of + the command with these options. This was fixed to match the + behaviour with --index. A patch that is meant to be applied + with -p1 from the toplevel of the project tree can be + applied with any custom -p<n> option. A patch that is not + relative to the toplevel needs to be applied with -p<n> + option with or without --index (or --cached). + - "git diff" outputs a trailing HT when pathnames have embedded SP on +++/--- header lines, in order to help "GNU patch" to parse its output. "git apply" was already updated to accept this modified output format since ce74618d (Sep 22, 2006). + - "git cvsserver" runs hooks/update and honors its exit status. + + - "git cvsserver" can be told to send everything with -kb. + + - "git diff --check" also honors the --color output option. + + - "git name-rev" used to stress the fact that a ref is a tag too + much, by saying something like "v1.2.3^0~22". It now says + "v1.2.3~22" in such a case (it still says "v1.2.3^0" if it does + not talk about an ancestor of the commit that is tagged, which + makes sense). + + - "git rev-list --boundary" now shows boundary markers for the + commits omitted by --max-age and --max-count condition. + + - The configuration mechanism now reads $(prefix)/etc/gitconfig. + + - "git apply --verbose" shows what preimage lines were wanted + when it couldn't find them. + + - "git status" in a read-only repository got a bit saner. + + - "git fetch" (hence "git clone" and "git pull") are less + noisy when the output does not go to tty. + * Hooks - The sample update hook to show how to send out notification @@ -39,6 +108,10 @@ Updates since v1.5.0 -- exec >/var/tmp/1 -O=v1.5.0-49-g69bc0e2 +O=v1.5.0.3-268-g3ddad98 echo O=`git describe master` git shortlog --no-merges $O..master ^maint + +# Local Variables: +# mode: text +# End: diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 285781d9db..131bcff9b2 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -1,3 +1,30 @@ +Checklist (and a short version for the impatient): + + - make commits of logical units + - check for unnecessary whitespace with "git diff --check" + before committing + - do not check in commented out code or unneeded files + - provide a meaningful commit message + - the first line of the commit message should be a short + description and should skip the full stop + - if you want your work included in git.git, add a + "Signed-off-by: Your Name <your@email.com>" line to the + commit message (or just use the option "-s" when + committing) to confirm that you agree to the Developer's + Certificate of Origin + - do not PGP sign your patch + - use "git format-patch -M" to create the patch + - do not attach your patch, but read in the mail + body, unless you cannot teach your mailer to + leave the formatting of the patch alone. + - be careful doing cut & paste into your mailer, not to + corrupt whitespaces. + - provide additional information (which is unsuitable for + the commit message) between the "---" and the diffstat + - send the patch to the list _and_ the maintainer + +Long version: + I started reading over the SubmittingPatches document for Linux kernel, primarily because I wanted to have a document similar to it for the core GIT to make sure people understand what they are diff --git a/Documentation/build-docdep.perl b/Documentation/build-docdep.perl index 489389c32a..ba4205e030 100755 --- a/Documentation/build-docdep.perl +++ b/Documentation/build-docdep.perl @@ -41,10 +41,6 @@ while ($changed) { while (my ($text, $included) = each %include) { if (! exists $included{$text} && (my $base = $text) =~ s/\.txt$//) { - my ($suffix) = '1'; - if ($base eq 'git') { - $suffix = '7'; # yuck... - } - print "$base.html $base.$suffix : ", join(" ", keys %$included), "\n"; + print "$base.html $base.xml : ", join(" ", keys %$included), "\n"; } } diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl index a2d6268e2b..b54382b2bf 100755 --- a/Documentation/cmd-list.perl +++ b/Documentation/cmd-list.perl @@ -70,6 +70,7 @@ git-archive mainporcelain git-bisect mainporcelain git-blame ancillaryinterrogators git-branch mainporcelain +git-bundle mainporcelain git-cat-file plumbinginterrogators git-checkout-index plumbingmanipulators git-checkout mainporcelain @@ -123,6 +124,7 @@ git-merge-index plumbingmanipulators git-merge mainporcelain git-merge-one-file purehelpers git-merge-tree ancillaryinterrogators +git-mergetool ancillarymanipulators git-mktag plumbingmanipulators git-mktree plumbingmanipulators git-mv mainporcelain diff --git a/Documentation/config.txt b/Documentation/config.txt index d2b4a05ca5..aaae9ac305 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -117,6 +117,13 @@ core.fileMode:: the working copy are ignored; useful on broken filesystems like FAT. See gitlink:git-update-index[1]. True by default. +core.symlinks:: + If false, symbolic links are checked out as small plain files that + contain the link text. gitlink:git-update-index[1] and + gitlink:git-add[1] will not change the recorded type to regular + file. Useful on filesystems like FAT that do not support + symbolic links. True by default. + core.gitProxy:: A "proxy command" to execute (as 'command host port') instead of establishing direct connection to the remote server when @@ -341,6 +348,11 @@ format.headers:: Additional email headers to include in a patch to be submitted by mail. See gitlink:git-format-patch[1]. +format.suffix:: + The default for format-patch is to output files with the suffix + `.patch`. Use this variable to change that suffix (make sure to + include the dot if you want it). + gc.packrefs:: `git gc` does not run `git pack-refs` in a bare repository by default so that older dumb-transport clients can still fetch @@ -441,6 +453,11 @@ merge.summary:: Whether to include summaries of merged commits in newly created merge commit messages. False by default. +merge.tool:: + Controls which merge resolution program is used by + gitlink:git-mergetool[l]. Valid values are: "kdiff3", "tkdiff", + "meld", "xxdiff", "emerge" + merge.verbosity:: Controls the amount of output shown by the recursive merge strategy. Level 0 outputs nothing except a final error diff --git a/Documentation/cvs-migration.txt b/Documentation/cvs-migration.txt index 764cc560b4..3b6b494162 100644 --- a/Documentation/cvs-migration.txt +++ b/Documentation/cvs-migration.txt @@ -109,7 +109,7 @@ sure it is in your path. Then cd to a checked out CVS working directory of the project you are interested in and run gitlink:git-cvsimport[1]: ------------------------------------------- -$ git cvsimport -C <destination> +$ git cvsimport -C <destination> <module> ------------------------------------------- This puts a git archive of the named CVS module in the directory diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index b73a99d61f..755d7186f5 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -52,7 +52,7 @@ OPTIONS -f:: Allow adding otherwise ignored files. -\i, \--interactive:: +-i, \--interactive:: Add modified contents in the working tree interactively to the index. diff --git a/Documentation/git-archimport.txt b/Documentation/git-archimport.txt index 5a13187a87..82cb41d279 100644 --- a/Documentation/git-archimport.txt +++ b/Documentation/git-archimport.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git-archimport' [-h] [-v] [-o] [-a] [-f] [-T] [-D depth] [-t tempdir] - <archive/branch> [ <archive/branch> ] + <archive/branch>[:<git-branch>] ... DESCRIPTION ----------- @@ -39,6 +39,19 @@ directory. To follow the development of a project that uses Arch, rerun `git-archimport` with the same parameters as the initial import to perform incremental imports. +While git-archimport will try to create sensible branch names for the +archives that it imports, it is also possible to specify git branch names +manually. To do so, write a git branch name after each <archive/branch> +parameter, separated by a colon. This way, you can shorten the Arch +branch names and convert Arch jargon to git jargon, for example mapping a +"PROJECT--devo--VERSION" branch to "master". + +Associating multiple Arch branches to one git branch is possible; the +result will make the most sense only if no commits are made to the first +branch, after the second branch is created. Still, this is useful to +convert Arch repositories that had been rotated periodically. + + MERGES ------ Patch merge data from Arch is used to mark merges in git as well. git @@ -73,7 +86,9 @@ OPTIONS Use this for compatibility with old-style branch names used by earlier versions of git-archimport. Old-style branch names were category--branch, whereas new-style branch names are - archive,category--branch--version. + archive,category--branch--version. In both cases, names given + on the command-line will override the automatically-generated + ones. -D <depth>:: Follow merge ancestry and attempt to import trees that have been diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index aa1fdd402a..603f87f3b5 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -8,8 +8,9 @@ git-branch - List, create, or delete branches SYNOPSIS -------- [verse] -'git-branch' [--color | --no-color] [-r | -a] [-v [--abbrev=<length>]] -'git-branch' [-l] [-f] <branchname> [<start-point>] +'git-branch' [--color | --no-color] [-r | -a] + [-v [--abbrev=<length> | --no-abbrev]] +'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>] 'git-branch' (-m | -M) [<oldbranch>] <newbranch> 'git-branch' (-d | -D) [-r] <branchname>... @@ -25,6 +26,13 @@ It will start out with a head equal to the one given as <start-point>. If no <start-point> is given, the branch will be created with a head equal to that of the currently checked out branch. +When a local branch is started off a remote branch, git can setup the +branch so that gitlink:git-pull[1] will appropriately merge from that +remote branch. If this behavior is desired, it is possible to make it +the default using the global `branch.autosetupmerge` configuration +flag. Otherwise, it can be chosen per-branch using the `--track` +and `--no-track` options. + With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>. If <oldbranch> had a corresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to remember the branch @@ -80,6 +88,9 @@ OPTIONS Alter minimum display length for sha1 in output listing, default value is 7. +--no-abbrev:: + Display the full sha1s in output listing rather than abbreviating them. + <branchname>:: The name of the branch to create or delete. The new branch name must pass all checks defined by diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt new file mode 100644 index 0000000000..92e7a68722 --- /dev/null +++ b/Documentation/git-bundle.txt @@ -0,0 +1,139 @@ +git-bundle(1) +============= + +NAME +---- +git-bundle - Move objects and refs by archive + + +SYNOPSIS +-------- +'git-bundle' create <file> [git-rev-list args] +'git-bundle' verify <file> +'git-bundle' list-heads <file> [refname...] +'git-bundle' unbundle <file> [refname...] + +DESCRIPTION +----------- + +Some workflows require that one or more branches of development on one +machine be replicated on another machine, but the two machines cannot +be directly connected so the interactive git protocols (git, ssh, +rsync, http) cannot be used. This command provides support for +git-fetch and git-pull to operate by packaging objects and references +in an archive at the originating machine, then importing those into +another repository using gitlink:git-fetch[1] and gitlink:git-pull[1] +after moving the archive by some means (i.e., by sneakernet). As no +direct connection between repositories exists, the user must specify a +basis for the bundle that is held by the destination repository: the +bundle assumes that all objects in the basis are already in the +destination repository. + +OPTIONS +------- + +create <file>:: + Used to create a bundle named 'file'. This requires the + git-rev-list arguments to define the bundle contents. + +verify <file>:: + Used to check that a bundle file is valid and will apply + cleanly to the current repository. This includes checks on the + bundle format itself as well as checking that the prerequisite + commits exist and are fully linked in the current repository. + git-bundle prints a list of missing commits, if any, and exits + with non-zero status. + +list-heads <file>:: + Lists the references defined in the bundle. If followed by a + list of references, only references matching those given are + printed out. + +unbundle <file>:: + Passes the objects in the bundle to gitlink:git-index-pack[1] + for storage in the repository, then prints the names of all + defined references. If a reflist is given, only references + matching those in the given list are printed. This command is + really plumbing, intended to be called only by + gitlink:git-fetch[1]. + +[git-rev-list-args...]:: + A list of arguments, acceptable to git-rev-parse and + git-rev-list, that specify the specific objects and references + to transport. For example, "master~10..master" causes the + current master reference to be packaged along with all objects + added since its 10th ancestor commit. There is no explicit + limit to the number of references and objects that may be + packaged. + + +[refname...]:: + A list of references used to limit the references reported as + available. This is principally of use to git-fetch, which + expects to receive only those references asked for and not + necessarily everything in the pack (in this case, git-bundle is + acting like gitlink:git-fetch-pack[1]). + +SPECIFYING REFERENCES +--------------------- + +git-bundle will only package references that are shown by +git-show-ref: this includes heads, tags, and remote heads. References +such as master~1 cannot be packaged, but are perfectly suitable for +defining the basis. More than one reference may be packaged, and more +than one basis can be specified. The objects packaged are those not +contained in the union of the given bases. Each basis can be +specified explicitly (e.g., ^master~10), or implicitly (e.g., +master~10..master, master --since=10.days.ago). + +It is very important that the basis used be held by the destination. +It is okay to err on the side of conservatism, causing the bundle file +to contain objects already in the destination as these are ignored +when unpacking at the destination. + +EXAMPLE +------- + +Assume two repositories exist as R1 on machine A, and R2 on machine B. +For whatever reason, direct connection between A and B is not allowed, +but we can move data from A to B via some mechanism (CD, email, etc). +We want to update R2 with developments made on branch master in R1. +We set a tag in R1 (lastR2bundle) after the previous such transport, +and move it afterwards to help build the bundle. + +in R1 on A: +$ git-bundle create mybundle master ^lastR2bundle +$ git tag -f lastR2bundle master + +(move mybundle from A to B by some mechanism) + +in R2 on B: +$ git-bundle verify mybundle +$ git-fetch mybundle refspec + +where refspec is refInBundle:localRef + + +Also, with something like this in your config: + +[remote "bundle"] + url = /home/me/tmp/file.bdl + fetch = refs/heads/*:refs/remotes/origin/* + +You can first sneakernet the bundle file to ~/tmp/file.bdl and +then these commands: + +$ git ls-remote bundle +$ git fetch bundle +$ git pull bundle + +would treat it as if it is talking with a remote side over the +network. + +Author +------ +Written by Mark Levedahl <mdl123@verizon.net> + +GIT +--- +Part of the gitlink:git[7] suite diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 1ae77be450..f5b2d5017b 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -8,7 +8,7 @@ git-checkout - Checkout and switch to a branch SYNOPSIS -------- [verse] -'git-checkout' [-q] [-f] [-b <new_branch> [-l]] [-m] [<branch>] +'git-checkout' [-q] [-f] [-b [--track | --no-track] <new_branch> [-l]] [-m] [<branch>] 'git-checkout' [<tree-ish>] <paths>... DESCRIPTION @@ -18,7 +18,8 @@ When <paths> are not given, this command switches branches by updating the index and working tree to reflect the specified branch, <branch>, and updating HEAD to be <branch> or, if specified, <new_branch>. Using -b will cause <new_branch> to -be created. +be created; in this case you can use the --track or --no-track +options, which will be passed to `git branch`. When <paths> are given, this command does *not* switch branches. It updates the named paths in the working tree from @@ -45,6 +46,16 @@ OPTIONS by gitlink:git-check-ref-format[1]. Some of these checks may restrict the characters allowed in a branch name. +--track:: + When -b is given and a branch is created off a remote branch, + setup so that git-pull will automatically retrieve data from + the remote branch. + +--no-track:: + When -b is given and a branch is created off a remote branch, + force that git-pull will automatically retrieve data from + the remote branch independent of the configuration settings. + -l:: Create the new branch's ref log. This activates recording of all changes to made the branch ref, enabling use of date diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 2187eee416..53a7bb0895 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -8,8 +8,9 @@ git-commit - Record changes to the repository SYNOPSIS -------- [verse] -'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg> | - --amend] [--no-verify] [-e] [--author <author>] +'git-commit' [-a | --interactive] [-s] [-v] + [(-c | -C) <commit> | -F <file> | -m <msg> | --amend] + [--no-verify] [-e] [--author <author>] [--] [[-i | -o ]<file>...] DESCRIPTION @@ -35,6 +36,10 @@ methods: before, and to automatically "rm" files that have been removed from the working tree, and perform the actual commit. +5. by using the --interactive switch with the 'commit' command to decide one + by one which files should be part of the commit, before finalizing the + operation. Currently, this is done by invoking `git-add --interactive`. + The gitlink:git-status[1] command can be used to obtain a summary of what is included by any of the above for the next commit by giving the same set of parameters you would give to diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index 6624484fe1..68de5881bd 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -16,6 +16,8 @@ SYNOPSIS '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] [type] --rename-section old_name new_name +'git-config' [--global] [type] --remove-section name 'git-config' [--global] -l | --list DESCRIPTION @@ -74,6 +76,12 @@ OPTIONS --global:: Use global ~/.gitconfig file rather than the repository .git/config. +--remove-section:: + Remove the given section from the configuration file. + +--rename-section:: + Rename the given section to a new name. + --unset:: Remove the line matching the key from config file. diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt index f5450de74a..0d59c06139 100644 --- a/Documentation/git-cvsimport.txt +++ b/Documentation/git-cvsimport.txt @@ -96,11 +96,6 @@ If you need to pass multiple options, separate them with a comma. -s <subst>:: Substitute the character "/" in branch names with <subst> --A <author-conv-file>:: - CVS by default uses the Unix username when writing its - commit logs. Using this option and an author-conv-file - in this format - -a:: Import all commits, including recent ones. cvsimport by default skips commits that have a timestamp less than 10 minutes ago. @@ -112,6 +107,10 @@ If you need to pass multiple options, separate them with a comma. Limit the number of commits imported. Workaround for cases where cvsimport leaks memory. +-A <author-conv-file>:: + CVS by default uses the Unix username when writing its + commit logs. Using this option and an author-conv-file + in this format + --------- exon=Andreas Ericsson <ae@op5.se> diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt index e328db3797..1c6f6a7e27 100644 --- a/Documentation/git-cvsserver.txt +++ b/Documentation/git-cvsserver.txt @@ -121,10 +121,10 @@ so that calling 'cvs' effectively calls git-cvsserver. Clients known to work --------------------- -CVS 1.12.9 on Debian -CVS 1.11.17 on MacOSX (from Fink package) -Eclipse 3.0, 3.1.2 on MacOSX (see Eclipse CVS Client Notes) -TortoiseCVS +- CVS 1.12.9 on Debian +- CVS 1.11.17 on MacOSX (from Fink package) +- Eclipse 3.0, 3.1.2 on MacOSX (see Eclipse CVS Client Notes) +- TortoiseCVS Operations supported -------------------- @@ -148,13 +148,16 @@ Copyright and Authors This program is copyright The Open University UK - 2006. -Authors: Martyn Smith <martyn@catalyst.net.nz> - Martin Langhoff <martin@catalyst.net.nz> - with ideas and patches from participants of the git-list <git@vger.kernel.org>. +Authors: + +- Martyn Smith <martyn@catalyst.net.nz> +- Martin Langhoff <martin@catalyst.net.nz> + +with ideas and patches from participants of the git-list <git@vger.kernel.org>. Documentation -------------- -Documentation by Martyn Smith <martyn@catalyst.net.nz> and Martin Langhoff <martin@catalyst.net.nz> Matthias Urlichs <smurf@smurf.noris.de>. +Documentation by Martyn Smith <martyn@catalyst.net.nz>, Martin Langhoff <martin@catalyst.net.nz>, and Matthias Urlichs <smurf@smurf.noris.de>. GIT --- diff --git a/Documentation/git-diff-files.txt b/Documentation/git-diff-files.txt index 7248b35d95..b78c4c64f1 100644 --- a/Documentation/git-diff-files.txt +++ b/Documentation/git-diff-files.txt @@ -8,7 +8,7 @@ git-diff-files - Compares files in the working tree and the index SYNOPSIS -------- -'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...] +'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc|-n|--no-index] [<common diff options>] [<path>...] DESCRIPTION ----------- @@ -36,6 +36,9 @@ omit diff output for unmerged entries and just show "Unmerged". diff, similar to the way 'diff-tree' shows a merge commit with these flags. +\-n,\--no-index:: + Compare the two given files / directories. + -q:: Remain silent even on nonexistent files diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index 6a098df26b..044cee9b42 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -8,7 +8,7 @@ git-diff - Show changes between commits, commit and working tree, etc SYNOPSIS -------- -'git-diff' [ --diff-options ] <commit>{0,2} [--] [<path>...] +'git-diff' [<common diff options>] <commit>{0,2} [--] [<path>...] DESCRIPTION ----------- @@ -23,6 +23,10 @@ tree and the index file, or the index file and the working tree. further add to the index but you still haven't. You can stage these changes by using gitlink:git-add[1]. + If exactly two paths are given, and at least one is untracked, + compare the two files / directories. This behavior can be + forced by --no-index. + 'git-diff' [--options] --cached [<commit>] [--] [<path>...]:: This form is to view the changes you staged for the next diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt index 77a14bb076..eaba6fd4c1 100644 --- a/Documentation/git-fast-import.txt +++ b/Documentation/git-fast-import.txt @@ -62,7 +62,18 @@ OPTIONS Dumps the internal marks table to <file> when complete. Marks are written one per line as `:markid SHA-1`. Frontends can use this file to validate imports after they - have been completed. + have been completed, or to save the marks table across + incremental runs. As <file> is only opened and truncated + at checkpoint (or completion) the same path can also be + safely given to \--import-marks. + +--import-marks=<file>:: + Before processing any input, load the marks specified in + <file>. The input file must exist, must be readable, and + must use the same format as produced by \--export-marks. + Multiple options may be supplied to import more than one + set of marks. If a mark is defined to different values, + the last file wins. --export-pack-edges=<file>:: After creating a packfile, print a line of data to @@ -451,7 +462,7 @@ in octal. Git only supports the following modes: In both formats `<path>` is the complete path of the file to be added (if not already existing) or modified (if already existing). -A `<path>` string must use UNIX-style directory seperators (forward +A `<path>` string must use UNIX-style directory separators (forward slash `/`), may contain any byte other than `LF`, and must not start with double quote (`"`). @@ -461,8 +472,8 @@ quoting should be used, e.g. `"path/with\n and \" in it"`. The value of `<path>` must be in canoncial form. That is it must not: * contain an empty directory component (e.g. `foo//bar` is invalid), -* end with a directory seperator (e.g. `foo/` is invalid), -* start with a directory seperator (e.g. `/foo` is invalid), +* end with a directory separator (e.g. `foo/` is invalid), +* start with a directory separator (e.g. `/foo` is invalid), * contain the special component `.` or `..` (e.g. `foo/./bar` and `foo/../bar` are invalid). diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt index 105d76b0ba..a99a5b321f 100644 --- a/Documentation/git-fetch-pack.txt +++ b/Documentation/git-fetch-pack.txt @@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository SYNOPSIS -------- -'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...] +'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...] DESCRIPTION ----------- @@ -63,6 +63,9 @@ OPTIONS \--depth=<n>:: Limit fetching to ancestor-chains not longer than n. +\--no-progress:: + Do not show the progress. + \-v:: Run verbosely. diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 59f34b9f0d..111d7c60bf 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -9,8 +9,9 @@ git-format-patch - Prepare patches for e-mail submission SYNOPSIS -------- [verse] -'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread] - [-s | --signoff] [--diff-options] [--start-number <n>] +'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--thread] + [--attach[=<boundary>] | --inline[=<boundary>]] + [-s | --signoff] [<common diff options>] [--start-number <n>] [--in-reply-to=Message-Id] [--suffix=.<sfx>] [--ignore-if-in-upstream] <since>[..<until>] @@ -46,6 +47,8 @@ reference. OPTIONS ------- +include::diff-options.txt[] + -o|--output-directory <dir>:: Use <dir> to store the resulting files, instead of the current working directory. @@ -68,8 +71,15 @@ OPTIONS Print all commits to the standard output in mbox format, instead of creating a file for each one. ---attach:: - Create attachments instead of inlining patches. +--attach[=<boundary>]:: + Create multipart/mixed attachment, the first part of + which is the commit message and the patch itself in the + second part, with "Content-Disposition: attachment". + +--inline[=<boundary>]:: + Create multipart/mixed attachment, the first part of + which is the commit message and the patch itself in the + second part, with "Content-Disposition: inline". --thread:: Add In-Reply-To and References headers to make the second and diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt new file mode 100644 index 0000000000..ae69a0eb83 --- /dev/null +++ b/Documentation/git-mergetool.txt @@ -0,0 +1,46 @@ +git-mergetool(1) +================ + +NAME +---- +git-mergetool - Run merge conflict resolution tools to resolve merge conflicts + +SYNOPSIS +-------- +'git-mergetool' [--tool=<tool>] [<file>]... + +DESCRIPTION +----------- + +Use 'git mergetool' to run one of several merge utilities to resolve +merge conflicts. It is typically run after gitlink:git-merge[1]. + +If one or more <file> parameters are given, the merge tool program will +be run to resolve differences on each file. If no <file> names are +specified, 'git mergetool' will run the merge tool program on every file +with merge conflicts. + +OPTIONS +------- +-t or --tool=<tool>:: + Use the merge resolution program specified by <tool>. + Valid merge tools are: + kdiff3, tkdiff, meld, xxdiff, and emerge. + + If a merge resolution program is not specified, 'git mergetool' + will use the configuration variable merge.tool. If the + configuration variable merge.tool is not set, 'git mergetool' + will pick a suitable default. + +Author +------ +Written by Theodore Y Ts'o <tytso@mit.edu> + +Documentation +-------------- +Documentation by Theodore Y Ts'o. + +GIT +--- +Part of the gitlink:git[7] suite + diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt index 6e9a8c369a..296937a416 100644 --- a/Documentation/git-quiltimport.txt +++ b/Documentation/git-quiltimport.txt @@ -42,10 +42,10 @@ OPTIONS --patches <dir>:: The directory to find the quilt patches and the quilt series file. - - The default for the patch directory is patches - or the value of the $QUILT_PATCHES environment - variable. ++ +The default for the patch directory is patches +or the value of the $QUILT_PATCHES environment +variable. Author ------ diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt index 10e8c46c4c..6914aa59c3 100644 --- a/Documentation/git-receive-pack.txt +++ b/Documentation/git-receive-pack.txt @@ -25,61 +25,126 @@ The command allows for creation and fast forwarding of sha1 refs local end receive-pack runs, but to the user who is sitting at the send-pack end, it is updating the remote. Confused?) -Before each ref is updated, if $GIT_DIR/hooks/update file exists -and executable, it is called with three parameters: +There are other real-world examples of using update and +post-update hooks found in the Documentation/howto directory. - $GIT_DIR/hooks/update refname sha1-old sha1-new +git-receive-pack honours the receive.denyNonFastForwards config +option, which tells it if updates to a ref should be denied if they +are not fast-forwards. + +OPTIONS +------- +<directory>:: + The repository to sync into. + +pre-receive Hook +---------------- +Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists +and is executable, it will be invoked once with no parameters. The +standard input of the hook will be one line per ref to be updated: + + sha1-old SP sha1-new SP refname LF + +The refname value is relative to $GIT_DIR; e.g. for the master +head this is "refs/heads/master". The two sha1 values before +each refname are the object names for the refname before and after +the update. Refs to be created will have sha1-old equal to 0{40}, +while refs to be deleted will have sha1-new equal to 0{40}, otherwise +sha1-old and sha1-new should be valid objects in the repository. + +This hook is called before any refname is updated and before any +fast-forward checks are performed. + +If the pre-receive hook exits with a non-zero exit status no updates +will be performed, and the update, post-receive and post-update +hooks will not be invoked either. This can be useful to quickly +bail out if the update is not to be supported. -The refname parameter is relative to $GIT_DIR; e.g. for the -master head this is "refs/heads/master". Two sha1 are the -object names for the refname before and after the update. Note -that the hook is called before the refname is updated, so either -sha1-old is 0{40} (meaning there is no such ref yet), or it -should match what is recorded in refname. +update Hook +----------- +Before each ref is updated, if $GIT_DIR/hooks/update file exists +and is executable, it is invoked once per ref, with three parameters: -The hook should exit with non-zero status if it wants to -disallow updating the named ref. Otherwise it should exit with -zero. + $GIT_DIR/hooks/update refname sha1-old sha1-new -Using this hook, it is easy to generate mails on updates to -the local repository. This example script sends a mail with -the commits pushed to the repository: +The refname parameter is relative to $GIT_DIR; e.g. for the master +head this is "refs/heads/master". The two sha1 arguments are +the object names for the refname before and after the update. +Note that the hook is called before the refname is updated, +so either sha1-old is 0{40} (meaning there is no such ref yet), +or it should match what is recorded in refname. + +The hook should exit with non-zero status if it wants to disallow +updating the named ref. Otherwise it should exit with zero. + +Successful execution (a zero exit status) of this hook does not +ensure the ref will actully be updated, it is only a prerequisite. +As such it is not a good idea to send notices (e.g. email) from +this hook. Consider using the post-receive hook instead. + +post-receive Hook +----------------- +After all refs were updated (or attempted to be updated), if any +ref update was successful, and if $GIT_DIR/hooks/post-receive +file exists and is executable, it will be invoke once with no +parameters. The standard input of the hook will be one line +for each successfully updated ref: + + sha1-old SP sha1-new SP refname LF + +The refname value is relative to $GIT_DIR; e.g. for the master +head this is "refs/heads/master". The two sha1 values before +each refname are the object names for the refname before and after +the update. Refs that were created will have sha1-old equal to +0{40}, while refs that were deleted will have sha1-new equal to +0{40}, otherwise sha1-old and sha1-new should be valid objects in +the repository. + +Using this hook, it is easy to generate mails describing the updates +to the repository. This example script sends one mail message per +ref listing the commits pushed to the repository: #!/bin/sh # mail out commit update information. - if expr "$2" : '0*$' >/dev/null - then - echo "Created a new ref, with the following commits:" - git-rev-list --pretty "$2" - else - echo "New commits:" - git-rev-list --pretty "$3" "^$2" - fi | - mail -s "Changes to ref $1" commit-list@mydomain + while read oval nval ref + do + if expr "$oval" : '0*$' >/dev/null + then + echo "Created a new ref, with the following commits:" + git-rev-list --pretty "$nval" + else + echo "New commits:" + git-rev-list --pretty "$nval" "^$oval" + fi | + mail -s "Changes to ref $ref" commit-list@mydomain + done exit 0 -Another hook $GIT_DIR/hooks/post-update, if exists and -executable, is called with the list of refs that have been -updated. This can be used to implement repository wide cleanup -task if needed. The exit code from this hook invocation is -ignored; the only thing left for git-receive-pack to do at that -point is to exit itself anyway. This hook can be used, for -example, to run "git-update-server-info" if the repository is -packed and is served via a dumb transport. +The exit code from this hook invocation is ignored, however a +non-zero exit code will generate an error message. - #!/bin/sh - exec git-update-server-info +Note that it is possible for refname to not have sha1-new when this +hook runs. This can easily occur if another user modifies the ref +after it was updated by receive-pack, but before the hook was able +to evaluate it. It is recommended that hooks rely on sha1-new +rather than the current value of refname. -There are other real-world examples of using update and -post-update hooks found in the Documentation/howto directory. +post-update Hook +---------------- +After all other processing, if at least one ref was updated, and +if $GIT_DIR/hooks/post-update file exists and is executable, then +post-update will called with the list of refs that have been updated. +This can be used to implement any repository wide cleanup tasks. -git-receive-pack honours the receive.denyNonFastforwards flag, which -tells it if updates to a ref should be denied if they are not fast-forwards. +The exit code from this hook invocation is ignored; the only thing +left for git-receive-pack to do at that point is to exit itself +anyway. -OPTIONS -------- -<directory>:: - The repository to sync into. +This hook can be used, for example, to run "git-update-server-info" +if the repository is packed and is served via a dumb transport. + + #!/bin/sh + exec git-update-server-info SEE ALSO diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index 266faade31..a9fb6a9a5e 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git-remote' -'git-remote' add <name> <url> +'git-remote' add [-t <branch>] [-m <branch>] [-f] <name> <url> 'git-remote' show <name> 'git-remote' prune <name> 'git-remote' update [group] @@ -77,8 +77,8 @@ gitlink:git-config[1]). Examples -------- -Add a new remote, fetch, and check out a branch from it: - +* Add a new remote, fetch, and check out a branch from it ++ ------------ $ git remote origin @@ -98,6 +98,17 @@ $ git checkout -b nfs linux-nfs/master ... ------------ +* Imitate 'git clone' but track only selected branches ++ +------------ +$ mkdir project.git +$ cd project.git +$ git init +$ git remote add -f -t master -m master origin git://example.com/git.git/ +$ git merge origin +------------ + + See Also -------- gitlink:git-fetch[1] diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 4041a16070..ccc66aae7f 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -190,6 +190,13 @@ blobs contained in a commit. and dereference the tag recursively until a non-tag object is found. +* A colon, followed by a slash, followed by a text: this names + a commit whose commit message starts with the specified text. + This name returns the youngest matching commit which is + reachable from any ref. If the commit message starts with a + '!', you have to repeat that; the special sequence ':/!', + followed by something else than '!' is reserved for now. + * A suffix ':' followed by a path; this names the blob or tree at the given path in the tree-ish object named by the part before the colon. diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index 4c8d907bd5..9b3aabb6fe 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -26,13 +26,13 @@ The options available are: --bcc:: Specify a "Bcc:" value for each email. - - The --bcc option must be repeated for each user you want on the bcc list. ++ +The --bcc option must be repeated for each user you want on the bcc list. --cc:: Specify a starting "Cc:" value for each email. - - The --cc option must be repeated for each user you want on the cc list. ++ +The --cc option must be repeated for each user you want on the cc list. --chain-reply-to, --no-chain-reply-to:: If this is set, each email will be sent as a reply to the previous @@ -40,7 +40,8 @@ The options available are: the first will be sent as replies to the first email sent. When using this, it is recommended that the first file given be an overview of the entire patch series. - Default is --chain-reply-to + Default is the value of the 'sendemail.chainreplyto' configuration + value; if that is unspecified, default to --chain-reply-to. --compose:: Use $EDITOR to edit an introductory message for the @@ -87,9 +88,29 @@ The options available are: Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. ++ +The --to option must be repeated for each user you want on the to list. + + +CONFIGURATION +------------- +sendemail.aliasesfile:: + To avoid typing long email addresses, point this to one or more + email aliases files. You must also supply 'sendemail.aliasfiletype'. + +sendemail.aliasfiletype:: + Format of the file(s) specified in sendemail.aliasesfile. Must be + one of 'mutt', 'mailrc', 'pine', or 'gnus'. + +sendemail.bcc:: + Email address (or alias) to always bcc. - The --to option must be repeated for each user you want on the to list. +sendemail.chainreplyto:: + Boolean value specifying the default to the '--chain_reply_to' + parameter. +sendemail.smtpserver:: + Default smtp server to use. Author ------ diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt index f56f164983..5a219ab577 100644 --- a/Documentation/git-show.txt +++ b/Documentation/git-show.txt @@ -48,15 +48,15 @@ git show v1.0.0:: Shows the tag `v1.0.0`, along with the object the tags points at. -git show v1.0.0^{tree}:: +git show v1.0.0^\{tree\}:: Shows the tree pointed to by the tag `v1.0.0`. -git show next~10:Documentation/README +git show next~10:Documentation/README:: Shows the contents of the file `Documentation/README` as they were current in the 10th last commit of the branch `next`. -git show master:Makefile master:t/Makefile +git show master:Makefile master:t/Makefile:: Concatenates the contents of said Makefiles in the head of the branch `master`. diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index cf094ca357..a0d34e0058 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -63,7 +63,7 @@ COMMANDS transports (eg svn+ssh://), you must include the username in the URL, eg svn+ssh://foo@svn.bar.com/project ---prefix=<prefix> +--prefix=<prefix>:: This allows one to specify a prefix which is prepended to the names of remotes if trunk/branches/tags are specified. The prefix does not automatically include a @@ -94,16 +94,24 @@ COMMANDS This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it. - This works similarly to 'svn update' or 'git-pull' except that - it preserves linear history with 'git-rebase' instead of - 'git-merge' for ease of dcommit-ing with git-svn. +This works similarly to 'svn update' or 'git-pull' except that +it preserves linear history with 'git-rebase' instead of +'git-merge' for ease of dcommit-ing with git-svn. - This accepts all options that 'git-svn fetch' and 'git-rebase' - accepts. However '--fetch-all' only fetches from the current - [svn-remote], and not all [svn-remote] definitions. +This accepts all options that 'git-svn fetch' and 'git-rebase' +accepts. However '--fetch-all' only fetches from the current +[svn-remote], and not all [svn-remote] definitions. - Like 'git-rebase'; this requires that the working tree be clean - and have no uncommitted changes. +Like 'git-rebase'; this requires that the working tree be clean +and have no uncommitted changes. ++ +-- +-l;; +--local;; + Do not fetch remotely; only run 'git-rebase' against the + last fetched commit from the upstream SVN. +-- ++ 'dcommit':: Commit each diff from a specified head directly to the SVN @@ -117,29 +125,40 @@ COMMANDS alternative to HEAD. This is advantageous over 'set-tree' (below) because it produces cleaner, more linear history. +-- 'log':: This should make it easy to look up svn log messages when svn users refer to -r/--revision numbers. ++ +The following features from `svn log' are supported: ++ +-- +--revision=<n>[:<n>];; + is supported, non-numeric args are not: + HEAD, NEXT, BASE, PREV, etc ... +-v/--verbose;; + it's not completely compatible with the --verbose + output in svn log, but reasonably close. +--limit=<n>;; + is NOT the same as --max-count, doesn't count + merged/excluded commits +--incremental;; + supported +-- ++ +New features: ++ +-- +--show-commit;; + shows the git commit sha1, as well +--oneline;; + our version of --pretty=oneline +-- ++ +Any other arguments are passed directly to `git log' - The following features from `svn log' are supported: - - --revision=<n>[:<n>] - is supported, non-numeric args are not: - HEAD, NEXT, BASE, PREV, etc ... - -v/--verbose - it's not completely compatible with - the --verbose output in svn log, but - reasonably close. - --limit=<n> - is NOT the same as --max-count, - doesn't count merged/excluded commits - --incremental - supported - - New features: - - --show-commit - shows the git commit sha1, as well - --oneline - our version of --pretty=oneline - - Any other arguments are passed directly to `git log' - +-- 'set-tree':: You should consider using 'dcommit' instead of this command. Commit specified commit or tree objects to SVN. This relies on @@ -256,16 +275,18 @@ config key: svn.authorsfile Make git-svn less verbose. --repack[=<n>]:: ---repack-flags=<flags> - These should help keep disk usage sane for large fetches - with many revisions. +--repack-flags=<flags>:: - --repack takes an optional argument for the number of revisions - to fetch before repacking. This defaults to repacking every - 1000 commits fetched if no argument is specified. +These should help keep disk usage sane for large fetches +with many revisions. - --repack-flags are passed directly to gitlink:git-repack[1]. +--repack takes an optional argument for the number of revisions +to fetch before repacking. This defaults to repacking every +1000 commits fetched if no argument is specified. +--repack-flags are passed directly to gitlink:git-repack[1]. + +[verse] config key: svn.repack config key: svn.repackflags @@ -323,28 +344,30 @@ CONFIG FILE-ONLY OPTIONS svn.noMetadata:: svn-remote.<name>.noMetadata:: - This gets rid of the git-svn-id: lines at the end of every commit. - If you lose your .git/svn/git-svn/.rev_db file, git-svn will not - be able to rebuild it and you won't be able to fetch again, - either. This is fine for one-shot imports. +This gets rid of the git-svn-id: lines at the end of every commit. - The 'git-svn log' command will not work on repositories using - this, either. Using this conflicts with the 'useSvmProps' - option for (hopefully) obvious reasons. +If you lose your .git/svn/git-svn/.rev_db file, git-svn will not +be able to rebuild it and you won't be able to fetch again, +either. This is fine for one-shot imports. + +The 'git-svn log' command will not work on repositories using +this, either. Using this conflicts with the 'useSvmProps' +option for (hopefully) obvious reasons. svn.useSvmProps:: svn-remote.<name>.useSvmProps:: - This allows git-svn to re-map repository URLs and UUIDs from - mirrors created using SVN::Mirror (or svk) for metadata. - If an SVN revision has a property, "svm:headrev", it is likely - that the revision was created by SVN::Mirror (also used by SVK). - The property contains a repository UUID and a revision. We want - to make it look like we are mirroring the original URL, so - introduce a helper function that returns the original identity - URL and UUID, and use it when generating metadata in commit - messages. +This allows git-svn to re-map repository URLs and UUIDs from +mirrors created using SVN::Mirror (or svk) for metadata. + +If an SVN revision has a property, "svm:headrev", it is likely +that the revision was created by SVN::Mirror (also used by SVK). +The property contains a repository UUID and a revision. We want +to make it look like we are mirroring the original URL, so +introduce a helper function that returns the original identity +URL and UUID, and use it when generating metadata in commit +messages. svn.useSvnsyncProps:: svn-remote.<name>.useSvnsyncprops:: @@ -369,8 +392,8 @@ section because they affect the 'git-svn-id:' metadata line. -- -Basic Examples -~~~~~~~~~~~~~~ +BASIC EXAMPLES +-------------- Tracking and contributing to a the trunk of a Subversion-managed project: @@ -405,7 +428,7 @@ Tracking and contributing to an entire Subversion-managed project # with the appropriate name): git reset --hard remotes/trunk # You may only dcommit to one branch/tag/trunk at a time. The usage -# of dcommit/rebase/show-ignore should be teh same as above. +# of dcommit/rebase/show-ignore should be the same as above. ------------------------------------------------------------------------ REBASE VS. PULL/MERGE diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt index b161c8b32b..cd5e014d48 100644 --- a/Documentation/git-update-index.txt +++ b/Documentation/git-update-index.txt @@ -295,6 +295,11 @@ in the index and the file mode on the filesystem if they differ only on executable bit. On such an unfortunate filesystem, you may need to use `git-update-index --chmod=`. +Quite similarly, if `core.symlinks` configuration variable is set +to 'false' (see gitlink:git-config[1]), symbolic links are checked out +as plain files, and this command does not modify a recorded file mode +from symbolic link to regular file. + The command looks at `core.ignorestat` configuration variable. See 'Using "assume unchanged" bit' section above. diff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt index 9da062d5c9..fd6519299a 100644 --- a/Documentation/git-upload-pack.txt +++ b/Documentation/git-upload-pack.txt @@ -8,7 +8,7 @@ git-upload-pack - Send objects packed back to git-fetch-pack SYNOPSIS -------- -'git-upload-pack' <directory> +'git-upload-pack' [--strict] [--timeout=<n>] <directory> DESCRIPTION ----------- @@ -23,6 +23,13 @@ repository. For push operations, see 'git-send-pack'. OPTIONS ------- + +\--strict:: + Do not try <directory>/.git/ if <directory> is no git directory. + +\--timeout=<n>:: + Interrupt transfer after <n> seconds of inactivity. + <directory>:: The repository to sync from. diff --git a/Documentation/git.txt b/Documentation/git.txt index 9a74747989..e875e8318d 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -35,14 +35,14 @@ ifdef::stalenotes[] You are reading the documentation for the latest version of git. Documentation for older releases are available here: -* link:v1.5.0.2/git.html[documentation for release 1.5.0.2] +* link:v1.5.0.3/git.html[documentation for release 1.5.0.3] + +* link:v1.5.0.3/RelNotes-1.5.0.3.txt[release notes for 1.5.0.3] * link:v1.5.0.2/RelNotes-1.5.0.2.txt[release notes for 1.5.0.2] * link:v1.5.0.1/RelNotes-1.5.0.1.txt[release notes for 1.5.0.1] -* link:v1.5.0/git.html[documentation for release 1.5.0] - * link:v1.5.0/RelNotes-1.5.0.txt[release notes for 1.5.0] * link:v1.4.4.4/git.html[documentation for release 1.4.4.4] @@ -241,6 +241,12 @@ Identifier Terminology operate on a <tree> object but automatically dereferences <commit> and <tag> objects that point at a <tree>. +<commit-ish>:: + Indicates a commit or tag object name. A + command that takes a <commit-ish> argument ultimately wants to + operate on a <commit> object but automatically dereferences + <tag> objects that point at a <commit>. + <type>:: Indicates that an object type is required. Currently one of: `blob`, `tree`, `commit`, or `tag`. diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt index d20eb6270c..9f446241e2 100644 --- a/Documentation/glossary.txt +++ b/Documentation/glossary.txt @@ -73,6 +73,11 @@ DAG:: objects is acyclic (there is no chain which begins and ends with the same object). +dangling object:: + An unreachable object which is not reachable even from other + unreachable objects; a dangling object has no references to it + from any reference or object in the repository. + dircache:: You are *waaaaay* behind. @@ -350,6 +355,10 @@ tag:: unmerged index:: An index which contains unmerged index entries. +unreachable object:: + An object which is not reachable from a branch, tag, or any + other reference. + working tree:: The set of files and directories currently being worked on, i.e. you can work in your working tree without using git at all. diff --git a/Documentation/install-webdoc.sh b/Documentation/install-webdoc.sh index b3981936e3..cd3a18eb7f 100755 --- a/Documentation/install-webdoc.sh +++ b/Documentation/install-webdoc.sh @@ -2,7 +2,7 @@ T="$1" -for h in *.html *.txt howto/*.txt howto/*.html RelNotes-*.txt +for h in *.html *.txt howto/*.txt howto/*.html RelNotes-*.txt *.css do if test -f "$T/$h" && diff -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h" diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index fb0b0b9582..2fe6c31967 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -77,9 +77,53 @@ displayed in full, regardless of whether --abbrev or true parent commits, without taking grafts nor history simplification into account. + * 'format:' ++ +The 'format:' format allows you to specify which information +you want to show. It works a little bit like printf format, +with the notable exception that you get a newline with '%n' +instead of '\n'. + +E.g, 'format:"The author of %h was %an, %ar%nThe title was >>%s<<"' +would show something like this: + +The author of fe6e0ee was Junio C Hamano, 23 hours ago +The title was >>t4119: test autocomputing -p<n> for traditional diff input.<< + +The placeholders are: + +- '%H': commit hash +- '%h': abbreviated commit hash +- '%T': tree hash +- '%t': abbreviated tree hash +- '%P': parent hashes +- '%p': abbreviated parent hashes +- '%an': author name +- '%ae': author email +- '%ad': author date +- '%aD': author date, RFC2822 style +- '%ar': author date, relative +- '%at': author date, UNIX timestamp +- '%cn': committer name +- '%ce': committer email +- '%cd': committer date +- '%cD': committer date, RFC2822 style +- '%cr': committer date, relative +- '%ct': committer date, UNIX timestamp +- '%e': encoding +- '%s': subject +- '%b': body +- '%Cred': switch color to red +- '%Cgreen': switch color to green +- '%Cblue': switch color to blue +- '%Creset': reset color +- '%n': newline + + --encoding[=<encoding>]:: The commit objects record the encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. + diff --git a/Documentation/sort_glossary.pl b/Documentation/sort_glossary.pl index e0bc552a64..05dc7b2c7b 100644 --- a/Documentation/sort_glossary.pl +++ b/Documentation/sort_glossary.pl @@ -48,7 +48,7 @@ This list is sorted alphabetically: '; @keys=sort {uc($a) cmp uc($b)} keys %terms; -$pattern='(\b(?<!link:git-)'.join('\b|\b(?<!link:git-)',reverse @keys).'\b)'; +$pattern='(\b(?<!link:git-)'.join('\b|\b(?<!-)',reverse @keys).'\b)'; foreach $key (@keys) { $terms{$key}=~s/$pattern/sprintf "<<ref_".no_spaces($1).",$1>>";/eg; print '[[ref_'.no_spaces($key).']]'.$key."::\n" diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 03736bbcd3..d7b227e647 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -2,7 +2,7 @@ Git User's Manual _________________ This manual is designed to be readable by someone with basic unix -commandline skills, but no previous knowledge of git. +command-line skills, but no previous knowledge of git. Chapter 1 gives a brief overview of git commands, without any explanation; you may prefer to skip to chapter 2 on a first reading. @@ -391,15 +391,20 @@ index 8be626f..d7aac9d 100644 As you can see, a commit shows who made the latest change, what they did, and why. -Every commit has a 40-hexdigit id, sometimes called the "object name" -or the "SHA1 id", shown on the first line of the "git show" output. -You can usually refer to a commit by a shorter name, such as a tag or a -branch name, but this longer name can also be useful. Most -importantly, it is a globally unique name for this commit: so if you -tell somebody else the object name (for example in email), then you are -guaranteed that name will refer to the same commit in their repository -that it does in yours (assuming their repository has that commit at -all). +Every commit has a 40-hexdigit id, sometimes called the "object name" or the +"SHA1 id", shown on the first line of the "git show" output. You can usually +refer to a commit by a shorter name, such as a tag or a branch name, but this +longer name can also be useful. Most importantly, it is a globally unique +name for this commit: so if you tell somebody else the object name (for +example in email), then you are guaranteed that name will refer to the same +commit in their repository that it does in yours (assuming their repository +has that commit at all). Since the object name is computed as a hash over the +contents of the commit, you are guaranteed that the commit can never change +without its name also changing. + +In fact, in <<git-internals>> we shall see that everything stored in git +history, including file data and directory contents, is stored in an object +with a name that is a hash of its contents. Understanding history: commits, parents, and reachability ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -432,11 +437,14 @@ We will sometimes represent git history using diagrams like the one below. Commits are shown as "o", and the links between them with lines drawn with - / and \. Time goes left to right: + +................................................ o--o--o <-- Branch A / o--o--o <-- master \ o--o--o <-- Branch B +................................................ If we need to talk about a particular commit, the character "o" may be replaced with another letter or number. @@ -596,8 +604,8 @@ a new stanza: $ cat .git/config ... [remote "linux-nfs"] - url = git://linux-nfs.org/~bfields/git.git - fetch = +refs/heads/*:refs/remotes/linux-nfs-read/* + url = git://linux-nfs.org/pub/nfs-2.6.git + fetch = +refs/heads/*:refs/remotes/linux-nfs/* ... ------------------------------------------------- @@ -1128,17 +1136,9 @@ modified in two different ways in the remote branch and the local branch--then you are warned; the output may look something like this: ------------------------------------------------- -$ git pull . next -Trying really trivial in-index merge... -fatal: Merge requires file-level merging -Nope. -Merging HEAD with 77976da35a11db4580b80ae27e8d65caf5208086 -Merging: -15e2162 world -77976da goodbye -found 1 common ancestor(s): -d122ed4 initial -Auto-merging file.txt +$ git merge next + 100% (4/4) done +Auto-merged file.txt CONFLICT (content): Merge conflict in file.txt Automatic merge failed; fix conflicts and then commit the result. ------------------------------------------------- @@ -1163,18 +1163,46 @@ the working tree in a special state that gives you all the information you need to help resolve the merge. Files with conflicts are marked specially in the index, so until you -resolve the problem and update the index, git commit will fail: +resolve the problem and update the index, gitlink:git-commit[1] will +fail: ------------------------------------------------- $ git commit file.txt: needs merge ------------------------------------------------- -Also, git status will list those files as "unmerged". +Also, gitlink:git-status[1] will list those files as "unmerged", and the +files with conflicts will have conflict markers added, like this: + +------------------------------------------------- +<<<<<<< HEAD:file.txt +Hello world +======= +Goodbye +>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt +------------------------------------------------- + +All you need to do is edit the files to resolve the conflicts, and then + +------------------------------------------------- +$ git add file.txt +$ git commit +------------------------------------------------- + +Note that the commit message will already be filled in for you with +some information about the merge. Normally you can just use this +default message unchanged, but you may add additional commentary of +your own if desired. + +The above is all you need to know to resolve a simple merge. But git +also provides more information to help resolve conflicts: + +Getting conflict-resolution help during a merge +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All of the changes that git was able to merge automatically are already added to the index file, so gitlink:git-diff[1] shows only -the conflicts. Also, it uses a somewhat unusual syntax: +the conflicts. It uses an unusual syntax: ------------------------------------------------- $ git diff @@ -1195,14 +1223,32 @@ conflict will have two parents instead of the usual one: one parent will be HEAD, the tip of the current branch; the other will be the tip of the other branch, which is stored temporarily in MERGE_HEAD. -The diff above shows the differences between the working-tree version -of file.txt and two previous version: one version from HEAD, and one -from MERGE_HEAD. So instead of preceding each line by a single "+" -or "-", it now uses two columns: the first column is used for -differences between the first parent and the working directory copy, -and the second for differences between the second parent and the -working directory copy. Thus after resolving the conflict in the -obvious way, the diff will look like: +During the merge, the index holds three versions of each file. Each of +these three "file stages" represents a different version of the file: + +------------------------------------------------- +$ git show :1:file.txt # the file in a common ancestor of both branches +$ git show :2:file.txt # the version from HEAD, but including any + # nonconflicting changes from MERGE_HEAD +$ git show :3:file.txt # the version from MERGE_HEAD, but including any + # nonconflicting changes from HEAD. +------------------------------------------------- + +Since the stage 2 and stage 3 versions have already been updated with +nonconflicting changes, the only remaining differences between them are +the important ones; thus gitlink:git-diff[1] can use the information in +the index to show only those conflicts. + +The diff above shows the differences between the working-tree version of +file.txt and the stage 2 and stage 3 versions. So instead of preceding +each line by a single "+" or "-", it now uses two columns: the first +column is used for differences between the first parent and the working +directory copy, and the second for differences between the second parent +and the working directory copy. (See the "COMBINED DIFF FORMAT" section +of gitlink:git-diff-files[1] for a details of the format.) + +After resolving the conflict in the obvious way (but before updating the +index), the diff will look like: ------------------------------------------------- $ git diff @@ -1220,26 +1266,37 @@ This shows that our resolved version deleted "Hello world" from the first parent, deleted "Goodbye" from the second parent, and added "Goodbye world", which was previously absent from both. -The gitlink:git-log[1] command also provides special help for merges: +Some special diff options allow diffing the working directory against +any of these stages: + +------------------------------------------------- +$ git diff -1 file.txt # diff against stage 1 +$ git diff --base file.txt # same as the above +$ git diff -2 file.txt # diff against stage 2 +$ git diff --ours file.txt # same as the above +$ git diff -3 file.txt # diff against stage 3 +$ git diff --theirs file.txt # same as the above. +------------------------------------------------- + +The gitlink:git-log[1] and gitk[1] commands also provide special help +for merges: ------------------------------------------------- $ git log --merge +$ gitk --merge ------------------------------------------------- -This will list all commits which exist only on HEAD or on MERGE_HEAD, -and which touch an unmerged file. +These will display all commits which exist only on HEAD or on +MERGE_HEAD, and which touch an unmerged file. -We can now add the resolved version to the index and commit: +Each time you resolve the conflicts in a file and update the index: ------------------------------------------------- $ git add file.txt -$ git commit ------------------------------------------------- -Note that the commit message will already be filled in for you with -some information about the merge. Normally you can just use this -default message unchanged, but you may add additional commentary of -your own if desired. +the different stages of that file will be "collapsed", after which +git-diff will (by default) no longer show diffs for that file. [[undoing-a-merge]] undoing a merge @@ -1255,7 +1312,7 @@ $ git reset --hard HEAD Or, if you've already commited the merge that you want to throw away, ------------------------------------------------- -$ git reset --hard HEAD^ +$ git reset --hard ORIG_HEAD ------------------------------------------------- However, this last command can be dangerous in some cases--never @@ -1328,6 +1385,7 @@ with the changes to be reverted, then you will be asked to fix conflicts manually, just as in the case of <<resolving-a-merge, resolving a merge>>. +[[fixing-a-mistake-by-editing-history]] Fixing a mistake by editing history ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1376,7 +1434,7 @@ modifying the working directory, you can do that with gitlink:git-show[1]: ------------------------------------------------- -$ git show HEAD^ path/to/file +$ git show HEAD^:path/to/file ------------------------------------------------- which will display the given version of the file. @@ -1479,7 +1537,7 @@ Examining dangling objects In some situations the reflog may not be able to save you. For example, suppose you delete a branch, then realize you need the history -it pointed you. The reflog is also deleted; however, if you have not +it contained. The reflog is also deleted; however, if you have not yet pruned the repository, then you may still be able to find the lost commits; run git-fsck and watch for output that mentions "dangling commits": @@ -1505,7 +1563,7 @@ history that is described by all your existing branches and tags. Thus you get exactly the history reachable from that commit that is lost. (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 was gotten dropped.) +and complex commit history that was dropped.) If you decide you want the history back, you can always create a new reference pointing to it, for example, a new branch: @@ -1561,7 +1619,7 @@ repository that you pulled from. (But note that no such commit will be created in the case of a <<fast-forwards,fast forward>>; instead, your branch will just be -updated to point to the latest commit from the upstream branch). +updated to point to the latest commit from the upstream branch.) The git-pull command can also be given "." as the "remote" repository, in which case it just merges in a branch from the current repository; so @@ -1638,8 +1696,8 @@ updates with git pull>>". If you and maintainer both have accounts on the same machine, then then you can just pull changes from each other's repositories -directly; note that all of the command (gitlink:git-clone[1], -git-fetch[1], git-pull[1], etc.) which accept a URL as an argument +directly; note that all of the commands (gitlink:git-clone[1], +git-fetch[1], git-pull[1], etc.) that accept a URL as an argument will also accept a local file patch; so, for example, you can use @@ -1832,7 +1890,7 @@ that makes it easy for them to read your changes, verify that they are correct, and understand why you made each change. If you present all of your changes as a single patch (or commit), they -may find it is too much to digest all at once. +may find that it is too much to digest all at once. If you present them with the entire history of your work, complete with mistakes, corrections, and dead ends, they may be overwhelmed. @@ -1858,11 +1916,8 @@ you are rewriting history. Keeping a patch series up to date using git-rebase -------------------------------------------------- -Suppose you have a series of commits in a branch "mywork", which -originally branched off from "origin". - -Suppose you create a branch "mywork" on a remote-tracking branch -"origin", and created some commits on top of it: +Suppose that you create a branch "mywork" on a remote-tracking branch +"origin", and create some commits on top of it: ------------------------------------------------- $ git checkout -b mywork origin @@ -1876,25 +1931,29 @@ $ git commit You have performed no merges into mywork, so it is just a simple linear sequence of patches on top of "origin": - +................................................ o--o--o <-- origin \ o--o--o <-- mywork +................................................ Some more interesting work has been done in the upstream project, and "origin" has advanced: +................................................ o--o--O--o--o--o <-- origin \ a--b--c <-- mywork +................................................ At this point, you could use "pull" to merge your changes back in; the result would create a new merge commit, like this: - +................................................ o--o--O--o--o--o <-- origin \ \ a--b--c--m <-- mywork +................................................ However, if you prefer to keep the history in mywork a simple series of commits without any merges, you may instead choose to use @@ -1911,9 +1970,11 @@ point at the latest version of origin, then apply each of the saved patches to the new mywork. The result will look like: +................................................ o--o--O--o--o--o <-- origin \ a'--b'--c' <-- mywork +................................................ In the process, it may discover conflicts. In that case it will stop and allow you to fix the conflicts; after fixing conflicts, use "git @@ -1933,6 +1994,51 @@ return mywork to the state it had before you started the rebase: $ git rebase --abort ------------------------------------------------- +Modifying a single commit +------------------------- + +We saw in <<fixing-a-mistake-by-editing-history>> that you can replace the +most recent commit using + +------------------------------------------------- +$ git commit --amend +------------------------------------------------- + +which will replace the old commit by a new commit incorporating your +changes, giving you a chance to edit the old commit message first. + +You can also use a combination of this and gitlink:git-rebase[1] to edit +commits further back in your history. First, tag the problematic commit with + +------------------------------------------------- +$ git tag bad mywork~5 +------------------------------------------------- + +(Either gitk or git-log may be useful for finding the commit.) + +Then check out a new branch at that commit, edit it, and rebase the rest of +the series on top of it: + +------------------------------------------------- +$ git checkout -b TMP bad +$ # make changes here and update the index +$ git commit --amend +$ git rebase --onto TMP bad mywork +------------------------------------------------- + +When you're done, you'll be left with mywork checked out, with the top patches +on mywork reapplied on top of the modified commit you created in TMP. You can +then clean up with + +------------------------------------------------- +$ git branch -d TMP +$ git tag -d bad +------------------------------------------------- + +Note that the immutable nature of git history means that you haven't really +"modified" existing commits; instead, you have replaced the old commits with +new commits having new object names. + Reordering or selecting from a patch series ------------------------------------------- @@ -1966,7 +2072,7 @@ Other tools ----------- There are numerous other tools, such as stgit, which exist for the -purpose of maintaining a patch series. These are out of the scope of +purpose of maintaining a patch series. These are outside of the scope of this manual. Problems with rewriting history @@ -1976,24 +2082,30 @@ The primary problem with rewriting the history of a branch has to do with merging. Suppose somebody fetches your branch and merges it into their branch, with a result something like this: +................................................ o--o--O--o--o--o <-- origin \ \ t--t--t--m <-- their branch: +................................................ Then suppose you modify the last three commits: +................................................ o--o--o <-- new head of origin / o--o--O--o--o--o <-- old head of origin +................................................ If we examined all this history together in one repository, it will look like: +................................................ o--o--o <-- new head of origin / o--o--O--o--o--o <-- old head of origin \ \ t--t--t--m <-- their branch: +................................................ Git has no way of knowing that the new head is an updated version of the old head; it treats this situation exactly the same as it would if @@ -2054,9 +2166,11 @@ commit. Git calls this process a "fast forward". A fast forward looks something like this: +................................................ o--o--o--o <-- old head of the branch \ o--o--o <-- new head of the branch +................................................ In some cases it is possible that the new head will *not* actually be @@ -2064,11 +2178,11 @@ a descendant of the old head. For example, the developer may have realized she made a serious mistake, and decided to backtrack, resulting in a situation like: +................................................ o--o--o--o--a--b <-- old head of the branch \ o--o--o <-- new head of the branch - - +................................................ In this case, "git fetch" will fail, and print out a warning. @@ -2088,7 +2202,7 @@ descendant of the old head, you may force the update with: $ git fetch git://example.com/proj.git +master:refs/remotes/example/master ------------------------------------------------- -Note the addition of the "+" sign. Be aware that commits which the +Note the addition of the "+" sign. Be aware that commits that the old version of example/master pointed at may be lost, as we saw in the previous section. @@ -2096,7 +2210,7 @@ Configuring remote branches --------------------------- We saw above that "origin" is just a shortcut to refer to the -repository which you originally cloned from. This information is +repository that you originally cloned from. This information is stored in git configuration variables, which you can see using gitlink:git-config[1]: @@ -2158,6 +2272,7 @@ See gitlink:git-config[1] for more details on the configuration options mentioned above. +[[git-internals]] Git internals ============= @@ -2407,7 +2522,7 @@ 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 +Those are the ONLY three 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 @@ -2939,11 +3054,6 @@ provides. Simplify beginning by suggesting disconnected head instead of temporary branch creation? -Explain how to refer to file stages in the "how to resolve a merge" -section: diff -1, -2, -3, --ours, --theirs :1:/path notation. The -"git ls-files --unmerged --stage" thing is sorta useful too, -actually. And note gitk --merge. - Add more good examples. Entire sections of just cookbook examples might be a good idea; maybe make an "advanced examples" section a standard end-of-chapter section? @@ -1,6 +1,8 @@ # The default target of this Makefile is... all:: +# Define V=1 to have a more verbose compile. +# # Define NO_OPENSSL environment variable if you do not have OpenSSL. # This also implies MOZILLA_SHA1. # @@ -89,6 +91,9 @@ all:: # # Define NO_ICONV if your libc does not properly support iconv. # +# Define OLD_ICONV if your library has an old iconv(), where the second +# (input buffer pointer) parameter is declared with type (const char **). +# # Define NO_R_TO_GCC if your gcc does not like "-R/path/lib" that # tells runtime paths to dynamic libraries; "-Wl,-rpath=/path/lib" # is used instead. @@ -174,10 +179,10 @@ SCRIPT_SH = \ git-clean.sh git-clone.sh git-commit.sh \ git-fetch.sh git-gc.sh \ git-ls-remote.sh \ - git-merge-one-file.sh git-parse-remote.sh \ + git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \ git-pull.sh git-rebase.sh \ git-repack.sh git-request-pull.sh git-reset.sh \ - git-revert.sh git-sh-setup.sh \ + git-sh-setup.sh \ git-tag.sh git-verify-tag.sh \ git-applymbox.sh git-applypatch.sh git-am.sh \ git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \ @@ -193,7 +198,7 @@ SCRIPT_PERL = \ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ - git-cherry-pick git-status git-instaweb + git-status git-instaweb # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS = \ @@ -220,7 +225,7 @@ 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-repo-config$X \ - git-fsck-objects$X \ + git-fsck-objects$X git-cherry-pick$X \ $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS)) # what 'all' will build and 'install' will install, in gitexecdir @@ -277,6 +282,7 @@ BUILTIN_OBJS = \ builtin-archive.o \ builtin-blame.o \ builtin-branch.o \ + builtin-bundle.o \ builtin-cat-file.o \ builtin-checkout-index.o \ builtin-check-ref-format.o \ @@ -312,6 +318,7 @@ BUILTIN_OBJS = \ builtin-rerere.o \ builtin-rev-list.o \ builtin-rev-parse.o \ + builtin-revert.o \ builtin-rm.o \ builtin-runstatus.o \ builtin-shortlog.o \ @@ -378,7 +385,6 @@ ifeq ($(uname_O),Cygwin) NO_STRCASESTR = YesPlease NO_SYMLINK_HEAD = YesPlease NEEDS_LIBICONV = YesPlease - NO_C99_FORMAT = YesPlease NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes NO_TRUSTABLE_FILEMODE = UnfortunatelyYes # There are conflicting reports about this. @@ -576,6 +582,10 @@ ifdef NO_ICONV BASIC_CFLAGS += -DNO_ICONV endif +ifdef OLD_ICONV + BASIC_CFLAGS += -DOLD_ICONV +endif + ifdef PPC_SHA1 SHA1_HEADER = "ppc/sha1.h" LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o @@ -597,6 +607,31 @@ ifdef NO_PERL_MAKEMAKER export NO_PERL_MAKEMAKER endif +QUIET_SUBDIR0 = $(MAKE) -C # space to separate -C and subdir +QUIET_SUBDIR1 = + +ifneq ($(findstring $(MAKEFLAGS),w),w) +PRINT_DIR = --no-print-directory +else # "make -w" +NO_SUBDIR = : +endif + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_AR = @echo ' ' AR $@; + QUIET_LINK = @echo ' ' LINK $@; + QUIET_BUILT_IN = @echo ' ' BUILTIN $@; + QUIET_GEN = @echo ' ' GEN $@; + QUIET_SUBDIR0 = @subdir= + QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ + $(MAKE) $(PRINT_DIR) -C $$subdir + export V + export QUIET_GEN + export QUIET_BUILT_IN +endif +endif + # Shell quote (do not use $(call) to accommodate ancient setups); SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER)) @@ -631,44 +666,43 @@ ifneq (,$X) endif all:: - $(MAKE) -C git-gui all - $(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all - $(MAKE) -C templates + $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all + $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all + $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) strip: $(PROGRAMS) git$X $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS - $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \ + $(QUIET_LINK)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \ $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \ $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS) help.o: common-cmds.h $(BUILT_INS): git$X - rm -f $@ && ln git$X $@ + $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@ common-cmds.h: Documentation/git-*.txt - ./generate-cmdlist.sh > $@+ - mv $@+ $@ + $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh - rm -f $@ $@+ + $(QUIET_GEN)rm -f $@ $@+ && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ - $@.sh >$@+ - chmod +x $@+ + $@.sh >$@+ && \ + chmod +x $@+ && \ mv $@+ $@ $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak perl/perl.mak: GIT-CFLAGS - $(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F) + $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F) $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl - rm -f $@ $@+ + $(QUIET_GEN)rm -f $@ $@+ && \ INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \ sed -e '1{' \ -e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \ @@ -679,20 +713,15 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl -e '}' \ -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ - $@.perl >$@+ - chmod +x $@+ - mv $@+ $@ - -git-cherry-pick: git-revert - cp $< $@+ + $@.perl >$@+ && \ + chmod +x $@+ && \ mv $@+ $@ git-status: git-commit - cp $< $@+ - mv $@+ $@ + $(QUIET_GEN)cp $< $@+ && mv $@+ $@ gitweb/gitweb.cgi: gitweb/gitweb.perl - rm -f $@ $@+ + $(QUIET_GEN)rm -f $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \ -e 's|++GIT_BINDIR++|$(bindir)|g' \ @@ -710,12 +739,12 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ - chmod +x $@+ + $< >$@+ && \ + chmod +x $@+ && \ mv $@+ $@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css - rm -f $@ $@+ + $(QUIET_GEN)rm -f $@ $@+ && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ @@ -723,15 +752,15 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css -e '/@@GITWEB_CGI@@/d' \ -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \ -e '/@@GITWEB_CSS@@/d' \ - $@.sh > $@+ - chmod +x $@+ + $@.sh > $@+ && \ + chmod +x $@+ && \ mv $@+ $@ configure: configure.ac - rm -f $@ $<+ + $(QUIET_GEN)rm -f $@ $<+ && \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ - $< > $<+ - autoconf -o $@ $<+ + $< > $<+ && \ + autoconf -o $@ $<+ && \ rm -f $<+ # These can record GIT_VERSION @@ -741,25 +770,25 @@ git$X git.spec \ : GIT-VERSION-FILE %.o: %.c GIT-CFLAGS - $(CC) -o $*.o -c $(ALL_CFLAGS) $< + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $< %.o: %.S - $(CC) -o $*.o -c $(ALL_CFLAGS) $< + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $< exec_cmd.o: exec_cmd.c GIT-CFLAGS - $(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $< + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $< builtin-init-db.o: builtin-init-db.c GIT-CFLAGS - $(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $< + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $< http.o: http.c GIT-CFLAGS - $(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $< + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $< ifdef NO_EXPAT http-fetch.o: http-fetch.c http.h GIT-CFLAGS - $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $< + $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $< endif git-%$X: %.o $(GITLIBS) - $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) ssh-pull.o: ssh-fetch.c ssh-push.o: ssh-upload.c @@ -773,19 +802,19 @@ git-imap-send$X: imap-send.o $(LIB_FILE) http.o http-fetch.o http-push.o: http.h git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS) - $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) git-http-push$X: revision.o http.o http-push.o $(GITLIBS) - $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) -$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) +$(LIB_OBJS) $(BUILTIN_OBJS) fetch.o: $(LIB_H) $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) $(DIFF_OBJS): diffcore.h $(LIB_FILE): $(LIB_OBJS) - rm -f $@ && $(AR) rcs $@ $(LIB_OBJS) + $(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(LIB_OBJS) XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \ xdiff/xmerge.o @@ -793,7 +822,7 @@ $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \ xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h $(XDIFF_LIB): $(XDIFF_OBJS) - rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS) + $(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS) perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS @@ -903,8 +932,7 @@ dist: git.spec git-archive $(TAR) rf $(GIT_TARNAME).tar \ $(GIT_TARNAME)/git.spec \ $(GIT_TARNAME)/version \ - $(GIT_TARNAME)/git-gui/version \ - $(GIT_TARNAME)/git-gui/credits + $(GIT_TARNAME)/git-gui/version @rm -rf $(GIT_TARNAME) gzip -f -9 $(GIT_TARNAME).tar diff --git a/builtin-add.c b/builtin-add.c index 87e16aa220..9fcf514dbc 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -12,6 +12,8 @@ static const char builtin_add_usage[] = "git-add [-n] [-v] [-f] [--interactive | -i] [--] <filepattern>..."; +static const char *excludes_file; + static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { char *seen; @@ -67,6 +69,8 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) path = git_path("info/exclude"); if (!access(path, R_OK)) add_excludes_from_file(dir, path); + if (!access(excludes_file, R_OK)) + add_excludes_from_file(dir, excludes_file); /* * Calculate common prefix for the pathspec, and @@ -88,6 +92,18 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) prune_directory(dir, pathspec, baselen); } +static int git_add_config(const char *var, const char *value) +{ + if (!strcmp(var, "core.excludesfile")) { + if (!value) + die("core.excludesfile without value"); + excludes_file = xstrdup(value); + return 0; + } + + return git_default_config(var, value); +} + static struct lock_file lock_file; static const char ignore_warning[] = @@ -115,7 +131,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) exit(1); } - git_config(git_default_config); + git_config(git_add_config); newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1); diff --git a/builtin-apply.c b/builtin-apply.c index 38f647510a..dfa1716796 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -1981,7 +1981,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry * } } else if (patch->old_name) { - size = st->st_size; + size = xsize_t(st->st_size); alloc = size + 8192; buf = xmalloc(alloc); if (read_old_data(st, patch->old_name, &buf, &alloc, &size)) @@ -2359,7 +2359,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf, char *nbuf; unsigned long nsize; - if (S_ISLNK(mode)) + if (has_symlinks && S_ISLNK(mode)) /* Although buf:size is counted string, it also is NUL * terminated. */ diff --git a/builtin-archive.c b/builtin-archive.c index 8ea6cb1efc..2fae885f5c 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -252,8 +252,6 @@ int cmd_archive(int argc, const char **argv, const char *prefix) memset(&ar, 0, sizeof(ar)); tree_idx = parse_archive_args(argc, argv, &ar); - if (prefix == NULL) - prefix = setup_git_directory(); argv += tree_idx; parse_treeish_arg(argv, &ar.args, prefix); diff --git a/builtin-blame.c b/builtin-blame.c index 9f7dd4e19f..b51cdc71fa 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -1244,26 +1244,26 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt) */ struct commit_info { - char *author; - char *author_mail; + const char *author; + const char *author_mail; unsigned long author_time; - char *author_tz; + const char *author_tz; /* filled only when asked for details */ - char *committer; - char *committer_mail; + const char *committer; + const char *committer_mail; unsigned long committer_time; - char *committer_tz; + const char *committer_tz; - char *summary; + const 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) + int bufsz, char *person, const char **mail, + unsigned long *time, const char **tz) { int len; char *tmp, *endp; @@ -1280,7 +1280,7 @@ static void get_ac_line(const char *inbuf, const char *what, if (bufsz <= len) { error_out: /* Ugh */ - person = *mail = *tz = "(unknown)"; + *mail = *tz = "(unknown)"; *time = 0; return; } @@ -1963,7 +1963,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con die("Cannot lstat %s", path); read_from = path; } - fin_size = st.st_size; + fin_size = xsize_t(st.st_size); buf = xmalloc(fin_size+1); mode = canon_mode(st.st_mode); switch (st.st_mode & S_IFMT) { diff --git a/builtin-branch.c b/builtin-branch.c index d0179b00a2..42b1ff129e 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -12,7 +12,7 @@ #include "builtin.h" static const char builtin_branch_usage[] = - "git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [--color | --no-color] [-r | -a] [-v [--abbrev=<length>]]"; + "git-branch [-r] (-d | -D) <branchname> | [--track | --no-track] [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [--color | --no-color] [-r | -a] [-v [--abbrev=<length> | --no-abbrev]]"; #define REF_UNKNOWN_TYPE 0x00 #define REF_LOCAL_BRANCH 0x01 @@ -22,6 +22,8 @@ static const char builtin_branch_usage[] = static const char *head; static unsigned char head_sha1[20]; +static int branch_track_remotes; + static int branch_use_color; static char branch_colors[][COLOR_MAXLEN] = { "\033[m", /* reset */ @@ -64,6 +66,9 @@ int git_branch_config(const char *var, const char *value) color_parse(value, var, branch_colors[slot]); return 0; } + if (!strcmp(var, "branch.autosetupmerge")) + branch_track_remotes = git_config_bool(var, value); + return git_default_config(var, value); } @@ -289,12 +294,13 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev) detached = (detached && (kinds & REF_LOCAL_BRANCH)); if (detached) { struct ref_item item; - item.name = "(no branch)"; + item.name = xstrdup("(no branch)"); item.kind = REF_LOCAL_BRANCH; hashcpy(item.sha1, head_sha1); if (strlen(item.name) > ref_list.maxwidth) ref_list.maxwidth = strlen(item.name); print_ref_item(&item, ref_list.maxwidth, verbose, abbrev, 1); + free(item.name); } for (i = 0; i < ref_list.index; i++) { @@ -308,14 +314,108 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev) free_ref_list(&ref_list); } +static char *config_repo; +static char *config_remote; +static const char *start_ref; +static int start_len; +static int base_len; + +static int get_remote_branch_name(const char *value) +{ + const char *colon; + const char *end; + + if (*value == '+') + value++; + + colon = strchr(value, ':'); + if (!colon) + return 0; + + end = value + strlen(value); + + /* Try an exact match first. */ + if (!strcmp(colon + 1, start_ref)) { + /* Truncate the value before the colon. */ + nfasprintf(&config_repo, "%.*s", colon - value, value); + return 1; + } + + /* Try with a wildcard match now. */ + if (end - value > 2 && end[-2] == '/' && end[-1] == '*' && + colon - value > 2 && colon[-2] == '/' && colon[-1] == '*' && + (end - 2) - (colon + 1) == base_len && + !strncmp(colon + 1, start_ref, base_len)) { + /* Replace the star with the remote branch name. */ + nfasprintf(&config_repo, "%.*s%s", + (colon - 2) - value, value, + start_ref + base_len); + return 1; + } + + return 0; +} + +static int get_remote_config(const char *key, const char *value) +{ + const char *var; + if (prefixcmp(key, "remote.")) + return 0; + + var = strrchr(key, '.'); + if (var == key + 6) + return 0; + + if (!strcmp(var, ".fetch") && get_remote_branch_name(value)) + nfasprintf(&config_remote, "%.*s", var - (key + 7), key + 7); + + return 0; +} + +static void set_branch_defaults(const char *name, const char *real_ref) +{ + char key[1024]; + const char *slash = strrchr(real_ref, '/'); + + if (!slash) + return; + + start_ref = real_ref; + start_len = strlen(real_ref); + base_len = slash - real_ref; + git_config(get_remote_config); + + if (config_repo && config_remote) { + if (sizeof(key) <= + snprintf(key, sizeof(key), "branch.%s.remote", name)) + die("what a long branch name you have!"); + git_config_set(key, config_remote); + + /* + * We do not have to check if we have enough space for + * the 'merge' key, since it's shorter than the + * previous 'remote' key, which we already checked. + */ + snprintf(key, sizeof(key), "branch.%s.merge", name); + git_config_set(key, config_repo); + + printf("Branch %s set up to track remote branch %s.\n", + name, real_ref); + } + + if (config_repo) + free(config_repo); + if (config_remote) + free(config_remote); +} + static void create_branch(const char *name, const char *start_name, - unsigned char *start_sha1, - int force, int reflog) + int force, int reflog, int track) { struct ref_lock *lock; struct commit *commit; unsigned char sha1[20]; - char ref[PATH_MAX], msg[PATH_MAX + 20]; + char *real_ref, ref[PATH_MAX], msg[PATH_MAX + 20]; int forcing = 0; snprintf(ref, sizeof ref, "refs/heads/%s", name); @@ -330,12 +430,23 @@ static void create_branch(const char *name, const char *start_name, forcing = 1; } - if (start_sha1) - /* detached HEAD */ - hashcpy(sha1, start_sha1); - else if (get_sha1(start_name, sha1)) + real_ref = NULL; + if (get_sha1(start_name, sha1)) die("Not a valid object name: '%s'.", start_name); + switch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) { + case 0: + /* Not branching from any existing branch */ + real_ref = NULL; + break; + case 1: + /* Unique completion -- good */ + break; + default: + die("Ambiguous object name: '%s'.", start_name); + break; + } + if ((commit = lookup_commit_reference(sha1)) == NULL) die("Not a valid branch point: '%s'.", start_name); hashcpy(sha1, commit->object.sha1); @@ -354,8 +465,17 @@ static void create_branch(const char *name, const char *start_name, snprintf(msg, sizeof msg, "branch: Created from %s", start_name); + /* When branching off a remote branch, set up so that git-pull + automatically merges from there. So far, this is only done for + remotes registered via .git/config. */ + if (real_ref && track) + set_branch_defaults(name, real_ref); + if (write_ref_sha1(lock, sha1, msg) < 0) die("Failed to write ref: %s.", strerror(errno)); + + if (real_ref) + free(real_ref); } static void rename_branch(const char *oldname, const char *newname, int force) @@ -397,11 +517,12 @@ int cmd_branch(int argc, const char **argv, const char *prefix) int delete = 0, force_delete = 0, force_create = 0; int rename = 0, force_rename = 0; int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0; - int reflog = 0; + int reflog = 0, track; int kinds = REF_LOCAL_BRANCH; int i; git_config(git_branch_config); + track = branch_track_remotes; for (i = 1; i < argc; i++) { const char *arg = argv[i]; @@ -412,6 +533,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix) i++; break; } + if (!strcmp(arg, "--track")) { + track = 1; + continue; + } + if (!strcmp(arg, "--no-track")) { + track = 0; + continue; + } if (!strcmp(arg, "-d")) { delete = 1; continue; @@ -446,8 +575,16 @@ int cmd_branch(int argc, const char **argv, const char *prefix) reflog = 1; continue; } + if (!prefixcmp(arg, "--no-abbrev")) { + abbrev = 0; + continue; + } if (!prefixcmp(arg, "--abbrev=")) { - abbrev = atoi(arg+9); + abbrev = strtoul(arg + 9, NULL, 10); + if (abbrev < MINIMUM_ABBREV) + abbrev = MINIMUM_ABBREV; + else if (abbrev > 40) + abbrev = 40; continue; } if (!strcmp(arg, "-v")) { @@ -489,10 +626,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix) rename_branch(head, argv[i], force_rename); else if (rename && (i == argc - 2)) rename_branch(argv[i], argv[i + 1], force_rename); - else if (i == argc - 1) - create_branch(argv[i], head, head_sha1, force_create, reflog); - else if (i == argc - 2) - create_branch(argv[i], argv[i+1], NULL, force_create, reflog); + else if (i == argc - 1 || i == argc - 2) + create_branch(argv[i], (i == argc - 2) ? argv[i+1] : head, + force_create, reflog, track); else usage(builtin_branch_usage); diff --git a/builtin-bundle.c b/builtin-bundle.c new file mode 100644 index 0000000000..786808081b --- /dev/null +++ b/builtin-bundle.c @@ -0,0 +1,449 @@ +#include "cache.h" +#include "object.h" +#include "commit.h" +#include "diff.h" +#include "revision.h" +#include "list-objects.h" +#include "exec_cmd.h" + +/* + * Basic handler for bundle files to connect repositories via sneakernet. + * Invocation must include action. + * This function can create a bundle or provide information on an existing + * bundle supporting git-fetch, git-pull, and git-ls-remote + */ + +static const char *bundle_usage="git-bundle (create <bundle> <git-rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )"; + +static const char bundle_signature[] = "# v2 git bundle\n"; + +struct ref_list { + unsigned int nr, alloc; + struct ref_list_entry { + unsigned char sha1[20]; + char *name; + } *list; +}; + +static void add_to_ref_list(const unsigned char *sha1, const char *name, + struct ref_list *list) +{ + if (list->nr + 1 >= list->alloc) { + list->alloc = alloc_nr(list->nr + 1); + list->list = xrealloc(list->list, + list->alloc * sizeof(list->list[0])); + } + memcpy(list->list[list->nr].sha1, sha1, 20); + list->list[list->nr].name = xstrdup(name); + list->nr++; +} + +struct bundle_header { + struct ref_list prerequisites; + struct ref_list references; +}; + +/* this function returns the length of the string */ +static int read_string(int fd, char *buffer, int size) +{ + int i; + for (i = 0; i < size - 1; i++) { + int count = xread(fd, buffer + i, 1); + if (count < 0) + return error("Read error: %s", strerror(errno)); + if (count == 0) { + i--; + break; + } + if (buffer[i] == '\n') + break; + } + buffer[i + 1] = '\0'; + return i + 1; +} + +/* returns an fd */ +static int read_header(const char *path, struct bundle_header *header) { + char buffer[1024]; + int fd = open(path, O_RDONLY); + + if (fd < 0) + return error("could not open '%s'", path); + if (read_string(fd, buffer, sizeof(buffer)) < 0 || + strcmp(buffer, bundle_signature)) { + close(fd); + return error("'%s' does not look like a v2 bundle file", path); + } + while (read_string(fd, buffer, sizeof(buffer)) > 0 + && buffer[0] != '\n') { + int is_prereq = buffer[0] == '-'; + int offset = is_prereq ? 1 : 0; + int len = strlen(buffer); + unsigned char sha1[20]; + struct ref_list *list = is_prereq ? &header->prerequisites + : &header->references; + char delim; + + if (buffer[len - 1] == '\n') + buffer[len - 1] = '\0'; + if (get_sha1_hex(buffer + offset, sha1)) { + warn("unrecognized header: %s", buffer); + continue; + } + delim = buffer[40 + offset]; + if (!isspace(delim) && (delim != '\0' || !is_prereq)) + die ("invalid header: %s", buffer); + add_to_ref_list(sha1, isspace(delim) ? + buffer + 41 + offset : "", list); + } + return fd; +} + +/* if in && *in >= 0, take that as input file descriptor instead */ +static int fork_with_pipe(const char **argv, int *in, int *out) +{ + int needs_in, needs_out; + int fdin[2], fdout[2], pid; + + needs_in = in && *in < 0; + if (needs_in) { + if (pipe(fdin) < 0) + return error("could not setup pipe"); + *in = fdin[1]; + } + + needs_out = out && *out < 0; + if (needs_out) { + if (pipe(fdout) < 0) + return error("could not setup pipe"); + *out = fdout[0]; + } + + if ((pid = fork()) < 0) { + if (needs_in) { + close(fdin[0]); + close(fdin[1]); + } + if (needs_out) { + close(fdout[0]); + close(fdout[1]); + } + return error("could not fork"); + } + if (!pid) { + if (needs_in) { + dup2(fdin[0], 0); + close(fdin[0]); + close(fdin[1]); + } else if (in) { + dup2(*in, 0); + close(*in); + } + if (needs_out) { + dup2(fdout[1], 1); + close(fdout[0]); + close(fdout[1]); + } else if (out) { + dup2(*out, 1); + close(*out); + } + exit(execv_git_cmd(argv)); + } + if (needs_in) + close(fdin[0]); + else if (in) + close(*in); + if (needs_out) + close(fdout[1]); + else if (out) + close(*out); + return pid; +} + +static int list_refs(struct ref_list *r, int argc, const char **argv) +{ + int i; + + for (i = 0; i < r->nr; i++) { + if (argc > 1) { + int j; + for (j = 1; j < argc; j++) + if (!strcmp(r->list[i].name, argv[j])) + break; + if (j == argc) + continue; + } + printf("%s %s\n", sha1_to_hex(r->list[i].sha1), + r->list[i].name); + } + return 0; +} + +#define PREREQ_MARK (1u<<16) + +static int verify_bundle(struct bundle_header *header, int verbose) +{ + /* + * Do fast check, then if any prereqs are missing then go line by line + * to be verbose about the errors + */ + struct ref_list *p = &header->prerequisites; + struct rev_info revs; + const char *argv[] = {NULL, "--all"}; + struct object_array refs; + struct commit *commit; + int i, ret = 0, req_nr; + const char *message = "Repository lacks these prerequisite commits:"; + + init_revisions(&revs, NULL); + for (i = 0; i < p->nr; i++) { + struct ref_list_entry *e = p->list + i; + struct object *o = parse_object(e->sha1); + if (o) { + o->flags |= PREREQ_MARK; + add_pending_object(&revs, o, e->name); + continue; + } + if (++ret == 1) + error(message); + error("%s %s", sha1_to_hex(e->sha1), e->name); + } + if (revs.pending.nr != p->nr) + return ret; + req_nr = revs.pending.nr; + setup_revisions(2, argv, &revs, NULL); + + memset(&refs, 0, sizeof(struct object_array)); + for (i = 0; i < revs.pending.nr; i++) { + struct object_array_entry *e = revs.pending.objects + i; + add_object_array(e->item, e->name, &refs); + } + + prepare_revision_walk(&revs); + + i = req_nr; + while (i && (commit = get_revision(&revs))) + if (commit->object.flags & PREREQ_MARK) + i--; + + for (i = 0; i < req_nr; i++) + if (!(refs.objects[i].item->flags & SHOWN)) { + if (++ret == 1) + error(message); + error("%s %s", sha1_to_hex(refs.objects[i].item->sha1), + refs.objects[i].name); + } + + for (i = 0; i < refs.nr; i++) + clear_commit_marks((struct commit *)refs.objects[i].item, -1); + + if (verbose) { + struct ref_list *r; + + r = &header->references; + printf("The bundle contains %d ref%s\n", + r->nr, (1 < r->nr) ? "s" : ""); + list_refs(r, 0, NULL); + r = &header->prerequisites; + printf("The bundle requires these %d ref%s\n", + r->nr, (1 < r->nr) ? "s" : ""); + list_refs(r, 0, NULL); + } + return ret; +} + +static int list_heads(struct bundle_header *header, int argc, const char **argv) +{ + return list_refs(&header->references, argc, argv); +} + +static int create_bundle(struct bundle_header *header, const char *path, + int argc, const char **argv) +{ + int bundle_fd = -1; + const char **argv_boundary = xmalloc((argc + 4) * sizeof(const char *)); + const char **argv_pack = xmalloc(5 * sizeof(const char *)); + int pid, in, out, i, status, ref_count = 0; + char buffer[1024]; + struct rev_info revs; + + bundle_fd = (!strcmp(path, "-") ? 1 : + open(path, O_CREAT | O_EXCL | O_WRONLY, 0666)); + if (bundle_fd < 0) + return error("Could not create '%s': %s", path, strerror(errno)); + + /* write signature */ + write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature)); + + /* init revs to list objects for pack-objects later */ + save_commit_buffer = 0; + init_revisions(&revs, NULL); + + /* write prerequisites */ + memcpy(argv_boundary + 3, argv + 1, argc * sizeof(const char *)); + argv_boundary[0] = "rev-list"; + argv_boundary[1] = "--boundary"; + argv_boundary[2] = "--pretty=oneline"; + argv_boundary[argc + 2] = NULL; + out = -1; + pid = fork_with_pipe(argv_boundary, NULL, &out); + if (pid < 0) + return -1; + while ((i = read_string(out, buffer, sizeof(buffer))) > 0) { + unsigned char sha1[20]; + if (buffer[0] == '-') { + write_or_die(bundle_fd, buffer, i); + if (!get_sha1_hex(buffer + 1, sha1)) { + struct object *object = parse_object(sha1); + object->flags |= UNINTERESTING; + add_pending_object(&revs, object, buffer); + } + } else if (!get_sha1_hex(buffer, sha1)) { + struct object *object = parse_object(sha1); + object->flags |= SHOWN; + } + } + while ((i = waitpid(pid, &status, 0)) < 0) + if (errno != EINTR) + return error("rev-list died"); + if (!WIFEXITED(status) || WEXITSTATUS(status)) + return error("rev-list died %d", WEXITSTATUS(status)); + + /* write references */ + argc = setup_revisions(argc, argv, &revs, NULL); + if (argc > 1) + return error("unrecognized argument: %s'", argv[1]); + + for (i = 0; i < revs.pending.nr; i++) { + struct object_array_entry *e = revs.pending.objects + i; + unsigned char sha1[20]; + char *ref; + + if (e->item->flags & UNINTERESTING) + continue; + if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1) + continue; + /* + * Make sure the refs we wrote out is correct; --max-count and + * other limiting options could have prevented all the tips + * from getting output. + */ + if (!(e->item->flags & SHOWN)) { + warn("ref '%s' is excluded by the rev-list options", + e->name); + continue; + } + ref_count++; + write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40); + write_or_die(bundle_fd, " ", 1); + write_or_die(bundle_fd, ref, strlen(ref)); + write_or_die(bundle_fd, "\n", 1); + free(ref); + } + if (!ref_count) + die ("Refusing to create empty bundle."); + + /* end header */ + write_or_die(bundle_fd, "\n", 1); + + /* write pack */ + argv_pack[0] = "pack-objects"; + argv_pack[1] = "--all-progress"; + argv_pack[2] = "--stdout"; + argv_pack[3] = "--thin"; + argv_pack[4] = NULL; + in = -1; + out = bundle_fd; + pid = fork_with_pipe(argv_pack, &in, &out); + if (pid < 0) + return error("Could not spawn pack-objects"); + for (i = 0; i < revs.pending.nr; i++) { + struct object *object = revs.pending.objects[i].item; + if (object->flags & UNINTERESTING) + write(in, "^", 1); + write(in, sha1_to_hex(object->sha1), 40); + write(in, "\n", 1); + } + close(in); + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + return -1; + if (!WIFEXITED(status) || WEXITSTATUS(status)) + return error ("pack-objects died"); + + return status; +} + +static int unbundle(struct bundle_header *header, int bundle_fd, + int argc, const char **argv) +{ + const char *argv_index_pack[] = {"index-pack", + "--fix-thin", "--stdin", NULL}; + int pid, status, dev_null; + + if (verify_bundle(header, 0)) + return -1; + dev_null = open("/dev/null", O_WRONLY); + if (dev_null < 0) + return error("Could not open /dev/null"); + pid = fork_with_pipe(argv_index_pack, &bundle_fd, &dev_null); + if (pid < 0) + return error("Could not spawn index-pack"); + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + return error("index-pack died"); + if (!WIFEXITED(status) || WEXITSTATUS(status)) + return error("index-pack exited with status %d", + WEXITSTATUS(status)); + return list_heads(header, argc, argv); +} + +int cmd_bundle(int argc, const char **argv, const char *prefix) +{ + struct bundle_header header; + int nongit = 0; + const char *cmd, *bundle_file; + int bundle_fd = -1; + char buffer[PATH_MAX]; + + if (argc < 3) + usage(bundle_usage); + + cmd = argv[1]; + bundle_file = argv[2]; + argc -= 2; + argv += 2; + + prefix = setup_git_directory_gently(&nongit); + if (prefix && bundle_file[0] != '/') { + snprintf(buffer, sizeof(buffer), "%s/%s", prefix, bundle_file); + bundle_file = buffer; + } + + memset(&header, 0, sizeof(header)); + if (strcmp(cmd, "create") && + (bundle_fd = read_header(bundle_file, &header)) < 0) + return 1; + + if (!strcmp(cmd, "verify")) { + close(bundle_fd); + if (verify_bundle(&header, 1)) + return 1; + fprintf(stderr, "%s is okay\n", bundle_file); + return 0; + } + if (!strcmp(cmd, "list-heads")) { + close(bundle_fd); + return !!list_heads(&header, argc, argv); + } + if (!strcmp(cmd, "create")) { + if (nongit) + die("Need a repository to create a bundle."); + return !!create_bundle(&header, bundle_file, argc, argv); + } else if (!strcmp(cmd, "unbundle")) { + if (nongit) + die("Need a repository to unbundle."); + return !!unbundle(&header, bundle_fd, argc, argv); + } else + usage(bundle_usage); +} diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index 04f61d5101..4a8d8d8b67 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -45,14 +45,14 @@ static void add_buffer(char **bufp, unsigned int *sizep, const char *fmt, ...) memcpy(buf + size, one_line, len); } -static void check_valid(unsigned char *sha1, const char *expect) +static void check_valid(unsigned char *sha1, enum object_type expect) { enum object_type type = sha1_object_info(sha1, NULL); if (type < 0) die("%s is not a valid object", sha1_to_hex(sha1)); - if (expect && type != type_from_string(expect)) + if (type != expect) die("%s is not a valid '%s' object", sha1_to_hex(sha1), - expect); + typename(expect)); } /* @@ -100,7 +100,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) if (get_sha1(argv[1], tree_sha1)) die("Not a valid object name %s", argv[1]); - check_valid(tree_sha1, tree_type); + check_valid(tree_sha1, OBJ_TREE); for (i = 2; i < argc; i += 2) { const char *a, *b; a = argv[i]; b = argv[i+1]; @@ -111,7 +111,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) die("Too many parents (%d max)", MAXPARENT); if (get_sha1(b, parent_sha1[parents])) die("Not a valid object name %s", b); - check_valid(parent_sha1[parents], commit_type); + check_valid(parent_sha1[parents], OBJ_COMMIT); if (new_parent(parents)) parents++; } diff --git a/builtin-config.c b/builtin-config.c index f1433a4ab6..dfa403b94b 100644 --- a/builtin-config.c +++ b/builtin-config.c @@ -2,7 +2,7 @@ #include "cache.h" static const char git_config_set_usage[] = -"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"; +"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 | --remove-section name | --list"; static char *key; static regex_t *key_regexp; @@ -168,6 +168,19 @@ int cmd_config(int argc, const char **argv, const char *prefix) } return 0; } + else if (!strcmp(argv[1], "--remove-section")) { + int ret; + if (argc != 3) + usage(git_config_set_usage); + ret = git_config_rename_section(argv[2], NULL); + if (ret < 0) + return ret; + if (ret == 0) { + fprintf(stderr, "No such section!\n"); + return 1; + } + return 0; + } else break; argc--; diff --git a/builtin-count-objects.c b/builtin-count-objects.c index f5b22bb80e..6263d8af29 100644 --- a/builtin-count-objects.c +++ b/builtin-count-objects.c @@ -44,7 +44,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose, if (lstat(path, &st) || !S_ISREG(st.st_mode)) bad = 1; else - (*loose_size) += st.st_blocks; + (*loose_size) += xsize_t(st.st_blocks); } if (bad) { if (verbose) { diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 5d4a5c5828..aec8338429 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -10,42 +10,24 @@ #include "builtin.h" static const char diff_files_usage[] = -"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]" +"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|-n|--no-index] [<common diff options>] [<path>...]" COMMON_DIFF_OPTIONS_HELP; int cmd_diff_files(int argc, const char **argv, const char *prefix) { struct rev_info rev; - int silent = 0; + int nongit = 0; + prefix = setup_git_directory_gently(&nongit); init_revisions(&rev, prefix); git_config(git_default_config); /* no "diff" UI options */ rev.abbrev = 0; - argc = setup_revisions(argc, argv, &rev, NULL); - while (1 < argc && argv[1][0] == '-') { - if (!strcmp(argv[1], "--base")) - rev.max_count = 1; - else if (!strcmp(argv[1], "--ours")) - rev.max_count = 2; - else if (!strcmp(argv[1], "--theirs")) - rev.max_count = 3; - else if (!strcmp(argv[1], "-q")) - silent = 1; - else - usage(diff_files_usage); - argv++; argc--; - } + if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) + argc = 0; + else + argc = setup_revisions(argc, argv, &rev, NULL); if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; - - /* - * Make sure there are NO revision (i.e. pending object) parameter, - * rev.max_count is reasonable (0 <= n <= 3), - * there is no other revision filtering parameters. - */ - if (rev.pending.nr || - rev.min_age != -1 || rev.max_age != -1) - usage(diff_files_usage); - return run_diff_files(&rev, silent); + return run_diff_files_cmd(&rev, argc, argv); } diff --git a/builtin-diff-index.c b/builtin-diff-index.c index 95a3db156b..083599d5c4 100644 --- a/builtin-diff-index.c +++ b/builtin-diff-index.c @@ -38,5 +38,9 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) if (rev.pending.nr != 1 || rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1) usage(diff_cache_usage); + if (read_cache() < 0) { + perror("read_cache"); + return -1; + } return run_diff_index(&rev, cached); } diff --git a/builtin-diff.c b/builtin-diff.c index 67f49329bf..4efbb8237b 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -25,40 +25,6 @@ struct blobinfo { static const char builtin_diff_usage[] = "git-diff <options> <rev>{0,2} -- <path>*"; -static int builtin_diff_files(struct rev_info *revs, - int argc, const char **argv) -{ - int silent = 0; - while (1 < argc) { - const char *arg = argv[1]; - if (!strcmp(arg, "--base")) - revs->max_count = 1; - else if (!strcmp(arg, "--ours")) - revs->max_count = 2; - else if (!strcmp(arg, "--theirs")) - revs->max_count = 3; - else if (!strcmp(arg, "-q")) - silent = 1; - else - usage(builtin_diff_usage); - argv++; argc--; - } - /* - * Make sure there are NO revision (i.e. pending object) parameter, - * specified rev.max_count is reasonable (0 <= n <= 3), and - * there is no other revision filtering parameter. - */ - if (revs->pending.nr || - revs->min_age != -1 || - revs->max_age != -1 || - 3 < revs->max_count) - usage(builtin_diff_usage); - if (revs->max_count < 0 && - (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) - revs->combine_merges = revs->dense_combined_merges = 1; - return run_diff_files(revs, silent); -} - static void stuff_change(struct diff_options *opt, unsigned old_mode, unsigned new_mode, const unsigned char *old_sha1, @@ -151,6 +117,10 @@ static int builtin_diff_index(struct rev_info *revs, revs->max_count != -1 || revs->min_age != -1 || revs->max_age != -1) usage(builtin_diff_usage); + if (read_cache() < 0) { + perror("read_cache"); + return -1; + } return run_diff_index(revs, cached); } @@ -219,6 +189,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) int ents = 0, blobs = 0, paths = 0; const char *path = NULL; struct blobinfo blob[2]; + int nongit = 0; /* * We could get N tree-ish in the rev.pending_objects list. @@ -240,10 +211,14 @@ int cmd_diff(int argc, const char **argv, const char *prefix) * Other cases are errors. */ + prefix = setup_git_directory_gently(&nongit); git_config(git_diff_ui_config); init_revisions(&rev, prefix); - argc = setup_revisions(argc, argv, &rev, NULL); + if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) + argc = 0; + else + argc = setup_revisions(argc, argv, &rev, NULL); if (!rev.diffopt.output_format) { rev.diffopt.output_format = DIFF_FORMAT_PATCH; if (diff_setup_done(&rev.diffopt) < 0) @@ -317,7 +292,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (!ents) { switch (blobs) { case 0: - return builtin_diff_files(&rev, argc, argv); + return run_diff_files_cmd(&rev, argc, argv); break; case 1: if (paths != 1) diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c index 1489883564..5c145d2165 100644 --- a/builtin-fmt-merge-msg.c +++ b/builtin-fmt-merge-msg.c @@ -259,13 +259,15 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) else if (!strcmp(argv[1], "--no-summary")) merge_summary = 0; else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) { - if (argc < 2) + if (argc < 3) die ("Which file?"); if (!strcmp(argv[2], "-")) in = stdin; else { fclose(in); in = fopen(argv[2], "r"); + if (!in) + die("cannot open %s", argv[2]); } argc--; argv++; } else diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index b11ca928d6..2b218425aa 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -301,7 +301,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un return ""; } -static char *copy_line(const char *buf) +static const char *copy_line(const char *buf) { const char *eol = strchr(buf, '\n'); char *line; @@ -315,7 +315,7 @@ static char *copy_line(const char *buf) return line; } -static char *copy_name(const char *buf) +static const char *copy_name(const char *buf) { const char *eol = strchr(buf, '\n'); const char *eoname = strstr(buf, " <"); @@ -330,7 +330,7 @@ static char *copy_name(const char *buf) return line; } -static char *copy_email(const char *buf) +static const char *copy_email(const char *buf) { const char *email = strchr(buf, '<'); const char *eoemail = strchr(email, '>'); diff --git a/builtin-fsck.c b/builtin-fsck.c index 6abf498d2b..b8e71b640b 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -18,6 +18,9 @@ static int check_full; static int check_strict; static int keep_cache_objects; static unsigned char head_sha1[20]; +static int errors_found; +#define ERROR_OBJECT 01 +#define ERROR_REACHABLE 02 #ifdef NO_D_INO_IN_DIRENT #define SORT_DIRENT 0 @@ -40,6 +43,7 @@ static int objerror(struct object *obj, const char *err, ...) { va_list params; va_start(params, err); + errors_found |= ERROR_OBJECT; objreport(obj, "error", err, params); va_end(params); return -1; @@ -67,9 +71,10 @@ static void check_reachable_object(struct object *obj) * do a full fsck */ if (!obj->parsed) { - if (has_sha1_file(obj->sha1)) + if (has_sha1_pack(obj->sha1, NULL)) return; /* it is in pack - forget about it */ printf("missing %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1)); + errors_found |= ERROR_REACHABLE; return; } @@ -88,6 +93,7 @@ static void check_reachable_object(struct object *obj) typename(obj->type), sha1_to_hex(obj->sha1)); printf(" to %7s %s\n", typename(ref->type), sha1_to_hex(ref->sha1)); + errors_found |= ERROR_REACHABLE; } } } @@ -346,8 +352,11 @@ static int fsck_tag(struct tag *tag) static int fsck_sha1(unsigned char *sha1) { struct object *obj = parse_object(sha1); - if (!obj) - return error("%s: object corrupt or missing", sha1_to_hex(sha1)); + if (!obj) { + errors_found |= ERROR_OBJECT; + return error("%s: object corrupt or missing", + sha1_to_hex(sha1)); + } if (obj->flags & SEEN) return 0; obj->flags |= SEEN; @@ -359,8 +368,10 @@ static int fsck_sha1(unsigned char *sha1) return fsck_commit((struct commit *) obj); if (obj->type == OBJ_TAG) return fsck_tag((struct tag *) obj); + /* By now, parse_object() would've returned NULL instead. */ - return objerror(obj, "unknown type '%d' (internal fsck error)", obj->type); + return objerror(obj, "unknown type '%d' (internal fsck error)", + obj->type); } /* @@ -576,11 +587,16 @@ static int fsck_cache_tree(struct cache_tree *it) return err; } +static const char fsck_usage[] = +"git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] " +"[--strict] <head-sha1>*]"; + int cmd_fsck(int argc, char **argv, const char *prefix) { int i, heads; track_object_refs = 1; + errors_found = 0; for (i = 1; i < argc; i++) { const char *arg = argv[i]; @@ -610,7 +626,7 @@ int cmd_fsck(int argc, char **argv, const char *prefix) continue; } if (*arg == '-') - usage("git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] [--strict] <head-sha1>*]"); + usage(fsck_usage); } fsck_head_link(); @@ -632,7 +648,7 @@ int cmd_fsck(int argc, char **argv, const char *prefix) verify_pack(p, 0); for (p = packed_git; p; p = p->next) { - int num = num_packed_objects(p); + uint32_t i, num = num_packed_objects(p); for (i = 0; i < num; i++) { unsigned char sha1[20]; nth_packed_object_sha1(p, i, sha1); @@ -690,5 +706,5 @@ int cmd_fsck(int argc, char **argv, const char *prefix) } check_connectivity(); - return 0; + return errors_found; } diff --git a/builtin-grep.c b/builtin-grep.c index 96b70227cf..4510d35324 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -122,6 +122,8 @@ static int grep_file(struct grep_opt *opt, const char *filename) struct stat st; int i; char *data; + size_t sz; + if (lstat(filename, &st) < 0) { err_ret: if (errno != ENOENT) @@ -132,11 +134,12 @@ static int grep_file(struct grep_opt *opt, const char *filename) return 0; /* empty file -- no grep hit */ if (!S_ISREG(st.st_mode)) return 0; + sz = xsize_t(st.st_size); i = open(filename, O_RDONLY); if (i < 0) goto err_ret; - data = xmalloc(st.st_size + 1); - if (st.st_size != read_in_full(i, data, st.st_size)) { + data = xmalloc(sz + 1); + if (st.st_size != read_in_full(i, data, sz)) { error("'%s': short read %s", filename, strerror(errno)); close(i); free(data); @@ -145,11 +148,12 @@ static int grep_file(struct grep_opt *opt, const char *filename) close(i); if (opt->relative && opt->prefix_length) filename += opt->prefix_length; - i = grep_buffer(opt, filename, data, st.st_size); + i = grep_buffer(opt, filename, data, sz); free(data); return i; } +#ifdef __unix__ static int exec_grep(int argc, const char **argv) { pid_t pid; @@ -298,6 +302,7 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) } return hit; } +#endif static int grep_cache(struct grep_opt *opt, const char **paths, int cached) { @@ -426,6 +431,19 @@ static const char emsg_missing_context_len[] = static const char emsg_missing_argument[] = "option requires an argument -%s"; +static int strtoul_ui(char const *s, unsigned int *result) +{ + unsigned long ul; + char *p; + + errno = 0; + ul = strtoul(s, &p, 10); + if (errno || *p || p == s || (unsigned int) ul != ul) + return -1; + *result = ul; + return 0; +} + int cmd_grep(int argc, const char **argv, const char *prefix) { int hit = 0; @@ -548,7 +566,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) scan = arg + 1; break; } - if (sscanf(scan, "%u", &num) != 1) + if (strtoul_ui(scan, &num)) die(emsg_invalid_context_len, scan); switch (arg[1]) { case 'A': diff --git a/builtin-log.c b/builtin-log.c index 1c9f7d02a8..865832c85e 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -482,10 +482,22 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) memcpy(add_signoff, committer, endpos - committer + 1); add_signoff[endpos - committer + 1] = 0; } - else if (!strcmp(argv[i], "--attach")) + else if (!strcmp(argv[i], "--attach")) { rev.mime_boundary = git_version_string; - else if (!prefixcmp(argv[i], "--attach=")) + rev.no_inline = 1; + } + else if (!prefixcmp(argv[i], "--attach=")) { + rev.mime_boundary = argv[i] + 9; + rev.no_inline = 1; + } + else if (!strcmp(argv[i], "--inline")) { + rev.mime_boundary = git_version_string; + rev.no_inline = 0; + } + else if (!prefixcmp(argv[i], "--inline=")) { rev.mime_boundary = argv[i] + 9; + rev.no_inline = 0; + } else if (!strcmp(argv[i], "--ignore-if-in-upstream")) ignore_if_in_upstream = 1; else if (!strcmp(argv[i], "--thread")) diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 766a37ebe2..d94578cb4a 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -11,19 +11,22 @@ static FILE *cmitmsg, *patchfile, *fin, *fout; static int keep_subject; static const char *metainfo_charset; static char line[1000]; -static char date[1000]; static char name[1000]; static char email[1000]; -static char subject[1000]; static enum { TE_DONTCARE, TE_QP, TE_BASE64, } transfer_encoding; -static char charset[256]; +static enum { + TYPE_TEXT, TYPE_OTHER, +} message_type; -static char multipart_boundary[1000]; -static int multipart_boundary_len; +static char charset[256]; static int patch_lines; +static char **p_hdr_data, **s_hdr_data; + +#define MAX_HDR_PARSED 10 +#define MAX_BOUNDARIES 5 static char *sanity_check(char *name, char *email) { @@ -137,15 +140,13 @@ static int handle_from(char *in_line) return 1; } -static int handle_date(char *line) +static int handle_header(char *line, char *data, int ofs) { - strcpy(date, line); - return 0; -} + if (!line || !data) + return 1; + + strcpy(data, line+ofs); -static int handle_subject(char *line) -{ - strcpy(subject, line); return 0; } @@ -177,17 +178,32 @@ static int slurp_attr(const char *line, const char *name, char *attr) return 1; } -static int handle_subcontent_type(char *line) +struct content_type { + char *boundary; + int boundary_len; +}; + +static struct content_type content[MAX_BOUNDARIES]; + +static struct content_type *content_top = content; + +static int handle_content_type(char *line) { - /* We do not want to mess with boundary. Note that we do not - * handle nested multipart. - */ - if (strcasestr(line, "boundary=")) { - fprintf(stderr, "Not handling nested multipart message.\n"); - exit(1); + char boundary[256]; + + if (strcasestr(line, "text/") == NULL) + message_type = TYPE_OTHER; + if (slurp_attr(line, "boundary=", boundary + 2)) { + memcpy(boundary, "--", 2); + if (content_top++ >= &content[MAX_BOUNDARIES]) { + fprintf(stderr, "Too many boundaries to handle\n"); + exit(1); + } + content_top->boundary_len = strlen(boundary); + content_top->boundary = xmalloc(content_top->boundary_len+1); + strcpy(content_top->boundary, boundary); } - slurp_attr(line, "charset=", charset); - if (*charset) { + if (slurp_attr(line, "charset=", charset)) { int i, c; for (i = 0; (c = charset[i]) != 0; i++) charset[i] = tolower(c); @@ -195,17 +211,6 @@ static int handle_subcontent_type(char *line) return 0; } -static int handle_content_type(char *line) -{ - *multipart_boundary = 0; - if (slurp_attr(line, "boundary=", multipart_boundary + 2)) { - memcpy(multipart_boundary, "--", 2); - multipart_boundary_len = strlen(multipart_boundary); - } - slurp_attr(line, "charset=", charset); - return 0; -} - static int handle_content_transfer_encoding(char *line) { if (strcasestr(line, "base64")) @@ -219,7 +224,7 @@ static int handle_content_transfer_encoding(char *line) static int is_multipart_boundary(const char *line) { - return (!memcmp(line, multipart_boundary, multipart_boundary_len)); + return (!memcmp(line, content_top->boundary, content_top->boundary_len)); } static int eatspace(char *line) @@ -230,62 +235,6 @@ static int eatspace(char *line) return len; } -#define SEEN_FROM 01 -#define SEEN_DATE 02 -#define SEEN_SUBJECT 04 -#define SEEN_BOGUS_UNIX_FROM 010 -#define SEEN_PREFIX 020 - -/* First lines of body can have From:, Date:, and Subject: or empty */ -static void handle_inbody_header(int *seen, char *line) -{ - if (*seen & SEEN_PREFIX) - return; - if (isspace(*line)) { - char *cp; - for (cp = line + 1; *cp; cp++) { - if (!isspace(*cp)) - break; - } - if (!*cp) - return; - } - if (!memcmp(">From", line, 5) && isspace(line[5])) { - if (!(*seen & SEEN_BOGUS_UNIX_FROM)) { - *seen |= SEEN_BOGUS_UNIX_FROM; - return; - } - } - if (!memcmp("From:", line, 5) && isspace(line[5])) { - if (!(*seen & SEEN_FROM) && handle_from(line+6)) { - *seen |= SEEN_FROM; - return; - } - } - if (!memcmp("Date:", line, 5) && isspace(line[5])) { - if (!(*seen & SEEN_DATE)) { - handle_date(line+6); - *seen |= SEEN_DATE; - return; - } - } - if (!memcmp("Subject:", line, 8) && isspace(line[8])) { - if (!(*seen & SEEN_SUBJECT)) { - handle_subject(line+9); - *seen |= SEEN_SUBJECT; - return; - } - } - if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) { - if (!(*seen & SEEN_SUBJECT)) { - handle_subject(line); - *seen |= SEEN_SUBJECT; - return; - } - } - *seen |= SEEN_PREFIX; -} - static char *cleanup_subject(char *subject) { if (keep_subject) @@ -296,7 +245,7 @@ static char *cleanup_subject(char *subject) switch (*subject) { case 'r': case 'R': if (!memcmp("e:", subject+1, 2)) { - subject +=3; + subject += 3; continue; } break; @@ -341,57 +290,62 @@ static void cleanup_space(char *buf) } static void decode_header(char *it); -typedef int (*header_fn_t)(char *); -struct header_def { - const char *name; - header_fn_t func; - int namelen; +static char *header[MAX_HDR_PARSED] = { + "From","Subject","Date", }; -static void check_header(char *line, struct header_def *header) +static int check_header(char *line, char **hdr_data) { int i; - if (header[0].namelen <= 0) { - for (i = 0; header[i].name; i++) - header[i].namelen = strlen(header[i].name); - } - for (i = 0; header[i].name; i++) { - int len = header[i].namelen; - if (!strncasecmp(line, header[i].name, len) && + /* search for the interesting parts */ + for (i = 0; header[i]; i++) { + int len = strlen(header[i]); + if (!hdr_data[i] && + !strncasecmp(line, header[i], len) && line[len] == ':' && isspace(line[len + 1])) { /* Unwrap inline B and Q encoding, and optionally * normalize the meta information to utf8. */ decode_header(line + len + 2); - header[i].func(line + len + 2); - break; + hdr_data[i] = xmalloc(1000 * sizeof(char)); + if (! handle_header(line, hdr_data[i], len + 2)) { + return 1; + } } } -} -static void check_subheader_line(char *line) -{ - static struct header_def header[] = { - { "Content-Type", handle_subcontent_type }, - { "Content-Transfer-Encoding", - handle_content_transfer_encoding }, - { NULL }, - }; - check_header(line, header); -} -static void check_header_line(char *line) -{ - static struct header_def header[] = { - { "From", handle_from }, - { "Date", handle_date }, - { "Subject", handle_subject }, - { "Content-Type", handle_content_type }, - { "Content-Transfer-Encoding", - handle_content_transfer_encoding }, - { NULL }, - }; - check_header(line, header); + /* Content stuff */ + if (!strncasecmp(line, "Content-Type", 12) && + line[12] == ':' && isspace(line[12 + 1])) { + decode_header(line + 12 + 2); + if (! handle_content_type(line)) { + return 1; + } + } + if (!strncasecmp(line, "Content-Transfer-Encoding", 25) && + line[25] == ':' && isspace(line[25 + 1])) { + decode_header(line + 25 + 2); + if (! handle_content_transfer_encoding(line)) { + return 1; + } + } + + /* for inbody stuff */ + if (!memcmp(">From", line, 5) && isspace(line[5])) + return 1; + if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) { + for (i = 0; header[i]; i++) { + if (!memcmp("Subject: ", header[i], 9)) { + if (! handle_header(line, hdr_data[i], 0)) { + return 1; + } + } + } + } + + /* no match */ + return 0; } static int is_rfc2822_header(char *line) @@ -545,10 +499,10 @@ static int decode_b_segment(char *in, char *ot, char *ep) return 0; } -static void convert_to_utf8(char *line, char *charset) +static void convert_to_utf8(char *line, const char *charset) { - static char latin_one[] = "latin1"; - char *input_charset = *charset ? charset : latin_one; + static const char latin_one[] = "latin1"; + const char *input_charset = *charset ? charset : latin_one; char *out = reencode_string(line, metainfo_charset, input_charset); if (!out) @@ -647,147 +601,253 @@ static void decode_transfer_encoding(char *line) } } -static void handle_info(void) +static int handle_filter(char *line); + +static int find_boundary(void) { - char *sub; + while(fgets(line, sizeof(line), fin) != NULL) { + if (is_multipart_boundary(line)) + return 1; + } + return 0; +} + +static int handle_boundary(void) +{ +again: + if (!memcmp(line+content_top->boundary_len, "--", 2)) { + /* we hit an end boundary */ + /* pop the current boundary off the stack */ + free(content_top->boundary); + + /* technically won't happen as is_multipart_boundary() + will fail first. But just in case.. + */ + if (content_top-- < content) { + fprintf(stderr, "Detected mismatched boundaries, " + "can't recover\n"); + exit(1); + } + handle_filter("\n"); + + /* skip to the next boundary */ + if (!find_boundary()) + return 0; + goto again; + } + + /* set some defaults */ + transfer_encoding = TE_DONTCARE; + charset[0] = 0; + message_type = TYPE_TEXT; - sub = cleanup_subject(subject); - cleanup_space(name); - cleanup_space(date); - cleanup_space(email); - cleanup_space(sub); + /* slurp in this section's info */ + while (read_one_header_line(line, sizeof(line), fin)) + check_header(line, p_hdr_data); - fprintf(fout, "Author: %s\nEmail: %s\nSubject: %s\nDate: %s\n\n", - name, email, sub, date); + /* eat the blank line after section info */ + return (fgets(line, sizeof(line), fin) != NULL); } -/* We are inside message body and have read line[] already. - * Spit out the commit log. - */ -static int handle_commit_msg(int *seen) +static inline int patchbreak(const char *line) { - if (!cmitmsg) - return 0; - do { - if (!memcmp("diff -", line, 6) || - !memcmp("---", line, 3) || - !memcmp("Index: ", line, 7)) - break; - if ((multipart_boundary[0] && is_multipart_boundary(line))) { - /* We come here when the first part had only - * the commit message without any patch. We - * pretend we have not seen this line yet, and - * go back to the loop. - */ + /* Beginning of a "diff -" header? */ + if (!memcmp("diff -", line, 6)) + return 1; + + /* CVS "Index: " line? */ + if (!memcmp("Index: ", line, 7)) + return 1; + + /* + * "--- <filename>" starts patches without headers + * "---<sp>*" is a manual separator + */ + if (!memcmp("---", line, 3)) { + line += 3; + /* space followed by a filename? */ + if (line[0] == ' ' && !isspace(line[1])) return 1; + /* Just whitespace? */ + for (;;) { + unsigned char c = *line++; + if (c == '\n') + return 1; + if (!isspace(c)) + break; } + return 0; + } + return 0; +} - /* Unwrap transfer encoding and optionally - * normalize the log message to UTF-8. - */ - decode_transfer_encoding(line); - if (metainfo_charset) - convert_to_utf8(line, charset); - handle_inbody_header(seen, line); - if (!(*seen & SEEN_PREFIX)) - continue; +static int handle_commit_msg(char *line) +{ + static int still_looking = 1; - fputs(line, cmitmsg); - } while (fgets(line, sizeof(line), fin) != NULL); - fclose(cmitmsg); - cmitmsg = NULL; + if (!cmitmsg) + return 0; + + if (still_looking) { + char *cp = line; + if (isspace(*line)) { + for (cp = line + 1; *cp; cp++) { + if (!isspace(*cp)) + break; + } + if (!*cp) + return 0; + } + if ((still_looking = check_header(cp, s_hdr_data)) != 0) + return 0; + } + + if (patchbreak(line)) { + fclose(cmitmsg); + cmitmsg = NULL; + return 1; + } + + fputs(line, cmitmsg); return 0; } -/* We have done the commit message and have the first - * line of the patch in line[]. - */ -static void handle_patch(void) +static int handle_patch(char *line) { - do { - if (multipart_boundary[0] && is_multipart_boundary(line)) - break; - /* Only unwrap transfer encoding but otherwise do not - * do anything. We do *NOT* want UTF-8 conversion - * here; we are dealing with the user payload. - */ - decode_transfer_encoding(line); - fputs(line, patchfile); - patch_lines++; - } while (fgets(line, sizeof(line), fin) != NULL); + fputs(line, patchfile); + patch_lines++; + return 0; } -/* multipart boundary and transfer encoding are set up for us, and we - * are at the end of the sub header. do equivalent of handle_body up - * to the next boundary without closing patchfile --- we will expect - * that the first part to contain commit message and a patch, and - * handle other parts as pure patches. - */ -static int handle_multipart_one_part(int *seen) +static int handle_filter(char *line) { - int n = 0; + static int filter = 0; - while (fgets(line, sizeof(line), fin) != NULL) { - again: - n++; - if (is_multipart_boundary(line)) + /* filter tells us which part we left off on + * a non-zero return indicates we hit a filter point + */ + switch (filter) { + case 0: + if (!handle_commit_msg(line)) break; - if (handle_commit_msg(seen)) - goto again; - handle_patch(); - break; + filter++; + case 1: + if (!handle_patch(line)) + break; + filter++; + default: + return 1; } - if (n == 0) - return -1; + return 0; } -static void handle_multipart_body(void) +static void handle_body(void) { - int seen = 0; - int part_num = 0; + int rc = 0; + static char newline[2000]; + static char *np = newline; /* Skip up to the first boundary */ - while (fgets(line, sizeof(line), fin) != NULL) - if (is_multipart_boundary(line)) { - part_num = 1; + if (content_top->boundary) { + if (!find_boundary()) + return; + } + + do { + /* process any boundary lines */ + if (content_top->boundary && is_multipart_boundary(line)) { + /* flush any leftover */ + if ((transfer_encoding == TE_BASE64) && + (np != newline)) { + handle_filter(newline); + } + if (!handle_boundary()) + return; + } + + /* Unwrap transfer encoding and optionally + * normalize the log message to UTF-8. + */ + decode_transfer_encoding(line); + if (metainfo_charset) + convert_to_utf8(line, charset); + + switch (transfer_encoding) { + case TE_BASE64: + { + char *op = line; + + /* binary data most likely doesn't have newlines */ + if (message_type != TYPE_TEXT) { + rc = handle_filter(line); + break; + } + + /* this is a decoded line that may contain + * multiple new lines. Pass only one chunk + * at a time to handle_filter() + */ + + do { + while (*op != '\n' && *op != 0) + *np++ = *op++; + *np = *op; + if (*np != 0) { + /* should be sitting on a new line */ + *(++np) = 0; + op++; + rc = handle_filter(newline); + np = newline; + } + } while (*op != 0); + /* the partial chunk is saved in newline and + * will be appended by the next iteration of fgets + */ break; } - if (!part_num) - return; - /* We are on boundary line. Start slurping the subhead. */ - while (1) { - int hdr = read_one_header_line(line, sizeof(line), fin); - if (!hdr) { - if (handle_multipart_one_part(&seen) < 0) - return; - /* Reset per part headers */ - transfer_encoding = TE_DONTCARE; - charset[0] = 0; + default: + rc = handle_filter(line); } - else - check_subheader_line(line); - } - fclose(patchfile); - if (!patch_lines) { - fprintf(stderr, "No patch found\n"); - exit(1); - } + if (rc) + /* nothing left to filter */ + break; + } while (fgets(line, sizeof(line), fin)); + + return; } -/* Non multipart message */ -static void handle_body(void) +static void handle_info(void) { - int seen = 0; + char *sub; + char *hdr; + int i; - handle_commit_msg(&seen); - handle_patch(); - fclose(patchfile); - if (!patch_lines) { - fprintf(stderr, "No patch found\n"); - exit(1); + for (i = 0; header[i]; i++) { + + /* only print inbody headers if we output a patch file */ + if (patch_lines && s_hdr_data[i]) + hdr = s_hdr_data[i]; + else if (p_hdr_data[i]) + hdr = p_hdr_data[i]; + else + continue; + + if (!memcmp(header[i], "Subject", 7)) { + sub = cleanup_subject(hdr); + cleanup_space(sub); + fprintf(fout, "Subject: %s\n", sub); + } else if (!memcmp(header[i], "From", 4)) { + handle_from(hdr); + fprintf(fout, "Author: %s\n", name); + fprintf(fout, "Email: %s\n", email); + } else { + cleanup_space(hdr); + fprintf(fout, "%s: %s\n", header[i], hdr); + } } + fprintf(fout, "\n"); } int mailinfo(FILE *in, FILE *out, int ks, const char *encoding, @@ -809,18 +869,16 @@ int mailinfo(FILE *in, FILE *out, int ks, const char *encoding, fclose(cmitmsg); return -1; } - while (1) { - int hdr = read_one_header_line(line, sizeof(line), fin); - if (!hdr) { - if (multipart_boundary[0]) - handle_multipart_body(); - else - handle_body(); - handle_info(); - break; - } - check_header_line(line); - } + + p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *)); + s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *)); + + /* process the email header */ + while (read_one_header_line(line, sizeof(line), fin)) + check_header(line, p_hdr_data); + + handle_body(); + handle_info(); return 0; } diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 8cf24f4079..f8ebad0b2f 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -23,7 +23,7 @@ git-pack-objects [{ -q | --progress | --all-progress }] \n\ struct object_entry { unsigned char sha1[20]; unsigned long size; /* uncompressed size */ - unsigned long offset; /* offset into the final pack file; + off_t offset; /* offset into the final pack file; * nonzero if already written. */ unsigned int depth; /* delta depth */ @@ -35,7 +35,7 @@ struct object_entry { #define in_pack_header_size delta_size /* only when reusing pack data */ struct object_entry *delta; /* delta base object */ struct packed_git *in_pack; /* already in pack */ - unsigned int in_pack_offset; + off_t in_pack_offset; struct object_entry *delta_child; /* deltified objects who bases me */ struct object_entry *delta_sibling; /* other deltified objects who * uses the same base as me @@ -68,7 +68,7 @@ static int allow_ofs_delta; static struct object_entry **sorted_by_sha, **sorted_by_type; static struct object_entry *objects; -static int nr_objects, nr_alloc, nr_result; +static uint32_t nr_objects, nr_alloc, nr_result; static const char *base_name; static unsigned char pack_file_sha1[20]; static int progress = 1; @@ -101,7 +101,7 @@ static int object_ix_hashsz; * get the object sha1 from the main index. */ struct revindex_entry { - unsigned int offset; + off_t offset; unsigned int nr; }; struct pack_revindex { @@ -114,10 +114,8 @@ static int pack_revindex_hashsz; /* * stats */ -static int written; -static int written_delta; -static int reused; -static int reused_delta; +static uint32_t written, written_delta; +static uint32_t reused, reused_delta; static int pack_revindex_ix(struct packed_git *p) { @@ -185,7 +183,7 @@ static void prepare_pack_revindex(struct pack_revindex *rix) } static struct revindex_entry * find_packed_object(struct packed_git *p, - unsigned int ofs) + off_t ofs) { int num; int lo, hi; @@ -213,15 +211,14 @@ static struct revindex_entry * find_packed_object(struct packed_git *p, die("internal error: pack revindex corrupt"); } -static unsigned long find_packed_object_size(struct packed_git *p, - unsigned long ofs) +static off_t find_packed_object_size(struct packed_git *p, off_t ofs) { struct revindex_entry *entry = find_packed_object(p, ofs); return entry[1].offset - ofs; } static unsigned char *find_packed_object_name(struct packed_git *p, - unsigned long ofs) + off_t ofs) { struct revindex_entry *entry = find_packed_object(p, ofs); return (unsigned char *)(p->index_base + 256) + 24 * entry->nr + 4; @@ -278,8 +275,8 @@ static int encode_header(enum object_type type, unsigned long size, unsigned cha */ static int check_pack_inflate(struct packed_git *p, struct pack_window **w_curs, - unsigned long offset, - unsigned long len, + off_t offset, + off_t len, unsigned long expect) { z_stream stream; @@ -305,8 +302,8 @@ static int check_pack_inflate(struct packed_git *p, static void copy_pack_data(struct sha1file *f, struct packed_git *p, struct pack_window **w_curs, - unsigned long offset, - unsigned long len) + off_t offset, + off_t len) { unsigned char *in; unsigned int avail; @@ -314,7 +311,7 @@ static void copy_pack_data(struct sha1file *f, while (len) { in = use_pack(p, w_curs, offset, &avail); if (avail > len) - avail = len; + avail = (unsigned int)len; sha1write(f, in, avail); offset += avail; len -= avail; @@ -371,14 +368,15 @@ static int revalidate_loose_object(struct object_entry *entry, return check_loose_inflate(map, mapsize, size); } -static unsigned long write_object(struct sha1file *f, +static off_t write_object(struct sha1file *f, struct object_entry *entry) { unsigned long size; enum object_type type; void *buf; unsigned char header[10]; - unsigned hdrlen, datalen; + unsigned hdrlen; + off_t datalen; enum object_type obj_type; int to_reuse = 0; @@ -441,7 +439,7 @@ static unsigned long write_object(struct sha1file *f, * encoding of the relative offset for the delta * base from this object's position in the pack. */ - unsigned long ofs = entry->offset - entry->delta->offset; + off_t ofs = entry->offset - entry->delta->offset; unsigned pos = sizeof(header) - 1; header[pos] = ofs & 127; while (ofs >>= 7) @@ -462,7 +460,7 @@ static unsigned long write_object(struct sha1file *f, else { struct packed_git *p = entry->in_pack; struct pack_window *w_curs = NULL; - unsigned long offset; + off_t offset; if (entry->delta) { obj_type = (allow_ofs_delta && entry->delta->offset) ? @@ -472,7 +470,7 @@ static unsigned long write_object(struct sha1file *f, hdrlen = encode_header(obj_type, entry->size, header); sha1write(f, header, hdrlen); if (obj_type == OBJ_OFS_DELTA) { - unsigned long ofs = entry->offset - entry->delta->offset; + off_t ofs = entry->offset - entry->delta->offset; unsigned pos = sizeof(header) - 1; header[pos] = ofs & 127; while (ofs >>= 7) @@ -500,9 +498,9 @@ static unsigned long write_object(struct sha1file *f, return hdrlen + datalen; } -static unsigned long write_one(struct sha1file *f, +static off_t write_one(struct sha1file *f, struct object_entry *e, - unsigned long offset) + off_t offset) { if (e->offset || e->preferred_base) /* offset starts from header size and cannot be zero @@ -518,9 +516,9 @@ static unsigned long write_one(struct sha1file *f, static void write_pack_file(void) { - int i; + uint32_t i; struct sha1file *f; - unsigned long offset; + off_t offset; struct pack_header hdr; unsigned last_percent = 999; int do_progress = progress; @@ -533,7 +531,7 @@ static void write_pack_file(void) f = sha1create("%s-%s.%s", base_name, sha1_to_hex(object_list_sha1), "pack"); if (do_progress) - fprintf(stderr, "Writing %d objects.\n", nr_result); + fprintf(stderr, "Writing %u objects.\n", nr_result); hdr.hdr_signature = htonl(PACK_SIGNATURE); hdr.hdr_version = htonl(PACK_VERSION); @@ -558,13 +556,13 @@ static void write_pack_file(void) fputc('\n', stderr); done: if (written != nr_result) - die("wrote %d objects while expecting %d", written, nr_result); + die("wrote %u objects while expecting %u", written, nr_result); sha1close(f, pack_file_sha1, 1); } static void write_index_file(void) { - int i; + uint32_t i; struct sha1file *f = sha1create("%s-%s.%s", base_name, sha1_to_hex(object_list_sha1), "idx"); struct object_entry **list = sorted_by_sha; @@ -633,7 +631,7 @@ static struct object_entry *locate_object_entry(const unsigned char *sha1) static void rehash_objects(void) { - int i; + uint32_t i; struct object_entry *oe; object_ix_hashsz = nr_objects * 3; @@ -670,16 +668,16 @@ static unsigned name_hash(const char *name) static int add_object_entry(const unsigned char *sha1, unsigned hash, int exclude) { - unsigned int idx = nr_objects; + uint32_t idx = nr_objects; struct object_entry *entry; struct packed_git *p; - unsigned int found_offset = 0; + off_t found_offset = 0; struct packed_git *found_pack = NULL; int ix, status = 0; if (!exclude) { for (p = packed_git; p; p = p->next) { - unsigned long offset = find_pack_entry_one(sha1, p); + off_t offset = find_pack_entry_one(sha1, p); if (offset) { if (incremental) return 0; @@ -696,9 +694,8 @@ static int add_object_entry(const unsigned char *sha1, unsigned hash, int exclud goto already_added; if (idx >= nr_alloc) { - unsigned int needed = (idx + 1024) * 3 / 2; - objects = xrealloc(objects, needed * sizeof(*entry)); - nr_alloc = needed; + nr_alloc = (idx + 1024) * 3 / 2; + objects = xrealloc(objects, nr_alloc * sizeof(*entry)); } entry = objects + idx; nr_objects = idx + 1; @@ -718,7 +715,7 @@ static int add_object_entry(const unsigned char *sha1, unsigned hash, int exclud already_added: if (progress_update) { - fprintf(stderr, "Counting objects...%d\r", nr_objects); + fprintf(stderr, "Counting objects...%u\r", nr_objects); progress_update = 0; } if (exclude) @@ -981,17 +978,17 @@ static void check_object(struct object_entry *entry) if (entry->in_pack && !entry->preferred_base) { struct packed_git *p = entry->in_pack; struct pack_window *w_curs = NULL; - unsigned long left = p->pack_size - entry->in_pack_offset; unsigned long size, used; + unsigned int avail; unsigned char *buf; struct object_entry *base_entry = NULL; - buf = use_pack(p, &w_curs, entry->in_pack_offset, NULL); + buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail); /* We want in_pack_type even if we do not reuse delta. * There is no point not reusing non-delta representations. */ - used = unpack_object_header_gently(buf, left, + used = unpack_object_header_gently(buf, avail, &entry->in_pack_type, &size); /* Check if it is delta, and the base is also an object @@ -1000,7 +997,7 @@ static void check_object(struct object_entry *entry) */ if (!no_reuse_delta) { unsigned char c, *base_name; - unsigned long ofs; + off_t ofs; unsigned long used_0; /* there is at least 20 bytes left in the pack */ switch (entry->in_pack_type) { @@ -1081,7 +1078,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n) static void get_object_details(void) { - int i; + uint32_t i; struct object_entry *entry; prepare_pack_ix(); @@ -1120,7 +1117,7 @@ static int sort_comparator(const void *_a, const void *_b) static struct object_entry **create_sorted_list(entry_sort_t sort) { struct object_entry **list = xmalloc(nr_objects * sizeof(struct object_entry *)); - int i; + uint32_t i; for (i = 0; i < nr_objects; i++) list[i] = objects + i; @@ -1137,7 +1134,7 @@ static int sha1_sort(const struct object_entry *a, const struct object_entry *b) static struct object_entry **create_final_object_list(void) { struct object_entry **list; - int i, j; + uint32_t i, j; for (i = nr_result = 0; i < nr_objects; i++) if (!objects[i].preferred_base) @@ -1279,20 +1276,20 @@ static void progress_interval(int signum) static void find_deltas(struct object_entry **list, int window, int depth) { - int i, idx; + uint32_t i = nr_objects, idx = 0, processed = 0; unsigned int array_size = window * sizeof(struct unpacked); - struct unpacked *array = xmalloc(array_size); - unsigned processed = 0; + struct unpacked *array; unsigned last_percent = 999; + if (!nr_objects) + return; + array = xmalloc(array_size); memset(array, 0, array_size); - i = nr_objects; - idx = 0; if (progress) - fprintf(stderr, "Deltifying %d objects.\n", nr_result); + fprintf(stderr, "Deltifying %u objects.\n", nr_result); - while (--i >= 0) { - struct object_entry *entry = list[i]; + do { + struct object_entry *entry = list[--i]; struct unpacked *n = array + idx; int j; @@ -1325,7 +1322,7 @@ static void find_deltas(struct object_entry **list, int window, int depth) j = window; while (--j > 0) { - unsigned int other_idx = idx + j; + uint32_t other_idx = idx + j; struct unpacked *m; if (other_idx >= window) other_idx -= window; @@ -1345,7 +1342,7 @@ static void find_deltas(struct object_entry **list, int window, int depth) idx++; if (idx >= window) idx = 0; - } + } while (i > 0); if (progress) fputc('\n', stderr); @@ -1386,7 +1383,7 @@ static int reuse_cached_pack(unsigned char *sha1) } if (progress) - fprintf(stderr, "Reusing %d objects pack %s\n", nr_objects, + fprintf(stderr, "Reusing %u objects pack %s\n", nr_objects, sha1_to_hex(sha1)); if (pack_to_stdout) { @@ -1537,7 +1534,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) struct object_entry **list; int use_internal_rev_list = 0; int thin = 0; - int i; + uint32_t i; const char **rp_av; int rp_ac_alloc = 64; int rp_ac; @@ -1670,7 +1667,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } if (progress) - fprintf(stderr, "Done counting %d objects.\n", nr_objects); + fprintf(stderr, "Done counting %u objects.\n", nr_objects); sorted_by_sha = create_final_object_list(); if (non_empty && !nr_result) return 0; @@ -1683,7 +1680,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } SHA1_Final(object_list_sha1, &ctx); if (progress && (nr_objects != nr_result)) - fprintf(stderr, "Result has %d objects.\n", nr_result); + fprintf(stderr, "Result has %u objects.\n", nr_result); if (reuse_cached_pack(object_list_sha1)) ; @@ -1704,7 +1701,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } } if (progress) - fprintf(stderr, "Total %d (delta %d), reused %d (delta %d)\n", + fprintf(stderr, "Total %u (delta %u), reused %u (delta %u)\n", written, written_delta, reused, reused_delta); return 0; } diff --git a/builtin-push.c b/builtin-push.c index 979efcc45f..6ab9a28e8c 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -336,7 +336,7 @@ static int do_push(const char *repo) argv[dest_argc] = NULL; if (verbose) fprintf(stderr, "Pushing to %s\n", dest); - err = run_command_v(argv); + err = run_command_v_opt(argv, 0); if (!err) continue; switch (err) { diff --git a/builtin-revert.c b/builtin-revert.c new file mode 100644 index 0000000000..652eece5ad --- /dev/null +++ b/builtin-revert.c @@ -0,0 +1,404 @@ +#include "cache.h" +#include "builtin.h" +#include "object.h" +#include "commit.h" +#include "tag.h" +#include "wt-status.h" +#include "run-command.h" +#include "exec_cmd.h" +#include "utf8.h" + +/* + * This implements the builtins revert and cherry-pick. + * + * Copyright (c) 2007 Johannes E. Schindelin + * + * Based on git-revert.sh, which is + * + * Copyright (c) 2005 Linus Torvalds + * Copyright (c) 2005 Junio C Hamano + */ + +static const char *revert_usage = "git-revert [--edit | --no-edit] [-n] <commit-ish>"; + +static const char *cherry_pick_usage = "git-cherry-pick [--edit] [-n] [-r] [-x] <commit-ish>"; + +static int edit; +static int replay; +enum { REVERT, CHERRY_PICK } action; +static int no_commit; +static struct commit *commit; +static int needed_deref; + +static const char *me; + +#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION" + +static void parse_options(int argc, const char **argv) +{ + const char *usage_str = action == REVERT ? + revert_usage : cherry_pick_usage; + unsigned char sha1[20]; + const char *arg; + int i; + + if (argc < 2) + usage(usage_str); + + for (i = 1; i < argc - 1; i++) { + arg = argv[i]; + if (!strcmp(arg, "-n") || !strcmp(arg, "--no-commit")) + no_commit = 1; + else if (!strcmp(arg, "-e") || !strcmp(arg, "--edit")) + edit = 1; + else if (!strcmp(arg, "--no-edit")) + edit = 0; + else if (!strcmp(arg, "-x") || !strcmp(arg, "--i-really-want-" + "to-expose-my-private-commit-object-name")) + replay = 0; + else if (strcmp(arg, "-r")) + usage(usage_str); + } + + arg = argv[argc - 1]; + if (get_sha1(arg, sha1)) + die ("Cannot find '%s'", arg); + commit = (struct commit *)parse_object(sha1); + if (!commit) + die ("Could not find %s", sha1_to_hex(sha1)); + if (commit->object.type == OBJ_TAG) { + commit = (struct commit *) + deref_tag((struct object *)commit, arg, strlen(arg)); + needed_deref = 1; + } + if (commit->object.type != OBJ_COMMIT) + die ("'%s' does not point to a commit", arg); +} + +static char *get_oneline(const char *message) +{ + char *result; + const char *p = message, *abbrev, *eol; + int abbrev_len, oneline_len; + + if (!p) + die ("Could not read commit message of %s", + sha1_to_hex(commit->object.sha1)); + while (*p && (*p != '\n' || p[1] != '\n')) + p++; + + if (*p) { + p += 2; + for (eol = p + 1; *eol && *eol != '\n'; eol++) + ; /* do nothing */ + } else + eol = p; + abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV); + abbrev_len = strlen(abbrev); + oneline_len = eol - p; + result = xmalloc(abbrev_len + 5 + oneline_len); + memcpy(result, abbrev, abbrev_len); + memcpy(result + abbrev_len, "... ", 4); + memcpy(result + abbrev_len + 4, p, oneline_len); + result[abbrev_len + 4 + oneline_len] = '\0'; + return result; +} + +char *get_encoding(const char *message) +{ + const char *p = message, *eol; + + if (!p) + die ("Could not read commit message of %s", + sha1_to_hex(commit->object.sha1)); + while (*p && *p != '\n') { + for (eol = p + 1; *eol && *eol != '\n'; eol++) + ; /* do nothing */ + if (!prefixcmp(p, "encoding ")) { + char *result = xmalloc(eol - 8 - p); + strlcpy(result, p + 9, eol - 8 - p); + return result; + } + p = eol; + if (*p == '\n') + p++; + } + return NULL; +} + +struct lock_file msg_file; +static int msg_fd; + +static void add_to_msg(const char *string) +{ + int len = strlen(string); + if (write_in_full(msg_fd, string, len) < 0) + die ("Could not write to .msg"); +} + +static void add_message_to_msg(const char *message) +{ + const char *p = message; + while (*p && (*p != '\n' || p[1] != '\n')) + p++; + + if (!*p) + add_to_msg(sha1_to_hex(commit->object.sha1)); + + p += 2; + add_to_msg(p); + return; +} + +static void set_author_ident_env(const char *message) +{ + const char *p = message; + if (!p) + die ("Could not read commit message of %s", + sha1_to_hex(commit->object.sha1)); + while (*p && *p != '\n') { + const char *eol; + + for (eol = p; *eol && *eol != '\n'; eol++) + ; /* do nothing */ + if (!prefixcmp(p, "author ")) { + char *line, *pend, *email, *timestamp; + + p += 7; + line = xmalloc(eol + 1 - p); + memcpy(line, p, eol - p); + line[eol - p] = '\0'; + email = strchr(line, '<'); + if (!email) + die ("Could not extract author email from %s", + sha1_to_hex(commit->object.sha1)); + if (email == line) + pend = line; + else + for (pend = email; pend != line + 1 && + isspace(pend[-1]); pend--); + ; /* do nothing */ + *pend = '\0'; + email++; + timestamp = strchr(email, '>'); + if (!timestamp) + die ("Could not extract author email from %s", + sha1_to_hex(commit->object.sha1)); + *timestamp = '\0'; + for (timestamp++; *timestamp && isspace(*timestamp); + timestamp++) + ; /* do nothing */ + setenv("GIT_AUTHOR_NAME", line, 1); + setenv("GIT_AUTHOR_EMAIL", email, 1); + setenv("GIT_AUTHOR_DATE", timestamp, 1); + free(line); + return; + } + p = eol; + if (*p == '\n') + p++; + } + die ("No author information found in %s", + sha1_to_hex(commit->object.sha1)); +} + +static int merge_recursive(const char *base_sha1, + const char *head_sha1, const char *head_name, + const char *next_sha1, const char *next_name) +{ + char buffer[256]; + const char *argv[6]; + + sprintf(buffer, "GITHEAD_%s", head_sha1); + setenv(buffer, head_name, 1); + sprintf(buffer, "GITHEAD_%s", next_sha1); + setenv(buffer, next_name, 1); + + /* + * 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). + */ + argv[0] = "merge-recursive"; + argv[1] = base_sha1; + argv[2] = "--"; + argv[3] = head_sha1; + argv[4] = next_sha1; + argv[5] = NULL; + + return run_command_v_opt(argv, RUN_COMMAND_NO_STDIN | RUN_GIT_CMD); +} + +static int revert_or_cherry_pick(int argc, const char **argv) +{ + unsigned char head[20]; + struct commit *base, *next; + int i; + char *oneline, *encoding, *reencoded_message = NULL; + const char *message; + + git_config(git_default_config); + me = action == REVERT ? "revert" : "cherry-pick"; + setenv(GIT_REFLOG_ACTION, me, 0); + parse_options(argc, argv); + + /* this is copied from the shell script, but it's never triggered... */ + if (action == REVERT && replay) + die("revert is incompatible with replay"); + + if (no_commit) { + /* + * We do not intend to commit immediately. We just want to + * merge the differences in. + */ + if (write_tree(head, 0, NULL)) + die ("Your index file is unmerged."); + } else { + struct wt_status s; + + if (get_sha1("HEAD", head)) + die ("You do not have a valid HEAD"); + wt_status_prepare(&s); + if (s.commitable || s.workdir_dirty) + die ("Dirty index: cannot %s", me); + discard_cache(); + } + + if (!commit->parents) + die ("Cannot %s a root commit", me); + if (commit->parents->next) + die ("Cannot %s a multi-parent commit.", me); + if (!(message = commit->buffer)) + die ("Cannot get commit message for %s", + sha1_to_hex(commit->object.sha1)); + + /* + * "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 + * reverse of it if we are revert. + */ + + msg_fd = hold_lock_file_for_update(&msg_file, ".msg", 1); + + encoding = get_encoding(message); + if (!encoding) + encoding = "utf-8"; + if (!git_commit_encoding) + git_commit_encoding = "utf-8"; + if ((reencoded_message = reencode_string(message, + git_commit_encoding, encoding))) + message = reencoded_message; + + oneline = get_oneline(message); + + if (action == REVERT) { + base = commit; + next = commit->parents->item; + add_to_msg("Revert "); + add_to_msg(find_unique_abbrev(commit->object.sha1, + DEFAULT_ABBREV)); + add_to_msg(oneline); + add_to_msg("\nThis reverts commit "); + add_to_msg(sha1_to_hex(commit->object.sha1)); + add_to_msg(".\n"); + } else { + base = commit->parents->item; + next = commit; + set_author_ident_env(message); + add_message_to_msg(message); + if (!replay) { + add_to_msg("(cherry picked from commit "); + add_to_msg(sha1_to_hex(commit->object.sha1)); + add_to_msg(")\n"); + } + } + if (needed_deref) { + add_to_msg("(original 'git "); + add_to_msg(me); + add_to_msg("' arguments: "); + for (i = 0; i < argc; i++) { + if (i) + add_to_msg(" "); + add_to_msg(argv[i]); + } + add_to_msg(")\n"); + } + + if (merge_recursive(sha1_to_hex(base->object.sha1), + sha1_to_hex(head), "HEAD", + sha1_to_hex(next->object.sha1), oneline) || + write_tree(head, 0, NULL)) { + const char *target = git_path("MERGE_MSG"); + add_to_msg("\nConflicts:\n\n"); + read_cache(); + for (i = 0; i < active_nr;) { + struct cache_entry *ce = active_cache[i++]; + if (ce_stage(ce)) { + add_to_msg("\t"); + add_to_msg(ce->name); + add_to_msg("\n"); + while (i < active_nr && !strcmp(ce->name, + active_cache[i]->name)) + i++; + } + } + if (close(msg_fd) || commit_lock_file(&msg_file) < 0) + die ("Error wrapping up .msg"); + unlink(target); + if (rename(".msg", target)) + die ("Could not move .msg to %s", target); + fprintf(stderr, "Automatic %s failed. " + "After resolving the conflicts,\n" + "mark the corrected paths with 'git-add <paths>'\n" + "and commit the result.\n", me); + if (action == CHERRY_PICK) { + fprintf(stderr, "When commiting, use the option " + "'-c %s' to retain authorship and message.\n", + find_unique_abbrev(commit->object.sha1, + DEFAULT_ABBREV)); + } + exit(1); + } + if (close(msg_fd) || commit_lock_file(&msg_file) < 0) + die ("Error wrapping up .msg"); + fprintf(stderr, "Finished one %s.\n", me); + + /* + * + * If we are cherry-pick, and if the merge did not result in + * hand-editing, we will hit this commit and inherit the original + * author date and name. + * If we are revert, or if our cherry-pick results in a hand merge, + * we had better say that the current user is responsible for that. + */ + + if (!no_commit) { + if (edit) + return execl_git_cmd("commit", "-n", "-F", ".msg", + "-e", NULL); + else + return execl_git_cmd("commit", "-n", "-F", ".msg", + NULL); + } + if (reencoded_message) + free(reencoded_message); + + return 0; +} + +int cmd_revert(int argc, const char **argv, const char *prefix) +{ + if (isatty(0)) + edit = 1; + action = REVERT; + return revert_or_cherry_pick(argc, argv); +} + +int cmd_cherry_pick(int argc, const char **argv, const char *prefix) +{ + replay = 1; + action = CHERRY_PICK; + return revert_or_cherry_pick(argc, argv); +} diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 2f71a2a6e2..29343aefc8 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -217,13 +217,13 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list) prepare_revision_walk(rev); while ((commit = get_revision(rev)) != NULL) { - char *author = NULL, *oneline, *buffer; + const char *author = NULL, *oneline, *buffer; int authorlen = authorlen, onelinelen; /* get author and oneline */ for (buffer = commit->buffer; buffer && *buffer != '\0' && *buffer != '\n'; ) { - char *eol = strchr(buffer, '\n'); + const char *eol = strchr(buffer, '\n'); if (eol == NULL) eol = buffer + strlen(buffer); @@ -304,8 +304,11 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) if (!access(".mailmap", R_OK)) read_mailmap(".mailmap"); - if (rev.pending.nr == 0) + if (rev.pending.nr == 0) { + if (isatty(0)) + fprintf(stderr, "(reading log to summarize from standard input)\n"); read_from_stdin(&list); + } else get_from_rev(&rev, &list); diff --git a/builtin-show-branch.c b/builtin-show-branch.c index 67ae6bacda..c892f1f7a6 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -721,7 +721,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) } for (i = 0; i < reflog; i++) { - char *logmsg, *msg, *m; + char *logmsg, *m; + const char *msg; unsigned long timestamp; int tz; diff --git a/builtin-update-index.c b/builtin-update-index.c index 772aaba7bb..71cef633c0 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -109,11 +109,11 @@ static int add_file_to_cache(const char *path) ce->ce_flags = htons(namelen); fill_stat_cache_info(ce, &st); - if (trust_executable_bit) + if (trust_executable_bit && has_symlinks) ce->ce_mode = create_ce_mode(st.st_mode); else { - /* If there is an existing entry, pick the mode bits - * from it, otherwise assume unexecutable. + /* If there is an existing entry, pick the mode bits and type + * from it, otherwise assume unexecutable regular file. */ struct cache_entry *ent; int pos = cache_name_pos(path, namelen); @@ -487,6 +487,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) int prefix_length = prefix ? strlen(prefix) : 0; char set_executable_bit = 0; unsigned int refresh_flags = 0; + int lock_error = 0; struct lock_file *lock_file; git_config(git_default_config); @@ -494,7 +495,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) /* We can't free this memory, it becomes part of a linked list parsed atexit() */ lock_file = xcalloc(1, sizeof(struct lock_file)); - newfd = hold_lock_file_for_update(lock_file, get_index_file(), 1); + newfd = hold_lock_file_for_update(lock_file, get_index_file(), 0); + if (newfd < 0) + lock_error = errno; entries = read_cache(); if (entries < 0) @@ -651,6 +654,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) finish: if (active_cache_changed) { + if (newfd < 0) { + if (refresh_flags & REFRESH_QUIET) + exit(128); + die("unable to create '%s.lock': %s", + get_index_file(), strerror(lock_error)); + } if (write_cache(newfd, active_cache, active_nr) || close(newfd) || commit_lock_file(lock_file)) die("Unable to write new index file"); @@ -19,10 +19,12 @@ extern int cmd_apply(int argc, const char **argv, const char *prefix); extern int cmd_archive(int argc, const char **argv, const char *prefix); extern int cmd_blame(int argc, const char **argv, const char *prefix); extern int cmd_branch(int argc, const char **argv, const char *prefix); +extern int cmd_bundle(int argc, const char **argv, const char *prefix); extern int cmd_cat_file(int argc, const char **argv, const char *prefix); extern int cmd_checkout_index(int argc, const char **argv, const char *prefix); extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix); extern int cmd_cherry(int argc, const char **argv, const char *prefix); +extern int cmd_cherry_pick(int argc, const char **argv, const char *prefix); extern int cmd_commit_tree(int argc, const char **argv, const char *prefix); extern int cmd_count_objects(int argc, const char **argv, const char *prefix); extern int cmd_describe(int argc, const char **argv, const char *prefix); @@ -60,6 +62,7 @@ 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); +extern int cmd_revert(int argc, const char **argv, const char *prefix); extern int cmd_rm(int argc, const char **argv, const char *prefix); extern int cmd_runstatus(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); @@ -108,7 +108,10 @@ static inline unsigned int create_ce_mode(unsigned int mode) } static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode) { - extern int trust_executable_bit; + extern int trust_executable_bit, has_symlinks; + if (!has_symlinks && S_ISREG(mode) && + ce && S_ISLNK(ntohl(ce->ce_mode))) + return ce->ce_mode; if (!trust_executable_bit && S_ISREG(mode)) { if (ce && S_ISREG(ntohl(ce->ce_mode))) return ce->ce_mode; @@ -127,6 +130,19 @@ extern unsigned int active_nr, active_alloc, active_cache_changed; extern struct cache_tree *active_cache_tree; extern int cache_errno; +enum object_type { + OBJ_BAD = -1, + OBJ_NONE = 0, + OBJ_COMMIT = 1, + OBJ_TREE = 2, + OBJ_BLOB = 3, + OBJ_TAG = 4, + /* 5 for future expansion */ + OBJ_OFS_DELTA = 6, + OBJ_REF_DELTA = 7, + OBJ_MAX, +}; + #define GIT_DIR_ENVIRONMENT "GIT_DIR" #define DEFAULT_GIT_DIR_ENVIRONMENT ".git" #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY" @@ -177,7 +193,7 @@ extern int ce_same_name(struct cache_entry *a, struct cache_entry *b); extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int); extern int ce_modified(struct cache_entry *ce, struct stat *st, int); extern int ce_path_match(const struct cache_entry *ce, const char **pathspec); -extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, const char *type); +extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path); extern int read_pipe(int fd, char** return_buf, unsigned long* return_size); extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object); extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object); @@ -202,6 +218,7 @@ extern int delete_ref(const char *, unsigned char *sha1); /* Environment bits from configuration mechanism */ extern int use_legacy_headers; extern int trust_executable_bit; +extern int has_symlinks; extern int assume_unchanged; extern int prefer_symlink_refs; extern int log_all_ref_updates; @@ -262,21 +279,8 @@ int adjust_shared_perm(const char *path); int safe_create_leading_directories(char *path); char *enter_repo(char *path, int strict); -enum object_type { - OBJ_NONE = 0, - OBJ_COMMIT = 1, - OBJ_TREE = 2, - OBJ_BLOB = 3, - OBJ_TAG = 4, - /* 5 for future expansion */ - OBJ_OFS_DELTA = 6, - OBJ_REF_DELTA = 7, - OBJ_BAD, -}; - /* Read and unpack a sha1 file into memory, write memory to a sha1 file */ extern int sha1_object_info(const unsigned char *, unsigned long *); -extern void * unpack_sha1_file(void *map, unsigned long mapsize, enum object_type *type, unsigned long *size); extern void * read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size); extern int hash_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *sha1); extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1); @@ -326,7 +330,8 @@ extern void *read_object_with_reference(const unsigned char *sha1, unsigned long *size, unsigned char *sha1_ret); -const char *show_date(unsigned long time, int timezone, int relative); +enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT }; +const char *show_date(unsigned long time, int timezone, enum date_mode mode); const char *show_rfc2822_date(unsigned long time, int timezone); int parse_date(const char *date, char *buf, int bufsize); void datestamp(char *buf, int bufsize); @@ -377,7 +382,7 @@ extern struct packed_git { } *packed_git; struct pack_entry { - unsigned int offset; + off_t offset; unsigned char sha1[20]; struct packed_git *p; }; @@ -416,15 +421,15 @@ extern struct packed_git *find_sha1_pack(const unsigned char *sha1, struct packed_git *packs); extern void pack_report(void); -extern unsigned char* use_pack(struct packed_git *, struct pack_window **, unsigned long, unsigned int *); +extern unsigned char* use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *); extern void unuse_pack(struct pack_window **); extern struct packed_git *add_packed_git(char *, int, int); -extern int num_packed_objects(const struct packed_git *p); -extern int nth_packed_object_sha1(const struct packed_git *, int, unsigned char*); -extern unsigned long find_pack_entry_one(const unsigned char *, struct packed_git *); -extern void *unpack_entry(struct packed_git *, unsigned long, enum object_type *, unsigned long *); +extern uint32_t num_packed_objects(const struct packed_git *p); +extern int nth_packed_object_sha1(const struct packed_git *, uint32_t, unsigned char*); +extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); +extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *); extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); -extern const char *packed_object_info_detail(struct packed_git *, unsigned long, unsigned long *, unsigned long *, unsigned int *, unsigned char *); +extern const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *); /* Dumb servers support */ extern int update_server_info(int); @@ -445,7 +450,7 @@ extern char git_default_email[MAX_GITNAME]; extern char git_default_name[MAX_GITNAME]; extern char *git_commit_encoding; -extern char *git_log_output_encoding; +extern const 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); @@ -475,6 +480,7 @@ extern struct tag *alloc_tag_node(void); extern void alloc_report(void); /* trace.c */ +extern int nfasprintf(char **str, const char *fmt, ...); extern int nfvasprintf(char **str, const char *fmt, va_list va); extern void trace_printf(const char *format, ...); extern void trace_argv_printf(const char **argv, int count, const char *format, ...); diff --git a/combine-diff.c b/combine-diff.c index 9daa0cb9a9..3a9b32f6b8 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -684,7 +684,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, goto deleted_file; if (S_ISLNK(st.st_mode)) { - size_t len = st.st_size; + size_t len = xsize_t(st.st_size); result_size = len; result = xmalloc(len + 1); if (result_size != readlink(elem->path, result, len)) { @@ -697,10 +697,20 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, } else if (0 <= (fd = open(elem->path, O_RDONLY)) && !fstat(fd, &st)) { - size_t len = st.st_size; + size_t len = xsize_t(st.st_size); size_t sz = 0; + int is_file, i; elem->mode = canon_mode(st.st_mode); + /* if symlinks don't work, assume symlink if all parents + * are symlinks + */ + is_file = has_symlinks; + for (i = 0; !is_file && i < num_parent; i++) + is_file = !S_ISLNK(elem->parent[i].mode); + if (!is_file) + elem->mode = canon_mode(S_IFLNK); + result_size = len; result = xmalloc(len + 1); while (sz < len) { @@ -3,6 +3,7 @@ #include "commit.h" #include "pkt-line.h" #include "utf8.h" +#include "interpolate.h" int save_commit_buffer = 1; @@ -36,8 +37,11 @@ struct cmt_fmt_map { { "full", 5, CMIT_FMT_FULL }, { "fuller", 5, CMIT_FMT_FULLER }, { "oneline", 1, CMIT_FMT_ONELINE }, + { "format:", 7, CMIT_FMT_USERFORMAT}, }; +static char *user_format; + enum cmit_fmt get_commit_format(const char *arg) { int i; @@ -46,6 +50,12 @@ enum cmit_fmt get_commit_format(const char *arg) return CMIT_FMT_DEFAULT; if (*arg == '=') arg++; + if (!prefixcmp(arg, "format:")) { + if (user_format) + free(user_format); + user_format = xstrdup(arg + 7); + return CMIT_FMT_USERFORMAT; + } for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) { if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) && !strncmp(arg, cmt_fmts[i].n, strlen(arg))) @@ -641,7 +651,7 @@ static char *get_header(const struct commit *commit, const char *key) } } -static char *replace_encoding_header(char *buf, char *encoding) +static char *replace_encoding_header(char *buf, const char *encoding) { char *encoding_header = strstr(buf, "\nencoding "); char *end_of_encoding_header; @@ -684,32 +694,211 @@ static char *replace_encoding_header(char *buf, char *encoding) } static char *logmsg_reencode(const struct commit *commit, - char *output_encoding) + const char *output_encoding) { + static const char *utf8 = "utf-8"; + const char *use_encoding; char *encoding; char *out; - char *utf8 = "utf-8"; if (!*output_encoding) return NULL; encoding = get_header(commit, "encoding"); - if (!encoding) - encoding = utf8; - if (!strcmp(encoding, output_encoding)) + use_encoding = encoding ? encoding : utf8; + if (!strcmp(use_encoding, output_encoding)) out = strdup(commit->buffer); else out = reencode_string(commit->buffer, - output_encoding, encoding); + output_encoding, use_encoding); if (out) out = replace_encoding_header(out, output_encoding); - if (encoding != utf8) - free(encoding); - if (!out) - return NULL; + free(encoding); return out; } +static char *xstrndup(const char *text, int len) +{ + char *result = xmalloc(len + 1); + memcpy(result, text, len); + result[len] = '\0'; + return result; +} + +static void fill_person(struct interp *table, const char *msg, int len) +{ + int start, end, tz = 0; + unsigned long date; + char *ep; + + /* parse name */ + for (end = 0; end < len && msg[end] != '<'; end++) + ; /* do nothing */ + start = end + 1; + while (end > 0 && isspace(msg[end - 1])) + end--; + table[0].value = xstrndup(msg, end); + + if (start >= len) + return; + + /* parse email */ + for (end = start + 1; end < len && msg[end] != '>'; end++) + ; /* do nothing */ + + if (end >= len) + return; + + table[1].value = xstrndup(msg + start, end - start); + + /* parse date */ + for (start = end + 1; start < len && isspace(msg[start]); start++) + ; /* do nothing */ + if (start >= len) + return; + date = strtoul(msg + start, &ep, 10); + if (msg + start == ep) + return; + + table[5].value = xstrndup(msg + start, ep - msg + start); + + /* parse tz */ + for (start = ep - msg + 1; start < len && isspace(msg[start]); start++) + ; /* do nothing */ + if (start + 1 < len) { + tz = strtoul(msg + start + 1, NULL, 10); + if (msg[start] == '-') + tz = -tz; + } + + interp_set_entry(table, 2, show_date(date, tz, 0)); + interp_set_entry(table, 3, show_rfc2822_date(date, tz)); + interp_set_entry(table, 4, show_date(date, tz, 1)); +} + +static long format_commit_message(const struct commit *commit, + const char *msg, char *buf, unsigned long space) +{ + struct interp table[] = { + { "%H" }, /* commit hash */ + { "%h" }, /* abbreviated commit hash */ + { "%T" }, /* tree hash */ + { "%t" }, /* abbreviated tree hash */ + { "%P" }, /* parent hashes */ + { "%p" }, /* abbreviated parent hashes */ + { "%an" }, /* author name */ + { "%ae" }, /* author email */ + { "%ad" }, /* author date */ + { "%aD" }, /* author date, RFC2822 style */ + { "%ar" }, /* author date, relative */ + { "%at" }, /* author date, UNIX timestamp */ + { "%cn" }, /* committer name */ + { "%ce" }, /* committer email */ + { "%cd" }, /* committer date */ + { "%cD" }, /* committer date, RFC2822 style */ + { "%cr" }, /* committer date, relative */ + { "%ct" }, /* committer date, UNIX timestamp */ + { "%e" }, /* encoding */ + { "%s" }, /* subject */ + { "%b" }, /* body */ + { "%Cred" }, /* red */ + { "%Cgreen" }, /* green */ + { "%Cblue" }, /* blue */ + { "%Creset" }, /* reset color */ + { "%n" } /* newline */ + }; + enum interp_index { + IHASH = 0, IHASH_ABBREV, + ITREE, ITREE_ABBREV, + IPARENTS, IPARENTS_ABBREV, + IAUTHOR_NAME, IAUTHOR_EMAIL, + IAUTHOR_DATE, IAUTHOR_DATE_RFC2822, IAUTHOR_DATE_RELATIVE, + IAUTHOR_TIMESTAMP, + ICOMMITTER_NAME, ICOMMITTER_EMAIL, + ICOMMITTER_DATE, ICOMMITTER_DATE_RFC2822, + ICOMMITTER_DATE_RELATIVE, ICOMMITTER_TIMESTAMP, + IENCODING, + ISUBJECT, + IBODY, + IRED, IGREEN, IBLUE, IRESET_COLOR, + INEWLINE + }; + struct commit_list *p; + char parents[1024]; + int i; + enum { HEADER, SUBJECT, BODY } state; + + if (INEWLINE + 1 != ARRAY_SIZE(table)) + die("invalid interp table!"); + + /* these are independent of the commit */ + interp_set_entry(table, IRED, "\033[31m"); + interp_set_entry(table, IGREEN, "\033[32m"); + interp_set_entry(table, IBLUE, "\033[34m"); + interp_set_entry(table, IRESET_COLOR, "\033[m"); + interp_set_entry(table, INEWLINE, "\n"); + + /* these depend on the commit */ + if (!commit->object.parsed) + parse_object(commit->object.sha1); + interp_set_entry(table, IHASH, sha1_to_hex(commit->object.sha1)); + interp_set_entry(table, IHASH_ABBREV, + find_unique_abbrev(commit->object.sha1, + DEFAULT_ABBREV)); + interp_set_entry(table, ITREE, sha1_to_hex(commit->tree->object.sha1)); + interp_set_entry(table, ITREE_ABBREV, + find_unique_abbrev(commit->tree->object.sha1, + DEFAULT_ABBREV)); + for (i = 0, p = commit->parents; + p && i < sizeof(parents) - 1; + p = p->next) + i += snprintf(parents + i, sizeof(parents) - i - 1, "%s ", + sha1_to_hex(p->item->object.sha1)); + interp_set_entry(table, IPARENTS, parents); + for (i = 0, p = commit->parents; + p && i < sizeof(parents) - 1; + p = p->next) + i += snprintf(parents + i, sizeof(parents) - i - 1, "%s ", + find_unique_abbrev(p->item->object.sha1, + DEFAULT_ABBREV)); + interp_set_entry(table, IPARENTS_ABBREV, parents); + + for (i = 0, state = HEADER; msg[i] && state < BODY; i++) { + int eol; + for (eol = i; msg[eol] && msg[eol] != '\n'; eol++) + ; /* do nothing */ + + if (state == SUBJECT) { + table[ISUBJECT].value = xstrndup(msg + i, eol - i); + i = eol; + } + if (i == eol) { + state++; + /* strip empty lines */ + while (msg[eol + 1] == '\n') + eol++; + } else if (!prefixcmp(msg + i, "author ")) + fill_person(table + IAUTHOR_NAME, + msg + i + 7, eol - i - 7); + else if (!prefixcmp(msg + i, "committer ")) + fill_person(table + ICOMMITTER_NAME, + msg + i + 10, eol - i - 10); + else if (!prefixcmp(msg + i, "encoding ")) + table[IENCODING].value = xstrndup(msg + i, eol - i); + i = eol; + } + if (msg[i]) + table[IBODY].value = xstrdup(msg + i); + for (i = 0; i < ARRAY_SIZE(table); i++) + if (!table[i].value) + interp_set_entry(table, i, "<unknown>"); + + interpolate(buf, space, user_format, table, ARRAY_SIZE(table)); + interp_clear_table(table, ARRAY_SIZE(table)); + + return strlen(buf); +} + unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, unsigned long len, @@ -725,7 +914,10 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const char *msg = commit->buffer; int plain_non_ascii = 0; char *reencoded; - char *encoding; + const char *encoding; + + if (fmt == CMIT_FMT_USERFORMAT) + return format_commit_message(commit, msg, buf, space); encoding = (git_log_output_encoding ? git_log_output_encoding @@ -47,6 +47,7 @@ enum cmit_fmt { CMIT_FMT_FULLER, CMIT_FMT_ONELINE, CMIT_FMT_EMAIL, + CMIT_FMT_USERFORMAT, CMIT_FMT_UNSPECIFIED, }; @@ -269,6 +269,11 @@ int git_default_config(const char *var, const char *value) return 0; } + if (!strcmp(var, "core.symlinks")) { + has_symlinks = git_config_bool(var, value); + return 0; + } + if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; @@ -426,7 +431,7 @@ static struct { int do_not_match; regex_t* value_regex; int multi_replace; - off_t offset[MAX_MATCHES]; + size_t offset[MAX_MATCHES]; enum { START, SECTION_SEEN, SECTION_END_SEEN, KEY_SEEN } state; int seen; } store; @@ -574,11 +579,11 @@ static int store_write_pair(int fd, const char* key, const char* value) return 1; } -static int find_beginning_of_line(const char* contents, int size, - int offset_, int* found_bracket) +static ssize_t find_beginning_of_line(const char* contents, size_t size, + size_t offset_, int* found_bracket) { - int equal_offset = size, bracket_offset = size; - int offset; + size_t equal_offset = size, bracket_offset = size; + ssize_t offset; for (offset = offset_-2; offset > 0 && contents[offset] != '\n'; offset--) @@ -722,7 +727,8 @@ int git_config_set_multivar(const char* key, const char* value, } else { struct stat st; char* contents; - int i, copy_begin, copy_end, new_line = 0; + size_t contents_sz, copy_begin, copy_end; + int i, new_line = 0; if (value_regex == NULL) store.value_regex = NULL; @@ -779,7 +785,8 @@ int git_config_set_multivar(const char* key, const char* value, } fstat(in_fd, &st); - contents = xmmap(NULL, st.st_size, PROT_READ, + contents_sz = xsize_t(st.st_size); + contents = xmmap(NULL, contents_sz, PROT_READ, MAP_PRIVATE, in_fd, 0); close(in_fd); @@ -788,12 +795,12 @@ int git_config_set_multivar(const char* key, const char* value, for (i = 0, copy_begin = 0; i < store.seen; i++) { if (store.offset[i] == 0) { - store.offset[i] = copy_end = st.st_size; + store.offset[i] = copy_end = contents_sz; } else if (store.state != KEY_SEEN) { copy_end = store.offset[i]; } else copy_end = find_beginning_of_line( - contents, st.st_size, + contents, contents_sz, store.offset[i]-2, &new_line); /* write the first part of the config */ @@ -820,13 +827,13 @@ int git_config_set_multivar(const char* key, const char* value, } /* write the rest of the config */ - if (copy_begin < st.st_size) + if (copy_begin < contents_sz) if (write_in_full(fd, contents + copy_begin, - st.st_size - copy_begin) < - st.st_size - copy_begin) + contents_sz - copy_begin) < + contents_sz - copy_begin) goto write_err_out; - munmap(contents, st.st_size); + munmap(contents, contents_sz); unlink(config_filename); } @@ -854,9 +861,37 @@ write_err_out: } +static int section_name_match (const char *buf, const char *name) +{ + int i = 0, j = 0, dot = 0; + for (; buf[i] && buf[i] != ']'; i++) { + if (!dot && isspace(buf[i])) { + dot = 1; + if (name[j++] != '.') + break; + for (i++; isspace(buf[i]); i++) + ; /* do nothing */ + if (buf[i] != '"') + break; + continue; + } + if (buf[i] == '\\' && dot) + i++; + else if (buf[i] == '"' && dot) { + for (i++; isspace(buf[i]); i++) + ; /* do_nothing */ + break; + } + if (buf[i] != name[j++]) + break; + } + return (buf[i] == ']' && name[j] == 0); +} + +/* if new_name == NULL, the section is removed instead */ int git_config_rename_section(const char *old_name, const char *new_name) { - int ret = 0; + int ret = 0, remove = 0; char *config_filename; struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1); int out_fd; @@ -887,31 +922,12 @@ int git_config_rename_section(const char *old_name, const char *new_name) ; /* do nothing */ if (buf[i] == '[') { /* it's a section */ - int j = 0, dot = 0; - for (i++; buf[i] && buf[i] != ']'; i++) { - if (!dot && isspace(buf[i])) { - dot = 1; - if (old_name[j++] != '.') - break; - for (i++; isspace(buf[i]); i++) - ; /* do nothing */ - if (buf[i] != '"') - break; + if (section_name_match (&buf[i+1], old_name)) { + ret++; + if (new_name == NULL) { + remove = 1; continue; } - if (buf[i] == '\\' && dot) - i++; - else if (buf[i] == '"' && dot) { - for (i++; isspace(buf[i]); i++) - ; /* do_nothing */ - break; - } - if (buf[i] != old_name[j++]) - break; - } - if (buf[i] == ']' && old_name[j] == 0) { - /* old_name matches */ - ret++; store.baselen = strlen(new_name); if (!store_write_section(out_fd, new_name)) { ret = write_error(); @@ -919,7 +935,10 @@ int git_config_rename_section(const char *old_name, const char *new_name) } continue; } + remove = 0; } + if (remove) + continue; length = strlen(buf); if (write_in_full(out_fd, buf, length) != length) { ret = write_error(); diff --git a/contrib/blameview/blameview.perl b/contrib/blameview/blameview.perl index a9a509febb..1dec00137b 100755 --- a/contrib/blameview/blameview.perl +++ b/contrib/blameview/blameview.perl @@ -41,7 +41,7 @@ $fileview->set_rules_hint(1); $fileview->signal_connect (row_activated => sub { my ($sl, $path, $column) = @_; my $row_ref = $sl->get_row_data_from_path ($path); - system("blameview @$row_ref[0] $fn &"); + system("blameview @$row_ref[0]~1 $fn &"); }); my $commitwindow = Gtk2::ScrolledWindow->new(); diff --git a/contrib/emacs/Makefile b/contrib/emacs/Makefile index 350846de90..8554e3967c 100644 --- a/contrib/emacs/Makefile +++ b/contrib/emacs/Makefile @@ -2,7 +2,7 @@ EMACS = emacs -ELC = git.elc vc-git.elc +ELC = git.elc vc-git.elc git-blame.elc INSTALL ?= install INSTALL_ELC = $(INSTALL) -m 644 prefix ?= $(HOME) @@ -15,6 +15,6 @@ install: all $(INSTALL_ELC) $(ELC) $(emacsdir) %.elc: %.el - $(EMACS) --batch --eval '(byte-compile-file "$<")' + $(EMACS) -batch -f batch-byte-compile $< clean:; rm -f $(ELC) diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 24629eb3e2..db87a37895 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -75,10 +75,11 @@ then to `add-log-mailing-address' and then to `user-mail-address'." :type '(choice (const :tag "Default" nil) (string :tag "Email"))) -(defcustom git-commits-coding-system 'utf-8 +(defcustom git-commits-coding-system nil "Default coding system for the log message of git commits." :group 'git - :type 'coding-system) + :type '(choice (const :tag "From repository config" nil) + (coding-system))) (defcustom git-append-signed-off-by nil "Whether to append a Signed-off-by line to the commit message before editing." @@ -236,6 +237,15 @@ and returns the process output as a string." (and (fboundp 'user-mail-address) (user-mail-address)) (and (boundp 'user-mail-address) user-mail-address))) +(defun git-get-commits-coding-system () + "Return the coding system to use for commits." + (let ((repo-config (git-config "i18n.commitencoding"))) + (or git-commits-coding-system + (and repo-config + (fboundp 'locale-charset-to-coding-system) + (locale-charset-to-coding-system repo-config)) + 'utf-8))) + (defun git-escape-file-name (name) "Escape a file name if necessary." (if (string-match "[\n\t\"\\]" name) @@ -327,7 +337,7 @@ and returns the process output as a string." "Call git-commit-tree with buffer as input and return the resulting commit SHA1." (let ((author-name (git-get-committer-name)) (author-email (git-get-committer-email)) - author-date log-start log-end args) + author-date log-start log-end args coding-system-for-write) (when head (push "-p" args) (push head args)) @@ -350,12 +360,12 @@ and returns the process output as a string." (push "-p" args) (push (match-string 1) args)))) (setq log-start (point-min))) - (setq log-end (point-max))) + (setq log-end (point-max)) + (setq coding-system-for-write buffer-file-coding-system)) (git-get-string-sha1 (with-output-to-string (with-current-buffer standard-output - (let ((coding-system-for-write git-commits-coding-system) - (env `(("GIT_AUTHOR_NAME" . ,author-name) + (let ((env `(("GIT_AUTHOR_NAME" . ,author-name) ("GIT_AUTHOR_EMAIL" . ,author-email) ("GIT_COMMITTER_NAME" . ,(git-get-committer-name)) ("GIT_COMMITTER_EMAIL" . ,(git-get-committer-email))))) @@ -881,37 +891,80 @@ and returns the process output as a string." (with-current-buffer log-edit-parent-buffer (git-get-filenames (git-marked-files-state 'added 'deleted 'modified)))) +(defun git-append-sign-off (name email) + "Append a Signed-off-by entry to the current buffer, avoiding duplicates." + (let ((sign-off (format "Signed-off-by: %s <%s>" name email)) + (case-fold-search t)) + (goto-char (point-min)) + (unless (re-search-forward (concat "^" (regexp-quote sign-off)) nil t) + (goto-char (point-min)) + (unless (re-search-forward "^Signed-off-by: " nil t) + (setq sign-off (concat "\n" sign-off))) + (goto-char (point-max)) + (insert sign-off "\n")))) + +(defun git-setup-log-buffer (buffer &optional author-name author-email subject date msg) + "Setup the log buffer for a commit." + (unless git-status (error "Not in git-status buffer.")) + (let ((merge-heads (git-get-merge-heads)) + (dir default-directory) + (committer-name (git-get-committer-name)) + (committer-email (git-get-committer-email)) + (sign-off git-append-signed-off-by)) + (with-current-buffer buffer + (cd dir) + (erase-buffer) + (insert + (propertize + (format "Author: %s <%s>\n%s%s" + (or author-name committer-name) + (or author-email committer-email) + (if date (format "Date: %s\n" date) "") + (if merge-heads + (format "Parent: %s\n%s\n" + (git-rev-parse "HEAD") + (mapconcat (lambda (str) (concat "Parent: " str)) merge-heads "\n")) + "")) + 'face 'git-header-face) + (propertize git-log-msg-separator 'face 'git-separator-face) + "\n") + (when subject (insert subject "\n\n")) + (cond (msg (insert msg "\n")) + ((file-readable-p ".dotest/msg") + (insert-file-contents ".dotest/msg")) + ((file-readable-p ".git/MERGE_MSG") + (insert-file-contents ".git/MERGE_MSG"))) + ; delete empty lines at end + (goto-char (point-min)) + (when (re-search-forward "\n+\\'" nil t) + (replace-match "\n" t t)) + (when sign-off (git-append-sign-off committer-name committer-email))))) + (defun git-commit-file () "Commit the marked file(s), asking for a commit message." (interactive) (unless git-status (error "Not in git-status buffer.")) (let ((buffer (get-buffer-create "*git-commit*")) - (merge-heads (git-get-merge-heads)) - (dir default-directory) - (sign-off git-append-signed-off-by)) - (with-current-buffer buffer - (when (eq 0 (buffer-size)) - (cd dir) - (erase-buffer) - (insert - (propertize - (format "Author: %s <%s>\n%s" - (git-get-committer-name) (git-get-committer-email) - (if merge-heads - (format "Parent: %s\n%s\n" - (git-rev-parse "HEAD") - (mapconcat (lambda (str) (concat "Parent: " str)) merge-heads "\n")) - "")) - 'face 'git-header-face) - (propertize git-log-msg-separator 'face 'git-separator-face) - "\n") - (cond ((file-readable-p ".git/MERGE_MSG") - (insert-file-contents ".git/MERGE_MSG")) - (sign-off - (insert (format "\n\nSigned-off-by: %s <%s>\n" - (git-get-committer-name) (git-get-committer-email))))))) + (coding-system (git-get-commits-coding-system)) + author-name author-email subject date) + (when (eq 0 (buffer-size buffer)) + (when (file-readable-p ".dotest/info") + (with-temp-buffer + (insert-file-contents ".dotest/info") + (goto-char (point-min)) + (when (re-search-forward "^Author: \\(.*\\)\nEmail: \\(.*\\)$" nil t) + (setq author-name (match-string 1)) + (setq author-email (match-string 2))) + (goto-char (point-min)) + (when (re-search-forward "^Subject: \\(.*\\)$" nil t) + (setq subject (match-string 1))) + (goto-char (point-min)) + (when (re-search-forward "^Date: \\(.*\\)$" nil t) + (setq date (match-string 1))))) + (git-setup-log-buffer buffer author-name author-email subject date)) (log-edit #'git-do-commit nil #'git-log-edit-files buffer) (setq font-lock-keywords (font-lock-compile-keywords git-log-edit-font-lock-keywords)) + (setq buffer-file-coding-system coding-system) (re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))) (defun git-find-file () diff --git a/convert-objects.c b/convert-objects.c index b5f41ae2e3..4809f9199f 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -132,7 +132,7 @@ static void convert_tree(void *buffer, unsigned long size, unsigned char *result unsigned long orig_size = size; while (size) { - int len = 1+strlen(buffer); + size_t len = 1+strlen(buffer); convert_binary_sha1((char *) buffer + len); @@ -55,12 +55,12 @@ static struct tm *time_to_tm(unsigned long time, int tz) return gmtime(&t); } -const char *show_date(unsigned long time, int tz, int relative) +const char *show_date(unsigned long time, int tz, enum date_mode mode) { struct tm *tm; static char timebuf[200]; - if (relative) { + if (mode == DATE_RELATIVE) { unsigned long diff; struct timeval now; gettimeofday(&now, NULL); @@ -105,12 +105,16 @@ const char *show_date(unsigned long time, int tz, int relative) tm = time_to_tm(time, tz); if (!tm) return NULL; - sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d %+05d", - weekday_names[tm->tm_wday], - month_names[tm->tm_mon], - tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, - tm->tm_year + 1900, tz); + if (mode == DATE_SHORT) + sprintf(timebuf, "%04d-%02d-%02d", tm->tm_year + 1900, + tm->tm_mon + 1, tm->tm_mday); + else + sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d %+05d", + weekday_names[tm->tm_wday], + month_names[tm->tm_mon], + tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, + tm->tm_year + 1900, tz); return timebuf; } diff --git a/diff-lib.c b/diff-lib.c index 60c0fa6488..6abb981534 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -8,11 +8,305 @@ #include "diffcore.h" #include "revision.h" #include "cache-tree.h" +#include "path-list.h" /* * diff-files */ +static int read_directory(const char *path, struct path_list *list) +{ + DIR *dir; + struct dirent *e; + + if (!(dir = opendir(path))) + return error("Could not open directory %s", path); + + while ((e = readdir(dir))) + if (strcmp(".", e->d_name) && strcmp("..", e->d_name)) + path_list_insert(xstrdup(e->d_name), list); + + closedir(dir); + return 0; +} + +static int get_mode(const char *path, int *mode) +{ + struct stat st; + + if (!path || !strcmp(path, "/dev/null")) + *mode = 0; + else if (!strcmp(path, "-")) + *mode = ntohl(create_ce_mode(0666)); + else if (stat(path, &st)) + return error("Could not access '%s'", path); + else + *mode = st.st_mode; + return 0; +} + +static int queue_diff(struct diff_options *o, + const char *name1, const char *name2) +{ + int mode1 = 0, mode2 = 0; + + if (get_mode(name1, &mode1) || get_mode(name2, &mode2)) + return -1; + + if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) + return error("file/directory conflict: %s, %s", name1, name2); + + if (S_ISDIR(mode1) || S_ISDIR(mode2)) { + char buffer1[PATH_MAX], buffer2[PATH_MAX]; + struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1}; + int len1 = 0, len2 = 0, i1, i2, ret = 0; + + if (name1 && read_directory(name1, &p1)) + return -1; + if (name2 && read_directory(name2, &p2)) { + path_list_clear(&p1, 0); + return -1; + } + + if (name1) { + len1 = strlen(name1); + if (len1 > 0 && name1[len1 - 1] == '/') + len1--; + memcpy(buffer1, name1, len1); + buffer1[len1++] = '/'; + } + + if (name2) { + len2 = strlen(name2); + if (len2 > 0 && name2[len2 - 1] == '/') + len2--; + memcpy(buffer2, name2, len2); + buffer2[len2++] = '/'; + } + + for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) { + const char *n1, *n2; + int comp; + + if (i1 == p1.nr) + comp = 1; + else if (i2 == p2.nr) + comp = -1; + else + comp = strcmp(p1.items[i1].path, + p2.items[i2].path); + + if (comp > 0) + n1 = NULL; + else { + n1 = buffer1; + strncpy(buffer1 + len1, p1.items[i1++].path, + PATH_MAX - len1); + } + + if (comp < 0) + n2 = NULL; + else { + n2 = buffer2; + strncpy(buffer2 + len2, p2.items[i2++].path, + PATH_MAX - len2); + } + + ret = queue_diff(o, n1, n2); + } + path_list_clear(&p1, 0); + path_list_clear(&p2, 0); + + return ret; + } else { + struct diff_filespec *d1, *d2; + + if (o->reverse_diff) { + unsigned tmp; + const char *tmp_c; + tmp = mode1; mode1 = mode2; mode2 = tmp; + tmp_c = name1; name1 = name2; name2 = tmp_c; + } + + if (!name1) + name1 = "/dev/null"; + if (!name2) + name2 = "/dev/null"; + d1 = alloc_filespec(name1); + d2 = alloc_filespec(name2); + fill_filespec(d1, null_sha1, mode1); + fill_filespec(d2, null_sha1, mode2); + + diff_queue(&diff_queued_diff, d1, d2); + return 0; + } +} + +static int is_in_index(const char *path) +{ + int len = strlen(path); + int pos = cache_name_pos(path, len); + char c; + + if (pos < 0) + return 0; + if (strncmp(active_cache[pos]->name, path, len)) + return 0; + c = active_cache[pos]->name[len]; + return c == '\0' || c == '/'; +} + +static int handle_diff_files_args(struct rev_info *revs, + int argc, const char **argv, int *silent) +{ + *silent = 0; + + /* revs->max_count == -2 means --no-index */ + while (1 < argc && argv[1][0] == '-') { + if (!strcmp(argv[1], "--base")) + revs->max_count = 1; + else if (!strcmp(argv[1], "--ours")) + revs->max_count = 2; + else if (!strcmp(argv[1], "--theirs")) + revs->max_count = 3; + else if (!strcmp(argv[1], "-n") || + !strcmp(argv[1], "--no-index")) + revs->max_count = -2; + else if (!strcmp(argv[1], "-q")) + *silent = 1; + else + return error("invalid option: %s", argv[1]); + argv++; argc--; + } + + if (revs->max_count == -1 && revs->diffopt.nr_paths == 2) { + /* + * If two files are specified, and at least one is untracked, + * default to no-index. + */ + read_cache(); + if (!is_in_index(revs->diffopt.paths[0]) || + !is_in_index(revs->diffopt.paths[1])) + revs->max_count = -2; + } + + /* + * Make sure there are NO revision (i.e. pending object) parameter, + * rev.max_count is reasonable (0 <= n <= 3), + * there is no other revision filtering parameters. + */ + if (revs->pending.nr || revs->max_count > 3 || + revs->min_age != -1 || revs->max_age != -1) + return error("no revision allowed with diff-files"); + + if (revs->max_count == -1 && + (revs->diffopt.output_format & DIFF_FORMAT_PATCH)) + revs->combine_merges = revs->dense_combined_merges = 1; + + return 0; +} + +static int is_outside_repo(const char *path, int nongit, const char *prefix) +{ + int i; + if (nongit || !strcmp(path, "-") || path[0] == '/') + return 1; + if (prefixcmp(path, "../")) + return 0; + if (!prefix) + return 1; + for (i = strlen(prefix); !prefixcmp(path, "../"); ) { + while (i > 0 && prefix[i - 1] != '/') + i--; + if (--i < 0) + return 1; + path += 3; + } + return 0; +} + +int setup_diff_no_index(struct rev_info *revs, + int argc, const char ** argv, int nongit, const char *prefix) +{ + int i; + for (i = 1; i < argc; i++) + if (argv[i][0] != '-' || argv[i][1] == '\0') + break; + else if (!strcmp(argv[i], "--")) { + i++; + break; + } else if (i < argc - 3 && !strcmp(argv[i], "--no-index")) { + i = argc - 3; + break; + } + if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) && + !is_outside_repo(argv[i], nongit, prefix))) + return -1; + + diff_setup(&revs->diffopt); + for (i = 1; i < argc - 2; ) + if (!strcmp(argv[i], "--no-index")) + i++; + else { + int j = diff_opt_parse(&revs->diffopt, + argv + i, argc - i); + if (!j) + die("invalid diff option/value: %s", argv[i]); + i += j; + } + + if (prefix) { + int len = strlen(prefix); + + revs->diffopt.paths = xcalloc(2, sizeof(char*)); + for (i = 0; i < 2; i++) { + const char *p = argv[argc - 2 + i]; + /* + * stdin should be spelled as '-'; if you have + * path that is '-', spell it as ./-. + */ + p = (strcmp(p, "-") + ? xstrdup(prefix_filename(prefix, len, p)) + : p); + revs->diffopt.paths[i] = p; + } + } + else + revs->diffopt.paths = argv + argc - 2; + revs->diffopt.nr_paths = 2; + revs->max_count = -2; + return 0; +} + +int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv) +{ + int silent_on_removed; + + if (handle_diff_files_args(revs, argc, argv, &silent_on_removed)) + return -1; + + if (revs->max_count == -2) { + if (revs->diffopt.nr_paths != 2) + return error("need two files/directories with --no-index"); + if (queue_diff(&revs->diffopt, revs->diffopt.paths[0], + revs->diffopt.paths[1])) + return -1; + diffcore_std(&revs->diffopt); + diff_flush(&revs->diffopt); + /* + * The return code for --no-index imitates diff(1): + * 0 = no changes, 1 = changes, else error + */ + return revs->diffopt.found_changes; + } + + if (read_cache() < 0) { + perror("read_cache"); + return -1; + } + return run_diff_files(revs, silent_on_removed); +} + int run_diff_files(struct rev_info *revs, int silent_on_removed) { int entries, i; @@ -20,11 +314,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed) if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; - entries = read_cache(); - if (entries < 0) { - perror("read_cache"); - return -1; - } + entries = active_nr; for (i = 0; i < entries; i++) { struct stat st; unsigned int oldmode, newmode; @@ -134,6 +424,9 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed) S_ISREG(newmode) && S_ISREG(oldmode) && ((newmode ^ oldmode) == 0111)) newmode = oldmode; + else if (!has_symlinks && + S_ISREG(newmode) && S_ISLNK(oldmode)) + newmode = oldmode; diff_change(&revs->diffopt, oldmode, newmode, ce->sha1, (changed ? null_sha1 : ce->sha1), ce->name, NULL); @@ -362,10 +655,6 @@ int run_diff_index(struct rev_info *revs, int cached) if (!revs->ignore_merges) match_missing = 1; - if (read_cache() < 0) { - perror("read_cache"); - return -1; - } mark_merge_entries(); ent = revs->pending.objects[0].item; @@ -382,6 +382,7 @@ struct emit_callback { int nparents, color_diff; const char **label_path; struct diff_words_data *diff_words; + int *found_changesp; }; static void free_diff_words_data(struct emit_callback *ecbdata) @@ -501,6 +502,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) const char *set = diff_get_color(ecbdata->color_diff, DIFF_METAINFO); const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET); + *(ecbdata->found_changesp) = 1; + if (ecbdata->label_path[0]) { const char *name_a_tab, *name_b_tab; @@ -1098,6 +1101,7 @@ static void builtin_diff(const char *name_a, if (complete_rewrite) { emit_rewrite_diff(name_a, name_b, one, two, o->color_diff); + o->found_changes = 1; goto free_ab_and_return; } } @@ -1115,6 +1119,7 @@ static void builtin_diff(const char *name_a, else printf("Binary files %s and %s differ\n", lbl[0], lbl[1]); + o->found_changes = 1; } else { /* Crazy xdl interfaces.. */ @@ -1127,6 +1132,7 @@ static void builtin_diff(const char *name_a, memset(&ecbdata, 0, sizeof(ecbdata)); ecbdata.label_path = lbl; ecbdata.color_diff = o->color_diff; + ecbdata.found_changesp = &o->found_changes; xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts; xecfg.ctxlen = o->context; xecfg.flags = XDL_EMIT_FUNCNAMES; @@ -1358,6 +1364,32 @@ static struct sha1_size_cache *locate_size_cache(unsigned char *sha1, return e; } +static int populate_from_stdin(struct diff_filespec *s) +{ +#define INCREMENT 1024 + char *buf; + unsigned long size; + int got; + + size = 0; + buf = NULL; + while (1) { + buf = xrealloc(buf, size + INCREMENT); + got = xread(0, buf + size, INCREMENT); + if (!got) + break; /* EOF */ + if (got < 0) + return error("error while reading from stdin %s", + strerror(errno)); + size += got; + } + s->should_munmap = 0; + s->data = buf; + s->size = size; + s->should_free = 1; + return 0; +} + /* * While doing rename detection and pickaxe operation, we may need to * grab the data for the blob (or file) for our own in-core comparison. @@ -1383,6 +1415,9 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) char *buf; unsigned long size; + if (!strcmp(s->path, "-")) + return populate_from_stdin(s); + if (lstat(s->path, &st) < 0) { if (errno == ENOENT) { err_empty: @@ -1393,7 +1428,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) return err; } } - s->size = st.st_size; + s->size = xsize_t(st.st_size); if (!s->size) goto empty; if (size_only) @@ -1509,12 +1544,13 @@ static void prepare_temp_file(const char *name, if (S_ISLNK(st.st_mode)) { int ret; char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */ + size_t sz = xsize_t(st.st_size); if (sizeof(buf) <= st.st_size) die("symlink too long: %s", name); - ret = readlink(name, buf, st.st_size); + ret = readlink(name, buf, sz); if (ret < 0) die("readlink(%s)", name); - prep_temp_blob(temp, buf, st.st_size, + prep_temp_blob(temp, buf, sz, (one->sha1_valid ? one->sha1 : null_sha1), (one->sha1_valid ? @@ -1683,6 +1719,10 @@ static void diff_fill_sha1_info(struct diff_filespec *one) if (DIFF_FILE_VALID(one)) { if (!one->sha1_valid) { struct stat st; + if (!strcmp(one->path, "-")) { + hashcpy(one->sha1, null_sha1); + return; + } if (lstat(one->path, &st) < 0) die("stat %s", one->path); if (index_path(one->sha1, one->path, &st, 0)) @@ -2132,7 +2172,7 @@ static int parse_num(const char **cp_p) /* user says num divided by scale and we say internally that * is MAX_SCORE * num / scale. */ - return (num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale); + return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale)); } int diff_scoreopt_parse(const char *opt) @@ -2456,7 +2496,8 @@ static void diff_resolve_rename_copy(void) p->status = DIFF_STATUS_RENAMED; } else if (hashcmp(p->one->sha1, p->two->sha1) || - p->one->mode != p->two->mode) + p->one->mode != p->two->mode || + is_null_sha1(p->one->sha1)) p->status = DIFF_STATUS_MODIFIED; else { /* This is a "no-change" entry and should not @@ -75,6 +75,9 @@ struct diff_options { int stat_width; int stat_name_width; + /* this is set by diffcore for DIFF_FORMAT_PATCH */ + int found_changes; + int nr_paths; const char **paths; int *pathlens; @@ -219,6 +222,9 @@ extern void diff_flush(struct diff_options*); extern const char *diff_unique_abbrev(const unsigned char *, int); extern int run_diff_files(struct rev_info *revs, int silent_on_removed); +extern int setup_diff_no_index(struct rev_info *revs, + int argc, const char ** argv, int nongit, const char *prefix); +extern int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv); extern int run_diff_index(struct rev_info *revs, int cached); diff --git a/diffcore-break.c b/diffcore-break.c index acb18db1db..9c19b8cab7 100644 --- a/diffcore-break.c +++ b/diffcore-break.c @@ -89,7 +89,7 @@ static int should_break(struct diff_filespec *src, * merge the surviving pair together if the score is * less than the minimum, after rename/copy runs. */ - *merge_score_p = src_removed * MAX_SCORE / src->size; + *merge_score_p = (int)(src_removed * MAX_SCORE / src->size); /* Extent of damage, which counts both inserts and * deletes. diff --git a/diffcore-order.c b/diffcore-order.c index 7ad0946185..2a4bd8232e 100644 --- a/diffcore-order.c +++ b/diffcore-order.c @@ -14,6 +14,7 @@ static void prepare_order(const char *orderfile) void *map; char *cp, *endp; struct stat st; + size_t sz; if (order) return; @@ -25,11 +26,12 @@ static void prepare_order(const char *orderfile) close(fd); return; } - map = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + sz = xsize_t(st.st_size); + map = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); close(fd); if (map == MAP_FAILED) return; - endp = (char *) map + st.st_size; + endp = (char *) map + sz; for (pass = 0; pass < 2; pass++) { cnt = 0; cp = map; diff --git a/diffcore-rename.c b/diffcore-rename.c index 91fa2bea51..79030412db 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -172,7 +172,8 @@ static int estimate_similarity(struct diff_filespec *src, return 0; /* error but caught downstream */ - delta_limit = base_size * (MAX_SCORE-minimum_score) / MAX_SCORE; + delta_limit = (unsigned long) + (base_size * (MAX_SCORE-minimum_score) / MAX_SCORE); if (diffcore_count_changes(src->data, src->size, dst->data, dst->size, &src->cnt_data, &dst->cnt_data, @@ -186,7 +187,7 @@ static int estimate_similarity(struct diff_filespec *src, if (!dst->size) score = 0; /* should not happen */ else - score = src_copied * MAX_SCORE / max_size; + score = (int)(src_copied * MAX_SCORE / max_size); return score; } @@ -297,7 +298,7 @@ void diffcore_rename(struct diff_options *options) struct diff_filespec *one = rename_src[j].one; if (!is_exact_match(one, two, contents_too)) continue; - record_rename_pair(i, j, MAX_SCORE); + record_rename_pair(i, j, (int)MAX_SCORE); rename_count++; break; /* we are done with this entry */ } @@ -130,13 +130,13 @@ static int add_excludes_from_file_1(const char *fname, { struct stat st; int fd, i; - long size; + size_t size; char *buf, *entry; fd = open(fname, O_RDONLY); if (fd < 0 || fstat(fd, &st) < 0) goto err; - size = st.st_size; + size = xsize_t(st.st_size); if (size == 0) { close(fd); return 0; @@ -111,9 +111,12 @@ static int write_entry(struct cache_entry *ce, char *path, struct checkout *stat return error("git-checkout-index: unable to write file %s", path); break; case S_IFLNK: - if (to_tempfile) { - strcpy(path, ".merge_link_XXXXXX"); - fd = mkstemp(path); + if (to_tempfile || !has_symlinks) { + if (to_tempfile) { + strcpy(path, ".merge_link_XXXXXX"); + fd = mkstemp(path); + } else + fd = create_file(path, 0666); if (fd < 0) { free(new); return error("git-checkout-index: unable to create " diff --git a/environment.c b/environment.c index 570e32ac3c..0151ad0722 100644 --- a/environment.c +++ b/environment.c @@ -13,6 +13,7 @@ char git_default_email[MAX_GITNAME]; char git_default_name[MAX_GITNAME]; int use_legacy_headers = 1; int trust_executable_bit = 1; +int has_symlinks = 1; int assume_unchanged; int prefer_symlink_refs; int is_bare_repository_cfg = -1; /* unspecified */ @@ -20,7 +21,7 @@ int log_all_ref_updates = -1; /* unspecified */ int warn_ambiguous_refs = 1; int repository_format_version; char *git_commit_encoding; -char *git_log_output_encoding; +const char *git_log_output_encoding; int shared_repository = PERM_UMASK; const char *apply_default_whitespace; int zlib_compression_level = Z_DEFAULT_COMPRESSION; diff --git a/fast-import.c b/fast-import.c index 65e99c2e8b..55ffae4fa6 100644 --- a/fast-import.c +++ b/fast-import.c @@ -133,10 +133,6 @@ Format of STDIN stream: #define PACK_ID_BITS 16 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1) -#ifndef PRIuMAX -#define PRIuMAX "llu" -#endif - struct object_entry { struct object_entry *next; @@ -220,7 +216,8 @@ struct branch const char *name; struct tree_entry branch_tree; uintmax_t last_commit; - unsigned int pack_id; + unsigned active : 1; + unsigned pack_id : PACK_ID_BITS; unsigned char sha1[20]; }; @@ -252,7 +249,7 @@ typedef enum { /* Configured limits on output */ static unsigned long max_depth = 10; -static unsigned long max_packsize = (1LL << 32) - 1; +static off_t max_packsize = (1LL << 32) - 1; static int force_update; /* Stats and misc. counters */ @@ -528,6 +525,7 @@ static struct branch *new_branch(const char *name) b->table_next_branch = branch_table[hc]; b->branch_tree.versions[0].mode = S_IFDIR; b->branch_tree.versions[1].mode = S_IFDIR; + b->active = 0; b->pack_id = MAX_PACK_ID; branch_table[hc] = b; branch_count++; @@ -755,7 +753,7 @@ static char *create_index(void) static char *keep_pack(char *curr_index_name) { static char name[PATH_MAX]; - static char *keep_msg = "fast-import"; + static const char *keep_msg = "fast-import"; int keep_fd; chmod(pack_data->pack_name, 0444); @@ -1060,7 +1058,7 @@ static void load_tree(struct tree_entry *root) struct tree_entry *e = new_tree_entry(); if (t->entry_count == t->entry_capacity) - root->tree = t = grow_tree_content(t, 8); + root->tree = t = grow_tree_content(t, t->entry_count); t->entries[t->entry_count++] = e; e->tree = NULL; @@ -1068,7 +1066,7 @@ static void load_tree(struct tree_entry *root) if (!c) die("Corrupt mode in %s", sha1_to_hex(sha1)); e->versions[0].mode = e->versions[1].mode; - e->name = to_atom(c, (unsigned short)strlen(c)); + e->name = to_atom(c, strlen(c)); c += e->name->str_len + 1; hashcpy(e->versions[0].sha1, (unsigned char*)c); hashcpy(e->versions[1].sha1, (unsigned char*)c); @@ -1227,9 +1225,9 @@ static int tree_content_set( } if (t->entry_count == t->entry_capacity) - root->tree = t = grow_tree_content(t, 8); + root->tree = t = grow_tree_content(t, t->entry_count); e = new_tree_entry(); - e->name = to_atom(p, (unsigned short)n); + e->name = to_atom(p, n); e->versions[0].mode = 0; hashclr(e->versions[0].sha1); t->entries[t->entry_count++] = e; @@ -1373,16 +1371,33 @@ static void dump_marks_helper(FILE *f, static void dump_marks(void) { - if (mark_file) - { - FILE *f = fopen(mark_file, "w"); - if (f) { - dump_marks_helper(f, 0, marks); - fclose(f); - } else - failure |= error("Unable to write marks file %s: %s", - mark_file, strerror(errno)); + static struct lock_file mark_lock; + int mark_fd; + FILE *f; + + if (!mark_file) + return; + + mark_fd = hold_lock_file_for_update(&mark_lock, mark_file, 0); + if (mark_fd < 0) { + failure |= error("Unable to write marks file %s: %s", + mark_file, strerror(errno)); + return; + } + + f = fdopen(mark_fd, "w"); + if (!f) { + rollback_lock_file(&mark_lock); + failure |= error("Unable to write marks file %s: %s", + mark_file, strerror(errno)); + return; } + + dump_marks_helper(f, 0, marks); + fclose(f); + if (commit_lock_file(&mark_lock)) + failure |= error("Unable to write marks file %s: %s", + mark_file, strerror(errno)); } static void read_next_command(void) @@ -1529,7 +1544,7 @@ static void unload_one_branch(void) { while (cur_active_branches && cur_active_branches >= max_active_branches) { - unsigned long min_commit = ULONG_MAX; + uintmax_t min_commit = ULONG_MAX; struct branch *e, *l = NULL, *p = NULL; for (e = active_branches; e; e = e->active_next_branch) { @@ -1547,6 +1562,7 @@ static void unload_one_branch(void) e = active_branches; active_branches = e->active_next_branch; } + e->active = 0; e->active_next_branch = NULL; if (e->branch_tree.tree) { release_tree_content_recursive(e->branch_tree.tree); @@ -1559,10 +1575,13 @@ static void unload_one_branch(void) static void load_branch(struct branch *b) { load_tree(&b->branch_tree); - b->active_next_branch = active_branches; - active_branches = b; - cur_active_branches++; - branch_load_count++; + if (!b->active) { + b->active = 1; + b->active_next_branch = active_branches; + active_branches = b; + cur_active_branches++; + branch_load_count++; + } } static void file_change_m(struct branch *b) @@ -1746,7 +1765,14 @@ static struct hash_list *cmd_merge(unsigned int *count) if (oe->type != OBJ_COMMIT) die("Mark :%" PRIuMAX " not a commit", idnum); hashcpy(n->sha1, oe->sha1); - } else if (get_sha1(from, n->sha1)) + } else if (!get_sha1(from, n->sha1)) { + unsigned long size; + char *buf = read_object_with_reference(n->sha1, + commit_type, &size, n->sha1); + if (!buf || size < 46) + die("Not a valid commit: %s", from); + free(buf); + } else die("Invalid ref name or SHA1 expression: %s", from); n->next = NULL; @@ -1967,6 +1993,40 @@ static void cmd_checkpoint(void) read_next_command(); } +static void import_marks(const char *input_file) +{ + char line[512]; + FILE *f = fopen(input_file, "r"); + if (!f) + die("cannot read %s: %s", input_file, strerror(errno)); + while (fgets(line, sizeof(line), f)) { + uintmax_t mark; + char *end; + unsigned char sha1[20]; + struct object_entry *e; + + end = strchr(line, '\n'); + if (line[0] != ':' || !end) + die("corrupt mark line: %s", line); + *end = 0; + mark = strtoumax(line + 1, &end, 10); + if (!mark || end == line + 1 + || *end != ' ' || get_sha1(end + 1, sha1)) + die("corrupt mark line: %s", line); + e = find_object(sha1); + if (!e) { + enum object_type type = sha1_object_info(sha1, NULL); + if (type < 0) + die("object not found: %s", sha1_to_hex(sha1)); + e = insert_object(sha1); + e->type = type; + e->pack_id = MAX_PACK_ID; + } + insert_mark(mark, e); + } + fclose(f); +} + static const char fast_import_usage[] = "git-fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]"; @@ -1975,6 +2035,12 @@ int main(int argc, const char **argv) int i, show_stats = 1; git_config(git_default_config); + alloc_objects(object_entry_alloc); + strbuf_init(&command_buf); + atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*)); + branch_table = xcalloc(branch_table_sz, sizeof(struct branch*)); + avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*)); + marks = pool_calloc(1, sizeof(struct mark_set)); for (i = 1; i < argc; i++) { const char *a = argv[i]; @@ -1998,6 +2064,8 @@ int main(int argc, const char **argv) max_depth = strtoul(a + 8, NULL, 0); else if (!prefixcmp(a, "--active-branches=")) max_active_branches = strtoul(a + 18, NULL, 0); + else if (!prefixcmp(a, "--import-marks=")) + import_marks(a + 15); else if (!prefixcmp(a, "--export-marks=")) mark_file = a + 15; else if (!prefixcmp(a, "--export-pack-edges=")) { @@ -2018,14 +2086,6 @@ int main(int argc, const char **argv) if (i != argc) usage(fast_import_usage); - alloc_objects(object_entry_alloc); - strbuf_init(&command_buf); - - atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*)); - branch_table = xcalloc(branch_table_sz, sizeof(struct branch*)); - avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*)); - marks = pool_calloc(1, sizeof(struct mark_set)); - start_packfile(); for (;;) { read_next_command(); diff --git a/fetch-pack.c b/fetch-pack.c index 41bdd27b8f..06f4aeced4 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -15,8 +15,9 @@ static int quiet; static int verbose; static int fetch_all; static int depth; +static int no_progress; static const char fetch_pack_usage[] = -"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]"; +"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]"; static const char *uploadpack = "git-upload-pack"; #define COMPLETE (1U << 0) @@ -173,12 +174,13 @@ static int find_common(int fd[2], unsigned char *result_sha1, } if (!fetching) - packet_write(fd[1], "want %s%s%s%s%s%s\n", + packet_write(fd[1], "want %s%s%s%s%s%s%s\n", sha1_to_hex(remote), (multi_ack ? " multi_ack" : ""), (use_sideband == 2 ? " side-band-64k" : ""), (use_sideband == 1 ? " side-band" : ""), (use_thin_pack ? " thin-pack" : ""), + (no_progress ? " no-progress" : ""), " ofs-delta"); else packet_write(fd[1], "want %s\n", sha1_to_hex(remote)); @@ -521,7 +523,7 @@ static int get_pack(int xd[2]) if (do_keep) { *av++ = "index-pack"; *av++ = "--stdin"; - if (!quiet) + if (!quiet && !no_progress) *av++ = "-v"; if (use_thin_pack) *av++ = "--fix-thin"; @@ -718,6 +720,10 @@ int main(int argc, char **argv) st.st_mtime = 0; continue; } + if (!strcmp("--no-progress", arg)) { + no_progress = 1; + continue; + } usage(fetch_pack_usage); } dest = arg; @@ -290,6 +290,10 @@ do git-mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \ <"$dotest/$msgnum" >"$dotest/info" || stop_here $this + test -s $dotest/patch || { + echo "Patch is empty. Was is split wrong?" + stop_here $this + } git-stripspace < "$dotest/msg" > "$dotest/msg-clean" ;; esac diff --git a/git-applymbox.sh b/git-applymbox.sh index 1f68599ae5..2cbdc7eb3c 100755 --- a/git-applymbox.sh +++ b/git-applymbox.sh @@ -77,6 +77,10 @@ do *) git-mailinfo $keep_subject $utf8 \ .dotest/msg .dotest/patch <$i >.dotest/info || exit 1 + test -s $dotest/patch || { + echo "Patch is empty. Was is split wrong?" + stop_here $this + } git-stripspace < .dotest/msg > .dotest/msg-clean ;; esac diff --git a/git-archimport.perl b/git-archimport.perl index 66aaeae102..c1e7c1ddcb 100755 --- a/git-archimport.perl +++ b/git-archimport.perl @@ -89,7 +89,11 @@ usage if $opt_h; # values associated with keys: # =1 - Arch version / git 'branch' detected via abrowse on a limit # >1 - Arch version / git 'branch' of an auxiliary branch we've merged -my %arch_branches = map { $_ => 1 } @ARGV; +my %arch_branches = map { my $branch = $_; $branch =~ s/:[^:]*$//; $branch => 1 } @ARGV; + +# $branch_name_map: +# maps arch branches to git branch names +my %branch_name_map = map { m/^(.*):([^:]*)$/; $1 => $2 } grep { m/:/ } @ARGV; $ENV{'TMPDIR'} = $opt_t if $opt_t; # $ENV{TMPDIR} will affect tempdir() calls: my $tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1); @@ -104,6 +108,7 @@ unless (-d $git_dir) { # initial import needs empty directory closedir DIR } +my $default_archive; # default Arch archive my %reachable = (); # Arch repositories we can access my %unreachable = (); # Arch repositories we can't access :< my @psets = (); # the collection @@ -303,7 +308,34 @@ sub old_style_branchname { return $ret; } -*git_branchname = $opt_o ? *old_style_branchname : *tree_dirname; +*git_default_branchname = $opt_o ? *old_style_branchname : *tree_dirname; + +# retrieve default archive, since $branch_name_map keys might not include it +sub get_default_archive { + if (!defined $default_archive) { + $default_archive = safe_pipe_capture($TLA,'my-default-archive'); + chomp $default_archive; + } + return $default_archive; +} + +sub git_branchname { + my $revision = shift; + my $name = extract_versionname($revision); + + if (exists $branch_name_map{$name}) { + return $branch_name_map{$name}; + + } elsif ($name =~ m#^([^/]*)/(.*)$# + && $1 eq get_default_archive() + && exists $branch_name_map{$2}) { + # the names given in the command-line lacked the archive. + return $branch_name_map{$2}; + + } else { + return git_default_branchname($revision); + } +} sub process_patchset_accurate { my $ps = shift; @@ -333,19 +365,23 @@ sub process_patchset_accurate { if ($ps->{tag} && (my $branchpoint = eval { ptag($ps->{tag}) })) { # find where we are supposed to branch from - system('git-checkout','-f','-b',$ps->{branch}, - $branchpoint) == 0 or die "$! $?\n"; - + if (! -e "$git_dir/refs/heads/$ps->{branch}") { + system('git-branch',$ps->{branch},$branchpoint) == 0 or die "$! $?\n"; + + # We trust Arch with the fact that this is just a tag, + # and it does not affect the state of the tree, so + # we just tag and move on. If the user really wants us + # to consolidate more branches into one, don't tag because + # the tag name would be already taken. + tag($ps->{id}, $branchpoint); + ptag($ps->{id}, $branchpoint); + print " * Tagged $ps->{id} at $branchpoint\n"; + } + system('git-checkout','-f',$ps->{branch}) == 0 or die "$! $?\n"; + # remove any old stuff that got leftover: my $rm = safe_pipe_capture('git-ls-files','--others','-z'); rmtree(split(/\0/,$rm)) if $rm; - - # If we trust Arch with the fact that this is just - # a tag, and it does not affect the state of the tree - # then we just tag and move on - tag($ps->{id}, $branchpoint); - ptag($ps->{id}, $branchpoint); - print " * Tagged $ps->{id} at $branchpoint\n"; return 0; } else { warn "Tagging from unknown id unsupported\n" if $ps->{tag}; @@ -385,14 +421,19 @@ sub process_patchset_fast { unless $branchpoint; # find where we are supposed to branch from - system('git-checkout','-b',$ps->{branch},$branchpoint); - - # If we trust Arch with the fact that this is just - # a tag, and it does not affect the state of the tree - # then we just tag and move on - tag($ps->{id}, $branchpoint); - ptag($ps->{id}, $branchpoint); - print " * Tagged $ps->{id} at $branchpoint\n"; + if (! -e "$git_dir/refs/heads/$ps->{branch}") { + system('git-branch',$ps->{branch},$branchpoint) == 0 or die "$! $?\n"; + + # We trust Arch with the fact that this is just a tag, + # and it does not affect the state of the tree, so + # we just tag and move on. If the user really wants us + # to consolidate more branches into one, don't tag because + # the tag name would be already taken. + tag($ps->{id}, $branchpoint); + ptag($ps->{id}, $branchpoint); + print " * Tagged $ps->{id} at $branchpoint\n"; + } + system('git-checkout',$ps->{branch}) == 0 or die "$! $?\n"; return 0; } die $! if $?; @@ -553,7 +594,7 @@ foreach my $ps (@psets) { my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) or die $!; - print WRITER $ps->{summary},"\n"; + print WRITER $ps->{summary},"\n\n"; print WRITER $ps->{message},"\n"; # make it easy to backtrack and figure out which Arch revision this was: @@ -755,7 +796,8 @@ sub parselog { $ps->{tag} = $1; $key = undef; } elsif (/^Summary:\s*(.*)$/ ) { - # summary can be multiline as long as it has a leading space + # summary can be multiline as long as it has a leading space. + # we squeeze it onto a single line, though. $ps->{summary} = [ $1 ]; $key = 'summary'; } elsif (/^Creator: (.*)\s*<([^\>]+)>/) { @@ -787,8 +829,18 @@ sub parselog { } } - # post-processing: - $ps->{summary} = join("\n",@{$ps->{summary}})."\n"; + # drop leading empty lines from the log message + while (@$log && $log->[0] eq '') { + shift @$log; + } + if (exists $ps->{summary} && @{$ps->{summary}}) { + $ps->{summary} = join(' ', @{$ps->{summary}}); + } + elsif (@$log == 0) { + $ps->{summary} = 'empty commit message'; + } else { + $ps->{summary} = $log->[0] . '...'; + } $ps->{message} = join("\n",@$log); # skip Arch control files, unescape pika-escaped files @@ -819,8 +871,9 @@ sub tag { if ($opt_o) { $tag =~ s|/|--|g; } else { - # don't use subdirs for tags yet, it could screw up other porcelains - $tag =~ s|/|,|g; + my $patchname = $tag; + $patchname =~ s/.*--//; + $tag = git_branchname ($tag) . '--' . $patchname; } if ($commit) { diff --git a/git-checkout.sh b/git-checkout.sh index 14835a4aa9..6caa9fdcc6 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -12,6 +12,7 @@ new= new_name= force= branch= +track= newbranch= newbranch_log= merge= @@ -33,7 +34,10 @@ while [ "$#" != "0" ]; do die "git checkout: we do not like '$newbranch' as a branch name." ;; "-l") - newbranch_log=1 + newbranch_log=-l + ;; + "--track"|"--no-track") + track="$arg" ;; "-f") force=1 @@ -85,6 +89,11 @@ while [ "$#" != "0" ]; do esac done +case "$new_branch,$track" in +,--*) + die "git checkout: --track and --no-track require -b" +esac + case "$force$merge" in 11) die "git checkout: -f and -m are incompatible" @@ -235,11 +244,7 @@ fi # if [ "$?" -eq 0 ]; then if [ "$newbranch" ]; then - if [ "$newbranch_log" ]; then - mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$newbranch") - touch "$GIT_DIR/logs/refs/heads/$newbranch" - fi - git-update-ref -m "checkout: Created from $new_name" "refs/heads/$newbranch" $new || exit + git-branch $track $newbranch_log "$newbranch" "$new_name" || exit branch="$newbranch" fi if test -n "$branch" diff --git a/git-clone.sh b/git-clone.sh index 1bd54ded3c..de51983584 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -79,6 +79,8 @@ origin= origin_override= use_separate_remote=t depth= +no_progress= +test -t 1 || no_progress=--no-progress while case "$#,$1" in 0,*) break ;; @@ -290,8 +292,8 @@ yes,yes) ;; *) case "$upload_pack" in - '') git-fetch-pack --all -k $quiet $depth "$repo" ;; - *) git-fetch-pack --all -k $quiet "$upload_pack" $depth "$repo" ;; + '') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";; + *) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;; esac >"$GIT_DIR/CLONE_HEAD" || die "fetch-pack from '$repo' failed." ;; @@ -393,7 +395,7 @@ then case "$no_checkout" in '') - test "z$quiet" = z && v=-v || v= + test "z$quiet" = z -a "z$no_progress" = z && v=-v || v= git-read-tree -m -u $v HEAD HEAD esac fi diff --git a/git-commit.sh b/git-commit.sh index 476f4f18db..3656d607d5 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> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]' +USAGE='[-a | --interactive] [-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 @@ -13,10 +13,10 @@ git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t case "$0" in *status) status_only=t - unmerged_ok_if_status=--unmerged ;; + ;; *commit) status_only= - unmerged_ok_if_status= ;; + ;; esac refuse_partial () { @@ -71,6 +71,7 @@ trap ' all= also= +interactive= only= logfile= use_commit= @@ -131,6 +132,11 @@ do also=t shift ;; + --int|--inte|--inter|--intera|--interac|--interact|--interacti|\ + --interactiv|--interactive) + interactive=t + shift + ;; -o|--o|--on|--onl|--only) only=t shift @@ -304,12 +310,14 @@ case "$#,$also,$only,$amend" in ;; esac unset only -case "$all,$also,$#" in -t,t,*) - die "Cannot use -a and -i at the same time." ;; +case "$all,$interactive,$also,$#" in +*t,*t,*) + die "Cannot use -a, --interactive or -i at the same time." ;; t,,[1-9]*) die "Paths with -a does not make sense." ;; -,t,0) +,t,[1-9]*) + die "Paths with --interactive does not make sense." ;; +,,t,0) die "No paths with -i does not make sense." ;; esac @@ -344,6 +352,9 @@ t,) ) || exit ;; ,) + if test "$interactive" = t; then + git add --interactive || exit + fi case "$#" in 0) ;; # commit as-is @@ -393,16 +404,17 @@ else USE_INDEX="$THIS_INDEX" fi -GIT_INDEX_FILE="$USE_INDEX" \ - git-update-index -q $unmerged_ok_if_status --refresh || exit - -################################################################ -# If the request is status, just show it and exit. - -case "$0" in -*status) +case "$status_only" in +t) + # This will silently fail in a read-only repository, which is + # what we want. + GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --unmerged --refresh run_status exit $? + ;; +'') + GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --refresh || exit + ;; esac ################################################################ @@ -621,6 +633,9 @@ else fi ret="$?" rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG" + +cd_to_toplevel + if test -d "$GIT_DIR/rr-cache" then git-rerere diff --git a/git-compat-util.h b/git-compat-util.h index 5d154faef6..7534db1267 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -49,9 +49,15 @@ #include <netdb.h> #include <pwd.h> #include <inttypes.h> +#if defined(__CYGWIN__) +#undef _XOPEN_SOURCE +#include <grp.h> +#define _XOPEN_SOURCE 600 +#else #undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */ #include <grp.h> #define _ALL_SOURCE 1 +#endif #ifndef NO_ICONV #include <iconv.h> @@ -64,6 +70,10 @@ #define PATH_MAX 4096 #endif +#ifndef PRIuMAX +#define PRIuMAX "llu" +#endif + #ifdef __GNUC__ #define NORETURN __attribute__((__noreturn__)) #else @@ -248,6 +258,11 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len) } } +static inline size_t xsize_t(off_t len) +{ + return (size_t)len; +} + static inline int has_extension(const char *filename, const char *ext) { size_t len = strlen(filename); diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl index d08216cfd7..67224b4449 100755 --- a/git-cvsexportcommit.perl +++ b/git-cvsexportcommit.perl @@ -248,13 +248,14 @@ if ($opt_c) { die "Exiting: The commit did not succeed"; } print "Committed successfully to CVS\n"; + # clean up + unlink(".msg"); } else { print "Ready for you to commit, just run:\n\n $cmd\n"; } # clean up unlink(".cvsexportcommit.diff"); -unlink(".msg"); sub usage { print STDERR <<END; diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 84520e7ad5..65fcc84049 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -374,7 +374,8 @@ sub req_add print "Checked-in $dirpart\n"; print "$filename\n"; - print "/$filepart/0///\n"; + my $kopts = kopts_from_path($filepart); + print "/$filepart/0//$kopts/\n"; $addcount++; } @@ -455,7 +456,8 @@ sub req_remove print "Checked-in $dirpart\n"; print "$filename\n"; - print "/$filepart/-1.$wrev///\n"; + my $kopts = kopts_from_path($filepart); + print "/$filepart/-1.$wrev//$kopts/\n"; $rmcount++; } @@ -726,7 +728,8 @@ sub req_co print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n"; # this is an "entries" line - print "/$git->{name}/1.$git->{revision}///\n"; + my $kopts = kopts_from_path($git->{name}); + print "/$git->{name}/1.$git->{revision}//$kopts/\n"; # permissions print "u=$git->{mode},g=$git->{mode},o=$git->{mode}\n"; @@ -917,8 +920,9 @@ sub req_update print $state->{CVSROOT} . "/$state->{module}/$filename\n"; # this is an "entries" line - $log->debug("/$filepart/1.$meta->{revision}///"); - print "/$filepart/1.$meta->{revision}///\n"; + my $kopts = kopts_from_path($filepart); + $log->debug("/$filepart/1.$meta->{revision}//$kopts/"); + print "/$filepart/1.$meta->{revision}//$kopts/\n"; # permissions $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}"); @@ -953,16 +957,17 @@ sub req_update { $log->info("Merged successfully"); print "M M $filename\n"; - $log->debug("Update-existing $dirpart"); + $log->debug("Merged $dirpart"); # Don't want to actually _DO_ the update if -n specified unless ( $state->{globaloptions}{-n} ) { - print "Update-existing $dirpart\n"; + print "Merged $dirpart\n"; $log->debug($state->{CVSROOT} . "/$state->{module}/$filename"); print $state->{CVSROOT} . "/$state->{module}/$filename\n"; - $log->debug("/$filepart/1.$meta->{revision}///"); - print "/$filepart/1.$meta->{revision}///\n"; + my $kopts = kopts_from_path($filepart); + $log->debug("/$filepart/1.$meta->{revision}//$kopts/"); + print "/$filepart/1.$meta->{revision}//$kopts/\n"; } } elsif ( $return == 1 ) @@ -973,9 +978,10 @@ sub req_update # Don't want to actually _DO_ the update if -n specified unless ( $state->{globaloptions}{-n} ) { - print "Update-existing $dirpart\n"; + print "Merged $dirpart\n"; print $state->{CVSROOT} . "/$state->{module}/$filename\n"; - print "/$filepart/1.$meta->{revision}/+//\n"; + my $kopts = kopts_from_path($filepart); + print "/$filepart/1.$meta->{revision}/+/$kopts/\n"; } } else @@ -1031,36 +1037,35 @@ sub req_ci exit; } - my $lockfile = "$state->{CVSROOT}/refs/heads/$state->{module}.lock"; - unless ( sysopen(LOCKFILE,$lockfile,O_EXCL|O_CREAT|O_WRONLY) ) - { - $log->warn("lockfile '$lockfile' already exists, please try again"); - print "error 1 Lock file '$lockfile' already exists, please try again\n"; - exit; - } - # Grab a handle to the SQLite db and do any necessary updates my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log); $updater->update(); my $tmpdir = tempdir ( DIR => $TEMP_DIR ); my ( undef, $file_index ) = tempfile ( DIR => $TEMP_DIR, OPEN => 0 ); - $log->info("Lock successful, basing commit on '$tmpdir', index file is '$file_index'"); + $log->info("Lockless commit start, basing commit on '$tmpdir', index file is '$file_index'"); $ENV{GIT_DIR} = $state->{CVSROOT} . "/"; $ENV{GIT_INDEX_FILE} = $file_index; + # Remember where the head was at the beginning. + my $parenthash = `git show-ref -s refs/heads/$state->{module}`; + chomp $parenthash; + if ($parenthash !~ /^[0-9a-f]{40}$/) { + print "error 1 pserver cannot find the current HEAD of module"; + exit; + } + chdir $tmpdir; # populate the temporary index based - system("git-read-tree", $state->{module}); + system("git-read-tree", $parenthash); unless ($? == 0) { die "Error running git-read-tree $state->{module} $file_index $!"; } $log->info("Created index '$file_index' with for head $state->{module} - exit status $?"); - my @committedfiles = (); # foreach file specified on the command line ... @@ -1095,8 +1100,6 @@ sub req_ci { # fail everything if an up to date check fails print "error 1 Up to date check failed for $filename\n"; - close LOCKFILE; - unlink($lockfile); chdir "/"; exit; } @@ -1139,16 +1142,12 @@ sub req_ci { print "E No files to commit\n"; print "ok\n"; - close LOCKFILE; - unlink($lockfile); chdir "/"; return; } my $treehash = `git-write-tree`; - my $parenthash = `cat $ENV{GIT_DIR}refs/heads/$state->{module}`; chomp $treehash; - chomp $parenthash; $log->debug("Treehash : $treehash, Parenthash : $parenthash"); @@ -1159,14 +1158,13 @@ sub req_ci close $msg_fh; my $commithash = `git-commit-tree $treehash -p $parenthash < $msg_filename`; + chomp($commithash); $log->info("Commit hash : $commithash"); unless ( $commithash =~ /[a-zA-Z0-9]{40}/ ) { $log->warn("Commit failed (Invalid commit hash)"); print "error 1 Commit failed (unknown reason)\n"; - close LOCKFILE; - unlink($lockfile); chdir "/"; exit; } @@ -1179,14 +1177,17 @@ sub req_ci { $log->warn("Commit failed (update hook declined to update ref)"); print "error 1 Commit failed (update hook declined)\n"; - close LOCKFILE; - unlink($lockfile); chdir "/"; exit; } } - print LOCKFILE $commithash; + if (system(qw(git update-ref -m), "cvsserver ci", + "refs/heads/$state->{module}", $commithash, $parenthash)) { + $log->warn("update-ref for $state->{module} failed."); + print "error 1 Cannot commit -- update first\n"; + exit; + } $updater->update(); @@ -1211,16 +1212,12 @@ sub req_ci } else { print "Checked-in $dirpart\n"; print "$filename\n"; - print "/$filepart/1.$meta->{revision}///\n"; + my $kopts = kopts_from_path($filepart); + print "/$filepart/1.$meta->{revision}//$kopts/\n"; } } - close LOCKFILE; - my $reffile = "$ENV{GIT_DIR}refs/heads/$state->{module}"; - unlink($reffile); - rename($lockfile, $reffile); chdir "/"; - print "ok\n"; } @@ -1897,6 +1894,28 @@ sub filecleanup return $filename; } +# Given a path, this function returns a string containing the kopts +# that should go into that path's Entries line. For example, a binary +# file should get -kb. +sub kopts_from_path +{ + my ($path) = @_; + + # Once it exists, the git attributes system should be used to look up + # what attributes apply to this path. + + # Until then, take the setting from the config file + unless ( defined ( $cfg->{gitcvs}{allbinary} ) and $cfg->{gitcvs}{allbinary} =~ /^\s*(1|true|yes)\s*$/i ) + { + # Return "" to give no special treatment to any path + return ""; + } else { + # Alternatively, to have all files treated as if they are binary (which + # is more like git itself), always return the "-kb" option + return "-kb"; + } +} + package GITCVS::log; #### diff --git a/git-fetch.sh b/git-fetch.sh index 4a8d8d6ef7..9d45dd266a 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -24,6 +24,8 @@ update_head_ok= exec= keep= shallow_depth= +no_progress= +test -t 1 || no_progress=--no-progress while case "$#" in 0) break ;; esac do case "$1" in @@ -163,8 +165,16 @@ fetch_native () { ( : subshell because we muck with IFS IFS=" $LF" ( - git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref || + if test -f "$remote" ; then + test -n "$shallow_depth" && + die "shallow clone with bundle is not supported" + git-bundle unbundle "$remote" $rref || + echo failed "$remote" + else + git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \ + "$remote" $rref || echo failed "$remote" + fi ) | ( flags= @@ -4,7 +4,7 @@ # # Cleanup unreachable files and optimize the repository. -USAGE='git-gc [--prune]' +USAGE='[--prune]' SUBDIRECTORY_OK=Yes . git-sh-setup diff --git a/git-gui/.gitignore b/git-gui/.gitignore index 805ca2e1c7..c714d382e8 100644 --- a/git-gui/.gitignore +++ b/git-gui/.gitignore @@ -1,4 +1,3 @@ -CREDITS-FILE GIT-VERSION-FILE git-citool git-gui diff --git a/git-gui/CREDITS-GEN b/git-gui/CREDITS-GEN deleted file mode 100755 index d1b0f86355..0000000000 --- a/git-gui/CREDITS-GEN +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -CF=CREDITS-FILE -tip= - -tree_search () -{ - head=$1 - tree=$2 - for p in $(git rev-list --parents --max-count=1 $head 2>/dev/null) - do - test $tree = $(git rev-parse $p^{tree} 2>/dev/null) && - vn=$(git describe --abbrev=4 $p 2>/dev/null) && - case "$vn" in - gitgui-[0-9]*) echo $p; break;; - esac - done -} - -generate_credits () -{ - tip=$1 && - rm -f "$2" && - git shortlog -n -s $tip | sed 's/: .*$//' >"$2" || exit -} - -# Always use the tarball credits file if found, just -# in case we are somehow contained in a larger git -# repository that doesn't actually track our state. -# (At least one package manager is doing this.) -# -# We may be a subproject, so try looking for the merge -# commit that supplied this directory content if we are -# not at the toplevel. We probably will always be the -# second parent in the commit, but we shouldn't rely on -# that fact. -# - -credits_tmp=/var/tmp/gitgui-credits-$$ -trap 'rm -f "$credits_tmp"' 0 - -orig="$credits_tmp" - -if test -f credits -then - orig=credits -elif prefix="$(git rev-parse --show-prefix 2>/dev/null)" && - test -n "$prefix" && - head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) && - tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) && - tip=$(tree_search $head $tree) && - test -n "$tip" -then - generate_credits $tip "$orig" || exit -elif tip="$(git rev-parse --verify HEAD 2>/dev/null)" && - test -n "$tip" -then - generate_credits $tip "$orig" || exit -else - echo "error: Cannot locate authorship information." >&2 - exit 1 -fi - -if test -f "$orig" && cmp -s "$orig" "$CF" -then - : noop -else - rm -f "$CF" && - cat "$orig" >"$CF" -fi - diff --git a/git-gui/Makefile b/git-gui/Makefile index 66538ba1ad..b82789ead6 100644 --- a/git-gui/Makefile +++ b/git-gui/Makefile @@ -1,11 +1,15 @@ all:: +# Define V=1 to have a more verbose compile. +# + GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @$(SHELL_PATH) ./GIT-VERSION-GEN -include GIT-VERSION-FILE +SCRIPT_SH = git-gui.sh GITGUI_BUILT_INS = git-citool -ALL_PROGRAMS = git-gui $(GITGUI_BUILT_INS) +ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH)) ifndef SHELL_PATH SHELL_PATH = /bin/sh @@ -19,27 +23,33 @@ ifndef INSTALL INSTALL = install endif +ifndef V + QUIET_GEN = @echo ' ' GEN $@; + QUIET_BUILT_IN = @echo ' ' BUILTIN $@; +endif + +ifeq ($(findstring $(MAKEFLAGS),s),s) +QUIET_GEN = +QUIET_BUILT_IN = +endif + DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) -git-gui: git-gui.sh GIT-VERSION-FILE CREDITS-FILE - rm -f $@ $@+ - sed -n \ - -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ +$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh + $(QUIET_GEN)rm -f $@ $@+ && \ + sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \ - -e '1,/^set gitgui_credits /p' \ - $@.sh >$@+ - cat CREDITS-FILE >>$@+ - sed -e '1,/^set gitgui_credits /d' $@.sh >>$@+ - chmod +x $@+ + $@.sh >$@+ && \ + chmod +x $@+ && \ mv $@+ $@ -CREDITS-FILE: CREDITS-GEN .FORCE-CREDITS-FILE - $(SHELL_PATH) ./CREDITS-GEN - $(GITGUI_BUILT_INS): git-gui - rm -f $@ && ln git-gui $@ + $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@ + +# These can record GITGUI_VERSION +$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE all:: $(ALL_PROGRAMS) @@ -48,14 +58,12 @@ install: all $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)' $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;) -dist-version: CREDITS-FILE +dist-version: @mkdir -p $(TARDIR) @echo $(GITGUI_VERSION) > $(TARDIR)/version - @cat CREDITS-FILE > $(TARDIR)/credits clean:: - rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE CREDITS-FILE + rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE .PHONY: all install dist-version clean .PHONY: .FORCE-GIT-VERSION-FILE -.PHONY: .FORCE-CREDITS-FILE diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index f84ba3382b..60e79ca1b0 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -19,9 +19,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA} -set gitgui_credits { -Paul Mackerras -} ###################################################################### ## @@ -302,6 +299,11 @@ proc ask_popup {msg} { ## ## version check +if {{--version} eq $argv || {version} eq $argv} { + puts "git-gui version $appvers" + exit +} + set req_maj 1 set req_min 5 @@ -1171,7 +1173,7 @@ File [short_path $path] cannot be committed by this program. } } } - if {!$files_ready} { + if {!$files_ready && ![string match *merge $curType]} { info_popup {No changes to commit. You must add at least 1 file before you can commit. @@ -1267,6 +1269,24 @@ proc commit_committree {fd_wt curHEAD msg} { return } + # -- Verify this wasn't an empty change. + # + if {$commit_type eq {normal}} { + set old_tree [git rev-parse "$PARENT^{tree}"] + if {$tree_id eq $old_tree} { + info_popup {No changes to commit. + +No files were modified by this commit and it +was not a merge commit. + +A rescan will be automatically started now. +} + unlock_index + rescan {set ui_status_value {No changes to commit.}} + return + } + } + # -- Build the message. # set msg_p [gitdir COMMIT_EDITMSG] @@ -1281,14 +1301,8 @@ proc commit_committree {fd_wt curHEAD msg} { # -- Create the commit. # set cmd [list git commit-tree $tree_id] - set parents [concat $PARENT $MERGE_HEAD] - if {[llength $parents] > 0} { - foreach p $parents { - lappend cmd -p $p - } - } else { - # git commit-tree writes to stderr during initial commit. - lappend cmd 2>/dev/null + foreach p [concat $PARENT $MERGE_HEAD] { + lappend cmd -p $p } lappend cmd <$msg_p if {[catch {set cmt_id [eval exec $cmd]} err]} { @@ -4480,61 +4494,6 @@ proc do_commit {} { commit_tree } -proc do_credits {} { - global gitgui_credits - - set w .credits_dialog - - toplevel $w - wm geometry $w "+[winfo rootx .]+[winfo rooty .]" - - label $w.header -text {git-gui Contributors} -font font_uibold - pack $w.header -side top -fill x - - frame $w.buttons - button $w.buttons.close -text {Close} \ - -font font_ui \ - -command [list destroy $w] - pack $w.buttons.close -side right - pack $w.buttons -side bottom -fill x -pady 10 -padx 10 - - frame $w.credits - text $w.credits.t \ - -background [$w.header cget -background] \ - -yscrollcommand [list $w.credits.sby set] \ - -width 20 \ - -height 10 \ - -wrap none \ - -borderwidth 1 \ - -relief solid \ - -padx 5 -pady 5 \ - -font font_ui - scrollbar $w.credits.sby -command [list $w.credits.t yview] - pack $w.credits.sby -side right -fill y - pack $w.credits.t -fill both -expand 1 - pack $w.credits -side top -fill both -expand 1 -padx 5 -pady 5 - - label $w.desc \ - -text "All portions are copyrighted by their respective authors -and are distributed under the GNU General Public License." \ - -padx 5 -pady 5 \ - -justify left \ - -anchor w \ - -borderwidth 1 \ - -relief solid \ - -font font_ui - pack $w.desc -side top -fill x -padx 5 -pady 5 - - $w.credits.t insert end "[string trim $gitgui_credits]\n" - $w.credits.t conf -state disabled - $w.credits.t see 1.0 - - bind $w <Visibility> "grab $w; focus $w" - bind $w <Key-Escape> [list destroy $w] - wm title $w [$w.header cget -text] - tkwait window $w -} - proc do_about {} { global appvers copyright global tcl_patchLevel tk_patchLevel @@ -4551,10 +4510,6 @@ proc do_about {} { button $w.buttons.close -text {Close} \ -font font_ui \ -command [list destroy $w] - button $w.buttons.credits -text {Contributors} \ - -font font_ui \ - -command do_credits - pack $w.buttons.credits -side left pack $w.buttons.close -side right pack $w.buttons -side bottom -fill x -pady 10 -padx 10 @@ -5104,8 +5059,6 @@ enable_option branch enable_option transport switch -- $subcommand { ---version - -version - browser - blame { disable_option multicommit @@ -5256,6 +5209,12 @@ if {[is_enabled branch]} { -font font_ui lappend disable_on_lock [list .mbar.branch entryconf \ [.mbar.branch index last] -state] + + .mbar.branch add command -label {Reset...} \ + -command do_reset_hard \ + -font font_ui + lappend disable_on_lock [list .mbar.branch entryconf \ + [.mbar.branch index last] -state] } # -- Commit Menu @@ -5330,6 +5289,34 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} { [list .mbar.commit entryconf [.mbar.commit index last] -state] } +# -- Merge Menu +# +if {[is_enabled branch]} { + menu .mbar.merge + .mbar.merge add command -label {Local Merge...} \ + -command do_local_merge \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.merge entryconf [.mbar.merge index last] -state] + .mbar.merge add command -label {Abort Merge...} \ + -command do_reset_hard \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.merge entryconf [.mbar.merge index last] -state] + +} + +# -- Transport Menu +# +if {[is_enabled transport]} { + menu .mbar.fetch + + menu .mbar.push + .mbar.push add command -label {Push...} \ + -command do_push_anywhere \ + -font font_ui +} + if {[is_MacOSX]} { # -- Apple Menu (Mac OS X only) # @@ -5442,11 +5429,6 @@ bind all <$M1B-Key-W> {destroy [winfo toplevel %W]} # -- Not a normal commit type invocation? Do that instead! # switch -- $subcommand { ---version - -version { - puts "git-gui version $appvers" - exit -} browser { if {[llength $argv] != 1} { puts stderr "usage: $argv0 browser commit" @@ -5502,28 +5484,6 @@ pack .branch.l1 -side left pack .branch.cb -side left -fill x pack .branch -side top -fill x -if {[is_enabled branch]} { - menu .mbar.merge - .mbar.merge add command -label {Local Merge...} \ - -command do_local_merge \ - -font font_ui - lappend disable_on_lock \ - [list .mbar.merge entryconf [.mbar.merge index last] -state] - .mbar.merge add command -label {Abort Merge...} \ - -command do_reset_hard \ - -font font_ui - lappend disable_on_lock \ - [list .mbar.merge entryconf [.mbar.merge index last] -state] - - - menu .mbar.fetch - - menu .mbar.push - .mbar.push add command -label {Push...} \ - -command do_push_anywhere \ - -font font_ui -} - # -- Main Window Layout # panedwindow .vpane -orient vertical diff --git a/git-ls-remote.sh b/git-ls-remote.sh index 8ea5c5e816..a6ed99a7c5 100755 --- a/git-ls-remote.sh +++ b/git-ls-remote.sh @@ -89,8 +89,13 @@ rsync://* ) ;; * ) - git-peek-remote $exec "$peek_repo" || + if test -f "$peek_repo" ; then + git bundle list-heads "$peek_repo" || echo "failed slurping" + else + git-peek-remote $exec "$peek_repo" || + echo "failed slurping" + fi ;; esac | sort -t ' ' -k 2 | diff --git a/git-merge.sh b/git-merge.sh index 498c938c45..6ce62c860a 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -294,7 +294,12 @@ f,*) git-update-index --refresh 2>/dev/null new_head=$(git-rev-parse --verify "$1^0") && git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" && - finish "$new_head" "Fast forward" + msg="Fast forward" + if test -n "$have_message" + then + msg="$msg (no commit created; -m option ignored)" + fi + finish "$new_head" "$msg" || exit dropsave exit 0 ;; diff --git a/git-mergetool.sh b/git-mergetool.sh new file mode 100755 index 0000000000..52386a5443 --- /dev/null +++ b/git-mergetool.sh @@ -0,0 +1,352 @@ +#!/bin/sh +# +# This program resolves merge conflicts in git +# +# Copyright (c) 2006 Theodore Y. Ts'o +# +# This file is licensed under the GPL v2, or a later version +# at the discretion of Junio C Hammano. +# + +USAGE='[--tool=tool] [file to merge] ...' +SUBDIRECTORY_OK=Yes +. git-sh-setup +require_work_tree + +# Returns true if the mode reflects a symlink +function is_symlink () { + test "$1" = 120000 +} + +function local_present () { + test -n "$local_mode" +} + +function remote_present () { + test -n "$remote_mode" +} + +function base_present () { + test -n "$base_mode" +} + +cleanup_temp_files () { + if test "$1" = --save-backup ; then + mv -- "$BACKUP" "$path.orig" + rm -f -- "$LOCAL" "$REMOTE" "$BASE" + else + rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP" + fi +} + +function describe_file () { + mode="$1" + branch="$2" + file="$3" + + echo -n " " + if test -z "$mode"; then + echo -n "'$path' was deleted" + elif is_symlink "$mode" ; then + echo -n "'$path' is a symlink containing '" + cat "$file" + echo -n "'" + else + if base_present; then + echo -n "'$path' was created" + else + echo -n "'$path' was modified" + fi + fi + echo " in the $branch branch" +} + + +resolve_symlink_merge () { + while /bin/true; do + echo -n "Use (r)emote or (l)ocal, or (a)bort? " + read ans + case "$ans" in + [lL]*) + git-checkout-index -f --stage=2 -- "$path" + git-add -- "$path" + cleanup_temp_files --save-backup + return + ;; + [rR]*) + git-checkout-index -f --stage=3 -- "$path" + git-add -- "$path" + cleanup_temp_files --save-backup + return + ;; + [qQ]*) + exit 1 + ;; + esac + done +} + +resolve_deleted_merge () { + while /bin/true; do + echo -n "Use (m)odified or (d)eleted file, or (a)bort? " + read ans + case "$ans" in + [mM]*) + git-add -- "$path" + cleanup_temp_files --save-backup + return + ;; + [dD]*) + git-rm -- "$path" + cleanup_temp_files + return + ;; + [qQ]*) + exit 1 + ;; + esac + done +} + +merge_file () { + path="$1" + + if test ! -f "$path" ; then + echo "$path: file not found" + exit 1 + fi + + f=`git-ls-files -u -- "$path"` + if test -z "$f" ; then + echo "$path: file does not need merging" + exit 1 + fi + + BACKUP="$path.BACKUP.$$" + LOCAL="$path.LOCAL.$$" + REMOTE="$path.REMOTE.$$" + BASE="$path.BASE.$$" + + mv -- "$path" "$BACKUP" + cp -- "$BACKUP" "$path" + + base_mode=`git ls-files -u -- "$path" | awk '{if ($3==1) print $1;}'` + local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'` + remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'` + + base_present && git cat-file blob ":1:$path" > "$BASE" 2>/dev/null + local_present && git cat-file blob ":2:$path" > "$LOCAL" 2>/dev/null + remote_present && git cat-file blob ":3:$path" > "$REMOTE" 2>/dev/null + + if test -z "$local_mode" -o -z "$remote_mode"; then + echo "Deleted merge conflict for $path:" + describe_file "$local_mode" "local" "$LOCAL" + describe_file "$remote_mode" "remote" "$REMOTE" + resolve_deleted_merge + return + fi + + if is_symlink "$local_mode" || is_symlink "$remote_mode"; then + echo "Symlink merge conflict for $path:" + describe_file "$local_mode" "local" "$LOCAL" + describe_file "$remote_mode" "remote" "$REMOTE" + resolve_symlink_merge + return + fi + + echo "Normal merge conflict for $path:" + describe_file "$local_mode" "local" "$LOCAL" + describe_file "$remote_mode" "remote" "$REMOTE" + echo -n "Hit return to start merge resolution tool ($merge_tool): " + read ans + + case "$merge_tool" in + kdiff3) + if base_present ; then + (kdiff3 --auto --L1 "$path (Base)" -L2 "$path (Local)" --L3 "$path (Remote)" \ + -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1) + else + (kdiff3 --auto -L1 "$path (Local)" --L2 "$path (Remote)" \ + -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1) + fi + status=$? + if test "$status" -eq 0; then + rm "$BACKUP" + fi + ;; + tkdiff) + if base_present ; then + tkdiff -a "$BASE" -o "$path" -- "$LOCAL" "$REMOTE" + else + tkdiff -o "$path" -- "$LOCAL" "$REMOTE" + fi + status=$? + if test "$status" -eq 0; then + mv -- "$BACKUP" "$path.orig" + fi + ;; + meld) + touch "$BACKUP" + meld -- "$LOCAL" "$path" "$REMOTE" + if test "$path" -nt "$BACKUP" ; then + status=0; + else + while true; do + echo "$path seems unchanged." + echo -n "Was the merge successful? [y/n] " + read answer < /dev/tty + case "$answer" in + y*|Y*) status=0; break ;; + n*|N*) status=1; break ;; + esac + done + fi + if test "$status" -eq 0; then + mv -- "$BACKUP" "$path.orig" + fi + ;; + xxdiff) + touch "$BACKUP" + if base_present ; then + xxdiff -X --show-merged-pane \ + -R 'Accel.SaveAsMerged: "Ctrl-S"' \ + -R 'Accel.Search: "Ctrl+F"' \ + -R 'Accel.SearchForward: "Ctrl-G"' \ + --merged-file "$path" -- "$LOCAL" "$BASE" "$REMOTE" + else + xxdiff -X --show-merged-pane \ + -R 'Accel.SaveAsMerged: "Ctrl-S"' \ + -R 'Accel.Search: "Ctrl+F"' \ + -R 'Accel.SearchForward: "Ctrl-G"' \ + --merged-file "$path" -- "$LOCAL" "$REMOTE" + fi + if test "$path" -nt "$BACKUP" ; then + status=0; + else + while true; do + echo "$path seems unchanged." + echo -n "Was the merge successful? [y/n] " + read answer < /dev/tty + case "$answer" in + y*|Y*) status=0; break ;; + n*|N*) status=1; break ;; + esac + done + fi + if test "$status" -eq 0; then + mv -- "$BACKUP" "$path.orig" + fi + ;; + emerge) + if base_present ; then + emacs -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$path" + else + emacs -f emerge-files-command "$LOCAL" "$REMOTE" "$path" + fi + status=$? + if test "$status" -eq 0; then + mv -- "$BACKUP" "$path.orig" + fi + ;; + esac + if test "$status" -ne 0; then + echo "merge of $path failed" 1>&2 + mv -- "$BACKUP" "$path" + exit 1 + fi + git add -- "$path" + cleanup_temp_files +} + +while case $# in 0) break ;; esac +do + case "$1" in + -t|--tool*) + case "$#,$1" in + *,*=*) + merge_tool=`expr "z$1" : 'z-[^=]*=\(.*\)'` + ;; + 1,*) + usage ;; + *) + merge_tool="$2" + shift ;; + esac + ;; + --) + break + ;; + -*) + usage + ;; + *) + break + ;; + esac + shift +done + +if test -z "$merge_tool"; then + merge_tool=`git-config merge.tool` + if test $merge_tool = kdiff3 -o $merge_tool = tkdiff -o \ + $merge_tool = xxdiff -o $merge_tool = meld ; then + unset merge_tool + fi +fi + +if test -z "$merge_tool" ; then + if type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then + merge_tool="kdiff3"; + elif type tkdiff >/dev/null 2>&1 && test -n "$DISPLAY"; then + merge_tool=tkdiff + elif type xxdiff >/dev/null 2>&1 && test -n "$DISPLAY"; then + merge_tool=xxdiff + elif type meld >/dev/null 2>&1 && test -n "$DISPLAY"; then + merge_tool=meld + elif type emacs >/dev/null 2>&1; then + merge_tool=emerge + else + echo "No available merge resolution programs available." + exit 1 + fi +fi + +case "$merge_tool" in + kdiff3|tkdiff|meld|xxdiff) + if ! type "$merge_tool" > /dev/null 2>&1; then + echo "The merge tool $merge_tool is not available" + exit 1 + fi + ;; + emerge) + if ! type "emacs" > /dev/null 2>&1; then + echo "Emacs is not available" + exit 1 + fi + ;; + *) + echo "Unknown merge tool: $merge_tool" + exit 1 + ;; +esac + +if test $# -eq 0 ; then + files=`git ls-files -u | sed -e 's/^[^ ]* //' | sort -u` + if test -z "$files" ; then + echo "No files need merging" + exit 0 + fi + echo Merging the files: $files + git ls-files -u | sed -e 's/^[^ ]* //' | sort -u | while read i + do + echo "" + merge_file "$i" < /dev/tty > /dev/tty + done +else + while test $# -gt 0; do + echo "" + merge_file "$1" + shift + done +fi +exit 0 diff --git a/git-quiltimport.sh b/git-quiltimport.sh index 671a5ff865..08ac9bb729 100755 --- a/git-quiltimport.sh +++ b/git-quiltimport.sh @@ -73,6 +73,10 @@ mkdir $tmp_dir || exit 2 for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do echo $patch_name (cat $QUILT_PATCHES/$patch_name | git-mailinfo "$tmp_msg" "$tmp_patch" > "$tmp_info") || exit 3 + test -s $dotest/patch || { + echo "Patch is empty. Was is split wrong?" + stop_here $this + } # Parse the author information export GIT_AUTHOR_NAME=$(sed -ne 's/Author: //p' "$tmp_info") diff --git a/git-revert.sh b/git-revert.sh deleted file mode 100755 index 49f00321b2..0000000000 --- a/git-revert.sh +++ /dev/null @@ -1,197 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Linus Torvalds -# Copyright (c) 2005 Junio C Hamano -# - -case "$0" in -*-revert* ) - test -t 0 && edit=-e - replay= - me=revert - USAGE='[--edit | --no-edit] [-n] <commit-ish>' ;; -*-cherry-pick* ) - replay=t - edit= - me=cherry-pick - USAGE='[--edit] [-n] [-r] [-x] <commit-ish>' ;; -* ) - 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 -do - case "$1" in - -n|--n|--no|--no-|--no-c|--no-co|--no-com|--no-comm|\ - --no-commi|--no-commit) - no_commit=t - ;; - -e|--e|--ed|--edi|--edit) - edit=-e - ;; - --n|--no|--no-|--no-e|--no-ed|--no-edi|--no-edit) - edit= - ;; - -r) - : no-op ;; - -x|--i-really-want-to-expose-my-private-commit-object-name) - replay= - ;; - -*) - usage - ;; - *) - break - ;; - esac - shift -done - -set_reflog_action "$me" - -test "$me,$replay" = "revert,t" && usage - -case "$no_commit" in -t) - # We do not intend to commit immediately. We just want to - # merge the differences in. - head=$(git-write-tree) || - die "Your index file is unmerged." - ;; -*) - head=$(git-rev-parse --verify HEAD) || - die "You do not have a valid HEAD" - files=$(git-diff-index --cached --name-only $head) || exit - if [ "$files" ]; then - die "Dirty index: cannot $me (dirty: $files)" - fi - ;; -esac - -rev=$(git-rev-parse --verify "$@") && -commit=$(git-rev-parse --verify "$rev^0") || - die "Not a single commit $@" -prev=$(git-rev-parse --verify "$commit^1" 2>/dev/null) || - die "Cannot run $me a root commit" -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 -# reverse of it if we are revert. - -case "$me" in -revert) - git show -s --pretty=oneline --encoding="$encoding" $commit | - sed -e ' - s/^[^ ]* /Revert "/ - s/$/"/ - ' - echo - echo "This reverts commit $commit." - test "$rev" = "$commit" || - echo "(original 'git revert' arguments: $@)" - base=$commit next=$prev - ;; - -cherry-pick) - pick_author_script=' - /^author /{ - s/'\''/'\''\\'\'\''/g - h - s/^author \([^<]*\) <[^>]*> .*$/\1/ - s/'\''/'\''\'\'\''/g - s/.*/GIT_AUTHOR_NAME='\''&'\''/p - - g - s/^author [^<]* <\([^>]*\)> .*$/\1/ - s/'\''/'\''\'\'\''/g - s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p - - g - s/^author [^<]* <[^>]*> \(.*\)$/\1/ - s/'\''/'\''\'\'\''/g - s/.*/GIT_AUTHOR_DATE='\''&'\''/p - - q - }' - - 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 - - echo "$logmsg" | - sed -e '1,/^$/d' -e 's/^ //' - case "$replay" in - '') - echo "(cherry picked from commit $commit)" - test "$rev" = "$commit" || - echo "(original 'git cherry-pick' arguments: $@)" - ;; - esac - base=$prev next=$commit - ;; - -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). - -git-merge-recursive $base -- $head $next && -result=$(git-write-tree 2>/dev/null) || { - 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) - echo >&2 "You may choose to use the following when making" - echo >&2 "the commit:" - echo >&2 "$set_author_env" - esac - exit 1 -} -echo >&2 "Finished one $me." - -# If we are cherry-pick, and if the merge did not result in -# hand-editing, we will hit this commit and inherit the original -# author date and name. -# If we are revert, or if our cherry-pick results in a hand merge, -# we had better say that the current user is responsible for that. - -case "$no_commit" in -'') - git-commit -n -F .msg $edit - rm -f .msg - ;; -esac diff --git a/git-send-email.perl b/git-send-email.perl index 6a285bfd21..6989c0260f 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -34,6 +34,53 @@ sub readline { } package main; + +sub usage { + print <<EOT; +git-send-email [options] <file | directory>... +Options: + --from Specify the "From:" line of the email to be sent. + + --to Specify the primary "To:" line of the email. + + --cc Specify an initial "Cc:" list for the entire series + of emails. + + --bcc Specify a list of email addresses that should be Bcc: + on all the emails. + + --compose Use \$EDITOR to edit an introductory message for the + patch series. + + --subject Specify the initial "Subject:" line. + Only necessary if --compose is also set. If --compose + is not set, this will be prompted for. + + --in-reply-to Specify the first "In-Reply-To:" header line. + Only used if --compose is also set. If --compose is not + set, this will be prompted for. + + --chain-reply-to If set, the replies will all be to the previous + email sent, rather than to the first email sent. + Defaults to on. + + --no-signed-off-cc Suppress the automatic addition of email addresses + that appear in a Signed-off-by: line, to the cc: list. + Note: Using this option is not recommended. + + --smtp-server If set, specifies the outgoing SMTP server to use. + Defaults to localhost. + + --suppress-from Suppress sending emails to yourself if your address + appears in a From: line. + + --quiet Make git-send-email less verbose. One line per email + should be all that is output. + +EOT + exit(1); +} + # most mail servers generate the Date: header, but not all... sub format_2822_time { my ($time) = @_; @@ -102,6 +149,16 @@ if ($@) { $term = new FakeTerm "$@: going non-interactive"; } +my $def_chain = $repo->config_boolean('sendemail.chainreplyto'); +if ($def_chain and $def_chain eq 'false') { + $chain_reply_to = 0; +} + +@bcclist = $repo->config('sendemail.bcc'); +if (!@bcclist or !$bcclist[0]) { + @bcclist = (); +} + # Begin by accumulating all the variables (defined above), that we will end up # needing, first, from the command line: @@ -120,6 +177,10 @@ my $rc = GetOptions("from=s" => \$from, "dry-run" => \$dry_run, ); +unless ($rc) { + usage(); +} + # Verify the user input foreach my $entry (@to) { @@ -311,50 +372,8 @@ if (@files) { print $_,"\n" for (@files); } } else { - print <<EOT; -git-send-email [options] <file | directory> [... file | directory ] -Options: - --from Specify the "From:" line of the email to be sent. - - --to Specify the primary "To:" line of the email. - - --cc Specify an initial "Cc:" list for the entire series - of emails. - - --bcc Specify a list of email addresses that should be Bcc: - on all the emails. - - --compose Use \$EDITOR to edit an introductory message for the - patch series. - - --subject Specify the initial "Subject:" line. - Only necessary if --compose is also set. If --compose - is not set, this will be prompted for. - - --in-reply-to Specify the first "In-Reply-To:" header line. - Only used if --compose is also set. If --compose is not - set, this will be prompted for. - - --chain-reply-to If set, the replies will all be to the previous - email sent, rather than to the first email sent. - Defaults to on. - - --no-signed-off-cc Suppress the automatic addition of email addresses - that appear in a Signed-off-by: line, to the cc: list. - Note: Using this option is not recommended. - - --smtp-server If set, specifies the outgoing SMTP server to use. - Defaults to localhost. - - --suppress-from Suppress sending emails to yourself if your address - appears in a From: line. - - --quiet Make git-send-email less verbose. One line per email should be - all that is output. - -Error: Please specify a file or a directory on the command line. -EOT - exit(1); + print STDERR "\nNo patch files specified!\n\n"; + usage(); } # Variables we set as part of the loop over files diff --git a/git-svn.perl b/git-svn.perl index 41961b59f6..e8457893db 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -56,7 +56,7 @@ my ($_stdin, $_help, $_edit, $_message, $_file, $_template, $_shared, $_version, $_fetch_all, - $_merge, $_strategy, $_dry_run, + $_merge, $_strategy, $_dry_run, $_local, $_prefix, $_no_checkout, $_verbose); $Git::SVN::_follow_parent = 1; my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username, @@ -145,6 +145,7 @@ my %cmd = ( { 'merge|m|M' => \$_merge, 'verbose|v' => \$_verbose, 'strategy|s=s' => \$_strategy, + 'local|l' => \$_local, 'fetch-all|all' => \$_fetch_all, %fc_opts } ], 'commit-diff' => [ \&cmd_commit_diff, @@ -439,7 +440,9 @@ sub cmd_rebase { command_noisy('status'); exit 1; } - $_fetch_all ? $gs->fetch_all : $gs->fetch; + unless ($_local) { + $_fetch_all ? $gs->fetch_all : $gs->fetch; + } command_noisy(rebase_cmd(), $gs->refname); } @@ -447,7 +450,7 @@ sub cmd_show_ignore { my $url = (::working_head_info('HEAD'))[0]; my $gs = Git::SVN->find_by_url($url) || Git::SVN->new; my $r = (defined $_revision ? $_revision : $gs->ra->get_latest_revnum); - $gs->traverse_ignore(\*STDOUT, '', $r); + $gs->traverse_ignore(\*STDOUT, $gs->{path}, $r); } sub cmd_multi_init { @@ -1334,7 +1337,7 @@ sub traverse_ignore { my $ra = $self->ra; my ($dirent, undef, $props) = $ra->get_dir($path, $r); my $p = $path; - $p =~ s#^\Q$ra->{svn_path}\E/##; + $p =~ s#^\Q$self->{path}\E(/|$)##; print $fh length $p ? "\n# $p\n" : "\n# /\n"; if (my $s = $props->{'svn:ignore'}) { $s =~ s/[\r\n]+/\n/g; @@ -226,19 +226,21 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "add", cmd_add, RUN_SETUP | NOT_BARE }, { "annotate", cmd_annotate, USE_PAGER }, { "apply", cmd_apply }, - { "archive", cmd_archive }, + { "archive", cmd_archive, RUN_SETUP }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP }, + { "bundle", cmd_bundle }, { "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 }, + { "cherry-pick", cmd_cherry_pick, RUN_SETUP | NOT_BARE }, { "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 }, - { "diff-files", cmd_diff_files, RUN_SETUP }, + { "diff", cmd_diff, USE_PAGER }, + { "diff-files", cmd_diff_files }, { "diff-index", cmd_diff_index, RUN_SETUP }, { "diff-tree", cmd_diff_tree, RUN_SETUP }, { "fetch--tool", cmd_fetch__tool, RUN_SETUP }, @@ -272,6 +274,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "rerere", cmd_rerere, RUN_SETUP }, { "rev-list", cmd_rev_list, RUN_SETUP }, { "rev-parse", cmd_rev_parse, RUN_SETUP }, + { "revert", cmd_revert, RUN_SETUP | NOT_BARE }, { "rm", cmd_rm, RUN_SETUP | NOT_BARE }, { "runstatus", cmd_runstatus, RUN_SETUP | NOT_BARE }, { "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER }, diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 653ca3cc60..27b5970bca 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -591,7 +591,7 @@ sub esc_html ($;%) { my %opts = @_; $str = to_utf8($str); - $str = escapeHTML($str); + $str = $cgi->escapeHTML($str); if ($opts{'-nbsp'}) { $str =~ s/ / /g; } @@ -605,7 +605,7 @@ sub esc_path { my %opts = @_; $str = to_utf8($str); - $str = escapeHTML($str); + $str = $cgi->escapeHTML($str); if ($opts{'-nbsp'}) { $str =~ s/ / /g; } @@ -1974,17 +1974,17 @@ sub git_print_page_path { $fullname .= ($fullname ? '/' : '') . $dir; print $cgi->a({-href => href(action=>"tree", file_name=>$fullname, hash_base=>$hb), - -title => esc_html($fullname)}, esc_path($dir)); + -title => $fullname}, esc_path($dir)); print " / "; } if (defined $type && $type eq 'blob') { print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name, hash_base=>$hb), - -title => esc_html($name)}, esc_path($basename)); + -title => $name}, esc_path($basename)); } elsif (defined $type && $type eq 'tree') { print $cgi->a({-href => href(action=>"tree", file_name=>$file_name, hash_base=>$hb), - -title => esc_html($name)}, esc_path($basename)); + -title => $name}, esc_path($basename)); print " / "; } else { print esc_path($basename); diff --git a/hash-object.c b/hash-object.c index 5f89e64c13..18f5017f51 100644 --- a/hash-object.c +++ b/hash-object.c @@ -7,7 +7,7 @@ #include "cache.h" #include "blob.h" -static void hash_object(const char *path, const char *type, int write_object) +static void hash_object(const char *path, enum object_type type, int write_object) { int fd; struct stat st; @@ -15,7 +15,7 @@ static void hash_object(const char *path, const char *type, int write_object) fd = open(path, O_RDONLY); if (fd < 0 || fstat(fd, &st) < 0 || - index_fd(sha1, fd, &st, write_object, type)) + index_fd(sha1, fd, &st, write_object, type, path)) die(write_object ? "Unable to add %s to database" : "Unable to hash %s", path); @@ -73,7 +73,7 @@ int main(int argc, char **argv) if (0 <= prefix_length) arg = prefix_filename(prefix, prefix_length, arg); - hash_object(arg, type, write_object); + hash_object(arg, type_from_string(type), write_object); no_more_flags = 1; } } diff --git a/http-push.c b/http-push.c index 0fd73dbf58..cbb02d3bc1 100644 --- a/http-push.c +++ b/http-push.c @@ -1271,7 +1271,9 @@ xml_cdata(void *userData, const XML_Char *s, int len) struct xml_ctx *ctx = (struct xml_ctx *)userData; free(ctx->cdata); ctx->cdata = xmalloc(len + 1); - strlcpy(ctx->cdata, s, len + 1); + /* NB: 's' is not null-terminated, can not use strlcpy here */ + memcpy(ctx->cdata, s, len); + ctx->cdata[len] = '\0'; } static struct remote_lock *lock_remote(const char *path, long timeout) @@ -1295,7 +1297,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout) sprintf(url, "%s%s", remote->url, path); /* Make sure leading directories exist for the remote ref */ - ep = strchr(url + strlen(remote->url) + 11, '/'); + ep = strchr(url + strlen(remote->url) + 1, '/'); while (ep) { *ep = 0; slot = get_active_slot(); @@ -1473,7 +1475,8 @@ static void process_ls_object(struct remote_ls_ctx *ls) return; path += 8; obj_hex = xmalloc(strlen(path)); - strlcpy(obj_hex, path, 3); + /* NB: path is not null-terminated, can not use strlcpy here */ + memcpy(obj_hex, path, 2); strcpy(obj_hex + 2, path + 3); one_remote_object(obj_hex); free(obj_hex); @@ -2170,7 +2173,8 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1) /* If it's a symref, set the refname; otherwise try for a sha1 */ if (!prefixcmp((char *)buffer.buffer, "ref: ")) { *symref = xmalloc(buffer.posn - 5); - strlcpy(*symref, (char *)buffer.buffer + 5, buffer.posn - 5); + memcpy(*symref, (char *)buffer.buffer + 5, buffer.posn - 6); + (*symref)[buffer.posn - 6] = '\0'; } else { get_sha1_hex(buffer.buffer, sha1); } diff --git a/index-pack.c b/index-pack.c index c56458ebd5..b405864be9 100644 --- a/index-pack.c +++ b/index-pack.c @@ -277,13 +277,19 @@ static void *get_data_from_pack(struct object_entry *obj) { unsigned long from = obj[0].offset + obj[0].hdr_size; unsigned long len = obj[1].offset - from; + unsigned long rdy = 0; unsigned char *src, *data; z_stream stream; int st; src = xmalloc(len); - if (pread(pack_fd, src, len, from) != len) - die("cannot pread pack file: %s", strerror(errno)); + data = src; + do { + ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy); + if (n <= 0) + die("cannot pread pack file: %s", strerror(errno)); + rdy += n; + } while (rdy < len); data = xmalloc(obj->size); memset(&stream, 0, sizeof(stream)); stream.next_out = data; @@ -457,7 +463,8 @@ static void parse_pack_objects(unsigned char *sha1) /* If input_fd is a file, we should have reached its end now. */ if (fstat(input_fd, &st)) die("cannot fstat packfile: %s", strerror(errno)); - if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes) + if (S_ISREG(st.st_mode) && + lseek(input_fd, 0, SEEK_CUR) - input_len != st.st_size) die("pack has junk at the end"); if (!nr_deltas) @@ -746,7 +753,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name, const char *keep_name, const char *keep_msg, unsigned char *sha1) { - char *report = "pack"; + const char *report = "pack"; char name[PATH_MAX]; int err; diff --git a/interpolate.c b/interpolate.c index f992ef7753..fb30694f47 100644 --- a/interpolate.c +++ b/interpolate.c @@ -55,7 +55,7 @@ int interpolate(char *result, int reslen, const char *src = orig; char *dest = result; int newlen = 0; - char *name, *value; + const char *name, *value; int namelen, valuelen; int i; char c; diff --git a/interpolate.h b/interpolate.h index 190a180b58..16a26b9986 100644 --- a/interpolate.h +++ b/interpolate.h @@ -12,7 +12,7 @@ */ struct interp { - char *name; + const char *name; char *value; }; diff --git a/log-tree.c b/log-tree.c index ac86194047..8797aa14c4 100644 --- a/log-tree.c +++ b/log-tree.c @@ -186,7 +186,7 @@ void show_log(struct rev_info *opt, const char *sep) snprintf(subject_buffer, sizeof(subject_buffer) - 1, "%s" "MIME-Version: 1.0\n" - "Content-Type: multipart/mixed;\n" + "Content-Type: multipart/mixed;" " boundary=\"%s%s\"\n" "\n" "This is a multi-part message in MIME " @@ -202,16 +202,18 @@ void show_log(struct rev_info *opt, const char *sep) snprintf(buffer, sizeof(buffer) - 1, "--%s%s\n" - "Content-Type: text/x-patch;\n" + "Content-Type: text/x-patch;" " name=\"%s.diff\"\n" "Content-Transfer-Encoding: 8bit\n" - "Content-Disposition: inline;\n" + "Content-Disposition: %s;" " filename=\"%s.diff\"\n\n", mime_boundary_leader, opt->mime_boundary, - sha1, sha1); + sha1, + opt->no_inline ? "attachment" : "inline", + sha1); opt->diffopt.stat_sep = buffer; } - } else { + } else if (opt->commit_format != CMIT_FMT_USERFORMAT) { fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT), stdout); if (opt->commit_format != CMIT_FMT_ONELINE) diff --git a/merge-recursive.c b/merge-recursive.c index 87cd8709bb..c96e1a734c 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -570,7 +570,7 @@ static void update_file_flags(const unsigned char *sha, if (type != OBJ_BLOB) die("blob expected for %s '%s'", sha1_to_hex(sha), path); - if (S_ISREG(mode)) { + if (S_ISREG(mode) || (!has_symlinks && S_ISLNK(mode))) { int fd; if (mkdir_p(path, 0777)) die("failed to create path %s: %s", path, strerror(errno)); @@ -591,6 +591,7 @@ static void update_file_flags(const unsigned char *sha, mkdir_p(path, 0777); unlink(path); symlink(lnk, path); + free(lnk); } else die("do not know what to do with %06o %s '%s'", mode, sha1_to_hex(sha), path); diff --git a/pack-check.c b/pack-check.c index f248ac8c7a..299c514128 100644 --- a/pack-check.c +++ b/pack-check.c @@ -4,12 +4,13 @@ static int verify_packfile(struct packed_git *p, struct pack_window **w_curs) { - unsigned long index_size = p->index_size; + off_t index_size = p->index_size; void *index_base = p->index_base; SHA_CTX ctx; unsigned char sha1[20]; - unsigned long offset = 0, pack_sig = p->pack_size - 20; - int nr_objects, err, i; + off_t offset = 0, pack_sig = p->pack_size - 20; + uint32_t nr_objects, i; + int err; /* Note that the pack header checks are actually performed by * use_pack when it first opens the pack file. If anything @@ -23,7 +24,7 @@ static int verify_packfile(struct packed_git *p, unsigned char *in = use_pack(p, w_curs, offset, &remaining); offset += remaining; if (offset > pack_sig) - remaining -= offset - pack_sig; + remaining -= (unsigned int)(offset - pack_sig); SHA1_Update(&ctx, in, remaining); } SHA1_Final(sha1, &ctx); @@ -40,11 +41,12 @@ static int verify_packfile(struct packed_git *p, * we do not do scan-streaming check on the pack file. */ nr_objects = num_packed_objects(p); - for (i = err = 0; i < nr_objects; i++) { + for (i = 0, err = 0; i < nr_objects; i++) { unsigned char sha1[20]; void *data; enum object_type type; - unsigned long size, offset; + unsigned long size; + off_t offset; if (nth_packed_object_sha1(p, i, sha1)) die("internal error pack-check nth-packed-object"); @@ -74,8 +76,7 @@ static int verify_packfile(struct packed_git *p, static void show_pack_info(struct packed_git *p) { - int nr_objects, i; - unsigned int chain_histogram[MAX_CHAIN]; + uint32_t nr_objects, i, chain_histogram[MAX_CHAIN]; nr_objects = num_packed_objects(p); memset(chain_histogram, 0, sizeof(chain_histogram)); @@ -85,7 +86,7 @@ static void show_pack_info(struct packed_git *p) const char *type; unsigned long size; unsigned long store_size; - unsigned long offset; + off_t offset; unsigned int delta_chain_length; if (nth_packed_object_sha1(p, i, sha1)) @@ -99,9 +100,11 @@ static void show_pack_info(struct packed_git *p) base_sha1); printf("%s ", sha1_to_hex(sha1)); if (!delta_chain_length) - printf("%-6s %lu %lu\n", type, size, offset); + printf("%-6s %lu %"PRIuMAX"\n", + type, size, (uintmax_t)offset); else { - printf("%-6s %lu %lu %u %s\n", type, size, offset, + printf("%-6s %lu %"PRIuMAX" %u %s\n", + type, size, (uintmax_t)offset, delta_chain_length, sha1_to_hex(base_sha1)); if (delta_chain_length < MAX_CHAIN) chain_histogram[delta_chain_length]++; @@ -123,7 +126,7 @@ static void show_pack_info(struct packed_git *p) int verify_pack(struct packed_git *p, int verbose) { - unsigned long index_size = p->index_size; + off_t index_size = p->index_size; void *index_base = p->index_base; SHA_CTX ctx; unsigned char sha1[20]; @@ -132,7 +135,7 @@ int verify_pack(struct packed_git *p, int verbose) ret = 0; /* Verify SHA1 sum of the index file */ SHA1_Init(&ctx); - SHA1_Update(&ctx, index_base, index_size - 20); + SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20)); SHA1_Final(sha1, &ctx); if (hashcmp(sha1, (unsigned char *)index_base + index_size - 20)) ret = error("Packfile index for %s SHA1 mismatch", diff --git a/pack-redundant.c b/pack-redundant.c index edb5524fc4..c8f7d9af7b 100644 --- a/pack-redundant.c +++ b/pack-redundant.c @@ -396,9 +396,9 @@ static size_t get_pack_redundancy(struct pack_list *pl) return ret; } -static inline size_t pack_set_bytecount(struct pack_list *pl) +static inline off_t pack_set_bytecount(struct pack_list *pl) { - size_t ret = 0; + off_t ret = 0; while (pl) { ret += pl->pack->pack_size; ret += pl->pack->index_size; @@ -413,7 +413,7 @@ static void minimize(struct pack_list **min) *non_unique = NULL, *min_perm = NULL; struct pll *perm, *perm_all, *perm_ok = NULL, *new_perm; struct llist *missing; - size_t min_perm_size = (size_t)-1, perm_size; + off_t min_perm_size = 0, perm_size; int n; pl = local_packs; @@ -461,7 +461,7 @@ static void minimize(struct pack_list **min) perm = perm_ok; while (perm) { perm_size = pack_set_bytecount(perm->pl); - if (min_perm_size > perm_size) { + if (!min_perm_size || min_perm_size > perm_size) { min_perm_size = perm_size; min_perm = perm->pl; } @@ -252,7 +252,7 @@ char *enter_repo(char *path, int strict) if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 && validate_headref("HEAD") == 0) { - putenv("GIT_DIR=."); + setenv("GIT_DIR", ".", 1); check_repository_format(); return path; } diff --git a/perl/Makefile b/perl/Makefile index 099beda873..17d004e5a0 100644 --- a/perl/Makefile +++ b/perl/Makefile @@ -6,11 +6,15 @@ makfile:=perl.mak PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) prefix_SQ = $(subst ','\'',$(prefix)) +ifndef V + QUIET = @ +endif + all install instlibdir: $(makfile) - $(MAKE) -f $(makfile) $@ + $(QUIET)$(MAKE) -f $(makfile) $@ clean: - test -f $(makfile) && $(MAKE) -f $(makfile) $@ || exit 0 + $(QUIET)test -f $(makfile) && $(MAKE) -f $(makfile) $@ || exit 0 $(RM) ppport.h $(RM) $(makfile) $(RM) $(makfile).old diff --git a/read-cache.c b/read-cache.c index d63746476e..6339a278da 100644 --- a/read-cache.c +++ b/read-cache.c @@ -59,14 +59,14 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st) if (fd >= 0) { unsigned char sha1[20]; - if (!index_fd(sha1, fd, st, 0, NULL)) + if (!index_fd(sha1, fd, st, 0, OBJ_BLOB, ce->name)) match = hashcmp(sha1, ce->sha1); /* index_fd() closed the file descriptor already */ } return match; } -static int ce_compare_link(struct cache_entry *ce, unsigned long expected_size) +static int ce_compare_link(struct cache_entry *ce, size_t expected_size) { int match = -1; char *target; @@ -101,7 +101,7 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st) return DATA_CHANGED; break; case S_IFLNK: - if (ce_compare_link(ce, st->st_size)) + if (ce_compare_link(ce, xsize_t(st->st_size))) return DATA_CHANGED; break; default: @@ -125,7 +125,9 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) changed |= MODE_CHANGED; break; case S_IFLNK: - changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0; + if (!S_ISLNK(st->st_mode) && + (has_symlinks || !S_ISREG(st->st_mode))) + changed |= TYPE_CHANGED; break; default: die("internal error: ce_mode is %o", ntohl(ce->ce_mode)); @@ -344,11 +346,11 @@ int add_file_to_index(const char *path, int verbose) ce->ce_flags = htons(namelen); fill_stat_cache_info(ce, &st); - if (trust_executable_bit) + if (trust_executable_bit && has_symlinks) ce->ce_mode = create_ce_mode(st.st_mode); else { - /* If there is an existing entry, pick the mode bits - * from it, otherwise assume unexecutable. + /* If there is an existing entry, pick the mode bits and type + * from it, otherwise assume unexecutable regular file. */ struct cache_entry *ent; int pos = cache_name_pos(path, namelen); @@ -795,7 +797,7 @@ int read_cache_from(const char *path) } if (!fstat(fd, &st)) { - cache_mmap_size = st.st_size; + cache_mmap_size = xsize_t(st.st_size); errno = EINVAL; if (cache_mmap_size >= sizeof(struct cache_header) + 20) cache_mmap = xmmap(NULL, cache_mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); diff --git a/receive-pack.c b/receive-pack.c index 7f1dcc045c..7cf58782e3 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -67,18 +67,11 @@ struct command { static struct command *commands; -static char update_hook[] = "hooks/update"; +static const char pre_receive_hook[] = "hooks/pre-receive"; +static const char post_receive_hook[] = "hooks/post-receive"; -static int run_update_hook(const char *refname, - char *old_hex, char *new_hex) +static int hook_status(int code, const char *hook_name) { - int code; - - if (access(update_hook, X_OK) < 0) - return 0; - code = run_command_opt(RUN_COMMAND_NO_STDIN - | RUN_COMMAND_STDOUT_TO_STDERR, - update_hook, refname, old_hex, new_hex, NULL); switch (code) { case 0: return 0; @@ -86,42 +79,101 @@ static int run_update_hook(const char *refname, return error("hook fork failed"); case -ERR_RUN_COMMAND_EXEC: return error("hook execute failed"); + case -ERR_RUN_COMMAND_PIPE: + return error("hook pipe failed"); case -ERR_RUN_COMMAND_WAITPID: return error("waitpid failed"); case -ERR_RUN_COMMAND_WAITPID_WRONG_PID: return error("waitpid is confused"); case -ERR_RUN_COMMAND_WAITPID_SIGNAL: - return error("%s died of signal", update_hook); + return error("%s died of signal", hook_name); case -ERR_RUN_COMMAND_WAITPID_NOEXIT: - return error("%s died strangely", update_hook); + return error("%s died strangely", hook_name); default: - error("%s exited with error code %d", update_hook, -code); + error("%s exited with error code %d", hook_name, -code); return -code; } } -static int update(struct command *cmd) +static int run_hook(const char *hook_name) +{ + static char buf[sizeof(commands->old_sha1) * 2 + PATH_MAX + 4]; + struct command *cmd; + struct child_process proc; + const char *argv[2]; + int have_input = 0, code; + + for (cmd = commands; !have_input && cmd; cmd = cmd->next) { + if (!cmd->error_string) + have_input = 1; + } + + if (!have_input || access(hook_name, X_OK) < 0) + return 0; + + argv[0] = hook_name; + argv[1] = NULL; + + memset(&proc, 0, sizeof(proc)); + proc.argv = argv; + proc.in = -1; + proc.stdout_to_stderr = 1; + + code = start_command(&proc); + if (code) + return hook_status(code, hook_name); + for (cmd = commands; cmd; cmd = cmd->next) { + if (!cmd->error_string) { + size_t n = snprintf(buf, sizeof(buf), "%s %s %s\n", + sha1_to_hex(cmd->old_sha1), + sha1_to_hex(cmd->new_sha1), + cmd->ref_name); + if (write_in_full(proc.in, buf, n) != n) + break; + } + } + return hook_status(finish_command(&proc), hook_name); +} + +static int run_update_hook(struct command *cmd) +{ + static const char update_hook[] = "hooks/update"; + struct child_process proc; + const char *argv[5]; + + if (access(update_hook, X_OK) < 0) + return 0; + + argv[0] = update_hook; + argv[1] = cmd->ref_name; + argv[2] = sha1_to_hex(cmd->old_sha1); + argv[3] = sha1_to_hex(cmd->new_sha1); + argv[4] = NULL; + + memset(&proc, 0, sizeof(proc)); + proc.argv = argv; + proc.no_stdin = 1; + proc.stdout_to_stderr = 1; + + return hook_status(run_command(&proc), update_hook); +} + +static const char *update(struct command *cmd) { const char *name = cmd->ref_name; unsigned char *old_sha1 = cmd->old_sha1; unsigned char *new_sha1 = cmd->new_sha1; - char new_hex[41], old_hex[41]; struct ref_lock *lock; - cmd->error_string = NULL; if (!prefixcmp(name, "refs/") && check_ref_format(name + 5)) { - cmd->error_string = "funny refname"; - return error("refusing to create funny ref '%s' locally", - name); + error("refusing to create funny ref '%s' locally", name); + return "funny refname"; } - strcpy(new_hex, sha1_to_hex(new_sha1)); - strcpy(old_hex, sha1_to_hex(old_sha1)); - if (!is_null_sha1(new_sha1) && !has_sha1_file(new_sha1)) { - cmd->error_string = "bad pack"; - return error("unpack should have generated %s, " - "but I can't find it!", new_hex); + error("unpack should have generated %s, " + "but I can't find it!", sha1_to_hex(new_sha1)); + return "bad pack"; } if (deny_non_fast_forwards && !is_null_sha1(new_sha1) && !is_null_sha1(old_sha1) && @@ -136,32 +188,39 @@ static int update(struct command *cmd) if (!hashcmp(old_sha1, ent->item->object.sha1)) break; free_commit_list(bases); - if (!ent) - return error("denying non-fast forward;" - " you should pull first"); + if (!ent) { + error("denying non-fast forward %s" + " (you should pull first)", name); + return "non-fast forward"; + } } - if (run_update_hook(name, old_hex, new_hex)) { - cmd->error_string = "hook declined"; - return error("hook declined to update %s", name); + if (run_update_hook(cmd)) { + error("hook declined to update %s", name); + return "hook declined"; } if (is_null_sha1(new_sha1)) { if (delete_ref(name, old_sha1)) { - cmd->error_string = "failed to delete"; - return error("failed to delete %s", name); + error("failed to delete %s", name); + return "failed to delete"; } - fprintf(stderr, "%s: %s -> deleted\n", name, old_hex); + fprintf(stderr, "%s: %s -> deleted\n", name, + sha1_to_hex(old_sha1)); + return NULL; /* good */ } else { lock = lock_any_ref_for_update(name, old_sha1); if (!lock) { - cmd->error_string = "failed to lock"; - return error("failed to lock %s", name); + error("failed to lock %s", name); + return "failed to lock"; + } + if (write_ref_sha1(lock, new_sha1, "push")) { + return "failed to write"; /* error() already called */ } - write_ref_sha1(lock, new_sha1, "push"); - fprintf(stderr, "%s: %s -> %s\n", name, old_hex, new_hex); + fprintf(stderr, "%s: %s -> %s\n", name, + sha1_to_hex(old_sha1), sha1_to_hex(new_sha1)); + return NULL; /* good */ } - return 0; } static char update_post_hook[] = "hooks/post-update"; @@ -172,14 +231,14 @@ static void run_update_post_hook(struct command *cmd) int argc; const char **argv; - if (access(update_post_hook, X_OK) < 0) - return; - for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) { + for (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) { if (cmd_p->error_string) continue; argc++; } - argv = xmalloc(sizeof(*argv) * (1 + argc)); + if (!argc || access(update_post_hook, X_OK) < 0) + return; + argv = xmalloc(sizeof(*argv) * (2 + argc)); argv[0] = update_post_hook; for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) { @@ -196,19 +255,30 @@ static void run_update_post_hook(struct command *cmd) | RUN_COMMAND_STDOUT_TO_STDERR); } -/* - * This gets called after(if) we've successfully - * unpacked the data payload. - */ -static void execute_commands(void) +static void execute_commands(const char *unpacker_error) { struct command *cmd = commands; + if (unpacker_error) { + while (cmd) { + cmd->error_string = "n/a (unpacker error)"; + cmd = cmd->next; + } + return; + } + + if (run_hook(pre_receive_hook)) { + while (cmd) { + cmd->error_string = "pre-receive hook declined"; + cmd = cmd->next; + } + return; + } + while (cmd) { - update(cmd); + cmd->error_string = update(cmd); cmd = cmd->next; } - run_update_post_hook(commands); } static void read_head_info(void) @@ -244,7 +314,7 @@ static void read_head_info(void) hashcpy(cmd->old_sha1, old_sha1); hashcpy(cmd->new_sha1, new_sha1); memcpy(cmd->ref_name, line + 82, len - 81); - cmd->error_string = "n/a (unpacker error)"; + cmd->error_string = NULL; cmd->next = NULL; *p = cmd; p = &cmd->next; @@ -447,12 +517,13 @@ int main(int argc, char **argv) if (!delete_only(commands)) unpack_status = unpack(); - if (!unpack_status) - execute_commands(); + execute_commands(unpack_status); if (pack_lockfile) unlink(pack_lockfile); if (report_status) report(unpack_status); + run_hook(post_receive_hook); + run_update_post_hook(commands); } return 0; } @@ -921,6 +921,8 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1, log_file, strerror(errno)); } + adjust_shared_perm(log_file); + msglen = 0; if (msg) { /* clean up the message and make sure it is a single line */ @@ -1042,7 +1044,9 @@ int create_symref(const char *ref_target, const char *refs_heads_master, return -1; } +#ifndef NO_SYMLINK_HEAD done: +#endif if (logmsg && !read_ref(refs_heads_master, new_sha1)) log_ref_write(ref_target, old_sha1, new_sha1, logmsg); @@ -1073,6 +1077,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * unsigned long date; unsigned char logged_sha1[20]; void *log_mapped; + size_t mapsz; logfile = git_path("logs/%s", ref); logfd = open(logfile, O_RDONLY, 0); @@ -1081,7 +1086,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); - log_mapped = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, logfd, 0); + mapsz = xsize_t(st.st_size); + log_mapped = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, logfd, 0); logdata = log_mapped; close(logfd); @@ -1134,7 +1140,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * logfile, show_rfc2822_date(date, tz)); } } - munmap(log_mapped, st.st_size); + munmap(log_mapped, mapsz); return 0; } lastrec = rec; @@ -1153,7 +1159,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char * die("Log %s is corrupt.", logfile); if (msg) *msg = ref_msg(logdata, logend); - munmap(log_mapped, st.st_size); + munmap(log_mapped, mapsz); if (cutoff_time) *cutoff_time = date; diff --git a/revision.c b/revision.c index 4cf697e2c1..3c2eb125e6 100644 --- a/revision.c +++ b/revision.c @@ -116,6 +116,8 @@ void mark_parents_uninteresting(struct commit *commit) void add_pending_object(struct rev_info *revs, struct object *obj, const char *name) { + if (revs->no_walk && (obj->flags & UNINTERESTING)) + die("object ranges do not make sense when not walking revisions"); add_object_array(obj, name, &revs->pending); if (revs->reflog_info && obj->type == OBJ_COMMIT) add_reflog_for_walk(revs->reflog_info, @@ -435,36 +437,6 @@ static void limit_list(struct rev_info *revs) continue; p = &commit_list_insert(commit, p)->next; } - if (revs->boundary) { - /* mark the ones that are on the result list first */ - for (list = newlist; list; list = list->next) { - struct commit *commit = list->item; - commit->object.flags |= TMP_MARK; - } - for (list = newlist; list; list = list->next) { - struct commit *commit = list->item; - struct object *obj = &commit->object; - struct commit_list *parent; - if (obj->flags & UNINTERESTING) - continue; - for (parent = commit->parents; - parent; - parent = parent->next) { - struct commit *pcommit = parent->item; - if (!(pcommit->object.flags & UNINTERESTING)) - continue; - pcommit->object.flags |= BOUNDARY; - if (pcommit->object.flags & TMP_MARK) - continue; - pcommit->object.flags |= TMP_MARK; - p = &commit_list_insert(pcommit, p)->next; - } - } - for (list = newlist; list; list = list->next) { - struct commit *commit = list->item; - commit->object.flags &= ~TMP_MARK; - } - } revs->commits = newlist; } @@ -480,7 +452,7 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, struct all_refs_cb *cb = cb_data; struct object *object = get_reference(cb->all_revs, path, sha1, cb->all_flags); - add_pending_object(cb->all_revs, object, ""); + add_pending_object(cb->all_revs, object, path); return 0; } @@ -1191,17 +1163,6 @@ static void rewrite_parents(struct rev_info *revs, struct commit *commit) } } -static void mark_boundary_to_show(struct commit *commit) -{ - struct commit_list *p = commit->parents; - while (p) { - commit = p->item; - p = p->next; - if (commit->object.flags & BOUNDARY) - commit->object.flags |= BOUNDARY_SHOW; - } -} - static int commit_match(struct commit *commit, struct rev_info *opt) { if (!opt->grep_filter) @@ -1233,15 +1194,9 @@ static struct commit *get_revision_1(struct rev_info *revs) */ if (!revs->limited) { if (revs->max_age != -1 && - (commit->date < revs->max_age)) { - if (revs->boundary) - commit->object.flags |= - BOUNDARY_SHOW | BOUNDARY; - else - continue; - } else - add_parents_to_list(revs, commit, - &revs->commits); + (commit->date < revs->max_age)) + continue; + add_parents_to_list(revs, commit, &revs->commits); } if (commit->object.flags & SHOWN) continue; @@ -1250,18 +1205,6 @@ static struct commit *get_revision_1(struct rev_info *revs) revs->ignore_packed)) continue; - /* We want to show boundary commits only when their - * children are shown. When path-limiter is in effect, - * rewrite_parents() drops some commits from getting shown, - * and there is no point showing boundary parents that - * are not shown. After rewrite_parents() rewrites the - * parents of a commit that is shown, we mark the boundary - * parents with BOUNDARY_SHOW. - */ - if (commit->object.flags & BOUNDARY_SHOW) { - commit->object.flags |= SHOWN; - return commit; - } if (commit->object.flags & UNINTERESTING) continue; if (revs->min_age != -1 && (commit->date > revs->min_age)) @@ -1284,80 +1227,136 @@ static struct commit *get_revision_1(struct rev_info *revs) if (revs->parents) rewrite_parents(revs, commit); } - if (revs->boundary) - mark_boundary_to_show(commit); - commit->object.flags |= SHOWN; return commit; } while (revs->commits); return NULL; } +static void gc_boundary(struct object_array *array) +{ + unsigned nr = array->nr; + unsigned alloc = array->alloc; + struct object_array_entry *objects = array->objects; + + if (alloc <= nr) { + unsigned i, j; + for (i = j = 0; i < nr; i++) { + if (objects[i].item->flags & SHOWN) + continue; + if (i != j) + objects[j] = objects[i]; + j++; + } + for (i = j; i < nr; i++) + objects[i].item = NULL; + array->nr = j; + } +} + struct commit *get_revision(struct rev_info *revs) { struct commit *c = NULL; + struct commit_list *l; + + if (revs->boundary == 2) { + unsigned i; + struct object_array *array = &revs->boundary_commits; + struct object_array_entry *objects = array->objects; + for (i = 0; i < array->nr; i++) { + c = (struct commit *)(objects[i].item); + if (!c) + continue; + if (!(c->object.flags & CHILD_SHOWN)) + continue; + if (!(c->object.flags & SHOWN)) + break; + } + if (array->nr <= i) + return NULL; - if (revs->reverse) { - struct commit_list *list; + c->object.flags |= SHOWN | BOUNDARY; + return c; + } - /* - * rev_info.reverse is used to note the fact that we - * want to output the list of revisions in reverse - * order. To accomplish this goal, reverse can have - * different values: - * - * 0 do nothing - * 1 reverse the list - * 2 internal use: we have already obtained and - * reversed the list, now we only need to yield - * its items. - */ + if (revs->reverse) { + int limit = -1; - if (revs->reverse == 1) { - revs->reverse = 0; - list = NULL; - while ((c = get_revision(revs))) - commit_list_insert(c, &list); - revs->commits = list; - revs->reverse = 2; + if (0 <= revs->max_count) { + limit = revs->max_count; + if (0 < revs->skip_count) + limit += revs->skip_count; } - - if (!revs->commits) - return NULL; - c = revs->commits->item; - list = revs->commits->next; - free(revs->commits); - revs->commits = list; - return c; + l = NULL; + while ((c = get_revision_1(revs))) { + commit_list_insert(c, &l); + if ((0 < limit) && !--limit) + break; + } + revs->commits = l; + revs->reverse = 0; + revs->max_count = -1; + c = NULL; } - if (0 < revs->skip_count) { - while ((c = get_revision_1(revs)) != NULL) { - if (revs->skip_count-- <= 0) + /* + * Now pick up what they want to give us + */ + c = get_revision_1(revs); + if (c) { + while (0 < revs->skip_count) { + revs->skip_count--; + c = get_revision_1(revs); + if (!c) break; } } - /* Check the max_count ... */ + /* + * Check the max_count. + */ switch (revs->max_count) { case -1: break; case 0: - if (revs->boundary) { - struct commit_list *list = revs->commits; - while (list) { - list->item->object.flags |= - BOUNDARY_SHOW | BOUNDARY; - list = list->next; - } - /* all remaining commits are boundary commits */ - revs->max_count = -1; - revs->limited = 1; - } else - return NULL; + c = NULL; + break; default: revs->max_count--; } + if (c) + c->object.flags |= SHOWN; + + if (!revs->boundary) { return c; - return get_revision_1(revs); + } + + if (!c) { + /* + * get_revision_1() runs out the commits, and + * we are done computing the boundaries. + * switch to boundary commits output mode. + */ + revs->boundary = 2; + return get_revision(revs); + } + + /* + * boundary commits are the commits that are parents of the + * ones we got from get_revision_1() but they themselves are + * not returned from get_revision_1(). Before returning + * 'c', we need to mark its parents that they could be boundaries. + */ + + for (l = c->parents; l; l = l->next) { + struct object *p; + p = &(l->item->object); + if (p->flags & (CHILD_SHOWN | SHOWN)) + continue; + p->flags |= CHILD_SHOWN; + gc_boundary(&revs->boundary_commits); + add_object_array(p, NULL, &revs->boundary_commits); + } + + return c; } diff --git a/revision.h b/revision.h index 5fec1846f3..6ae39e6bec 100644 --- a/revision.h +++ b/revision.h @@ -7,7 +7,7 @@ #define SHOWN (1u<<3) #define TMP_MARK (1u<<4) /* for isolated cases; clean after use */ #define BOUNDARY (1u<<5) -#define BOUNDARY_SHOW (1u<<6) +#define CHILD_SHOWN (1u<<6) #define ADDED (1u<<7) /* Parents already parsed and added? */ #define SYMMETRIC_LEFT (1u<<8) @@ -21,6 +21,9 @@ struct rev_info { struct commit_list *commits; struct object_array pending; + /* Parents of shown commits */ + struct object_array boundary_commits; + /* Basic information */ const char *prefix; void *prune_data; @@ -40,10 +43,10 @@ struct rev_info { edge_hint:1, limited:1, unpacked:1, /* see also ignore_packed below */ - boundary:1, + boundary:2, left_right:1, parents:1, - reverse:2; + reverse:1; /* Diff flags */ unsigned int diff:1, @@ -74,6 +77,7 @@ struct rev_info { const char *add_signoff; const char *extra_headers; const char *log_reencode; + int no_inline; /* Filter by commit log message */ struct grep_opt *grep_filter; diff --git a/run-command.c b/run-command.c index cfbad74d14..bef9775e08 100644 --- a/run-command.c +++ b/run-command.c @@ -2,30 +2,70 @@ #include "run-command.h" #include "exec_cmd.h" -int run_command_v_opt(const char **argv, int flags) +static inline void close_pair(int fd[2]) { - pid_t pid = fork(); + close(fd[0]); + close(fd[1]); +} + +int start_command(struct child_process *cmd) +{ + int need_in = !cmd->no_stdin && cmd->in < 0; + int fdin[2]; - if (pid < 0) + if (need_in) { + if (pipe(fdin) < 0) + return -ERR_RUN_COMMAND_PIPE; + cmd->in = fdin[1]; + cmd->close_in = 1; + } + + cmd->pid = fork(); + if (cmd->pid < 0) { + if (need_in) + close_pair(fdin); return -ERR_RUN_COMMAND_FORK; - if (!pid) { - if (flags & RUN_COMMAND_NO_STDIN) { + } + + if (!cmd->pid) { + if (cmd->no_stdin) { int fd = open("/dev/null", O_RDWR); dup2(fd, 0); close(fd); + } else if (need_in) { + dup2(fdin[0], 0); + close_pair(fdin); + } else if (cmd->in) { + dup2(cmd->in, 0); + close(cmd->in); } - if (flags & RUN_COMMAND_STDOUT_TO_STDERR) + + if (cmd->stdout_to_stderr) dup2(2, 1); - if (flags & RUN_GIT_CMD) { - execv_git_cmd(argv); + if (cmd->git_cmd) { + execv_git_cmd(cmd->argv); } else { - execvp(argv[0], (char *const*) argv); + execvp(cmd->argv[0], (char *const*) cmd->argv); } - die("exec %s failed.", argv[0]); + die("exec %s failed.", cmd->argv[0]); } + + if (need_in) + close(fdin[0]); + else if (cmd->in) + close(cmd->in); + + return 0; +} + +int finish_command(struct child_process *cmd) +{ + if (cmd->close_in) + close(cmd->in); + for (;;) { int status, code; - pid_t waiting = waitpid(pid, &status, 0); + pid_t waiting = waitpid(cmd->pid, &status, 0); if (waiting < 0) { if (errno == EINTR) @@ -33,7 +73,7 @@ int run_command_v_opt(const char **argv, int flags) error("waitpid failed (%s)", strerror(errno)); return -ERR_RUN_COMMAND_WAITPID; } - if (waiting != pid) + if (waiting != cmd->pid) return -ERR_RUN_COMMAND_WAITPID_WRONG_PID; if (WIFSIGNALED(status)) return -ERR_RUN_COMMAND_WAITPID_SIGNAL; @@ -47,47 +87,21 @@ int run_command_v_opt(const char **argv, int flags) } } -int run_command_v(const char **argv) -{ - return run_command_v_opt(argv, 0); -} - -static int run_command_va_opt(int opt, const char *cmd, va_list param) -{ - int argc; - const char *argv[MAX_RUN_COMMAND_ARGS]; - const char *arg; - - argv[0] = (char*) cmd; - argc = 1; - while (argc < MAX_RUN_COMMAND_ARGS) { - arg = argv[argc++] = va_arg(param, char *); - if (!arg) - break; - } - if (MAX_RUN_COMMAND_ARGS <= argc) - return error("too many args to run %s", cmd); - return run_command_v_opt(argv, opt); -} - -int run_command_opt(int opt, const char *cmd, ...) +int run_command(struct child_process *cmd) { - va_list params; - int r; - - va_start(params, cmd); - r = run_command_va_opt(opt, cmd, params); - va_end(params); - return r; + int code = start_command(cmd); + if (code) + return code; + return finish_command(cmd); } -int run_command(const char *cmd, ...) +int run_command_v_opt(const char **argv, int opt) { - va_list params; - int r; - - va_start(params, cmd); - r = run_command_va_opt(0, cmd, params); - va_end(params); - return r; + struct child_process cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.argv = argv; + cmd.no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0; + cmd.git_cmd = opt & RUN_GIT_CMD ? 1 : 0; + cmd.stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0; + return run_command(&cmd); } diff --git a/run-command.h b/run-command.h index 59c4476ced..ff090679a6 100644 --- a/run-command.h +++ b/run-command.h @@ -1,22 +1,33 @@ #ifndef RUN_COMMAND_H #define RUN_COMMAND_H -#define MAX_RUN_COMMAND_ARGS 256 enum { ERR_RUN_COMMAND_FORK = 10000, ERR_RUN_COMMAND_EXEC, + ERR_RUN_COMMAND_PIPE, ERR_RUN_COMMAND_WAITPID, ERR_RUN_COMMAND_WAITPID_WRONG_PID, ERR_RUN_COMMAND_WAITPID_SIGNAL, ERR_RUN_COMMAND_WAITPID_NOEXIT, }; +struct child_process { + const char **argv; + pid_t pid; + int in; + unsigned close_in:1; + unsigned no_stdin:1; + unsigned git_cmd:1; /* if this is to be git sub-command */ + unsigned stdout_to_stderr:1; +}; + +int start_command(struct child_process *); +int finish_command(struct child_process *); +int run_command(struct child_process *); + #define RUN_COMMAND_NO_STDIN 1 #define RUN_GIT_CMD 2 /*If this is to be git sub-command */ #define RUN_COMMAND_STDOUT_TO_STDERR 4 int run_command_v_opt(const char **argv, int opt); -int run_command_v(const char **argv); -int run_command_opt(int opt, const char *cmd, ...); -int run_command(const char *cmd, ...); #endif @@ -216,7 +216,7 @@ const char *setup_git_directory_gently(int *nongit_ok) die("Not a git repository: '%s'", gitdirenv); } - if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/') + if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/') die("Unable to read current working directory"); offset = len = strlen(cwd); diff --git a/sha1_file.c b/sha1_file.c index 3831614734..7faa8bcd50 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -349,6 +349,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep, static void read_info_alternates(const char * relative_base, int depth) { char *map; + size_t mapsz; struct stat st; char path[PATH_MAX]; int fd; @@ -361,12 +362,13 @@ static void read_info_alternates(const char * relative_base, int depth) close(fd); return; } - map = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + mapsz = xsize_t(st.st_size); + map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - link_alt_odb_entries(map, map + st.st_size, '\n', relative_base, depth); + link_alt_odb_entries(map, map + mapsz, '\n', relative_base, depth); - munmap(map, st.st_size); + munmap(map, mapsz); } void prepare_alt_odb(void) @@ -430,13 +432,14 @@ void pack_report() pack_mapped, peak_pack_mapped); } -static int check_packed_git_idx(const char *path, unsigned long *idx_size_, - void **idx_map_) +static int check_packed_git_idx(const char *path, + unsigned long *idx_size_, + void **idx_map_) { void *idx_map; uint32_t *index; - unsigned long idx_size; - int nr, i; + size_t idx_size; + uint32_t nr, i; int fd = open(path, O_RDONLY); struct stat st; if (fd < 0) @@ -445,7 +448,11 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_, close(fd); return -1; } - idx_size = st.st_size; + idx_size = xsize_t(st.st_size); + if (idx_size < 4 * 256 + 20 + 20) { + close(fd); + return error("index file %s is too small", path); + } idx_map = xmmap(NULL, idx_size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); @@ -453,25 +460,25 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_, *idx_map_ = idx_map; *idx_size_ = idx_size; - /* check index map */ - if (idx_size < 4*256 + 20 + 20) - 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)) + if (index[0] == htonl(PACK_IDX_SIGNATURE)) { + munmap(idx_map, idx_size); 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) + uint32_t n = ntohl(index[i]); + if (n < nr) { + munmap(idx_map, idx_size); return error("non-monotonic index %s", path); + } nr = n; } @@ -482,8 +489,10 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_, * - 20-byte SHA1 of the packfile * - 20-byte SHA1 file checksum */ - if (idx_size != 4*256 + nr * 24 + 20 + 20) + if (idx_size != 4*256 + nr * 24 + 20 + 20) { + munmap(idx_map, idx_size); return error("wrong index file size in %s", path); + } return 0; } @@ -622,7 +631,7 @@ static int open_packed_git(struct packed_git *p) return -1; } -static int in_window(struct pack_window *win, unsigned long offset) +static int in_window(struct pack_window *win, off_t offset) { /* We must promise at least 20 bytes (one hash) after the * offset is available from this window, otherwise the offset @@ -637,7 +646,7 @@ static int in_window(struct pack_window *win, unsigned long offset) unsigned char* use_pack(struct packed_git *p, struct pack_window **w_cursor, - unsigned long offset, + off_t offset, unsigned int *left) { struct pack_window *win = *w_cursor; @@ -662,11 +671,13 @@ unsigned char* use_pack(struct packed_git *p, } if (!win) { size_t window_align = packed_git_window_size / 2; + off_t len; win = xcalloc(1, sizeof(*win)); win->offset = (offset / window_align) * window_align; - win->len = p->pack_size - win->offset; - if (win->len > packed_git_window_size) - win->len = packed_git_window_size; + len = p->pack_size - win->offset; + if (len > packed_git_window_size) + len = packed_git_window_size; + win->len = (size_t)len; pack_mapped += win->len; while (packed_git_limit < pack_mapped && unuse_one_window(p)) @@ -695,7 +706,7 @@ unsigned char* use_pack(struct packed_git *p, } offset -= win->offset; if (left) - *left = win->len - offset; + *left = win->len - xsize_t(offset); return win->base + offset; } @@ -871,9 +882,9 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size) */ sha1_file_open_flag = 0; } - map = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + *size = xsize_t(st.st_size); + map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - *size = st.st_size; return map; } @@ -956,11 +967,12 @@ static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned lon return 0; } -static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size) +static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size, const unsigned char *sha1) { int bytes = strlen(buffer) + 1; unsigned char *buf = xmalloc(1+size); unsigned long n; + int status = Z_OK; n = stream->total_out - bytes; if (n > size) @@ -970,12 +982,22 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size if (bytes < size) { stream->next_out = buf + bytes; stream->avail_out = size - bytes; - while (inflate(stream, Z_FINISH) == Z_OK) - /* nothing */; + while (status == Z_OK) + status = inflate(stream, Z_FINISH); } buf[size] = 0; - inflateEnd(stream); - return buf; + if ((status == Z_OK || status == Z_STREAM_END) && !stream->avail_in) { + inflateEnd(stream); + return buf; + } + + if (status < 0) + error("corrupt loose object '%s'", sha1_to_hex(sha1)); + else if (stream->avail_in) + error("garbage at end of loose object '%s'", + sha1_to_hex(sha1)); + free(buf); + return NULL; } /* @@ -1029,7 +1051,7 @@ static int parse_sha1_header(const char *hdr, unsigned long *sizep) return *hdr ? -1 : type_from_string(type); } -void * unpack_sha1_file(void *map, unsigned long mapsize, enum object_type *type, unsigned long *size) +static void *unpack_sha1_file(void *map, unsigned long mapsize, enum object_type *type, unsigned long *size, const unsigned char *sha1) { int ret; z_stream stream; @@ -1039,17 +1061,17 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, enum object_type *type if (ret < Z_OK || (*type = parse_sha1_header(hdr, size)) < 0) return NULL; - return unpack_sha1_rest(&stream, hdr, *size); + return unpack_sha1_rest(&stream, hdr, *size, sha1); } -static unsigned long get_delta_base(struct packed_git *p, +static off_t get_delta_base(struct packed_git *p, struct pack_window **w_curs, - unsigned long *curpos, + off_t *curpos, enum object_type type, - unsigned long delta_obj_offset) + off_t delta_obj_offset) { unsigned char *base_info = use_pack(p, w_curs, *curpos, NULL); - unsigned long base_offset; + off_t base_offset; /* use_pack() assured us we have [base_info, base_info + 20) * as a range that we can look at without walking off the @@ -1085,17 +1107,17 @@ static unsigned long get_delta_base(struct packed_git *p, } /* forward declaration for a mutually recursive function */ -static int packed_object_info(struct packed_git *p, unsigned long offset, +static int packed_object_info(struct packed_git *p, off_t offset, unsigned long *sizep); static int packed_delta_info(struct packed_git *p, struct pack_window **w_curs, - unsigned long curpos, + off_t curpos, enum object_type type, - unsigned long obj_offset, + off_t obj_offset, unsigned long *sizep) { - unsigned long base_offset; + off_t base_offset; base_offset = get_delta_base(p, w_curs, &curpos, type, obj_offset); type = packed_object_info(p, base_offset, NULL); @@ -1145,7 +1167,7 @@ static int packed_delta_info(struct packed_git *p, static int unpack_object_header(struct packed_git *p, struct pack_window **w_curs, - unsigned long *curpos, + off_t *curpos, unsigned long *sizep) { unsigned char *base; @@ -1169,14 +1191,15 @@ static int unpack_object_header(struct packed_git *p, } const char *packed_object_info_detail(struct packed_git *p, - unsigned long obj_offset, + off_t obj_offset, unsigned long *size, unsigned long *store_size, unsigned int *delta_chain_length, unsigned char *base_sha1) { struct pack_window *w_curs = NULL; - unsigned long curpos, dummy; + off_t curpos; + unsigned long dummy; unsigned char *next_sha1; enum object_type type; @@ -1200,6 +1223,7 @@ const char *packed_object_info_detail(struct packed_git *p, obj_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset); if (*delta_chain_length == 0) { /* TODO: find base_sha1 as pointed by curpos */ + hashclr(base_sha1); } break; case OBJ_REF_DELTA: @@ -1215,11 +1239,12 @@ const char *packed_object_info_detail(struct packed_git *p, } } -static int packed_object_info(struct packed_git *p, unsigned long obj_offset, +static int packed_object_info(struct packed_git *p, off_t obj_offset, unsigned long *sizep) { struct pack_window *w_curs = NULL; - unsigned long size, curpos = obj_offset; + unsigned long size; + off_t curpos = obj_offset; enum object_type type; type = unpack_object_header(p, &w_curs, &curpos, &size); @@ -1247,7 +1272,7 @@ static int packed_object_info(struct packed_git *p, unsigned long obj_offset, static void *unpack_compressed_entry(struct packed_git *p, struct pack_window **w_curs, - unsigned long curpos, + off_t curpos, unsigned long size) { int st; @@ -1278,20 +1303,22 @@ static void *unpack_compressed_entry(struct packed_git *p, static void *unpack_delta_entry(struct packed_git *p, struct pack_window **w_curs, - unsigned long curpos, + off_t curpos, unsigned long delta_size, - unsigned long obj_offset, + off_t obj_offset, enum object_type *type, unsigned long *sizep) { void *delta_data, *result, *base; - unsigned long base_size, base_offset; + unsigned long base_size; + off_t base_offset; base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset); base = unpack_entry(p, base_offset, type, &base_size); if (!base) - die("failed to read delta base object at %lu from %s", - base_offset, p->pack_name); + die("failed to read delta base object" + " at %"PRIuMAX" from %s", + (uintmax_t)base_offset, p->pack_name); delta_data = unpack_compressed_entry(p, w_curs, curpos, delta_size); result = patch_delta(base, base_size, @@ -1304,11 +1331,11 @@ static void *unpack_delta_entry(struct packed_git *p, return result; } -void *unpack_entry(struct packed_git *p, unsigned long obj_offset, +void *unpack_entry(struct packed_git *p, off_t obj_offset, enum object_type *type, unsigned long *sizep) { struct pack_window *w_curs = NULL; - unsigned long curpos = obj_offset; + off_t curpos = obj_offset; void *data; *type = unpack_object_header(p, &w_curs, &curpos, sizep); @@ -1331,23 +1358,23 @@ void *unpack_entry(struct packed_git *p, unsigned long obj_offset, return data; } -int num_packed_objects(const struct packed_git *p) +uint32_t num_packed_objects(const struct packed_git *p) { /* See check_packed_git_idx() */ - return (p->index_size - 20 - 20 - 4*256) / 24; + return (uint32_t)((p->index_size - 20 - 20 - 4*256) / 24); } -int nth_packed_object_sha1(const struct packed_git *p, int n, +int nth_packed_object_sha1(const struct packed_git *p, uint32_t n, unsigned char* sha1) { void *index = p->index_base + 256; - if (n < 0 || num_packed_objects(p) <= n) + if (num_packed_objects(p) <= n) return -1; hashcpy(sha1, (unsigned char *) index + (24 * n) + 4); return 0; } -unsigned long find_pack_entry_one(const unsigned char *sha1, +off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *p) { uint32_t *level1_ofs = p->index_base; @@ -1389,7 +1416,7 @@ static int matches_pack_name(struct packed_git *p, const char *ig) static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed) { struct packed_git *p; - unsigned long offset; + off_t offset; prepare_packed_git(); @@ -1555,7 +1582,7 @@ void *read_sha1_file(const unsigned char *sha1, enum object_type *type, return buf; map = map_sha1_file(sha1, &mapsize); if (map) { - buf = unpack_sha1_file(map, mapsize, type, size); + buf = unpack_sha1_file(map, mapsize, type, size, sha1); munmap(map, mapsize); return buf; } @@ -2053,27 +2080,27 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object) return ret; } -int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, const char *type) +int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, + enum object_type type, const char *path) { - unsigned long size = st->st_size; - void *buf; + size_t size = xsize_t(st->st_size); + void *buf = NULL; int ret, re_allocated = 0; - buf = ""; if (size) buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); if (!type) - type = blob_type; + type = OBJ_BLOB; /* * Convert blobs to git internal format */ - if (!strcmp(type, blob_type)) { + if ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) { unsigned long nsize = size; char *nbuf = buf; - if (convert_to_git(NULL, &nbuf, &nsize)) { + if (convert_to_git(path, &nbuf, &nsize)) { if (size) munmap(buf, size); size = nsize; @@ -2083,9 +2110,9 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, con } if (write_object) - ret = write_sha1_file(buf, size, type, sha1); + ret = write_sha1_file(buf, size, typename(type), sha1); else - ret = hash_sha1_file(buf, size, type, sha1); + ret = hash_sha1_file(buf, size, typename(type), sha1); if (re_allocated) { free(buf); return ret; @@ -2099,6 +2126,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write { int fd; char *target; + size_t len; switch (st->st_mode & S_IFMT) { case S_IFREG: @@ -2106,21 +2134,22 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write if (fd < 0) return error("open(\"%s\"): %s", path, strerror(errno)); - if (index_fd(sha1, fd, st, write_object, NULL) < 0) + if (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0) return error("%s: failed to insert into database", path); break; case S_IFLNK: - target = xmalloc(st->st_size+1); - if (readlink(path, target, st->st_size+1) != st->st_size) { + len = xsize_t(st->st_size); + target = xmalloc(len + 1); + if (readlink(path, target, len + 1) != st->st_size) { char *errstr = strerror(errno); free(target); return error("readlink(\"%s\"): %s", path, errstr); } if (!write_object) - hash_sha1_file(target, st->st_size, blob_type, sha1); - else if (write_sha1_file(target, st->st_size, blob_type, sha1)) + hash_sha1_file(target, len, blob_type, sha1); + else if (write_sha1_file(target, len, blob_type, sha1)) return error("%s: failed to insert into database", path); free(target); diff --git a/sha1_name.c b/sha1_name.c index a7efa96f35..bede0e5b06 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -76,10 +76,10 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne prepare_packed_git(); for (p = packed_git; p && found < 2; p = p->next) { - unsigned num = num_packed_objects(p); - unsigned first = 0, last = num; + uint32_t num = num_packed_objects(p); + uint32_t first = 0, last = num; while (first < last) { - unsigned mid = (first + last) / 2; + uint32_t mid = (first + last) / 2; unsigned char now[20]; int cmp; @@ -577,6 +577,66 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1) return get_short_sha1(name, len, sha1, 0); } +static int handle_one_ref(const char *path, + const unsigned char *sha1, int flag, void *cb_data) +{ + struct commit_list **list = cb_data; + struct object *object = parse_object(sha1); + if (!object) + return 0; + if (object->type == OBJ_TAG) + object = deref_tag(object, path, strlen(path)); + if (object->type != OBJ_COMMIT) + return 0; + insert_by_date((struct commit *)object, list); + return 0; +} + +/* + * This interprets names like ':/Initial revision of "git"' by searching + * through history and returning the first commit whose message starts + * with the given string. + * + * For future extension, ':/!' is reserved. If you want to match a message + * beginning with a '!', you have to repeat the exclamation mark. + */ + +#define ONELINE_SEEN (1u<<20) +static int get_sha1_oneline(const char *prefix, unsigned char *sha1) +{ + struct commit_list *list = NULL, *backup = NULL, *l; + int retval = -1; + + if (prefix[0] == '!') { + if (prefix[1] != '!') + die ("Invalid search pattern: %s", prefix); + prefix++; + } + if (!save_commit_buffer) + return error("Could not expand oneline-name."); + for_each_ref(handle_one_ref, &list); + for (l = list; l; l = l->next) + commit_list_insert(l->item, &backup); + while (list) { + char *p; + struct commit *commit; + + commit = pop_most_recent_commit(&list, ONELINE_SEEN); + parse_object(commit->object.sha1); + if (!commit->buffer || !(p = strstr(commit->buffer, "\n\n"))) + continue; + if (!prefixcmp(p + 2, prefix)) { + hashcpy(sha1, commit->object.sha1); + retval = 0; + break; + } + } + free_commit_list(list); + for (l = backup; l; l = l->next) + clear_commit_marks(l->item, ONELINE_SEEN); + return retval; +} + /* * This is like "get_sha1_basic()", except it allows "sha1 expressions", * notably "xyz^" for "parent of xyz" @@ -600,6 +660,8 @@ int get_sha1(const char *name, unsigned char *sha1) int stage = 0; struct cache_entry *ce; int pos; + if (namelen > 2 && name[1] == '/') + return get_sha1_oneline(name + 2, sha1); if (namelen < 3 || name[2] != ':' || name[1] < '0' || '3' < name[1]) diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 87403da780..cacb273aff 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -114,7 +114,8 @@ test_expect_success \ test_expect_success \ 'some edit' \ 'mv file file.orig && - sed -e "s/^3A/99/" -e "/^1A/d" < file.orig > file && + sed -e "s/^3A/99/" -e "/^1A/d" -e "/^incomplete/d" < file.orig > file && + echo "incomplete" | tr -d "\\012" >>file && GIT_AUTHOR_NAME="D" git commit -a -m "edit"' test_expect_success \ diff --git a/t/diff-lib.sh b/t/diff-lib.sh index 745a1b0311..4624fe654c 100755 --- a/t/diff-lib.sh +++ b/t/diff-lib.sh @@ -11,7 +11,7 @@ compare_diff_raw () { sed -e "$sanitize_diff_raw" <"$1" >.tmp-1 sed -e "$sanitize_diff_raw" <"$2" >.tmp-2 - diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 + git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/' @@ -23,7 +23,7 @@ compare_diff_raw_z () { tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 - diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 + git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } compare_diff_patch () { @@ -37,5 +37,5 @@ compare_diff_patch () { /^[dis]*imilarity index [0-9]*%$/d /^index [0-9a-f]*\.\.[0-9a-f]/d ' <"$2" >.tmp-2 - diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 + git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 } diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh index d0af8c3d52..e26a36cf0f 100755 --- a/t/t1000-read-tree-m-3way.sh +++ b/t/t1000-read-tree-m-3way.sh @@ -131,7 +131,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" check_result () { git-ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current && - diff -u expected current + git diff expected current } # This is done on an empty work directory, which is the normal diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index 75e4c9a886..030226bbfb 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -33,7 +33,7 @@ compare_change () { -e '/^--- /d; /^+++ /d; /^@@ /d;' \ -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \ "$1" - diff -u expected current + git diff expected current } check_cache_at () { @@ -86,7 +86,7 @@ test_expect_success \ 'rm -f .git/index && read_tree_twoway $treeH $treeM && git-ls-files --stage >1-3.out && - diff -u M.out 1-3.out && + git diff M.out 1-3.out && check_cache_at bozbar dirty && check_cache_at frotz dirty && check_cache_at nitfol dirty' @@ -101,7 +101,7 @@ test_expect_success \ git-update-index --add yomin && read_tree_twoway $treeH $treeM && git-ls-files --stage >4.out || return 1 - diff -u M.out 4.out >4diff.out + git diff M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean' @@ -115,7 +115,7 @@ test_expect_success \ echo yomin yomin >yomin && read_tree_twoway $treeH $treeM && git-ls-files --stage >5.out || return 1 - diff -u M.out 5.out >5diff.out + git diff M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty' @@ -127,7 +127,7 @@ test_expect_success \ git-update-index --add frotz && read_tree_twoway $treeH $treeM && git-ls-files --stage >6.out && - diff -u M.out 6.out && + git diff M.out 6.out && check_cache_at frotz clean' test_expect_success \ @@ -140,7 +140,7 @@ test_expect_success \ echo frotz frotz >frotz && read_tree_twoway $treeH $treeM && git-ls-files --stage >7.out && - diff -u M.out 7.out && + git diff M.out 7.out && check_cache_at frotz dirty' test_expect_success \ @@ -171,7 +171,7 @@ test_expect_success \ git-update-index --add rezrov && read_tree_twoway $treeH $treeM && git-ls-files --stage >10.out && - diff -u M.out 10.out' + git diff M.out 10.out' test_expect_success \ '11 - dirty path removed.' \ @@ -216,7 +216,7 @@ test_expect_success \ git-update-index --add nitfol && read_tree_twoway $treeH $treeM && git-ls-files --stage >14.out || return 1 - diff -u M.out 14.out >14diff.out + git diff M.out 14.out >14diff.out compare_change 14diff.out expected && check_cache_at nitfol clean' @@ -230,7 +230,7 @@ test_expect_success \ echo nitfol nitfol nitfol >nitfol && read_tree_twoway $treeH $treeM && git-ls-files --stage >15.out || return 1 - diff -u M.out 15.out >15diff.out + git diff M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty' @@ -262,7 +262,7 @@ test_expect_success \ git-update-index --add bozbar && read_tree_twoway $treeH $treeM && git-ls-files --stage >18.out && - diff -u M.out 18.out && + git diff M.out 18.out && check_cache_at bozbar clean' test_expect_success \ @@ -275,7 +275,7 @@ test_expect_success \ echo gnusto gnusto >bozbar && read_tree_twoway $treeH $treeM && git-ls-files --stage >19.out && - diff -u M.out 19.out && + git diff M.out 19.out && check_cache_at bozbar dirty' test_expect_success \ @@ -287,7 +287,7 @@ test_expect_success \ git-update-index --add bozbar && read_tree_twoway $treeH $treeM && git-ls-files --stage >20.out && - diff -u M.out 20.out && + git diff M.out 20.out && check_cache_at bozbar dirty' test_expect_success \ @@ -337,7 +337,7 @@ test_expect_success \ git-update-index --add DF && read_tree_twoway $treeDF $treeDFDF && git-ls-files --stage >DFDFcheck.out && - diff -u DFDF.out DFDFcheck.out && + git diff DFDF.out DFDFcheck.out && check_cache_at DF/DF dirty && :' diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh index da3c81357b..87fe993f59 100755 --- a/t/t1002-read-tree-m-u-2way.sh +++ b/t/t1002-read-tree-m-u-2way.sh @@ -16,7 +16,7 @@ compare_change () { sed >current \ -e '/^--- /d; /^+++ /d; /^@@ /d;' \ -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1" - diff -u expected current + git diff expected current } check_cache_at () { diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 49b5666b33..78c2e0864f 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -368,12 +368,12 @@ cat > expect << EOF weird EOF -test_expect_success "rename succeeded" "diff -u expect .git/config" +test_expect_success "rename succeeded" "git diff expect .git/config" test_expect_failure "rename non-existing section" \ 'git-config --rename-section branch."world domination" branch.drei' -test_expect_success "rename succeeded" "diff -u expect .git/config" +test_expect_success "rename succeeded" "git diff expect .git/config" test_expect_success "rename another section" \ 'git-config --rename-section branch."1 234 blabl/a" branch.drei' @@ -389,7 +389,23 @@ cat > expect << EOF weird EOF -test_expect_success "rename succeeded" "diff -u expect .git/config" +test_expect_success "rename succeeded" "git diff expect .git/config" + +cat >> .git/config << EOF + [branch "zwei"] a = 1 [branch "vier"] +EOF + +test_expect_success "remove section" "git config --remove-section branch.zwei" + +cat > expect << EOF +# Hallo + #Bello +[branch "drei"] +weird +EOF + +test_expect_success "section was removed properly" \ + "git diff -u expect .git/config" test_expect_success numbers ' diff --git a/t/t2005-checkout-index-symlinks.sh b/t/t2005-checkout-index-symlinks.sh new file mode 100755 index 0000000000..e34a515333 --- /dev/null +++ b/t/t2005-checkout-index-symlinks.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes Sixt +# + +test_description='git-checkout-index on filesystem w/o symlinks test. + +This tests that git-checkout-index creates a symbolic link as a plain +file if core.symlinks is false.' + +. ./test-lib.sh + +test_expect_success \ +'preparation' ' +git-config core.symlinks false && +l=$(echo -n file | git-hash-object -t blob -w --stdin) && +echo "120000 $l symlink" | git-update-index --index-info' + +test_expect_success \ +'the checked-out symlink must be a file' ' +git-checkout-index symlink && +test -f symlink' + +test_expect_success \ +'the file must be the blob we added during the setup' ' +test "$(git-hash-object -t blob symlink)" = $l' + +test_done diff --git a/t/t2102-update-index-symlinks.sh b/t/t2102-update-index-symlinks.sh new file mode 100755 index 0000000000..969ef891d3 --- /dev/null +++ b/t/t2102-update-index-symlinks.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes Sixt +# + +test_description='git-update-index on filesystem w/o symlinks test. + +This tests that git-update-index keeps the symbolic link property +even if a plain file is in the working tree if core.symlinks is false.' + +. ./test-lib.sh + +test_expect_success \ +'preparation' ' +git-config core.symlinks false && +l=$(echo -n file | git-hash-object -t blob -w --stdin) && +echo "120000 $l symlink" | git-update-index --index-info' + +test_expect_success \ +'modify the symbolic link' ' +echo -n new-file > symlink && +git-update-index symlink' + +test_expect_success \ +'the index entry must still be a symbolic link' ' +case "`git-ls-files --stage --cached symlink`" in +120000" "*symlink) echo ok;; +*) echo fail; git-ls-files --stage --cached symlink; (exit 1);; +esac' + +test_done diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 6979b7c1c0..db7a847a5d 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -65,7 +65,7 @@ test_expect_success \ --exclude-per-directory=.gitignore \ --exclude-from=.git/ignore \ >output && - diff -u expect output' + git diff expect output' # Test \r\n (MSDOS-like systems) printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore @@ -77,6 +77,6 @@ test_expect_success \ --exclude-per-directory=.gitignore \ --exclude-from=.git/ignore \ >output && - diff -u expect output' + git diff expect output' test_done diff --git a/t/t3002-ls-files-dashpath.sh b/t/t3002-ls-files-dashpath.sh index b42f1382bc..cc8967d76b 100755 --- a/t/t3002-ls-files-dashpath.sh +++ b/t/t3002-ls-files-dashpath.sh @@ -23,7 +23,7 @@ test_expect_success \ test_expect_success \ 'git-ls-files without path restriction.' \ 'git-ls-files --others >output && - diff -u output - <<EOF + git diff output - <<EOF -- -foo output @@ -34,7 +34,7 @@ EOF test_expect_success \ 'git-ls-files with path restriction.' \ 'git-ls-files --others path0 >output && - diff -u output - <<EOF + git diff output - <<EOF path0 EOF ' @@ -42,7 +42,7 @@ EOF test_expect_success \ 'git-ls-files with path restriction with --.' \ 'git-ls-files --others -- path0 >output && - diff -u output - <<EOF + git diff output - <<EOF path0 EOF ' @@ -50,7 +50,7 @@ EOF test_expect_success \ 'git-ls-files with path restriction with -- --.' \ 'git-ls-files --others -- -- >output && - diff -u output - <<EOF + git diff output - <<EOF -- EOF ' @@ -58,7 +58,7 @@ EOF test_expect_success \ 'git-ls-files with no path restriction.' \ 'git-ls-files --others -- >output && - diff -u output - <<EOF + git diff output - <<EOF -- -foo output diff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh index 2ec06d3d39..e10749245b 100755 --- a/t/t3100-ls-tree-restrict.sh +++ b/t/t3100-ls-tree-restrict.sh @@ -35,7 +35,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" test_output () { sed -e "s/ $_x40 / X /" <current >check - diff -u expected check + git diff expected check } test_expect_success \ diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh index d78deb1e71..087929a4bf 100755 --- a/t/t3101-ls-tree-dirname.sh +++ b/t/t3101-ls-tree-dirname.sh @@ -43,7 +43,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" test_output () { sed -e "s/ $_x40 / X /" <current >check - diff -u expected check + git diff expected check } test_expect_success \ diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 5565c27033..75c000a968 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -47,17 +47,6 @@ test_expect_success \ test ! -f .git/refs/heads/d/e/f && test ! -f .git/logs/refs/heads/d/e/f' -cat >expect <<EOF -0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master -EOF -test_expect_success \ - 'git checkout -b g/h/i -l should create a branch and a log' \ - 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ - git-checkout -b g/h/i -l master && - test -f .git/refs/heads/g/h/i && - test -f .git/logs/refs/heads/g/h/i && - diff expect .git/logs/refs/heads/g/h/i' - test_expect_success \ 'git branch j/k should work after branch j has been deleted' \ 'git-branch j && @@ -117,4 +106,58 @@ test_expect_failure \ ln -s real-u .git/logs/refs/heads/u && git-branch -m u v' +test_expect_success 'test tracking setup via --track' \ + 'git-config remote.local.url . && + git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git-show-ref -q refs/remotes/local/master || git-fetch local) && + git-branch --track my1 local/master && + test $(git-config branch.my1.remote) = local && + test $(git-config branch.my1.merge) = refs/heads/master' + +test_expect_success 'test tracking setup (non-wildcard, matching)' \ + 'git-config remote.local.url . && + git-config remote.local.fetch refs/heads/master:refs/remotes/local/master && + (git-show-ref -q refs/remotes/local/master || git-fetch local) && + git-branch --track my4 local/master && + test $(git-config branch.my4.remote) = local && + test $(git-config branch.my4.merge) = refs/heads/master' + +test_expect_success 'test tracking setup (non-wildcard, not matching)' \ + 'git-config remote.local.url . && + git-config remote.local.fetch refs/heads/s:refs/remotes/local/s && + (git-show-ref -q refs/remotes/local/master || git-fetch local) && + git-branch --track my5 local/master && + ! test $(git-config branch.my5.remote) = local && + ! test $(git-config branch.my5.merge) = refs/heads/master' + +test_expect_success 'test tracking setup via config' \ + 'git-config branch.autosetupmerge true && + git-config remote.local.url . && + git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git-show-ref -q refs/remotes/local/master || git-fetch local) && + git-branch my3 local/master && + test $(git-config branch.my3.remote) = local && + test $(git-config branch.my3.merge) = refs/heads/master' + +test_expect_success 'test overriding tracking setup via --no-track' \ + 'git-config branch.autosetupmerge true && + git-config remote.local.url . && + git-config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git-show-ref -q refs/remotes/local/master || git-fetch local) && + git-branch --no-track my2 local/master && + ! test $(git-config branch.my2.remote) = local && + ! test $(git-config branch.my2.merge) = refs/heads/master' + +# Keep this test last, as it changes the current branch +cat >expect <<EOF +0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master +EOF +test_expect_success \ + 'git checkout -b g/h/i -l should create a branch and a log' \ + 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ + git-checkout -b g/h/i -l master && + test -f .git/refs/heads/g/h/i && + test -f .git/logs/refs/heads/g/h/i && + diff expect .git/logs/refs/heads/g/h/i' + test_done diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index c12270efab..b5a1400e18 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -35,7 +35,7 @@ no-funny' >expected test_expect_success 'git-ls-files no-funny' \ 'git-update-index --add "$p0" "$p2" && git-ls-files >current && - diff -u expected current' + git diff expected current' t0=`git-write-tree` echo "$t0" >t0 @@ -48,14 +48,14 @@ EOF test_expect_success 'git-ls-files with-funny' \ 'git-update-index --add "$p1" && git-ls-files >current && - diff -u expected current' + git diff expected current' echo 'just space no-funny tabs ," (dq) and spaces' >expected test_expect_success 'git-ls-files -z with-funny' \ 'git-ls-files -z | tr \\0 \\012 >current && - diff -u expected current' + git diff expected current' t1=`git-write-tree` echo "$t1" >t1 @@ -67,28 +67,28 @@ no-funny EOF test_expect_success 'git-ls-tree with funny' \ 'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && - diff -u expected current' + git diff expected current' cat > expected <<\EOF A "tabs\t,\" (dq) and spaces" EOF test_expect_success 'git-diff-index with-funny' \ 'git-diff-index --name-status $t0 >current && - diff -u expected current' + git diff expected current' test_expect_success 'git-diff-tree with-funny' \ 'git-diff-tree --name-status $t0 $t1 >current && - diff -u expected current' + git diff expected current' echo 'A tabs ," (dq) and spaces' >expected test_expect_success 'git-diff-index -z with-funny' \ 'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current && - diff -u expected current' + git diff expected current' test_expect_success 'git-diff-tree -z with-funny' \ 'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current && - diff -u expected current' + git diff expected current' cat > expected <<\EOF CNUM no-funny "tabs\t,\" (dq) and spaces" @@ -96,7 +96,7 @@ EOF test_expect_success 'git-diff-tree -C with-funny' \ 'git-diff-tree -C --find-copies-harder --name-status \ $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current && - diff -u expected current' + git diff expected current' cat > expected <<\EOF RNUM no-funny "tabs\t,\" (dq) and spaces" @@ -105,7 +105,7 @@ test_expect_success 'git-diff-tree delete with-funny' \ 'git-update-index --force-remove "$p0" && git-diff-index -M --name-status \ $t0 | sed -e 's/^R[0-9]*/RNUM/' >current && - diff -u expected current' + git diff expected current' cat > expected <<\EOF diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" @@ -116,7 +116,7 @@ EOF test_expect_success 'git-diff-tree delete with-funny' \ 'git-diff-index -M -p $t0 | sed -e "s/index [0-9]*%/index NUM%/" >current && - diff -u expected current' + git diff expected current' chmod +x "$p1" cat > expected <<\EOF @@ -130,7 +130,7 @@ EOF test_expect_success 'git-diff-tree delete with-funny' \ 'git-diff-index -M -p $t0 | sed -e "s/index [0-9]*%/index NUM%/" >current && - diff -u expected current' + git diff expected current' cat >expected <<\EOF "tabs\t,\" (dq) and spaces" @@ -139,7 +139,7 @@ EOF test_expect_success 'git-diff-tree rename with-funny applied' \ 'git-diff-index -M -p $t0 | git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && - diff -u expected current' + git diff expected current' cat > expected <<\EOF no-funny @@ -149,12 +149,12 @@ EOF test_expect_success 'git-diff-tree delete with-funny applied' \ 'git-diff-index -p $t0 | git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && - diff -u expected current' + git diff expected current' test_expect_success 'git-apply non-git diff' \ 'git-diff-index -p $t0 | sed -ne "/^[-+@]/p" | git-apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && - diff -u expected current' + git diff expected current' test_done diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index e54fe0f401..ffddb68db3 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -9,7 +9,7 @@ test_description='commit and log output encodings' compare_with () { git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current && - diff -u current "$2" + git diff current "$2" } test_expect_success setup ' diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh index ca342f48a1..e72c6fd1b4 100755 --- a/t/t4006-diff-mode.sh +++ b/t/t4006-diff-mode.sh @@ -38,7 +38,7 @@ echo ":100644 100755 X X M rezrov" >expected test_expect_success \ 'verify' \ - 'diff -u expected check' + 'git diff expected check' test_done diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 3d85ceaae9..488e075c16 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -106,12 +106,12 @@ do echo "\$ git $cmd" git $cmd | sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \ - -e "s/^\\( *boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/" + -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/" echo "\$" } >"$actual" && if test -f "$expect" then - diff -u "$expect" "$actual" && + git diff "$expect" "$actual" && rm -f "$actual" else # this is to help developing new tests. @@ -238,6 +238,9 @@ format-patch --stdout initial..master format-patch --attach --stdout initial..side format-patch --attach --stdout initial..master^ format-patch --attach --stdout initial..master +format-patch --inline --stdout initial..side +format-patch --inline --stdout initial..master^ +format-patch --inline --stdout initial..master diff --abbrev initial..side diff -r initial..side diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master b/t/t4013/diff.format-patch_--attach_--stdout_initial..master index e5ddd6fcbb..cf6891f748 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master @@ -4,8 +4,7 @@ From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:01:00 +0000 Subject: [PATCH] Second MIME-Version: 1.0 -Content-Type: multipart/mixed; - boundary="------------g-i-t--v-e-r-s-i-o-n" +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" This is a multi-part message in MIME format. --------------g-i-t--v-e-r-s-i-o-n @@ -21,11 +20,9 @@ This is the second commit. 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" +Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Transfer-Encoding: 8bit -Content-Disposition: inline; - filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" +Content-Disposition: attachment; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" diff --git a/dir/sub b/dir/sub index 35d242b..8422d40 100644 @@ -66,8 +63,7 @@ From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 Subject: [PATCH] Third MIME-Version: 1.0 -Content-Type: multipart/mixed; - boundary="------------g-i-t--v-e-r-s-i-o-n" +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" This is a multi-part message in MIME format. --------------g-i-t--v-e-r-s-i-o-n @@ -80,11 +76,9 @@ Content-Transfer-Encoding: 8bit 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" +Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Transfer-Encoding: 8bit -Content-Disposition: inline; - filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" +Content-Disposition: attachment; filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" diff --git a/dir/sub b/dir/sub index 8422d40..cead32e 100644 @@ -115,8 +109,7 @@ From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:03:00 +0000 Subject: [PATCH] Side MIME-Version: 1.0 -Content-Type: multipart/mixed; - boundary="------------g-i-t--v-e-r-s-i-o-n" +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" This is a multi-part message in MIME format. --------------g-i-t--v-e-r-s-i-o-n @@ -130,11 +123,9 @@ Content-Transfer-Encoding: 8bit 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" +Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Transfer-Encoding: 8bit -Content-Disposition: inline; - filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" +Content-Disposition: attachment; filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" diff --git a/dir/sub b/dir/sub index 35d242b..7289e35 100644 diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ index d0dd19b623..fe0258720c 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ @@ -4,8 +4,7 @@ From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:01:00 +0000 Subject: [PATCH] Second MIME-Version: 1.0 -Content-Type: multipart/mixed; - boundary="------------g-i-t--v-e-r-s-i-o-n" +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" This is a multi-part message in MIME format. --------------g-i-t--v-e-r-s-i-o-n @@ -21,11 +20,9 @@ This is the second commit. 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" +Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" Content-Transfer-Encoding: 8bit -Content-Disposition: inline; - filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" +Content-Disposition: attachment; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" diff --git a/dir/sub b/dir/sub index 35d242b..8422d40 100644 @@ -66,8 +63,7 @@ From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:02:00 +0000 Subject: [PATCH] Third MIME-Version: 1.0 -Content-Type: multipart/mixed; - boundary="------------g-i-t--v-e-r-s-i-o-n" +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" This is a multi-part message in MIME format. --------------g-i-t--v-e-r-s-i-o-n @@ -80,11 +76,9 @@ Content-Transfer-Encoding: 8bit 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" +Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" Content-Transfer-Encoding: 8bit -Content-Disposition: inline; - filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" +Content-Disposition: attachment; filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" diff --git a/dir/sub b/dir/sub index 8422d40..cead32e 100644 diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..side b/t/t4013/diff.format-patch_--attach_--stdout_initial..side index 67a95c5cba..9ff828ee9d 100644 --- a/t/t4013/diff.format-patch_--attach_--stdout_initial..side +++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..side @@ -4,8 +4,7 @@ From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:03:00 +0000 Subject: [PATCH] Side MIME-Version: 1.0 -Content-Type: multipart/mixed; - boundary="------------g-i-t--v-e-r-s-i-o-n" +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" This is a multi-part message in MIME format. --------------g-i-t--v-e-r-s-i-o-n @@ -19,11 +18,9 @@ Content-Transfer-Encoding: 8bit 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" +Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" Content-Transfer-Encoding: 8bit -Content-Disposition: inline; - filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" +Content-Disposition: attachment; filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" diff --git a/dir/sub b/dir/sub index 35d242b..7289e35 100644 diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master b/t/t4013/diff.format-patch_--inline_--stdout_initial..master new file mode 100644 index 0000000000..aa110c0e7f --- /dev/null +++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master @@ -0,0 +1,164 @@ +$ git format-patch --inline --stdout initial..master +From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [PATCH] Second +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + + +This is the second commit. +--- + dir/sub | 2 ++ + 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" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +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" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + +--- + dir/sub | 2 ++ + 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" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ new file mode 100644 index 0000000000..95e9ea4c59 --- /dev/null +++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ @@ -0,0 +1,106 @@ +$ git format-patch --inline --stdout initial..master^ +From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [PATCH] Second +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + + +This is the second commit. +--- + dir/sub | 2 ++ + 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" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [PATCH] Third +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +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" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..side b/t/t4013/diff.format-patch_--inline_--stdout_initial..side new file mode 100644 index 0000000000..86ae923d71 --- /dev/null +++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..side @@ -0,0 +1,59 @@ +$ git format-patch --inline --stdout initial..side +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [PATCH] Side +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + +--- + dir/sub | 2 ++ + 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" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index adf4993bac..930e209d31 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -43,13 +43,13 @@ index adf3937..6edc172 100644 EOF git-diff > out -test_expect_success "Ray's example without options" 'diff -u expect out' +test_expect_success "Ray's example without options" 'git diff expect out' git-diff -w > out -test_expect_success "Ray's example with -w" 'diff -u expect out' +test_expect_success "Ray's example with -w" 'git diff expect out' git-diff -b > out -test_expect_success "Ray's example with -b" 'diff -u expect out' +test_expect_success "Ray's example with -b" 'git diff expect out' tr 'Q' '\015' << EOF > x whitespace at beginning @@ -90,14 +90,14 @@ index d99af23..8b32fb5 100644 +CR at end EOF git-diff > out -test_expect_success 'another test, without options' 'diff -u expect out' +test_expect_success 'another test, without options' 'git diff expect out' cat << EOF > expect diff --git a/x b/x index d99af23..8b32fb5 100644 EOF git-diff -w > out -test_expect_success 'another test, with -w' 'diff -u expect out' +test_expect_success 'another test, with -w' 'git diff expect out' tr 'Q' '\015' << EOF > expect diff --git a/x b/x @@ -115,6 +115,6 @@ index d99af23..8b32fb5 100644 CR at endQ EOF git-diff -b > out -test_expect_success 'another test, with -b' 'diff -u expect out' +test_expect_success 'another test, with -b' 'git diff expect out' test_done diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh index 2e7cd5f255..5dbdc0c9fa 100755 --- a/t/t4016-diff-quote.sh +++ b/t/t4016-diff-quote.sh @@ -49,7 +49,7 @@ cat >expect <<\EOF EOF test_expect_success 'git diff --summary -M HEAD' ' git diff --summary -M HEAD >actual && - diff -u expect actual + git diff expect actual ' cat >expect <<\EOF @@ -64,7 +64,7 @@ cat >expect <<\EOF EOF test_expect_success 'git diff --stat -M HEAD' ' git diff --stat -M HEAD >actual && - diff -u expect actual + git diff expect actual ' test_done diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 6579f06b05..7b81c32e57 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -11,37 +11,37 @@ test_description='git-apply --stat --summary test. test_expect_success \ 'rename' \ 'git-apply --stat --summary <../t4100/t-apply-1.patch >current && - diff -u ../t4100/t-apply-1.expect current' + git diff ../t4100/t-apply-1.expect current' test_expect_success \ 'copy' \ 'git-apply --stat --summary <../t4100/t-apply-2.patch >current && - diff -u ../t4100/t-apply-2.expect current' + git diff ../t4100/t-apply-2.expect current' test_expect_success \ 'rewrite' \ 'git-apply --stat --summary <../t4100/t-apply-3.patch >current && - diff -u ../t4100/t-apply-3.expect current' + git diff ../t4100/t-apply-3.expect current' test_expect_success \ 'mode' \ 'git-apply --stat --summary <../t4100/t-apply-4.patch >current && - diff -u ../t4100/t-apply-4.expect current' + git diff ../t4100/t-apply-4.expect current' test_expect_success \ 'non git' \ 'git-apply --stat --summary <../t4100/t-apply-5.patch >current && - diff -u ../t4100/t-apply-5.expect current' + git diff ../t4100/t-apply-5.expect current' test_expect_success \ 'non git' \ 'git-apply --stat --summary <../t4100/t-apply-6.patch >current && - diff -u ../t4100/t-apply-6.expect current' + git diff ../t4100/t-apply-6.expect current' test_expect_success \ 'non git' \ 'git-apply --stat --summary <../t4100/t-apply-7.patch >current && - diff -u ../t4100/t-apply-7.expect current' + git diff ../t4100/t-apply-7.expect current' test_done diff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh index 2ff800c23f..a5fb3ea40e 100755 --- a/t/t4104-apply-boundary.sh +++ b/t/t4104-apply-boundary.sh @@ -90,7 +90,7 @@ do cat '"$kind-patch.$with"' (exit 1) } && - diff -u '"$kind"'-expect victim + git diff '"$kind"'-expect victim ' done done @@ -108,7 +108,7 @@ do cat '"$kind-ng.without"' (exit 1) } && - diff -u '"$kind"'-expect victim + git diff '"$kind"'-expect victim ' done diff --git a/t/t4115-apply-symlink.sh b/t/t4115-apply-symlink.sh index d5f2cfb186..b947ed83bb 100755 --- a/t/t4115-apply-symlink.sh +++ b/t/t4115-apply-symlink.sh @@ -33,7 +33,7 @@ test_expect_success 'apply symlink patch' ' git checkout side && git apply patch && git diff-files -p >patched && - diff -u patch patched + git diff patch patched ' @@ -42,7 +42,7 @@ test_expect_success 'apply --index symlink patch' ' git checkout -f side && git apply --index patch && git diff-index --cached -p HEAD >patched && - diff -u patch patched + git diff patch patched ' diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh index aa2c869e0e..2685b22630 100755 --- a/t/t4116-apply-reverse.sh +++ b/t/t4116-apply-reverse.sh @@ -42,7 +42,7 @@ test_expect_success 'apply in reverse' ' git reset --hard second && git apply --reverse --binary --index patch && git diff >diff && - diff -u /dev/null diff + git diff /dev/null diff ' diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh index b4de075a3e..91931f0e3f 100755 --- a/t/t4117-apply-reject.sh +++ b/t/t4117-apply-reject.sh @@ -54,7 +54,7 @@ test_expect_success 'apply without --reject should fail' ' exit 1 fi - diff -u file1 saved.file1 + git diff file1 saved.file1 ' test_expect_success 'apply without --reject should fail' ' @@ -65,7 +65,7 @@ test_expect_success 'apply without --reject should fail' ' exit 1 fi - diff -u file1 saved.file1 + git diff file1 saved.file1 ' test_expect_success 'apply with --reject should fail but update the file' ' @@ -79,7 +79,7 @@ test_expect_success 'apply with --reject should fail but update the file' ' exit 1 fi - diff -u file1 expected && + git diff file1 expected && cat file1.rej && @@ -105,7 +105,7 @@ test_expect_success 'apply with --reject should fail but update the file' ' echo "file1 still exists?" exit 1 } - diff -u file2 expected && + git diff file2 expected && cat file2.rej && @@ -132,7 +132,7 @@ test_expect_success 'the same test with --verbose' ' echo "file1 still exists?" exit 1 } - diff -u file2 expected && + git diff file2 expected && cat file2.rej && @@ -151,7 +151,7 @@ test_expect_success 'apply cleanly with --verbose' ' git apply --verbose patch.1 && - diff -u file1 clean + git diff file1 clean ' test_done diff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh index 7309422fe5..690a182003 100755 --- a/t/t4118-apply-empty-context.sh +++ b/t/t4118-apply-empty-context.sh @@ -37,7 +37,7 @@ test_expect_success 'apply --numstat' ' echo "0 1 file1" && echo "0 1 file2" } >expect && - diff -u expect actual + git diff expect actual ' @@ -47,8 +47,8 @@ test_expect_success 'apply --apply' ' cat file2.orig >file2 && git update-index file1 file2 && git apply --index diff.output && - diff -u file1.mods file1 && - diff -u file2.mods file2 + git diff file1.mods file1 && + git diff file2.mods file2 ' test_done diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 639d45fcec..e081b32aff 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -70,7 +70,7 @@ EOF git rerere diff > out -test_expect_success 'rerere diff' 'diff -u expect out' +test_expect_success 'rerere diff' 'git diff expect out' cat > expect << EOF a1 @@ -78,7 +78,7 @@ EOF git rerere status > out -test_expect_success 'rerere status' 'diff -u expect out' +test_expect_success 'rerere status' 'git diff expect out' test_expect_success 'commit succeeds' \ "git commit -q -a -m 'prefer first over second'" @@ -94,7 +94,7 @@ test_expect_failure 'another conflicting merge' 'git pull . first' git show first:a1 | sed 's/To die: t/To die! T/' > expect test_expect_success 'rerere kicked in' "! grep ======= a1" -test_expect_success 'rerere prefers first change' 'diff -u a1 expect' +test_expect_success 'rerere prefers first change' 'git diff a1 expect' rm $rr/postimage echo "$sha1 a1" | tr '\012' '\0' > .git/rr-cache/MERGE_RR diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 4d2b781a18..ca96918da2 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -11,7 +11,7 @@ test_expect_success 'split sample box' \ 'git-mailsplit -o. ../t5100/sample.mbox >last && last=`cat last` && echo total is $last && - test `cat last` = 6' + test `cat last` = 8' for mail in `echo 00*` do diff --git a/t/t5100/info0007 b/t/t5100/info0007 new file mode 100644 index 0000000000..49bb0fec85 --- /dev/null +++ b/t/t5100/info0007 @@ -0,0 +1,5 @@ +Author: A U Thor +Email: a.u.thor@example.com +Subject: another patch +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/info0008 b/t/t5100/info0008 new file mode 100644 index 0000000000..e8a2951383 --- /dev/null +++ b/t/t5100/info0008 @@ -0,0 +1,5 @@ +Author: Junio C Hamano +Email: junio@kernel.org +Subject: another patch +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/msg0007 b/t/t5100/msg0007 new file mode 100644 index 0000000000..71b23c0236 --- /dev/null +++ b/t/t5100/msg0007 @@ -0,0 +1,2 @@ +Here is an empty patch from A U Thor. + diff --git a/t/t5100/msg0008 b/t/t5100/msg0008 new file mode 100644 index 0000000000..a80ecb97ef --- /dev/null +++ b/t/t5100/msg0008 @@ -0,0 +1,4 @@ +>Here is an empty patch from A U Thor. + +Hey you forgot the patch! + diff --git a/t/t5100/patch0005 b/t/t5100/patch0005 index 7d24b24af8..e7d6f66608 100644 --- a/t/t5100/patch0005 +++ b/t/t5100/patch0005 @@ -61,7 +61,7 @@ diff --git a/git-cvsimport-script b/git-cvsimport-script push(@old,$fn); -- -David Kågedal +David KÃ¥gedal - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org diff --git a/t/t5100/patch0007 b/t/t5100/patch0007 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/t/t5100/patch0007 diff --git a/t/t5100/patch0008 b/t/t5100/patch0008 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/t/t5100/patch0008 diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index 86bfc27147..b80c981c16 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -386,3 +386,21 @@ index 9123cdc..918dcf8 100644 -- 1.4.0.g6f2b +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor <a.u.thor@example.com> +Date: Fri, 9 Jun 2006 00:44:16 -0700 +Subject: [PATCH] another patch + +Here is an empty patch from A U Thor. + +From nobody Mon Sep 17 00:00:00 2001 +From: Junio C Hamano <junio@kernel.org> +Date: Fri, 9 Jun 2006 00:44:16 -0700 +Subject: re: [PATCH] another patch + +From: A U Thor <a.u.thor@example.com> +Subject: [PATCH] another patch +>Here is an empty patch from A U Thor. + +Hey you forgot the patch! + diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 7d93d0d7c9..477b267599 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -108,9 +108,9 @@ test_expect_success \ cd victim && git-config receive.denyNonFastforwards true && cd .. && - git-update-ref refs/heads/master master^ && - git-send-pack --force ./victim/.git/ master && - ! diff -u .git/refs/heads/master victim/.git/refs/heads/master + git-update-ref refs/heads/master master^ || return 1 + git-send-pack --force ./victim/.git/ master && return 1 + ! git diff .git/refs/heads/master victim/.git/refs/heads/master ' test_done diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh index 0514056ca6..f1c7ff0c0a 100755 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@ -11,71 +11,126 @@ test_expect_success setup ' git-update-index --add a && tree0=$(git-write-tree) && commit0=$(echo setup | git-commit-tree $tree0) && - git-update-ref HEAD $commit0 && - git-clone ./. victim && echo We hope it works. >a && git-update-index a && tree1=$(git-write-tree) && commit1=$(echo modify | git-commit-tree $tree1 -p $commit0) && - git-update-ref HEAD $commit1 + git-update-ref refs/heads/master $commit0 && + git-update-ref refs/heads/tofail $commit1 && + git-clone ./. victim && + GIT_DIR=victim/.git git-update-ref refs/heads/tofail $commit1 && + git-update-ref refs/heads/master $commit1 && + git-update-ref refs/heads/tofail $commit0 ' +cat >victim/.git/hooks/pre-receive <<'EOF' +#!/bin/sh +printf "$@" >>$GIT_DIR/pre-receive.args +cat - >$GIT_DIR/pre-receive.stdin +echo STDOUT pre-receive +echo STDERR pre-receive >&2 +EOF +chmod u+x victim/.git/hooks/pre-receive + cat >victim/.git/hooks/update <<'EOF' #!/bin/sh -echo "$@" >$GIT_DIR/update.args +echo "$@" >>$GIT_DIR/update.args read x; printf "$x" >$GIT_DIR/update.stdin -echo STDOUT update -echo STDERR update >&2 +echo STDOUT update $1 +echo STDERR update $1 >&2 +test "$1" = refs/heads/master || exit EOF chmod u+x victim/.git/hooks/update +cat >victim/.git/hooks/post-receive <<'EOF' +#!/bin/sh +printf "$@" >>$GIT_DIR/post-receive.args +cat - >$GIT_DIR/post-receive.stdin +echo STDOUT post-receive +echo STDERR post-receive >&2 +EOF +chmod u+x victim/.git/hooks/post-receive + cat >victim/.git/hooks/post-update <<'EOF' #!/bin/sh -echo "$@" >$GIT_DIR/post-update.args +echo "$@" >>$GIT_DIR/post-update.args read x; printf "$x" >$GIT_DIR/post-update.stdin echo STDOUT post-update echo STDERR post-update >&2 EOF chmod u+x victim/.git/hooks/post-update -test_expect_success push ' - git-send-pack ./victim/.git/ master >send.out 2>send.err +test_expect_failure push ' + git-send-pack --force ./victim/.git master tofail >send.out 2>send.err +' + +test_expect_success 'updated as expected' ' + test $(GIT_DIR=victim/.git git-rev-parse master) = $commit1 && + test $(GIT_DIR=victim/.git git-rev-parse tofail) = $commit1 ' test_expect_success 'hooks ran' ' + test -f victim/.git/pre-receive.args && + test -f victim/.git/pre-receive.stdin && test -f victim/.git/update.args && test -f victim/.git/update.stdin && + test -f victim/.git/post-receive.args && + test -f victim/.git/post-receive.stdin && test -f victim/.git/post-update.args && test -f victim/.git/post-update.stdin ' +test_expect_success 'pre-receive hook input' ' + (echo $commit0 $commit1 refs/heads/master; + echo $commit1 $commit0 refs/heads/tofail + ) | git diff - victim/.git/pre-receive.stdin +' + test_expect_success 'update hook arguments' ' - echo refs/heads/master $commit0 $commit1 | - diff -u - victim/.git/update.args + (echo refs/heads/master $commit0 $commit1; + echo refs/heads/tofail $commit1 $commit0 + ) | git diff - victim/.git/update.args +' + +test_expect_success 'post-receive hook input' ' + echo $commit0 $commit1 refs/heads/master | + git diff - victim/.git/post-receive.stdin ' test_expect_success 'post-update hook arguments' ' echo refs/heads/master | - diff -u - victim/.git/post-update.args + git diff - victim/.git/post-update.args ' -test_expect_failure 'update hook stdin is /dev/null' ' - test -s victim/.git/update.stdin +test_expect_success 'all hook stdin is /dev/null' ' + ! test -s victim/.git/update.stdin && + ! test -s victim/.git/post-update.stdin ' -test_expect_failure 'post-update hook stdin is /dev/null' ' - test -s victim/.git/post-update.stdin +test_expect_success 'all *-receive hook args are empty' ' + ! test -s victim/.git/pre-receive.args && + ! test -s victim/.git/post-receive.args ' test_expect_failure 'send-pack produced no output' ' test -s send.out ' +cat <<EOF >expect +STDOUT pre-receive +STDERR pre-receive +STDOUT update refs/heads/master +STDERR update refs/heads/master +STDOUT update refs/heads/tofail +STDERR update refs/heads/tofail +STDOUT post-receive +STDERR post-receive +STDOUT post-update +STDERR post-update +EOF test_expect_success 'send-pack stderr contains hook messages' ' - grep "STDOUT update" send.err && - grep "STDERR update" send.err && - grep "STDOUT post-update" send.err && - grep "STDERR post-update" send.err + egrep ^STD send.err >actual && + git diff - actual <expect ' test_done diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 50c64856f0..426017e1d0 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -35,7 +35,9 @@ test_expect_success "clone and setup child repos" ' echo "URL: ../two/.git/" echo "Pull: refs/heads/master:refs/heads/two" echo "Pull: refs/heads/one:refs/heads/one" - } >.git/remotes/two + } >.git/remotes/two && + cd .. && + git clone . bundle ' test_expect_success "fetch test" ' @@ -81,4 +83,66 @@ test_expect_success 'fetch following tags' ' ' +test_expect_success 'create bundle 1' ' + cd "$D" && + echo >file updated again by origin && + git commit -a -m "tip" && + git bundle create bundle1 master^..master +' + +test_expect_success 'header of bundle looks right' ' + head -n 1 "$D"/bundle1 | grep "^#" && + head -n 2 "$D"/bundle1 | grep "^-[0-9a-f]\{40\} " && + head -n 3 "$D"/bundle1 | grep "^[0-9a-f]\{40\} " && + head -n 4 "$D"/bundle1 | grep "^$" +' + +test_expect_success 'create bundle 2' ' + cd "$D" && + git bundle create bundle2 master~2..master +' + +test_expect_failure 'unbundle 1' ' + cd "$D/bundle" && + git checkout -b some-branch && + git fetch "$D/bundle1" master:master +' + +test_expect_success 'bundle 1 has only 3 files ' ' + cd "$D" && + ( + while read x && test -n "$x" + do + :; + done + cat + ) <bundle1 >bundle.pack && + git index-pack bundle.pack && + verify=$(git verify-pack -v bundle.pack) && + test 4 = $(echo "$verify" | wc -l) +' + +test_expect_success 'unbundle 2' ' + cd "$D/bundle" && + git fetch ../bundle2 master:master && + test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)" +' + +test_expect_success 'bundle does not prerequisite objects' ' + cd "$D" && + touch file2 && + git add file2 && + git commit -m add.file2 file2 && + git bundle create bundle3 -1 HEAD && + ( + while read x && test -n "$x" + do + :; + done + cat + ) <bundle3 >bundle.pack && + git index-pack bundle.pack && + test 4 = $(git verify-pack -v bundle.pack | wc -l) +' + test_done diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh new file mode 100755 index 0000000000..6c9cc67508 --- /dev/null +++ b/t/t5515-fetch-merge-logic.sh @@ -0,0 +1,162 @@ +#!/bin/sh +# +# Copyright (c) 2007 Santi Béjar, based on t4013 by Junio C Hamano +# +# + +test_description='Merge logic in fetch' + +. ./test-lib.sh + +LF=' +' + +test_expect_success setup ' + GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && + GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" && + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + + echo >file original && + git add file && + git commit -a -m One && + git tag tag-one && + git tag tag-one-tree HEAD^{tree} && + git branch one && + + echo two >> file && + git commit -a -m Two && + git tag -a -m "Tag Two" tag-two && + git branch two && + + echo three >> file && + git commit -a -m Three && + git tag -a -m "Tag Three" tag-three && + git tag -a -m "Tag Three file" tag-three-file HEAD^{tree}:file && + git branch three && + + echo master >> file && + git commit -a -m Master && + git tag -a -m "Tag Master" tag-master && + + git checkout three && + + git clone . cloned && + cd cloned && + git config remote.origin.url ../.git/ && + + git config remote.config-explicit.url ../.git/ && + git config remote.config-explicit.fetch refs/heads/master:remotes/rem/master && + git config --add remote.config-explicit.fetch refs/heads/one:remotes/rem/one && + git config --add remote.config-explicit.fetch two:remotes/rem/two && + git config --add remote.config-explicit.fetch refs/heads/three:remotes/rem/three && + remotes="config-explicit" && + + git config remote.config-glob.url ../.git/ && + git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* && + remotes="$remotes config-glob" && + + mkdir -p .git/remotes && + { + echo "URL: ../.git/" + echo "Pull: refs/heads/master:remotes/rem/master" + echo "Pull: refs/heads/one:remotes/rem/one" + echo "Pull: two:remotes/rem/two" + echo "Pull: refs/heads/three:remotes/rem/three" + } >.git/remotes/remote-explicit && + remotes="$remotes remote-explicit" && + + { + echo "URL: ../.git/" + echo "Pull: refs/heads/*:refs/remotes/rem/*" + } >.git/remotes/remote-glob && + remotes="$remotes remote-glob" && + + mkdir -p .git/branches && + echo "../.git" > .git/branches/branches-default && + remotes="$remotes branches-default" && + + echo "../.git#one" > .git/branches/branches-one && + remotes="$remotes branches-one" && + + for remote in $remotes ; do + git config branch.br-$remote.remote $remote && + git config branch.br-$remote-merge.remote $remote && + git config branch.br-$remote-merge.merge refs/heads/three && + git config branch.br-$remote-octopus.remote $remote && + git config branch.br-$remote-octopus.merge refs/heads/one && + git config --add branch.br-$remote-octopus.merge two && + git config --add branch.br-$remote-octopus.merge remotes/rem/three + done +' + +# Merge logic depends on branch properties and Pull: or .fetch lines +for remote in $remotes ; do + for branch in "" "-merge" "-octopus" ; do +cat <<EOF +br-$remote$branch +br-$remote$branch $remote +EOF + done +done > tests + +# Merge logic does not depend on branch properties, +# but does depend on Pull: or fetch lines. +# Use two branches completely unrelated from the arguments, +# the clone default and one without branch properties +for branch in master br-unconfig ; do + echo $branch + for remote in $remotes ; do + echo $branch $remote + done +done >> tests + +# Merge logic does not depend on branch properties +# neither in the Pull: or .fetch config +for branch in master br-unconfig ; do + cat <<EOF +$branch ../.git +$branch ../.git one +$branch ../.git one two +$branch --tags ../.git +$branch ../.git tag tag-one tag tag-three +$branch ../.git tag tag-one-tree tag tag-three-file +$branch ../.git one tag tag-one tag tag-three-file +EOF +done >> tests + +while read cmd +do + case "$cmd" in + '' | '#'*) continue ;; + esac + test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` + cnt=`expr $test_count + 1` + pfx=`printf "%04d" $cnt` + expect="../../t5515/fetch.$test" + actual="$pfx-fetch.$test" + + test_expect_success "$cmd" ' + { + echo "# $cmd" + set x $cmd; shift + git symbolic-ref HEAD refs/heads/$1 ; shift + rm -f .git/FETCH_HEAD + rm -f .git/refs/heads/* + rm -f .git/refs/remotes/rem/* + rm -f .git/refs/tags/* + git fetch "$@" >/dev/null + cat .git/FETCH_HEAD + } >"$actual" && + if test -f "$expect" + then + git diff -u "$expect" "$actual" && + rm -f "$actual" + else + # this is to help developing new tests. + cp "$actual" "$expect" + false + fi + ' +done < tests + +test_done diff --git a/t/t5515/fetch.br-branches-default b/t/t5515/fetch.br-branches-default new file mode 100644 index 0000000000..2e0414f6c3 --- /dev/null +++ b/t/t5515/fetch.br-branches-default @@ -0,0 +1,8 @@ +# br-branches-default +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-default-merge b/t/t5515/fetch.br-branches-default-merge new file mode 100644 index 0000000000..ea65f31bde --- /dev/null +++ b/t/t5515/fetch.br-branches-default-merge @@ -0,0 +1,8 @@ +# br-branches-default-merge +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-default-merge_branches-default b/t/t5515/fetch.br-branches-default-merge_branches-default new file mode 100644 index 0000000000..7b5fa949e6 --- /dev/null +++ b/t/t5515/fetch.br-branches-default-merge_branches-default @@ -0,0 +1,8 @@ +# br-branches-default-merge branches-default +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-default-octopus b/t/t5515/fetch.br-branches-default-octopus new file mode 100644 index 0000000000..128397d737 --- /dev/null +++ b/t/t5515/fetch.br-branches-default-octopus @@ -0,0 +1,8 @@ +# br-branches-default-octopus +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-default-octopus_branches-default b/t/t5515/fetch.br-branches-default-octopus_branches-default new file mode 100644 index 0000000000..4b37cd481a --- /dev/null +++ b/t/t5515/fetch.br-branches-default-octopus_branches-default @@ -0,0 +1,8 @@ +# br-branches-default-octopus branches-default +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-default_branches-default b/t/t5515/fetch.br-branches-default_branches-default new file mode 100644 index 0000000000..4a2bf3c95c --- /dev/null +++ b/t/t5515/fetch.br-branches-default_branches-default @@ -0,0 +1,8 @@ +# br-branches-default branches-default +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-one b/t/t5515/fetch.br-branches-one new file mode 100644 index 0000000000..12ac8d20fb --- /dev/null +++ b/t/t5515/fetch.br-branches-one @@ -0,0 +1,8 @@ +# br-branches-one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-one-merge b/t/t5515/fetch.br-branches-one-merge new file mode 100644 index 0000000000..3a4e77ead5 --- /dev/null +++ b/t/t5515/fetch.br-branches-one-merge @@ -0,0 +1,8 @@ +# br-branches-one-merge +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-one-merge_branches-one b/t/t5515/fetch.br-branches-one-merge_branches-one new file mode 100644 index 0000000000..00e04b435e --- /dev/null +++ b/t/t5515/fetch.br-branches-one-merge_branches-one @@ -0,0 +1,8 @@ +# br-branches-one-merge branches-one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-one-octopus b/t/t5515/fetch.br-branches-one-octopus new file mode 100644 index 0000000000..53fe808a3b --- /dev/null +++ b/t/t5515/fetch.br-branches-one-octopus @@ -0,0 +1,8 @@ +# br-branches-one-octopus +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-one-octopus_branches-one b/t/t5515/fetch.br-branches-one-octopus_branches-one new file mode 100644 index 0000000000..41b18ff78a --- /dev/null +++ b/t/t5515/fetch.br-branches-one-octopus_branches-one @@ -0,0 +1,8 @@ +# br-branches-one-octopus branches-one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-branches-one_branches-one b/t/t5515/fetch.br-branches-one_branches-one new file mode 100644 index 0000000000..281fa09d48 --- /dev/null +++ b/t/t5515/fetch.br-branches-one_branches-one @@ -0,0 +1,8 @@ +# br-branches-one branches-one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-explicit b/t/t5515/fetch.br-config-explicit new file mode 100644 index 0000000000..e2fa9c8654 --- /dev/null +++ b/t/t5515/fetch.br-config-explicit @@ -0,0 +1,11 @@ +# br-config-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-explicit-merge b/t/t5515/fetch.br-config-explicit-merge new file mode 100644 index 0000000000..ec1a7231aa --- /dev/null +++ b/t/t5515/fetch.br-config-explicit-merge @@ -0,0 +1,11 @@ +# br-config-explicit-merge +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-explicit-merge_config-explicit b/t/t5515/fetch.br-config-explicit-merge_config-explicit new file mode 100644 index 0000000000..54f689151f --- /dev/null +++ b/t/t5515/fetch.br-config-explicit-merge_config-explicit @@ -0,0 +1,11 @@ +# br-config-explicit-merge config-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-explicit-octopus b/t/t5515/fetch.br-config-explicit-octopus new file mode 100644 index 0000000000..7011dfc181 --- /dev/null +++ b/t/t5515/fetch.br-config-explicit-octopus @@ -0,0 +1,11 @@ +# br-config-explicit-octopus +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-explicit-octopus_config-explicit b/t/t5515/fetch.br-config-explicit-octopus_config-explicit new file mode 100644 index 0000000000..bdad51f871 --- /dev/null +++ b/t/t5515/fetch.br-config-explicit-octopus_config-explicit @@ -0,0 +1,11 @@ +# br-config-explicit-octopus config-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-explicit_config-explicit b/t/t5515/fetch.br-config-explicit_config-explicit new file mode 100644 index 0000000000..1b237dde6e --- /dev/null +++ b/t/t5515/fetch.br-config-explicit_config-explicit @@ -0,0 +1,11 @@ +# br-config-explicit config-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-glob b/t/t5515/fetch.br-config-glob new file mode 100644 index 0000000000..e75ec2f72b --- /dev/null +++ b/t/t5515/fetch.br-config-glob @@ -0,0 +1,11 @@ +# br-config-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-glob-merge b/t/t5515/fetch.br-config-glob-merge new file mode 100644 index 0000000000..ce8f739a0d --- /dev/null +++ b/t/t5515/fetch.br-config-glob-merge @@ -0,0 +1,11 @@ +# br-config-glob-merge +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-glob-merge_config-glob b/t/t5515/fetch.br-config-glob-merge_config-glob new file mode 100644 index 0000000000..5817bed8f8 --- /dev/null +++ b/t/t5515/fetch.br-config-glob-merge_config-glob @@ -0,0 +1,11 @@ +# br-config-glob-merge config-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-glob-octopus b/t/t5515/fetch.br-config-glob-octopus new file mode 100644 index 0000000000..9ee213ea45 --- /dev/null +++ b/t/t5515/fetch.br-config-glob-octopus @@ -0,0 +1,11 @@ +# br-config-glob-octopus +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-glob-octopus_config-glob b/t/t5515/fetch.br-config-glob-octopus_config-glob new file mode 100644 index 0000000000..44bd0ec59f --- /dev/null +++ b/t/t5515/fetch.br-config-glob-octopus_config-glob @@ -0,0 +1,11 @@ +# br-config-glob-octopus config-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-config-glob_config-glob b/t/t5515/fetch.br-config-glob_config-glob new file mode 100644 index 0000000000..a6c20f92ce --- /dev/null +++ b/t/t5515/fetch.br-config-glob_config-glob @@ -0,0 +1,11 @@ +# br-config-glob config-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-explicit b/t/t5515/fetch.br-remote-explicit new file mode 100644 index 0000000000..83534d2ec8 --- /dev/null +++ b/t/t5515/fetch.br-remote-explicit @@ -0,0 +1,11 @@ +# br-remote-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-explicit-merge b/t/t5515/fetch.br-remote-explicit-merge new file mode 100644 index 0000000000..a9064dd65a --- /dev/null +++ b/t/t5515/fetch.br-remote-explicit-merge @@ -0,0 +1,11 @@ +# br-remote-explicit-merge +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-explicit-merge_remote-explicit b/t/t5515/fetch.br-remote-explicit-merge_remote-explicit new file mode 100644 index 0000000000..732a37e4d3 --- /dev/null +++ b/t/t5515/fetch.br-remote-explicit-merge_remote-explicit @@ -0,0 +1,11 @@ +# br-remote-explicit-merge remote-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-explicit-octopus b/t/t5515/fetch.br-remote-explicit-octopus new file mode 100644 index 0000000000..ecf020d929 --- /dev/null +++ b/t/t5515/fetch.br-remote-explicit-octopus @@ -0,0 +1,11 @@ +# br-remote-explicit-octopus +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit b/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit new file mode 100644 index 0000000000..af77531011 --- /dev/null +++ b/t/t5515/fetch.br-remote-explicit-octopus_remote-explicit @@ -0,0 +1,11 @@ +# br-remote-explicit-octopus remote-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-explicit_remote-explicit b/t/t5515/fetch.br-remote-explicit_remote-explicit new file mode 100644 index 0000000000..51fae567c8 --- /dev/null +++ b/t/t5515/fetch.br-remote-explicit_remote-explicit @@ -0,0 +1,11 @@ +# br-remote-explicit remote-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-glob b/t/t5515/fetch.br-remote-glob new file mode 100644 index 0000000000..94e6ad31e3 --- /dev/null +++ b/t/t5515/fetch.br-remote-glob @@ -0,0 +1,11 @@ +# br-remote-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-glob-merge b/t/t5515/fetch.br-remote-glob-merge new file mode 100644 index 0000000000..09362e25af --- /dev/null +++ b/t/t5515/fetch.br-remote-glob-merge @@ -0,0 +1,11 @@ +# br-remote-glob-merge +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-glob-merge_remote-glob b/t/t5515/fetch.br-remote-glob-merge_remote-glob new file mode 100644 index 0000000000..e2eabec62e --- /dev/null +++ b/t/t5515/fetch.br-remote-glob-merge_remote-glob @@ -0,0 +1,11 @@ +# br-remote-glob-merge remote-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-glob-octopus b/t/t5515/fetch.br-remote-glob-octopus new file mode 100644 index 0000000000..c1554f8f2d --- /dev/null +++ b/t/t5515/fetch.br-remote-glob-octopus @@ -0,0 +1,11 @@ +# br-remote-glob-octopus +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-glob-octopus_remote-glob b/t/t5515/fetch.br-remote-glob-octopus_remote-glob new file mode 100644 index 0000000000..e6134345b8 --- /dev/null +++ b/t/t5515/fetch.br-remote-glob-octopus_remote-glob @@ -0,0 +1,11 @@ +# br-remote-glob-octopus remote-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-remote-glob_remote-glob b/t/t5515/fetch.br-remote-glob_remote-glob new file mode 100644 index 0000000000..646dbc8770 --- /dev/null +++ b/t/t5515/fetch.br-remote-glob_remote-glob @@ -0,0 +1,11 @@ +# br-remote-glob remote-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig b/t/t5515/fetch.br-unconfig new file mode 100644 index 0000000000..65ce6d99e2 --- /dev/null +++ b/t/t5515/fetch.br-unconfig @@ -0,0 +1,11 @@ +# br-unconfig +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_--tags_.._.git b/t/t5515/fetch.br-unconfig_--tags_.._.git new file mode 100644 index 0000000000..8258c80868 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_--tags_.._.git @@ -0,0 +1,7 @@ +# br-unconfig --tags ../.git +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_.._.git b/t/t5515/fetch.br-unconfig_.._.git new file mode 100644 index 0000000000..284bb1fb61 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_.._.git @@ -0,0 +1,2 @@ +# br-unconfig ../.git +0567da4d5edd2ff4bb292a465ba9e64dcad9536b ../ diff --git a/t/t5515/fetch.br-unconfig_.._.git_one b/t/t5515/fetch.br-unconfig_.._.git_one new file mode 100644 index 0000000000..11eb5a6ef2 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_.._.git_one @@ -0,0 +1,2 @@ +# br-unconfig ../.git one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ diff --git a/t/t5515/fetch.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file b/t/t5515/fetch.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file new file mode 100644 index 0000000000..f02bab2fb4 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file @@ -0,0 +1,8 @@ +# br-unconfig ../.git one tag tag-one tag tag-three-file +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 tag 'tag-one' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_.._.git_one_two b/t/t5515/fetch.br-unconfig_.._.git_one_two new file mode 100644 index 0000000000..3f1be224b8 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_.._.git_one_two @@ -0,0 +1,3 @@ +# br-unconfig ../.git one two +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 branch 'two' of ../ diff --git a/t/t5515/fetch.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file b/t/t5515/fetch.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file new file mode 100644 index 0000000000..85de41109e --- /dev/null +++ b/t/t5515/fetch.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file @@ -0,0 +1,7 @@ +# br-unconfig ../.git tag tag-one-tree tag tag-three-file +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_.._.git_tag_tag-one_tag_tag-three b/t/t5515/fetch.br-unconfig_.._.git_tag_tag-one_tag_tag-three new file mode 100644 index 0000000000..0da2337f1b --- /dev/null +++ b/t/t5515/fetch.br-unconfig_.._.git_tag_tag-one_tag_tag-three @@ -0,0 +1,7 @@ +# br-unconfig ../.git tag tag-one tag tag-three +8e32a6d901327a23ef831511badce7bf3bf46689 tag 'tag-one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b tag 'tag-three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_branches-default b/t/t5515/fetch.br-unconfig_branches-default new file mode 100644 index 0000000000..fc7041eefc --- /dev/null +++ b/t/t5515/fetch.br-unconfig_branches-default @@ -0,0 +1,8 @@ +# br-unconfig branches-default +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_branches-one b/t/t5515/fetch.br-unconfig_branches-one new file mode 100644 index 0000000000..e94cde745b --- /dev/null +++ b/t/t5515/fetch.br-unconfig_branches-one @@ -0,0 +1,8 @@ +# br-unconfig branches-one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_config-explicit b/t/t5515/fetch.br-unconfig_config-explicit new file mode 100644 index 0000000000..01a283e70d --- /dev/null +++ b/t/t5515/fetch.br-unconfig_config-explicit @@ -0,0 +1,11 @@ +# br-unconfig config-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_config-glob b/t/t5515/fetch.br-unconfig_config-glob new file mode 100644 index 0000000000..3a556c5e96 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_config-glob @@ -0,0 +1,11 @@ +# br-unconfig config-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_remote-explicit b/t/t5515/fetch.br-unconfig_remote-explicit new file mode 100644 index 0000000000..db216dfa56 --- /dev/null +++ b/t/t5515/fetch.br-unconfig_remote-explicit @@ -0,0 +1,11 @@ +# br-unconfig remote-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.br-unconfig_remote-glob b/t/t5515/fetch.br-unconfig_remote-glob new file mode 100644 index 0000000000..aee65c204d --- /dev/null +++ b/t/t5515/fetch.br-unconfig_remote-glob @@ -0,0 +1,11 @@ +# br-unconfig remote-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master b/t/t5515/fetch.master new file mode 100644 index 0000000000..950fd078db --- /dev/null +++ b/t/t5515/fetch.master @@ -0,0 +1,11 @@ +# master +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_--tags_.._.git b/t/t5515/fetch.master_--tags_.._.git new file mode 100644 index 0000000000..0e59950c7b --- /dev/null +++ b/t/t5515/fetch.master_--tags_.._.git @@ -0,0 +1,7 @@ +# master --tags ../.git +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_.._.git b/t/t5515/fetch.master_.._.git new file mode 100644 index 0000000000..66d1aaddae --- /dev/null +++ b/t/t5515/fetch.master_.._.git @@ -0,0 +1,2 @@ +# master ../.git +0567da4d5edd2ff4bb292a465ba9e64dcad9536b ../ diff --git a/t/t5515/fetch.master_.._.git_one b/t/t5515/fetch.master_.._.git_one new file mode 100644 index 0000000000..35deddbd2c --- /dev/null +++ b/t/t5515/fetch.master_.._.git_one @@ -0,0 +1,2 @@ +# master ../.git one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ diff --git a/t/t5515/fetch.master_.._.git_one_tag_tag-one_tag_tag-three-file b/t/t5515/fetch.master_.._.git_one_tag_tag-one_tag_tag-three-file new file mode 100644 index 0000000000..82868524ca --- /dev/null +++ b/t/t5515/fetch.master_.._.git_one_tag_tag-one_tag_tag-three-file @@ -0,0 +1,8 @@ +# master ../.git one tag tag-one tag tag-three-file +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 tag 'tag-one' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_.._.git_one_two b/t/t5515/fetch.master_.._.git_one_two new file mode 100644 index 0000000000..35ec5782c8 --- /dev/null +++ b/t/t5515/fetch.master_.._.git_one_two @@ -0,0 +1,3 @@ +# master ../.git one two +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 branch 'two' of ../ diff --git a/t/t5515/fetch.master_.._.git_tag_tag-one-tree_tag_tag-three-file b/t/t5515/fetch.master_.._.git_tag_tag-one-tree_tag_tag-three-file new file mode 100644 index 0000000000..2e133eff29 --- /dev/null +++ b/t/t5515/fetch.master_.._.git_tag_tag-one-tree_tag_tag-three-file @@ -0,0 +1,7 @@ +# master ../.git tag tag-one-tree tag tag-three-file +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_.._.git_tag_tag-one_tag_tag-three b/t/t5515/fetch.master_.._.git_tag_tag-one_tag_tag-three new file mode 100644 index 0000000000..92b18b40cc --- /dev/null +++ b/t/t5515/fetch.master_.._.git_tag_tag-one_tag_tag-three @@ -0,0 +1,7 @@ +# master ../.git tag tag-one tag tag-three +8e32a6d901327a23ef831511badce7bf3bf46689 tag 'tag-one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b tag 'tag-three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_branches-default b/t/t5515/fetch.master_branches-default new file mode 100644 index 0000000000..603d6d2331 --- /dev/null +++ b/t/t5515/fetch.master_branches-default @@ -0,0 +1,8 @@ +# master branches-default +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_branches-one b/t/t5515/fetch.master_branches-one new file mode 100644 index 0000000000..fe9bb0b798 --- /dev/null +++ b/t/t5515/fetch.master_branches-one @@ -0,0 +1,8 @@ +# master branches-one +8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_config-explicit b/t/t5515/fetch.master_config-explicit new file mode 100644 index 0000000000..4be97c7575 --- /dev/null +++ b/t/t5515/fetch.master_config-explicit @@ -0,0 +1,11 @@ +# master config-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_config-glob b/t/t5515/fetch.master_config-glob new file mode 100644 index 0000000000..cb0726ff8d --- /dev/null +++ b/t/t5515/fetch.master_config-glob @@ -0,0 +1,11 @@ +# master config-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_remote-explicit b/t/t5515/fetch.master_remote-explicit new file mode 100644 index 0000000000..44a1ca8429 --- /dev/null +++ b/t/t5515/fetch.master_remote-explicit @@ -0,0 +1,11 @@ +# master remote-explicit +754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t5515/fetch.master_remote-glob b/t/t5515/fetch.master_remote-glob new file mode 100644 index 0000000000..724e8db0a5 --- /dev/null +++ b/t/t5515/fetch.master_remote-glob @@ -0,0 +1,11 @@ +# master remote-glob +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge branch 'master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge branch 'one' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge branch 'three' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge branch 'two' of ../ +754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../ +8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../ +22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../ +0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../ +0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../ +6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../ diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index f3cd3dba4d..c76fccfb5a 100644 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -63,7 +63,7 @@ test_expect_success "merge without conflict (missing LF at EOF)" \ "git-merge-file test2.txt orig.txt new2.txt" test_expect_success "merge result added missing LF" \ - "diff -u test.txt test2.txt" + "git diff test.txt test2.txt" cp test.txt backup.txt test_expect_failure "merge with conflicts" \ @@ -86,7 +86,7 @@ non timebo mala, quoniam tu mecum es: virga tua et baculus tuus ipsa me consolata sunt. EOF -test_expect_success "expected conflict markers" "diff -u test.txt expect.txt" +test_expect_success "expected conflict markers" "git diff test.txt expect.txt" cp backup.txt test.txt test_expect_failure "merge with conflicts, using -L" \ @@ -110,7 +110,7 @@ virga tua et baculus tuus ipsa me consolata sunt. EOF test_expect_success "expected conflict markers, with -L" \ - "diff -u test.txt expect.txt" + "git diff test.txt expect.txt" sed "s/ tu / TU /" < new1.txt > new5.txt test_expect_failure "conflict in removed tail" \ @@ -132,7 +132,7 @@ virga tua et baculus tuus ipsa me consolata sunt. >>>>>>> new5.txt EOF -test_expect_success "expected conflict markers" "diff -u expect out" +test_expect_success "expected conflict markers" "git diff expect out" test_done diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh index 31b96257b4..a398556137 100644 --- a/t/t6024-recursive-merge.sh +++ b/t/t6024-recursive-merge.sh @@ -70,7 +70,7 @@ G >>>>>>> G:a1 EOF -test_expect_success "result contains a conflict" "diff -u expect a1" +test_expect_success "result contains a conflict" "git diff expect a1" git ls-files --stage > out cat > expect << EOF @@ -79,6 +79,6 @@ cat > expect << EOF 100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1 EOF -test_expect_success "virtual trees were processed" "diff -u expect out" +test_expect_success "virtual trees were processed" "git diff expect out" test_done diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh new file mode 100644 index 0000000000..3c1a6972bd --- /dev/null +++ b/t/t6025-merge-symlinks.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# +# Copyright (c) 2007 Johannes Sixt +# + +test_description='merging symlinks on filesystem w/o symlink support. + +This tests that git-merge-recursive writes merge results as plain files +if core.symlinks is false.' + +. ./test-lib.sh + +test_expect_success \ +'setup' ' +git-config core.symlinks false && +> file && +git-add file && +git-commit -m initial && +git-branch b-symlink && +git-branch b-file && +l=$(echo -n file | git-hash-object -t blob -w --stdin) && +echo "120000 $l symlink" | git-update-index --index-info && +git-commit -m master && +git-checkout b-symlink && +l=$(echo -n file-different | git-hash-object -t blob -w --stdin) && +echo "120000 $l symlink" | git-update-index --index-info && +git-commit -m b-symlink && +git-checkout b-file && +echo plain-file > symlink && +git-add symlink && +git-commit -m b-file' + +test_expect_failure \ +'merge master into b-symlink, which has a different symbolic link' ' +! git-checkout b-symlink || +git-merge master' + +test_expect_success \ +'the merge result must be a file' ' +test -f symlink' + +test_expect_failure \ +'merge master into b-file, which has a file instead of a symbolic link' ' +! (git-reset --hard && +git-checkout b-file) || +git-merge master' + +test_expect_success \ +'the merge result must be a file' ' +test -f symlink' + +test_expect_failure \ +'merge b-file, which has a file instead of a symbolic link, into master' ' +! (git-reset --hard && +git-checkout master) || +git-merge b-file' + +test_expect_success \ +'the merge result must be a file' ' +test -f symlink' + +test_done diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index ea14023616..526d7d1c44 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -79,7 +79,7 @@ test_expect_success 'merge-msg test #1' ' git fetch . left && git fmt-merge-msg <.git/FETCH_HEAD >actual && - diff -u actual expected + git diff actual expected ' cat >expected <<\EOF @@ -92,7 +92,7 @@ test_expect_success 'merge-msg test #2' ' git fetch ../trash left && git fmt-merge-msg <.git/FETCH_HEAD >actual && - diff -u actual expected + git diff actual expected ' cat >expected <<\EOF @@ -115,7 +115,7 @@ test_expect_success 'merge-msg test #3' ' git fetch . left && git fmt-merge-msg <.git/FETCH_HEAD >actual && - diff -u actual expected + git diff actual expected ' cat >expected <<\EOF @@ -145,7 +145,7 @@ test_expect_success 'merge-msg test #4' ' git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual && - diff -u actual expected + git diff actual expected ' test_expect_success 'merge-msg test #5' ' @@ -157,7 +157,7 @@ test_expect_success 'merge-msg test #5' ' git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual && - diff -u actual expected + git diff actual expected ' test_done diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 7dcfc7e7db..eb628fe075 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -169,7 +169,7 @@ test_expect_success "$name" " svn up '$SVN_TREE' && test -f '$SVN_TREE'/exec-2.sh && test ! -L '$SVN_TREE'/exec-2.sh && - diff -u help $SVN_TREE/exec-2.sh" + git diff help $SVN_TREE/exec-2.sh" if test "$have_utf8" = t then @@ -193,7 +193,7 @@ test_expect_success "$name" \ "git-svn init $svnrepo && git-svn fetch && git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && - diff -u a b" + git diff a b" name='check imported tree checksums expected tree checksums' rm -f expected @@ -211,7 +211,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 EOF -test_expect_success "$name" "diff -u a expected" +test_expect_success "$name" "git diff a expected" test_expect_failure 'exit if remote refs are ambigious' " git-config --add svn-remote.svn.fetch \ diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 970d683650..8e958da536 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -74,7 +74,7 @@ EOF test_expect_success \ 'A: verify commit' \ 'git-cat-file commit master | sed 1d >actual && - diff -u expect actual' + git diff expect actual' cat >expect <<EOF 100644 blob file2 @@ -84,22 +84,22 @@ EOF test_expect_success \ 'A: verify tree' \ 'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && - diff -u expect actual' + git diff expect actual' echo "$file2_data" >expect test_expect_success \ 'A: verify file2' \ - 'git-cat-file blob master:file2 >actual && diff -u expect actual' + 'git-cat-file blob master:file2 >actual && git diff expect actual' echo "$file3_data" >expect test_expect_success \ 'A: verify file3' \ - 'git-cat-file blob master:file3 >actual && diff -u expect actual' + 'git-cat-file blob master:file3 >actual && git diff expect actual' printf "$file4_data" >expect test_expect_success \ 'A: verify file4' \ - 'git-cat-file blob master:file4 >actual && diff -u expect actual' + 'git-cat-file blob master:file4 >actual && git diff expect actual' cat >expect <<EOF :2 `git-rev-parse --verify master:file2` @@ -109,7 +109,15 @@ cat >expect <<EOF EOF test_expect_success \ 'A: verify marks output' \ - 'diff -u expect marks.out' + 'git diff expect marks.out' + +test_expect_success \ + 'A: verify marks import' \ + 'git-fast-import \ + --import-marks=marks.out \ + --export-marks=marks.new \ + </dev/null && + git diff -u expect marks.new' ### ### series B @@ -175,7 +183,7 @@ EOF test_expect_success \ 'C: verify commit' \ 'git-cat-file commit branch | sed 1d >actual && - diff -u expect actual' + git diff expect actual' cat >expect <<EOF :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf @@ -232,13 +240,13 @@ echo "$file5_data" >expect test_expect_success \ 'D: verify file5' \ 'git-cat-file blob branch:newdir/interesting >actual && - diff -u expect actual' + git diff expect actual' echo "$file6_data" >expect test_expect_success \ 'D: verify file6' \ 'git-cat-file blob branch:newdir/exec.sh >actual && - diff -u expect actual' + git diff expect actual' ### ### series E @@ -274,7 +282,7 @@ EOF test_expect_success \ 'E: verify commit' \ 'git-cat-file commit branch | sed 1,2d >actual && - diff -u expect actual' + git diff expect actual' ### ### series F @@ -327,7 +335,7 @@ EOF test_expect_success \ 'F: verify other commit' \ 'git-cat-file commit other >actual && - diff -u expect actual' + git diff expect actual' ### ### series G @@ -405,7 +413,7 @@ echo "$file5_data" >expect test_expect_success \ 'H: verify file' \ 'git-cat-file blob H:h/e/l/lo >actual && - diff -u expect actual' + git diff expect actual' ### ### series I @@ -431,7 +439,7 @@ EOF test_expect_success \ 'I: verify edge list' \ 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && - diff -u expect actual' + git diff expect actual' ### ### series J @@ -493,4 +501,54 @@ test_expect_success \ 'test `git-rev-parse --verify branch^1` \ = `git-rev-parse --verify K^1`' +### +### series L +### + +cat >input <<INPUT_END +blob +mark :1 +data <<EOF +some data +EOF + +blob +mark :2 +data <<EOF +other data +EOF + +commit refs/heads/L +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +create L +COMMIT + +M 644 :1 b. +M 644 :1 b/other +M 644 :1 ba + +commit refs/heads/L +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +update L +COMMIT + +M 644 :2 b. +M 644 :2 b/other +M 644 :2 ba +INPUT_END + +cat >expect <<EXPECT_END +:100644 100644 4268632... 55d3a52... M b. +:040000 040000 0ae5cac... 443c768... M b +:100644 100644 4268632... 55d3a52... M ba +EXPECT_END + +test_expect_success \ + 'L: verify internal tree sorting' \ + 'git-fast-import <input && + git-diff --raw L^ L >output && + git diff expect output' + test_done diff --git a/templates/Makefile b/templates/Makefile index 0eeee43feb..b8352e731b 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -1,5 +1,9 @@ # make and install sample templates +ifndef V + QUIET = @ +endif + INSTALL ?= install TAR ?= tar prefix ?= $(HOME) @@ -18,7 +22,7 @@ all: boilerplates.made custom bpsrc = $(filter-out %~,$(wildcard *--*)) boilerplates.made : $(bpsrc) - ls *--* 2>/dev/null | \ + $(QUIET)ls *--* 2>/dev/null | \ while read boilerplate; \ do \ case "$$boilerplate" in *~) continue ;; esac && \ @@ -29,13 +33,13 @@ boilerplates.made : $(bpsrc) *--) ;; \ *) cp $$boilerplate blt/$$dst ;; \ esac || exit; \ - done || exit + done && \ date >$@ # If you need build-tailored templates, build them into blt/ # directory yourself here. custom: - : no custom templates yet + $(QUIET): no custom templates yet clean: rm -rf blt boilerplates.made diff --git a/templates/hooks--update b/templates/hooks--update index fd1f73d6aa..5b82b68e93 100644 --- a/templates/hooks--update +++ b/templates/hooks--update @@ -64,7 +64,7 @@ case "$refname","$newrev_type" in # un-annotated tag refname_type="tag" short_refname=${refname##refs/tags/} - if [ $allowunannotated != "true" ]; then + 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 @@ -148,7 +148,7 @@ case "$refname_type" in # 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-parse --not --all | git-rev-list --stdin --pretty $newref + git log $newrev --not --all echo $LOGEND else # oldrev is valid @@ -165,7 +165,7 @@ case "$refname_type" in baserev=$(git-merge-base $oldrev $newrev) # Commit with a parent - for rev in $(git-rev-parse --not --all | git-rev-list --stdin $newrev ^$baserev) + for rev in $(git-rev-list $newrev --not $baserev --all) do revtype=$(git-cat-file -t "$rev") echo " via $rev ($revtype)" @@ -190,12 +190,11 @@ case "$refname_type" in fi echo "" echo $LOGBEGIN - git-rev-parse --not --all | - git-rev-list --stdin --pretty $newrev ^$baserev + git log $newrev --not $baserev --all echo $LOGEND echo "" echo "Diffstat:" - git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev ^$baserev + git-diff-tree --no-color --stat -M -C --find-copies-harder $baserev..$newrev fi ;; "annotated tag") @@ -26,14 +26,14 @@ #include "quote.h" /* Stolen from "imap-send.c". */ -static int git_vasprintf(char **strp, const char *fmt, va_list ap) +int nfvasprintf(char **strp, const char *fmt, va_list ap) { int len; char tmp[1024]; if ((len = vsnprintf(tmp, sizeof(tmp), fmt, ap)) < 0 || !(*strp = xmalloc(len + 1))) - return -1; + die("Fatal: Out of memory\n"); if (len >= (int)sizeof(tmp)) vsprintf(*strp, fmt, ap); else @@ -41,13 +41,15 @@ static int git_vasprintf(char **strp, const char *fmt, va_list ap) return len; } -/* Stolen from "imap-send.c". */ -int nfvasprintf(char **str, const char *fmt, va_list va) +int nfasprintf(char **str, const char *fmt, ...) { - int ret = git_vasprintf(str, fmt, va); - if (ret < 0) - die("Fatal: Out of memory\n"); - return ret; + int rc; + va_list args; + + va_start(args, fmt); + rc = nfvasprintf(str, fmt, args); + va_end(args); + return rc; } /* Get a trace file descriptor from GIT_TRACE env variable. */ diff --git a/upload-pack.c b/upload-pack.c index 804bbb6c9e..498bf50eb8 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -26,7 +26,7 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n static unsigned long oldest_have; static int multi_ack, nr_our_refs; -static int use_thin_pack, use_ofs_delta; +static int use_thin_pack, use_ofs_delta, no_progress; static struct object_array have_obj; static struct object_array want_obj; static unsigned int timeout; @@ -164,6 +164,9 @@ static void create_pack_file(void) die("git-upload-pack: unable to fork git-pack-objects"); } if (!pid_pack_objects) { + const char *argv[10]; + int i = 0; + dup2(lp_pipe[0], 0); dup2(pu_pipe[1], 1); dup2(pe_pipe[1], 2); @@ -174,9 +177,16 @@ static void create_pack_file(void) close(pu_pipe[1]); close(pe_pipe[0]); close(pe_pipe[1]); - execl_git_cmd("pack-objects", "--stdout", "--progress", - use_ofs_delta ? "--delta-base-offset" : NULL, - NULL); + + argv[i++] = "pack-objects"; + argv[i++] = "--stdout"; + if (!no_progress) + argv[i++] = "--progress"; + if (use_ofs_delta) + argv[i++] = "--delta-base-offset"; + argv[i++] = NULL; + + execv_git_cmd(argv); kill(pid_rev_list, SIGKILL); die("git-upload-pack: unable to exec git-pack-objects"); } @@ -537,6 +547,8 @@ static void receive_needs(void) use_sideband = LARGE_PACKET_MAX; else if (strstr(line+45, "side-band")) use_sideband = DEFAULT_PACKET_MAX; + if (strstr(line+45, "no-progress")) + no_progress = 1; /* We have sent all our refs already, and the other end * should have chosen out of them; otherwise they are @@ -605,7 +617,7 @@ static void receive_needs(void) static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { static const char *capabilities = "multi_ack thin-pack side-band" - " side-band-64k ofs-delta shallow"; + " side-band-64k ofs-delta shallow no-progress"; struct object *o = parse_object(sha1); if (!o) @@ -3,13 +3,15 @@ /* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */ +typedef unsigned int ucs_char_t; /* assuming 32bit int */ + struct interval { int first; int last; }; /* auxiliary function for binary search in interval table */ -static int bisearch(wchar_t ucs, const struct interval *table, int max) { +static int bisearch(ucs_char_t ucs, const struct interval *table, int max) { int min = 0; int mid; @@ -56,11 +58,11 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) { * ISO 8859-1 and WGL4 characters, Unicode control characters, * etc.) have a column width of 1. * - * This implementation assumes that wchar_t characters are encoded + * This implementation assumes that ucs_char_t characters are encoded * in ISO 10646. */ -static int wcwidth(wchar_t ch) +static int wcwidth(ucs_char_t ch) { /* * Sorted list of non-overlapping intervals of non-spacing characters, @@ -157,7 +159,7 @@ static int wcwidth(wchar_t ch) int utf8_width(const char **start) { unsigned char *s = (unsigned char *)*start; - wchar_t ch; + ucs_char_t ch; if (*s < 0x80) { /* 0xxxxxxx */ @@ -235,12 +237,19 @@ static void print_spaces(int count) /* * Wrap the text, if necessary. The variable indent is the indent for the * first line, indent2 is the indent for all other lines. + * If indent is negative, assume that already -indent columns have been + * consumed (and no extra indent is necessary for the first line). */ -void print_wrapped_text(const char *text, int indent, int indent2, int width) +int print_wrapped_text(const char *text, int indent, int indent2, int width) { int w = indent, assume_utf8 = is_utf8(text); const char *bol = text, *space = NULL; + if (indent < 0) { + w = -indent; + space = text; + } + for (;;) { char c = *text; if (!c || isspace(c)) { @@ -251,10 +260,9 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width) else print_spaces(indent); fwrite(start, text - start, 1, stdout); - if (!c) { - putchar('\n'); - return; - } else if (c == '\t') + if (!c) + return w; + else if (c == '\t') w |= 0x07; space = text; w++; @@ -262,7 +270,7 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width) } else { putchar('\n'); - text = bol = space + 1; + text = bol = space + isspace(*space); space = NULL; w = indent = indent2; } @@ -275,6 +283,7 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width) text++; } } + return w; } int is_encoding_utf8(const char *name) @@ -291,11 +300,17 @@ int is_encoding_utf8(const char *name) * with iconv. If the conversion fails, returns NULL. */ #ifndef NO_ICONV +#ifdef OLD_ICONV + typedef const char * iconv_ibp; +#else + typedef char * iconv_ibp; +#endif char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding) { iconv_t conv; size_t insz, outsz, outalloc; - char *out, *outpos, *cp; + char *out, *outpos; + iconv_ibp cp; if (!in_encoding) return NULL; @@ -307,7 +322,7 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e outalloc = outsz + 1; /* for terminating NUL */ out = xmalloc(outalloc); outpos = out; - cp = (char *)in; + cp = (iconv_ibp)in; while (1) { size_t cnt = iconv(conv, &cp, &insz, &outpos, &outsz); @@ -5,7 +5,7 @@ int utf8_width(const char **start); int is_utf8(const char *text); int is_encoding_utf8(const char *name); -void print_wrapped_text(const char *text, int indent, int indent2, int len); +int print_wrapped_text(const char *text, int indent, int indent2, int len); #ifndef NO_ICONV char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding); diff --git a/wt-status.c b/wt-status.c index 035e546ed7..a25632bc87 100644 --- a/wt-status.c +++ b/wt-status.c @@ -191,12 +191,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q, wt_status_print_trailer(); } +static void wt_read_cache(struct wt_status *s) +{ + discard_cache(); + read_cache(); +} + void wt_status_print_initial(struct wt_status *s) { int i; char buf[PATH_MAX]; - read_cache(); + wt_read_cache(s); if (active_nr) { s->commitable = 1; wt_status_print_cached_header(NULL); @@ -220,6 +226,7 @@ static void wt_status_print_updated(struct wt_status *s) rev.diffopt.format_callback = wt_status_print_updated_cb; rev.diffopt.format_callback_data = s; rev.diffopt.detect_rename = 1; + wt_read_cache(s); run_diff_index(&rev, 1); } @@ -231,6 +238,7 @@ static void wt_status_print_changed(struct wt_status *s) rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_print_changed_cb; rev.diffopt.format_callback_data = s; + wt_read_cache(s); run_diff_files(&rev, 0); } @@ -287,6 +295,7 @@ static void wt_status_print_verbose(struct wt_status *s) setup_revisions(0, NULL, &rev, s->reference); rev.diffopt.output_format |= DIFF_FORMAT_PATCH; rev.diffopt.detect_rename = 1; + wt_read_cache(s); run_diff_index(&rev, 1); } @@ -316,7 +325,6 @@ void wt_status_print(struct wt_status *s) } else { wt_status_print_updated(s); - discard_cache(); } wt_status_print_changed(s); diff --git a/xdiff-interface.c b/xdiff-interface.c index 6c1f99b149..10816e95a0 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -107,16 +107,18 @@ int read_mmfile(mmfile_t *ptr, const char *filename) { struct stat st; FILE *f; + size_t sz; if (stat(filename, &st)) return error("Could not stat %s", filename); if ((f = fopen(filename, "rb")) == NULL) return error("Could not open %s", filename); - ptr->ptr = xmalloc(st.st_size); - if (fread(ptr->ptr, st.st_size, 1, f) != 1) + sz = xsize_t(st.st_size); + ptr->ptr = xmalloc(sz); + if (fread(ptr->ptr, sz, 1, f) != 1) return error("Could not read %s", filename); fclose(f); - ptr->size = st.st_size; + ptr->size = sz; return 0; } |