diff options
278 files changed, 7634 insertions, 2764 deletions
diff --git a/.gitignore b/.gitignore index aa258a6bcf..6669bf0c6c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ /git-bundle /git-cat-file /git-check-attr +/git-check-ignore /git-check-ref-format /git-checkout /git-checkout-index diff --git a/Documentation/.gitignore b/Documentation/.gitignore index d62aebd848..2c8b2d612e 100644 --- a/Documentation/.gitignore +++ b/Documentation/.gitignore @@ -9,4 +9,5 @@ gitman.info howto-index.txt doc.dep cmds-*.txt +mergetools-*.txt manpage-base-url.xsl diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 69f7e9b76c..9eb2d9fe7e 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -1,5 +1,5 @@ Like other projects, we also have some guidelines to keep to the -code. For git in general, three rough rules are: +code. For Git in general, three rough rules are: - Most importantly, we never say "It's in POSIX; we'll happily ignore your needs should your system not conform to it." @@ -22,7 +22,7 @@ code. For git in general, three rough rules are: As for more concrete guidelines, just imitate the existing code (this is a good guideline, no matter which project you are contributing to). It is always preferable to match the _local_ -convention. New code added to git suite is expected to match +convention. New code added to Git suite is expected to match the overall style of existing code. Modifications to existing code is expected to match the style the surrounding code already uses (even if it doesn't match the overall style of existing code). @@ -112,7 +112,7 @@ For C programs: - We try to keep to at most 80 characters per line. - - We try to support a wide range of C compilers to compile git with, + - We try to support a wide range of C compilers to compile Git with, including old ones. That means that you should not use C99 initializers, even if a lot of compilers grok it. @@ -164,14 +164,14 @@ For C programs: - If you are planning a new command, consider writing it in shell or perl first, so that changes in semantics can be easily - changed and discussed. Many git commands started out like + changed and discussed. Many Git commands started out like that, and a few are still scripts. - - Avoid introducing a new dependency into git. This means you + - Avoid introducing a new dependency into Git. This means you usually should stay away from scripting languages not already - used in the git core command set (unless your command is clearly + used in the Git core command set (unless your command is clearly separate from it, such as an importer to convert random-scm-X - repositories to git). + repositories to Git). - When we pass <string, length> pair to functions, we should try to pass them in that order. @@ -179,6 +179,20 @@ For C programs: - Use Git's gettext wrappers to make the user interface translatable. See "Marking strings for translation" in po/README. +For Python scripts: + + - We follow PEP-8 (http://www.python.org/dev/peps/pep-0008/). + + - As a minimum, we aim to be compatible with Python 2.6 and 2.7. + + - Where required libraries do not restrict us to Python 2, we try to + also be compatible with Python 3.1 and later. + + - When you must differentiate between Unicode literals and byte string + literals, it is OK to use the 'b' prefix. Even though the Python + documentation for version 2.6 does not mention this prefix, it has + been supported since version 2.6.0. + Writing Documentation: Every user-visible change should be reflected in the documentation. @@ -230,3 +244,8 @@ Writing Documentation: valid usage. "*" has its own pair of brackets, because it can (optionally) be specified only when one or more of the letters is also provided. + + A note on notation: + Use 'git' (all lowercase) when talking about commands i.e. something + the user would type into a shell and use 'Git' (uppercase first letter) + when talking about the version control system and its properties. diff --git a/Documentation/Makefile b/Documentation/Makefile index 971977b8aa..62dbd9ac7c 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,19 +1,41 @@ -MAN1_TXT= \ - $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ - $(wildcard git-*.txt)) \ - gitk.txt gitweb.txt git.txt -MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \ - gitrepository-layout.txt gitweb.conf.txt -MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \ - gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \ - gitdiffcore.txt gitnamespaces.txt gitrevisions.txt gitworkflows.txt +# Guard against environment variables +MAN1_TXT = +MAN5_TXT = +MAN7_TXT = + +MAN1_TXT += $(filter-out \ + $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ + $(wildcard git-*.txt)) +MAN1_TXT += git.txt +MAN1_TXT += gitk.txt +MAN1_TXT += gitremote-helpers.txt +MAN1_TXT += gitweb.txt + +MAN5_TXT += gitattributes.txt +MAN5_TXT += githooks.txt +MAN5_TXT += gitignore.txt +MAN5_TXT += gitmodules.txt +MAN5_TXT += gitrepository-layout.txt +MAN5_TXT += gitweb.conf.txt + +MAN7_TXT += gitcli.txt +MAN7_TXT += gitcore-tutorial.txt MAN7_TXT += gitcredentials.txt +MAN7_TXT += gitcvs-migration.txt +MAN7_TXT += gitdiffcore.txt +MAN7_TXT += gitglossary.txt +MAN7_TXT += gitnamespaces.txt +MAN7_TXT += gitrevisions.txt +MAN7_TXT += gittutorial-2.txt +MAN7_TXT += gittutorial.txt +MAN7_TXT += gitworkflows.txt MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT) MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) -DOC_HTML=$(MAN_HTML) +OBSOLETE_HTML = git-remote-helpers.html +DOC_HTML=$(MAN_HTML) $(OBSOLETE_HTML) ARTICLES = howto-index ARTICLES += everyday @@ -222,7 +244,11 @@ install-html: html # # Determine "include::" file references in asciidoc files. # -doc.dep : $(wildcard *.txt) build-docdep.perl +docdep_prereqs = \ + mergetools-list.made $(mergetools_txt) \ + cmd-list.made $(cmds_txt) + +doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl $(QUIET_GEN)$(RM) $@+ $@ && \ $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \ mv $@+ $@ @@ -246,13 +272,27 @@ cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT) $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \ date >$@ +mergetools_txt = mergetools-diff.txt mergetools-merge.txt + +$(mergetools_txt): mergetools-list.made + +mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*) + $(QUIET_GEN)$(RM) $@ && \ + $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \ + . ../git-mergetool--lib.sh && \ + show_tool_names can_diff "* " || :' >mergetools-diff.txt && \ + $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \ + . ../git-mergetool--lib.sh && \ + show_tool_names can_merge "* " || :' >mergetools-merge.txt && \ + date >$@ + clean: $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7 $(RM) *.texi *.texi+ *.texi++ git.info gitman.info $(RM) *.pdf $(RM) howto-index.txt howto/*.html doc.dep $(RM) technical/*.html technical/api-index.txt - $(RM) $(cmds_txt) *.made + $(RM) $(cmds_txt) $(mergetools_txt) *.made $(RM) manpage-base-url.xsl $(MAN_HTML): %.html : %.txt asciidoc.conf @@ -261,6 +301,12 @@ $(MAN_HTML): %.html : %.txt asciidoc.conf $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \ mv $@+ $@ +$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf + $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ + $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \ + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \ + mv $@+ $@ + manpage-base-url.xsl: manpage-base-url.xsl.in sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@ @@ -346,8 +392,8 @@ $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt install-webdoc : html '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST) -# You must have a clone of git-htmldocs and git-manpages repositories -# next to the git repository itself for the following to work. +# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories +# next to the 'git' repository itself for the following to work. quick-install: quick-install-man diff --git a/Documentation/RelNotes/1.8.1.2.txt b/Documentation/RelNotes/1.8.1.2.txt index 76ad0b3d01..5ab7b18906 100644 --- a/Documentation/RelNotes/1.8.1.2.txt +++ b/Documentation/RelNotes/1.8.1.2.txt @@ -4,6 +4,16 @@ Git 1.8.1.2 Release Notes Fixes since v1.8.1.1 -------------------- + * An element on GIT_CEILING_DIRECTORIES list that does not name the + real path to a directory (i.e. a symbolic link) could have caused + the GIT_DIR discovery logic to escape the ceiling. + + * Command line completion for "tcsh" emitted an unwanted space + after completing a single directory name. + + * Command line completion leaked an unnecessary error message while + looking for possible matches with paths in <tree-ish>. + * "git archive" did not record uncompressed size in the header when streaming a zip archive, which confused some implementations of unzip. @@ -11,3 +21,5 @@ Fixes since v1.8.1.1 trailer part, "git send-email" failed to pick up the addresses from there. As e-mail headers field names are case insensitive, this script should follow suit and treat "cc:" and "Cc:" the same way. + +Also contains various documentation fixes. diff --git a/Documentation/RelNotes/1.8.1.3.txt b/Documentation/RelNotes/1.8.1.3.txt new file mode 100644 index 0000000000..681cb35c0a --- /dev/null +++ b/Documentation/RelNotes/1.8.1.3.txt @@ -0,0 +1,47 @@ +Git 1.8.1.3 Release Notes +========================= + +Fixes since v1.8.1.2 +-------------------- + + * The attribute mechanism didn't allow limiting attributes to be + applied to only a single directory itself with "path/" like the + exclude mechanism does. The fix for this in 1.8.1.2 had + performance degradations. + + * Command line completion code was inadvertently made incompatible with + older versions of bash by using a newer array notation. + + * Scripts to test bash completion was inherently flaky as it was + affected by whatever random things the user may have on $PATH. + + * A fix was added to the build procedure to work around buggy + versions of ccache broke the auto-generation of dependencies, which + unfortunately is still relevant because some people use ancient + distros. + + * We used to stuff "user@" and then append what we read from + /etc/mailname to come up with a default e-mail ident, but a bug + lost the "user@" part. + + * "git am" did not parse datestamp correctly from Hg generated patch, + when it is run in a locale outside C (or en). + + * Attempt to "branch --edit-description" an existing branch, while + being on a detached HEAD, errored out. + + * "git cherry-pick" did not replay a root commit to an unborn branch. + + * We forgot to close the file descriptor reading from "gpg" output, + killing "git log --show-signature" on a long history. + + * "git rebase --preserve-merges" lost empty merges in recent versions + of Git. + + * Rebasing the history of superproject with change in the submodule + has been broken since v1.7.12. + + * A failure to push due to non-ff while on an unborn branch + dereferenced a NULL pointer when showing an error message. + +Also contains various documentation fixes. diff --git a/Documentation/RelNotes/1.8.2.txt b/Documentation/RelNotes/1.8.2.txt index 0ae40f3b25..a244034b90 100644 --- a/Documentation/RelNotes/1.8.2.txt +++ b/Documentation/RelNotes/1.8.2.txt @@ -15,6 +15,13 @@ current branch to the branch with the same name, only when the current branch is set to integrate with that remote branch. There is a user preference configuration variable "push.default" to change this. +"git push $there tag v1.2.3" used to allow replacing a tag v1.2.3 +that already exists in the repository $there, if the rewritten tag +you are pushing points at a commit that is a decendant of a commit +that the old tag v1.2.3 points at. This was found to be error prone +and starting with this release, any attempt to update an existing +ref under refs/tags/ hierarchy will fail, without "--force". + Updates since v1.8.1 -------------------- @@ -26,6 +33,12 @@ UI, Workflows & Features * Output from the tests is coloured using "green is okay, yellow is questionable, red is bad and blue is informative" scheme. + * Mention of "GIT/Git/git" in the documentation have been updated to + be more uniform and consistent. The name of the system and the + concept it embodies is "Git"; the command the users type is "git". + All-caps "GIT" was merely a way to imitate "Git" typeset in small + caps in our ASCII text only documentation and to be avoided. + * In bare repositories, "git shortlog" and other commands now read mailmap files from the tip of the history, to help running these tools in server settings. @@ -38,11 +51,38 @@ UI, Workflows & Features * Scripts can ask Git that wildcard patterns in pathspecs they give do not have any significance, i.e. take them as literal strings. - * The pathspec code learned to grok "foo/**/bar" as a pattern that - matches "bar" in 0-or-more levels of subdirectory in "foo". + * The patterns in .gitignore and .gitattributes files can have **/, + as a pattern that matches 0 or more levels of subdirectory. + E.g. "foo/**/bar" matches "bar" in "foo" itself or in a + subdirectory of "foo". + + * When giving arguments without "--" disambiguation, object names + that come earlier on the command line must not be interpretable as + pathspecs and pathspecs that come later on the command line must + not be interpretable as object names. This disambiguation rule has + been tweaked so that ":/" (no other string before or after) is + always interpreted as a pathspec; "git cmd -- :/" is no longer + needed, you can just say "git cmd :/". + + * Various "hint" lines Git gives when it asks the user to edit + messages in the editor are commented out with '#' by default. The + core.commentchar configuration variable can be used to customize + this '#' to a different character. + + * "git add -u" and "git add -A" without pathspec issues warning to + make users aware that they are only operating on paths inside the + subdirectory they are in. Use ":/" (everything from the top) or + "." (everything from the $cwd) to disambiguate. * "git blame" (and "git diff") learned the "--no-follow" option. + * "git branch" now rejects some nonsense combinations of command line + arguments (e.g. giving more than one branch name to rename) with + more case-specific error messages. + + * "git check-ignore" command to help debugging .gitignore files has + been added. + * "git cherry-pick" can be used to replay a root commit to an unborn branch. @@ -69,9 +109,22 @@ UI, Workflows & Features rewrite the names and email addresses of people using the mailmap mechanism. + * "git mergetool" and "git difftool" learned to list the available + tool backends in a more consistent manner. + + * "git mergetool" is aware of TortoiseGitMerge now and uses it over + TortoiseMerge when available. + * "git push" now requires "-f" to update a tag, even if it is a fast-forward, as tags are meant to be fixed points. + * Error messages from "git push" when it stops to prevent remote refs + from getting overwritten by mistake have been improved to explain + various situations separately. + + * "git push" will stop without doing anything if the new "pre-push" + hook exists and exits with a failure. + * When "git rebase" fails to generate patches to be applied (e.g. due to oom), it failed to detect the failure and instead behaved as if there were nothing to do. A workaround to use a temporary file has @@ -97,7 +150,9 @@ Foreign Interface * A new remote helper to interact with bzr has been added to contrib/. - * "git p4" got various bugfixes around its branch handling. + * "git p4" got various bugfixes around its branch handling. It is + also made usable with Python 2.4/2.5. In addition, its various + portability issues for Cygwin have been addressed. * The remote helper to interact with Hg in contrib/ has seen a few fixes. @@ -111,18 +166,45 @@ Performance, Internal Implementation, etc. * Matching paths with common forms of pathspecs that contain wildcard characters has been optimized further. + * We stopped paying attention to $GIT_CONFIG environment that points + at a single configuration file from any command other than "git config" + quite a while ago, but "git clone" internally set, exported, and + then unexported the variable during its operation unnecessarily. + * "git reset" internals has been reworked and should be faster in general. We tried to be careful not to break any behaviour but there could be corner cases, especially when running the command from a conflicted state, that we may have missed. * The implementation of "imap-send" has been updated to reuse xml - quoting code from http-push codepath. + quoting code from http-push codepath, and lost a lot of unused + code. * There is a simple-minded checker for the test scripts in t/ directory to catch most common mistakes (it is not enabled by default). + * You can build with USE_WILDMATCH=YesPlease to use a replacement + implementation of pattern matching logic used for pathname-like + things, e.g. refnames and paths in the repository. This new + implementation is not expected change the existing behaviour of Git + in this release, except for "git for-each-ref" where you can now + say "refs/**/master" and match with both refs/heads/master and + refs/remotes/origin/master. We plan to use this new implementation + in wider places (e.g. "git ls-files '**/Makefile' may find Makefile + at the top-level, and "git log '**/t*.sh'" may find commits that + touch a shell script whose name begins with "t" at any level) in + future versions of Git, but we are not there yet. By building with + USE_WILDMATCH, using the resulting Git daily and reporting when you + find breakages, you can help us get closer to that goal. + + * Some reimplementations of Git do not write all the stat info back + to the index due to their implementation limitations (e.g. jgit). + A configuration option can tell Git to ignore changes to most of + the stat fields and only pay attention to mtime and size, which + these implementations can reliably update. This can be used to + avoid excessive revalidation of contents. + Also contains minor documentation updates and code clean-ups. @@ -137,47 +219,53 @@ details). * An element on GIT_CEILING_DIRECTORIES list that does not name the real path to a directory (i.e. a symbolic link) could have caused the GIT_DIR discovery logic to escape the ceiling. - (merge 059b379 mh/ceiling later to maint). * When attempting to read the XDG-style $HOME/.config/git/config and finding that $HOME/.config/git is a file, we gave a wrong error message, instead of treating the case as "a custom config file does not exist there" and moving on. - (merge 8f2bbe4 jn/warn-on-inaccessible-loosen later to maint). * The behaviour visible to the end users was confusing, when they attempt to kill a process spawned in the editor that was in turn launched by Git with SIGINT (or SIGQUIT), as Git would catch that signal and die. We ignore these signals now. - (merge 1250857 pf/editor-ignore-sigint later to maint). + (merge 0398fc34 pf/editor-ignore-sigint later to maint). * A child process that was killed by a signal (e.g. SIGINT) was reported in an inconsistent way depending on how the process was spawned by us, with or without a shell in between. - (merge 709ca73 jk/unify-exit-code-by-receiving-signal later to maint). * After failing to create a temporary file using mkstemp(), failing pathname was not reported correctly on some platforms. - (merge f7be59b jc/mkstemp-more-careful-error-reporting later to maint). + + * We used to stuff "user@" and then append what we read from + /etc/mailname to come up with a default e-mail ident, but a bug + lost the "user@" part. * The attribute mechanism didn't allow limiting attributes to be applied to only a single directory itself with "path/" like the exclude mechanism does. The initial implementation of this that was merged to 'maint' and 1.8.1.2 was with a severe performance degradations and needs to merge a fix-up topic. - (merge 9db9eec nd/fix-directory-attrs-off-by-one later to maint). + + * "git am" did not parse datestamp correctly from Hg generated patch, + when it is run in a locale outside C (or en). * "git apply" misbehaved when fixing whitespace breakages by removing excess trailing blank lines. - (merge 5de7166 jc/apply-trailing-blank-removal later to maint). * A tar archive created by "git archive" recorded a directory in a way that made NetBSD's implementation of "tar" sometimes unhappy. - (merge 22f0dcd rs/leave-base-name-in-name-field-of-tar later to maint). * "git archive" did not record uncompressed size in the header when streaming a zip archive, which confused some implementations of unzip. - (merge 5ea2c84 rs/zip-with-uncompressed-size-in-the-header later to maint). + + * "git archive" did not parse configuration values in tar.* namespace + correctly. + (merge b3873c3 jk/config-parsing-cleanup later to maint). + + * Attempt to "branch --edit-description" an existing branch, while + being on a detached HEAD, errored out. * "git clean" showed what it was going to do, but sometimes end up finding that it was not allowed to do so, which resulted in a @@ -190,27 +278,37 @@ details). * When "git clone --separate-git-dir=$over_there" is interrupted, it failed to remove the real location of the $GIT_DIR it created. This was most visible when interrupting a submodule update. - (merge 9be1980 jl/interrupt-clone-remove-separate-git-dir later to maint). + + * "git fetch --depth" was broken in at least three ways. The + resulting history was deeper than specified by one commit, it was + unclear how to wipe the shallowness of the repository with the + command, and documentation was misleading. + (merge cfb70e1 nd/fetch-depth-is-broken later to maint). + + * "git log --all -p" that walked refs/notes/textconv/ ref can later + try to use the textconv data incorrectly after it gets freed. + (merge be5c9fb jk/read-commit-buffer-data-after-free later to maint). + + * We forgot to close the file descriptor reading from "gpg" output, + killing "git log --show-signature" on a long history. * The way "git svn" asked for password using SSH_ASKPASS and GIT_ASKPASS was not in line with the rest of the system. - (merge e9263e4 ss/svn-prompt later to maint). * The --graph code fell into infinite loop when asked to do what the code did not expect. - (merge 656197a mk/maint-graph-infinity-loop later to maint). * http transport was wrong to ask for the username when the authentication is done by certificate identity. - (merge 75e9a40 rb/http-cert-cred-no-username-prompt later to maint). * "git pack-refs" that ran in parallel to another process that created new refs had a nasty race. - (merge b3f1280 jk/repack-ref-racefix later to maint). + + * Rebasing the history of superproject with change in the submodule + has been broken since v1.7.12. * After "git add -N" and then writing a tree object out of the index, the cache-tree data structure got corrupted. - (merge eec3e7e nd/invalidate-i-t-a-cache-tree later to maint). * "git clone" used to allow --bare and --separate-git-dir=$there options at the same time, which was nonsensical. @@ -218,54 +316,54 @@ details). * "git rebase --preserve-merges" lost empty merges in recent versions of Git. - (merge 9869778 ph/rebase-preserve-all-merges later to maint). * "git merge --no-edit" computed who were involved in the work done on the side branch, even though that information is to be discarded without getting seen in the editor. - (merge 9bcbb1c jc/maint-fmt-merge-msg-no-edit-lose-credit later to maint). * "git merge" started calling prepare-commit-msg hook like "git commit" does some time ago, but forgot to pay attention to the exit status of the hook. - (merge 3e4141d ap/merge-stop-at-prepare-commit-msg-failure later to maint). + + * A failure to push due to non-ff while on an unborn branch + dereferenced a NULL pointer when showing an error message. * When users spell "cc:" in lowercase in the fake "header" in the trailer part, "git send-email" failed to pick up the addresses from there. As e-mail headers field names are case insensitive, this script should follow suit and treat "cc:" and "Cc:" the same way. - (merge 6310071 nz/send-email-headers-are-case-insensitive later to maint). * Output from "git status --ignored" showed an unexpected interaction with "--untracked". - (merge a45fb69 ap/status-ignored-in-ignored-directory later to maint). * "gitweb", when sorting by age to show repositories with new activities first, used to sort repositories with absolutely nothing in it early, which was not very useful. - (merge 28dae18 md/gitweb-sort-by-age later to maint). * "gitweb"'s code to sanitize control characters before passing it to "highlight" filter lost known-to-be-safe control characters by mistake. - (merge 0e901d2 os/gitweb-highlight-uncaptured later to maint). + + * "gitweb" pages served over HTTPS, when configured to show picon or + gravatar, referred to these external resources to be fetched via + HTTP, resulting in mixed contents warning in browsers. + (merge 5748558 ab/gitweb-use-same-scheme later to maint). * When a line to be wrapped has a solid run of non space characters whose length exactly is the wrap width, "git shortlog -w" failed to add a newline after such a line. - (merge e0db176 sp/shortlog-missing-lf later to maint). * Command line completion leaked an unnecessary error message while looking for possible matches with paths in <tree-ish>. - (merge ca87dd6 ds/completion-silence-in-tree-path-probe later to maint). * Command line completion for "tcsh" emitted an unwanted space after completing a single directory name. - (merge 92f1c04 mk/complete-tcsh later to maint). + + * Command line completion code was inadvertently made incompatible with + older versions of bash by using a newer array notation. * Some shells do not behave correctly when IFS is unset; work it around by explicitly setting it to the default value. - (merge 393050c jc/maint-fbsd-sh-ifs-workaround later to maint). * Some scripted programs written in Python did not get updated when PYTHON_PATH changed. @@ -273,24 +371,28 @@ details). * When autoconf is used, any build on a different commit always ran "config.status --recheck" even when unnecessary. - (merge 1226504 jn/less-reconfigure later to maint). + + * A fix was added to the build procedure to work around buggy + versions of ccache broke the auto-generation of dependencies, which + unfortunately is still relevant because some people use ancient + distros. * We have been carrying a translated and long-unmaintained copy of an old version of the tutorial; removed. - (merge 0a85441 ta/remove-stale-translated-tut later to maint). + + * t0050 had tests expecting failures from a bug that was fixed some + time ago. * t4014, t9502 and t0200 tests had various portability issues that broke on OpenBSD. - (merge 27f6342 jc/maint-test-portability later to maint). * t9020 and t3600 tests had various portability issues. - (merge 5a02966 jc/test-portability later to maint). * t9200 runs "cvs init" on a directory that already exists, but a platform can configure this fail for the current user (e.g. you need to be in the cvsadmin group on NetBSD 6.0). - (merge 8666df0 jc/test-cvs-no-init-in-existing-dir later to maint). * t9020 and t9810 had a few non-portable shell script construct. - (merge 2797914 tb/test-t9020-no-which later to maint). - (merge 6f4e505 tb/test-t9810-no-sed-i later to maint). + + * Scripts to test bash completion was inherently flaky as it was + affected by whatever random things the user may have on $PATH. diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 90133d8c3b..d0a4733e45 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -103,9 +103,9 @@ without external resources. Instead of giving a URL to a mailing list archive, summarize the relevant points of the discussion. -(3) Generate your patch using git tools out of your commits. +(3) Generate your patch using Git tools out of your commits. -git based diff tools generate unidiff which is the preferred format. +Git based diff tools generate unidiff which is the preferred format. You do not have to be afraid to use -M option to "git diff" or "git format-patch", if your patch involves file renames. The @@ -122,7 +122,7 @@ that is fine, but please mark it as such. (4) Sending your patches. -People on the git mailing list need to be able to read and +People on the Git mailing list need to be able to read and comment on the changes you are submitting. It is important for a developer to be able to "quote" your changes, using standard e-mail tools, so that they may comment on specific portions of @@ -206,7 +206,7 @@ patch. To improve tracking of who did what, we've borrowed the "sign-off" procedure from the Linux kernel project on patches -that are being emailed around. Although core GIT is a lot +that are being emailed around. Although core Git is a lot smaller project it is a good discipline to follow it. The sign-off is a simple line at the end of the explanation for @@ -244,7 +244,7 @@ then you just add a line saying Signed-off-by: Random J Developer <random@developer.example.org> -This line can be automatically added by git if you run the git-commit +This line can be automatically added by Git if you run the git-commit command with the -s option. Notice that you can place your own Signed-off-by: line when @@ -337,7 +337,7 @@ Know the status of your patch after submission tell you if your patch is merged in pu if you rebase on top of master). -* Read the git mailing list, the maintainer regularly posts messages +* Read the Git mailing list, the maintainer regularly posts messages entitled "What's cooking in git.git" and "What's in git.git" giving the status of various proposed changes. diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index 1273a85c8a..2c16c536ba 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -4,7 +4,7 @@ # # Note, {0} is the manpage section, while {target} is the command. # -# Show GIT link as: <command>(<section>); if section is defined, else just show +# Show Git link as: <command>(<section>); if section is defined, else just show # the command. [macros] diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt index d4a51da464..b0d31df0e7 100644 --- a/Documentation/blame-options.txt +++ b/Documentation/blame-options.txt @@ -95,7 +95,7 @@ of lines before or after the line given by <start>. running extra passes of inspection. + <num> is optional but it is the lower bound on the number of -alphanumeric characters that git must detect as moving/copying +alphanumeric characters that Git must detect as moving/copying within a file for it to associate those lines with the parent commit. The default value is 20. @@ -110,7 +110,7 @@ commit. The default value is 20. looks for copies from other files in any commit. + <num> is optional but it is the lower bound on the number of -alphanumeric characters that git must detect as moving/copying +alphanumeric characters that Git must detect as moving/copying between files for it to associate those lines with the parent commit. And the default value is 40. If there are more than one `-C` options given, the <num> argument of the last `-C` will diff --git a/Documentation/config.txt b/Documentation/config.txt index b87f744643..9b11597387 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1,14 +1,14 @@ CONFIGURATION FILE ------------------ -The git configuration file contains a number of variables that affect -the git command's behavior. The `.git/config` file in each repository +The Git configuration file contains a number of variables that affect +the Git commands' behavior. The `.git/config` file in each repository is used to store the configuration for that repository, and `$HOME/.gitconfig` is used to store a per-user configuration as fallback values for the `.git/config` file. The file `/etc/gitconfig` can be used to store a system-wide default configuration. -The configuration variables are used by both the git plumbing +The configuration variables are used by both the Git plumbing and the porcelains. The variables are divided into sections, wherein the fully qualified variable name of the variable itself is the last dot-separated segment and the section name is everything before the last @@ -143,7 +143,8 @@ advice.*:: pushUpdateRejected:: Set this variable to 'false' if you want to disable 'pushNonFFCurrent', 'pushNonFFDefault', - 'pushNonFFMatching', and 'pushAlreadyExists' + 'pushNonFFMatching', 'pushAlreadyExists', + 'pushFetchFirst', and 'pushNeedsForce' simultaneously. pushNonFFCurrent:: Advice shown when linkgit:git-push[1] fails due to a @@ -162,6 +163,15 @@ advice.*:: pushAlreadyExists:: Shown when linkgit:git-push[1] rejects an update that does not qualify for fast-forwarding (e.g., a tag.) + pushFetchFirst:: + Shown when linkgit:git-push[1] rejects an update that + tries to overwrite a remote ref that points at an + object we do not have. + pushNeedsForce:: + Shown when linkgit:git-push[1] rejects an update that + tries to overwrite a remote ref that points at an + object that is not a committish, or make the remote + ref point at an object that is not a committish. statusHints:: Show directions on how to proceed from the current state in the output of linkgit:git-status[1], in @@ -209,9 +219,9 @@ core.ignoreCygwinFSTricks:: core.ignorecase:: If true, this option enables various workarounds to enable - git to work better on filesystems that are not case sensitive, + Git to work better on filesystems that are not case sensitive, like FAT. For example, if a directory listing finds - "makefile" when git expects "Makefile", git will assume + "makefile" when Git expects "Makefile", Git will assume it is really the same file, and continue to remember it as "Makefile". + @@ -220,13 +230,13 @@ will probe and set core.ignorecase true if appropriate when the repository is created. core.precomposeunicode:: - This option is only used by Mac OS implementation of git. - When core.precomposeunicode=true, git reverts the unicode decomposition + This option is only used by Mac OS implementation of Git. + When core.precomposeunicode=true, Git reverts the unicode decomposition of filenames done by Mac OS. This is useful when sharing a repository between Mac OS and Linux or Windows. - (Git for Windows 1.7.10 or higher is needed, or git under cygwin 1.7). - When false, file names are handled fully transparent by git, - which is backward compatible with older versions of git. + (Git for Windows 1.7.10 or higher is needed, or Git under cygwin 1.7). + When false, file names are handled fully transparent by Git, + which is backward compatible with older versions of Git. core.trustctime:: If false, the ctime differences between the index and the @@ -235,6 +245,12 @@ core.trustctime:: crawlers and some backup systems). See linkgit:git-update-index[1]. True by default. +core.checkstat:: + Determines which stat fields to match between the index + and work tree. The user can set this to 'default' or + 'minimal'. Default (or explicitly 'default'), is to check + all fields, including the sub-second part of mtime and ctime. + core.quotepath:: The commands that output paths (e.g. 'ls-files', 'diff'), when not given the `-z` option, will quote @@ -256,20 +272,20 @@ core.eol:: conversion. core.safecrlf:: - If true, makes git check if converting `CRLF` is reversible when + If true, makes Git check if converting `CRLF` is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly. For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of - `core.autocrlf`, git will reject the file. The variable can - be set to "warn", in which case git will only warn about an + `core.autocrlf`, Git will reject the file. The variable can + be set to "warn", in which case Git will only warn about an irreversible conversion but continue the operation. + CRLF conversion bears a slight chance of corrupting data. -When it is enabled, git will convert CRLF to LF during commit and LF to +When it is enabled, Git will convert CRLF to LF during commit and LF to CRLF during checkout. A file that contains a mixture of LF and -CRLF before the commit cannot be recreated by git. For text +CRLF before the commit cannot be recreated by Git. For text files this is the right thing to do: it corrects line endings such that we have only LF line endings in the repository. But for binary files that are accidentally classified as text the @@ -279,7 +295,7 @@ If you recognize such corruption early you can easily fix it by setting the conversion type explicitly in .gitattributes. Right after committing you still have the original file in your work tree and this file is not yet corrupted. You can explicitly tell -git that this file is binary and git will handle the file +Git that this file is binary and Git will handle the file appropriately. + Unfortunately, the desired effect of cleaning up text files with @@ -324,7 +340,7 @@ is created. core.gitProxy:: A "proxy command" to execute (as 'command host port') instead of establishing direct connection to the remote server when - using the git protocol for fetching. If the variable value is + using the Git protocol for fetching. If the variable value is in the "COMMAND for DOMAIN" format, the command is applied only on hostnames ending with the specified domain string. This variable may be set multiple times and is matched in the given order; @@ -383,7 +399,7 @@ Note that this variable is honored even when set in a configuration file in a ".git" subdirectory of a directory and its value differs from the latter directory (e.g. "/path/to/.git/config" has core.worktree set to "/different/path"), which is most likely a -misconfiguration. Running git commands in the "/path/to" directory will +misconfiguration. Running Git commands in the "/path/to" directory will still use "/different/path" as the root of the work tree and can cause confusion unless you know what you are doing (e.g. you are creating a read-only snapshot of the same index to a location different from the @@ -415,7 +431,7 @@ core.sharedRepository:: several users in a group (making sure all the files and objects are group-writable). When 'all' (or 'world' or 'everybody'), the repository will be readable by all users, additionally to being - group-shareable. When 'umask' (or 'false'), git will use permissions + group-shareable. When 'umask' (or 'false'), Git will use permissions reported by umask(2). When '0xxx', where '0xxx' is an octal number, files in the repository will have this mode value. '0xxx' will override user's umask value (whereas the other options will only override @@ -426,7 +442,7 @@ core.sharedRepository:: See linkgit:git-init[1]. False by default. core.warnAmbiguousRefs:: - If true, git will warn you if the ref name you passed it is ambiguous + If true, Git will warn you if the ref name you passed it is ambiguous and might match multiple refs in the .git/refs/ tree. True by default. core.compression:: @@ -498,7 +514,7 @@ Common unit suffixes of 'k', 'm', or 'g' are supported. core.excludesfile:: In addition to '.gitignore' (per-directory) and - '.git/info/exclude', git looks into this file for patterns + '.git/info/exclude', Git looks into this file for patterns of files which are not meant to be tracked. "`~/`" is expanded to the value of `$HOME` and "`~user/`" to the specified user's home directory. Its default value is $XDG_CONFIG_HOME/git/ignore. @@ -516,7 +532,7 @@ core.askpass:: core.attributesfile:: In addition to '.gitattributes' (per-directory) and - '.git/info/attributes', git looks into this file for attributes + '.git/info/attributes', Git looks into this file for attributes (see linkgit:gitattributes[5]). Path expansions are made the same way as for `core.excludesfile`. Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME is either not @@ -528,6 +544,12 @@ core.editor:: variable when it is set, and the environment variable `GIT_EDITOR` is not set. See linkgit:git-var[1]. +core.commentchar:: + Commands such as `commit` and `tag` that lets you edit + messages consider a line that begins with this character + commented, and removes them after the editor returns + (default '#'). + sequence.editor:: Text editor used by `git rebase -i` for editing the rebase insn file. The value is meant to be interpreted by the shell when it is used. @@ -535,9 +557,9 @@ sequence.editor:: When not configured the default commit message editor is used instead. core.pager:: - The command that git will use to paginate output. Can + The command that Git will use to paginate output. Can be overridden with the `GIT_PAGER` environment - variable. Note that git sets the `LESS` environment + variable. Note that Git sets the `LESS` environment variable to `FRSX` if it is unset when it runs the pager. One can change these settings by setting the `LESS` variable to some other value. Alternately, @@ -545,11 +567,11 @@ core.pager:: global basis by setting the `core.pager` option. Setting `core.pager` has no effect on the `LESS` environment variable behaviour above, so if you want - to override git's default settings this way, you need + to override Git's default settings this way, you need to be explicit. For example, to disable the S option in a backward compatible manner, set `core.pager` to `less -+S`. This will be passed to the shell by - git, which will translate the final command to + Git, which will translate the final command to `LESS=FRSX less -+S`. core.whitespace:: @@ -578,7 +600,7 @@ core.whitespace:: does not trigger if the character before such a carriage-return is not a whitespace (not enabled by default). * `tabwidth=<n>` tells how many character positions a tab occupies; this - is relevant for `indent-with-non-tab` and when git fixes `tab-in-indent` + is relevant for `indent-with-non-tab` and when Git fixes `tab-in-indent` errors. The default tab width is 8. Allowed values are 1 to 63. core.fsyncobjectfiles:: @@ -594,7 +616,7 @@ core.preloadindex:: + This can speed up operations like 'git diff' and 'git status' especially on filesystems like NFS that have weak caching semantics and thus -relatively high IO latencies. With this set to 'true', git will do the +relatively high IO latencies. With this set to 'true', Git will do the index comparison to the filesystem data in parallel, allowing overlapping IO's. @@ -630,9 +652,9 @@ add.ignore-errors:: add.ignoreErrors:: Tells 'git add' to continue adding files when some files cannot be added due to indexing errors. Equivalent to the '--ignore-errors' - option of linkgit:git-add[1]. Older versions of git accept only + option of linkgit:git-add[1]. Older versions of Git accept only `add.ignore-errors`, which does not follow the usual naming - convention for configuration variables. Newer versions of git + convention for configuration variables. Newer versions of Git honor `add.ignoreErrors` as well. alias.*:: @@ -640,7 +662,7 @@ alias.*:: after defining "alias.last = cat-file commit HEAD", the invocation "git last" is equivalent to "git cat-file commit HEAD". To avoid confusion and troubles with script usage, aliases that - hide existing git commands are ignored. Arguments are split by + hide existing Git commands are ignored. Arguments are split by spaces, the usual shell quoting and escaping is supported. quote pair and a backslash can be used to quote them. + @@ -687,7 +709,7 @@ branch.autosetupmerge:: branch.autosetuprebase:: When a new branch is created with 'git branch' or 'git checkout' - that tracks another branch, this variable tells git to set + that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch.<name>.rebase"). When `never`, rebase is never automatically set to true. When `local`, rebase is set to true for tracked branches of @@ -868,7 +890,7 @@ color.status.<slot>:: one of `header` (the header text of the status message), `added` or `updated` (files which are added but not committed), `changed` (files which are changed but not added in the index), - `untracked` (files which are not tracked by git), + `untracked` (files which are not tracked by Git), `branch` (the current branch), or `nobranch` (the color the 'no branch' warning is shown in, defaulting to red). The values of these variables may be specified as in @@ -882,7 +904,7 @@ color.ui:: to `always` if you want all output not intended for machine consumption to use color, to `true` or `auto` if you want such output to use color when written to the terminal, or to `false` or - `never` if you prefer git commands not to use color unless enabled + `never` if you prefer Git commands not to use color unless enabled explicitly with some other configuration or the `--color` option. column.ui:: @@ -999,7 +1021,7 @@ fetch.fsckObjects:: is used instead. fetch.unpackLimit:: - If the number of objects fetched over the git native + If the number of objects fetched over the Git native transfer is below this limit, then the objects will be unpacked into loose object files. However if the number of received objects equals or @@ -1039,7 +1061,7 @@ format.subjectprefix:: format.signature:: The default for format-patch is to output a signature containing - the git version number. Use this variable to change that default. + the Git version number. Use this variable to change that default. Set this variable to the empty string ("") to suppress signature generation. @@ -1152,7 +1174,7 @@ gitcvs.logfile:: gitcvs.usecrlfattr:: If true, the server will look up the end-of-line conversion attributes for files to determine the '-k' modes to use. If - the attributes force git to treat a file as text, + the attributes force Git to treat a file as text, the '-k' mode will be left blank so CVS clients will treat it as text. If they suppress text conversion, the file will be set with '-kb' mode, which suppresses any newline munging @@ -1172,7 +1194,7 @@ gitcvs.allbinary:: gitcvs.dbname:: Database used by git-cvsserver to cache revision information - derived from the git repository. The exact meaning depends on the + derived from the Git repository. The exact meaning depends on the used database driver, for SQLite (which is the default driver) this is a filename. Supports variable substitution (see linkgit:git-cvsserver[1] for details). May not contain semicolons (`;`). @@ -1384,7 +1406,7 @@ http.proxy:: http.cookiefile:: File containing previously stored cookie lines which should be used - in the git http session, if they match the server. The file format + in the Git http session, if they match the server. The file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format (see linkgit:curl[1]). NOTE that the file specified with http.cookiefile is only used as @@ -1406,7 +1428,7 @@ http.sslKey:: variable. http.sslCertPasswordProtected:: - Enable git's password prompt for the SSL certificate. Otherwise + Enable Git's password prompt for the SSL certificate. Otherwise OpenSSL will prompt the user, possibly many times, if the certificate or private key is encrypted. Can be overridden by the 'GIT_SSL_CERT_PASSWORD_PROTECTED' environment variable. @@ -1453,7 +1475,7 @@ http.noEPSV:: http.useragent:: The HTTP USER_AGENT string presented to an HTTP server. The default - value represents the version of the client git such as git/1.7.1. + value represents the version of the client Git such as git/1.7.1. This option allows you to override this value to a more common value such as Mozilla/4.0. This may be necessary, for instance, if connecting through a firewall that restricts HTTP connections to a set @@ -1461,7 +1483,7 @@ http.useragent:: Can be overridden by the 'GIT_HTTP_USER_AGENT' environment variable. i18n.commitEncoding:: - Character encoding the commit messages are stored in; git itself + Character encoding the commit messages are stored in; Git itself does not care per se, but this information is necessary e.g. when importing commits from emails or in the gitk graphical history browser (and possibly at other places in the future or in other @@ -1599,7 +1621,7 @@ mergetool.keepBackup:: `true` (i.e. keep the backup files). mergetool.keepTemporaries:: - When invoking a custom merge tool, git uses a set of temporary + When invoking a custom merge tool, Git uses a set of temporary files to pass to the tool. If the tool returns an error and this variable is set to `true`, then these temporary files will be preserved, otherwise they will be removed after the tool has @@ -1627,7 +1649,7 @@ displayed. notes.rewrite.<command>:: When rewriting commits with <command> (currently `amend` or - `rebase`) and this variable is set to `true`, git + `rebase`) and this variable is set to `true`, Git automatically copies your notes from the original to the rewritten commit. Defaults to `true`, but see "notes.rewriteRef" below. @@ -1707,7 +1729,7 @@ pack.threads:: warning. This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. - Specifying 0 will cause git to auto-detect the number of CPU's + Specifying 0 will cause Git to auto-detect the number of CPU's and set the number of threads accordingly. pack.indexVersion:: @@ -1719,11 +1741,11 @@ pack.indexVersion:: and this config option ignored whenever the corresponding pack is larger than 2 GB. + -If you have an old git that does not understand the version 2 `*.idx` file, +If you have an old Git that does not understand the version 2 `*.idx` file, cloning or fetching over a non native protocol (e.g. "http" and "rsync") that will copy both `*.pack` file and corresponding `*.idx` file from the other side may give you a repository that cannot be accessed with your -older version of git. If the `*.pack` file is smaller than 2 GB, however, +older version of Git. If the `*.pack` file is smaller than 2 GB, however, you can use linkgit:git-index-pack[1] on the *.pack file to regenerate the `*.idx` file. @@ -1738,7 +1760,7 @@ pack.packSizeLimit:: pager.<cmd>:: If the value is boolean, turns on or off pagination of the - output of a particular git subcommand when writing to a tty. + output of a particular Git subcommand when writing to a tty. Otherwise, turns on pagination for the subcommand using the pager specified by the value of `pager.<cmd>`. If `--paginate` or `--no-pager` is specified on the command line, it takes @@ -1773,7 +1795,7 @@ pull.twohead:: The default merge strategy to use when pulling a single branch. push.default:: - Defines the action git push should take if no refspec is given + Defines the action `git push` should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line. Possible values are: @@ -1913,7 +1935,7 @@ remote.<name>.tagopt:: linkgit:git-fetch[1]. remote.<name>.vcs:: - Setting this to a value <vcs> will cause git to interact with + Setting this to a value <vcs> will cause Git to interact with the remote with the git-remote-<vcs> helper. remotes.<group>:: @@ -1923,9 +1945,9 @@ remotes.<group>:: repack.usedeltabaseoffset:: By default, linkgit:git-repack[1] creates packs that use delta-base offset. If you need to share your repository with - git older than version 1.4.4, either directly or via a dumb + Git older than version 1.4.4, either directly or via a dumb protocol such as http, then you need to set this option to - "false" and repack. Access from old git versions over the + "false" and repack. Access from old Git versions over the native protocol are unaffected by this option. rerere.autoupdate:: @@ -1994,7 +2016,7 @@ showbranch.default:: status.relativePaths:: By default, linkgit:git-status[1] shows paths relative to the current directory. Setting this variable to `false` shows paths - relative to the repository root (this was the default for git + relative to the repository root (this was the default for Git prior to v1.5.4). status.showUntrackedFiles:: @@ -2081,7 +2103,7 @@ url.<base>.insteadOf:: large number of repositories, and serves them with multiple access methods, and some users need to use different access methods, this feature allows people to specify any of the - equivalent URLs and have git automatically rewrite the URL to + equivalent URLs and have Git automatically rewrite the URL to the best alternative for the particular user, even for a never-before-seen repository on the site. When more than one insteadOf strings match a given URL, the longest match is used. @@ -2092,11 +2114,11 @@ url.<base>.pushInsteadOf:: resulting URL will be pushed to. In cases where some site serves a large number of repositories, and serves them with multiple access methods, some of which do not allow push, this feature - allows people to specify a pull-only URL and have git + allows people to specify a pull-only URL and have Git automatically use an appropriate URL to push, even for a never-before-seen repository on the site. When more than one pushInsteadOf strings match a given URL, the longest match is - used. If a remote has an explicit pushurl, git will ignore this + used. If a remote has an explicit pushurl, Git will ignore this setting for that remote. user.email:: diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt index 4314ad0fbb..7c70c2a2fe 100644 --- a/Documentation/diff-config.txt +++ b/Documentation/diff-config.txt @@ -99,7 +99,7 @@ diff.renameLimit:: detection; equivalent to the 'git diff' option '-l'. diff.renames:: - Tells git to detect renames. If set to any boolean value, it + Tells Git to detect renames. If set to any boolean value, it will enable basic rename detection. If set to "copies" or "copy", it will detect copies, as well. @@ -149,9 +149,10 @@ diff.<driver>.cachetextconv:: conversion outputs. See linkgit:gitattributes[5] for details. diff.tool:: - The diff tool to be used by linkgit:git-difftool[1]. This - option overrides `merge.tool`, and has the same valid built-in - values as `merge.tool` minus "tortoisemerge" and plus - "kompare". Any other value is treated as a custom diff tool, - and there must be a corresponding `difftool.<tool>.cmd` - option. + Controls which diff tool is used by linkgit:git-difftool[1]. + This variable overrides the value configured in `merge.tool`. + The list below shows the valid built-in values. + Any other value is treated as a custom diff tool and requires + that a corresponding difftool.<tool>.cmd variable is defined. + +include::mergetools-diff.txt[] diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 39f2c5074c..7a87473526 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -283,7 +283,7 @@ few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number `m` controls this aspect of the -B option (defaults to 60%). `-B/70%` specifies that less than 30% of the -original should remain in the result for git to consider it a total +original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines). + @@ -307,7 +307,7 @@ ifdef::git-log[] endif::git-log[] If `n` is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the - file's size). For example, `-M90%` means git should consider a + file's size). For example, `-M90%` means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn't changed. Without a `%` sign, the number is to be read as a fraction, with a decimal point before it. I.e., `-M5` becomes diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 048337b40f..e1fba85660 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -1,4 +1,4 @@ -Everyday GIT With 20 Commands Or So +Everyday Git With 20 Commands Or So =================================== <<Individual Developer (Standalone)>> commands are essential for @@ -12,7 +12,7 @@ commands in addition to the above. <<Repository Administration>> commands are for system administrators who are responsible for the care and feeding -of git repositories. +of Git repositories. Individual Developer (Standalone)[[Individual Developer (Standalone)]] @@ -87,7 +87,7 @@ $ git log v2.43.. curses/ <12> + <1> create a new topic branch. <2> revert your botched changes in `curses/ux_audio_oss.c`. -<3> you need to tell git if you added a new file; removal and +<3> you need to tell Git if you added a new file; removal and modification will be caught if you do `git commit -a` later. <4> to see what changes you are committing. <5> commit everything as you have tested, with your sign-off. @@ -229,7 +229,7 @@ commands in addition to the ones needed by participants. Examples ~~~~~~~~ -My typical GIT day.:: +My typical Git day.:: + ------------ $ git status <1> @@ -332,7 +332,7 @@ Run git-daemon to serve /pub/scm from xinetd.:: ------------ $ cat /etc/xinetd.d/git-daemon # default: off -# description: The git server offers access to git repositories +# description: The Git server offers access to Git repositories service git { disable = no diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 6e98bdf149..9cb649673d 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -8,11 +8,15 @@ option old data in `.git/FETCH_HEAD` will be overwritten. --depth=<depth>:: - Deepen the history of a 'shallow' repository created by + Deepen or shorten the history of a 'shallow' repository created by `git clone` with `--depth=<depth>` option (see linkgit:git-clone[1]) to the specified number of commits from the tip of each remote branch history. Tags for the deepened commits are not fetched. +--unshallow:: + Convert a shallow repository to a complete one, removing all + the limitations imposed by shallow repositories. + ifndef::git-pull[] --dry-run:: Show what would be done, without making any changes. diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index fd9e36b99f..533355984c 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -107,9 +107,10 @@ apply to the index. See EDITING PATCHES below. from the index if the corresponding files in the working tree have been removed. + -If no <filepattern> is given, default to "."; in other words, -update all tracked files in the current directory and its -subdirectories. +If no <filepattern> is given, the current version of Git defaults to +"."; in other words, update all tracked files in the current directory +and its subdirectories. This default will change in a future version +of Git, hence the form without <filepattern> should not be used. -A:: --all:: diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt index 634b84e4b9..f605327946 100644 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@ -24,7 +24,7 @@ Reads the supplied diff output (i.e. "a patch") and applies it to files. With the `--index` option the patch is also applied to the index, and with the `--cached` option the patch is only applied to the index. Without these options, the command applies the patch only to files, -and does not require them to be in a git repository. +and does not require them to be in a Git repository. This command applies the patch but does not create a commit. Use linkgit:git-am[1] to create commits from patches generated by @@ -198,7 +198,7 @@ behavior: * `fix` outputs warnings for a few such errors, and applies the patch after fixing them (`strip` is a synonym --- the tool used to consider only trailing whitespace characters as errors, and the - fix involved 'stripping' them, but modern gits do more). + fix involved 'stripping' them, but modern Gits do more). * `error` outputs warnings for a few such errors, and refuses to apply the patch. * `error-all` is similar to `error` but shows all errors. diff --git a/Documentation/git-archimport.txt b/Documentation/git-archimport.txt index f4504ba9bf..163b9f6f41 100644 --- a/Documentation/git-archimport.txt +++ b/Documentation/git-archimport.txt @@ -3,7 +3,7 @@ git-archimport(1) NAME ---- -git-archimport - Import an Arch repository into git +git-archimport - Import an Arch repository into Git SYNOPSIS @@ -40,13 +40,13 @@ directory. To follow the development of a project that uses Arch, rerun 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> +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 +branch names and convert Arch jargon to Git jargon, for example mapping a "PROJECT{litdd}devo{litdd}VERSION" branch to "master". -Associating multiple Arch branches to one git branch is possible; the +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. @@ -54,14 +54,14 @@ convert Arch repositories that had been rotated periodically. MERGES ------ -Patch merge data from Arch is used to mark merges in git as well. git +Patch merge data from Arch is used to mark merges in Git as well. Git does not care much about tracking patches, and only considers a merge when a branch incorporates all the commits since the point they forked. The end result -is that git will have a good idea of how far branches have diverged. So the +is that Git will have a good idea of how far branches have diverged. So the import process does lose some patch-trading metadata. Fortunately, when you try and merge branches imported from Arch, -git will find a good merge base, and it has a good chance of identifying +Git will find a good merge base, and it has a good chance of identifying patches that have been traded out-of-sequence between the branches. OPTIONS diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt index 59d73e532f..b4c2e24849 100644 --- a/Documentation/git-archive.txt +++ b/Documentation/git-archive.txt @@ -128,7 +128,7 @@ export-ignore:: added to archive files. See linkgit:gitattributes[5] for details. export-subst:: - If the attribute export-subst is set for a file then git will + If the attribute export-subst is set for a file then Git will expand several placeholders when adding this file to an archive. See linkgit:gitattributes[5] for details. diff --git a/Documentation/git-bisect-lk2009.txt b/Documentation/git-bisect-lk2009.txt index ec4497e098..0eed3e3f29 100644 --- a/Documentation/git-bisect-lk2009.txt +++ b/Documentation/git-bisect-lk2009.txt @@ -224,7 +224,7 @@ Note that the example that we will use is really a toy example, we will be looking for the first commit that has a version like "2.6.26-something", that is the commit that has a "SUBLEVEL = 26" line in the top level Makefile. This is a toy example because there are -better ways to find this commit with git than using "git bisect" (for +better ways to find this commit with Git than using "git bisect" (for example "git blame" or "git log -S<string>"). Driving a bisection manually @@ -455,7 +455,7 @@ So only the W and B commits will be kept. Because commits X and Y will have been removed by rules a) and b) respectively, and because commits G are removed by rule b) too. -Note for git users, that it is equivalent as keeping only the commit +Note for Git users, that it is equivalent as keeping only the commit given by: ------------- @@ -710,8 +710,8 @@ Skip algorithm discussed After step 7) (in the skip algorithm), we could check if the second commit has been skipped and return it if it is not the case. And in fact that was the algorithm we used from when "git bisect skip" was -developed in git version 1.5.4 (released on February 1st 2008) until -git version 1.6.4 (released July 29th 2009). +developed in Git version 1.5.4 (released on February 1st 2008) until +Git version 1.6.4 (released July 29th 2009). But Ingo Molnar and H. Peter Anvin (another well known linux kernel developer) both complained that sometimes the best bisection points @@ -1025,10 +1025,10 @@ And here is what Andreas said about this work-flow <<5>>: _____________ To give some hard figures, we used to have an average report-to-fix cycle of 142.6 hours (according to our somewhat weird bug-tracker -which just measures wall-clock time). Since we moved to git, we've +which just measures wall-clock time). Since we moved to Git, we've lowered that to 16.2 hours. Primarily because we can stay on top of the bug fixing now, and because everyone's jockeying to get to fix -bugs (we're quite proud of how lazy we are to let git find the bugs +bugs (we're quite proud of how lazy we are to let Git find the bugs for us). Each new release results in ~40% fewer bugs (almost certainly due to how we now feel about writing tests). _____________ @@ -1228,9 +1228,9 @@ commits in already released history, for example to change the commit message or the author. And it can also be used instead of git "grafts" to link a repository with another old repository. -In fact it's this last feature that "sold" it to the git community, so -it is now in the "master" branch of git's git repository and it should -be released in git 1.6.5 in October or November 2009. +In fact it's this last feature that "sold" it to the Git community, so +it is now in the "master" branch of Git's Git repository and it should +be released in Git 1.6.5 in October or November 2009. One problem with "git replace" is that currently it stores all the replacements refs in "refs/replace/", but it would be perhaps better @@ -1324,7 +1324,7 @@ Acknowledgements ---------------- Many thanks to Junio Hamano for his help in reviewing this paper, for -reviewing the patches I sent to the git mailing list, for discussing +reviewing the patches I sent to the Git mailing list, for discussing some ideas and helping me improve them, for improving "git bisect" a lot and for his awesome work in maintaining and developing Git. @@ -1337,7 +1337,7 @@ Many thanks to Linus Torvalds for inventing, developing and evangelizing "git bisect", Git and Linux. Many thanks to the many other great people who helped one way or -another when I worked on git, especially to Andreas Ericsson, Johannes +another when I worked on Git, especially to Andreas Ericsson, Johannes Schindelin, H. Peter Anvin, Daniel Barkalow, Bill Lear, John Hawley, Shawn O. Pierce, Jeff King, Sam Vilain, Jon Seymour. diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt index e4f46bc18d..b4831bb0cf 100644 --- a/Documentation/git-bisect.txt +++ b/Documentation/git-bisect.txt @@ -169,14 +169,14 @@ the revision as good or bad in the usual manner. Bisect skip ~~~~~~~~~~~~ -Instead of choosing by yourself a nearby commit, you can ask git +Instead of choosing by yourself a nearby commit, you can ask Git to do it for you by issuing the command: ------------ $ git bisect skip # Current version cannot be tested ------------ -But git may eventually be unable to tell the first bad commit among +But Git may eventually be unable to tell the first bad commit among a bad commit and one or more skipped commits. You can even skip a range of commits, instead of just one commit, diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt index e44173f66a..9a05c2b3d2 100644 --- a/Documentation/git-blame.txt +++ b/Documentation/git-blame.txt @@ -30,7 +30,7 @@ The report does not tell you anything about lines which have been deleted or replaced; you need to use a tool such as 'git diff' or the "pickaxe" interface briefly mentioned in the following paragraph. -Apart from supporting file annotation, git also supports searching the +Apart from supporting file annotation, Git also supports searching the development history for when a code snippet occurred in a change. This makes it possible to track when a code snippet was added to a file, moved or copied between files, and eventually deleted or replaced. It works by searching for diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 45a225e0aa..b7cb625b89 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -22,13 +22,15 @@ SYNOPSIS DESCRIPTION ----------- -With no arguments, existing branches are listed and the current branch will -be highlighted with an asterisk. Option `-r` causes the remote-tracking -branches to be listed, and option `-a` shows both. This list mode is also -activated by the `--list` option (see below). -<pattern> restricts the output to matching branches, the pattern is a shell -wildcard (i.e., matched using fnmatch(3)). -Multiple patterns may be given; if any of them matches, the branch is shown. +If `--list` is given, or if there are no non-option arguments, existing +branches are listed; the current branch will be highlighted with an +asterisk. Option `-r` causes the remote-tracking branches to be listed, +and option `-a` shows both local and remote branches. If a `<pattern>` +is given, it is used as a shell wildcard to restrict the output to +matching branches. If multiple patterns are given, a branch is shown if +it matches any of the patterns. Note that when providing a +`<pattern>`, you must use `--list`; otherwise the command is interpreted +as branch creation. With `--contains`, shows only the branches that contain the named commit (in other words, the branches whose tip commits are descendants of the @@ -45,7 +47,7 @@ Note that this will create the new branch, but it will not switch the working tree to it; use "git checkout <newbranch>" to switch to the new branch. -When a local branch is started off a remote-tracking branch, git sets up the +When a local branch is started off a remote-tracking branch, Git sets up the branch so that 'git pull' will appropriately merge from the remote-tracking branch. This behavior may be changed via the global `branch.autosetupmerge` configuration flag. That setting can be @@ -193,15 +195,15 @@ start-point is either a local or remote-tracking branch. --contains [<commit>]:: Only list branches which contain the specified commit (HEAD - if not specified). + if not specified). Implies `--list`. --merged [<commit>]:: Only list branches whose tips are reachable from the - specified commit (HEAD if not specified). + specified commit (HEAD if not specified). Implies `--list`. --no-merged [<commit>]:: Only list branches whose tips are not reachable from the - specified commit (HEAD if not specified). + specified commit (HEAD if not specified). Implies `--list`. <branchname>:: The name of the branch to create or delete. diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt index bc023cc5f3..0417562eb7 100644 --- a/Documentation/git-bundle.txt +++ b/Documentation/git-bundle.txt @@ -19,7 +19,7 @@ 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, and therefore the interactive git protocols (git, +be directly connected, and therefore 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 diff --git a/Documentation/git-check-ignore.txt b/Documentation/git-check-ignore.txt new file mode 100644 index 0000000000..854e4d0c42 --- /dev/null +++ b/Documentation/git-check-ignore.txt @@ -0,0 +1,89 @@ +git-check-ignore(1) +=================== + +NAME +---- +git-check-ignore - Debug gitignore / exclude files + + +SYNOPSIS +-------- +[verse] +'git check-ignore' [options] pathname... +'git check-ignore' [options] --stdin < <list-of-paths> + +DESCRIPTION +----------- + +For each pathname given via the command-line or from a file via +`--stdin`, show the pattern from .gitignore (or other input files to +the exclude mechanism) that decides if the pathname is excluded or +included. Later patterns within a file take precedence over earlier +ones. + +OPTIONS +------- +-q, --quiet:: + Don't output anything, just set exit status. This is only + valid with a single pathname. + +-v, --verbose:: + Also output details about the matching pattern (if any) + for each given pathname. + +--stdin:: + Read file names from stdin instead of from the command-line. + +-z:: + The output format is modified to be machine-parseable (see + below). If `--stdin` is also given, input paths are separated + with a NUL character instead of a linefeed character. + +OUTPUT +------ + +By default, any of the given pathnames which match an ignore pattern +will be output, one per line. If no pattern matches a given path, +nothing will be output for that path; this means that path will not be +ignored. + +If `--verbose` is specified, the output is a series of lines of the form: + +<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname> + +<pathname> is the path of a file being queried, <pattern> is the +matching pattern, <source> is the pattern's source file, and <linenum> +is the line number of the pattern within that source. If the pattern +contained a `!` prefix or `/` suffix, it will be preserved in the +output. <source> will be an absolute path when referring to the file +configured by `core.excludesfile`, or relative to the repository root +when referring to `.git/info/exclude` or a per-directory exclude file. + +If `-z` is specified, the pathnames in the output are delimited by the +null character; if `--verbose` is also specified then null characters +are also used instead of colons and hard tabs: + +<source> <NULL> <linenum> <NULL> <pattern> <NULL> <pathname> <NULL> + + +EXIT STATUS +----------- + +0:: + One or more of the provided paths is ignored. + +1:: + None of the provided paths are ignored. + +128:: + A fatal error was encountered. + +SEE ALSO +-------- +linkgit:gitignore[5] +linkgit:gitconfig[5] +linkgit:git-ls-files[5] + +GIT +--- +Part of the linkgit:git[1] suite diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt index 98009d1bd5..ec1739a896 100644 --- a/Documentation/git-check-ref-format.txt +++ b/Documentation/git-check-ref-format.txt @@ -18,14 +18,14 @@ DESCRIPTION Checks if a given 'refname' is acceptable, and exits with a non-zero status if it is not. -A reference is used in git to specify branches and tags. A +A reference is used in Git to specify branches and tags. A branch head is stored in the `refs/heads` hierarchy, while a tag is stored in the `refs/tags` hierarchy of the ref namespace (typically in `$GIT_DIR/refs/heads` and `$GIT_DIR/refs/tags` directories or, as entries in file `$GIT_DIR/packed-refs` if refs are packed by `git gc`). -git imposes the following rules on how references are named: +Git imposes the following rules on how references are named: . They can include slash `/` for hierarchical (directory) grouping, but no slash-separated component can begin with a diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 6f04d22f5e..8edcdcae9d 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -333,7 +333,7 @@ a---b---c---d branch 'master' (refers to commit 'd') tag 'v2.0' (refers to commit 'b') ------------ -In fact, we can perform all the normal git operations. But, let's look +In fact, we can perform all the normal Git operations. But, let's look at what happens when we then checkout master: ------------ @@ -350,7 +350,7 @@ a---b---c---d branch 'master' (refers to commit 'd') It is important to realize that at this point nothing refers to commit 'f'. Eventually commit 'f' (and by extension commit 'e') will be deleted -by the routine git garbage collection process, unless we create a reference +by the routine Git garbage collection process, unless we create a reference before that happens. If we have not yet moved away from commit 'f', any of these will create a reference to it: diff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt index 9f42c0d0e6..bdc3ab80c7 100644 --- a/Documentation/git-clean.txt +++ b/Documentation/git-clean.txt @@ -16,7 +16,7 @@ DESCRIPTION Cleans the working tree by recursively removing files that are not under version control, starting from the current directory. -Normally, only files unknown to git are removed, but if the '-x' +Normally, only files unknown to Git are removed, but if the '-x' option is specified, ignored files are also removed. This can, for example, be useful to remove all build products. @@ -27,13 +27,13 @@ OPTIONS ------- -d:: Remove untracked directories in addition to untracked files. - If an untracked directory is managed by a different git + If an untracked directory is managed by a different Git repository, it is not removed by default. Use -f option twice if you really want to remove such a directory. -f:: --force:: - If the git configuration variable clean.requireForce is not set + If the Git configuration variable clean.requireForce is not set to false, 'git clean' will refuse to run unless given -f or -n. -n:: @@ -60,7 +60,7 @@ OPTIONS working directory to test a clean build. -X:: - Remove only files ignored by git. This may be useful to rebuild + Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files. SEE ALSO diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 7fefdb0384..5c16e317f6 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -43,7 +43,7 @@ OPTIONS --local:: -l:: When the repository to clone from is on a local machine, - this flag bypasses the normal "git aware" transport + this flag bypasses the normal "Git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under `.git/objects/` directory are hardlinked @@ -54,11 +54,11 @@ this is the default, and --local is essentially a no-op. If the repository is specified as a URL, then this flag is ignored (and we never use the local optimizations). Specifying `--no-local` will override the default when `/path/to/repo` is given, using the regular -git transport instead. +Git transport instead. + To force copying instead of hardlinking (which may be desirable if you are trying to make a back-up of your repository), but still avoid the -usual "git aware" transport mechanism, `--no-hardlinks` can be used. +usual "Git aware" transport mechanism, `--no-hardlinks` can be used. --no-hardlinks:: Optimize the cloning process from a repository on a @@ -76,9 +76,9 @@ usual "git aware" transport mechanism, `--no-hardlinks` can be used. *NOTE*: this is a possibly dangerous operation; do *not* use it unless you understand what it does. If you clone your repository using this option and then delete branches (or use any -other git command that makes any existing commit unreferenced) in the +other Git command that makes any existing commit unreferenced) in the source repository, some objects may become unreferenced (or dangling). -These objects may be removed by normal git operations (such as `git commit`) +These objects may be removed by normal Git operations (such as `git commit`) which automatically call `git gc --auto`. (See linkgit:git-gc[1].) If these objects are removed and were referenced by the cloned repository, then the cloned repository will become corrupt. @@ -125,7 +125,7 @@ objects from the source repository into a pack in the cloned repository. No checkout of HEAD is performed after the clone is complete. --bare:: - Make a 'bare' GIT repository. That is, instead of + Make a 'bare' Git repository. That is, instead of creating `<directory>` and placing the administrative files in `<directory>/.git`, make the `<directory>` itself the `$GIT_DIR`. This obviously implies the `-n` @@ -213,8 +213,8 @@ objects from the source repository into a pack in the cloned repository. --separate-git-dir=<git dir>:: Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, - then make a filesytem-agnostic git symbolic link to there. - The result is git repository can be separated from working + then make a filesytem-agnostic Git symbolic link to there. + The result is Git repository can be separated from working tree. diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt index a221169515..86ef56e7c8 100644 --- a/Documentation/git-commit-tree.txt +++ b/Documentation/git-commit-tree.txt @@ -30,7 +30,7 @@ While a tree represents a particular directory state of a working directory, a commit represents that state in "time", and explains how to get there. -Normally a commit would identify a new "HEAD" state, and while git +Normally a commit would identify a new "HEAD" state, and while Git doesn't care where you save the note about that state, in practice we tend to just write the result to the file that is pointed at by `.git/HEAD`, so that we can always see what the last committed diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 41b27da325..0eb79ccdba 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -32,7 +32,7 @@ The content to be added can be specified in several ways: 3. by listing files as arguments to the 'commit' command, in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already - be known to git); + be known to Git); 4. by using the -a switch with the 'commit' command to automatically "add" changes from all known files (i.e. all files that are already @@ -59,7 +59,7 @@ OPTIONS --all:: Tell the command to automatically stage files that have been modified and deleted, but new files you have not - told git about are not affected. + told Git about are not affected. -p:: --patch:: @@ -404,7 +404,7 @@ Though not required, it's a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated -as the commit title, and that title is used throughout git. +as the commit title, and that title is used throughout Git. For example, linkgit:git-format-patch[1] turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body. diff --git a/Documentation/git-credential-cache.txt b/Documentation/git-credential-cache.txt index eeff5fa989..89b730632d 100644 --- a/Documentation/git-credential-cache.txt +++ b/Documentation/git-credential-cache.txt @@ -14,13 +14,13 @@ git config credential.helper 'cache [options]' DESCRIPTION ----------- -This command caches credentials in memory for use by future git +This command caches credentials in memory for use by future Git programs. The stored credentials never touch the disk, and are forgotten after a configurable timeout. The cache is accessible over a Unix domain socket, restricted to the current user by filesystem permissions. You probably don't want to invoke this command directly; it is meant to -be used as a credential helper by other parts of git. See +be used as a credential helper by other parts of Git. See linkgit:gitcredentials[7] or `EXAMPLES` below. OPTIONS diff --git a/Documentation/git-credential-store.txt b/Documentation/git-credential-store.txt index b27c03c361..8481cae70e 100644 --- a/Documentation/git-credential-store.txt +++ b/Documentation/git-credential-store.txt @@ -20,7 +20,7 @@ security tradeoff, try linkgit:git-credential-cache[1], or find a helper that integrates with secure storage provided by your operating system. This command stores credentials indefinitely on disk for use by future -git programs. +Git programs. You probably don't want to invoke this command directly; it is meant to be used as a credential helper by other parts of git. See @@ -63,11 +63,11 @@ stored on its own line as a URL like: https://user:pass@example.com ------------------------------ -When git needs authentication for a particular URL context, +When Git needs authentication for a particular URL context, credential-store will consider that context a pattern to match against each entry in the credentials file. If the protocol, hostname, and username (if we already have one) match, then the password is returned -to git. See the discussion of configuration in linkgit:gitcredentials[7] +to Git. See the discussion of configuration in linkgit:gitcredentials[7] for more information. GIT diff --git a/Documentation/git-credential.txt b/Documentation/git-credential.txt index 810e957124..472f00f607 100644 --- a/Documentation/git-credential.txt +++ b/Documentation/git-credential.txt @@ -18,9 +18,9 @@ Git has an internal interface for storing and retrieving credentials from system-specific helpers, as well as prompting the user for usernames and passwords. The git-credential command exposes this interface to scripts which may want to retrieve, store, or prompt for -credentials in the same manner as git. The design of this scriptable +credentials in the same manner as Git. The design of this scriptable interface models the internal C API; see -link:technical/api-credentials.txt[the git credential API] for more +link:technical/api-credentials.txt[the Git credential API] for more background on the concepts. git-credential takes an "action" option on the command-line (one of @@ -74,7 +74,7 @@ infomation it has): password=secr3t + In most cases, this means the attributes given in the input will be -repeated in the output, but git may also modify the credential +repeated in the output, but Git may also modify the credential description, for example by removing the `path` attribute when the protocol is HTTP(s) and `credential.useHttpPath` is false. + diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt index 7f79cec3f8..00154b6c85 100644 --- a/Documentation/git-cvsexportcommit.txt +++ b/Documentation/git-cvsexportcommit.txt @@ -15,8 +15,8 @@ SYNOPSIS DESCRIPTION ----------- -Exports a commit from GIT to a CVS checkout, making it easier -to merge patches from a git repository into a CVS repository. +Exports a commit from Git to a CVS checkout, making it easier +to merge patches from a Git repository into a CVS repository. Specify the name of a CVS checkout using the -w switch or execute it from the root of the CVS working copy. In the latter case GIT_DIR must @@ -71,7 +71,7 @@ OPTIONS -w:: Specify the location of the CVS checkout to use for the export. This option does not require GIT_DIR to be set before execution if the - current directory is within a git repository. The default is the + current directory is within a Git repository. The default is the value of 'cvsexportcommit.cvsdir'. -W:: diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt index 9d5353e8be..d1bcda28f4 100644 --- a/Documentation/git-cvsimport.txt +++ b/Documentation/git-cvsimport.txt @@ -18,7 +18,13 @@ SYNOPSIS DESCRIPTION ----------- -Imports a CVS repository into git. It will either create a new +*WARNING:* `git cvsimport` uses cvsps version 2, which is considered +deprecated; it does not work with cvsps version 3 and later. If you are +performing a one-shot import of a CVS repository consider using +link:http://cvs2svn.tigris.org/cvs2git.html[cvs2git] or +link:https://github.com/BartMassey/parsecvs[parsecvs]. + +Imports a CVS repository into Git. It will either create a new repository, or incrementally import into an existing one. Splitting the CVS log into patch sets is done by 'cvsps'. @@ -59,18 +65,18 @@ OPTIONS `CVS/Repository`. -C <target-dir>:: - The git repository to import to. If the directory doesn't + The Git repository to import to. If the directory doesn't exist, it will be created. Default is the current directory. -r <remote>:: - The git remote to import this CVS repository into. + The Git remote to import this CVS repository into. Moves all CVS branches into remotes/<remote>/<branch> akin to the way 'git clone' uses 'origin' by default. -o <branch-for-HEAD>:: When no remote is specified (via -r) the 'HEAD' branch - from CVS is imported to the 'origin' branch within the git - repository, as 'HEAD' already has a special meaning for git. + from CVS is imported to the 'origin' branch within the Git + repository, as 'HEAD' already has a special meaning for Git. When a remote is specified the 'HEAD' branch is named remotes/<remote>/master mirroring 'git clone' behaviour. Use this option if you want to import into a different diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt index 88d814af0e..472f5cbd07 100644 --- a/Documentation/git-cvsserver.txt +++ b/Documentation/git-cvsserver.txt @@ -3,7 +3,7 @@ git-cvsserver(1) NAME ---- -git-cvsserver - A CVS server emulator for git +git-cvsserver - A CVS server emulator for Git SYNOPSIS -------- @@ -60,7 +60,7 @@ unless '--export-all' was given, too. DESCRIPTION ----------- -This application is a CVS emulation layer for git. +This application is a CVS emulation layer for Git. It is highly functional. However, not all methods are implemented, and for those methods that are implemented, @@ -72,9 +72,9 @@ plugin. Most functionality works fine with both of these clients. LIMITATIONS ----------- -CVS clients cannot tag, branch or perform GIT merges. +CVS clients cannot tag, branch or perform Git merges. -'git-cvsserver' maps GIT branches to CVS modules. This is very different +'git-cvsserver' maps Git branches to CVS modules. This is very different from what most CVS users would expect since in CVS modules usually represent one or more directories. @@ -130,7 +130,7 @@ Then provide your password via the pserver method, for example: ------ cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name> ------ -No special setup is needed for SSH access, other than having GIT tools +No special setup is needed for SSH access, other than having Git tools in the PATH. If you have clients that do not accept the CVS_SERVER environment variable, you can rename 'git-cvsserver' to `cvs`. @@ -160,9 +160,9 @@ with CVS_SERVER (and shouldn't) as 'git-shell' understands `cvs` to mean Note: you need to ensure each user that is going to invoke 'git-cvsserver' has write access to the log file and to the database (see <<dbbackend,Database Backend>>. If you want to offer write access over -SSH, the users of course also need write access to the git repository itself. +SSH, the users of course also need write access to the Git repository itself. -You also need to ensure that each repository is "bare" (without a git index +You also need to ensure that each repository is "bare" (without a Git index file) for `cvs commit` to work. See linkgit:gitcvs-migration[7]. [[configaccessmethod]] @@ -181,7 +181,7 @@ allowing access over SSH. 3. If you didn't specify the CVSROOT/CVS_SERVER directly in the checkout command, automatically saving it in your 'CVS/Root' files, then you need to set them explicitly in your environment. CVSROOT should be set as per normal, but the - directory should point at the appropriate git repo. As above, for SSH clients + directory should point at the appropriate Git repo. As above, for SSH clients _not_ restricted to 'git-shell', CVS_SERVER should be set to 'git-cvsserver'. + -- @@ -197,7 +197,7 @@ allowing access over SSH. shell is bash, .bashrc may be a reasonable alternative. 5. Clients should now be able to check out the project. Use the CVS 'module' - name to indicate what GIT 'head' you want to check out. This also sets the + name to indicate what Git 'head' you want to check out. This also sets the name of your newly checked-out directory, unless you tell it otherwise with `-d <dir_name>`. For example, this checks out 'master' branch to the `project-master` directory: @@ -210,7 +210,7 @@ allowing access over SSH. Database Backend ---------------- -'git-cvsserver' uses one database per git head (i.e. CVS module) to +'git-cvsserver' uses one database per Git head (i.e. CVS module) to store information about the repository to maintain consistent CVS revision numbers. The database needs to be updated (i.e. written to) after every commit. @@ -225,7 +225,7 @@ the pserver method), 'git-cvsserver' should have write access to the database to work reliably (otherwise you need to make sure that the database is up-to-date any time 'git-cvsserver' is executed). -By default it uses SQLite databases in the git directory, named +By default it uses SQLite databases in the Git directory, named `gitcvs.<module_name>.sqlite`. Note that the SQLite backend creates temporary files in the same directory as the database file on write so it might not be enough to grant the users using @@ -291,14 +291,14 @@ Variable substitution In `dbdriver` and `dbuser` you can use the following variables: %G:: - git directory name + Git directory name %g:: - git directory name, where all characters except for + Git directory name, where all characters except for alpha-numeric ones, `.`, and `-` are replaced with `_` (this should make it easier to use the directory name in a filename if wanted) %m:: - CVS module/git head name + CVS module/Git head name %a:: access method (one of "ext" or "pserver") %u:: @@ -359,6 +359,43 @@ Operations supported All the operations required for normal use are supported, including checkout, diff, status, update, log, add, remove, commit. + +Most CVS command arguments that read CVS tags or revision numbers +(typically -r) work, and also support any git refspec +(tag, branch, commit ID, etc). +However, CVS revision numbers for non-default branches are not well +emulated, and cvs log does not show tags or branches at +all. (Non-main-branch CVS revision numbers superficially resemble CVS +revision numbers, but they actually encode a git commit ID directly, +rather than represent the number of revisions since the branch point.) + +Note that there are two ways to checkout a particular branch. +As described elsewhere on this page, the "module" parameter +of cvs checkout is interpreted as a branch name, and it becomes +the main branch. It remains the main branch for a given sandbox +even if you temporarily make another branch sticky with +cvs update -r. Alternatively, the -r argument can indicate +some other branch to actually checkout, even though the module +is still the "main" branch. Tradeoffs (as currently +implemented): Each new "module" creates a new database on disk with +a history for the given module, and after the database is created, +operations against that main branch are fast. Or alternatively, +-r doesn't take any extra disk space, but may be significantly slower for +many operations, like cvs update. + +If you want to refer to a git refspec that has characters that are +not allowed by CVS, you have two options. First, it may just work +to supply the git refspec directly to the appropriate CVS -r argument; +some CVS clients don't seem to do much sanity checking of the argument. +Second, if that fails, you can use a special character escape mechanism +that only uses characters that are valid in CVS tags. A sequence +of 4 or 5 characters of the form (underscore (`"_"`), dash (`"-"`), +one or two characters, and dash (`"-"`)) can encode various characters based +on the one or two letters: `"s"` for slash (`"/"`), `"p"` for +period (`"."`), `"u"` for underscore (`"_"`), or two hexadecimal digits +for any byte value at all (typically an ASCII number, or perhaps a part +of a UTF-8 encoded character). + Legacy monitoring operations are not supported (edit, watch and related). Exports and tagging (tags and branches) are not supported at this stage. diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index 7e5098a95e..77da564134 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -3,7 +3,7 @@ git-daemon(1) NAME ---- -git-daemon - A really simple server for git repositories +git-daemon - A really simple server for Git repositories SYNOPSIS -------- @@ -22,12 +22,12 @@ SYNOPSIS DESCRIPTION ----------- -A really simple TCP git daemon that normally listens on port "DEFAULT_GIT_PORT" +A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT" aka 9418. It waits for a connection asking for a service, and will serve that service if it is enabled. It verifies that the directory has the magic file "git-daemon-export-ok", and -it will refuse to export any git directory that hasn't explicitly been marked +it will refuse to export any Git directory that hasn't explicitly been marked for export this way (unless the '--export-all' parameter is specified). If you pass some directory paths as 'git daemon' arguments, you can further restrict the offers to a whitelist comprising of those. @@ -37,7 +37,7 @@ By default, only `upload-pack` service is enabled, which serves from 'git fetch', 'git pull', and 'git clone'. This is ideally suited for read-only updates, i.e., pulling from -git repositories. +Git repositories. An `upload-archive` also exists to serve 'git archive'. @@ -51,7 +51,7 @@ OPTIONS --base-path=<path>:: Remap all the path requests as relative to the given path. - This is sort of "GIT root" - if you run 'git daemon' with + This is sort of "Git root" - if you run 'git daemon' with '--base-path=/srv/git' on example.com, then if you later try to pull 'git://example.com/hello.git', 'git daemon' will interpret the path as '/srv/git/hello.git'. @@ -73,7 +73,7 @@ OPTIONS whitelist. --export-all:: - Allow pulling from all directories that look like GIT repositories + Allow pulling from all directories that look like Git repositories (have the 'objects' and 'refs' subdirectories), even if they do not have the 'git-daemon-export-ok' file. diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index 72d6bb612b..32da244fd5 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -131,7 +131,7 @@ closest tagname without any suffix: Note that the suffix you get if you type these commands today may be longer than what Linus saw above when he ran these commands, as your -git repository may have new commits whose object names begin with +Git repository may have new commits whose object names begin with 975b that did not exist back then, and "-g975b" suffix alone may not be sufficient to disambiguate these commits. diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index f8c06013f3..a7b46208f6 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -25,7 +25,7 @@ between two files on disk. This form is to view the changes you made relative to the index (staging area for the next commit). In other - words, the differences are what you _could_ tell git to + words, the differences are what you _could_ tell Git to further add to the index but you still haven't. You can stage these changes by using linkgit:git-add[1]. + diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt index 73ca7025a3..e0e12e9470 100644 --- a/Documentation/git-difftool.txt +++ b/Documentation/git-difftool.txt @@ -12,7 +12,7 @@ SYNOPSIS DESCRIPTION ----------- -'git difftool' is a git command that allows you to compare and edit files +'git difftool' is a Git command that allows you to compare and edit files between revisions using common diff tools. 'git difftool' is a frontend to 'git diff' and accepts the same options and arguments. See linkgit:git-diff[1]. diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt index 8c751202d7..b81e90d8e7 100644 --- a/Documentation/git-fetch-pack.txt +++ b/Documentation/git-fetch-pack.txt @@ -84,6 +84,8 @@ be in a separate packet, and the list must end with a flush packet. --depth=<n>:: Limit fetching to ancestor-chains not longer than n. + 'git-upload-pack' treats the special depth 2147483647 as + infinite even if there is an ancestor-chain that long. --no-progress:: Do not show the progress. diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt index b41d7c1de1..e08a028946 100644 --- a/Documentation/git-fetch.txt +++ b/Documentation/git-fetch.txt @@ -80,7 +80,7 @@ Using --recurse-submodules can only fetch new commits in already checked out submodules right now. When e.g. upstream added a new submodule in the just fetched commits of the superproject the submodule itself can not be fetched, making it impossible to check out that submodule later without -having to do a fetch again. This is expected to be fixed in a future git +having to do a fetch again. This is expected to be fixed in a future Git version. SEE ALSO diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt index e2301f5c01..dfd12c94e4 100644 --- a/Documentation/git-filter-branch.txt +++ b/Documentation/git-filter-branch.txt @@ -18,7 +18,7 @@ SYNOPSIS DESCRIPTION ----------- -Lets you rewrite git revision history by rewriting the branches mentioned +Lets you rewrite Git revision history by rewriting the branches mentioned in the <rev-list options>, applying custom filters on each revision. Those filters can modify each tree (e.g. removing a file or running a perl rewrite on all files) or information about each commit. @@ -29,7 +29,7 @@ The command will only rewrite the _positive_ refs mentioned in the command line (e.g. if you pass 'a..b', only 'b' will be rewritten). If you specify no filters, the commits will be recommitted without any changes, which would normally have no effect. Nevertheless, this may be -useful in the future for compensating for some git bugs or such, +useful in the future for compensating for some Git bugs or such, therefore such a usage is permitted. *NOTE*: This command honors `.git/info/grafts` file and refs in @@ -374,7 +374,7 @@ git-filter-branch is often used to get rid of a subset of files, usually with some combination of `--index-filter` and `--subdirectory-filter`. People expect the resulting repository to be smaller than the original, but you need a few more steps to -actually make it smaller, because git tries hard not to lose your +actually make it smaller, because Git tries hard not to lose your objects until you tell it to. First make sure that: * You really removed all variants of a filename, if a blob was moved diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 9a914d0159..3a62f50eda 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -208,14 +208,14 @@ The expected use case of this is to write supporting explanation for the commit that does not belong to the commit log message proper, and include it with the patch submission. While one can simply write these explanations after `format-patch` has run but before sending, -keeping them as git notes allows them to be maintained between versions +keeping them as Git notes allows them to be maintained between versions of the patch series (but see the discussion of the `notes.rewrite` configuration options in linkgit:git-notes[1] to use this workflow). --[no]-signature=<signature>:: Add a signature to each message produced. Per RFC 3676 the signature is separated from the body by a line with '-- ' on it. If the - signature option is omitted the signature defaults to the git version + signature option is omitted the signature defaults to the Git version number. --suffix=.<sfx>:: @@ -389,7 +389,7 @@ Thunderbird ~~~~~~~~~~~ By default, Thunderbird will both wrap emails as well as flag them as being 'format=flowed', both of which will make the -resulting email unusable by git. +resulting email unusable by Git. There are three different approaches: use an add-on to turn off line wraps, configure Thunderbird to not mangle patches, or use @@ -525,8 +525,8 @@ $ git format-patch -M -B origin Additionally, it detects and handles renames and complete rewrites intelligently to produce a renaming patch. A renaming patch reduces the amount of text output, and generally makes it easier to review. -Note that non-git "patch" programs won't understand renaming patches, so -use it only when you know the recipient uses git to apply your patch. +Note that non-Git "patch" programs won't understand renaming patches, so +use it only when you know the recipient uses Git to apply your patch. * Extract three topmost commits from the current branch and format them as e-mailable patches: diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt index da348fc942..eff91889d7 100644 --- a/Documentation/git-fsck.txt +++ b/Documentation/git-fsck.txt @@ -56,7 +56,7 @@ index file, all SHA1 references in `refs` namespace, and all reflogs ($GIT_DIR/objects), but also the ones found in alternate object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES or $GIT_DIR/objects/info/alternates, - and in packed git archives found in $GIT_DIR/objects/pack + and in packed Git archives found in $GIT_DIR/objects/pack and corresponding pack subdirectories in alternate object pools. This is now default; you can turn it off with --no-full. @@ -64,8 +64,8 @@ index file, all SHA1 references in `refs` namespace, and all reflogs --strict:: Enable more strict checking, namely to catch a file mode recorded with g+w bit set, which was created by older - versions of git. Existing repositories, including the - Linux kernel, git itself, and sparse repository have old + versions of Git. Existing repositories, including the + Linux kernel, Git itself, and sparse repository have old objects that triggers this check, but it is recommended to check new projects with this flag. diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index cfecf848fb..50d46e1a7b 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -61,7 +61,7 @@ OPTIONS blobs registered in the index file. --no-index:: - Search files in the current directory that is not managed by git. + Search files in the current directory that is not managed by Git. --untracked:: In addition to searching in the tracked files in the working diff --git a/Documentation/git-gui.txt b/Documentation/git-gui.txt index 0041994443..8144527ae0 100644 --- a/Documentation/git-gui.txt +++ b/Documentation/git-gui.txt @@ -102,7 +102,7 @@ Examples SEE ALSO -------- linkgit:gitk[1]:: - The git repository browser. Shows branches, commit history + The Git repository browser. Shows branches, commit history and file differences. gitk is the utility started by 'git gui''s Repository Visualize actions. diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index 4b0a502e8e..02c1f12685 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -40,7 +40,7 @@ OPTIONS --path:: Hash object as it were located at the given path. The location of file does not directly influence on the hash value, but path is - used to determine what git filters should be applied to the object + used to determine what Git filters should be applied to the object before it can be placed to the object database, and, as result of applying filters, the actual blob put into the object database may differ from the given file. This option is mainly useful for hashing diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt index 9e0b3f6811..e07b6dc19a 100644 --- a/Documentation/git-help.txt +++ b/Documentation/git-help.txt @@ -3,7 +3,7 @@ git-help(1) NAME ---- -git-help - display help information about git +git-help - Display help information about Git SYNOPSIS -------- @@ -14,13 +14,13 @@ DESCRIPTION ----------- With no options and no COMMAND given, the synopsis of the 'git' -command and a list of the most commonly used git commands are printed +command and a list of the most commonly used Git commands are printed on the standard output. If the option '--all' or '-a' is given, then all available commands are printed on the standard output. -If a git command is named, a manual page for that command is brought +If a Git subcommand is named, a manual page for that subcommand is brought up. The 'man' program is used by default for this purpose, but this can be overridden by other options or configuration variables. diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt index f4e0741c11..7b1e85cd15 100644 --- a/Documentation/git-http-backend.txt +++ b/Documentation/git-http-backend.txt @@ -19,7 +19,7 @@ and the backwards-compatible dumb HTTP protocol, as well as clients pushing using the smart HTTP protocol. It verifies that the directory has the magic file -"git-daemon-export-ok", and it will refuse to export any git directory +"git-daemon-export-ok", and it will refuse to export any Git directory that hasn't explicitly been marked for export this way (unless the GIT_HTTP_EXPORT_ALL environmental variable is set). diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt index 070cd1e6ed..21a33d2c41 100644 --- a/Documentation/git-http-fetch.txt +++ b/Documentation/git-http-fetch.txt @@ -3,7 +3,7 @@ git-http-fetch(1) NAME ---- -git-http-fetch - Download from a remote git repository via HTTP +git-http-fetch - Download from a remote Git repository via HTTP SYNOPSIS @@ -13,7 +13,7 @@ SYNOPSIS DESCRIPTION ----------- -Downloads a remote git repository via HTTP. +Downloads a remote Git repository via HTTP. *NOTE*: use of this command without -a is deprecated. The -a behaviour will become the default in a future release. diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 39e6d0ddd8..36adc5fc14 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -19,7 +19,7 @@ DESCRIPTION Reads a packed archive (.pack) from the specified file, and builds a pack index file (.idx) for it. The packed archive together with the pack index can then be placed in the -objects/pack/ directory of a git repository. +objects/pack/ directory of a Git repository. OPTIONS @@ -39,7 +39,7 @@ OPTIONS When this flag is provided, the pack is read from stdin instead and a copy is then written to <pack-file>. If <pack-file> is not specified, the pack is written to - objects/pack/ directory of the current git repository with + objects/pack/ directory of the current Git repository with a default name determined from the pack content. If <pack-file> is not specified consider using --keep to prevent a race condition between this process and @@ -81,7 +81,7 @@ OPTIONS This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. - Specifying 0 will cause git to auto-detect the number of CPU's + Specifying 0 will cause Git to auto-detect the number of CPU's and use maximum 3 threads. diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index a21e346789..648a6cd78a 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -3,7 +3,7 @@ git-init-db(1) NAME ---- -git-init-db - Creates an empty git repository +git-init-db - Creates an empty Git repository SYNOPSIS diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 9ac2bbaa56..afd721e3a9 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -3,7 +3,7 @@ git-init(1) NAME ---- -git-init - Create an empty git repository or reinitialize an existing one +git-init - Create an empty Git repository or reinitialize an existing one SYNOPSIS @@ -17,7 +17,7 @@ SYNOPSIS DESCRIPTION ----------- -This command creates an empty git repository - basically a `.git` +This command creates an empty Git repository - basically a `.git` directory with subdirectories for `objects`, `refs/heads`, `refs/tags`, and template files. An initial `HEAD` file that references the HEAD of the master branch is also created. @@ -58,19 +58,19 @@ DIRECTORY" section below.) --separate-git-dir=<git dir>:: Instead of initializing the repository where it is supposed to be, -place a filesytem-agnostic git symbolic link there, pointing to the -specified git path, and initialize a git repository at the path. The -result is git repository can be separated from working tree. If this +place a filesytem-agnostic Git symbolic link there, pointing to the +specified path, and initialize a Git repository at the path. The +result is Git repository can be separated from working tree. If this is reinitialization, the repository will be moved to the specified path. --shared[=(false|true|umask|group|all|world|everybody|0xxx)]:: -Specify that the git repository is to be shared amongst several users. This +Specify that the Git repository is to be shared amongst several users. This allows users belonging to the same group to push into that repository. When specified, the config variable "core.sharedRepository" is set so that files and directories under `$GIT_DIR` are created with the -requested permissions. When not specified, git will use permissions reported +requested permissions. When not specified, Git will use permissions reported by umask(2). The option can have the following values, defaulting to 'group' if no value @@ -130,7 +130,7 @@ The suggested patterns and hook files are all modifiable and extensible. EXAMPLES -------- -Start a new git repository for an existing code base:: +Start a new Git repository for an existing code base:: + ---------------- $ cd /path/to/my/codebase diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 22c0d6e4b1..69db5783ce 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -64,7 +64,7 @@ produced by --stat etc. --log-size:: Before the log message print out its size in bytes. Intended - mainly for porcelain tools consumption. If git is unable to + mainly for porcelain tools consumption. If Git is unable to produce a valid value size is set to zero. Note that only message is considered, if also a diff is shown its size is not included. diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 4b28292811..0bdebff6f7 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -92,7 +92,7 @@ OPTIONS directory and its subdirectories in <file>. --exclude-standard:: - Add the standard git exclusions: .git/info/exclude, .gitignore + Add the standard Git exclusions: .git/info/exclude, .gitignore in each directory, and the user's global exclusion file. --error-unmatch:: diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt index e0df1b3340..0c80cec0e8 100644 --- a/Documentation/git-merge-index.txt +++ b/Documentation/git-merge-index.txt @@ -41,13 +41,13 @@ If 'git merge-index' is called with multiple <file>s (or -a) then it processes them in turn only stopping if merge returns a non-zero exit code. -Typically this is run with a script calling git's imitation of +Typically this is run with a script calling Git's imitation of the 'merge' command from the RCS package. A sample script called 'git merge-one-file' is included in the distribution. -ALERT ALERT ALERT! The git "merge object order" is different from the +ALERT ALERT ALERT! The Git "merge object order" is different from the RCS 'merge' program merge object order. In the above ordering, the original is first. But the argument order to the 3-way merge program 'merge' is to have the original in the middle. Don't ask me why. diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index d34ea3c50b..c852a2677a 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -178,10 +178,10 @@ of the merge. Among the changes made to the common ancestor's version, non-overlapping ones (that is, you changed an area of the file while the other side left that area intact, or vice versa) are incorporated in the final result verbatim. When both sides made changes to the same area, -however, git cannot randomly pick one side over the other, and asks you to +however, Git cannot randomly pick one side over the other, and asks you to resolve it by leaving what both sides did to that area. -By default, git uses the same style as the one used by the "merge" program +By default, Git uses the same style as the one used by the "merge" program from the RCS suite to present such a conflicted hunk, like this: ------------ diff --git a/Documentation/git-mergetool--lib.txt b/Documentation/git-mergetool--lib.txt index f98a41b87c..055550b2bc 100644 --- a/Documentation/git-mergetool--lib.txt +++ b/Documentation/git-mergetool--lib.txt @@ -3,7 +3,7 @@ git-mergetool{litdd}lib(1) NAME ---- -git-mergetool--lib - Common git merge tool shell scriptlets +git-mergetool--lib - Common Git merge tool shell scriptlets SYNOPSIS -------- @@ -19,7 +19,7 @@ Porcelain-ish scripts and/or are writing new ones. The 'git-mergetool{litdd}lib' scriptlet is designed to be sourced (using `.`) by other shell scripts to set up functions for working -with git merge tools. +with Git merge tools. Before sourcing 'git-mergetool{litdd}lib', your script must set `TOOL_MODE` to define the operation mode for the functions listed below. diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt index 65e167a5c5..3ca158b05e 100644 --- a/Documentation/git-mktag.txt +++ b/Documentation/git-mktag.txt @@ -28,9 +28,9 @@ A tag signature file has a very simple fixed format: four lines of tagger <tagger> followed by some 'optional' free-form message (some tags created -by older git may not have `tagger` line). The message, when +by older Git may not have `tagger` line). The message, when exists, is separated by a blank line from the header. The -message part may contain a signature that git itself doesn't +message part may contain a signature that Git itself doesn't care about, but that can be verified with gpg. GIT diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt index e3c8448614..e93fcb49fd 100644 --- a/Documentation/git-mv.txt +++ b/Documentation/git-mv.txt @@ -34,7 +34,7 @@ OPTIONS -k:: Skip move or rename actions which would lead to an error condition. An error happens when a source is neither existing nor - controlled by GIT, or when it would overwrite an existing + controlled by Git, or when it would overwrite an existing file unless '-f' is given. -n:: --dry-run:: diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt index f70ef9ded2..c579fbc2b8 100644 --- a/Documentation/git-p4.txt +++ b/Documentation/git-p4.txt @@ -18,13 +18,13 @@ SYNOPSIS DESCRIPTION ----------- This command provides a way to interact with p4 repositories -using git. +using Git. -Create a new git repository from an existing p4 repository using +Create a new Git repository from an existing p4 repository using 'git p4 clone', giving it one or more p4 depot paths. Incorporate new commits from p4 changes with 'git p4 sync'. The 'sync' command is also used to include new branches from other p4 depot paths. -Submit git changes back to p4 using 'git p4 submit'. The command +Submit Git changes back to p4 using 'git p4 submit'. The command 'git p4 rebase' does a sync plus rebases the current branch onto the updated p4 remote branch. @@ -37,7 +37,7 @@ EXAMPLE $ git p4 clone //depot/path/project ------------ -* Do some work in the newly created git repository: +* Do some work in the newly created Git repository: + ------------ $ cd project @@ -45,7 +45,7 @@ $ vi foo.h $ git commit -a -m "edited foo.h" ------------ -* Update the git repository with recent changes from p4, rebasing your +* Update the Git repository with recent changes from p4, rebasing your work on top: + ------------ @@ -64,21 +64,21 @@ COMMANDS Clone ~~~~~ -Generally, 'git p4 clone' is used to create a new git directory +Generally, 'git p4 clone' is used to create a new Git directory from an existing p4 repository: ------------ $ git p4 clone //depot/path/project ------------ This: -1. Creates an empty git repository in a subdirectory called 'project'. +1. Creates an empty Git repository in a subdirectory called 'project'. + 2. Imports the full contents of the head revision from the given p4 -depot path into a single commit in the git branch 'refs/remotes/p4/master'. +depot path into a single commit in the Git branch 'refs/remotes/p4/master'. + 3. Creates a local branch, 'master' from this remote and checks it out. -To reproduce the entire p4 history in git, use the '@all' modifier on +To reproduce the entire p4 history in Git, use the '@all' modifier on the depot path: ------------ $ git p4 clone //depot/path/project@all @@ -88,13 +88,13 @@ $ git p4 clone //depot/path/project@all Sync ~~~~ As development continues in the p4 repository, those changes can -be included in the git repository using: +be included in the Git repository using: ------------ $ git p4 sync ------------ -This command finds new changes in p4 and imports them as git commits. +This command finds new changes in p4 and imports them as Git commits. -P4 repositories can be added to an existing git repository using +P4 repositories can be added to an existing Git repository using 'git p4 sync' too: ------------ $ mkdir repo-git @@ -103,14 +103,14 @@ $ git init $ git p4 sync //path/in/your/perforce/depot ------------ This imports the specified depot into -'refs/remotes/p4/master' in an existing git repository. The +'refs/remotes/p4/master' in an existing Git repository. The '--branch' option can be used to specify a different branch to be used for the p4 content. -If a git repository includes branches 'refs/remotes/origin/p4', these +If a Git repository includes branches 'refs/remotes/origin/p4', these will be fetched and consulted first during a 'git p4 sync'. Since importing directly from p4 is considerably slower than pulling changes -from a git remote, this can be useful in a multi-developer environment. +from a Git remote, this can be useful in a multi-developer environment. If there are multiple branches, doing 'git p4 sync' will automatically use the "BRANCH DETECTION" algorithm to try to partition new changes @@ -132,13 +132,13 @@ $ git p4 rebase Submit ~~~~~~ -Submitting changes from a git repository back to the p4 repository +Submitting changes from a Git repository back to the p4 repository requires a separate p4 client workspace. This should be specified -using the 'P4CLIENT' environment variable or the git configuration +using the 'P4CLIENT' environment variable or the Git configuration variable 'git-p4.client'. The p4 client must exist, but the client root will be created and populated if it does not already exist. -To submit all changes that are in the current git branch but not in +To submit all changes that are in the current Git branch but not in the 'p4/master' branch, use: ------------ $ git p4 submit @@ -154,7 +154,7 @@ be overridden using the '--origin=' command-line option. The p4 changes will be created as the user invoking 'git p4 submit'. The '--preserve-user' option will cause ownership to be modified -according to the author of the git commit. This option requires admin +according to the author of the Git commit. This option requires admin privileges in p4, which can be granted using 'p4 protect'. @@ -185,7 +185,7 @@ subsequent 'sync' operations. branch is 'master'. + This example imports a new remote "p4/proj2" into an existing -git repository: +Git repository: + ---- $ git init @@ -206,11 +206,11 @@ git repository: --detect-labels:: Query p4 for labels associated with the depot paths, and add - them as tags in git. Limited usefulness as only imports labels + them as tags in Git. Limited usefulness as only imports labels associated with new changelists. Deprecated. --import-labels:: - Import labels from p4 into git. + Import labels from p4 into Git. --import-local:: By default, p4 branches are stored in 'refs/remotes/p4/', @@ -226,12 +226,12 @@ git repository: specifier. --keep-path:: - The mapping of file names from the p4 depot path to git, by + The mapping of file names from the p4 depot path to Git, by default, involves removing the entire depot path. With this - option, the full p4 depot path is retained in git. For example, + option, the full p4 depot path is retained in Git. For example, path '//depot/main/foo/bar.c', when imported from '//depot/main/', becomes 'foo/bar.c'. With '--keep-path', the - git path is instead 'depot/main/foo/bar.c'. + Git path is instead 'depot/main/foo/bar.c'. --use-client-spec:: Use a client spec to find the list of interesting files in p4. @@ -243,7 +243,7 @@ These options can be used in an initial 'clone', along with the 'sync' options described above. --destination <directory>:: - Where to create the git repository. If not provided, the last + Where to create the Git repository. If not provided, the last component in the p4 depot path is used to create a new directory. @@ -273,12 +273,12 @@ These options can be used to modify 'git p4 submit' behavior. requires p4 admin privileges. --export-labels:: - Export tags from git as p4 labels. Tags found in git are applied + Export tags from Git as p4 labels. Tags found in Git are applied to the perforce working directory. --dry-run, -n:: Show just what commits would be submitted to p4; do not change - state in git or p4. + state in Git or p4. --prepare-p4-only:: Apply a commit to the p4 workspace, opening, adding and deleting @@ -324,12 +324,12 @@ p4 revision specifier on the end: "//depot/proj1@all //depot/proj2@all":: Import all changes from both named depot paths into a single repository. Only files below these directories are included. - There is not a subdirectory in git for each "proj1" and "proj2". + There is not a subdirectory in Git for each "proj1" and "proj2". You must use the '--destination' option when specifying more than one depot path. The revision specifier must be specified identically on each depot path. If there are files in the depot paths with the same name, the path with the most recently - updated version of the file is the one that appears in git. + updated version of the file is the one that appears in Git. See 'p4 help revisions' for the full syntax of p4 revision specifiers. @@ -346,11 +346,11 @@ configuration file. This allows future 'git p4 submit' commands to work properly; the submit command looks only at the variable and does not have a command-line option. -The full syntax for a p4 view is documented in 'p4 help views'. 'Git p4' +The full syntax for a p4 view is documented in 'p4 help views'. 'git p4' knows only a subset of the view syntax. It understands multi-line mappings, overlays with '+', exclusions with '-' and double-quotes around whitespace. Of the possible wildcards, 'git p4' only handles -'...', and only when it is at the end of the path. 'Git p4' will complain +'...', and only when it is at the end of the path. 'git p4' will complain if it encounters an unhandled wildcard. Bugs in the implementation of overlap mappings exist. If multiple depot @@ -366,7 +366,7 @@ variable P4CLIENT, a file referenced by P4CONFIG, or the local host name. BRANCH DETECTION ---------------- -P4 does not have the same concept of a branch as git. Instead, +P4 does not have the same concept of a branch as Git. Instead, p4 organizes its content as a directory tree, where by convention different logical branches are in different locations in the tree. The 'p4 branch' command is used to maintain mappings between @@ -376,7 +376,7 @@ can use these mappings to determine branch relationships. If you have a repository where all the branches of interest exist as subdirectories of a single depot path, you can use '--detect-branches' when cloning or syncing to have 'git p4' automatically find -subdirectories in p4, and to generate these as branches in git. +subdirectories in p4, and to generate these as branches in Git. For example, if the P4 repository structure is: ---- @@ -398,7 +398,7 @@ called 'master', and one for //depot/branch1 called 'depot/branch1'. However, it is not necessary to create branches in p4 to be able to use them like branches. Because it is difficult to infer branch -relationships automatically, a git configuration setting +relationships automatically, a Git configuration setting 'git-p4.branchList' can be used to explicitly identify branch relationships. It is a list of "source:destination" pairs, like a simple p4 branch specification, where the "source" and "destination" are @@ -416,7 +416,7 @@ git p4 clone --detect-branches //depot@all . PERFORMANCE ----------- The fast-import mechanism used by 'git p4' creates one pack file for -each invocation of 'git p4 sync'. Normally, git garbage compression +each invocation of 'git p4 sync'. Normally, Git garbage compression (linkgit:git-gc[1]) automatically compresses these to fewer pack files, but explicit invocation of 'git repack -adf' may improve performance. @@ -454,9 +454,9 @@ git-p4.client:: Clone and sync variables ~~~~~~~~~~~~~~~~~~~~~~~~ git-p4.syncFromOrigin:: - Because importing commits from other git repositories is much faster + Because importing commits from other Git repositories is much faster than importing them from p4, a mechanism exists to find p4 changes - first in git remotes. If branches exist under 'refs/remote/origin/p4', + first in Git remotes. If branches exist under 'refs/remote/origin/p4', those will be fetched and used when syncing from p4. This variable can be set to 'false' to disable this behavior. @@ -508,7 +508,7 @@ git-p4.detectCopiesHarder:: Detect copies harder. See linkgit:git-diff[1]. A boolean. git-p4.preserveUser:: - On submit, re-author changes to reflect the git author, + On submit, re-author changes to reflect the Git author, regardless of who invokes 'git p4 submit'. git-p4.allowMissingP4Users:: @@ -545,7 +545,7 @@ git-p4.attemptRCSCleanup:: present. git-p4.exportLabels:: - Export git tags to p4 labels, as per --export-labels. + Export Git tags to p4 labels, as per --export-labels. git-p4.labelExportRegexp:: Only p4 labels matching this regular expression will be exported. The @@ -557,11 +557,11 @@ git-p4.conflict:: IMPLEMENTATION DETAILS ---------------------- -* Changesets from p4 are imported using git fast-import. +* Changesets from p4 are imported using Git fast-import. * Cloning or syncing does not require a p4 client; file contents are collected using 'p4 print'. * Submitting requires a p4 client, which is not in the same location - as the git repository. Patches are applied, one at a time, to + as the Git repository. Patches are applied, one at a time, to this p4 client and submitted from there. * Each commit imported by 'git p4' has a line at the end of the log message indicating the p4 depot location and change number. This diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index 20c8551d6a..69c9313cf5 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -35,7 +35,7 @@ A pack index file (.idx) is generated for fast, random access to the objects in the pack. Placing both the index file (.idx) and the packed archive (.pack) in the pack/ subdirectory of $GIT_OBJECT_DIRECTORY (or any of the directories on $GIT_ALTERNATE_OBJECT_DIRECTORIES) -enables git to read from the pack archive. +enables Git to read from the pack archive. The 'git unpack-objects' command can read the packed archive and expand the objects contained in the pack into "one-file @@ -80,7 +80,7 @@ base-name:: --include-tag:: Include unasked-for annotated tags if the object they reference was included in the resulting packfile. This - can be useful to send new tags to native git clients. + can be useful to send new tags to native Git clients. --window=<n>:: --depth=<n>:: @@ -185,14 +185,14 @@ base-name:: option only makes sense in conjunction with --stdout. + Note: A thin pack violates the packed archive format by omitting -required objects and is thus unusable by git without making it +required objects and is thus unusable by Git without making it self-contained. Use `git index-pack --fix-thin` (see linkgit:git-index-pack[1]) to restore the self-contained property. --delta-base-offset:: A packed archive can express the base object of a delta as either a 20-byte object name or as an offset in the - stream, but ancient versions of git don't understand the + stream, but ancient versions of Git don't understand the latter. By default, 'git pack-objects' only uses the former format for better compatibility. This option allows the command to use the latter format for @@ -202,7 +202,7 @@ self-contained. Use `git index-pack --fix-thin` + Note: Porcelain commands such as `git gc` (see linkgit:git-gc[1]), `git repack` (see linkgit:git-repack[1]) pass this option by default -in modern git when they put objects in your repository into pack files. +in modern Git when they put objects in your repository into pack files. So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle. --threads=<n>:: @@ -212,7 +212,7 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle. This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. - Specifying 0 will cause git to auto-detect the number of CPU's + Specifying 0 will cause Git to auto-detect the number of CPU's and set the number of threads accordingly. --index-version=<version>[,<offset>]:: diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 67fa5ee195..c975743230 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -59,8 +59,8 @@ and a log message from the user describing the changes. See linkgit:git-merge[1] for details, including how conflicts are presented and handled. -In git 1.7.0 or later, to cancel a conflicting merge, use -`git reset --merge`. *Warning*: In older versions of git, running 'git pull' +In Git 1.7.0 or later, to cancel a conflicting merge, use +`git reset --merge`. *Warning*: In older versions of Git, running 'git pull' with uncommitted changes is discouraged: while possible, it leaves you in a state that may be hard to back out of in the case of a conflict. @@ -89,7 +89,7 @@ must be given before the options meant for 'git fetch'. This option controls if new commits of all populated submodules should be fetched too (see linkgit:git-config[1] and linkgit:gitmodules[5]). That might be necessary to get the data needed for merging submodule - commits, a feature git learned in 1.7.3. Notice that the result of a + commits, a feature Git learned in 1.7.3. Notice that the result of a merge will not be checked out in the submodule, "git submodule update" has to be called afterwards to bring the work tree up to date with the merge result. @@ -228,7 +228,7 @@ Using --recurse-submodules can only fetch new commits in already checked out submodules right now. When e.g. upstream added a new submodule in the just fetched commits of the superproject the submodule itself can not be fetched, making it impossible to check out that submodule later without -having to do a fetch again. This is expected to be fixed in a future git +having to do a fetch again. This is expected to be fixed in a future Git version. SEE ALSO diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index c964b796be..13980257ee 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -53,7 +53,7 @@ updated. The object referenced by <src> is used to update the <dst> reference on the remote side. By default this is only allowed if <dst> is not a tag (annotated or lightweight), and then only if it can fast-forward -<dst>. By having the optional leading `+`, you can tell git to update +<dst>. By having the optional leading `+`, you can tell Git to update the <dst> ref even if it is not allowed by default (e.g., it is not a fast-forward.) This does *not* attempt to merge <src> into <dst>. See EXAMPLES below for details. @@ -64,7 +64,7 @@ Pushing an empty <src> allows you to delete the <dst> ref from the remote repository. + The special refspec `:` (or `+:` to allow non-fast-forward updates) -directs git to push "matching" branches: for every branch that exists on +directs Git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side. This is the default operation mode if no explicit refspec is found (that is neither on the command line @@ -177,7 +177,7 @@ useful if you write an alias or script around 'git push'. --recurse-submodules=check|on-demand:: Make sure all submodule commits used by the revisions to be pushed are available on a remote-tracking branch. If 'check' is - used git will verify that all submodule commits that changed in + used Git will verify that all submodule commits that changed in the revisions to be pushed are available on at least one remote of the submodule. If any commits are missing the push will be aborted and exit with non-zero status. If 'on-demand' is used @@ -192,7 +192,7 @@ OUTPUT ------ The output of "git push" depends on the transport method used; this -section describes the output when pushing over the git protocol (either +section describes the output when pushing over the Git protocol (either locally or via ssh). The status of the push is output in tabular form, with each line diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt index 7f112f3dcd..a356196586 100644 --- a/Documentation/git-quiltimport.txt +++ b/Documentation/git-quiltimport.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Applies a quilt patchset onto the current git branch, preserving +Applies a quilt patchset onto the current Git branch, preserving the patch boundaries, patch order, and patch descriptions present in the quilt patchset. @@ -25,7 +25,7 @@ the patch description is displayed and the user is asked to interactively enter the author of the patch. If a subject is not found in the patch description the patch name is -preserved as the 1 line subject in the git description. +preserved as the 1 line subject in the Git description. OPTIONS ------- diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index da067ecafa..aca840525e 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -179,7 +179,7 @@ parameter can be any valid commit-ish. In case of conflict, 'git rebase' will stop at the first problematic commit and leave conflict markers in the tree. You can use 'git diff' to locate the markers (<<<<<<) and make edits to resolve the conflict. For each -file you edit, you need to tell git that the conflict has been resolved, +file you edit, you need to tell Git that the conflict has been resolved, typically this would be done with diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt index 7fe2d2247b..fb8697ea4c 100644 --- a/Documentation/git-reflog.txt +++ b/Documentation/git-reflog.txt @@ -38,7 +38,7 @@ The reflog will cover all recent actions (HEAD reflog records branch switching as well). It is an alias for `git log -g --abbrev-commit --pretty=oneline`; see linkgit:git-log[1]. -The reflog is useful in various git commands, to specify the old value +The reflog is useful in various Git commands, to specify the old value of a reference. For example, `HEAD@{2}` means "where HEAD used to be two moves ago", `master@{one.week.ago}` means "where master used to point to one week ago", and so on. See linkgit:gitrevisions[7] for diff --git a/Documentation/git-remote-ext.txt b/Documentation/git-remote-ext.txt index 8a8e1d775d..58b7facb09 100644 --- a/Documentation/git-remote-ext.txt +++ b/Documentation/git-remote-ext.txt @@ -13,7 +13,7 @@ git remote add <nick> "ext::<command>[ <arguments>...]" DESCRIPTION ----------- This remote helper uses the specified '<command>' to connect -to a remote git server. +to a remote Git server. Data written to stdin of the specified '<command>' is assumed to be sent to a git:// server, git-upload-pack, git-receive-pack @@ -33,12 +33,12 @@ The following sequences have a special meaning: '%s':: Replaced with name (receive-pack, upload-pack, or - upload-archive) of the service git wants to invoke. + upload-archive) of the service Git wants to invoke. '%S':: Replaced with long name (git-receive-pack, git-upload-pack, or git-upload-archive) of the service - git wants to invoke. + Git wants to invoke. '%G' (must be the first characters in an argument):: This argument will not be passed to '<command>'. Instead, it @@ -75,7 +75,7 @@ GIT_EXT_SERVICE_NOPREFIX:: EXAMPLES: --------- -This remote helper is transparently used by git when +This remote helper is transparently used by Git when you use commands such as "git fetch <URL>", "git clone <URL>", , "git push <URL>" or "git remote add <nick> <URL>", where <URL> begins with `ext::`. Examples: @@ -100,14 +100,14 @@ begins with `ext::`. Examples: Represents a repository with path /repo accessed using the helper program "git-server-alias foo". The hostname for the remote server passed in the protocol stream will be "foo" - (this allows multiple virtual git servers to share a + (this allows multiple virtual Git servers to share a link-level address). "ext::git-server-alias foo %G/repo% with% spaces %Vfoo":: Represents a repository with path '/repo with spaces' accessed using the helper program "git-server-alias foo". The hostname for the remote server passed in the protocol stream will be "foo" - (this allows multiple virtual git servers to share a + (this allows multiple virtual Git servers to share a link-level address). "ext::git-ssl foo.example /bar":: @@ -118,7 +118,7 @@ begins with `ext::`. Examples: Documentation -------------- -Documentation by Ilari Liusvaara, Jonathan Nieder and the git list +Documentation by Ilari Liusvaara, Jonathan Nieder and the Git list <git@vger.kernel.org> GIT diff --git a/Documentation/git-remote-fd.txt b/Documentation/git-remote-fd.txt index f095d57d09..933c2adaf6 100644 --- a/Documentation/git-remote-fd.txt +++ b/Documentation/git-remote-fd.txt @@ -11,14 +11,14 @@ SYNOPSIS DESCRIPTION ----------- -This helper uses specified file descriptors to connect to a remote git server. +This helper uses specified file descriptors to connect to a remote Git server. This is not meant for end users but for programs and scripts calling git fetch, push or archive. If only <infd> is given, it is assumed to be a bidirectional socket connected -to remote git server (git-upload-pack, git-receive-pack or +to remote Git server (git-upload-pack, git-receive-pack or git-upload-achive). If both <infd> and <outfd> are given, they are assumed -to be pipes connected to a remote git server (<infd> being the inbound pipe +to be pipes connected to a remote Git server (<infd> being the inbound pipe and <outfd> being the outbound pipe. It is assumed that any handshaking procedures have already been completed @@ -52,7 +52,7 @@ EXAMPLES Documentation -------------- -Documentation by Ilari Liusvaara and the git list <git@vger.kernel.org> +Documentation by Ilari Liusvaara and the Git list <git@vger.kernel.org> GIT --- diff --git a/Documentation/git-remote-helpers.txto b/Documentation/git-remote-helpers.txto new file mode 100644 index 0000000000..49233f5d26 --- /dev/null +++ b/Documentation/git-remote-helpers.txto @@ -0,0 +1,9 @@ +git-remote-helpers +================== + +This document has been moved to linkgit:gitremote-helpers[1]. + +Please let the owners of the referring site know so that they can update the +link you clicked to get here. + +Thanks. diff --git a/Documentation/git-remote-testgit.txt b/Documentation/git-remote-testgit.txt index 612a625ced..f791d73c05 100644 --- a/Documentation/git-remote-testgit.txt +++ b/Documentation/git-remote-testgit.txt @@ -23,7 +23,7 @@ The best way to learn more is to read the comments and source code in SEE ALSO -------- -linkgit:git-remote-helpers[1] +linkgit:gitremote-helpers[1] GIT --- diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt index 51131d0858..0142cd18ae 100644 --- a/Documentation/git-replace.txt +++ b/Documentation/git-replace.txt @@ -22,7 +22,7 @@ replacement object. Unless `-f` is given, the 'replace' reference must not yet exist. -Replacement references will be used by default by all git commands +Replacement references will be used by default by all Git commands except those doing reachability traversal (prune, pack transfer and fsck). diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 38fafcaa6b..65ac27e0c9 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -99,7 +99,7 @@ between the two operands. The following two commands are equivalent: $ git rev-list A...B ----------------------------------------------------------------------- -'rev-list' is a very essential git command, since it +'rev-list' is a very essential Git command, since it provides the ability to build and traverse commit ancestry graphs. For this reason, it has a lot of different options that enables it to be used by commands as different as 'git bisect' and diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 3c63561f02..10a116faf8 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Many git porcelainish commands take mixture of flags +Many Git porcelainish commands take mixture of flags (i.e. parameters that begin with a dash '-') and parameters meant for the underlying 'git rev-list' command they use internally and flags and parameters for the other commands they use @@ -147,7 +147,7 @@ shown. If the pattern does not contain a globbing character (`?`, relative to the current working directory. + If `$GIT_DIR` is not defined and the current directory -is not detected to lie in a git repository or work tree +is not detected to lie in a Git repository or work tree print a message to stderr and exit with nonzero status. --is-inside-git-dir:: @@ -187,9 +187,11 @@ print a message to stderr and exit with nonzero status. Flags and parameters to be parsed. --resolve-git-dir <path>:: - Check if <path> is a valid git-dir or a git-file pointing to a valid - git-dir. If <path> is a valid git-dir the resolved path to git-dir will - be printed. + Check if <path> is a valid repository or a gitfile that + points at a valid repository, and print the location of the + repository. If <path> is a gitfile then the resolved path + to the real repository is printed. + include::revisions.txt[] diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt index 262436b7b1..92bac27e05 100644 --- a/Documentation/git-rm.txt +++ b/Documentation/git-rm.txt @@ -28,7 +28,7 @@ OPTIONS ------- <file>...:: Files to remove. Fileglobs (e.g. `*.c`) can be given to - remove all matching files. If you want git to expand + remove all matching files. If you want Git to expand file glob characters, you may need to shell-escape them. A leading directory name (e.g. `dir` to remove `dir/file1` and `dir/file2`) can be @@ -74,8 +74,8 @@ DISCUSSION The <file> list given to the command can be exact pathnames, file glob patterns, or leading directory names. The command -removes only the paths that are known to git. Giving the name of -a file that you have not told git about does not remove that file. +removes only the paths that are known to Git. Giving the name of +a file that you have not told Git about does not remove that file. File globbing matches across directory boundaries. Thus, given two directories `d` and `d2`, there is a difference between @@ -137,7 +137,7 @@ git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached Submodules ~~~~~~~~~~ Only submodules using a gitfile (which means they were cloned -with a git version 1.7.8 or newer) will be removed from the work +with a Git version 1.7.8 or newer) will be removed from the work tree, as their repository lives inside the .git directory of the superproject. If a submodule (or one of those nested inside it) still uses a .git directory, `git rm` will fail - no matter if forced @@ -156,7 +156,7 @@ EXAMPLES `Documentation` directory and any of its subdirectories. + Note that the asterisk `*` is quoted from the shell in this -example; this lets git, and not the shell, expand the pathnames +example; this lets Git, and not the shell, expand the pathnames of files and subdirectories under the `Documentation/` directory. `git rm -f git-*.sh`:: diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index eeb561cf14..44a1f7c4e8 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -67,7 +67,7 @@ The --cc option must be repeated for each user you want on the cc list. When '--compose' is used, git send-email will use the From, Subject, and In-Reply-To headers specified in the message. If the body of the message (what you type after the headers and a blank line) only contains blank -(or GIT: prefixed) lines the summary won't be sent, but From, Subject, +(or Git: prefixed) lines the summary won't be sent, but From, Subject, and In-Reply-To headers will be used unless they are removed. + Missing From or In-Reply-To headers will be prompted for. diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt index bd3eaa69bf..dc3a568baa 100644 --- a/Documentation/git-send-pack.txt +++ b/Documentation/git-send-pack.txt @@ -3,7 +3,7 @@ git-send-pack(1) NAME ---- -git-send-pack - Push objects over git protocol to another repository +git-send-pack - Push objects over Git protocol to another repository SYNOPSIS diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt index 5e5f1c8964..6a9f66d1d9 100644 --- a/Documentation/git-sh-setup.txt +++ b/Documentation/git-sh-setup.txt @@ -3,7 +3,7 @@ git-sh-setup(1) NAME ---- -git-sh-setup - Common git shell script setup code +git-sh-setup - Common Git shell script setup code SYNOPSIS -------- @@ -19,7 +19,7 @@ Porcelain-ish scripts and/or are writing new ones. The 'git sh-setup' scriptlet is designed to be sourced (using `.`) by other shell scripts to set up some variables pointing at -the normal git directories and a few helper shell functions. +the normal Git directories and a few helper shell functions. Before sourcing it, your script should set up a few variables; `USAGE` (and `LONG_USAGE`, if any) is used to define message diff --git a/Documentation/git-show-index.txt b/Documentation/git-show-index.txt index 2dcbbb2454..9cbbed944c 100644 --- a/Documentation/git-show-index.txt +++ b/Documentation/git-show-index.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Reads given idx file for packed git archive created with +Reads given idx file for packed Git archive created with 'git pack-objects' command, and dumps its contents. The information it outputs is subset of what you can get from diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index 9f1ef9a463..0412c4017d 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -16,7 +16,7 @@ DESCRIPTION Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not -tracked by git (and are not ignored by linkgit:gitignore[5]). The first +tracked by Git (and are not ignored by linkgit:gitignore[5]). The first are what you _would_ commit by running `git commit`; the second and third are what you _could_ commit by running 'git add' before running `git commit`. @@ -35,7 +35,7 @@ OPTIONS --porcelain:: Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable - across git versions and regardless of user configuration. See + across Git versions and regardless of user configuration. See below for details. --long:: @@ -96,7 +96,7 @@ The default, long format, is designed to be human readable, verbose and descriptive. Its contents and format are subject to change at any time. -The paths mentioned in the output, unlike many other git commands, are +The paths mentioned in the output, unlike many other Git commands, are made relative to the current directory if you are working in a subdirectory (this is on purpose, to help cutting and pasting). See the status.relativePaths config option below. @@ -168,7 +168,7 @@ Porcelain Format ~~~~~~~~~~~~~~~~ The porcelain format is similar to the short format, but is guaranteed -not to change in a backwards-incompatible way between git versions or +not to change in a backwards-incompatible way between Git versions or based on user configuration. This makes it ideal for parsing by scripts. The description of the short format above also describes the porcelain format, with a few exceptions: diff --git a/Documentation/git-stripspace.txt b/Documentation/git-stripspace.txt index a80d94650d..c87bfcb674 100644 --- a/Documentation/git-stripspace.txt +++ b/Documentation/git-stripspace.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Clean the input in the manner used by 'git' for text such as commit +Clean the input in the manner used by Git for text such as commit messages, notes, tags and branch descriptions. With no arguments, this will: @@ -35,7 +35,13 @@ OPTIONS ------- -s:: --strip-comments:: - Skip and remove all lines starting with '#'. + Skip and remove all lines starting with comment character (default '#'). + +-c:: +--comment-lines:: + Prepend comment character and blank to each line. Lines will automatically + be terminated with a newline. On empty lines, only the comment character + will be prepended. EXAMPLES -------- diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index b1996f1a63..a0c9df85f4 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -91,7 +91,7 @@ working directory is used instead. <path> is the relative location for the cloned submodule to exist in the superproject. If <path> does not exist, then the submodule is created by cloning from the named URL. If <path> does -exist and is already a valid git repository, then this is added +exist and is already a valid Git repository, then this is added to the changeset without cloning. This second form is provided to ease creating a new submodule from scratch, and presumes the user will later push the submodule to the given URL. diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index 34d438b0ab..1b8b6498cd 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -3,7 +3,7 @@ git-svn(1) NAME ---- -git-svn - Bidirectional operation between a Subversion repository and git +git-svn - Bidirectional operation between a Subversion repository and Git SYNOPSIS -------- @@ -12,8 +12,8 @@ SYNOPSIS DESCRIPTION ----------- -'git svn' is a simple conduit for changesets between Subversion and git. -It provides a bidirectional flow of changes between a Subversion and a git +'git svn' is a simple conduit for changesets between Subversion and Git. +It provides a bidirectional flow of changes between a Subversion and a Git repository. 'git svn' can track a standard Subversion repository, @@ -21,15 +21,15 @@ following the common "trunk/branches/tags" layout, with the --stdlayout option. It can also follow branches and tags in any layout with the -T/-t/-b options (see options to 'init' below, and also the 'clone' command). -Once tracking a Subversion repository (with any of the above methods), the git +Once tracking a Subversion repository (with any of the above methods), the Git repository can be updated from Subversion by the 'fetch' command and -Subversion updated from git by the 'dcommit' command. +Subversion updated from Git by the 'dcommit' command. COMMANDS -------- 'init':: - Initializes an empty git repository with additional + Initializes an empty Git repository with additional metadata directories for 'git svn'. The Subversion URL may be specified as a command-line argument, or as full URL arguments to -T/-t/-b. Optionally, the target @@ -199,9 +199,9 @@ and have no uncommitted changes. Commit each diff from the current branch directly to the SVN repository, and then rebase or reset (depending on whether or not there is a diff between SVN and head). This will create - a revision in SVN for each commit in git. + a revision in SVN for each commit in Git. + -When an optional git branch name (or a git commit object name) +When an optional Git branch name (or a Git commit object name) is specified as an argument, the subcommand works on the specified branch, not on the current branch. + @@ -316,7 +316,7 @@ New features: + -- --show-commit;; - shows the git commit sha1, as well + shows the Git commit sha1, as well --oneline;; our version of --pretty=oneline -- @@ -337,13 +337,13 @@ Any other arguments are passed directly to 'git log' + --git-format;; Produce output in the same format as 'git blame', but with - SVN revision numbers instead of git commit hashes. In this mode, + SVN revision numbers instead of Git commit hashes. In this mode, changes that haven't been committed to SVN (including local working-copy edits) are shown as revision 0. 'find-rev':: When given an SVN revision number of the form 'rN', returns the - corresponding git commit hash (this can optionally be followed by a + corresponding Git commit hash (this can optionally be followed by a tree-ish to specify which branch should be searched). When given a tree-ish, returns the corresponding SVN revision number. + @@ -378,7 +378,7 @@ Any other arguments are passed directly to 'git log' the $GIT_DIR/info/exclude file. 'mkdirs':: - Attempts to recreate empty directories that core git cannot track + Attempts to recreate empty directories that core Git cannot track based on information in $GIT_DIR/svn/<refname>/unhandled.log files. Empty directories are automatically recreated when using "git svn clone" and "git svn rebase", so "mkdirs" is intended @@ -510,9 +510,9 @@ order. Only the leading sha1 is read from each line, so + Remove directories from the SVN tree if there are no files left behind. SVN can version empty directories, and they are not -removed by default if there are no files left in them. git +removed by default if there are no files left in them. Git cannot version empty directories. Enabling this flag will make -the commit to SVN act like git. +the commit to SVN act like Git. + [verse] config key: svn.rmdir @@ -599,7 +599,7 @@ Passed directly to 'git rebase' when using 'dcommit' if a This can be used with the 'dcommit', 'rebase', 'branch' and 'tag' commands. + -For 'dcommit', print out the series of git arguments that would show +For 'dcommit', print out the series of Git arguments that would show which diffs would be committed to SVN. + For 'rebase', display the local branch associated with the upstream svn @@ -610,14 +610,14 @@ For 'branch' and 'tag', display the urls that will be used for copying when creating the branch or tag. --use-log-author:: - When retrieving svn commits into git (as part of 'fetch', 'rebase', or + When retrieving svn commits into Git (as part of 'fetch', 'rebase', or 'dcommit' operations), look for the first `From:` or `Signed-off-by:` line in the log message and use that as the author string. --add-author-from:: - When committing to svn from git (as part of 'commit-diff', 'set-tree' or 'dcommit' + When committing to svn from Git (as part of 'commit-diff', 'set-tree' or 'dcommit' operations), if the existing log message doesn't already have a `From:` or `Signed-off-by:` line, append a `From:` line based on the - git commit's author string. If you use this, then `--use-log-author` + Git commit's author string. If you use this, then `--use-log-author` will retrieve a valid author string for all commits. @@ -642,7 +642,7 @@ ADVANCED OPTIONS one of the repository layout options --trunk, --tags, --branches, --stdlayout). For each tracked branch, try to find out where its revision was copied from, and set - a suitable parent in the first git commit for the branch. + a suitable parent in the first Git commit for the branch. This is especially helpful when we're tracking a directory that has been moved around within the repository. If this feature is disabled, the branches created by 'git svn' will all @@ -674,7 +674,7 @@ option for (hopefully) obvious reasons. + This option is NOT recommended as it makes it difficult to track down old references to SVN revision numbers in existing documentation, bug -reports and archives. If you plan to eventually migrate from SVN to git +reports and archives. If you plan to eventually migrate from SVN to Git and are certain about dropping SVN history, consider linkgit:git-filter-branch[1] instead. filter-branch also allows reformatting of metadata for ease-of-reading and rewriting authorship @@ -714,7 +714,7 @@ svn-remote.<name>.rewriteUUID:: svn-remote.<name>.pushurl:: - Similar to git's 'remote.<name>.pushurl', this key is designed + Similar to Git's 'remote.<name>.pushurl', this key is designed to be used in cases where 'url' points to an SVN repository via a read-only transport, to provide an alternate read/write transport. It is assumed that both keys point to the same @@ -768,15 +768,15 @@ Tracking and contributing to the trunk of a Subversion-managed project cd trunk # You should be on master branch, double-check with 'git branch' git branch -# Do some work and commit locally to git: +# Do some work and commit locally to Git: git commit ... # Something is committed to SVN, rebase your local changes against the # latest changes in SVN: git svn rebase -# Now commit your changes (that were committed previously using git) to SVN, +# Now commit your changes (that were committed previously using Git) to SVN, # as well as automatically updating your working HEAD: git svn dcommit -# Append svn:ignore settings to the default git exclude file: +# Append svn:ignore settings to the default Git exclude file: git svn show-ignore >> .git/info/exclude ------------------------------------------------------------------------ @@ -816,7 +816,7 @@ have each person clone that repository with 'git clone': git remote add origin server:/pub/project git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*' git fetch -# Prevent fetch/pull from remote git server in the future, +# Prevent fetch/pull from remote Git server in the future, # we only want to use git svn for future updates git config --remove-section remote.origin # Create a local branch from one of the branches just fetched @@ -849,13 +849,13 @@ While 'git svn' can track copy history (including branches and tags) for repositories adopting a standard layout, it cannot yet represent merge history that happened inside git back upstream to SVN users. Therefore it is advised that -users keep history as linear as possible inside git to ease +users keep history as linear as possible inside Git to ease compatibility with SVN (see the CAVEATS section below). HANDLING OF SVN BRANCHES ------------------------ If 'git svn' is configured to fetch branches (and --follow-branches -is in effect), it sometimes creates multiple git branches for one +is in effect), it sometimes creates multiple Git branches for one SVN branch, where the addtional branches have names of the form 'branchname@nnn' (with nnn an SVN revision number). These additional branches are created if 'git svn' cannot find a parent commit for the @@ -865,17 +865,17 @@ the other branches. Normally, the first commit in an SVN branch consists of a copy operation. 'git svn' will read this commit to get the SVN revision the branch was created from. It will then try to find the -git commit that corresponds to this SVN revision, and use that as the +Git commit that corresponds to this SVN revision, and use that as the parent of the branch. However, it is possible that there is no suitable -git commit to serve as parent. This will happen, among other reasons, +Git commit to serve as parent. This will happen, among other reasons, if the SVN branch is a copy of a revision that was not fetched by 'git svn' (e.g. because it is an old revision that was skipped with '--revision'), or if in SVN a directory was copied that is not tracked by 'git svn' (such as a branch that is not tracked at all, or a subdirectory of a tracked branch). In these cases, 'git svn' will still -create a git branch, but instead of using an existing git commit as the +create a Git branch, but instead of using an existing Git commit as the parent of the branch, it will read the SVN history of the directory the -branch was copied from and create appropriate git commits. This is +branch was copied from and create appropriate Git commits. This is indicated by the message "Initializing parent: <branchname>". Additionally, it will create a special branch named @@ -885,15 +885,15 @@ created parent commit of the branch. If in SVN the branch was deleted and later recreated from a different version, there will be multiple such branches with an '@'. -Note that this may mean that multiple git commits are created for a +Note that this may mean that multiple Git commits are created for a single SVN revision. An example: in an SVN repository with a standard trunk/tags/branches layout, a directory trunk/sub is created in r.100. In r.200, trunk/sub is branched by copying it to branches/. 'git svn -clone -s' will then create a branch 'sub'. It will also create new git +clone -s' will then create a branch 'sub'. It will also create new Git commits for r.100 through r.199 and use these as the history of branch -'sub'. Thus there will be two git commits for each revision from r.100 +'sub'. Thus there will be two Git commits for each revision from r.100 to r.199 (one containing trunk/, one containing trunk/sub/). Finally, it will create a branch 'sub@200' pointing to the new parent commit of branch 'sub' (i.e. the commit for r.200 and trunk/sub/). @@ -904,13 +904,13 @@ CAVEATS For the sake of simplicity and interoperating with Subversion, it is recommended that all 'git svn' users clone, fetch and dcommit directly from the SVN server, and avoid all 'git clone'/'pull'/'merge'/'push' -operations between git repositories and branches. The recommended -method of exchanging code between git branches and users is +operations between Git repositories and branches. The recommended +method of exchanging code between Git branches and users is 'git format-patch' and 'git am', or just 'dcommit'ing to the SVN repository. Running 'git merge' or 'git pull' is NOT recommended on a branch you plan to 'dcommit' from because Subversion users cannot see any -merges you've made. Furthermore, if you merge or pull from a git branch +merges you've made. Furthermore, if you merge or pull from a Git branch that is a mirror of an SVN branch, 'dcommit' may commit to the wrong branch. @@ -929,7 +929,7 @@ any 'git svn' metadata, or config. So repositories created and managed with using 'git svn' should use 'rsync' for cloning, if cloning is to be done at all. -Since 'dcommit' uses rebase internally, any git branches you 'git push' to +Since 'dcommit' uses rebase internally, any Git branches you 'git push' to before 'dcommit' on will require forcing an overwrite of the existing ref on the remote repository. This is generally considered bad practice, see the linkgit:git-push[1] documentation for details. @@ -941,7 +941,7 @@ dcommit with SVN is analogous to that. When cloning an SVN repository, if none of the options for describing the repository layout is used (--trunk, --tags, --branches, ---stdlayout), 'git svn clone' will create a git repository with +--stdlayout), 'git svn clone' will create a Git repository with completely linear history, where branches and tags appear as separate directories in the working copy. While this is the easiest way to get a copy of a complete repository, for projects with many branches it will @@ -957,7 +957,7 @@ branches and tags is required, the options '--trunk' / '--branches' / When using multiple --branches or --tags, 'git svn' does not automatically handle name collisions (for example, if two branches from different paths have the same name, or if a branch and a tag have the same name). In these cases, -use 'init' to set up your git repository then, before your first 'fetch', edit +use 'init' to set up your Git repository then, before your first 'fetch', edit the .git/config file so that the branches and tags are associated with different name spaces. For example: @@ -970,12 +970,12 @@ BUGS We ignore all SVN properties except svn:executable. Any unhandled properties are logged to $GIT_DIR/svn/<refname>/unhandled.log -Renamed and copied directories are not detected by git and hence not +Renamed and copied directories are not detected by Git and hence not tracked when committing to SVN. I do not plan on adding support for this as it's quite difficult and time-consuming to get working for all -the possible corner cases (git doesn't do it, either). Committing +the possible corner cases (Git doesn't do it, either). Committing renamed and copied files is fully supported if they're similar enough -for git to detect them. +for Git to detect them. In SVN, it is possible (though discouraged) to commit changes to a tag (because a tag is just a directory copy, thus technically the same as a @@ -987,7 +987,7 @@ CONFIGURATION ------------- 'git svn' stores [svn-remote] configuration information in the -repository .git/config file. It is similar the core git +repository .git/config file. It is similar the core Git [remote] sections except 'fetch' keys do not accept glob arguments; but they are instead handled by the 'branches' and 'tags' keys. Since some SVN repositories are oddly diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt index 6470cffd32..e3032c46c6 100644 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@ -242,7 +242,7 @@ $ git pull git://git..../proj.git master In such a case, you do not want to automatically follow the other person's tags. -One important aspect of git is its distributed nature, which +One important aspect of Git is its distributed nature, which largely means there is no inherent "upstream" or "downstream" in the system. On the face of it, the above example might seem to indicate that the tag namespace is owned diff --git a/Documentation/git-tools.txt b/Documentation/git-tools.txt index a96403cb8c..ad8b823f77 100644 --- a/Documentation/git-tools.txt +++ b/Documentation/git-tools.txt @@ -1,11 +1,11 @@ -A short git tools survey +A short Git tools survey ======================== Introduction ------------ -Apart from git contrib/ area there are some others third-party tools +Apart from Git contrib/ area there are some others third-party tools you may want to look. This document presents a brief summary of each tool and the corresponding @@ -17,26 +17,26 @@ Alternative/Augmentative Porcelains - *Cogito* (http://www.kernel.org/pub/software/scm/cogito/) - Cogito is a version control system layered on top of the git tree history + Cogito is a version control system layered on top of the Git tree history storage system. It aims at seamless user interface and ease of use, - providing generally smoother user experience than the "raw" Core GIT + providing generally smoother user experience than the "raw" Core Git itself and indeed many other version control systems. Cogito is no longer maintained as most of its functionality - is now in core GIT. + is now in core Git. - *pg* (http://www.spearce.org/category/projects/scm/pg/) - pg is a shell script wrapper around GIT to help the user manage a set of - patches to files. pg is somewhat like quilt or StGIT, but it does have a + pg is a shell script wrapper around Git to help the user manage a set of + patches to files. pg is somewhat like quilt or StGit, but it does have a slightly different feature set. - *StGit* (http://www.procode.org/stgit/) - Stacked GIT provides a quilt-like patch management functionality in the - GIT environment. You can easily manage your patches in the scope of GIT + Stacked Git provides a quilt-like patch management functionality in the + Git environment. You can easily manage your patches in the scope of Git until they get merged upstream. @@ -45,33 +45,33 @@ History Viewers - *gitk* (shipped with git-core) - gitk is a simple Tk GUI for browsing history of GIT repositories easily. + gitk is a simple Tk GUI for browsing history of Git repositories easily. - *gitview* (contrib/) - gitview is a GTK based repository browser for git + gitview is a GTK based repository browser for Git - *gitweb* (shipped with git-core) - GITweb provides full-fledged web interface for GIT repositories. + Gitweb provides full-fledged web interface for Git repositories. - *qgit* (http://digilander.libero.it/mcostalba/) - QGit is a git/StGIT GUI viewer built on Qt/C++. QGit could be used + QGit is a git/StGit GUI viewer built on Qt/C++. QGit could be used to browse history and directory tree, view annotated files, commit changes cherry picking single files or applying patches. - Currently it is the fastest and most feature rich among the git + Currently it is the fastest and most feature rich among the Git viewers and commit tools. - *tig* (http://jonas.nitro.dk/tig/) - tig by Jonas Fonseca is a simple git repository browser + tig by Jonas Fonseca is a simple Git repository browser written using ncurses. Basically, it just acts as a front-end for git-log and git-show/git-diff. Additionally, you can also - use it as a pager for git commands. + use it as a pager for Git commands. Foreign SCM interface @@ -80,20 +80,20 @@ Foreign SCM interface - *git-svn* (shipped with git-core) git-svn is a simple conduit for changesets between a single Subversion - branch and git. + branch and Git. - *quilt2git / git2quilt* (http://home-tj.org/wiki/index.php/Misc) These utilities convert patch series in a quilt repository and commit - series in git back and forth. + series in Git back and forth. - *hg-to-git* (contrib/) - hg-to-git converts a Mercurial repository into a git one, and + hg-to-git converts a Mercurial repository into a Git one, and preserves the full branch history in the process. hg-to-git can - also be used in an incremental way to keep the git repository + also be used in an incremental way to keep the Git repository in sync with the master Mercurial repository. @@ -102,14 +102,14 @@ Others - *(h)gct* (http://www.cyd.liu.se/users/~freku045/gct/) - Commit Tool or (h)gct is a GUI enabled commit tool for git and + Commit Tool or (h)gct is a GUI enabled commit tool for Git and Mercurial (hg). It allows the user to view diffs, select which files to committed (or ignored / reverted) write commit messages and perform the commit itself. - *git.el* (contrib/) - This is an Emacs interface for git. The user interface is modeled on + This is an Emacs interface for Git. The user interface is modeled on pcl-cvs. It has been developed on Emacs 21 and will probably need some tweaking to work on XEmacs. diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt index 9d0b1515c5..77a912d4ea 100644 --- a/Documentation/git-update-index.txt +++ b/Documentation/git-update-index.txt @@ -82,10 +82,10 @@ OPTIONS When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "assume unchanged" bit for the - paths. When the "assume unchanged" bit is on, git stops + paths. When the "assume unchanged" bit is on, Git stops checking the working tree files for possible modifications, so you need to manually unset the bit to - tell git when you change the working tree file. This is + tell Git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs). @@ -253,18 +253,18 @@ $ git ls-files -s Using ``assume unchanged'' bit ------------------------------ -Many operations in git depend on your filesystem to have an +Many operations in Git depend on your filesystem to have an efficient `lstat(2)` implementation, so that `st_mtime` information for working tree files can be cheaply checked to see if the file contents have changed from the version recorded in the index file. Unfortunately, some filesystems have inefficient `lstat(2)`. If your filesystem is one of them, you can set "assume unchanged" bit to paths you have not changed to -cause git not to do this check. Note that setting this bit on a -path does not mean git will check the contents of the file to -see if it has changed -- it makes git to omit any checking and +cause Git not to do this check. Note that setting this bit on a +path does not mean Git will check the contents of the file to +see if it has changed -- it makes Git to omit any checking and assume it has *not* changed. When you make changes to working -tree files, you have to explicitly tell git about it by dropping +tree files, you have to explicitly tell Git about it by dropping "assume unchanged" bit, either before or after you modify them. In order to set "assume unchanged" bit, use `--assume-unchanged` @@ -274,7 +274,7 @@ have the "assume unchanged" bit set, use `git ls-files -v` The command looks at `core.ignorestat` configuration variable. When this is true, paths updated with `git update-index paths...` and -paths updated with other git commands that update both index and +paths updated with other Git commands that update both index and working tree (e.g. 'git apply --index', 'git checkout-index -u', and 'git read-tree -u') are automatically marked as "assume unchanged". Note that "assume unchanged" bit is *not* set if diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt index d377a35243..0df13ff6f4 100644 --- a/Documentation/git-update-ref.txt +++ b/Documentation/git-update-ref.txt @@ -73,7 +73,7 @@ in ref value. Log lines are formatted as: Where "oldsha1" is the 40 character hexadecimal value previously stored in <ref>, "newsha1" is the 40 character hexadecimal value of <newvalue> and "committer" is the committer's name, email address -and date in the standard GIT committer ident format. +and date in the standard Git committer ident format. Optionally with -m: diff --git a/Documentation/git-upload-archive.txt b/Documentation/git-upload-archive.txt index 4d52d3833a..d09bbb52b1 100644 --- a/Documentation/git-upload-archive.txt +++ b/Documentation/git-upload-archive.txt @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- Invoked by 'git archive --remote' and sends a generated archive to the -other end over the git protocol. +other end over the Git protocol. This command is usually not invoked directly by the end user. The UI for the protocol is on the 'git archive' side, and the program pair diff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt index 71f16083d6..0abc806ea9 100644 --- a/Documentation/git-upload-pack.txt +++ b/Documentation/git-upload-pack.txt @@ -26,7 +26,7 @@ OPTIONS ------- --strict:: - Do not try <directory>/.git/ if <directory> is no git directory. + Do not try <directory>/.git/ if <directory> is no Git directory. --timeout=<n>:: Interrupt transfer after <n> seconds of inactivity. diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt index 67edf58689..44ff9541df 100644 --- a/Documentation/git-var.txt +++ b/Documentation/git-var.txt @@ -3,7 +3,7 @@ git-var(1) NAME ---- -git-var - Show a git logical variable +git-var - Show a Git logical variable SYNOPSIS @@ -13,13 +13,13 @@ SYNOPSIS DESCRIPTION ----------- -Prints a git logical variable. +Prints a Git logical variable. OPTIONS ------- -l:: Cause the logical variables to be listed. In addition, all the - variables of the git configuration file .git/config are listed + variables of the Git configuration file .git/config are listed as well. (However, the configuration variables listing functionality is deprecated in favor of `git config -l`.) @@ -35,10 +35,10 @@ GIT_AUTHOR_IDENT:: The author of a piece of code. GIT_COMMITTER_IDENT:: - The person who put a piece of code into git. + The person who put a piece of code into Git. GIT_EDITOR:: - Text editor for use by git commands. The value is meant to be + Text editor for use by Git commands. The value is meant to be interpreted by the shell when it is used. Examples: `~/bin/vi`, `$SOME_ENVIRONMENT_VARIABLE`, `"C:\Program Files\Vim\gvim.exe" --nofork`. The order of preference is the `$GIT_EDITOR` @@ -50,7 +50,7 @@ ifdef::git-default-editor[] endif::git-default-editor[] GIT_PAGER:: - Text viewer for use by git commands (e.g., 'less'). The value + Text viewer for use by Git commands (e.g., 'less'). The value is meant to be interpreted by the shell. The order of preference is the `$GIT_PAGER` environment variable, then `core.pager` configuration, then `$PAGER`, and then the default chosen at diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt index cd230769fd..0eb9ffbdd2 100644 --- a/Documentation/git-verify-pack.txt +++ b/Documentation/git-verify-pack.txt @@ -3,7 +3,7 @@ git-verify-pack(1) NAME ---- -git-verify-pack - Validate packed git archive files +git-verify-pack - Validate packed Git archive files SYNOPSIS @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION ----------- -Reads given idx file for packed git archive created with the +Reads given idx file for packed Git archive created with the 'git pack-objects' command and verifies idx file and the corresponding pack file. diff --git a/Documentation/git-verify-tag.txt b/Documentation/git-verify-tag.txt index 5ff76e892a..e996135be9 100644 --- a/Documentation/git-verify-tag.txt +++ b/Documentation/git-verify-tag.txt @@ -21,7 +21,7 @@ OPTIONS Print the contents of the tag object before validating it. <tag>...:: - SHA1 identifiers of git tag objects. + SHA1 identifiers of Git tag objects. GIT --- diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt index c2bc87bc61..ba79cb4f35 100644 --- a/Documentation/git-web--browse.txt +++ b/Documentation/git-web--browse.txt @@ -3,7 +3,7 @@ git-web{litdd}browse(1) NAME ---- -git-web--browse - git helper script to launch a web browser +git-web--browse - Git helper script to launch a web browser SYNOPSIS -------- @@ -50,7 +50,7 @@ OPTIONS -c <conf.var>:: --config=<conf.var>:: - CONF.VAR is looked up in the git config files. If it's set, + CONF.VAR is looked up in the Git config files. If it's set, then its value specifies the browser that should be used. CONFIGURATION VARIABLES diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt index 6c8f510c3f..c600b61e2b 100644 --- a/Documentation/git-whatchanged.txt +++ b/Documentation/git-whatchanged.txt @@ -24,7 +24,7 @@ This manual page describes only the most frequently used options. OPTIONS ------- -p:: - Show textual diffs, instead of the git internal diff + Show textual diffs, instead of the Git internal diff output format that is useful only to tell the changed paths and their nature of changes. @@ -36,7 +36,7 @@ OPTIONS exclusive, top inclusive). -r:: - Show git internal diff output, but for the whole tree, + Show Git internal diff output, but for the whole tree, not just the top level. -m:: diff --git a/Documentation/git.txt b/Documentation/git.txt index 555250dfa0..0b681d9a14 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -27,11 +27,11 @@ commands. The link:user-manual.html[Git User's Manual] has a more in-depth introduction. After you mastered the basic concepts, you can come back to this -page to learn what commands git offers. You can learn more about -individual git commands with "git help command". linkgit:gitcli[7] +page to learn what commands Git offers. You can learn more about +individual Git commands with "git help command". linkgit:gitcli[7] manual page gives you an overview of the command line command syntax. -Formatted and hyperlinked version of the latest git documentation +Formatted and hyperlinked version of the latest Git documentation can be viewed at `http://git-htmldocs.googlecode.com/git/git.html`. ifdef::stalenotes[] @@ -39,13 +39,15 @@ ifdef::stalenotes[] ============ You are reading the documentation for the latest (possibly -unreleased) version of git, that is available from 'master' +unreleased) version of Git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.8.1.1/git.html[documentation for release 1.8.1.1] +* link:v1.8.1.3/git.html[documentation for release 1.8.1.3] * release notes for + link:RelNotes/1.8.1.3.txt[1.8.1.3], + link:RelNotes/1.8.1.2.txt[1.8.1.2], link:RelNotes/1.8.1.1.txt[1.8.1.1], link:RelNotes/1.8.1.txt[1.8.1]. @@ -355,12 +357,12 @@ endif::stalenotes[] OPTIONS ------- --version:: - Prints the git suite version that the 'git' program came from. + Prints the Git suite version that the 'git' program came from. --help:: Prints the synopsis and a list of the most commonly used commands. If the option '--all' or '-a' is given then all - available commands are printed. If a git command is named this + available commands are printed. If a Git command is named this option will bring up the manual page for that command. + Other options are available to control how the manual page is @@ -375,22 +377,22 @@ help ...`. 'git config' (subkeys separated by dots). --exec-path[=<path>]:: - Path to wherever your core git programs are installed. + Path to wherever your core Git programs are installed. This can also be controlled by setting the GIT_EXEC_PATH environment variable. If no path is given, 'git' will print the current setting and then exit. --html-path:: - Print the path, without trailing slash, where git's HTML + Print the path, without trailing slash, where Git's HTML documentation is installed and exit. --man-path:: Print the manpath (see `man(1)`) for the man pages for - this version of git and exit. + this version of Git and exit. --info-path:: Print the path where the Info files documenting this - version of git are installed and exit. + version of Git are installed and exit. -p:: --paginate:: @@ -400,7 +402,7 @@ help ...`. below). --no-pager:: - Do not pipe git output into a pager. + Do not pipe Git output into a pager. --git-dir=<path>:: Set the path to the repository. This can also be controlled by @@ -416,7 +418,7 @@ help ...`. more detailed discussion). --namespace=<path>:: - Set the git namespace. See linkgit:gitnamespaces[7] for more + Set the Git namespace. See linkgit:gitnamespaces[7] for more details. Equivalent to setting the `GIT_NAMESPACE` environment variable. @@ -426,7 +428,7 @@ help ...`. directory. --no-replace-objects:: - Do not use replacement refs to replace git objects. See + Do not use replacement refs to replace Git objects. See linkgit:git-replace[1] for more information. --literal-pathspecs:: @@ -438,7 +440,7 @@ help ...`. GIT COMMANDS ------------ -We divide git into high level ("porcelain") commands and low level +We divide Git into high level ("porcelain") commands and low level ("plumbing") commands. High-level commands (porcelain) @@ -475,7 +477,7 @@ include::cmds-foreignscminterface.txt[] Low-level commands (plumbing) ----------------------------- -Although git includes its +Although Git includes its own porcelain layer, its low-level commands are sufficient to support development of alternative porcelains. Developers of such porcelains might start by reading about linkgit:git-update-index[1] and @@ -596,7 +598,7 @@ Identifier Terminology Symbolic Identifiers -------------------- -Any git command accepting any <object> can also use the following +Any Git command accepting any <object> can also use the following symbolic notation: HEAD:: @@ -632,13 +634,13 @@ Please see linkgit:gitglossary[7]. Environment Variables --------------------- -Various git commands use the following environment variables: +Various Git commands use the following environment variables: -The git Repository +The Git Repository ~~~~~~~~~~~~~~~~~~ -These environment variables apply to 'all' core git commands. Nb: it +These environment variables apply to 'all' core Git commands. Nb: it is worth noting that they may be used/overridden by SCMS sitting above -git so take care if using Cogito etc. +Git so take care if using Cogito etc. 'GIT_INDEX_FILE':: This environment allows the specification of an alternate @@ -652,10 +654,10 @@ git so take care if using Cogito etc. directory is used. 'GIT_ALTERNATE_OBJECT_DIRECTORIES':: - Due to the immutable nature of git objects, old objects can be + Due to the immutable nature of Git objects, old objects can be archived into shared, read-only directories. This variable specifies a ":" separated (on Windows ";" separated) list - of git object directories which can be used to search for git + of Git object directories which can be used to search for Git objects. New objects will not be written to these directories. 'GIT_DIR':: @@ -672,12 +674,12 @@ git so take care if using Cogito etc. option and the core.worktree configuration variable. 'GIT_NAMESPACE':: - Set the git namespace; see linkgit:gitnamespaces[7] for details. + Set the Git namespace; see linkgit:gitnamespaces[7] for details. The '--namespace' command-line option also sets this value. 'GIT_CEILING_DIRECTORIES':: This should be a colon-separated list of absolute paths. - If set, it is a list of directories that git should not chdir + If set, it is a list of directories that Git should not chdir up into while looking for a repository directory. It will not exclude the current working directory or a GIT_DIR set on the command line or in the environment. @@ -685,15 +687,15 @@ git so take care if using Cogito etc. 'GIT_DISCOVERY_ACROSS_FILESYSTEM':: When run in a directory that does not have ".git" repository - directory, git tries to find such a directory in the parent + directory, Git tries to find such a directory in the parent directories to find the top of the working tree, but by default it does not cross filesystem boundaries. This environment variable - can be set to true to tell git not to stop at filesystem + can be set to true to tell Git not to stop at filesystem boundaries. Like 'GIT_CEILING_DIRECTORIES', this will not affect an explicit repository directory set via 'GIT_DIR' or on the command line. -git Commits +Git Commits ~~~~~~~~~~~ 'GIT_AUTHOR_NAME':: 'GIT_AUTHOR_EMAIL':: @@ -704,13 +706,13 @@ git Commits 'EMAIL':: see linkgit:git-commit-tree[1] -git Diffs +Git Diffs ~~~~~~~~~ 'GIT_DIFF_OPTS':: Only valid setting is "--unified=??" or "-u??" to set the number of context lines shown when a unified diff is created. This takes precedence over any "-U" or "--unified" option - value passed on the git diff command line. + value passed on the Git diff command line. 'GIT_EXTERNAL_DIFF':: When the environment variable 'GIT_EXTERNAL_DIFF' is set, the @@ -745,13 +747,13 @@ other 'GIT_PAGER':: This environment variable overrides `$PAGER`. If it is set - to an empty string or to the value "cat", git will not launch + to an empty string or to the value "cat", Git will not launch a pager. See also the `core.pager` option in linkgit:git-config[1]. 'GIT_EDITOR':: This environment variable overrides `$EDITOR` and `$VISUAL`. - It is used by several git commands when, on interactive mode, + It is used by several Git commands when, on interactive mode, an editor is to be launched. See also linkgit:git-var[1] and the `core.editor` option in linkgit:git-config[1]. @@ -772,7 +774,7 @@ personal `.ssh/config` file. Please consult your ssh documentation for further details. 'GIT_ASKPASS':: - If this environment variable is set, then git commands which need to + If this environment variable is set, then Git commands which need to acquire passwords or passphrases (e.g. for HTTP or IMAP authentication) will call this program with a suitable prompt as command line argument and read the password from its STDOUT. See also the 'core.askpass' @@ -793,30 +795,30 @@ for further details. after each commit-oriented record have been flushed. If this variable is set to "0", the output of these commands will be done using completely buffered I/O. If this environment variable is - not set, git will choose buffered or record-oriented flushing + not set, Git will choose buffered or record-oriented flushing based on whether stdout appears to be redirected to a file or not. 'GIT_TRACE':: If this variable is set to "1", "2" or "true" (comparison - is case insensitive), git will print `trace:` messages on + is case insensitive), Git will print `trace:` messages on stderr telling about alias expansion, built-in command execution and external command execution. If this variable is set to an integer value greater than 1 - and lower than 10 (strictly) then git will interpret this + and lower than 10 (strictly) then Git will interpret this value as an open file descriptor and will try to write the trace messages into this file descriptor. Alternatively, if this variable is set to an absolute path - (starting with a '/' character), git will interpret this + (starting with a '/' character), Git will interpret this as a file path and will try to write the trace messages into it. GIT_LITERAL_PATHSPECS:: - Setting this variable to `1` will cause git to treat all + Setting this variable to `1` will cause Git to treat all pathspecs literally, rather than as glob patterns. For example, running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search for commits that touch the path `*.c`, not any paths that the glob `*.c` matches. You might want this if you are feeding - literal paths to git (e.g., paths previously given to you by + literal paths to Git (e.g., paths previously given to you by `git ls-tree`, `--raw` diff output, etc). @@ -824,10 +826,10 @@ Discussion[[Discussion]] ------------------------ More detail on the following is available from the -link:user-manual.html#git-concepts[git concepts chapter of the +link:user-manual.html#git-concepts[Git concepts chapter of the user-manual] and linkgit:gitcore-tutorial[7]. -A git project normally consists of a working directory with a ".git" +A Git project normally consists of a working directory with a ".git" subdirectory at the top level. The .git directory contains, among other things, a compressed object database representing the complete history of the project, an "index" file which links that history to the current @@ -877,12 +879,12 @@ FURTHER DOCUMENTATION --------------------- See the references in the "description" section to get started -using git. The following is probably more detail than necessary +using Git. The following is probably more detail than necessary for a first-time user. -The link:user-manual.html#git-concepts[git concepts chapter of the +The link:user-manual.html#git-concepts[Git concepts chapter of the user-manual] and linkgit:gitcore-tutorial[7] both provide -introductions to the underlying git architecture. +introductions to the underlying Git architecture. See linkgit:gitworkflows[7] for an overview of recommended workflows. @@ -890,7 +892,7 @@ See also the link:howto-index.html[howto] documents for some useful examples. The internals are documented in the -link:technical/api-index.html[GIT API documentation]. +link:technical/api-index.html[Git API documentation]. Users migrating from CVS may also want to read linkgit:gitcvs-migration[7]. @@ -899,7 +901,7 @@ read linkgit:gitcvs-migration[7]. Authors ------- Git was started by Linus Torvalds, and is currently maintained by Junio -C Hamano. Numerous contributions have come from the git mailing list +C Hamano. Numerous contributions have come from the Git mailing list <git@vger.kernel.org>. http://www.ohloh.net/p/git/contributors/summary gives you a more complete list of contributors. diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index 2698f63cf9..b322a2666c 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -58,7 +58,7 @@ attribute. The rules how the pattern matches paths are the same as in `.gitignore` files; see linkgit:gitignore[5]. Unlike `.gitignore`, negative patterns are forbidden. -When deciding what attributes are assigned to a path, git +When deciding what attributes are assigned to a path, Git consults `$GIT_DIR/info/attributes` file (which has the highest precedence), `.gitattributes` file in the same directory as the path in question, and its parent directories up to the toplevel of the @@ -94,7 +94,7 @@ the name of the attribute prefixed with an exclamation point `!`. EFFECTS ------- -Certain operations by git can be influenced by assigning +Certain operations by Git can be influenced by assigning particular attributes to a path. Currently, the following operations are attributes-aware. @@ -104,7 +104,7 @@ Checking-out and checking-in These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as 'git checkout' and 'git merge' run. They also affect how -git stores the contents you prepare in the working tree in the +Git stores the contents you prepare in the working tree in the repository upon 'git add' and 'git commit'. `text` @@ -124,22 +124,22 @@ Set:: Unset:: - Unsetting the `text` attribute on a path tells git not to + Unsetting the `text` attribute on a path tells Git not to attempt any end-of-line conversion upon checkin or checkout. Set to string value "auto":: When `text` is set to "auto", the path is marked for automatic - end-of-line normalization. If git decides that the content is + end-of-line normalization. If Git decides that the content is text, its line endings are normalized to LF on checkin. Unspecified:: - If the `text` attribute is unspecified, git uses the + If the `text` attribute is unspecified, Git uses the `core.autocrlf` configuration variable to determine if the file should be converted. -Any other value causes git to act as if `text` has been left +Any other value causes Git to act as if `text` has been left unspecified. `eol` @@ -151,13 +151,13 @@ content checks, effectively setting the `text` attribute. Set to string value "crlf":: - This setting forces git to normalize line endings for this + This setting forces Git to normalize line endings for this file on checkin and convert them to CRLF when the file is checked out. Set to string value "lf":: - This setting forces git to normalize line endings to LF on + This setting forces Git to normalize line endings to LF on checkin and prevents conversion to CRLF when the file is checked out. @@ -176,11 +176,11 @@ crlf=input eol=lf End-of-line conversion ^^^^^^^^^^^^^^^^^^^^^^ -While git normally leaves file contents alone, it can be configured to +While Git normally leaves file contents alone, it can be configured to normalize line endings to LF in the repository and, optionally, to convert them to CRLF when files are checked out. -Here is an example that will make git normalize .txt, .vcproj and .sh +Here is an example that will make Git normalize .txt, .vcproj and .sh files, ensure that .vcproj files have CRLF and .sh files have LF in the working directory, and prevent .jpg files from being normalized regardless of their content. @@ -194,7 +194,7 @@ regardless of their content. Other source code management systems normalize all text files in their repositories, and there are two ways to enable similar automatic -normalization in git. +normalization in Git. If you simply want to have CRLF line endings in your working directory regardless of the repository you are working with, you can set the @@ -219,9 +219,9 @@ attribute to "auto" for _all_ files. * text=auto ------------------------ -This ensures that all files that git considers to be text will have +This ensures that all files that Git considers to be text will have normalized (LF) line endings in the repository. The `core.eol` -configuration variable controls which line endings git will use for +configuration variable controls which line endings Git will use for normalized files in your working directory; the default is to use the native line ending for your platform, or CRLF if `core.autocrlf` is set. @@ -234,7 +234,7 @@ directory: ------------------------------------------------- $ echo "* text=auto" >>.gitattributes -$ rm .git/index # Remove the index to force git to +$ rm .git/index # Remove the index to force Git to $ git reset # re-scan the working directory $ git status # Show files that will be normalized $ git add -u @@ -249,17 +249,17 @@ unset their `text` attribute before running 'git add -u'. manual.pdf -text ------------------------ -Conversely, text files that git does not detect can have normalization +Conversely, text files that Git does not detect can have normalization enabled manually. ------------------------ weirdchars.txt text ------------------------ -If `core.safecrlf` is set to "true" or "warn", git verifies if +If `core.safecrlf` is set to "true" or "warn", Git verifies if the conversion is reversible for the current setting of -`core.autocrlf`. For "true", git rejects irreversible -conversions; for "warn", git only prints a warning but accepts +`core.autocrlf`. For "true", Git rejects irreversible +conversions; for "warn", Git only prints a warning but accepts an irreversible conversion. The safety triggers to prevent such a conversion done to the files in the work tree, but there are a few exceptions. Even though... @@ -280,7 +280,7 @@ few exceptions. Even though... `ident` ^^^^^^^ -When the attribute `ident` is set for a path, git replaces +When the attribute `ident` is set for a path, Git replaces `$Id$` in the blob object with `$Id:`, followed by the 40-character hexadecimal blob object name, followed by a dollar sign `$` upon checkout. Any byte sequence that begins with @@ -311,7 +311,7 @@ the appropriate filter program, the project should still be usable. Another use of the content filtering is to store the content that cannot be directly used in the repository (e.g. a UUID that refers to the true -content stored outside git, or an encrypted content) and turn it into a +content stored outside Git, or an encrypted content) and turn it into a usable form upon checkout (e.g. download the external content, or decrypt the encrypted content). @@ -397,7 +397,7 @@ clean/smudge filter or text/eol/ident attributes, merging anything where the attribute is not in place would normally cause merge conflicts. -To prevent these unnecessary merge conflicts, git can be told to run a +To prevent these unnecessary merge conflicts, Git can be told to run a virtual check-out and check-in of all three stages of a file when resolving a three-way merge by setting the `merge.renormalize` configuration variable. This prevents changes caused by check-in @@ -417,11 +417,11 @@ Generating diff text `diff` ^^^^^^ -The attribute `diff` affects how 'git' generates diffs for particular -files. It can tell git whether to generate a textual patch for the path +The attribute `diff` affects how Git generates diffs for particular +files. It can tell Git whether to generate a textual patch for the path or to treat the path as a binary file. It can also affect what line is -shown on the hunk header `@@ -k,l +n,m @@` line, tell git to use an -external command to generate the diff, or ask git to convert binary +shown on the hunk header `@@ -k,l +n,m @@` line, tell Git to use an +external command to generate the diff, or ask Git to convert binary files to a text format before generating the diff. Set:: @@ -449,7 +449,7 @@ String:: specify one or more options, as described in the following section. The options for the diff driver "foo" are defined by the configuration variables in the "diff.foo" section of the - git config file. + Git config file. Defining an external diff driver @@ -467,7 +467,7 @@ To define an external diff driver `jcdiff`, add a section to your command = j-c-diff ---------------------------------------------------------------- -When git needs to show you a diff for the path with `diff` +When Git needs to show you a diff for the path with `diff` attribute set to `jcdiff`, it calls the command you specified with the above configuration, i.e. `j-c-diff`, with 7 parameters, just like `GIT_EXTERNAL_DIFF` program is called. @@ -606,7 +606,7 @@ should generate it separately and send it as a comment _in addition to_ the usual binary diff that you might send. Because text conversion can be slow, especially when doing a -large number of them with `git log -p`, git provides a mechanism +large number of them with `git log -p`, Git provides a mechanism to cache the output and use it in future diffs. To enable caching, set the "cachetextconv" variable in your diff driver's config. For example: @@ -619,7 +619,7 @@ config. For example: This will cache the result of running "exif" on each blob indefinitely. If you change the textconv config variable for a -diff driver, git will automatically invalidate the cache entries +diff driver, Git will automatically invalidate the cache entries and re-run the textconv filter. If you want to invalidate the cache manually (e.g., because your version of "exif" was updated and now produces better output), you can remove the cache @@ -640,7 +640,7 @@ output to resemble unified diff. You are free to locate and report changes in the most appropriate way for your data format. A textconv, by comparison, is much more limiting. You provide a -transformation of the data into a line-oriented text format, and git +transformation of the data into a line-oriented text format, and Git uses its regular diff tools to generate the output. There are several advantages to choosing this method: @@ -650,7 +650,7 @@ advantages to choosing this method: odt2txt). 2. Git diff features. By performing only the transformation step - yourself, you can still utilize many of git's diff features, + yourself, you can still utilize many of Git's diff features, including colorization, word-diff, and combined diffs for merges. 3. Caching. Textconv caching can speed up repeated diffs, such as those @@ -675,7 +675,7 @@ attribute in the `.gitattributes` file: *.ps -diff ------------------------ -This will cause git to generate `Binary files differ` (or a binary +This will cause Git to generate `Binary files differ` (or a binary patch, if binary patches are enabled) instead of a regular diff. However, one may also want to specify other diff driver attributes. For @@ -831,7 +831,7 @@ control per path. Set:: - Notice all types of potential whitespace errors known to git. + Notice all types of potential whitespace errors known to Git. The tab width is taken from the value of the `core.whitespace` configuration variable. @@ -863,7 +863,7 @@ archive files. `export-subst` ^^^^^^^^^^^^^^ -If the attribute `export-subst` is set for a file then git will expand +If the attribute `export-subst` is set for a file then Git will expand several placeholders when adding this file to an archive. The expansion depends on the availability of a commit ID, i.e., if linkgit:git-archive[1] has been given a tree instead of a commit or a @@ -961,7 +961,7 @@ abc -foo -bar the attributes given to path `t/abc` are computed as follows: 1. By examining `t/.gitattributes` (which is in the same - directory as the path in question), git finds that the first + directory as the path in question), Git finds that the first line matches. `merge` attribute is set. It also finds that the second line matches, and attributes `foo` and `bar` are unset. diff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt index 3bc1500eda..dc9e617a10 100644 --- a/Documentation/gitcli.txt +++ b/Documentation/gitcli.txt @@ -3,7 +3,7 @@ gitcli(7) NAME ---- -gitcli - git command line interface and conventions +gitcli - Git command line interface and conventions SYNOPSIS -------- @@ -13,7 +13,7 @@ gitcli DESCRIPTION ----------- -This manual describes the convention used throughout git CLI. +This manual describes the convention used throughout Git CLI. Many commands take revisions (most often "commits", but sometimes "tree-ish", depending on the context and command) and paths as their @@ -32,7 +32,7 @@ arguments. Here are the rules: between the HEAD commit and the work tree as a whole". You can say `git diff HEAD --` to ask for the latter. - * Without disambiguating `--`, git makes a reasonable guess, but errors + * Without disambiguating `--`, Git makes a reasonable guess, but errors out and asking you to disambiguate when ambiguous. E.g. if you have a file called HEAD in your work tree, `git diff HEAD` is ambiguous, and you have to say either `git diff HEAD --` or `git diff -- HEAD` to @@ -60,9 +60,9 @@ see `hello.c` in your working tree with the former, but with the latter you will. Here are the rules regarding the "flags" that you should follow when you are -scripting git: +scripting Git: - * it's preferred to use the non dashed form of git commands, which means that + * it's preferred to use the non dashed form of Git commands, which means that you should prefer `git foo` to `git-foo`. * splitting short options to separate words (prefer `git foo -a -b` @@ -90,7 +90,7 @@ scripting git: ENHANCED OPTION PARSER ---------------------- -From the git 1.5.4 series and further, many git commands (not all of them at the +From the Git 1.5.4 series and further, many Git commands (not all of them at the time of the writing though) come with an enhanced option parser. Here is a list of the facilities provided by this option parser. @@ -117,7 +117,7 @@ usage: git describe [options] <committish>* --------------------------------------------- --help-all:: - Some git commands take options that are only used for plumbing or that + Some Git commands take options that are only used for plumbing or that are deprecated, and such options are hidden from the default usage. This option gives the full list of options. diff --git a/Documentation/gitcore-tutorial.txt b/Documentation/gitcore-tutorial.txt index 5325c5a7d5..59c1c17cca 100644 --- a/Documentation/gitcore-tutorial.txt +++ b/Documentation/gitcore-tutorial.txt @@ -3,7 +3,7 @@ gitcore-tutorial(7) NAME ---- -gitcore-tutorial - A git core tutorial for developers +gitcore-tutorial - A Git core tutorial for developers SYNOPSIS -------- @@ -12,17 +12,17 @@ git * DESCRIPTION ----------- -This tutorial explains how to use the "core" git commands to set up and -work with a git repository. +This tutorial explains how to use the "core" Git commands to set up and +work with a Git repository. -If you just need to use git as a revision control system you may prefer -to start with "A Tutorial Introduction to GIT" (linkgit:gittutorial[7]) or -link:user-manual.html[the GIT User Manual]. +If you just need to use Git as a revision control system you may prefer +to start with "A Tutorial Introduction to Git" (linkgit:gittutorial[7]) or +link:user-manual.html[the Git User Manual]. However, an understanding of these low-level tools can be helpful if -you want to understand git's internals. +you want to understand Git's internals. -The core git is often called "plumbing", with the prettier user +The core Git is often called "plumbing", with the prettier user interfaces on top of it called "porcelain". You may not want to use the plumbing directly very often, but it can be good to know what the plumbing does for when the porcelain isn't flushing. @@ -40,19 +40,19 @@ Deeper technical details are often marked as Notes, which you can skip on your first reading. -Creating a git repository +Creating a Git repository ------------------------- -Creating a new git repository couldn't be easier: all git repositories start +Creating a new Git repository couldn't be easier: all Git repositories start out empty, and the only thing you need to do is find yourself a subdirectory that you want to use as a working tree - either an empty one for a totally new project, or an existing working tree that you want -to import into git. +to import into Git. For our first example, we're going to start a totally new repository from scratch, with no pre-existing files, and we'll call it 'git-tutorial'. To start up, create a subdirectory for it, change into that -subdirectory, and initialize the git infrastructure with 'git init': +subdirectory, and initialize the Git infrastructure with 'git init': ------------------------------------------------ $ mkdir git-tutorial @@ -60,13 +60,13 @@ $ cd git-tutorial $ git init ------------------------------------------------ -to which git will reply +to which Git will reply ---------------- Initialized empty Git repository in .git/ ---------------- -which is just git's way of saying that you haven't been doing anything +which is just Git's way of saying that you haven't been doing anything strange, and that it will have created a local `.git` directory setup for your new project. You will now have a `.git` directory, and you can inspect that with 'ls'. For your new empty project, it should show you @@ -102,7 +102,7 @@ start out expecting to work on the `master` branch. However, this is only a convention, and you can name your branches anything you want, and don't have to ever even 'have' a `master` -branch. A number of the git tools will assume that `.git/HEAD` is +branch. A number of the Git tools will assume that `.git/HEAD` is valid, though. [NOTE] @@ -119,18 +119,18 @@ populating your tree. An advanced user may want to take a look at linkgit:gitrepository-layout[5] after finishing this tutorial. -You have now created your first git repository. Of course, since it's +You have now created your first Git repository. Of course, since it's empty, that's not very useful, so let's start populating it with data. -Populating a git repository +Populating a Git repository --------------------------- We'll keep this simple and stupid, so we'll start off with populating a few trivial files just to get a feel for it. Start off with just creating any random files that you want to maintain -in your git repository. We'll start off with a few bad examples, just to +in your Git repository. We'll start off with a few bad examples, just to get a feel for how this works: ------------------------------------------------ @@ -146,7 +146,7 @@ but to actually check in your hard work, you will have to go through two steps: - commit that index file as an object. -The first step is trivial: when you want to tell git about any changes +The first step is trivial: when you want to tell Git about any changes to your working tree, you use the 'git update-index' program. That program normally just takes a list of filenames you want to update, but to avoid trivial mistakes, it refuses to add new entries to the index @@ -160,10 +160,10 @@ So to populate the index with the two files you just created, you can do $ git update-index --add hello example ------------------------------------------------ -and you have now told git to track those two files. +and you have now told Git to track those two files. In fact, as you did that, if you now look into your object directory, -you'll notice that git will have added two new objects to the object +you'll notice that Git will have added two new objects to the object database. If you did exactly the steps above, you should now be able to do @@ -189,7 +189,7 @@ $ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238 ---------------- where the `-t` tells 'git cat-file' to tell you what the "type" of the -object is. git will tell you that you have a "blob" object (i.e., just a +object is. Git will tell you that you have a "blob" object (i.e., just a regular file), and you can see the contents with ---------------- @@ -214,28 +214,28 @@ Anyway, as we mentioned previously, you normally never actually take a look at the objects themselves, and typing long 40-character hex names is not something you'd normally want to do. The above digression was just to show that 'git update-index' did something magical, and -actually saved away the contents of your files into the git object +actually saved away the contents of your files into the Git object database. Updating the index did something else too: it created a `.git/index` file. This is the index that describes your current working tree, and something you should be very aware of. Again, you normally never worry about the index file itself, but you should be aware of the fact that -you have not actually really "checked in" your files into git so far, -you've only *told* git about them. +you have not actually really "checked in" your files into Git so far, +you've only *told* Git about them. -However, since git knows about them, you can now start using some of the -most basic git commands to manipulate the files or look at their status. +However, since Git knows about them, you can now start using some of the +most basic Git commands to manipulate the files or look at their status. -In particular, let's not even check in the two files into git yet, we'll +In particular, let's not even check in the two files into Git yet, we'll start off by adding another line to `hello` first: ------------------------------------------------ $ echo "It's a new day for git" >>hello ------------------------------------------------ -and you can now, since you told git about the previous state of `hello`, ask -git what has changed in the tree compared to your old index, using the +and you can now, since you told Git about the previous state of `hello`, ask +Git what has changed in the tree compared to your old index, using the 'git diff-files' command: ------------ @@ -282,11 +282,11 @@ index 557db03..263414f 100644 ------------ -Committing git state +Committing Git state -------------------- -Now, we want to go to the next stage in git, which is to take the files -that git knows about in the index, and commit them as a real tree. We do +Now, we want to go to the next stage in Git, which is to take the files +that Git knows about in the index, and commit them as a real tree. We do that in two phases: creating a 'tree' object, and committing that 'tree' object as a 'commit' object together with an explanation of what the tree was all about, along with information of how we came to that state. @@ -296,7 +296,7 @@ There are no options or other input: `git write-tree` will take the current index state, and write an object that describes that whole index. In other words, we're now tying together all the different filenames with their contents (and their permissions), and we're -creating the equivalent of a git "directory" object: +creating the equivalent of a Git "directory" object: ------------------------------------------------ $ git write-tree @@ -415,9 +415,9 @@ regardless of whether the `--cached` flag is used or not. The `--cached` flag really only determines whether the file *contents* to be compared come from the working tree or not. -This is not hard to understand, as soon as you realize that git simply +This is not hard to understand, as soon as you realize that Git simply never knows (or cares) about files that it is not told about -explicitly. git will never go *looking* for files to compare, it +explicitly. Git will never go *looking* for files to compare, it expects you to tell it what the files are, and that's what the index is there for. ================ @@ -433,7 +433,7 @@ update the index cache: $ git update-index hello ------------------------------------------------ -(note how we didn't need the `--add` flag this time, since git knew +(note how we didn't need the `--add` flag this time, since Git knew about the file already). Note what happens to the different 'git diff-{asterisk}' versions here. @@ -464,7 +464,7 @@ this point (you can continue to edit things and update the index), you can just leave an empty message. Otherwise `git commit` will commit the change for you. -You've now made your first real git commit. And if you're interested in +You've now made your first real Git commit. And if you're interested in looking at what `git commit` really does, feel free to investigate: it's a few very simple shell scripts to generate the helpful (?) commit message headers, and a few one-liners that actually do the @@ -535,7 +535,7 @@ all, but just show the actual commit message. In fact, together with the 'git rev-list' program (which generates a list of revisions), 'git diff-tree' ends up being a veritable fount of changes. A trivial (but very useful) script called 'git whatchanged' is -included with git which does exactly this, and shows a log of recent +included with Git which does exactly this, and shows a log of recent activities. To see the whole history of our pitiful little git-tutorial project, you @@ -563,19 +563,19 @@ the log.showroot configuration variable to false. Having this, you can still show it for each command just adding the `--root` option, which is a flag for 'git diff-tree' accepted by both commands. -With that, you should now be having some inkling of what git does, and +With that, you should now be having some inkling of what Git does, and can explore on your own. [NOTE] Most likely, you are not directly using the core -git Plumbing commands, but using Porcelain such as 'git add', `git-rm' +Git Plumbing commands, but using Porcelain such as 'git add', `git-rm' and `git-commit'. Tagging a version ----------------- -In git, there are two kinds of tags, a "light" one, and an "annotated tag". +In Git, there are two kinds of tags, a "light" one, and an "annotated tag". A "light" tag is technically nothing more than a branch, except we put it in the `.git/refs/tags/` subdirectory instead of calling it a `head`. @@ -598,7 +598,7 @@ obviously be an empty diff, but if you continue to develop and commit stuff, you can use your tag as an "anchor-point" to see what has changed since you tagged it. -An "annotated tag" is actually a real git object, and contains not only a +An "annotated tag" is actually a real Git object, and contains not only a pointer to the state you want to tag, but also a small tag name and message, along with optionally a PGP signature that says that yes, you really did @@ -623,17 +623,17 @@ name for the state at that point. Copying repositories -------------------- -git repositories are normally totally self-sufficient and relocatable. +Git repositories are normally totally self-sufficient and relocatable. Unlike CVS, for example, there is no separate notion of -"repository" and "working tree". A git repository normally *is* the -working tree, with the local git information hidden in the `.git` +"repository" and "working tree". A Git repository normally *is* the +working tree, with the local Git information hidden in the `.git` subdirectory. There is nothing else. What you see is what you got. [NOTE] -You can tell git to split the git internal information from +You can tell Git to split the Git internal information from the directory that it tracks, but we'll ignore that for now: it's not how normal projects work, and it's really only meant for special uses. -So the mental model of "the git information is always tied directly to +So the mental model of "the Git information is always tied directly to the working tree that it describes" may not be technically 100% accurate, but it's a good model for all normal use. @@ -649,13 +649,13 @@ $ rm -rf git-tutorial and it will be gone. There's no external repository, and there's no history outside the project you created. - - if you want to move or duplicate a git repository, you can do so. There + - if you want to move or duplicate a Git repository, you can do so. There is 'git clone' command, but if all you want to do is just to create a copy of your repository (with all the full history that went along with it), you can do so with a regular `cp -a git-tutorial new-git-tutorial`. + -Note that when you've moved or copied a git repository, your git index +Note that when you've moved or copied a Git repository, your Git index file (which caches various information, notably some of the "stat" information for the files involved) will likely need to be refreshed. So after you do a `cp -a` to create a new copy, you'll want to do @@ -667,7 +667,7 @@ $ git update-index --refresh in the new repository to make sure that the index file is up-to-date. Note that the second point is true even across machines. You can -duplicate a remote git repository with *any* regular copy mechanism, be it +duplicate a remote Git repository with *any* regular copy mechanism, be it 'scp', 'rsync' or 'wget'. When copying a remote repository, you'll want to at a minimum update the @@ -694,23 +694,23 @@ The above can also be written as simply $ git reset ---------------- -and in fact a lot of the common git command combinations can be scripted +and in fact a lot of the common Git command combinations can be scripted with the `git xyz` interfaces. You can learn things by just looking at what the various git scripts do. For example, `git reset` used to be the above two lines implemented in 'git reset', but some things like 'git status' and 'git commit' are slightly more complex scripts around -the basic git commands. +the basic Git commands. Many (most?) public remote repositories will not contain any of the checked out files or even an index file, and will *only* contain the -actual core git files. Such a repository usually doesn't even have the -`.git` subdirectory, but has all the git files directly in the +actual core Git files. Such a repository usually doesn't even have the +`.git` subdirectory, but has all the Git files directly in the repository. -To create your own local live copy of such a "raw" git repository, you'd +To create your own local live copy of such a "raw" Git repository, you'd first create your own subdirectory for the project, and then copy the raw repository contents into the `.git` directory. For example, to -create your own copy of the git repository, you'd do the following +create your own copy of the Git repository, you'd do the following ---------------- $ mkdir my-git @@ -725,7 +725,7 @@ $ git read-tree HEAD ---------------- to populate the index. However, now you have populated the index, and -you have all the git internal files, but you will notice that you don't +you have all the Git internal files, but you will notice that you don't actually have any of the working tree files to work on. To get those, you'd check them out with @@ -757,7 +757,7 @@ repository, and checked it out. Creating a new branch --------------------- -Branches in git are really nothing more than pointers into the git +Branches in Git are really nothing more than pointers into the Git object database from within the `.git/refs/` subdirectory, and as we already discussed, the `HEAD` branch is nothing but a symlink to one of these object pointers. @@ -849,7 +849,7 @@ $ git commit -m "Some work." -i hello Here, we just added another line to `hello`, and we used a shorthand for doing both `git update-index hello` and `git commit` by just giving the filename directly to `git commit`, with an `-i` flag (it tells -git to 'include' that file in addition to what you have done to +Git to 'include' that file in addition to what you have done to the index file so far when making the commit). The `-m` flag is to give the commit log message from the command line. @@ -900,7 +900,7 @@ where the first argument is going to be used as the commit message if the merge can be resolved automatically. Now, in this case we've intentionally created a situation where the -merge will need to be fixed up by hand, though, so git will do as much +merge will need to be fixed up by hand, though, so Git will do as much of it as it can automatically (which in this case is just merge the `example` file, which had no differences in the `mybranch` branch), and say: @@ -939,7 +939,7 @@ After you're done, start up `gitk --all` to see graphically what the history looks like. Notice that `mybranch` still exists, and you can switch to it, and continue to work with it if you want to. The `mybranch` branch will not contain the merge, but next time you merge it -from the `master` branch, git will know how you merged it, so you'll not +from the `master` branch, Git will know how you merged it, so you'll not have to do _that_ merge again. Another useful tool, especially if you do not always work in X-Window @@ -1028,7 +1028,7 @@ Merging external work --------------------- It's usually much more common that you merge with somebody else than -merging with your own branches, so it's worth pointing out that git +merging with your own branches, so it's worth pointing out that Git makes that very easy too, and in fact, it's not that different from doing a 'git merge'. In fact, a remote merge ends up being nothing more than "fetch the work from a remote repository into a temporary tag" @@ -1068,7 +1068,7 @@ and requires you to have a log-in privilege over `ssh` to the remote machine. It finds out the set of objects the other side lacks by exchanging the head commits both ends have and transfers (close to) minimum set of objects. It is by far the -most efficient way to exchange git objects between repositories. +most efficient way to exchange Git objects between repositories. Local directory:: `/path/to/repo.git/` @@ -1077,7 +1077,7 @@ This transport is the same as SSH transport but uses 'sh' to run both ends on the local machine instead of running other end on the remote machine via 'ssh'. -git Native:: +Git Native:: `git://remote.machine/path/to/repo.git/` + This transport was designed for anonymous downloading. Like SSH @@ -1099,8 +1099,8 @@ necessary objects. Because of this behavior, they are sometimes also called 'commit walkers'. + The 'commit walkers' are sometimes also called 'dumb -transports', because they do not require any git aware smart -server like git Native transport does. Any stock HTTP server +transports', because they do not require any Git aware smart +server like Git Native transport does. Any stock HTTP server that does not even support directory index would suffice. But you must prepare your repository with 'git update-server-info' to help dumb transport downloaders. @@ -1321,7 +1321,7 @@ update the public repository from it. This is often called [NOTE] This public repository could further be mirrored, and that is -how git repositories at `kernel.org` are managed. +how Git repositories at `kernel.org` are managed. Publishing the changes from your local (private) repository to your remote (public) repository requires a write privilege on @@ -1340,7 +1340,7 @@ done only once. on the remote machine. The communication between the two over the network internally uses an SSH connection. -Your private repository's git directory is usually `.git`, but +Your private repository's Git directory is usually `.git`, but your public repository is often named after the project name, i.e. `<project>.git`. Let's create such a public repository for project `my-git`. After logging into the remote machine, create @@ -1350,7 +1350,7 @@ an empty directory: $ mkdir my-git.git ------------ -Then, make that directory into a git repository by running +Then, make that directory into a Git repository by running 'git init', but this time, since its name is not the usual `.git`, we do things slightly differently: @@ -1389,7 +1389,7 @@ This synchronizes your public repository to match the named branch head (i.e. `master` in this case) and objects reachable from them in your current repository. -As a real example, this is how I update my public git +As a real example, this is how I update my public Git repository. Kernel.org mirror network takes care of the propagation to other publicly visible machines: @@ -1402,9 +1402,9 @@ Packing your repository ----------------------- Earlier, we saw that one file under `.git/objects/??/` directory -is stored for each git object you create. This representation +is stored for each Git object you create. This representation is efficient to create atomically and safely, but -not so convenient to transport over the network. Since git objects are +not so convenient to transport over the network. Since Git objects are immutable once they are created, there is a way to optimize the storage by "packing them together". The command @@ -1472,14 +1472,14 @@ repositories every once in a while. Working with Others ------------------- -Although git is a truly distributed system, it is often +Although Git is a truly distributed system, it is often convenient to organize your project with an informal hierarchy of developers. Linux kernel development is run this way. There is a nice illustration (page 17, "Merges to Mainline") in link:http://www.xenotime.net/linux/mentor/linux-mentoring-2006.pdf[Randy Dunlap's presentation]. It should be stressed that this hierarchy is purely *informal*. -There is nothing fundamental in git that enforces the "chain of +There is nothing fundamental in Git that enforces the "chain of patch flow" this hierarchy implies. You do not have to pull from only one remote repository. @@ -1592,7 +1592,7 @@ Working with Others, Shared Repository Style If you are coming from CVS background, the style of cooperation suggested in the previous section may be new to you. You do not -have to worry. git supports "shared public repository" style of +have to worry. Git supports "shared public repository" style of cooperation you are probably more familiar with as well. See linkgit:gitcvs-migration[7] for the details. @@ -1602,7 +1602,7 @@ Bundling your work together It is likely that you will be working on more than one thing at a time. It is easy to manage those more-or-less independent tasks -using branches with git. +using branches with Git. We have already seen how branches work previously, with "fun and work" example using two branches. The idea is the diff --git a/Documentation/gitcredentials.txt b/Documentation/gitcredentials.txt index 7dfffc0046..47576be5db 100644 --- a/Documentation/gitcredentials.txt +++ b/Documentation/gitcredentials.txt @@ -3,7 +3,7 @@ gitcredentials(7) NAME ---- -gitcredentials - providing usernames and passwords to git +gitcredentials - providing usernames and passwords to Git SYNOPSIS -------- @@ -18,13 +18,13 @@ DESCRIPTION Git will sometimes need credentials from the user in order to perform operations; for example, it may need to ask for a username and password in order to access a remote repository over HTTP. This manual describes -the mechanisms git uses to request these credentials, as well as some +the mechanisms Git uses to request these credentials, as well as some features to avoid inputting these credentials repeatedly. REQUESTING CREDENTIALS ---------------------- -Without any credential helpers defined, git will try the following +Without any credential helpers defined, Git will try the following strategies to ask the user for usernames and passwords: 1. If the `GIT_ASKPASS` environment variable is set, the program @@ -59,7 +59,7 @@ for a password. It is generally configured by adding this to your config: username = me --------------------------------------- -Credential helpers, on the other hand, are external programs from which git can +Credential helpers, on the other hand, are external programs from which Git can request both usernames and passwords; they typically interface with secure storage provided by the OS or other programs. @@ -79,7 +79,7 @@ store:: You may also have third-party helpers installed; search for `credential-*` in the output of `git help -a`, and consult the documentation of individual helpers. Once you have selected a helper, -you can tell git to use it by putting its name into the +you can tell Git to use it by putting its name into the credential.helper variable. 1. Find a helper. @@ -95,7 +95,7 @@ credential-foo $ git help credential-foo ------------------------------------------- -3. Tell git to use it. +3. Tell Git to use it. + ------------------------------------------- $ git config --global credential.helper foo @@ -103,7 +103,7 @@ $ git config --global credential.helper foo If there are multiple instances of the `credential.helper` configuration variable, each helper will be tried in turn, and may provide a username, -password, or nothing. Once git has acquired both a username and a +password, or nothing. Once Git has acquired both a username and a password, no more helpers will be tried. @@ -114,7 +114,7 @@ Git considers each credential to have a context defined by a URL. This context is used to look up context-specific configuration, and is passed to any helpers, which may use it as an index into secure storage. -For instance, imagine we are accessing `https://example.com/foo.git`. When git +For instance, imagine we are accessing `https://example.com/foo.git`. When Git looks into a config file to see if a section matches this context, it will consider the two a match if the context is a more-specific subset of the pattern in the config file. For example, if you have this in your config file: @@ -133,10 +133,10 @@ context would not match: username = foo -------------------------------------- -because the hostnames differ. Nor would it match `foo.example.com`; git +because the hostnames differ. Nor would it match `foo.example.com`; Git compares hostnames exactly, without considering whether two hosts are part of the same domain. Likewise, a config entry for `http://example.com` would not -match: git compares the protocols exactly. +match: Git compares the protocols exactly. CONFIGURATION OPTIONS @@ -164,7 +164,7 @@ username:: useHttpPath:: - By default, git does not consider the "path" component of an http URL + By default, Git does not consider the "path" component of an http URL to be worth matching via external helpers. This means that a credential stored for `https://example.com/foo.git` will also be used for `https://example.com/bar.git`. If you do want to distinguish these @@ -175,7 +175,7 @@ CUSTOM HELPERS -------------- You can write your own custom helpers to interface with any system in -which you keep credentials. See the documentation for git's +which you keep credentials. See the documentation for Git's link:technical/api-credentials.html[credentials API] for details. GIT diff --git a/Documentation/gitcvs-migration.txt b/Documentation/gitcvs-migration.txt index aeb0cdc973..5ab5b0727f 100644 --- a/Documentation/gitcvs-migration.txt +++ b/Documentation/gitcvs-migration.txt @@ -3,7 +3,7 @@ gitcvs-migration(7) NAME ---- -gitcvs-migration - git for CVS users +gitcvs-migration - Git for CVS users SYNOPSIS -------- @@ -19,7 +19,7 @@ important than any other. However, you can emulate the CVS model by designating a single shared repository which people can synchronize with; this document explains how to do that. -Some basic familiarity with git is required. Having gone through +Some basic familiarity with Git is required. Having gone through linkgit:gittutorial[7] and linkgit:gitglossary[7] should be sufficient. @@ -81,7 +81,7 @@ other than `master`. Setting Up a Shared Repository ------------------------------ -We assume you have already created a git repository for your project, +We assume you have already created a Git repository for your project, possibly created from scratch or from a tarball (see linkgit:gittutorial[7]), or imported from an already existing CVS repository (see the next section). @@ -101,7 +101,7 @@ Next, give every team member read/write access to this repository. One easy way to do this is to give all the team members ssh access to the machine where the repository is hosted. If you don't want to give them a full shell on the machine, there is a restricted shell which only allows -users to do git pushes and pulls; see linkgit:git-shell[1]. +users to do Git pushes and pulls; see linkgit:git-shell[1]. Put all the committers in the same group, and make the repository writable by that group: @@ -125,7 +125,7 @@ of the project you are interested in and run linkgit:git-cvsimport[1]: $ git cvsimport -C <destination> <module> ------------------------------------------- -This puts a git archive of the named CVS module in the directory +This puts a Git archive of the named CVS module in the directory <destination>, which will be created if necessary. The import checks out from CVS every revision of every file. Reportedly @@ -133,8 +133,8 @@ cvsimport can average some twenty revisions per second, so for a medium-sized project this should not take more than a couple of minutes. Larger projects or remote repositories may take longer. -The main trunk is stored in the git branch named `origin`, and additional -CVS branches are stored in git branches with the same names. The most +The main trunk is stored in the Git branch named `origin`, and additional +CVS branches are stored in Git branches with the same names. The most recent version of the main trunk is also left checked out on the `master` branch, so you can start adding your own changes right away. @@ -160,10 +160,10 @@ You can enforce finer grained permissions using update hooks. See link:howto/update-hook-example.txt[Controlling access to branches using update hooks]. -Providing CVS Access to a git Repository +Providing CVS Access to a Git Repository ---------------------------------------- -It is also possible to provide true CVS access to a git repository, so +It is also possible to provide true CVS access to a Git repository, so that developers can still use CVS; see linkgit:git-cvsserver[1] for details. @@ -171,8 +171,8 @@ Alternative Development Models ------------------------------ CVS users are accustomed to giving a group of developers commit access to -a common repository. As we've seen, this is also possible with git. -However, the distributed nature of git allows other development models, +a common repository. As we've seen, this is also possible with Git. +However, the distributed nature of Git allows other development models, and you may want to first consider whether one of them might be a better fit for your project. diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt index daf1782a31..4ed71c76cb 100644 --- a/Documentation/gitdiffcore.txt +++ b/Documentation/gitdiffcore.txt @@ -254,7 +254,7 @@ pattern. Filepairs that match a glob pattern on an earlier line in the file are output before ones that match a later line, and filepairs that do not match any glob pattern are output last. -As an example, a typical orderfile for the core git probably +As an example, a typical orderfile for the core Git probably would look like this: ------------------------------------------------ diff --git a/Documentation/gitglossary.txt b/Documentation/gitglossary.txt index d77a45aed6..e52de7dbb4 100644 --- a/Documentation/gitglossary.txt +++ b/Documentation/gitglossary.txt @@ -3,7 +3,7 @@ gitglossary(7) NAME ---- -gitglossary - A GIT Glossary +gitglossary - A Git Glossary SYNOPSIS -------- @@ -19,7 +19,7 @@ SEE ALSO linkgit:gittutorial[7], linkgit:gittutorial-2[7], linkgit:gitcvs-migration[7], -link:everyday.html[Everyday git], +link:everyday.html[Everyday Git], link:user-manual.html[The Git User's Manual] GIT diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt index b9003fed24..8181e4ed2a 100644 --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@ -3,7 +3,7 @@ githooks(5) NAME ---- -githooks - Hooks used by git +githooks - Hooks used by Git SYNOPSIS -------- @@ -108,7 +108,7 @@ it is not suppressed by the `--no-verify` option. A non-zero exit means a failure of the hook and aborts the commit. It should not be used as replacement for pre-commit hook. -The sample `prepare-commit-msg` hook that comes with git comments +The sample `prepare-commit-msg` hook that comes with Git comments out the `Conflicts:` part of a merge's commit message. commit-msg @@ -176,6 +176,35 @@ save and restore any form of metadata associated with the working tree (eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl for an example of how to do this. +pre-push +~~~~~~~~ + +This hook is called by 'git push' and can be used to prevent a push from taking +place. The hook is called with two parameters which provide the name and +location of the destination remote, if a named remote is not being used both +values will be the same. + +Information about what is to be pushed is provided on the hook's standard +input with lines of the form: + + <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF + +For instance, if the command +git push origin master:foreign+ were run the +hook would receive a line like the following: + + refs/heads/master 67890 refs/heads/foreign 12345 + +although the full, 40-character SHA1s would be supplied. If the foreign ref +does not yet exist the `<remote SHA1>` will be 40 `0`. If a ref is to be +deleted, the `<local ref>` will be supplied as `(delete)` and the `<local +SHA1>` will be 40 `0`. If the local commit was specified by something other +than a name which could be expanded (such as `HEAD~`, or a SHA1) it will be +supplied as it was originally given. + +If this hook exits with a non-zero status, 'git push' will abort without +pushing anything. Information about why the push is rejected may be sent +to the user by writing to standard error. + [[pre-receive]] pre-receive ~~~~~~~~~~~ @@ -275,7 +304,7 @@ for the user. The default 'post-receive' hook is empty, but there is a sample script `post-receive-email` provided in the `contrib/hooks` -directory in git distribution, which implements sending commit +directory in Git distribution, which implements sending commit emails. [[post-update]] @@ -303,7 +332,7 @@ them. When enabled, the default 'post-update' hook runs 'git update-server-info' to keep the information used by dumb transports (e.g., HTTP) up-to-date. If you are publishing -a git repository that is accessible via HTTP, you should +a Git repository that is accessible via HTTP, you should probably enable this hook. Both standard output and standard error output are forwarded to diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt index 91a6438031..54e334e3af 100644 --- a/Documentation/gitignore.txt +++ b/Documentation/gitignore.txt @@ -13,12 +13,12 @@ DESCRIPTION ----------- A `gitignore` file specifies intentionally untracked files that -git should ignore. -Files already tracked by git are not affected; see the NOTES +Git should ignore. +Files already tracked by Git are not affected; see the NOTES below for details. Each line in a `gitignore` file specifies a pattern. -When deciding whether to ignore a path, git normally checks +When deciding whether to ignore a path, Git normally checks `gitignore` patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome): @@ -53,17 +53,17 @@ be used. the repository but are specific to one user's workflow) should go into the `$GIT_DIR/info/exclude` file. - * Patterns which a user wants git to + * Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user's editor of choice) generally go into a file specified by `core.excludesfile` in the user's `~/.gitconfig`. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead. -The underlying git plumbing tools, such as +The underlying Git plumbing tools, such as 'git ls-files' and 'git read-tree', read `gitignore` patterns specified by command-line options, or from -files specified by command-line options. Higher-level git +files specified by command-line options. Higher-level Git tools, such as 'git status' and 'git add', use patterns from the sources specified above. @@ -89,15 +89,15 @@ PATTERN FORMAT a match with a directory. In other words, `foo/` will match a directory `foo` and paths underneath it, but will not match a regular file or a symbolic link `foo` (this is consistent - with the way how pathspec works in general in git). + with the way how pathspec works in general in Git). - - If the pattern does not contain a slash '/', git treats it as + - If the pattern does not contain a slash '/', Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the `.gitignore` file (relative to the toplevel of the work tree if not from a `.gitignore` file). - - Otherwise, git treats the pattern as a shell glob suitable + - Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/{asterisk}.html" matches @@ -131,7 +131,7 @@ NOTES ----- The purpose of gitignore files is to ensure that certain files -not tracked by git remain untracked. +not tracked by Git remain untracked. To ignore uncommitted changes in a file that is already tracked, use 'git update-index {litdd}assume-unchanged'. @@ -179,13 +179,15 @@ Another example: $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore -------------------------------------------------------------- -The second .gitignore prevents git from ignoring +The second .gitignore prevents Git from ignoring `arch/foo/kernel/vmlinux.lds.S`. SEE ALSO -------- -linkgit:git-rm[1], linkgit:git-update-index[1], -linkgit:gitrepository-layout[5] +linkgit:git-rm[1], +linkgit:git-update-index[1], +linkgit:gitrepository-layout[5], +linkgit:git-check-ignore[1] GIT --- diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt index a17a354936..c17e760184 100644 --- a/Documentation/gitk.txt +++ b/Documentation/gitk.txt @@ -3,7 +3,7 @@ gitk(1) NAME ---- -gitk - The git repository browser +gitk - The Git repository browser SYNOPSIS -------- @@ -18,7 +18,7 @@ the files in the trees of each revision. Historically, gitk was the first repository browser. It's written in tcl/tk and started off in a separate repository but was later merged into the main -git repository. +Git repository. OPTIONS ------- @@ -108,10 +108,10 @@ SEE ALSO 'gitview(1)':: A repository browser written in Python using Gtk. It's based on - 'bzrk(1)' and distributed in the contrib area of the git repository. + 'bzrk(1)' and distributed in the contrib area of the Git repository. 'tig(1)':: - A minimal repository browser and git tool output highlighter written + A minimal repository browser and Git tool output highlighter written in C using Ncurses. GIT diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt index 52d7ae4313..6a1ca4abad 100644 --- a/Documentation/gitmodules.txt +++ b/Documentation/gitmodules.txt @@ -13,7 +13,7 @@ $GIT_WORK_DIR/.gitmodules DESCRIPTION ----------- -The `.gitmodules` file, located in the top-level directory of a git +The `.gitmodules` file, located in the top-level directory of a Git working tree, is a text file with a syntax matching the requirements of linkgit:git-config[1]. @@ -24,7 +24,7 @@ option of 'git submodule add'. Each submodule section also contains the following required keys: submodule.<name>.path:: - Defines the path, relative to the top-level directory of the git + Defines the path, relative to the top-level directory of the Git working tree, where the submodule is expected to be checked out. The path name must not end with a `/`. All submodule paths must be unique within the .gitmodules file. diff --git a/Documentation/gitnamespaces.txt b/Documentation/gitnamespaces.txt index c6713cf5d7..7685e3651a 100644 --- a/Documentation/gitnamespaces.txt +++ b/Documentation/gitnamespaces.txt @@ -29,7 +29,7 @@ prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do. To specify a namespace, set the `GIT_NAMESPACE` environment variable to -the namespace. For each ref namespace, git stores the corresponding +the namespace. For each ref namespace, Git stores the corresponding refs in a directory under `refs/namespaces/`. For example, `GIT_NAMESPACE=foo` will store refs under `refs/namespaces/foo/`. You can also specify namespaces via the `--namespace` option to diff --git a/Documentation/git-remote-helpers.txt b/Documentation/gitremote-helpers.txt index 6d696e0f90..0c91aba861 100644 --- a/Documentation/git-remote-helpers.txt +++ b/Documentation/gitremote-helpers.txt @@ -1,9 +1,9 @@ -git-remote-helpers(1) -===================== +gitremote-helpers(1) +==================== NAME ---- -git-remote-helpers - Helper programs to interact with remote repositories +gitremote-helpers - Helper programs to interact with remote repositories SYNOPSIS -------- @@ -14,17 +14,17 @@ DESCRIPTION ----------- Remote helper programs are normally not used directly by end users, -but they are invoked by git when it needs to interact with remote -repositories git does not support natively. A given helper will -implement a subset of the capabilities documented here. When git +but they are invoked by Git when it needs to interact with remote +repositories Git does not support natively. A given helper will +implement a subset of the capabilities documented here. When Git needs to interact with a repository using a remote helper, it spawns the helper as an independent process, sends commands to the helper's standard input, and expects results from the helper's standard output. Because a remote helper runs as an independent process from -git, there is no need to re-link git to add a new helper, nor any -need to link the helper with the implementation of git. +Git, there is no need to re-link Git to add a new helper, nor any +need to link the helper with the implementation of Git. -Every helper must support the "capabilities" command, which git +Every helper must support the "capabilities" command, which Git uses to determine what other commands the helper will accept. Those other commands can be used to discover and update remote refs, transport objects between the object database and the remote repository, @@ -39,15 +39,15 @@ INVOCATION ---------- Remote helper programs are invoked with one or (optionally) two -arguments. The first argument specifies a remote repository as in git; +arguments. The first argument specifies a remote repository as in Git; it is either the name of a configured remote or a URL. The second argument specifies a URL; it is usually of the form '<transport>://<address>', but any arbitrary string is possible. The 'GIT_DIR' environment variable is set up for the remote helper and can be used to determine where to store additional data or from -which directory to invoke auxiliary git commands. +which directory to invoke auxiliary Git commands. -When git encounters a URL of the form '<transport>://<address>', where +When Git encounters a URL of the form '<transport>://<address>', where '<transport>' is a protocol that it cannot handle natively, it automatically invokes 'git remote-<transport>' with the full URL as the second argument. If such a URL is encountered directly on the @@ -55,14 +55,14 @@ command line, the first argument is the same as the second, and if it is encountered in a configured remote, the first argument is the name of that remote. -A URL of the form '<transport>::<address>' explicitly instructs git to +A URL of the form '<transport>::<address>' explicitly instructs Git to invoke 'git remote-<transport>' with '<address>' as the second argument. If such a URL is encountered directly on the command line, the first argument is '<address>', and if it is encountered in a configured remote, the first argument is the name of that remote. Additionally, when a configured remote has 'remote.<name>.vcs' set to -'<transport>', git explicitly invokes 'git remote-<transport>' with +'<transport>', Git explicitly invokes 'git remote-<transport>' with '<name>' as the first argument. If set, the second argument is 'remote.<name>.url'; otherwise, the second argument is omitted. @@ -85,7 +85,7 @@ Capabilities ~~~~~~~~~~~~ Each remote helper is expected to support only a subset of commands. -The operations a helper supports are declared to git in the response +The operations a helper supports are declared to Git in the response to the `capabilities` command (see COMMANDS, below). In the following, we list all defined capabilities and for @@ -114,10 +114,10 @@ Supported commands: 'list for-push', 'push'. + Supported commands: 'list for-push', 'export'. -If a helper advertises 'connect', git will use it if possible and +If a helper advertises 'connect', Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the 'connect' command under COMMANDS). -When choosing between 'push' and 'export', git prefers 'push'. +When choosing between 'push' and 'export', Git prefers 'push'. Other frontends may have some other order of preference. @@ -126,7 +126,7 @@ Capabilities for Fetching 'connect':: Can try to connect to 'git upload-pack' (for fetching), 'git receive-pack', etc for communication using the - git's native packfile protocol. This + Git's native packfile protocol. This requires a bidirectional, full-duplex connection. + Supported commands: 'connect'. @@ -143,10 +143,10 @@ Supported commands: 'list', 'fetch'. + Supported commands: 'list', 'import'. -If a helper advertises 'connect', git will use it if possible and +If a helper advertises 'connect', Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the 'connect' command under COMMANDS). -When choosing between 'fetch' and 'import', git prefers 'fetch'. +When choosing between 'fetch' and 'import', Git prefers 'fetch'. Other frontends may have some other order of preference. Miscellaneous capabilities @@ -183,22 +183,22 @@ there is an implied `refspec *:*`. to retrieve information about blobs and trees that already exist in fast-import's memory. This requires a channel from fast-import to the remote-helper. - If it is advertised in addition to "import", git establishes a pipe from + If it is advertised in addition to "import", Git establishes a pipe from fast-import to the remote-helper's stdin. - It follows that git and fast-import are both connected to the - remote-helper's stdin. Because git can send multiple commands to + It follows that Git and fast-import are both connected to the + remote-helper's stdin. Because Git can send multiple commands to the remote-helper it is required that helpers that use 'bidi-import' buffer all 'import' commands of a batch before sending data to fast-import. This is to prevent mixing commands and fast-import responses on the helper's stdin. 'export-marks' <file>:: - This modifies the 'export' capability, instructing git to dump the + This modifies the 'export' capability, instructing Git to dump the internal marks table to <file> when complete. For details, read up on '--export-marks=<file>' in linkgit:git-fast-export[1]. 'import-marks' <file>:: - This modifies the 'export' capability, instructing git to load the + This modifies the 'export' capability, instructing Git to load the marks specified in <file> before processing any input. For details, read up on '--import-marks=<file>' in linkgit:git-fast-export[1]. @@ -213,7 +213,7 @@ Commands are given by the caller on the helper's standard input, one per line. 'capabilities':: Lists the capabilities of the helper, one per line, ending with a blank line. Each capability may be preceded with '*', - which marks them mandatory for git versions using the remote + which marks them mandatory for Git versions using the remote helper to understand. Any unknown mandatory capability is a fatal error. + @@ -376,7 +376,7 @@ OPTIONS ------- The following options are defined and (under suitable circumstances) -set by git if the remote helper has the 'option' capability. +set by Git if the remote helper has the 'option' capability. 'option verbosity' <n>:: Changes the verbosity of messages displayed by the helper. diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt index 9f628862b4..f0eef765b9 100644 --- a/Documentation/gitrepository-layout.txt +++ b/Documentation/gitrepository-layout.txt @@ -12,12 +12,24 @@ $GIT_DIR/* DESCRIPTION ----------- -You may find these things in your git repository (`.git` -directory for a repository associated with your working tree, or -`<project>.git` directory for a public 'bare' repository. It is -also possible to have a working tree where `.git` is a plain -ASCII file containing `gitdir: <path>`, i.e. the path to the -real git repository). +A Git repository comes in two different flavours: + + * a `.git` directory at the root of the working tree; + + * a `<project>.git` directory that is a 'bare' repository + (i.e. without its own working tree), that is typically used for + exchanging histories with others by pushing into it and fetching + from it. + +*Note*: Also you can have a plain text file `.git` at the root of +your working tree, containing `gitdir: <path>` to point at the real +directory that has the repository. This mechanism is often used for +a working tree of a submodule checkout, to allow you in the +containing superproject to `git checkout` a branch that does not +have the submodule. The `checkout` has to remove the entire +submodule working tree, without losing the submodule repository. + +These things may exist in a Git repository. objects:: Object store associated with this repository. Usually @@ -108,7 +120,7 @@ HEAD:: A symref (see glossary) to the `refs/heads/` namespace describing the currently active branch. It does not mean much if the repository is not associated with any working tree - (i.e. a 'bare' repository), but a valid git repository + (i.e. a 'bare' repository), but a valid Git repository *must* have the HEAD file; some porcelains may use it to guess the designated "default" branch of the repository (usually 'master'). It is legal if the named branch @@ -131,7 +143,7 @@ branches:: and not likely to be found in modern repositories. hooks:: - Hooks are customization scripts used by various git + Hooks are customization scripts used by various Git commands. A handful of sample hooks are installed when 'git init' is run, but all of them are disabled by default. To enable, the `.sample` suffix has to be @@ -169,7 +181,7 @@ info/exclude:: This file, by convention among Porcelains, stores the exclude pattern list. `.gitignore` is the per-directory ignore file. 'git status', 'git add', 'git rm' and - 'git clean' look at it but the core git commands do not look + 'git clean' look at it but the core Git commands do not look at it. See also: linkgit:gitignore[5]. remotes:: diff --git a/Documentation/gitrevisions.txt b/Documentation/gitrevisions.txt index fc4789f98e..c0ed6d1925 100644 --- a/Documentation/gitrevisions.txt +++ b/Documentation/gitrevisions.txt @@ -3,7 +3,7 @@ gitrevisions(7) NAME ---- -gitrevisions - specifying revisions and ranges for git +gitrevisions - specifying revisions and ranges for Git SYNOPSIS -------- diff --git a/Documentation/gittutorial-2.txt b/Documentation/gittutorial-2.txt index e00a4d2170..94c906eda8 100644 --- a/Documentation/gittutorial-2.txt +++ b/Documentation/gittutorial-2.txt @@ -3,7 +3,7 @@ gittutorial-2(7) NAME ---- -gittutorial-2 - A tutorial introduction to git: part two +gittutorial-2 - A tutorial introduction to Git: part two SYNOPSIS -------- @@ -16,11 +16,11 @@ DESCRIPTION You should work through linkgit:gittutorial[7] before reading this tutorial. The goal of this tutorial is to introduce two fundamental pieces of -git's architecture--the object database and the index file--and to +Git's architecture--the object database and the index file--and to provide the reader with everything necessary to understand the rest -of the git documentation. +of the Git documentation. -The git object database +The Git object database ----------------------- Let's start a new project and create a small amount of history: @@ -42,14 +42,14 @@ $ git commit -a -m "add emphasis" 1 file changed, 1 insertion(+), 1 deletion(-) ------------------------------------------------ -What are the 7 digits of hex that git responded to the commit with? +What are the 7 digits of hex that Git responded to the commit with? We saw in part one of the tutorial that commits have names like this. -It turns out that every object in the git history is stored under +It turns out that every object in the Git history is stored under a 40-digit hex name. That name is the SHA1 hash of the object's -contents; among other things, this ensures that git will never store +contents; among other things, this ensures that Git will never store the same data twice (since identical data is given an identical SHA1 -name), and that the contents of a git object will never change (since +name), and that the contents of a Git object will never change (since that would change the object's name as well). The 7 char hex strings here are simply the abbreviation of such 40 character long strings. Abbreviations can be used everywhere where the 40 character strings @@ -60,7 +60,7 @@ following the example above generates a different SHA1 hash than the one shown above because the commit object records the time when it was created and the name of the person performing the commit. -We can ask git about this particular object with the `cat-file` +We can ask Git about this particular object with the `cat-file` command. Don't copy the 40 hex digits from this example but use those from your own version. Note that you can shorten it to only a few characters to save yourself typing all 40 hex digits: @@ -102,11 +102,11 @@ $ git cat-file blob 3b18e512 hello world ------------------------------------------------ -Note that this is the old file data; so the object that git named in +Note that this is the old file data; so the object that Git named in its response to the initial tree was a tree with a snapshot of the directory state that was recorded by the first commit. -All of these objects are stored under their SHA1 names inside the git +All of these objects are stored under their SHA1 names inside the Git directory: ------------------------------------------------ @@ -191,7 +191,7 @@ Besides blobs, trees, and commits, the only remaining type of object is a "tag", which we won't discuss here; refer to linkgit:git-tag[1] for details. -So now we know how git uses the object database to represent a +So now we know how Git uses the object database to represent a project's history: * "commit" objects refer to "tree" objects representing the @@ -403,21 +403,21 @@ What next? At this point you should know everything necessary to read the man pages for any of the git commands; one good place to start would be -with the commands mentioned in link:everyday.html[Everyday git]. You +with the commands mentioned in link:everyday.html[Everyday Git]. You should be able to find any unknown jargon in linkgit:gitglossary[7]. The link:user-manual.html[Git User's Manual] provides a more -comprehensive introduction to git. +comprehensive introduction to Git. linkgit:gitcvs-migration[7] explains how to -import a CVS repository into git, and shows how to use git in a +import a CVS repository into Git, and shows how to use Git in a CVS-like way. -For some interesting examples of git use, see the +For some interesting examples of Git use, see the link:howto-index.html[howtos]. -For git developers, linkgit:gitcore-tutorial[7] goes -into detail on the lower-level git mechanisms involved in, for +For Git developers, linkgit:gitcore-tutorial[7] goes +into detail on the lower-level Git mechanisms involved in, for example, creating a new commit. SEE ALSO @@ -427,7 +427,7 @@ linkgit:gitcvs-migration[7], linkgit:gitcore-tutorial[7], linkgit:gitglossary[7], linkgit:git-help[1], -link:everyday.html[Everyday git], +link:everyday.html[Everyday Git], link:user-manual.html[The Git User's Manual] GIT diff --git a/Documentation/gittutorial.txt b/Documentation/gittutorial.txt index f1cb6f3be6..8262196318 100644 --- a/Documentation/gittutorial.txt +++ b/Documentation/gittutorial.txt @@ -3,7 +3,7 @@ gittutorial(7) NAME ---- -gittutorial - A tutorial introduction to git (for version 1.5.1 or newer) +gittutorial - A tutorial introduction to Git (for version 1.5.1 or newer) SYNOPSIS -------- @@ -13,10 +13,10 @@ git * DESCRIPTION ----------- -This tutorial explains how to import a new project into git, make +This tutorial explains how to import a new project into Git, make changes to it, and share changes with other developers. -If you are instead primarily interested in using git to fetch a project, +If you are instead primarily interested in using Git to fetch a project, for example, to test the latest version, you may prefer to start with the first two chapters of link:user-manual.html[The Git User's Manual]. @@ -36,7 +36,7 @@ $ git help log With the latter, you can use the manual viewer of your choice; see linkgit:git-help[1] for more information. -It is a good idea to introduce yourself to git with your name and +It is a good idea to introduce yourself to Git with your name and public email address before doing any operation. The easiest way to do so is: @@ -50,7 +50,7 @@ Importing a new project ----------------------- Assume you have a tarball project.tar.gz with your initial work. You -can place it under git revision control as follows. +can place it under Git revision control as follows. ------------------------------------------------ $ tar xzf project.tar.gz @@ -67,14 +67,14 @@ Initialized empty Git repository in .git/ You've now initialized the working directory--you may notice a new directory created, named ".git". -Next, tell git to take a snapshot of the contents of all files under the +Next, tell Git to take a snapshot of the contents of all files under the current directory (note the '.'), with 'git add': ------------------------------------------------ $ git add . ------------------------------------------------ -This snapshot is now stored in a temporary staging area which git calls +This snapshot is now stored in a temporary staging area which Git calls the "index". You can permanently store the contents of the index in the repository with 'git commit': @@ -83,7 +83,7 @@ $ git commit ------------------------------------------------ This will prompt you for a commit message. You've now stored the first -version of your project in git. +version of your project in Git. Making changes -------------- @@ -141,7 +141,7 @@ begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used -throughout git. For example, linkgit:git-format-patch[1] turns a +throughout Git. For example, linkgit:git-format-patch[1] turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body. @@ -180,7 +180,7 @@ $ git log --stat --summary Managing branches ----------------- -A single git repository can maintain multiple branches of +A single Git repository can maintain multiple branches of development. To create a new branch named "experimental", use ------------------------------------------------ @@ -276,10 +276,10 @@ $ git branch -D crazy-idea Branches are cheap and easy, so this is a good way to try something out. -Using git for collaboration +Using Git for collaboration --------------------------- -Suppose that Alice has started a new project with a git repository in +Suppose that Alice has started a new project with a Git repository in /home/alice/project, and that Bob, who has a home directory on the same machine, wants to contribute. @@ -320,7 +320,7 @@ Note that in general, Alice would want her local changes committed before initiating this "pull". If Bob's work conflicts with what Alice did since their histories forked, Alice will use her working tree and the index to resolve conflicts, and existing local changes will interfere with the -conflict resolution process (git will still perform the fetch but will +conflict resolution process (Git will still perform the fetch but will refuse to merge --- Alice will have to get rid of her local changes in some way and pull again when this happens). @@ -422,7 +422,7 @@ bob$ git pull ------------------------------------- Note that he doesn't need to give the path to Alice's repository; -when Bob cloned Alice's repository, git stored the location of her +when Bob cloned Alice's repository, Git stored the location of her repository in the repository configuration, and that location is used for pulls: @@ -450,7 +450,7 @@ perform clones and pulls using the ssh protocol: bob$ git clone alice.org:/home/alice/project myrepo ------------------------------------- -Alternatively, git has a native protocol, or can use rsync or http; +Alternatively, Git has a native protocol, or can use rsync or http; see linkgit:git-pull[1] for details. Git can also be used in a CVS-like mode, with a central repository @@ -518,7 +518,7 @@ share this name with other people (for example, to identify a release version), you should create a "tag" object, and perhaps sign it; see linkgit:git-tag[1] for details. -Any git command that needs to know a commit can take any of these +Any Git command that needs to know a commit can take any of these names. For example: ------------------------------------- @@ -554,9 +554,9 @@ files it manages in your current directory. So $ git grep "hello" ------------------------------------- -is a quick way to search just the files that are tracked by git. +is a quick way to search just the files that are tracked by Git. -Many git commands also take sets of commits, which can be specified +Many Git commands also take sets of commits, which can be specified in a number of ways. Here are some examples with 'git log': ------------------------------------- @@ -592,7 +592,7 @@ then merged back together, the order in which 'git log' presents those commits is meaningless. Most projects with multiple contributors (such as the Linux kernel, -or git itself) have frequent merges, and 'gitk' does a better job of +or Git itself) have frequent merges, and 'gitk' does a better job of visualizing their history. For example, ------------------------------------- @@ -623,7 +623,7 @@ Next Steps This tutorial should be enough to perform basic distributed revision control for your projects. However, to fully understand the depth -and power of git you need to understand two simple ideas on which it +and power of Git you need to understand two simple ideas on which it is based: * The object database is the rather elegant system used to @@ -636,7 +636,7 @@ is based: Part two of this tutorial explains the object database, the index file, and a few other odds and ends that you'll -need to make the most of git. You can find it at linkgit:gittutorial-2[7]. +need to make the most of Git. You can find it at linkgit:gittutorial-2[7]. If you don't want to continue with that right away, a few other digressions that may be interesting at this point are: @@ -656,7 +656,7 @@ digressions that may be interesting at this point are: * linkgit:gitworkflows[7]: Gives an overview of recommended workflows. - * link:everyday.html[Everyday GIT with 20 Commands Or So] + * link:everyday.html[Everyday Git with 20 Commands Or So] * linkgit:gitcvs-migration[7]: Git for CVS users. @@ -668,7 +668,7 @@ linkgit:gitcore-tutorial[7], linkgit:gitglossary[7], linkgit:git-help[1], linkgit:gitworkflows[7], -link:everyday.html[Everyday git], +link:everyday.html[Everyday Git], link:user-manual.html[The Git User's Manual] GIT diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt index 49474557d8..eb636317be 100644 --- a/Documentation/gitweb.conf.txt +++ b/Documentation/gitweb.conf.txt @@ -3,7 +3,7 @@ gitweb.conf(5) NAME ---- -gitweb.conf - Gitweb (git web interface) configuration file +gitweb.conf - Gitweb (Git web interface) configuration file SYNOPSIS -------- @@ -79,7 +79,7 @@ stops declaring it. You can include other configuration file using read_config_file() subroutine. For example, one might want to put gitweb configuration related to access control for viewing repositories via Gitolite (one -of git repository management tools) in a separate file, e.g. in +of Git repository management tools) in a separate file, e.g. in '/etc/gitweb-gitolite.conf'. To include it, put -------------------------------------------------- @@ -111,7 +111,7 @@ and installing gitweb. Location of repositories ~~~~~~~~~~~~~~~~~~~~~~~~ The configuration variables described below control how gitweb finds -git repositories, and how repositories are displayed and accessed. +Git repositories, and how repositories are displayed and accessed. See also "Repositories" and later subsections in linkgit:gitweb[1] manpage. @@ -159,7 +159,7 @@ will fall back to scanning the `$projectroot` directory for repositories. $project_maxdepth:: If `$projects_list` variable is unset, gitweb will recursively - scan filesystem for git repositories. The `$project_maxdepth` + scan filesystem for Git repositories. The `$project_maxdepth` is used to limit traversing depth, relative to `$projectroot` (starting point); it means that directories which are further from `$projectroot` than `$project_maxdepth` will be skipped. @@ -200,7 +200,7 @@ our $export_ok = "git-daemon-export-ok"; + If not set (default), it means that this feature is disabled. + -See also more involved example in "Controlling access to git repositories" +See also more involved example in "Controlling access to Git repositories" subsection on linkgit:gitweb[1] manpage. $strict_export:: @@ -222,18 +222,18 @@ The values of these variables are paths on the filesystem. $GIT:: Core git executable to use. By default set to `$GIT_BINDIR/git`, which - in turn is by default set to `$(bindir)/git`. If you use git installed + in turn is by default set to `$(bindir)/git`. If you use Git installed from a binary package, you should usually set this to "/usr/bin/git". This can just be "git" if your web server has a sensible PATH; from security point of view it is better to use absolute path to git binary. - If you have multiple git versions installed it can be used to choose + If you have multiple Git versions installed it can be used to choose which one to use. Must be (correctly) set for gitweb to be able to work. $mimetypes_file:: File to use for (filename extension based) guessing of MIME types before trying '/etc/mime.types'. *NOTE* that this path, if relative, is taken - as relative to the current git repository, not to CGI script. If unset, + as relative to the current Git repository, not to CGI script. If unset, only '/etc/mime.types' is used (if present on filesystem). If no mimetypes file is found, mimetype guessing based on extension of file is disabled. Unset by default. @@ -343,8 +343,8 @@ $logo_url:: $logo_label:: URI and label (title) for the Git logo link (or your site logo, if you chose to use different logo image). By default, these both - refer to git homepage, http://git-scm.com[]; in the past, they pointed - to git documentation at http://www.kernel.org[]. + refer to Git homepage, http://git-scm.com[]; in the past, they pointed + to Git documentation at http://www.kernel.org[]. Changing gitweb's look @@ -436,7 +436,7 @@ $fallback_encoding:: detection. + *Note* that rename and especially copy detection can be quite -CPU-intensive. Note also that non git tools can have problems with +CPU-intensive. Note also that non Git tools can have problems with patches generated with options mentioned above, especially when they involve file copies (\'-C') or criss-cross renames (\'-B'). @@ -451,7 +451,7 @@ looks does contain variables configuring administrative side of gitweb affects how "summary" pages look like, or load limiting). @git_base_url_list:: - List of git base URLs. These URLs are used to generate URLs + List of Git base URLs. These URLs are used to generate URLs describing from where to fetch a project, which are shown on project summary page. The full fetch URL is "`$git_base_url/$project`", for each element of this list. You can set up multiple base URLs @@ -616,7 +616,7 @@ override:: (or enabled/disabled) on a per-repository basis. + Usually given "<feature>" is configurable via the `gitweb.<feature>` -config variable in the per-repository git configuration file. +config variable in the per-repository Git configuration file. + *Note* that no feature is overriddable by default. @@ -782,7 +782,7 @@ filesystem (i.e. "$projectroot/$project"), `%h` to the current hash (\'hb' gitweb parameter); `%%` expands to \'%'. + For example, at the time this page was written, the http://repo.or.cz[] -git hosting site set it to the following to enable graphical log +Git hosting site set it to the following to enable graphical log (using the third party tool *git-browser*): + ---------------------------------------------------------------------- @@ -796,10 +796,10 @@ This adds a link titled "graphiclog" after the "summary" link, leading to Project specific override is not supported. timed:: - Enable displaying how much time and how many git commands it took to + Enable displaying how much time and how many Git commands it took to generate and display each page in the page footer (at the bottom of page). For example the footer might contain: "This page took 6.53325 - seconds and 13 git commands to generate." Disabled by default. + seconds and 13 Git commands to generate." Disabled by default. + Project specific override is not supported. diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt index 168e8bfed6..40969f1098 100644 --- a/Documentation/gitweb.txt +++ b/Documentation/gitweb.txt @@ -7,14 +7,14 @@ gitweb - Git web interface (web frontend to Git repositories) SYNOPSIS -------- -To get started with gitweb, run linkgit:git-instaweb[1] from a git repository. +To get started with gitweb, run linkgit:git-instaweb[1] from a Git repository. This would configure and start your web server, and run web browser pointing to gitweb. DESCRIPTION ----------- -Gitweb provides a web interface to git repositories. Its features include: +Gitweb provides a web interface to Git repositories. Its features include: * Viewing multiple Git repositories with common root. * Browsing every revision of the repository. @@ -54,9 +54,9 @@ our $projectroot = '/path/to/parent/directory'; The default value for `$projectroot` is '/pub/git'. You can change it during building gitweb via `GITWEB_PROJECTROOT` build configuration variable. -By default all git repositories under `$projectroot` are visible and available +By default all Git repositories under `$projectroot` are visible and available to gitweb. The list of projects is generated by default by scanning the -`$projectroot` directory for git repositories (for object databases to be +`$projectroot` directory for Git repositories (for object databases to be more exact; gitweb is not interested in a working area, and is best suited to showing "bare" repositories). @@ -111,7 +111,7 @@ foo/bar.git O+W+Ner+<owner@example.org> By default this file controls only which projects are *visible* on projects -list page (note that entries that do not point to correctly recognized git +list page (note that entries that do not point to correctly recognized Git repositories won't be displayed by gitweb). Even if a project is not visible on projects list page, you can view it nevertheless by hand-crafting a gitweb URL. By setting `$strict_export` configuration variable (see @@ -151,9 +151,9 @@ as projects list file, which means that you can set `$projects_list` to its filename. -Controlling access to git repositories +Controlling access to Git repositories ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default all git repositories under `$projectroot` are visible and +By default all Git repositories under `$projectroot` are visible and available to gitweb. You can however configure how gitweb controls access to repositories. @@ -206,7 +206,7 @@ $export_auth_hook = sub { Per-repository gitweb configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can configure individual repositories shown in gitweb by creating file -in the 'GIT_DIR' of git repository, or by setting some repo configuration +in the 'GIT_DIR' of Git repository, or by setting some repo configuration variable (in 'GIT_DIR/config', see linkgit:git-config[1]). You can use the following files in repository: @@ -504,7 +504,7 @@ repositories, you can configure Apache like this: The above configuration expects your public repositories to live under '/pub/git' and will serve them as `http://git.domain.org/dir-under-pub-git`, -both as cloneable GIT URL and as browseable gitweb interface. If you then +both as cloneable Git URL and as browseable gitweb interface. If you then start your linkgit:git-daemon[1] with `--base-path=/pub/git --export-all` then you can even use the `git://` URL with exactly the same path. @@ -584,7 +584,7 @@ $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git"; referenced by `$per_request_config`; These configurations enable two things. First, each unix user (`<user>`) of -the server will be able to browse through gitweb git repositories found in +the server will be able to browse through gitweb Git repositories found in '~/public_git/' with the following url: http://git.example.org/~<user>/ @@ -673,7 +673,7 @@ The additional AliasMatch makes it so that http://git.example.com/project.git -will give raw access to the project's git dir (so that the project can be +will give raw access to the project's Git dir (so that the project can be cloned), while http://git.example.com/project diff --git a/Documentation/gitworkflows.txt b/Documentation/gitworkflows.txt index 8b8c6ae5d3..f16c414ea7 100644 --- a/Documentation/gitworkflows.txt +++ b/Documentation/gitworkflows.txt @@ -3,7 +3,7 @@ gitworkflows(7) NAME ---- -gitworkflows - An overview of recommended workflows with git +gitworkflows - An overview of recommended workflows with Git SYNOPSIS -------- @@ -242,10 +242,10 @@ tag to the tip of 'master' indicating the release version: .Release tagging [caption="Recipe: "] ===================================== -`git tag -s -m "GIT X.Y.Z" vX.Y.Z master` +`git tag -s -m "Git X.Y.Z" vX.Y.Z master` ===================================== -You need to push the new tag to a public git server (see +You need to push the new tag to a public Git server (see "DISTRIBUTED WORKFLOWS" below). This makes the tag available to others tracking your project. The push could also trigger a post-update hook to perform release-related items such as building diff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt index f928b57f90..eb7ba84f1f 100644 --- a/Documentation/glossary-content.txt +++ b/Documentation/glossary-content.txt @@ -7,7 +7,7 @@ A bare repository is normally an appropriately named <<def_directory,directory>> with a `.git` suffix that does not have a locally checked-out copy of any of the files under - revision control. That is, all of the `git` + revision control. That is, all of the Git administrative and control files that would normally be present in the hidden `.git` sub-directory are directly present in the `repository.git` directory instead, @@ -22,7 +22,7 @@ <<def_commit,commit>> on a branch is referred to as the tip of that branch. The tip of the branch is referenced by a branch <<def_head,head>>, which moves forward as additional development - is done on the branch. A single git + is done on the branch. A single Git <<def_repository,repository>> can track an arbitrary number of branches, but your <<def_working_tree,working tree>> is associated with just one of them (the "current" or "checked out" @@ -37,9 +37,9 @@ <<def_commit,commit>> could be one of its <<def_parent,parents>>). [[def_changeset]]changeset:: - BitKeeper/cvsps speak for "<<def_commit,commit>>". Since git does not + BitKeeper/cvsps speak for "<<def_commit,commit>>". Since Git does not store changes, but states, it really does not make sense to use the term - "changesets" with git. + "changesets" with Git. [[def_checkout]]checkout:: The action of updating all or part of the @@ -52,7 +52,7 @@ [[def_cherry-picking]]cherry-picking:: In <<def_SCM,SCM>> jargon, "cherry pick" means to choose a subset of changes out of a series of changes (typically commits) and record them - as a new series of changes on top of a different codebase. In GIT, this is + as a new series of changes on top of a different codebase. In Git, this is performed by the "git cherry-pick" command to extract the change introduced by an existing <<def_commit,commit>> and to record it based on the tip of the current <<def_branch,branch>> as a new commit. @@ -64,14 +64,14 @@ [[def_commit]]commit:: As a noun: A single point in the - git history; the entire history of a project is represented as a + Git history; the entire history of a project is represented as a set of interrelated commits. The word "commit" is often - used by git in the same places other revision control systems + used by Git in the same places other revision control systems use the words "revision" or "version". Also used as a short hand for <<def_commit_object,commit object>>. + As a verb: The action of storing a new snapshot of the project's -state in the git history, by creating a new commit representing the current +state in the Git history, by creating a new commit representing the current state of the <<def_index,index>> and advancing <<def_HEAD,HEAD>> to point at the new commit. @@ -82,8 +82,8 @@ to point at the new commit. to the top <<def_directory,directory>> of the stored revision. -[[def_core_git]]core git:: - Fundamental data structures and utilities of git. Exposes only limited +[[def_core_git]]core Git:: + Fundamental data structures and utilities of Git. Exposes only limited source code management tools. [[def_DAG]]DAG:: @@ -100,7 +100,7 @@ to point at the new commit. [[def_detached_HEAD]]detached HEAD:: Normally the <<def_HEAD,HEAD>> stores the name of a - <<def_branch,branch>>. However, git also allows you to <<def_checkout,check out>> + <<def_branch,branch>>. However, Git also allows you to <<def_checkout,check out>> an arbitrary <<def_commit,commit>> that isn't necessarily the tip of any particular branch. In this case HEAD is said to be "detached". @@ -142,22 +142,26 @@ to point at the new commit. and to get them, too. See also linkgit:git-fetch[1]. [[def_file_system]]file system:: - Linus Torvalds originally designed git to be a user space file system, + Linus Torvalds originally designed Git to be a user space file system, i.e. the infrastructure to hold files and directories. That ensured the - efficiency and speed of git. + efficiency and speed of Git. -[[def_git_archive]]git archive:: +[[def_git_archive]]Git archive:: Synonym for <<def_repository,repository>> (for arch people). +[[def_gitfile]]gitfile:: + A plain file `.git` at the root of a working tree that + points at the directory that is the real repository. + [[def_grafts]]grafts:: Grafts enables two otherwise different lines of development to be joined together by recording fake ancestry information for commits. This way - you can make git pretend the set of <<def_parent,parents>> a <<def_commit,commit>> has + you can make Git pretend the set of <<def_parent,parents>> a <<def_commit,commit>> has is different from what was recorded when the commit was created. Configured via the `.git/info/grafts` file. [[def_hash]]hash:: - In git's context, synonym to <<def_object_name,object name>>. + In Git's context, synonym to <<def_object_name,object name>>. [[def_head]]head:: A <<def_ref,named reference>> to the <<def_commit,commit>> at the tip of a @@ -177,14 +181,14 @@ to point at the new commit. A synonym for <<def_head,head>>. [[def_hook]]hook:: - During the normal execution of several git commands, call-outs are made + During the normal execution of several Git commands, call-outs are made to optional scripts that allow a developer to add functionality or checking. Typically, the hooks allow for a command to be pre-verified and potentially aborted, and allow for a post-notification after the operation is done. The hook scripts are found in the `$GIT_DIR/hooks/` directory, and are enabled by simply removing the `.sample` suffix from the filename. In earlier versions - of git you had to make them executable. + of Git you had to make them executable. [[def_index]]index:: A collection of files with stat information, whose contents are stored @@ -201,7 +205,7 @@ to point at the new commit. [[def_master]]master:: The default development <<def_branch,branch>>. Whenever you - create a git <<def_repository,repository>>, a branch named + create a Git <<def_repository,repository>>, a branch named "master" is created, and becomes the active branch. In most cases, this contains the local development, though that is purely by convention and is not required. @@ -228,7 +232,7 @@ This commit is referred to as a "merge commit", or sometimes just a "merge". [[def_object]]object:: - The unit of storage in git. It is uniquely identified by the + The unit of storage in Git. It is uniquely identified by the <<def_SHA1,SHA1>> of its contents. Consequently, an object can not be changed. @@ -323,7 +327,7 @@ top `/`;; + Currently only the slash `/` is recognized as the "magic signature", but it is envisioned that we will support more types of magic in later -versions of git. +versions of Git. + A pathspec with only a colon means "there is no pathspec". This form should not be combined with other pathspec. @@ -341,12 +345,12 @@ should not be combined with other pathspec. particular line of text. See linkgit:git-diff[1]. [[def_plumbing]]plumbing:: - Cute name for <<def_core_git,core git>>. + Cute name for <<def_core_git,core Git>>. [[def_porcelain]]porcelain:: Cute name for programs and program suites depending on - <<def_core_git,core git>>, presenting a high level access to - core git. Porcelains expose more of a <<def_SCM,SCM>> + <<def_core_git,core Git>>, presenting a high level access to + core Git. Porcelains expose more of a <<def_SCM,SCM>> interface than the <<def_plumbing,plumbing>>. [[def_pull]]pull:: @@ -406,7 +410,7 @@ should not be combined with other pathspec. linkgit:git-push[1]. [[def_remote_tracking_branch]]remote-tracking branch:: - A regular git <<def_branch,branch>> that is used to follow changes from + A regular Git <<def_branch,branch>> that is used to follow changes from another <<def_repository,repository>>. A remote-tracking branch should not contain direct modifications or have local commits made to it. A remote-tracking branch can usually be @@ -443,7 +447,7 @@ should not be combined with other pathspec. [[def_shallow_repository]]shallow repository:: A shallow <<def_repository,repository>> has an incomplete history some of whose <<def_commit,commits>> have <<def_parent,parents>> cauterized away (in other - words, git is told to pretend that these commits do not have the + words, Git is told to pretend that these commits do not have the parents, even though they are recorded in the <<def_commit_object,commit object>>). This is sometimes useful when you are interested only in the recent history of a project even though the real history recorded in the @@ -464,9 +468,9 @@ should not be combined with other pathspec. object of an arbitrary type (typically a tag points to either a <<def_tag_object,tag>> or a <<def_commit_object,commit object>>). In contrast to a <<def_head,head>>, a tag is not updated by - the `commit` command. A git tag has nothing to do with a Lisp + the `commit` command. A Git tag has nothing to do with a Lisp tag (which would be called an <<def_object_type,object type>> - in git's context). A tag is most typically used to mark a particular + in Git's context). A tag is most typically used to mark a particular point in the commit ancestry <<def_chain,chain>>. [[def_tag_object]]tag object:: @@ -476,7 +480,7 @@ should not be combined with other pathspec. signature, in which case it is called a "signed tag object". [[def_topic_branch]]topic branch:: - A regular git <<def_branch,branch>> that is used by a developer to + A regular Git <<def_branch,branch>> that is used by a developer to identify a conceptual line of development. Since branches are very easy and inexpensive, it is often desirable to have several small branches that each contain very well defined concepts or small incremental yet diff --git a/Documentation/howto-index.sh b/Documentation/howto-index.sh index 34aa30c5b9..a2340864b5 100755 --- a/Documentation/howto-index.sh +++ b/Documentation/howto-index.sh @@ -1,11 +1,11 @@ #!/bin/sh cat <<\EOF -GIT Howto Index +Git Howto Index =============== Here is a collection of mailing list postings made by various -people describing how they use git in their workflow. +people describing how they use Git in their workflow. EOF diff --git a/Documentation/howto/maintain-git.txt b/Documentation/howto/maintain-git.txt index ea6e4a52c9..33ae69c11f 100644 --- a/Documentation/howto/maintain-git.txt +++ b/Documentation/howto/maintain-git.txt @@ -1,7 +1,7 @@ From: Junio C Hamano <gitster@pobox.com> Date: Wed, 21 Nov 2007 16:32:55 -0800 Subject: Addendum to "MaintNotes" -Abstract: Imagine that git development is racing along as usual, when our friendly +Abstract: Imagine that Git development is racing along as usual, when our friendly neighborhood maintainer is struck down by a wayward bus. Out of the hordes of suckers (loyal developers), you have been tricked (chosen) to step up as the new maintainer. This howto will show you "how to" do it. @@ -10,35 +10,42 @@ Content-type: text/asciidoc How to maintain Git =================== -The maintainer's git time is spent on three activities. +Activities +---------- - - Communication (60%) +The maintainer's Git time is spent on three activities. + + - Communication (45%) Mailing list discussions on general design, fielding user questions, diagnosing bug reports; reviewing, commenting on, suggesting alternatives to, and rejecting patches. - - Integration (30%) + - Integration (50%) Applying new patches from the contributors while spotting and correcting minor mistakes, shuffling the integration and testing branches, pushing the results out, cutting the releases, and making announcements. - - Own development (10%) + - Own development (5%) Scratching my own itch and sending proposed patch series out. +The Policy +---------- + The policy on Integration is informally mentioned in "A Note from the maintainer" message, which is periodically posted to this mailing list after each feature release is made. -The policy. - - Feature releases are numbered as vX.Y.Z and are meant to contain bugfixes and enhancements in any area, including functionality, performance and usability, without regression. + - One release cycle for a feature release is expected to last for + eight to ten weeks. + - Maintenance releases are numbered as vX.Y.Z.W and are meant to contain only bugfixes for the corresponding vX.Y.Z feature release and earlier maintenance releases vX.Y.Z.V (V < W). @@ -62,12 +69,15 @@ The policy. - 'pu' branch is used to publish other proposed changes that do not yet pass the criteria set for 'next'. - - The tips of 'master', 'maint' and 'next' branches will always - fast-forward, to allow people to build their own - customization on top of them. + - The tips of 'master' and 'maint' branches will not be rewound to + allow people to build their own customization on top of them. + Early in a new development cycle, 'next' is rewound to the tip of + 'master' once, but otherwise it will not be rewound until the end + of the cycle. - - Usually 'master' contains all of 'maint', 'next' contains all - of 'master' and 'pu' contains all of 'next'. + - Usually 'master' contains all of 'maint' and 'next' contains all + of 'master'. 'pu' contains all the topics merged to 'next', but + is rebuilt directly on 'master'. - The tip of 'master' is meant to be more stable than any tagged releases, and the users are encouraged to follow it. @@ -77,14 +87,22 @@ The policy. are found before new topics are merged to 'master'. -A typical git day for the maintainer implements the above policy +A Typical Git Day +----------------- + +A typical Git day for the maintainer implements the above policy by doing the following: - - Scan mailing list and #git channel log. Respond with review - comments, suggestions etc. Kibitz. Collect potentially - usable patches from the mailing list. Patches about a single - topic go to one mailbox (I read my mail in Gnus, and type - \C-o to save/append messages in files in mbox format). + - Scan mailing list. Respond with review comments, suggestions + etc. Kibitz. Collect potentially usable patches from the + mailing list. Patches about a single topic go to one mailbox (I + read my mail in Gnus, and type \C-o to save/append messages in + files in mbox format). + + - Write his own patches to address issues raised on the list but + nobody has stepped up solving. Send it out just like other + contributors do, and pick them up just like patches from other + contributors (see above). - Review the patches in the saved mailboxes. Edit proposed log message for typofixes and clarifications, and add Acks @@ -100,40 +118,32 @@ by doing the following: - Obviously correct fixes that pertain to the tip of 'master' are directly applied to 'master'. + - Other topics are not handled in this step. + This step is done with "git am". $ git checkout master ;# or "git checkout maint" - $ git am -3 -s mailbox + $ git am -sc3 mailbox $ make test - - Merge downwards (maint->master): - - $ git checkout master - $ git merge maint - $ make test + In practice, almost no patch directly goes to 'master' or + 'maint'. - Review the last issue of "What's cooking" message, review the - topics scheduled for merging upwards (topic->master and - topic->maint), and merge. + topics ready for merging (topic->master and topic->maint). Use + "Meta/cook -w" script (where Meta/ contains a checkout of the + 'todo' branch) to aid this step. + + And perform the merge. Use "Meta/Reintegrate -e" script (see + later) to aid this step. + + $ Meta/cook -w last-issue-of-whats-cooking.mbox $ git checkout master ;# or "git checkout maint" - $ git merge ai/topic ;# or "git merge ai/maint-topic" + $ echo ai/topic | Meta/Reintegrate -e ;# "git merge ai/topic" $ git log -p ORIG_HEAD.. ;# final review $ git diff ORIG_HEAD.. ;# final review $ make test ;# final review - $ git branch -d ai/topic ;# or "git branch -d ai/maint-topic" - - - Merge downwards (maint->master) if needed: - - $ git checkout master - $ git merge maint - $ make test - - - Merge downwards (master->next) if needed: - - $ git checkout next - $ git merge master - $ make test - Handle the remaining patches: @@ -142,9 +152,9 @@ by doing the following: and not in 'master') is applied to a new topic branch that is forked from the tip of 'master'. This includes both enhancements and unobvious fixes to 'master'. A topic - branch is named as ai/topic where "ai" is typically - author's initial and "topic" is a descriptive name of the - topic (in other words, "what's the series is about"). + branch is named as ai/topic where "ai" is two-letter string + named after author's initial and "topic" is a descriptive name + of the topic (in other words, "what's the series is about"). - An unobvious fix meant for 'maint' is applied to a new topic branch that is forked from the tip of 'maint'. The @@ -162,7 +172,8 @@ by doing the following: The above except the "replacement" are all done with: - $ git am -3 -s mailbox + $ git checkout ai/topic ;# or "git checkout -b ai/topic master" + $ git am -sc3 mailbox while patch replacement is often done by: @@ -170,93 +181,170 @@ by doing the following: then replace some parts with the new patch, and reapplying: + $ git checkout ai/topic $ git reset --hard ai/topic~$n - $ git am -3 -s 000*.txt + $ git am -sc3 -s 000*.txt The full test suite is always run for 'maint' and 'master' after patch application; for topic branches the tests are run as time permits. - - Update "What's cooking" message to review the updates to - existing topics, newly added topics and graduated topics. + - Merge maint to master as needed: - This step is helped with Meta/cook script (where Meta/ contains - a checkout of the 'todo' branch). - - - Merge topics to 'next'. For each branch whose tip is not - merged to 'next', one of three things can happen: + $ git checkout master + $ git merge maint + $ make test - - The commits are all next-worthy; merge the topic to next: + - Merge master to next as needed: $ git checkout next - $ git merge ai/topic ;# or "git merge ai/maint-topic" + $ git merge master $ make test + - Review the last issue of "What's cooking" again and see if topics + that are ready to be merged to 'next' are still in good shape + (e.g. has there any new issue identified on the list with the + series?) + + - Prepare 'jch' branch, which is used to represent somewhere + between 'master' and 'pu' and often is slightly ahead of 'next'. + + $ Meta/Reintegrate master..pu >Meta/redo-jch.sh + + The result is a script that lists topics to be merged in order to + rebuild 'pu' as the input to Meta/Reintegrate script. Remove + later topics that should not be in 'jch' yet. Add a line that + consists of '### match next' before the name of the first topic + in the output that should be in 'jch' but not in 'next' yet. + + - Now we are ready to start merging topics to 'next'. For each + branch whose tip is not merged to 'next', one of three things can + happen: + + - The commits are all next-worthy; merge the topic to next; - The new parts are of mixed quality, but earlier ones are - next-worthy; merge the early parts to next: + next-worthy; merge the early parts to next; + - Nothing is next-worthy; do not do anything. + + This step is aided with Meta/redo-jch.sh script created earlier. + If a topic that was already in 'next' gained a patch, the script + would list it as "ai/topic~1". To include the new patch to the + updated 'next', drop the "~1" part; to keep it excluded, do not + touch the line. If a topic that was not in 'next' should be + merged to 'next', add it at the end of the list. Then: + + $ git checkout -B jch master + $ Meta/redo-jch.sh -c1 + + to rebuild the 'jch' branch from scratch. "-c1" tells the script + to stop merging at the first line that begins with '###' + (i.e. the "### match next" line you added earlier). + + At this point, build-test the result. It may reveal semantic + conflicts (e.g. a topic renamed a variable, another added a new + reference to the variable under its old name), in which case + prepare an appropriate merge-fix first (see appendix), and + rebuild the 'jch' branch from scratch, starting at the tip of + 'master'. + + Then do the same to 'next' $ git checkout next - $ git merge ai/topic~2 ;# the tip two are dubious - $ make test + $ sh Meta/redo-jch.sh -c1 -e - - Nothing is next-worthy; do not do anything. + The "-e" option allows the merge message that comes from the + history of the topic and the comments in the "What's cooking" to + be edited. The resulting tree should match 'jch' as the same set + of topics are merged on 'master'; otherwise there is a mismerge. + Investigate why and do not proceed until the mismerge is found + and rectified. - - [** OBSOLETE **] Optionally rebase topics that do not have any commit - in next yet, when they can take advantage of low-level framework - change that is merged to 'master' already. + $ git diff jch next - $ git rebase master ai/topic + When all is well, clean up the redo-jch.sh script with - This step is helped with Meta/git-topic.perl script to - identify which topic is rebaseable. There also is a - pre-rebase hook to make sure that topics that are already in - 'next' are not rebased beyond the merged commit. + $ sh Meta/redo-jch.sh -u - - [** OBSOLETE **] Rebuild "pu" to merge the tips of topics not in 'next'. + This removes topics listed in the script that have already been + merged to 'master'. This may lose '### match next' marker; + add it again to the appropriate place when it happens. - $ git checkout pu - $ git reset --hard next - $ git merge ai/topic ;# repeat for all remaining topics - $ make test + - Rebuild 'pu'. - This step is helped with Meta/PU script + $ Meta/Reintegrate master..pu >Meta/redo-pu.sh - - Push four integration branches to a private repository at - k.org and run "make test" on all of them. + Edit the result by adding new topics that are not still in 'pu' + in the script. Then - - Push four integration branches to /pub/scm/git/git.git at - k.org. This triggers its post-update hook which: + $ git checkout -B pu jch + $ sh Meta/redo-pu.sh - (1) runs "git pull" in $HOME/git-doc/ repository to pull - 'master' just pushed out; + When all is well, clean up the redo-pu.sh script with - (2) runs "make doc" in $HOME/git-doc/, install the generated - documentation in staging areas, which are separate - repositories that have html and man branches checked - out. + $ sh Meta/redo-pu.sh -u - (3) runs "git commit" in the staging areas, and run "git - push" back to /pub/scm/git/git.git/ to update the html - and man branches. + Double check by running - (4) installs generated documentation to /pub/software/scm/git/docs/ - to be viewed from http://www.kernel.org/ + $ git branch --no-merged pu - - Fetch html and man branches back from k.org, and push four - integration branches and the two documentation branches to - repo.or.cz and other mirrors. + to see there is no unexpected leftover topics. + At this point, build-test the result for semantic conflicts, and + if there are, prepare an appropriate merge-fix first (see + appendix), and rebuild the 'pu' branch from scratch, starting at + the tip of 'jch'. + + - Update "What's cooking" message to review the updates to + existing topics, newly added topics and graduated topics. + + This step is helped with Meta/cook script. + + $ Meta/cook + + This script inspects the history between master..pu, finds tips + of topic branches, compares what it found with the current + contents in Meta/whats-cooking.txt, and updates that file. + Topics not listed in the file but are found in master..pu are + added to the "New topics" section, topics listed in the file that + are no longer found in master..pu are moved to the "Graduated to + master" section, and topics whose commits changed their states + (e.g. used to be only in 'pu', now merged to 'next') are updated + with change markers "<<" and ">>". + + Look for lines enclosed in "<<" and ">>"; they hold contents from + old file that are replaced by this integration round. After + verifying them, remove the old part. Review the description for + each topic and update its doneness and plan as needed. To review + the updated plan, run + + $ Meta/cook -w + + which will pick up comments given to the topics, such as "Will + merge to 'next'", etc. (see Meta/cook script to learn what kind + of phrases are supported). + + - Compile, test and install all four (five) integration branches; + Meta/Dothem script may aid this step. + + - Format documentation if the 'master' branch was updated; + Meta/dodoc.sh script may aid this step. + + - Push the integration branches out to public places; Meta/pushall + script may aid this step. + +Observations +------------ Some observations to be made. - * Each topic is tested individually, and also together with - other topics cooking in 'next'. Until it matures, none part - of it is merged to 'master'. + * Each topic is tested individually, and also together with other + topics cooking first in 'pu', then in 'jch' and then in 'next'. + Until it matures, no part of it is merged to 'master'. * A topic already in 'next' can get fixes while still in 'next'. Such a topic will have many merges to 'next' (in other words, "git log --first-parent next" will show many - "Merge ai/topic to next" for the same topic. + "Merge branch 'ai/topic' to next" for the same topic. * An unobvious fix for 'maint' is cooked in 'next' and then merged to 'master' to make extra sure it is Ok and then @@ -278,3 +366,80 @@ Some observations to be made. * Being in the 'next' branch is not a guarantee for a topic to be included in the next feature release. Being in the 'master' branch typically is. + + +Appendix +-------- + +Preparing a "merge-fix" +~~~~~~~~~~~~~~~~~~~~~~~ + +A merge of two topics may not textually conflict but still have +conflict at the semantic level. A classic example is for one topic +to rename an variable and all its uses, while another topic adds a +new use of the variable under its old name. When these two topics +are merged together, the reference to the variable newly added by +the latter topic will still use the old name in the result. + +The Meta/Reintegrate script that is used by redo-jch and redo-pu +scripts implements a crude but usable way to work this issue around. +When the script merges branch $X, it checks if "refs/merge-fix/$X" +exists, and if so, the effect of it is squashed into the result of +the mechanical merge. In other words, + + $ echo $X | Meta/Reintegrate + +is roughly equivalent to this sequence: + + $ git merge --rerere-autoupdate $X + $ git commit + $ git cherry-pick -n refs/merge-fix/$X + $ git commit --amend + +The goal of this "prepare a merge-fix" step is to come up with a +commit that can be squashed into a result of mechanical merge to +correct semantic conflicts. + +After finding that the result of merging branch "ai/topic" to an +integration branch had such a semantic conflict, say pu~4, check the +problematic merge out on a detached HEAD, edit the working tree to +fix the semantic conflict, and make a separate commit to record the +fix-up: + + $ git checkout pu~4 + $ git show -s --pretty=%s ;# double check + Merge branch 'ai/topic' to pu + $ edit + $ git commit -m 'merge-fix/ai/topic' -a + +Then make a reference "refs/merge-fix/ai/topic" to point at this +result: + + $ git update-ref refs/merge-fix/ai/topic HEAD + +Then double check the result by asking Meta/Reintegrate to redo the +merge: + + $ git checkout pu~5 ;# the parent of the problem merge + $ echo ai/topic | Meta/Reintegrate + $ git diff pu~4 + +This time, because you prepared refs/merge-fix/ai/topic, the +resulting merge should have been tweaked to include the fix for the +semantic conflict. + +Note that this assumes that the order in which conflicting branches +are merged does not change. If the reason why merging ai/topic +branch needs this merge-fix is because another branch merged earlier +to the integration branch changed the underlying assumption ai/topic +branch made (e.g. ai/topic branch added a site to refer to a +variable, while the other branch renamed that variable and adjusted +existing use sites), and if you changed redo-jch (or redo-pu) script +to merge ai/topic branch before the other branch, then the above +merge-fix should not be applied while merging ai/topic, but should +instead be applied while merging the other branch. You would need +to move the fix to apply to the other branch, perhaps like this: + + $ mf=refs/merge-fix + $ git update-ref $mf/$the_other_branch $mf/ai/topic + $ git update-ref -d $mf/ai/topic diff --git a/Documentation/howto/new-command.txt b/Documentation/howto/new-command.txt index 36502f6718..2abc3a0a0e 100644 --- a/Documentation/howto/new-command.txt +++ b/Documentation/howto/new-command.txt @@ -1,25 +1,25 @@ From: Eric S. Raymond <esr@thyrsus.com> Abstract: This is how-to documentation for people who want to add extension - commands to git. It should be read alongside api-builtin.txt. + commands to Git. It should be read alongside api-builtin.txt. Content-type: text/asciidoc How to integrate new subcommands ================================ This is how-to documentation for people who want to add extension -commands to git. It should be read alongside api-builtin.txt. +commands to Git. It should be read alongside api-builtin.txt. Runtime environment ------------------- -git subcommands are standalone executables that live in the git exec +Git subcommands are standalone executables that live in the Git exec path, normally /usr/lib/git-core. The git executable itself is a thin wrapper that knows where the subcommands live, and runs them by passing command-line arguments to them. -(If "git foo" is not found in the git exec path, the wrapper +(If "git foo" is not found in the Git exec path, the wrapper will look in the rest of your $PATH for it. Thus, it's possible -to write local git extensions that don't live in system space.) +to write local Git extensions that don't live in system space.) Implementation languages ------------------------ @@ -30,13 +30,13 @@ Perl. While we strongly encourage coding in portable C for portability, these specific scripting languages are also acceptable. We won't accept more without a very strong technical case, as we don't want -to broaden the git suite's required dependencies. Import utilities, +to broaden the Git suite's required dependencies. Import utilities, surgical tools, remote helpers and other code at the edges of the -git suite are more lenient and we allow Python (and even Tcl/tk), +Git suite are more lenient and we allow Python (and even Tcl/tk), but they should not be used for core functions. This may change in the future. Especially Python is not allowed in -core because we need better Python integration in the git Windows +core because we need better Python integration in the Git Windows installer before we can be confident people in that environment won't experience an unacceptably large loss of capability. @@ -54,7 +54,7 @@ functions available to built-in commands written in C. What every extension command needs ---------------------------------- -You must have a man page, written in asciidoc (this is what git help +You must have a man page, written in asciidoc (this is what Git help followed by your subcommand name will display). Be aware that there is a local asciidoc configuration and macros which you should use. It's often helpful to start by cloning an existing page and replacing the @@ -74,7 +74,7 @@ Integrating a command --------------------- Here are the things you need to do when you want to merge a new -subcommand into the git tree. +subcommand into the Git tree. 1. Don't forget to sign off your patch! diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt index 4627ee47f2..19ab604f1f 100644 --- a/Documentation/howto/rebase-from-internal-branch.txt +++ b/Documentation/howto/rebase-from-internal-branch.txt @@ -4,7 +4,7 @@ Cc: Petr Baudis <pasky@suse.cz>, Linus Torvalds <torvalds@osdl.org> Subject: Re: sending changesets from the middle of a git tree Date: Sun, 14 Aug 2005 18:37:39 -0700 Abstract: In this article, JC talks about how he rebases the - public "pu" branch using the core GIT tools when he updates + public "pu" branch using the core Git tools when he updates the "master" branch, and how "rebase" works. Also discussed is how this applies to individual developers who sends patches upstream. @@ -31,7 +31,7 @@ up. With its basing philosophical ancestry on quilt, this is the kind of task StGIT is designed to do. I just have done a simpler one, this time using only the core -GIT tools. +Git tools. I had a handful of commits that were ahead of master in pu, and I wanted to add some documentation bypassing my usual habit of @@ -96,7 +96,7 @@ you ran fsck-cache, which is normal. After testing "pu", you can run "git prune" to get rid of those original three commits. While I am talking about "git rebase", I should talk about how -to do cherrypicking using only the core GIT tools. +to do cherrypicking using only the core Git tools. Let's go back to the earlier picture, with different labels. diff --git a/Documentation/howto/rebuild-from-update-hook.txt b/Documentation/howto/rebuild-from-update-hook.txt index 00c1b45b79..25378f68d3 100644 --- a/Documentation/howto/rebuild-from-update-hook.txt +++ b/Documentation/howto/rebuild-from-update-hook.txt @@ -3,7 +3,7 @@ Message-ID: <7vy86o6usx.fsf@assigned-by-dhcp.cox.net> From: Junio C Hamano <gitster@pobox.com> Date: Fri, 26 Aug 2005 18:19:10 -0700 Abstract: In this how-to article, JC talks about how he - uses the post-update hook to automate git documentation page + uses the post-update hook to automate Git documentation page shown at http://www.kernel.org/pub/software/scm/git/docs/. Content-type: text/asciidoc @@ -15,11 +15,11 @@ are built from Documentation/ directory of the git.git project and needed to be kept up-to-date. The www.kernel.org/ servers are mirrored and I was told that the origin of the mirror is on the machine $some.kernel.org, on which I was given an account -when I took over git maintainership from Linus. +when I took over Git maintainership from Linus. The directories relevant to this how-to are these two: - /pub/scm/git/git.git/ The public git repository. + /pub/scm/git/git.git/ The public Git repository. /pub/software/scm/git/docs/ The HTML documentation page. So I made a repository to generate the documentation under my @@ -46,7 +46,7 @@ script: EOF Initially I used to run this by hand whenever I push into the -public git repository. Then I did a cron job that ran twice a +public Git repository. Then I did a cron job that ran twice a day. The current round uses the post-update hook mechanism, like this: diff --git a/Documentation/howto/recover-corrupted-blob-object.txt b/Documentation/howto/recover-corrupted-blob-object.txt index 7484735320..6d362ceb10 100644 --- a/Documentation/howto/recover-corrupted-blob-object.txt +++ b/Documentation/howto/recover-corrupted-blob-object.txt @@ -20,7 +20,7 @@ itself doesn't actually tell you anything, in order to fix a corrupt object you basically have to find the "original source" for it. The easiest way to do that is almost always to have backups, and find the -same object somewhere else. Backups really are a good idea, and git makes +same object somewhere else. Backups really are a good idea, and Git makes it pretty easy (if nothing else, just clone the repository somewhere else, and make sure that you do *not* use a hard-linked clone, and preferably not the same disk/machine). @@ -134,7 +134,7 @@ and your repository is good again! git log --raw --all and just looked for the sha of the missing object (4b9458b..) in that -whole thing. It's up to you - git does *have* a lot of information, it is +whole thing. It's up to you - Git does *have* a lot of information, it is just missing one particular blob version. Trying to recreate trees and especially commits is *much* harder. So you diff --git a/Documentation/howto/revert-a-faulty-merge.txt b/Documentation/howto/revert-a-faulty-merge.txt index 8a685483f4..075418eeeb 100644 --- a/Documentation/howto/revert-a-faulty-merge.txt +++ b/Documentation/howto/revert-a-faulty-merge.txt @@ -164,7 +164,7 @@ merged. So it's debugging hell, because now you don't have lots of small changes that you can try to pinpoint which _part_ of it changes. But does it all work? Sure it does. You can revert a merge, and from a -purely technical angle, git did it very naturally and had no real +purely technical angle, Git did it very naturally and had no real troubles. It just considered it a change from "state before merge" to "state after merge", and that was it. Nothing complicated, nothing odd, nothing really dangerous. Git will do it without even thinking about it. diff --git a/Documentation/howto/revert-branch-rebase.txt b/Documentation/howto/revert-branch-rebase.txt index a59ced8d04..84dd839db4 100644 --- a/Documentation/howto/revert-branch-rebase.txt +++ b/Documentation/howto/revert-branch-rebase.txt @@ -12,10 +12,10 @@ How to revert an existing commit ================================ One of the changes I pulled into the 'master' branch turns out to -break building GIT with GCC 2.95. While they were well intentioned +break building Git with GCC 2.95. While they were well intentioned portability fixes, keeping things working with gcc-2.95 was also important. Here is what I did to revert the change in the 'master' -branch and to adjust the 'pu' branch, using core GIT tools and +branch and to adjust the 'pu' branch, using core Git tools and barebone Porcelain. First, prepare a throw-away branch in case I screw things up. diff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt index a695f01f0e..7f4943e102 100644 --- a/Documentation/howto/setup-git-server-over-http.txt +++ b/Documentation/howto/setup-git-server-over-http.txt @@ -1,9 +1,9 @@ From: Rutger Nijlunsing <rutger@nospam.com> -Subject: Setting up a git repository which can be pushed into and pulled from over HTTP(S). +Subject: Setting up a Git repository which can be pushed into and pulled from over HTTP(S). Date: Thu, 10 Aug 2006 22:00:26 +0200 Content-type: text/asciidoc -How to setup git server over http +How to setup Git server over http ================================= Since Apache is one of those packages people like to compile @@ -44,20 +44,20 @@ What's needed: - have permissions to chown a directory -- have git installed on the client, and +- have Git installed on the client, and -- either have git installed on the server or have a webdav client on +- either have Git installed on the server or have a webdav client on the client. In effect, this means you're going to be root, or that you're using a preconfigured WebDAV server. -Step 1: setup a bare GIT repository +Step 1: setup a bare Git repository ----------------------------------- -At the time of writing, git-http-push cannot remotely create a GIT -repository. So we have to do that at the server side with git. Another +At the time of writing, git-http-push cannot remotely create a Git +repository. So we have to do that at the server side with Git. Another option is to generate an empty bare repository at the client and copy it to the server with a WebDAV client (which is the only option if Git is not installed on the server). @@ -189,7 +189,7 @@ http://<servername>/my-new-repo.git [x] Open as webfolder -> login . Step 3: setup the client ------------------------ -Make sure that you have HTTP support, i.e. your git was built with +Make sure that you have HTTP support, i.e. your Git was built with libcurl (version more recent than 7.10). The command 'git http-push' with no argument should display a usage message. @@ -268,7 +268,7 @@ Reading /usr/local/apache2/logs/error_log is often helpful. On Debian: Read /var/log/apache2/error.log instead. -If you access HTTPS locations, git may fail verifying the SSL +If you access HTTPS locations, Git may fail verifying the SSL certificate (this is return code 60). Setting http.sslVerify=false can help diagnosing the problem, but removes security checks. diff --git a/Documentation/howto/use-git-daemon.txt b/Documentation/howto/use-git-daemon.txt index 23cdf35435..7af2e52cf3 100644 --- a/Documentation/howto/use-git-daemon.txt +++ b/Documentation/howto/use-git-daemon.txt @@ -4,7 +4,7 @@ How to use git-daemon ===================== Git can be run in inetd mode and in stand alone mode. But all you want is -let a coworker pull from you, and therefore need to set up a git server +let a coworker pull from you, and therefore need to set up a Git server real quick, right? Note that git-daemon is not really chatty at the moment, especially when diff --git a/Documentation/howto/using-signed-tag-in-pull-request.txt b/Documentation/howto/using-signed-tag-in-pull-request.txt index 00f693bde8..bbf040eda8 100644 --- a/Documentation/howto/using-signed-tag-in-pull-request.txt +++ b/Documentation/howto/using-signed-tag-in-pull-request.txt @@ -23,7 +23,7 @@ Earlier, a typical pull request may have started like this: Froboz 3.2 (2011-09-30 14:20:57 -0700) - are available in the git repository at: + are available in the Git repository at: example.com:/git/froboz.git for-xyzzy ------------ @@ -107,7 +107,7 @@ The resulting msg.txt file begins like so: Froboz 3.2 (2011-09-30 14:20:57 -0700) - are available in the git repository at: + are available in the Git repository at: example.com:/git/froboz.git tags/frotz-for-xyzzy diff --git a/Documentation/i18n.txt b/Documentation/i18n.txt index 625d3154ea..e9a1d5d25a 100644 --- a/Documentation/i18n.txt +++ b/Documentation/i18n.txt @@ -1,9 +1,9 @@ -At the core level, git is character encoding agnostic. +At the core level, Git is character encoding agnostic. - The pathnames recorded in the index and in the tree objects are treated as uninterpreted sequences of non-NUL bytes. What readdir(2) returns are what are recorded and compared - with the data git keeps track of, which in turn are expected + with the data Git keeps track of, which in turn are expected to be what lstat(2) and creat(2) accepts. There is no such thing as pathname encoding translation. @@ -15,9 +15,9 @@ At the core level, git is character encoding agnostic. bytes. Although we encourage that the commit log messages are encoded -in UTF-8, both the core and git Porcelain are designed not to +in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. If all participants of a particular -project find it more convenient to use legacy encodings, git +project find it more convenient to use legacy encodings, Git does not forbid it. However, there are a few things to keep in mind. diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt index 9bb4956ccd..d78d6d854e 100644 --- a/Documentation/merge-config.txt +++ b/Documentation/merge-config.txt @@ -17,10 +17,10 @@ merge.defaultToUpstream:: these tracking branches are merged. merge.ff:: - By default, git does not create an extra merge commit when merging + By default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded. When set to `false`, - this variable tells git to create an extra merge commit in such + this variable tells Git to create an extra merge commit in such a case (equivalent to giving the `--no-ff` option from the command line). When set to `only`, only such fast-forward merges are allowed (equivalent to giving the `--ff-only` option from the @@ -38,10 +38,10 @@ merge.renameLimit:: diff.renameLimit. merge.renormalize:: - Tell git that canonical representation of files in the + Tell Git that canonical representation of files in the repository has changed over time (e.g. earlier commits record text files with CRLF line endings, but recent ones use LF line - endings). In such a repository, git can convert the data + endings). In such a repository, Git can convert the data recorded in commits to a canonical form before performing a merge to reduce unnecessary conflicts. For more information, see section "Merging branches with differing checkin/checkout @@ -52,12 +52,12 @@ merge.stat:: at the end of the merge. True by default. merge.tool:: - Controls which merge resolution program is used by - linkgit:git-mergetool[1]. Valid built-in values are: "araxis", - "bc3", "diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld", - "opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff" - and "xxdiff". Any other value is treated is custom merge tool - and there must be a corresponding mergetool.<tool>.cmd option. + Controls which merge tool is used by linkgit:git-mergetool[1]. + The list below shows the valid built-in values. + Any other value is treated as a custom merge tool and requires + that a corresponding mergetool.<tool>.cmd variable is defined. + +include::mergetools-merge.txt[] merge.verbosity:: Controls the amount of output shown by the recursive merge diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 1ec14a068e..3bdbf5e856 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -649,7 +649,7 @@ together. Object Traversal ~~~~~~~~~~~~~~~~ -These options are mostly targeted for packing of git repositories. +These options are mostly targeted for packing of Git repositories. --objects:: @@ -717,7 +717,7 @@ format, often found in E-mail messages. + `--date=short` shows only date but not time, in `YYYY-MM-DD` format. + -`--date=raw` shows the date in the internal raw git format `%s %z` format. +`--date=raw` shows the date in the internal raw Git format `%s %z` format. + `--date=default` shows timestamps in the original timezone (either committer's or author's). diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt index 991fcd8f3f..678d1756a5 100644 --- a/Documentation/revisions.txt +++ b/Documentation/revisions.txt @@ -23,7 +23,7 @@ blobs contained in a commit. A symbolic ref name. E.g. 'master' typically means the commit object referenced by 'refs/heads/master'. If you happen to have both 'heads/master' and 'tags/master', you can - explicitly say 'heads/master' to tell git which one you mean. + explicitly say 'heads/master' to tell Git which one you mean. When ambiguous, a '<refname>' is disambiguated by taking the first match in the following rules: diff --git a/Documentation/technical/api-builtin.txt b/Documentation/technical/api-builtin.txt index b0cafe87be..4a4228b896 100644 --- a/Documentation/technical/api-builtin.txt +++ b/Documentation/technical/api-builtin.txt @@ -5,7 +5,7 @@ Adding a new built-in --------------------- There are 4 things to do to add a built-in command implementation to -git: +Git: . Define the implementation of the built-in command `foo` with signature: @@ -23,7 +23,7 @@ where options is the bitwise-or of: `RUN_SETUP`:: - Make sure there is a git directory to work on, and if there is a + Make sure there is a Git directory to work on, and if there is a work tree, chdir to the top of it if the command was invoked in a subdirectory. If there is no work tree, no chdir() is done. diff --git a/Documentation/technical/api-config.txt b/Documentation/technical/api-config.txt index edf8dfb99b..230b3a0f60 100644 --- a/Documentation/technical/api-config.txt +++ b/Documentation/technical/api-config.txt @@ -1,7 +1,7 @@ config API ========== -The config API gives callers a way to access git configuration files +The config API gives callers a way to access Git configuration files (and files which have the same syntax). See linkgit:git-config[1] for a discussion of the config file syntax. @@ -12,7 +12,7 @@ Config files are parsed linearly, and each variable found is passed to a caller-provided callback function. The callback function is responsible for any actions to be taken on the config option, and is free to ignore some options. It is not uncommon for the configuration to be parsed -several times during the run of a git program, with different callbacks +several times during the run of a Git program, with different callbacks picking out different variables useful to themselves. A config callback function takes three parameters: @@ -36,7 +36,7 @@ Basic Config Querying --------------------- Most programs will simply want to look up variables in all config files -that git knows about, using the normal precedence rules. To do this, +that Git knows about, using the normal precedence rules. To do this, call `git_config` with a callback function and void data pointer. `git_config` will read all config sources in order of increasing @@ -49,7 +49,7 @@ value is left at the end). The `git_config_with_options` function lets the caller examine config while adjusting some of the default behavior of `git_config`. It should -almost never be used by "regular" git code that is looking up +almost never be used by "regular" Git code that is looking up configuration variables. It is intended for advanced callers like `git-config`, which are intentionally tweaking the normal config-lookup process. It takes two extra parameters: @@ -66,7 +66,7 @@ Regular `git_config` defaults to `1`. There is a special version of `git_config` called `git_config_early`. This version takes an additional parameter to specify the repository config, instead of having it looked up via `git_path`. This is useful -early in a git program before the repository has been found. Unless +early in a Git program before the repository has been found. Unless you're working with early setup code, you probably don't want to use this. diff --git a/Documentation/technical/api-credentials.txt b/Documentation/technical/api-credentials.txt index 5977b58e57..516fda7412 100644 --- a/Documentation/technical/api-credentials.txt +++ b/Documentation/technical/api-credentials.txt @@ -7,9 +7,9 @@ world can take many forms, in this document the word "credential" always refers to a username and password pair). This document describes two interfaces: the C API that the credential -subsystem provides to the rest of git, and the protocol that git uses to +subsystem provides to the rest of Git, and the protocol that Git uses to communicate with system-specific "credential helpers". If you are -writing git code that wants to look up or prompt for credentials, see +writing Git code that wants to look up or prompt for credentials, see the section "C API" below. If you want to write your own helper, see the section on "Credential Helpers" below. @@ -18,7 +18,7 @@ Typical setup ------------ +-----------------------+ -| git code (C) |--- to server requiring ---> +| Git code (C) |--- to server requiring ---> | | authentication |.......................| | C credential API |--- prompt ---> User @@ -27,11 +27,11 @@ Typical setup | pipe | | v +-----------------------+ -| git credential helper | +| Git credential helper | +-----------------------+ ------------ -The git code (typically a remote-helper) will call the C API to obtain +The Git code (typically a remote-helper) will call the C API to obtain credential data like a login/password pair (credential_fill). The API will itself call a remote helper (e.g. "git credential-cache" or "git credential-store") that may retrieve credential data from a @@ -42,7 +42,7 @@ contacting the server, and does the actual authentication. C API ----- -The credential C API is meant to be called by git code which needs to +The credential C API is meant to be called by Git code which needs to acquire or store a credential. It is centered around an object representing a single credential and provides three basic operations: fill (acquire credentials by calling helpers and/or prompting the user), @@ -177,14 +177,14 @@ int foo_login(struct foo_connection *f) Credential Helpers ------------------ -Credential helpers are programs executed by git to fetch or save +Credential helpers are programs executed by Git to fetch or save credentials from and to long-term storage (where "long-term" is simply -longer than a single git process; e.g., credentials may be stored +longer than a single Git process; e.g., credentials may be stored in-memory for a few minutes, or indefinitely on disk). Each helper is specified by a single string in the configuration variable `credential.helper` (and others, see linkgit:git-config[1]). -The string is transformed by git into a command to be executed using +The string is transformed by Git into a command to be executed using these rules: 1. If the helper string begins with "!", it is considered a shell @@ -248,7 +248,7 @@ FORMAT` in linkgit:git-credential[7] for a detailed specification). For a `get` operation, the helper should produce a list of attributes on stdout in the same format. A helper is free to produce a subset, or even no values at all if it has nothing useful to provide. Any provided -attributes will overwrite those already known about by git. +attributes will overwrite those already known about by Git. For a `store` or `erase` operation, the helper's output is ignored. If it fails to perform the requested operation, it may complain to diff --git a/Documentation/technical/api-directory-listing.txt b/Documentation/technical/api-directory-listing.txt index 944fc39fac..1f349b28ae 100644 --- a/Documentation/technical/api-directory-listing.txt +++ b/Documentation/technical/api-directory-listing.txt @@ -39,7 +39,7 @@ The notable options are: `DIR_NO_GITLINKS`::: - If set, recurse into a directory that looks like a git + If set, recurse into a directory that looks like a Git directory. Otherwise it is shown as a directory. The result of the enumeration is left in these fields: @@ -67,11 +67,13 @@ marked. If you to exclude files, make sure you have loaded index first. * Prepare `struct dir_struct dir` and clear it with `memset(&dir, 0, sizeof(dir))`. -* Call `add_exclude()` to add single exclude pattern, - `add_excludes_from_file()` to add patterns from a file - (e.g. `.git/info/exclude`), and/or set `dir.exclude_per_dir`. A - short-hand function `setup_standard_excludes()` can be used to set up - the standard set of exclude settings. +* To add single exclude pattern, call `add_exclude_list()` and then + `add_exclude()`. + +* To add patterns from a file (e.g. `.git/info/exclude`), call + `add_excludes_from_file()` , and/or set `dir.exclude_per_dir`. A + short-hand function `setup_standard_excludes()` can be used to set + up the standard set of exclude settings. * Set options described in the Data Structure section above. @@ -79,4 +81,6 @@ marked. If you to exclude files, make sure you have loaded index first. * Use `dir.entries[]`. +* Call `clear_directory()` when none of the contained elements are no longer in use. + (JC) diff --git a/Documentation/technical/api-index-skel.txt b/Documentation/technical/api-index-skel.txt index 730cfacf78..eda8c195c1 100644 --- a/Documentation/technical/api-index-skel.txt +++ b/Documentation/technical/api-index-skel.txt @@ -1,7 +1,7 @@ -GIT API Documents +Git API Documents ================= -GIT has grown a set of internal API over time. This collection +Git has grown a set of internal API over time. This collection documents them. //////////////////////////////////////////////////////////////// diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt index 3062389404..32ddc1cf13 100644 --- a/Documentation/technical/api-parse-options.txt +++ b/Documentation/technical/api-parse-options.txt @@ -1,7 +1,7 @@ parse-options API ================= -The parse-options API is used to parse and massage options in git +The parse-options API is used to parse and massage options in Git and to provide a usage help with consistent look. Basics diff --git a/Documentation/technical/api-remote.txt b/Documentation/technical/api-remote.txt index c54b17db69..4be87768f6 100644 --- a/Documentation/technical/api-remote.txt +++ b/Documentation/technical/api-remote.txt @@ -3,7 +3,7 @@ Remotes configuration API The API in remote.h gives access to the configuration related to remotes. It handles all three configuration mechanisms historically -and currently used by git, and presents the information in a uniform +and currently used by Git, and presents the information in a uniform fashion. Note that the code also handles plain URLs without any configuration, giving them just the default information. @@ -45,7 +45,7 @@ struct remote `receivepack`, `uploadpack`:: The configured helper programs to run on the remote side, for - git-native protocols. + Git-native protocols. `http_proxy`:: diff --git a/Documentation/technical/api-strbuf.txt b/Documentation/technical/api-strbuf.txt index 84686b5c69..2c59cb2259 100644 --- a/Documentation/technical/api-strbuf.txt +++ b/Documentation/technical/api-strbuf.txt @@ -156,6 +156,11 @@ then they will free() it. Remove the bytes between `pos..pos+len` and replace it with the given data. +`strbuf_add_commented_lines`:: + + Add a NUL-terminated string to the buffer. Each line will be prepended + by a comment character and a blank. + `strbuf_add`:: Add data of given length to the buffer. @@ -229,6 +234,11 @@ which can be used by the programmer of the callback as she sees fit. Add a formatted string to the buffer. +`strbuf_commented_addf`:: + + Add a formatted string prepended by a comment character and a + blank to the buffer. + `strbuf_fread`:: Read a given size of data from a FILE* pointer to the buffer. diff --git a/Documentation/technical/index-format.txt b/Documentation/technical/index-format.txt index 7324154838..27c716b15f 100644 --- a/Documentation/technical/index-format.txt +++ b/Documentation/technical/index-format.txt @@ -1,7 +1,7 @@ -GIT index format +Git index format ================ -== The git index file has the following format +== The Git index file has the following format All binary numbers are in network byte order. Version 2 is described here unless stated otherwise. @@ -21,9 +21,9 @@ GIT index format - Extensions Extensions are identified by signature. Optional extensions can - be ignored if GIT does not understand them. + be ignored if Git does not understand them. - GIT currently supports cached tree and resolve undo extensions. + Git currently supports cached tree and resolve undo extensions. 4-byte extension signature. If the first byte is 'A'..'Z' the extension is optional and can be ignored. diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt index a7871fb865..0e37ec9de5 100644 --- a/Documentation/technical/pack-format.txt +++ b/Documentation/technical/pack-format.txt @@ -1,4 +1,4 @@ -GIT pack format +Git pack format =============== == pack-*.pack files have the following format: @@ -9,7 +9,7 @@ GIT pack format The signature is: {'P', 'A', 'C', 'K'} 4-byte version number (network byte order): - GIT currently accepts version number 2 or 3 but + Git currently accepts version number 2 or 3 but generates version 2 only. 4-byte number of objects contained in the pack (network byte order) diff --git a/Documentation/technical/pack-heuristics.txt b/Documentation/technical/pack-heuristics.txt index 103eb5d989..dbdf7ba9c8 100644 --- a/Documentation/technical/pack-heuristics.txt +++ b/Documentation/technical/pack-heuristics.txt @@ -5,11 +5,11 @@ Where do I go to learn the details - of git's packing heuristics? + of Git's packing heuristics? Be careful what you ask! -Followers of the git, please open the git IRC Log and turn to +Followers of the Git, please open the Git IRC Log and turn to February 10, 2006. It's a rare occasion, and we are joined by the King Git Himself, @@ -19,7 +19,7 @@ and seeks enlightenment. Others are present, but silent. Let's listen in! <njs`> Oh, here's a really stupid question -- where do I go to - learn the details of git's packing heuristics? google avails + learn the details of Git's packing heuristics? google avails me not, reading the source didn't help a lot, and wading through the whole mailing list seems less efficient than any of that. @@ -37,7 +37,7 @@ Ah! Modesty after all. <linus> njs, I don't think the docs exist. That's something where I don't think anybody else than me even really got involved. - Most of the rest of git others have been busy with (especially + Most of the rest of Git others have been busy with (especially Junio), but packing nobody touched after I did it. It's cryptic, yet vague. Linus in style for sure. Wise men @@ -57,7 +57,7 @@ Bait... And switch. That ought to do it! - <linus> Remember: git really doesn't follow files. So what it does is + <linus> Remember: Git really doesn't follow files. So what it does is - generate a list of all objects - sort the list according to magic heuristics - walk the list, using a sliding window, seeing if an object @@ -382,7 +382,7 @@ The 'net never forgets, so that should be good until the end of time. <njs`> (if only it happened more...) <linus> Anyway, the pack-file could easily be denser still, but - because it's used both for streaming (the git protocol) and + because it's used both for streaming (the Git protocol) and for on-disk, it has a few pessimizations. Actually, it is a made-up word. But it is a made-up word being @@ -432,12 +432,12 @@ Gasp! OK, saved. That's a fair Engineering trade off. Close call! In fact, Linus reflects on some Basic Engineering Fundamentals, design options, etc. - <linus> More importantly, they allow git to still _conceptually_ + <linus> More importantly, they allow Git to still _conceptually_ never deal with deltas at all, and be a "whole object" store. Which has some problems (we discussed bad huge-file - behaviour on the git lists the other day), but it does mean - that the basic git concepts are really really simple and + behaviour on the Git lists the other day), but it does mean + that the basic Git concepts are really really simple and straightforward. It's all been quite stable. @@ -461,6 +461,6 @@ Nuff said. <njs`> :-) <njs`> appreciate the infodump, I really was failing to find the - details on git packs :-) + details on Git packs :-) And now you know the rest of the story. diff --git a/Documentation/technical/racy-git.txt b/Documentation/technical/racy-git.txt index 53aa0c82c2..6dc82ca5a8 100644 --- a/Documentation/technical/racy-git.txt +++ b/Documentation/technical/racy-git.txt @@ -1,21 +1,21 @@ -Use of index and Racy git problem +Use of index and Racy Git problem ================================= Background ---------- -The index is one of the most important data structures in git. +The index is one of the most important data structures in Git. It represents a virtual working tree state by recording list of paths and their object names and serves as a staging area to write out the next tree object to be committed. The state is "virtual" in the sense that it does not necessarily have to, and often does not, match the files in the working tree. -There are cases git needs to examine the differences between the +There are cases Git needs to examine the differences between the virtual working tree state in the index and the files in the working tree. The most obvious case is when the user asks `git diff` (or its low level implementation, `git diff-files`) or -`git-ls-files --modified`. In addition, git internally checks +`git-ls-files --modified`. In addition, Git internally checks if the files in the working tree are different from what are recorded in the index to avoid stomping on local changes in them during patch application, switching branches, and merging. @@ -24,16 +24,16 @@ In order to speed up this comparison between the files in the working tree and the index entries, the index entries record the information obtained from the filesystem via `lstat(2)` system call when they were last updated. When checking if they differ, -git first runs `lstat(2)` on the files and compares the result +Git first runs `lstat(2)` on the files and compares the result with this information (this is what was originally done by the `ce_match_stat()` function, but the current code does it in `ce_match_stat_basic()` function). If some of these "cached -stat information" fields do not match, git can tell that the +stat information" fields do not match, Git can tell that the files are modified without even looking at their contents. Note: not all members in `struct stat` obtained via `lstat(2)` are used for this comparison. For example, `st_atime` obviously -is not useful. Currently, git compares the file type (regular +is not useful. Currently, Git compares the file type (regular files vs symbolic links) and executable bits (only for regular files) from `st_mode` member, `st_mtime` and `st_ctime` timestamps, `st_uid`, `st_gid`, `st_ino`, and `st_size` members. @@ -49,7 +49,7 @@ of git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ([PATCH] Sync in core time granuality with filesystems, 2005-01-04). -Racy git +Racy Git -------- There is one slight problem with the optimization based on the @@ -67,13 +67,13 @@ timestamp does not change, after this sequence, the cached stat information the index entry records still exactly match what you would see in the filesystem, even though the file `foo` is now different. -This way, git can incorrectly think files in the working tree +This way, Git can incorrectly think files in the working tree are unmodified even though they actually are. This is called -the "racy git" problem (discovered by Pasky), and the entries +the "racy Git" problem (discovered by Pasky), and the entries that appear clean when they may not be because of this problem are called "racily clean". -To avoid this problem, git does two things: +To avoid this problem, Git does two things: . When the cached stat information says the file has not been modified, and the `st_mtime` is the same as (or newer than) @@ -116,7 +116,7 @@ timestamp comparison check done with the former logic anymore. The latter makes sure that the cached stat information for `foo` would never match with the file in the working tree, so later checks by `ce_match_stat_basic()` would report that the index entry -does not match the file and git does not have to fall back on more +does not match the file and Git does not have to fall back on more expensive `ce_modified_check_fs()`. @@ -159,7 +159,7 @@ of the cached stat information. Avoiding runtime penalty ------------------------ -In order to avoid the above runtime penalty, post 1.4.2 git used +In order to avoid the above runtime penalty, post 1.4.2 Git used to have a code that made sure the index file got timestamp newer than the youngest files in the index when there are many young files with the same timestamp as the diff --git a/Documentation/technical/shallow.txt b/Documentation/technical/shallow.txt index 0502a5471e..ea2f69faf5 100644 --- a/Documentation/technical/shallow.txt +++ b/Documentation/technical/shallow.txt @@ -53,3 +53,6 @@ It also writes an appropriate $GIT_DIR/shallow. You can deepen a shallow repository with "git-fetch --depth 20 repo branch", which will fetch branch from repo, but stop at depth 20, updating $GIT_DIR/shallow. + +The special depth 2147483647 (or 0x7fffffff, the largest positive +number a signed 32-bit integer can contain) means infinite depth. diff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt index 00f7e79c44..282758e768 100644 --- a/Documentation/urls-remotes.txt +++ b/Documentation/urls-remotes.txt @@ -6,7 +6,7 @@ REMOTES[[REMOTES]] The name of one of the following can be used instead of a URL as `<repository>` argument: -* a remote in the git configuration file: `$GIT_DIR/config`, +* a remote in the Git configuration file: `$GIT_DIR/config`, * a file in the `$GIT_DIR/remotes` directory, or * a file in the `$GIT_DIR/branches` directory. diff --git a/Documentation/urls.txt b/Documentation/urls.txt index 1d15ee7e52..3ca122faed 100644 --- a/Documentation/urls.txt +++ b/Documentation/urls.txt @@ -29,7 +29,7 @@ The ssh and git protocols additionally support ~username expansion: - git://host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/ - {startsb}user@{endsb}host.xz:/~{startsb}user{endsb}/path/to/repo.git/ -For local repositories, also supported by git natively, the following +For local repositories, also supported by Git natively, the following syntaxes may be used: - /path/to/repo.git/ @@ -46,7 +46,7 @@ These two syntaxes are mostly equivalent, except the former implies --local option. endif::git-clone[] -When git doesn't know how to handle a certain transport protocol, it +When Git doesn't know how to handle a certain transport protocol, it attempts to use the 'remote-<transport>' remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used: @@ -55,7 +55,7 @@ may be used: where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being -invoked. See linkgit:git-remote-helpers[1] for details. +invoked. See linkgit:gitremote-helpers[1] for details. If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 1b377dc207..5077e7cd20 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -5,7 +5,7 @@ ______________________________________________ Git is a fast distributed revision control system. This manual is designed to be readable by someone with basic UNIX -command-line skills, but no previous knowledge of git. +command-line skills, but no previous knowledge of Git. <<repositories-and-branches>> and <<exploring-git-history>> explain how to fetch and study a project using git--read these chapters to learn how @@ -34,7 +34,7 @@ $ git help clone With the latter, you can use the manual viewer of your choice; see linkgit:git-help[1] for more information. -See also <<git-quick-start>> for a brief overview of git commands, +See also <<git-quick-start>> for a brief overview of Git commands, without any explanation. Finally, see <<todo>> for ways that you can help make this manual more @@ -46,10 +46,10 @@ Repositories and Branches ========================= [[how-to-get-a-git-repository]] -How to get a git repository +How to get a Git repository --------------------------- -It will be useful to have a git repository to experiment with as you +It will be useful to have a Git repository to experiment with as you read this manual. The best way to get one is by using the linkgit:git-clone[1] command to @@ -57,7 +57,7 @@ download a copy of an existing repository. If you don't already have a project in mind, here are some interesting examples: ------------------------------------------------ - # git itself (approx. 10MB download): + # Git itself (approx. 10MB download): $ git clone git://git.kernel.org/pub/scm/git/git.git # the Linux kernel (approx. 150MB download): $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git @@ -79,7 +79,7 @@ How to check out a different version of a project Git is best thought of as a tool for storing the history of a collection of files. It stores the history as a compressed collection of -interrelated snapshots of the project's contents. In git each such +interrelated snapshots of the project's contents. In Git each such version is called a <<def_commit,commit>>. Those snapshots aren't necessarily all arranged in a single line from @@ -87,7 +87,7 @@ oldest to newest; instead, work may simultaneously proceed along parallel lines of development, called <<def_branch,branches>>, which may merge and diverge. -A single git repository can track development on multiple branches. It +A single Git repository can track development on multiple branches. It does this by keeping a list of <<def_head,heads>> which reference the latest commit on each branch; the linkgit:git-branch[1] command shows you the list of branch heads: @@ -198,7 +198,7 @@ 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-concepts>> we shall see that everything stored in git +In fact, in <<git-concepts>> 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. @@ -211,7 +211,7 @@ parent commit which shows what happened before this commit. Following the chain of parents will eventually take you back to the beginning of the project. -However, the commits do not form a simple list; git allows lines of +However, the commits do not form a simple list; Git allows lines of development to diverge and then reconverge, and the point where two lines of development reconverge is called a "merge". The commit representing a merge can therefore have more than one parent, with @@ -219,8 +219,8 @@ each parent representing the most recent commit on one of the lines of development leading to that point. The best way to see how this works is using the linkgit:gitk[1] -command; running gitk now on a git repository and looking for merge -commits will help understand how the git organizes history. +command; running gitk now on a Git repository and looking for merge +commits will help understand how the Git organizes history. In the following, we say that commit X is "reachable" from commit Y if commit X is an ancestor of commit Y. Equivalently, you could say @@ -231,7 +231,7 @@ leading from commit Y to commit X. Understanding history: History diagrams ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We will sometimes represent git history using diagrams like the one +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: @@ -285,7 +285,7 @@ git branch -D <branch>:: even if the branch points to a commit not reachable from the current branch, you may know that that commit is still reachable from some other branch or tag. In that - case it is safe to use this command to force git to delete + case it is safe to use this command to force Git to delete the branch. git checkout <branch>:: make the current branch <branch>, updating the working @@ -295,7 +295,7 @@ git checkout -b <new> <start-point>:: check it out. The special symbol "HEAD" can always be used to refer to the current -branch. In fact, git uses a file named "HEAD" in the .git directory to +branch. In fact, Git uses a file named "HEAD" in the .git directory to remember which branch is current: ------------------------------------------------ @@ -377,7 +377,7 @@ $ git checkout -b my-todo-copy origin/todo You can also check out "origin/todo" directly to examine it or write a one-off patch. See <<detached-head,detached head>>. -Note that the name "origin" is just the name that git uses by default +Note that the name "origin" is just the name that Git uses by default to refer to the repository that you cloned from. [[how-git-stores-references]] @@ -405,7 +405,7 @@ As another useful shortcut, the "HEAD" of a repository can be referred to just using the name of that repository. So, for example, "origin" is usually a shortcut for the HEAD branch in the repository "origin". -For the complete list of paths which git checks for references, and +For the complete list of paths which Git checks for references, and the order it uses to decide which to choose when there are multiple references with the same shorthand name, see the "SPECIFYING REVISIONS" section of linkgit:gitrevisions[7]. @@ -449,7 +449,7 @@ origin/master If you run "git fetch <remote>" later, the remote-tracking branches for the named <remote> will be updated. -If you examine the file .git/config, you will see that git has added +If you examine the file .git/config, you will see that Git has added a new stanza: ------------------------------------------------- @@ -461,13 +461,13 @@ $ cat .git/config ... ------------------------------------------------- -This is what causes git to track the remote's branches; you may modify +This is what causes Git to track the remote's branches; you may modify or delete these configuration options by editing .git/config with a text editor. (See the "CONFIGURATION FILE" section of linkgit:git-config[1] for details.) [[exploring-git-history]] -Exploring git history +Exploring Git history ===================== Git is best thought of as a tool for storing the history of a @@ -499,7 +499,7 @@ Bisecting: 3537 revisions left to test after this [65934a9a028b88e83e2b0f8b36618fe503349f8e] BLOCK: Make USB storage depend on SCSI rather than selecting it [try #6] ------------------------------------------------- -If you run "git branch" at this point, you'll see that git has +If you run "git branch" at this point, you'll see that Git has temporarily moved you in "(no branch)". HEAD is now detached from any branch and points directly to a commit (with commit id 65934...) that is reachable from "master" but not from v2.6.18. Compile and test it, @@ -511,7 +511,7 @@ Bisecting: 1769 revisions left to test after this [7eff82c8b1511017ae605f0c99ac275a7e21b867] i2c-core: Drop useless bitmaskings ------------------------------------------------- -checks out an older version. Continue like this, telling git at each +checks out an older version. Continue like this, telling Git at each stage whether the version it gives you is good or bad, and notice that the number of revisions left to test is cut approximately in half each time. @@ -549,14 +549,14 @@ then test, run "bisect good" or "bisect bad" as appropriate, and continue. Instead of "git bisect visualize" and then "git reset --hard -fb47ddb2db...", you might just want to tell git that you want to skip +fb47ddb2db...", you might just want to tell Git that you want to skip the current commit: ------------------------------------------------- $ git bisect skip ------------------------------------------------- -In this case, though, git may not eventually be able to tell the first +In this case, though, Git may not eventually be able to tell the first bad one between some first skipped commits and a later bad commit. There are also ways to automate the bisecting process if you have a @@ -685,7 +685,7 @@ See the "--pretty" option in the linkgit:git-log[1] man page for more display options. Note that git log starts with the most recent commit and works -backwards through the parents; however, since git history can contain +backwards through the parents; however, since Git history can contain multiple independent lines of development, the particular order that commits are listed in may be somewhat arbitrary. @@ -732,7 +732,7 @@ $ git show v2.5:fs/locks.c ------------------------------------------------- Before the colon may be anything that names a commit, and after it -may be any path to a file tracked by git. +may be any path to a file tracked by Git. [[history-examples]] Examples @@ -984,14 +984,14 @@ student. The linkgit:git-log[1], linkgit:git-diff-tree[1], and linkgit:git-hash-object[1] man pages may prove helpful. [[Developing-With-git]] -Developing with git +Developing with Git =================== [[telling-git-your-name]] -Telling git your name +Telling Git your name --------------------- -Before creating any commits, you should introduce yourself to git. The +Before creating any commits, you should introduce yourself to Git. The easiest way to do so is to make sure the following lines appear in a file named .gitconfig in your home directory: @@ -1035,13 +1035,13 @@ Creating a new commit takes three steps: 1. Making some changes to the working directory using your favorite editor. - 2. Telling git about your changes. - 3. Creating the commit using the content you told git about + 2. Telling Git about your changes. + 3. Creating the commit using the content you told Git about in step 2. In practice, you can interleave and repeat steps 1 and 2 as many times as you want: in order to keep track of what you want committed -at step 3, git maintains a snapshot of the tree's contents in a +at step 3, Git maintains a snapshot of the tree's contents in a special staging area called "the index." At the beginning, the content of the index will be identical to @@ -1094,7 +1094,7 @@ When you're ready, just run $ git commit ------------------------------------------------- -and git will prompt you for a commit message and then create the new +and Git will prompt you for a commit message and then create the new commit. Check to make sure it looks like what you expected with ------------------------------------------------- @@ -1138,7 +1138,7 @@ with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used -throughout git. For example, linkgit:git-format-patch[1] turns a +throughout Git. For example, linkgit:git-format-patch[1] turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body. @@ -1147,15 +1147,15 @@ rest of the commit in the body. Ignoring files -------------- -A project will often generate files that you do 'not' want to track with git. +A project will often generate files that you do 'not' want to track with Git. This typically includes files generated by a build process or temporary -backup files made by your editor. Of course, 'not' tracking files with git +backup files made by your editor. Of course, 'not' tracking files with Git is just a matter of 'not' calling `git add` on them. But it quickly becomes annoying to have these untracked files lying around; e.g. they make `git add .` practically useless, and they keep showing up in the output of `git status`. -You can tell git to ignore certain files by creating a file called .gitignore +You can tell Git to ignore certain files by creating a file called .gitignore in the top level of your working directory, with contents such as: ------------------------------------------------- @@ -1181,7 +1181,7 @@ for other users who clone your repository. If you wish the exclude patterns to affect only certain repositories (instead of every repository for a given project), you may instead put them in a file in your repository named .git/info/exclude, or in any file -specified by the `core.excludesfile` configuration variable. Some git +specified by the `core.excludesfile` configuration variable. Some Git commands can also take exclude patterns directly on the command line. See linkgit:gitignore[5] for the details. @@ -1227,7 +1227,7 @@ Automatic merge failed; fix conflicts and then commit the result. Conflict markers are left in the problematic files, and after you resolve the conflicts manually, you can update the index -with the contents and run git commit, as you normally would when +with the contents and run Git commit, as you normally would when creating a new file. If you examine the resulting commit using gitk, you will see that it @@ -1238,7 +1238,7 @@ one to the top of the other branch. Resolving a merge ----------------- -When a merge isn't resolved automatically, git leaves the index and +When a merge isn't resolved automatically, Git leaves the index and the working tree in a special state that gives you all the information you need to help resolve the merge. @@ -1274,14 +1274,14 @@ 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 +The above is all you need to know to resolve a simple merge. But Git also provides more information to help resolve conflicts: [[conflict-resolution]] Getting conflict-resolution help during a merge ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -All of the changes that git was able to merge automatically are +All of the changes that Git was able to merge automatically are already added to the index file, so linkgit:git-diff[1] shows only the conflicts. It uses an unusual syntax: @@ -1413,7 +1413,7 @@ parents, one pointing at each of the two lines of development that were merged. However, if the current branch is a descendant of the other--so every -commit present in the one is already contained in the other--then git +commit present in the one is already contained in the other--then Git just performs a "fast-forward"; the head of the current branch is moved forward to point at the head of the merged-in branch, without any new commits being created. @@ -1439,7 +1439,7 @@ fundamentally different ways to fix the problem: 2. You can go back and modify the old commit. You should never do this if you have already made the history public; - git does not normally expect the "history" of a project to + Git does not normally expect the "history" of a project to change, and cannot correctly perform repeated merges from a branch that has had its history changed. @@ -1464,7 +1464,7 @@ You can also revert an earlier change, for example, the next-to-last: $ git revert HEAD^ ------------------------------------------------- -In this case git will attempt to undo the old change while leaving +In this case Git will attempt to undo the old change while leaving intact any changes made since then. If more recent changes overlap with the changes to be reverted, then you will be asked to fix conflicts manually, just as in the case of <<resolving-a-merge, @@ -1561,7 +1561,7 @@ $ git stash pop Ensuring good performance ------------------------- -On large repositories, git depends on compression to keep the history +On large repositories, Git depends on compression to keep the history information from taking up too much space on disk or in memory. This compression is not performed automatically. Therefore you @@ -1618,7 +1618,7 @@ Say you modify a branch with +linkgit:git-reset[1] \--hard+, and then realize that the branch was the only reference you had to that point in history. -Fortunately, git also keeps a log, called a "reflog", of all the +Fortunately, Git also keeps a log, called a "reflog", of all the previous values of each branch. So in this case you can still find the old history using, for example, @@ -1627,7 +1627,7 @@ $ git log master@{1} ------------------------------------------------- This lists the commits reachable from the previous version of the -"master" branch head. This syntax can be used with any git command +"master" branch head. This syntax can be used with any Git command that accepts a commit, not just with git log. Some other examples: ------------------------------------------------- @@ -1653,7 +1653,7 @@ pruned. See linkgit:git-reflog[1] and linkgit:git-gc[1] to learn how to control this pruning, and see the "SPECIFYING REVISIONS" section of linkgit:gitrevisions[7] for details. -Note that the reflog history is very different from normal git history. +Note that the reflog history is very different from normal Git history. While normal history is shared by every repository that works on the same project, the reflog history is not shared: it tells you only about how the branches in your local repository have changed over time. @@ -1816,7 +1816,7 @@ $ git am -3 patches.mbox Git will apply each patch in order; if any conflicts are found, it will stop, and you can fix the conflicts as described in "<<resolving-a-merge,Resolving a merge>>". (The "-3" option tells -git to perform a merge; if you would prefer it just to abort and +Git to perform a merge; if you would prefer it just to abort and leave your tree and index untouched, you may omit that option.) Once the index is updated with the results of the conflict @@ -1826,7 +1826,7 @@ resolution, instead of creating a new commit, just run $ git am --resolved ------------------------------------------------- -and git will create the commit for you and continue applying the +and Git will create the commit for you and continue applying the remaining patches from the mailbox. The final result will be a series of commits, one for each patch in @@ -1834,7 +1834,7 @@ the original mailbox, with authorship and commit log message each taken from the message containing each patch. [[public-repositories]] -Public git repositories +Public Git repositories ----------------------- Another way to submit changes to a project is to tell the maintainer @@ -1909,7 +1909,7 @@ public repository. You can use scp, rsync, or whatever is most convenient. [[exporting-via-git]] -Exporting a git repository via the git protocol +Exporting a Git repository via the Git protocol ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the preferred method. @@ -1922,7 +1922,7 @@ repository>>", below. Otherwise, all you need to do is start linkgit:git-daemon[1]; it will listen on port 9418. By default, it will allow access to any directory -that looks like a git directory and contains the magic file +that looks like a Git directory and contains the magic file git-daemon-export-ok. Passing some directory paths as `git daemon` arguments will further restrict the exports to those paths. @@ -1931,13 +1931,13 @@ linkgit:git-daemon[1] man page for details. (See especially the examples section.) [[exporting-via-http]] -Exporting a git repository via http +Exporting a Git repository via http ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The git protocol gives better performance and reliability, but on a +The Git protocol gives better performance and reliability, but on a host with a web server set up, http exports may be simpler to set up. -All you need to do is place the newly created bare git repository in +All you need to do is place the newly created bare Git repository in a directory that is exported by the web server, and make some adjustments to give web clients some extra information they need: @@ -2073,9 +2073,9 @@ all push to and pull from a single shared repository. See linkgit:gitcvs-migration[7] for instructions on how to set this up. -However, while there is nothing wrong with git's support for shared +However, while there is nothing wrong with Git's support for shared repositories, this mode of operation is not generally recommended, -simply because the mode of collaboration that git supports--by +simply because the mode of collaboration that Git supports--by exchanging patches and pulling from public repositories--has so many advantages over the central shared repository: @@ -2099,8 +2099,8 @@ Allowing web browsing of a repository ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The gitweb cgi script provides users an easy way to browse your -project's files and history without having to install git; see the file -gitweb/INSTALL in the git source tree for instructions on setting it up. +project's files and history without having to install Git; see the file +gitweb/INSTALL in the Git source tree for instructions on setting it up. [[sharing-development-examples]] Examples @@ -2110,7 +2110,7 @@ Examples Maintaining topic branches for a Linux subsystem maintainer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This describes how Tony Luck uses git in his role as maintainer of the +This describes how Tony Luck uses Git in his role as maintainer of the IA64 architecture for the Linux kernel. He uses two public branches: @@ -2160,7 +2160,7 @@ $ git checkout release && git pull Important note! If you have any local changes in these branches, then this merge will create a commit object in the history (with no local -changes git will simply do a "fast-forward" merge). Many people dislike +changes Git will simply do a "fast-forward" merge). Many people dislike the "noise" that this creates in the Linux history, so you should avoid doing this capriciously in the "release" branch, as these noisy commits will become part of the permanent history when you ask Linus to pull @@ -2299,7 +2299,7 @@ Here are some of the scripts that simplify all this even further. ------------------------------------------------- ==== update script ==== -# Update a branch in my GIT tree. If the branch to be updated +# Update a branch in my Git tree. If the branch to be updated # is origin, then pull from kernel.org. Otherwise merge # origin/master branch into test|release branch @@ -2357,7 +2357,7 @@ esac ------------------------------------------------- ==== status script ==== -# report on status of my ia64 GIT tree +# report on status of my ia64 Git tree gb=$(tput setab 2) rb=$(tput setab 1) @@ -2413,7 +2413,7 @@ Rewriting history and maintaining patch series Normally commits are only added to a project, never taken away or replaced. Git is designed with this assumption, and violating it will -cause git's merge machinery (for example) to do the wrong thing. +cause Git's merge machinery (for example) to do the wrong thing. However, there is a situation in which it can be useful to violate this assumption. @@ -2524,7 +2524,7 @@ running `git commit`, just run $ git rebase --continue ------------------------------------------------- -and git will continue applying the rest of the patches. +and Git will continue applying the rest of the patches. At any point you may use the `--abort` option to abort this process and return mywork to the state it had before you started the rebase: @@ -2577,7 +2577,7 @@ then clean up with $ git tag -d bad ------------------------------------------------- -Note that the immutable nature of git history means that you haven't really +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. @@ -2658,7 +2658,7 @@ 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 two developers had independently done the work on the old and new heads in parallel. At this point, if someone attempts to merge the new head -in to their branch, git will attempt to merge together the two (old and +in to their branch, Git will attempt to merge together the two (old and new) lines of development, instead of trying to replace the old by the new. The results are likely to be unexpected. @@ -2731,7 +2731,7 @@ linear history: Bisecting between Z and D* would hit a single culprit commit Y*, and understanding why Y* was broken would probably be easier. -Partly for this reason, many experienced git users, even when +Partly for this reason, many experienced Git users, even when working on an otherwise merge-heavy project, keep the history linear by rebasing against the latest upstream version before publishing. @@ -2752,8 +2752,8 @@ arbitrary name: $ git fetch origin todo:my-todo-work ------------------------------------------------- -The first argument, "origin", just tells git to fetch from the -repository you originally cloned from. The second argument tells git +The first argument, "origin", just tells Git to fetch from the +repository you originally cloned from. The second argument tells Git to fetch the branch named "todo" from the remote repository, and to store it locally under the name refs/heads/my-todo-work. @@ -2801,7 +2801,7 @@ resulting in a situation like: In this case, "git fetch" will fail, and print out a warning. -In that case, you can still force git to update to the new head, as +In that case, you can still force Git to update to the new head, as described in the following section. However, note that in the situation above this may mean losing the commits labeled "a" and "b", unless you've already created a reference of your own pointing to @@ -2834,7 +2834,7 @@ Configuring remote-tracking branches We saw above that "origin" is just a shortcut to refer to the repository that you originally cloned from. This information is -stored in git configuration variables, which you can see using +stored in Git configuration variables, which you can see using linkgit:git-config[1]: ------------------------------------------------- @@ -2900,7 +2900,7 @@ Git concepts Git is built on a small number of simple but powerful ideas. While it is possible to get things done without understanding them, you will find -git much more intuitive if you do. +Git much more intuitive if you do. We start with the most important, the <<def_object_database,object database>> and the <<def_index,index>>. @@ -2994,7 +2994,7 @@ As you can see, a commit is defined by: Note that a commit does not itself contain any information about what actually changed; all changes are calculated by comparing the contents of the tree referred to by this commit with the trees associated with -its parents. In particular, git does not attempt to record file renames +its parents. In particular, Git does not attempt to record file renames explicitly, though it can identify cases where the existence of the same file data at changing paths suggests a rename. (See, for example, the -M option to linkgit:git-diff[1]). @@ -3033,14 +3033,14 @@ another tree, representing the contents of a subdirectory. Since trees and blobs, like all other objects, are named by the SHA-1 hash of their contents, two trees have the same SHA-1 name if and only if their contents (including, recursively, the contents of all subdirectories) -are identical. This allows git to quickly determine the differences +are identical. This allows Git to quickly determine the differences between two related tree objects, since it can ignore any entries with identical object names. (Note: in the presence of submodules, trees may also have commits as entries. See <<submodules>> for documentation.) -Note that the files all have mode 644 or 755: git actually only pays +Note that the files all have mode 644 or 755: Git actually only pays attention to the executable bit. [[blob-object]] @@ -3101,7 +3101,7 @@ sending out a single email that tells the people the name (SHA-1 hash) of the top commit, and digitally sign that email using something like GPG/PGP. -To assist in this, git also provides the tag object... +To assist in this, Git also provides the tag object... [[tag-object]] Tag Object @@ -3134,7 +3134,7 @@ objects. (Note that linkgit:git-tag[1] can also be used to create references whose names begin with "refs/tags/"). [[pack-files]] -How git stores objects efficiently: pack files +How Git stores objects efficiently: pack files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Newly created objects are initially created in a file named after the @@ -3152,7 +3152,7 @@ The first number is the number of objects which are kept in individual files. The second is the amount of space taken up by those "loose" objects. -You can save space and make git faster by moving these loose objects in +You can save space and make Git faster by moving these loose objects in to a "pack file", which stores a group of objects in an efficient compressed format; the details of how pack files are formatted can be found in link:technical/pack-format.txt[technical/pack-format.txt]. @@ -3285,12 +3285,12 @@ repository is a *BAD* idea). Recovering from repository corruption ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By design, git treats data trusted to it with caution. However, even in -the absence of bugs in git itself, it is still possible that hardware or +By design, Git treats data trusted to it with caution. However, even in +the absence of bugs in Git itself, it is still possible that hardware or operating system errors could corrupt data. The first defense against such problems is backups. You can back up a -git directory using clone, or just using cp, tar, or any other backup +Git directory using clone, or just using cp, tar, or any other backup mechanism. As a last resort, you can search for the corrupted objects and attempt @@ -3396,7 +3396,7 @@ $ git log --raw --all ------------------------------------------------ and just looked for the sha of the missing object (4b9458b..) in that -whole thing. It's up to you - git does *have* a lot of information, it is +whole thing. It's up to you - Git does *have* a lot of information, it is just missing one particular blob version. [[the-index]] @@ -3438,7 +3438,7 @@ It does this by storing some additional data for each entry (such as the last modified time). This data is not displayed above, and is not stored in the created tree object, but it can be used to determine quickly which files in the working directory differ from what was -stored in the index, and thus save git from having to read all of the +stored in the index, and thus save Git from having to read all of the data from such files to look for changes. 3. It can efficiently represent information about merge conflicts @@ -3669,9 +3669,9 @@ Did you forget to 'git add'? Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a' ------------------------------------------------- -In older git versions it could be easily forgotten to commit new or modified +In older Git versions it could be easily forgotten to commit new or modified files in a submodule, which silently leads to similar problems as not pushing -the submodule changes. Starting with git 1.7.0 both "git status" and "git diff" +the submodule changes. Starting with Git 1.7.0 both "git status" and "git diff" in the superproject show submodules as modified when they contain new or modified files to protect against accidentally committing such a state. "git diff" will also add a "-dirty" to the work tree side when generating patch @@ -3714,12 +3714,12 @@ NOTE: The changes are still visible in the submodule's reflog. This is not the case if you did not commit your changes. [[low-level-operations]] -Low-level git operations +Low-level Git operations ======================== Many of the higher-level commands were originally implemented as shell -scripts using a smaller core of low-level git commands. These can still -be useful when doing unusual things with git, or just as a way to +scripts using a smaller core of low-level Git commands. These can still +be useful when doing unusual things with Git, or just as a way to understand its inner workings. [[object-manipulation]] @@ -3750,7 +3750,7 @@ between the working tree, the index, and the object database. Git provides low-level operations which perform each of these steps individually. -Generally, all "git" operations work on the index file. Some operations +Generally, all Git operations work on the index file. Some operations work *purely* on the index file (showing the current state of the index), but most operations move data between the index file and either the database or the working directory. Thus there are four main @@ -3773,7 +3773,7 @@ but to avoid common mistakes with filename globbing etc, the command will not normally add totally new entries or remove old entries, i.e. it will normally just update existing cache entries. -To tell git that yes, you really do realize that certain files no +To tell Git that yes, you really do realize that certain files no longer exist, or that new files should be added, you should use the `--remove` and `--add` flags respectively. @@ -3887,7 +3887,7 @@ redirection from a pipe or file, or by just typing it at the tty). `git commit-tree` will return the name of the object that represents that commit, and you should save it away for later use. Normally, -you'd commit a new `HEAD` state, and while git doesn't care where you +you'd commit a new `HEAD` state, and while Git doesn't care where you save the note about that state, in practice we tend to just write the result to the file pointed at by `.git/HEAD`, so that we can always see what the last committed state was. @@ -4044,7 +4044,7 @@ $ git ls-files --unmerged Each line of the `git ls-files --unmerged` output begins with the blob mode bits, blob SHA-1, 'stage number', and the -filename. The 'stage number' is git's way to say which tree it +filename. The 'stage number' is Git's way to say which tree it came from: stage 1 corresponds to the `$orig` tree, stage 2 to the `HEAD` tree, and stage 3 to the `$target` tree. @@ -4056,7 +4056,7 @@ obviously the final outcome is what is in `HEAD`. What the above example shows is that file `hello.c` was changed from `$orig` to `HEAD` and `$orig` to `$target` in a different way. You could resolve this by running your favorite 3-way merge -program, e.g. `diff3`, `merge`, or git's own merge-file, on +program, e.g. `diff3`, `merge`, or Git's own merge-file, on the blob objects from these three stages yourself, like this: ------------------------------------------------ @@ -4068,7 +4068,7 @@ $ git merge-file hello.c~2 hello.c~1 hello.c~3 This would leave the merge result in `hello.c~2` file, along with conflict markers if there are conflicts. After verifying -the merge result makes sense, you can tell git what the final +the merge result makes sense, you can tell Git what the final merge result for this file is by: ------------------------------------------------- @@ -4077,11 +4077,11 @@ $ git update-index hello.c ------------------------------------------------- When a path is in the "unmerged" state, running `git update-index` for -that path tells git to mark the path resolved. +that path tells Git to mark the path resolved. -The above is the description of a git merge at the lowest level, +The above is the description of a Git merge at the lowest level, to help you understand what conceptually happens under the hood. -In practice, nobody, not even git itself, runs `git cat-file` three times +In practice, nobody, not even Git itself, runs `git cat-file` three times for this. There is a `git merge-index` program that extracts the stages to temporary files and calls a "merge" script on it: @@ -4092,11 +4092,11 @@ $ git merge-index git-merge-one-file hello.c and that is what higher level `git merge -s resolve` is implemented with. [[hacking-git]] -Hacking git +Hacking Git =========== -This chapter covers internal details of the git implementation which -probably only git developers need to understand. +This chapter covers internal details of the Git implementation which +probably only Git developers need to understand. [[object-details]] Object storage format @@ -4114,7 +4114,7 @@ about the data in the object. It's worth noting that the SHA-1 hash that is used to name the object is the hash of the original data plus this header, so `sha1sum` 'file' does not match the object name for 'file'. -(Historical note: in the dawn of the age of git the hash +(Historical note: in the dawn of the age of Git the hash was the SHA-1 of the 'compressed' object.) As a result, the general consistency of an object can always be tested @@ -4144,7 +4144,7 @@ A good place to start is with the contents of the initial commit, with: $ git checkout e83c5163 ---------------------------------------------------- -The initial revision lays the foundation for almost everything git has +The initial revision lays the foundation for almost everything Git has today, but is small enough to read in one sitting. Note that terminology has changed since that revision. For example, the @@ -4298,7 +4298,7 @@ Now, for the meat: This is how you read a blob (actually, not only a blob, but any type of object). To know how the function `read_object_with_reference()` actually works, find the source code for it (something like `git grep -read_object_with | grep ":[a-z]"` in the git repository), and read +read_object_with | grep ":[a-z]"` in the Git repository), and read the source. To find out how the result can be used, just read on in `cmd_cat_file()`: @@ -4479,7 +4479,7 @@ $ git bisect bad # if this revision is bad. Making changes -------------- -Make sure git knows who to blame: +Make sure Git knows who to blame: ------------------------------------------------ $ cat >>~/.gitconfig <<\EOF @@ -4529,7 +4529,7 @@ $ git format-patch origin..HEAD # format a patch for each commit $ git am mbox # import patches from the mailbox "mbox" ----------------------------------------------- -Fetch a branch in a different git repository, then merge into the +Fetch a branch in a different Git repository, then merge into the current branch: ----------------------------------------------- @@ -4590,7 +4590,7 @@ The basic requirements: - It must be readable in order, from beginning to end, by someone intelligent with a basic grasp of the UNIX command line, but without - any special knowledge of git. If necessary, any other prerequisites + any special knowledge of Git. If necessary, any other prerequisites should be specifically mentioned as they arise. - Whenever possible, section headings should clearly describe the task they explain how to do, in language that requires no more knowledge @@ -131,8 +131,9 @@ Issues of note: use English. Under autoconf the configure script will do this automatically if it can't find libintl on the system. - - Python version 2.6 or later is needed to use the git-p4 - interface to Perforce. + - Python version 2.4 or later (but not 3.x, which is not + supported by Perforce) is needed to use the git-p4 interface + to Perforce. - Some platform specific issues are dealt with Makefile rules, but depending on your specific installation, you may not @@ -105,6 +105,9 @@ all:: # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the # FNM_CASEFOLD GNU extension. # +# Define USE_WILDMATCH if you want to use Git's wildmatch +# implementation as fnmatch +# # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd # in the C library. # @@ -241,11 +244,16 @@ all:: # apostrophes to be ASCII so that cut&pasting examples to the shell # will work. # +# Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl). +# # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's # MakeMaker (e.g. using ActiveState under Cygwin). # # Define NO_PERL if you do not want Perl scripts or libraries at all. # +# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python +# but /usr/bin/python2.7 on some platforms). +# # Define NO_PYTHON if you do not want Python scripts or libraries at all. # # Define NO_TCLTK if you do not want Tcl/Tk GUI. @@ -661,6 +669,7 @@ LIB_H += pack-revindex.h LIB_H += pack.h LIB_H += parse-options.h LIB_H += patch-ids.h +LIB_H += pathspec.h LIB_H += pkt-line.h LIB_H += progress.h LIB_H += prompt.h @@ -784,6 +793,7 @@ LIB_OBJS += parse-options-cb.o LIB_OBJS += patch-delta.o LIB_OBJS += patch-ids.o LIB_OBJS += path.o +LIB_OBJS += pathspec.o LIB_OBJS += pkt-line.o LIB_OBJS += preload-index.o LIB_OBJS += pretty.o @@ -849,6 +859,7 @@ BUILTIN_OBJS += builtin/branch.o BUILTIN_OBJS += builtin/bundle.o BUILTIN_OBJS += builtin/cat-file.o BUILTIN_OBJS += builtin/check-attr.o +BUILTIN_OBJS += builtin/check-ignore.o BUILTIN_OBJS += builtin/check-ref-format.o BUILTIN_OBJS += builtin/checkout-index.o BUILTIN_OBJS += builtin/checkout.o @@ -962,7 +973,8 @@ endif ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto) dep_check = $(shell $(CC) $(ALL_CFLAGS) \ - -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \ + -c -MF /dev/null -MQ /dev/null -MMD -MP \ + -x c /dev/null -o /dev/null 2>&1; \ echo $$?) ifeq ($(dep_check),0) override COMPUTE_HEADER_DEPENDENCIES = yes @@ -1217,6 +1229,9 @@ ifdef NO_FNMATCH_CASEFOLD COMPAT_OBJS += compat/fnmatch/fnmatch.o endif endif +ifdef USE_WILDMATCH + COMPAT_CFLAGS += -DUSE_WILDMATCH +endif ifdef NO_SETENV COMPAT_CFLAGS += -DNO_SETENV COMPAT_OBJS += compat/setenv.o @@ -1829,7 +1844,7 @@ $(dep_dirs): missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs)) dep_file = $(dir $@).depend/$(notdir $@).d -dep_args = -MF $(dep_file) -MMD -MP +dep_args = -MF $(dep_file) -MQ $@ -MMD -MP ifdef CHECK_HEADER_DEPENDENCIES $(error cannot compute header dependencies outside a normal build. \ Please unset CHECK_HEADER_DEPENDENCIES and try again) @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////// - GIT - the stupid content tracker + Git - the stupid content tracker //////////////////////////////////////////////////////////////// @@ -47,11 +47,10 @@ requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just "subscribe git" in the body to majordomo@vger.kernel.org. The mailing list archives are -available at http://marc.theaimsgroup.com/?l=git and other archival -sites. - -The messages titled "A note from the maintainer", "What's in -git.git (stable)" and "What's cooking in git.git (topics)" and -the discussion following them on the mailing list give a good -reference for project status, development direction and -remaining tasks. +available at http://news.gmane.org/gmane.comp.version-control.git/, +http://marc.info/?l=git and other archival sites. + +The maintainer frequently sends the "What's cooking" reports that +list the current status of various development topics to the mailing +list. The discussion following them give a good reference for +project status, development direction and remaining tasks. @@ -5,6 +5,8 @@ int advice_push_non_ff_current = 1; int advice_push_non_ff_default = 1; int advice_push_non_ff_matching = 1; int advice_push_already_exists = 1; +int advice_push_fetch_first = 1; +int advice_push_needs_force = 1; int advice_status_hints = 1; int advice_commit_before_merge = 1; int advice_resolve_conflict = 1; @@ -20,6 +22,8 @@ static struct { { "pushnonffdefault", &advice_push_non_ff_default }, { "pushnonffmatching", &advice_push_non_ff_matching }, { "pushalreadyexists", &advice_push_already_exists }, + { "pushfetchfirst", &advice_push_fetch_first }, + { "pushneedsforce", &advice_push_needs_force }, { "statushints", &advice_status_hints }, { "commitbeforemerge", &advice_commit_before_merge }, { "resolveconflict", &advice_resolve_conflict }, @@ -8,6 +8,8 @@ extern int advice_push_non_ff_current; extern int advice_push_non_ff_default; extern int advice_push_non_ff_matching; extern int advice_push_already_exists; +extern int advice_push_fetch_first; +extern int advice_push_needs_force; extern int advice_status_hints; extern int advice_commit_before_merge; extern int advice_resolve_conflict; diff --git a/archive-tar.c b/archive-tar.c index d1cce46e33..719b6298e6 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -327,20 +327,12 @@ static struct archiver *find_tar_filter(const char *name, int len) static int tar_filter_config(const char *var, const char *value, void *data) { struct archiver *ar; - const char *dot; const char *name; const char *type; int namelen; - if (prefixcmp(var, "tar.")) + if (parse_config_key(var, "tar", &name, &namelen, &type) < 0 || !name) return 0; - dot = strrchr(var, '.'); - if (dot == var + 9) - return 0; - - name = var + 4; - namelen = dot - name; - type = dot + 1; ar = find_tar_filter(name, namelen); if (!ar) { @@ -52,6 +52,7 @@ extern int cmd_cat_file(int argc, const char **argv, const char *prefix); extern int cmd_checkout(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_attr(int argc, const char **argv, const char *prefix); +extern int cmd_check_ignore(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); diff --git a/builtin/add.c b/builtin/add.c index 075312afcd..7738025a2e 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -6,6 +6,7 @@ #include "cache.h" #include "builtin.h" #include "dir.h" +#include "pathspec.h" #include "exec_cmd.h" #include "cache-tree.h" #include "run-command.h" @@ -97,39 +98,6 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags) return !!data.add_errors; } -static void fill_pathspec_matches(const char **pathspec, char *seen, int specs) -{ - int num_unmatched = 0, i; - - /* - * Since we are walking the index as if we were walking the directory, - * we have to mark the matched pathspec as seen; otherwise we will - * mistakenly think that the user gave a pathspec that did not match - * anything. - */ - for (i = 0; i < specs; i++) - if (!seen[i]) - num_unmatched++; - if (!num_unmatched) - return; - for (i = 0; i < active_nr; i++) { - struct cache_entry *ce = active_cache[i]; - match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen); - } -} - -static char *find_used_pathspec(const char **pathspec) -{ - char *seen; - int i; - - for (i = 0; pathspec[i]; i++) - ; /* just counting */ - seen = xcalloc(i, 1); - fill_pathspec_matches(pathspec, seen, i); - return seen; -} - static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { char *seen; @@ -149,10 +117,14 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec, int *dst++ = entry; } dir->nr = dst - dir->entries; - fill_pathspec_matches(pathspec, seen, specs); + add_pathspec_matches_against_index(pathspec, seen, specs); return seen; } +/* + * Checks the index to see whether any path in pathspec refers to + * something inside a submodule. If so, dies with an error message. + */ static void treat_gitlinks(const char **pathspec) { int i; @@ -160,24 +132,8 @@ static void treat_gitlinks(const char **pathspec) if (!pathspec || !*pathspec) return; - for (i = 0; i < active_nr; i++) { - struct cache_entry *ce = active_cache[i]; - if (S_ISGITLINK(ce->ce_mode)) { - int len = ce_namelen(ce), j; - for (j = 0; pathspec[j]; j++) { - int len2 = strlen(pathspec[j]); - if (len2 <= len || pathspec[j][len] != '/' || - memcmp(ce->name, pathspec[j], len)) - continue; - if (len2 == len + 1) - /* strip trailing slash */ - pathspec[j] = xstrndup(ce->name, len); - else - die (_("Path '%s' is in submodule '%.*s'"), - pathspec[j], len, ce->name); - } - } - } + for (i = 0; pathspec[i]; i++) + pathspec[i] = check_path_for_gitlink(pathspec[i]); } static void refresh(int verbose, const char **pathspec) @@ -197,17 +153,19 @@ static void refresh(int verbose, const char **pathspec) free(seen); } -static const char **validate_pathspec(int argc, const char **argv, const char *prefix) +/* + * Normalizes argv relative to prefix, via get_pathspec(), and then + * runs die_if_path_beyond_symlink() on each path in the normalized + * list. + */ +static const char **validate_pathspec(const char **argv, const char *prefix) { const char **pathspec = get_pathspec(prefix, argv); if (pathspec) { const char **p; for (p = pathspec; *p; p++) { - if (has_symlink_leading_path(*p, strlen(*p))) { - int len = prefix ? strlen(prefix) : 0; - die(_("'%s' is beyond a symbolic link"), *p + len); - } + die_if_path_beyond_symlink(*p, prefix); } } @@ -248,7 +206,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch) const char **pathspec = NULL; if (argc) { - pathspec = validate_pathspec(argc, argv, prefix); + pathspec = validate_pathspec(argv, prefix); if (!pathspec) return -1; } @@ -363,6 +321,35 @@ static int add_files(struct dir_struct *dir, int flags) return exit_status; } +static void warn_pathless_add(const char *option_name, const char *short_name) { + /* + * To be consistent with "git add -p" and most Git + * commands, we should default to being tree-wide, but + * this is not the original behavior and can't be + * changed until users trained themselves not to type + * "git add -u" or "git add -A". For now, we warn and + * keep the old behavior. Later, this warning can be + * turned into a die(...), and eventually we may + * reallow the command with a new behavior. + */ + warning(_("The behavior of 'git add %s (or %s)' with no path argument from a\n" + "subdirectory of the tree will change in Git 2.0 and should not be used anymore.\n" + "To add content for the whole tree, run:\n" + "\n" + " git add %s :/\n" + " (or git add %s :/)\n" + "\n" + "To restrict the command to the current directory, run:\n" + "\n" + " git add %s .\n" + " (or git add %s .)\n" + "\n" + "With the current Git version, the command is restricted to the current directory."), + option_name, short_name, + option_name, short_name, + option_name, short_name); +} + int cmd_add(int argc, const char **argv, const char *prefix) { int exit_status = 0; @@ -373,6 +360,8 @@ int cmd_add(int argc, const char **argv, const char *prefix) int add_new_files; int require_pathspec; char *seen = NULL; + const char *option_with_implicit_dot = NULL; + const char *short_option_with_implicit_dot = NULL; git_config(add_config, NULL); @@ -392,8 +381,19 @@ int cmd_add(int argc, const char **argv, const char *prefix) die(_("-A and -u are mutually incompatible")); if (!show_only && ignore_missing) die(_("Option --ignore-missing can only be used together with --dry-run")); - if ((addremove || take_worktree_changes) && !argc) { + if (addremove) { + option_with_implicit_dot = "--all"; + short_option_with_implicit_dot = "-A"; + } + if (take_worktree_changes) { + option_with_implicit_dot = "--update"; + short_option_with_implicit_dot = "-u"; + } + if (option_with_implicit_dot && !argc) { static const char *here[2] = { ".", NULL }; + if (prefix) + warn_pathless_add(option_with_implicit_dot, + short_option_with_implicit_dot); argc = 1; argv = here; } @@ -415,7 +415,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n")); return 0; } - pathspec = validate_pathspec(argc, argv, prefix); + pathspec = validate_pathspec(argv, prefix); if (read_cache() < 0) die(_("index file corrupt")); @@ -448,7 +448,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) path_exclude_check_init(&check, &dir); if (!seen) - seen = find_used_pathspec(pathspec); + seen = find_pathspecs_matching_against_index(pathspec); for (i = 0; pathspec[i]; i++) { if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i])) { diff --git a/builtin/apply.c b/builtin/apply.c index 6c11e8bc73..080ce2ea3e 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -1041,15 +1041,17 @@ static int gitdiff_renamedst(const char *line, struct patch *patch) static int gitdiff_similarity(const char *line, struct patch *patch) { - if ((patch->score = strtoul(line, NULL, 10)) == ULONG_MAX) - patch->score = 0; + unsigned long val = strtoul(line, NULL, 10); + if (val <= 100) + patch->score = val; return 0; } static int gitdiff_dissimilarity(const char *line, struct patch *patch) { - if ((patch->score = strtoul(line, NULL, 10)) == ULONG_MAX) - patch->score = 0; + unsigned long val = strtoul(line, NULL, 10); + if (val <= 100) + patch->score = val; return 0; } @@ -3609,7 +3611,6 @@ static void build_fake_ancestor(struct patch *list, const char *filename) * worth showing the new sha1 prefix, but until then... */ for (patch = list; patch; patch = patch->next) { - const unsigned char *sha1_ptr; unsigned char sha1[20]; struct cache_entry *ce; const char *name; @@ -3617,20 +3618,23 @@ static void build_fake_ancestor(struct patch *list, const char *filename) name = patch->old_name ? patch->old_name : patch->new_name; if (0 < patch->is_new) continue; - else if (get_sha1_blob(patch->old_sha1_prefix, sha1)) - /* git diff has no index line for mode/type changes */ - if (!patch->lines_added && !patch->lines_deleted) { - if (get_current_sha1(patch->old_name, sha1)) - die("mode change for %s, which is not " - "in current HEAD", name); - sha1_ptr = sha1; - } else - die("sha1 information is lacking or useless " - "(%s).", name); - else - sha1_ptr = sha1; - ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0); + if (S_ISGITLINK(patch->old_mode)) { + if (get_sha1_hex(patch->old_sha1_prefix, sha1)) + die("submoule change for %s without full index name", + name); + } else if (!get_sha1_blob(patch->old_sha1_prefix, sha1)) { + ; /* ok */ + } else if (!patch->lines_added && !patch->lines_deleted) { + /* mode-only change: update the current */ + if (get_current_sha1(patch->old_name, sha1)) + die("mode change for %s, which is not " + "in current HEAD", name); + } else + die("sha1 information is lacking or useless " + "(%s).", name); + + ce = make_cache_entry(patch->old_mode, sha1, name, 0, 0); if (!ce) die(_("make_cache_entry failed for path '%s'"), name); if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD)) diff --git a/builtin/blame.c b/builtin/blame.c index b431ba3209..86100e9662 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1420,32 +1420,18 @@ static void get_commit_info(struct commit *commit, { int len; const char *subject, *encoding; - char *reencoded, *message; + char *message; commit_info_init(ret); - /* - * We've operated without save_commit_buffer, so - * we now need to populate them for output. - */ - if (!commit->buffer) { - enum object_type type; - unsigned long size; - commit->buffer = - read_sha1_file(commit->object.sha1, &type, &size); - if (!commit->buffer) - die("Cannot read commit %s", - sha1_to_hex(commit->object.sha1)); - } encoding = get_log_output_encoding(); - reencoded = logmsg_reencode(commit, encoding); - message = reencoded ? reencoded : commit->buffer; + message = logmsg_reencode(commit, encoding); get_ac_line(message, "\nauthor ", &ret->author, &ret->author_mail, &ret->author_time, &ret->author_tz); if (!detailed) { - free(reencoded); + logmsg_free(message, commit); return; } @@ -1459,7 +1445,7 @@ static void get_commit_info(struct commit *commit, else strbuf_addf(&ret->summary, "(%s)", sha1_to_hex(commit->object.sha1)); - free(reencoded); + logmsg_free(message, commit); } /* diff --git a/builtin/branch.c b/builtin/branch.c index 873f624d1c..6371bf96c4 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -466,7 +466,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item, int verbose, int abbrev) { struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT; - const char *sub = " **** invalid ref ****"; + const char *sub = _(" **** invalid ref ****"); struct commit *commit = item->commit; if (commit && !parse_commit(commit)) { @@ -590,7 +590,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru struct commit *filter; filter = lookup_commit_reference_gently(merge_filter_ref, 0); if (!filter) - die("object '%s' does not point to a commit", + die(_("object '%s' does not point to a commit"), sha1_to_hex(merge_filter_ref)); filter->object.flags |= UNINTERESTING; @@ -706,11 +706,11 @@ static int edit_branch_description(const char *branch_name) read_branch_desc(&buf, branch_name); if (!buf.len || buf.buf[buf.len-1] != '\n') strbuf_addch(&buf, '\n'); - strbuf_addf(&buf, - "# Please edit the description for the branch\n" - "# %s\n" - "# Lines starting with '#' will be stripped.\n", - branch_name); + strbuf_commented_addf(&buf, + "Please edit the description for the branch\n" + " %s\n" + "Lines starting with '%c' will be stripped.\n", + branch_name, comment_line_char); fp = fopen(git_path(edit_description), "w"); if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) { strbuf_release(&buf); @@ -825,6 +825,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0) list = 1; + if (with_commit || merge_filter != NO_FILTER) + list = 1; + if (!!delete + !!rename + !!force_create + !!list + !!new_upstream + !!unset_upstream > 1) usage_with_options(builtin_branch_usage, options); @@ -837,9 +840,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix) colopts = 0; } - if (delete) + if (delete) { + if (!argc) + die(_("branch name required")); return delete_branches(argc, argv, delete > 1, kinds, quiet); - else if (list) { + } else if (list) { int ret = print_ref_list(kinds, detached, verbose, abbrev, with_commit, argv); print_columns(&output, colopts, NULL); @@ -850,24 +855,25 @@ int cmd_branch(int argc, const char **argv, const char *prefix) const char *branch_name; struct strbuf branch_ref = STRBUF_INIT; - if (detached) - die("Cannot give description to detached HEAD"); - if (!argc) + if (!argc) { + if (detached) + die(_("Cannot give description to detached HEAD")); branch_name = head; - else if (argc == 1) + } else if (argc == 1) branch_name = argv[0]; else - usage_with_options(builtin_branch_usage, options); + die(_("cannot edit description of more than one branch")); strbuf_addf(&branch_ref, "refs/heads/%s", branch_name); if (!ref_exists(branch_ref.buf)) { strbuf_release(&branch_ref); if (!argc) - return error("No commit on branch '%s' yet.", + return error(_("No commit on branch '%s' yet."), branch_name); else - return error("No such branch '%s'.", branch_name); + return error(_("No branch named '%s'."), + branch_name); } strbuf_release(&branch_ref); @@ -879,7 +885,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) else if (argc == 2) rename_branch(argv[0], argv[1], rename > 1); else - usage_with_options(builtin_branch_usage, options); + die(_("too many branches for a rename operation")); } else if (new_upstream) { struct branch *branch = branch_get(argv[0]); diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c new file mode 100644 index 0000000000..709535ce09 --- /dev/null +++ b/builtin/check-ignore.c @@ -0,0 +1,173 @@ +#include "builtin.h" +#include "cache.h" +#include "dir.h" +#include "quote.h" +#include "pathspec.h" +#include "parse-options.h" + +static int quiet, verbose, stdin_paths; +static const char * const check_ignore_usage[] = { +"git check-ignore [options] pathname...", +"git check-ignore [options] --stdin < <list-of-paths>", +NULL +}; + +static int null_term_line; + +static const struct option check_ignore_options[] = { + OPT__QUIET(&quiet, N_("suppress progress reporting")), + OPT__VERBOSE(&verbose, N_("be verbose")), + OPT_GROUP(""), + OPT_BOOLEAN(0, "stdin", &stdin_paths, + N_("read file names from stdin")), + OPT_BOOLEAN('z', NULL, &null_term_line, + N_("input paths are terminated by a null character")), + OPT_END() +}; + +static void output_exclude(const char *path, struct exclude *exclude) +{ + char *bang = exclude->flags & EXC_FLAG_NEGATIVE ? "!" : ""; + char *slash = exclude->flags & EXC_FLAG_MUSTBEDIR ? "/" : ""; + if (!null_term_line) { + if (!verbose) { + write_name_quoted(path, stdout, '\n'); + } else { + quote_c_style(exclude->el->src, NULL, stdout, 0); + printf(":%d:%s%s%s\t", + exclude->srcpos, + bang, exclude->pattern, slash); + quote_c_style(path, NULL, stdout, 0); + fputc('\n', stdout); + } + } else { + if (!verbose) { + printf("%s%c", path, '\0'); + } else { + printf("%s%c%d%c%s%s%s%c%s%c", + exclude->el->src, '\0', + exclude->srcpos, '\0', + bang, exclude->pattern, slash, '\0', + path, '\0'); + } + } +} + +static int check_ignore(const char *prefix, const char **pathspec) +{ + struct dir_struct dir; + const char *path, *full_path; + char *seen; + int num_ignored = 0, dtype = DT_UNKNOWN, i; + struct path_exclude_check check; + struct exclude *exclude; + + /* read_cache() is only necessary so we can watch out for submodules. */ + if (read_cache() < 0) + die(_("index file corrupt")); + + memset(&dir, 0, sizeof(dir)); + dir.flags |= DIR_COLLECT_IGNORED; + setup_standard_excludes(&dir); + + if (!pathspec || !*pathspec) { + if (!quiet) + fprintf(stderr, "no pathspec given.\n"); + return 0; + } + + path_exclude_check_init(&check, &dir); + /* + * look for pathspecs matching entries in the index, since these + * should not be ignored, in order to be consistent with + * 'git status', 'git add' etc. + */ + seen = find_pathspecs_matching_against_index(pathspec); + for (i = 0; pathspec[i]; i++) { + path = pathspec[i]; + full_path = prefix_path(prefix, prefix + ? strlen(prefix) : 0, path); + full_path = check_path_for_gitlink(full_path); + die_if_path_beyond_symlink(full_path, prefix); + if (!seen[i] && path[0]) { + exclude = last_exclude_matching_path(&check, full_path, + -1, &dtype); + if (exclude) { + if (!quiet) + output_exclude(path, exclude); + num_ignored++; + } + } + } + free(seen); + clear_directory(&dir); + path_exclude_check_clear(&check); + + return num_ignored; +} + +static int check_ignore_stdin_paths(const char *prefix) +{ + struct strbuf buf, nbuf; + char **pathspec = NULL; + size_t nr = 0, alloc = 0; + int line_termination = null_term_line ? 0 : '\n'; + int num_ignored; + + strbuf_init(&buf, 0); + strbuf_init(&nbuf, 0); + while (strbuf_getline(&buf, stdin, line_termination) != EOF) { + if (line_termination && buf.buf[0] == '"') { + strbuf_reset(&nbuf); + if (unquote_c_style(&nbuf, buf.buf, NULL)) + die("line is badly quoted"); + strbuf_swap(&buf, &nbuf); + } + ALLOC_GROW(pathspec, nr + 1, alloc); + pathspec[nr] = xcalloc(strlen(buf.buf) + 1, sizeof(*buf.buf)); + strcpy(pathspec[nr++], buf.buf); + } + ALLOC_GROW(pathspec, nr + 1, alloc); + pathspec[nr] = NULL; + num_ignored = check_ignore(prefix, (const char **)pathspec); + maybe_flush_or_die(stdout, "attribute to stdout"); + strbuf_release(&buf); + strbuf_release(&nbuf); + free(pathspec); + return num_ignored; +} + +int cmd_check_ignore(int argc, const char **argv, const char *prefix) +{ + int num_ignored; + + git_config(git_default_config, NULL); + + argc = parse_options(argc, argv, prefix, check_ignore_options, + check_ignore_usage, 0); + + if (stdin_paths) { + if (argc > 0) + die(_("cannot specify pathnames with --stdin")); + } else { + if (null_term_line) + die(_("-z only makes sense with --stdin")); + if (argc == 0) + die(_("no path specified")); + } + if (quiet) { + if (argc > 1) + die(_("--quiet is only valid with a single pathname")); + if (verbose) + die(_("cannot have both --quiet and --verbose")); + } + + if (stdin_paths) { + num_ignored = check_ignore_stdin_paths(prefix); + } else { + num_ignored = check_ignore(prefix, argv); + maybe_flush_or_die(stdout, "ignore to stdout"); + } + + return !num_ignored; +} diff --git a/builtin/clean.c b/builtin/clean.c index f4b760bf3d..04e396b17a 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -153,6 +153,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) static const char **pathspec; struct strbuf buf = STRBUF_INIT; struct string_list exclude_list = STRING_LIST_INIT_NODUP; + struct exclude_list *el; const char *qname; char *seen = NULL; struct option options[] = { @@ -205,9 +206,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix) if (!ignored) setup_standard_excludes(&dir); + el = add_exclude_list(&dir, EXC_CMDL, "--exclude option"); for (i = 0; i < exclude_list.nr; i++) - add_exclude(exclude_list.items[i].string, "", 0, - &dir.exclude_list[EXC_CMDL]); + add_exclude(exclude_list.items[i].string, "", 0, el, -(i+1)); pathspec = get_pathspec(prefix, argv); diff --git a/builtin/clone.c b/builtin/clone.c index 36ec99db3f..e0aaf13583 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -767,8 +767,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) atexit(remove_junk); sigchain_push_common(remove_junk_on_signal); - setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1); - if (safe_create_leading_directories_const(git_dir) < 0) die(_("could not create leading directories of '%s'"), git_dir); @@ -787,13 +785,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) init_db(option_template, INIT_DB_QUIET); write_config(&option_config); - /* - * At this point, the config exists, so we do not need the - * environment variable. We actually need to unset it, too, to - * re-enable parsing of the global configs. - */ - unsetenv(CONFIG_ENVIRONMENT); - git_config(git_default_config, NULL); if (option_bare) { diff --git a/builtin/commit.c b/builtin/commit.c index 7c2a3d48b4..1a0e5f14a3 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -733,15 +733,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix, if (cleanup_mode == CLEANUP_ALL) status_printf(s, GIT_COLOR_NORMAL, _("Please enter the commit message for your changes." - " Lines starting\nwith '#' will be ignored, and an empty" - " message aborts the commit.\n")); + " Lines starting\nwith '%c' will be ignored, and an empty" + " message aborts the commit.\n"), comment_line_char); else /* CLEANUP_SPACE, that is. */ status_printf(s, GIT_COLOR_NORMAL, _("Please enter the commit message for your changes." - " Lines starting\n" - "with '#' will be kept; you may remove them" - " yourself if you want to.\n" - "An empty message aborts the commit.\n")); + " Lines starting\n" + "with '%c' will be kept; you may remove them" + " yourself if you want to.\n" + "An empty message aborts the commit.\n"), comment_line_char); if (only_include_assumed) status_printf_ln(s, GIT_COLOR_NORMAL, "%s", only_include_assumed); @@ -946,24 +946,14 @@ static void handle_untracked_files_arg(struct wt_status *s) static const char *read_commit_message(const char *name) { - const char *out_enc, *out; + const char *out_enc; struct commit *commit; commit = lookup_commit_reference_by_name(name); if (!commit) die(_("could not lookup commit %s"), name); out_enc = get_commit_output_encoding(); - out = logmsg_reencode(commit, out_enc); - - /* - * If we failed to reencode the buffer, just copy it - * byte for byte so the user can try to fix it up. - * This also handles the case where input and output - * encodings are identical. - */ - if (out == NULL) - out = xstrdup(commit->buffer); - return out; + return logmsg_reencode(commit, out_enc); } static int parse_and_validate_options(int argc, const char *argv[], @@ -1329,8 +1319,6 @@ static int git_commit_config(const char *k, const char *v, void *cb) return git_status_config(k, v, s); } -static const char post_rewrite_hook[] = "hooks/post-rewrite"; - static int run_rewrite_hook(const unsigned char *oldsha1, const unsigned char *newsha1) { @@ -1341,10 +1329,10 @@ static int run_rewrite_hook(const unsigned char *oldsha1, int code; size_t n; - if (access(git_path(post_rewrite_hook), X_OK) < 0) + argv[0] = find_hook("post-rewrite"); + if (!argv[0]) return 0; - argv[0] = git_path(post_rewrite_hook); argv[1] = "amend"; argv[2] = NULL; diff --git a/builtin/fetch.c b/builtin/fetch.c index 4b5a89839b..4b6b1dfe66 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -32,7 +32,7 @@ enum { static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity; static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT; -static int tags = TAGS_DEFAULT; +static int tags = TAGS_DEFAULT, unshallow; static const char *depth; static const char *upload_pack; static struct strbuf default_rla = STRBUF_INIT; @@ -82,6 +82,9 @@ static struct option builtin_fetch_options[] = { OPT_BOOL(0, "progress", &progress, N_("force progress reporting")), OPT_STRING(0, "depth", &depth, N_("depth"), N_("deepen history of shallow clone")), + { OPTION_SET_INT, 0, "unshallow", &unshallow, NULL, + N_("convert to a complete repository"), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 }, { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"), N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN }, { OPTION_STRING, 0, "recurse-submodules-default", @@ -959,6 +962,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) struct string_list list = STRING_LIST_INIT_NODUP; struct remote *remote; int result = 0; + static const char *argv_gc_auto[] = { + "gc", "--auto", NULL, + }; packet_trace_identity("fetch"); @@ -970,6 +976,18 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, builtin_fetch_options, builtin_fetch_usage, 0); + if (unshallow) { + if (depth) + die(_("--depth and --unshallow cannot be used together")); + else if (!is_repository_shallow()) + die(_("--unshallow on a complete repository does not make sense")); + else { + static char inf_depth[12]; + sprintf(inf_depth, "%d", INFINITE_DEPTH); + depth = inf_depth; + } + } + if (recurse_submodules != RECURSE_SUBMODULES_OFF) { if (recurse_submodules_default) { int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default); @@ -1026,5 +1044,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) list.strdup_strings = 1; string_list_clear(&list, 0); + run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); + return result; } diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index d9af43c257..b49612f0ce 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -470,7 +470,7 @@ static void fmt_tag_signature(struct strbuf *tagbuf, strbuf_complete_line(tagbuf); if (sig->len) { strbuf_addch(tagbuf, '\n'); - strbuf_add_lines(tagbuf, "# ", sig->buf, sig->len); + strbuf_add_commented_lines(tagbuf, sig->buf, sig->len); } } diff --git a/builtin/grep.c b/builtin/grep.c index 0e1b6c860e..8025964987 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -823,6 +823,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) struct object *object = parse_object(sha1); if (!object) die(_("bad object %s"), arg); + if (!seen_dashdash) + verify_non_filename(prefix, arg); add_object_array(object, arg, &list); continue; } diff --git a/builtin/help.c b/builtin/help.c index bd86253d83..d1d71816a9 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -6,7 +6,6 @@ #include "cache.h" #include "builtin.h" #include "exec_cmd.h" -#include "common-cmds.h" #include "parse-options.h" #include "run-command.h" #include "column.h" @@ -237,21 +236,21 @@ static int add_man_viewer_cmd(const char *name, static int add_man_viewer_info(const char *var, const char *value) { - const char *name = var + 4; - const char *subkey = strrchr(name, '.'); + const char *name, *subkey; + int namelen; - if (!subkey) + if (parse_config_key(var, "man", &name, &namelen, &subkey) < 0 || !name) return 0; - if (!strcmp(subkey, ".path")) { + if (!strcmp(subkey, "path")) { if (!value) return config_error_nonbool(var); - return add_man_viewer_path(name, subkey - name, value); + return add_man_viewer_path(name, namelen, value); } - if (!strcmp(subkey, ".cmd")) { + if (!strcmp(subkey, "cmd")) { if (!value) return config_error_nonbool(var); - return add_man_viewer_cmd(name, subkey - name, value); + return add_man_viewer_cmd(name, namelen, value); } return 0; @@ -287,23 +286,6 @@ static int git_help_config(const char *var, const char *value, void *cb) static struct cmdnames main_cmds, other_cmds; -void list_common_cmds_help(void) -{ - int i, longest = 0; - - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { - if (longest < strlen(common_cmds[i].name)) - longest = strlen(common_cmds[i].name); - } - - puts(_("The most commonly used git commands are:")); - for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { - printf(" %s ", common_cmds[i].name); - mput_char(' ', longest - strlen(common_cmds[i].name)); - puts(_(common_cmds[i].help)); - } -} - static int is_git_command(const char *s) { return is_in_cmdlist(&main_cmds, s) || diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 373c573449..175e6e3e72 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -35,6 +35,7 @@ static int error_unmatch; static char *ps_matched; static const char *with_tree; static int exc_given; +static int exclude_args; static const char *tag_cached = ""; static const char *tag_unmerged = ""; @@ -420,10 +421,10 @@ static int option_parse_z(const struct option *opt, static int option_parse_exclude(const struct option *opt, const char *arg, int unset) { - struct exclude_list *list = opt->value; + struct string_list *exclude_list = opt->value; exc_given = 1; - add_exclude(arg, "", 0, list); + string_list_append(exclude_list, arg); return 0; } @@ -452,9 +453,11 @@ static int option_parse_exclude_standard(const struct option *opt, int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) { - int require_work_tree = 0, show_tag = 0; + int require_work_tree = 0, show_tag = 0, i; const char *max_prefix; struct dir_struct dir; + struct exclude_list *el; + struct string_list exclude_list = STRING_LIST_INIT_NODUP; struct option builtin_ls_files_options[] = { { OPTION_CALLBACK, 'z', NULL, NULL, NULL, N_("paths are separated with NUL character"), @@ -488,7 +491,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) N_("show unmerged files in the output")), OPT_BOOLEAN(0, "resolve-undo", &show_resolve_undo, N_("show resolve-undo information")), - { OPTION_CALLBACK, 'x', "exclude", &dir.exclude_list[EXC_CMDL], N_("pattern"), + { OPTION_CALLBACK, 'x', "exclude", &exclude_list, N_("pattern"), N_("skip files matching pattern"), 0, option_parse_exclude }, { OPTION_CALLBACK, 'X', "exclude-from", &dir, N_("file"), @@ -525,6 +528,10 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) argc = parse_options(argc, argv, prefix, builtin_ls_files_options, ls_files_usage, 0); + el = add_exclude_list(&dir, EXC_CMDL, "--exclude option"); + for (i = 0; i < exclude_list.nr; i++) { + add_exclude(exclude_list.items[i].string, "", 0, el, --exclude_args); + } if (show_tag || show_valid_bit) { tag_cached = "H "; tag_unmerged = "M "; diff --git a/builtin/merge.c b/builtin/merge.c index 9307e9c726..7c8922c8b0 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -788,17 +788,16 @@ static const char merge_editor_comment[] = N_("Please enter a commit message to explain why this merge is necessary,\n" "especially if it merges an updated upstream into a topic branch.\n" "\n" - "Lines starting with '#' will be ignored, and an empty message aborts\n" + "Lines starting with '%c' will be ignored, and an empty message aborts\n" "the commit.\n"); static void prepare_to_commit(struct commit_list *remoteheads) { struct strbuf msg = STRBUF_INIT; - const char *comment = _(merge_editor_comment); strbuf_addbuf(&msg, &merge_msg); strbuf_addch(&msg, '\n'); if (0 < option_edit) - strbuf_add_lines(&msg, "# ", comment, strlen(comment)); + strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char); write_merge_msg(&msg); if (run_hook(get_index_file(), "prepare-commit-msg", git_path("MERGE_MSG"), "merge", NULL, NULL)) diff --git a/builtin/notes.c b/builtin/notes.c index 453457adb9..57748a6fb6 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -92,10 +92,7 @@ static const char * const git_notes_get_ref_usage[] = { }; static const char note_template[] = - "\n" - "#\n" - "# Write/edit the notes for the following object:\n" - "#\n"; + "\nWrite/edit the notes for the following object:\n"; struct msg_arg { int given; @@ -129,7 +126,7 @@ static void write_commented_object(int fd, const unsigned char *object) {"show", "--stat", "--no-notes", sha1_to_hex(object), NULL}; struct child_process show; struct strbuf buf = STRBUF_INIT; - FILE *show_out; + struct strbuf cbuf = STRBUF_INIT; /* Invoke "git show --stat --no-notes $object" */ memset(&show, 0, sizeof(show)); @@ -142,21 +139,14 @@ static void write_commented_object(int fd, const unsigned char *object) die(_("unable to start 'show' for object '%s'"), sha1_to_hex(object)); - /* Open the output as FILE* so strbuf_getline() can be used. */ - show_out = xfdopen(show.out, "r"); - if (show_out == NULL) - die_errno(_("can't fdopen 'show' output fd")); + if (strbuf_read(&buf, show.out, 0) < 0) + die_errno(_("could not read 'show' output")); + strbuf_add_commented_lines(&cbuf, buf.buf, buf.len); + write_or_die(fd, cbuf.buf, cbuf.len); - /* Prepend "# " to each output line and write result to 'fd' */ - while (strbuf_getline(&buf, show_out, '\n') != EOF) { - write_or_die(fd, "# ", 2); - write_or_die(fd, buf.buf, buf.len); - write_or_die(fd, "\n", 1); - } + strbuf_release(&cbuf); strbuf_release(&buf); - if (fclose(show_out)) - die_errno(_("failed to close pipe to 'show' for object '%s'"), - sha1_to_hex(object)); + if (finish_command(&show)) die(_("failed to finish 'show' for object '%s'"), sha1_to_hex(object)); @@ -170,6 +160,7 @@ static void create_note(const unsigned char *object, struct msg_arg *msg, if (msg->use_editor || !msg->given) { int fd; + struct strbuf buf = STRBUF_INIT; /* write the template message before editing: */ path = git_pathdup("NOTES_EDITMSG"); @@ -181,11 +172,16 @@ static void create_note(const unsigned char *object, struct msg_arg *msg, write_or_die(fd, msg->buf.buf, msg->buf.len); else if (prev && !append_only) write_note_data(fd, prev); - write_or_die(fd, note_template, strlen(note_template)); + + strbuf_addch(&buf, '\n'); + strbuf_add_commented_lines(&buf, note_template, strlen(note_template)); + strbuf_addch(&buf, '\n'); + write_or_die(fd, buf.buf, buf.len); write_commented_object(fd, object); close(fd); + strbuf_release(&buf); strbuf_reset(&(msg->buf)); if (launch_editor(path, &(msg->buf), NULL)) { diff --git a/builtin/push.c b/builtin/push.c index 8491e431e4..42b129d36c 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -220,9 +220,20 @@ static const char message_advice_checkout_pull_push[] = "(e.g. 'git pull') before pushing again.\n" "See the 'Note about fast-forwards' in 'git push --help' for details."); +static const char message_advice_ref_fetch_first[] = + N_("Updates were rejected because the remote contains work that you do\n" + "not have locally. This is usually caused by another repository pushing\n" + "to the same ref. You may want to first merge the remote changes (e.g.,\n" + "'git pull') before pushing again.\n" + "See the 'Note about fast-forwards' in 'git push --help' for details."); + static const char message_advice_ref_already_exists[] = - N_("Updates were rejected because the destination reference already exists\n" - "in the remote."); + N_("Updates were rejected because the tag already exists in the remote."); + +static const char message_advice_ref_needs_force[] = + N_("You cannot update a remote ref that points at a non-commit object,\n" + "or update a remote ref to make it point at a non-commit object,\n" + "without using the '--force' option.\n"); static void advise_pull_before_push(void) { @@ -252,6 +263,20 @@ static void advise_ref_already_exists(void) advise(_(message_advice_ref_already_exists)); } +static void advise_ref_fetch_first(void) +{ + if (!advice_push_fetch_first || !advice_push_update_rejected) + return; + advise(_(message_advice_ref_fetch_first)); +} + +static void advise_ref_needs_force(void) +{ + if (!advice_push_needs_force || !advice_push_update_rejected) + return; + advise(_(message_advice_ref_needs_force)); +} + static int push_with_options(struct transport *transport, int flags) { int err; @@ -285,6 +310,10 @@ static int push_with_options(struct transport *transport, int flags) advise_checkout_pull_push(); } else if (reject_reasons & REJECT_ALREADY_EXISTS) { advise_ref_already_exists(); + } else if (reject_reasons & REJECT_FETCH_FIRST) { + advise_ref_fetch_first(); + } else if (reject_reasons & REJECT_NEEDS_FORCE) { + advise_ref_needs_force(); } return 1; @@ -407,6 +436,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "progress", &progress, N_("force progress reporting")), OPT_BIT(0, "prune", &flags, N_("prune locally removed refs"), TRANSPORT_PUSH_PRUNE), + OPT_BIT(0, "no-verify", &flags, N_("bypass pre-push hook"), TRANSPORT_PUSH_NO_HOOK), OPT_END() }; diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index ff781febca..e8878de45c 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -182,9 +182,6 @@ struct command { char ref_name[FLEX_ARRAY]; /* more */ }; -static const char pre_receive_hook[] = "hooks/pre-receive"; -static const char post_receive_hook[] = "hooks/post-receive"; - static void rp_error(const char *err, ...) __attribute__((format (printf, 1, 2))); static void rp_warning(const char *err, ...) __attribute__((format (printf, 1, 2))); @@ -242,10 +239,10 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta const char *argv[2]; int code; - if (access(hook_name, X_OK) < 0) + argv[0] = find_hook(hook_name); + if (!argv[0]) return 0; - argv[0] = hook_name; argv[1] = NULL; memset(&proc, 0, sizeof(proc)); @@ -331,15 +328,14 @@ static int run_receive_hook(struct command *commands, const char *hook_name, static int run_update_hook(struct command *cmd) { - static const char update_hook[] = "hooks/update"; const char *argv[5]; struct child_process proc; int code; - if (access(update_hook, X_OK) < 0) + argv[0] = find_hook("update"); + if (!argv[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); @@ -532,24 +528,25 @@ static const char *update(struct command *cmd) } } -static char update_post_hook[] = "hooks/post-update"; - static void run_update_post_hook(struct command *commands) { struct command *cmd; int argc; const char **argv; struct child_process proc; + char *hook; + hook = find_hook("post-update"); for (argc = 0, cmd = commands; cmd; cmd = cmd->next) { if (cmd->error_string || cmd->did_not_exist) continue; argc++; } - if (!argc || access(update_post_hook, X_OK) < 0) + if (!argc || !hook) return; + argv = xmalloc(sizeof(*argv) * (2 + argc)); - argv[0] = update_post_hook; + argv[0] = hook; for (argc = 1, cmd = commands; cmd; cmd = cmd->next) { char *p; @@ -704,7 +701,7 @@ static void execute_commands(struct command *commands, const char *unpacker_erro 0, &cmd)) set_connectivity_errors(commands); - if (run_receive_hook(commands, pre_receive_hook, 0)) { + if (run_receive_hook(commands, "pre-receive", 0)) { for (cmd = commands; cmd; cmd = cmd->next) { if (!cmd->error_string) cmd->error_string = "pre-receive hook declined"; @@ -994,7 +991,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) unlink_or_warn(pack_lockfile); if (report_status) report(commands, unpack_status); - run_receive_hook(commands, post_receive_hook, 1); + run_receive_hook(commands, "post-receive", 1); run_update_post_hook(commands); if (auto_gc) { const char *argv_gc_auto[] = { diff --git a/builtin/reflog.c b/builtin/reflog.c index b3c9e27bde..1fedf66329 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -510,26 +510,27 @@ static int parse_expire_cfg_value(const char *var, const char *value, unsigned l static int reflog_expire_config(const char *var, const char *value, void *cb) { - const char *lastdot = strrchr(var, '.'); + const char *pattern, *key; + int pattern_len; unsigned long expire; int slot; struct reflog_expire_cfg *ent; - if (!lastdot || prefixcmp(var, "gc.")) + if (parse_config_key(var, "gc", &pattern, &pattern_len, &key) < 0) return git_default_config(var, value, cb); - if (!strcmp(lastdot, ".reflogexpire")) { + if (!strcmp(key, "reflogexpire")) { slot = EXPIRE_TOTAL; if (parse_expire_cfg_value(var, value, &expire)) return -1; - } else if (!strcmp(lastdot, ".reflogexpireunreachable")) { + } else if (!strcmp(key, "reflogexpireunreachable")) { slot = EXPIRE_UNREACH; if (parse_expire_cfg_value(var, value, &expire)) return -1; } else return git_default_config(var, value, cb); - if (lastdot == var + 2) { + if (!pattern) { switch (slot) { case EXPIRE_TOTAL: default_reflog_expire = expire; @@ -541,7 +542,7 @@ static int reflog_expire_config(const char *var, const char *value, void *cb) return 0; } - ent = find_cfg_ent(var + 3, lastdot - (var+3)); + ent = find_cfg_ent(pattern, pattern_len); if (!ent) return -1; switch (slot) { diff --git a/builtin/send-pack.c b/builtin/send-pack.c index f849e0a4a0..57a46b2654 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -44,6 +44,16 @@ static void print_helper_status(struct ref *ref) msg = "non-fast forward"; break; + case REF_STATUS_REJECT_FETCH_FIRST: + res = "error"; + msg = "fetch first"; + break; + + case REF_STATUS_REJECT_NEEDS_FORCE: + res = "error"; + msg = "needs force"; + break; + case REF_STATUS_REJECT_ALREADY_EXISTS: res = "error"; msg = "already exists"; diff --git a/builtin/stripspace.c b/builtin/stripspace.c index f16986c0ae..e981dfb9f0 100644 --- a/builtin/stripspace.c +++ b/builtin/stripspace.c @@ -30,7 +30,8 @@ static size_t cleanup(char *line, size_t len) * * If last line does not have a newline at the end, one is added. * - * Enable skip_comments to skip every line starting with "#". + * Enable skip_comments to skip every line starting with comment + * character. */ void stripspace(struct strbuf *sb, int skip_comments) { @@ -45,7 +46,7 @@ void stripspace(struct strbuf *sb, int skip_comments) eol = memchr(sb->buf + i, '\n', sb->len - i); len = eol ? eol - (sb->buf + i) + 1 : sb->len - i; - if (skip_comments && len && sb->buf[i] == '#') { + if (skip_comments && len && sb->buf[i] == comment_line_char) { newlen = 0; continue; } @@ -66,21 +67,53 @@ void stripspace(struct strbuf *sb, int skip_comments) strbuf_setlen(sb, j); } +static void comment_lines(struct strbuf *buf) +{ + char *msg; + size_t len; + + msg = strbuf_detach(buf, &len); + strbuf_add_commented_lines(buf, msg, len); + free(msg); +} + +static const char *usage_msg = "\n" +" git stripspace [-s | --strip-comments] < input\n" +" git stripspace [-c | --comment-lines] < input"; + int cmd_stripspace(int argc, const char **argv, const char *prefix) { struct strbuf buf = STRBUF_INIT; int strip_comments = 0; + enum { INVAL = 0, STRIP_SPACE = 1, COMMENT_LINES = 2 } mode = STRIP_SPACE; + + if (argc == 2) { + if (!strcmp(argv[1], "-s") || + !strcmp(argv[1], "--strip-comments")) { + strip_comments = 1; + } else if (!strcmp(argv[1], "-c") || + !strcmp(argv[1], "--comment-lines")) { + mode = COMMENT_LINES; + } else { + mode = INVAL; + } + } else if (argc > 1) { + mode = INVAL; + } + + if (mode == INVAL) + usage(usage_msg); - if (argc == 2 && (!strcmp(argv[1], "-s") || - !strcmp(argv[1], "--strip-comments"))) - strip_comments = 1; - else if (argc > 1) - usage("git stripspace [-s | --strip-comments] < input"); + if (strip_comments || mode == COMMENT_LINES) + git_config(git_default_config, NULL); if (strbuf_read(&buf, 0, 1024) < 0) die_errno("could not read the input"); - stripspace(&buf, strip_comments); + if (mode == STRIP_SPACE) + stripspace(&buf, strip_comments); + else + comment_lines(&buf); write_or_die(1, buf.buf, buf.len); strbuf_release(&buf); diff --git a/builtin/tag.c b/builtin/tag.c index 9c3e0673d5..f8266888cc 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -246,19 +246,13 @@ static int do_sign(struct strbuf *buffer) } static const char tag_template[] = - N_("\n" - "#\n" - "# Write a tag message\n" - "# Lines starting with '#' will be ignored.\n" - "#\n"); + N_("\nWrite a tag message\n" + "Lines starting with '%c' will be ignored.\n"); static const char tag_template_nocleanup[] = - N_("\n" - "#\n" - "# Write a tag message\n" - "# Lines starting with '#' will be kept; you may remove them" - " yourself if you want to.\n" - "#\n"); + N_("\nWrite a tag message\n" + "Lines starting with '%c' will be kept; you may remove them" + " yourself if you want to.\n"); static int git_tag_config(const char *var, const char *value, void *cb) { @@ -346,14 +340,18 @@ static void create_tag(const unsigned char *object, const char *tag, if (fd < 0) die_errno(_("could not create file '%s'"), path); - if (!is_null_sha1(prev)) + if (!is_null_sha1(prev)) { write_tag_body(fd, prev); - else if (opt->cleanup_mode == CLEANUP_ALL) - write_or_die(fd, _(tag_template), - strlen(_(tag_template))); - else - write_or_die(fd, _(tag_template_nocleanup), - strlen(_(tag_template_nocleanup))); + } else { + struct strbuf buf = STRBUF_INIT; + strbuf_addch(&buf, '\n'); + if (opt->cleanup_mode == CLEANUP_ALL) + strbuf_commented_addf(&buf, _(tag_template), comment_line_char); + else + strbuf_commented_addf(&buf, _(tag_template_nocleanup), comment_line_char); + write_or_die(fd, buf.buf, buf.len); + strbuf_release(&buf); + } close(fd); if (launch_editor(path, buf, NULL)) { @@ -536,6 +536,7 @@ extern int delete_ref(const char *, const unsigned char *sha1, int delopt); /* Environment bits from configuration mechanism */ extern int trust_executable_bit; extern int trust_ctime; +extern int check_stat; extern int quote_path_fully; extern int has_symlinks; extern int minimum_abbrev, default_abbrev; @@ -562,6 +563,12 @@ extern int core_preload_index; extern int core_apply_sparse_checkout; extern int precomposed_unicode; +/* + * The character that begins a commented line in user-editable file + * that is subject to stripspace. + */ +extern char comment_line_char; + enum branch_track { BRANCH_TRACK_UNSPECIFIED = -1, BRANCH_TRACK_NEVER = 0, @@ -1008,11 +1015,8 @@ struct ref { char *symref; unsigned int force:1, - requires_force:1, + forced_update:1, merge:1, - nonfastforward:1, - not_forwardable:1, - update:1, deletion:1; enum { REF_STATUS_NONE = 0, @@ -1020,6 +1024,8 @@ struct ref { REF_STATUS_REJECT_NONFASTFORWARD, REF_STATUS_REJECT_ALREADY_EXISTS, REF_STATUS_REJECT_NODELETE, + REF_STATUS_REJECT_FETCH_FIRST, + REF_STATUS_REJECT_NEEDS_FORCE, REF_STATUS_UPTODATE, REF_STATUS_REMOTE_REJECT, REF_STATUS_EXPECTING_REPORT @@ -1148,7 +1154,7 @@ extern int check_repository_format_version(const char *var, const char *value, v extern int git_env_bool(const char *, int); extern int git_config_system(void); extern int config_error_nonbool(const char *); -#ifdef __GNUC__ +#if defined(__GNUC__) && ! defined(__clang__) #define config_error_nonbool(s) (config_error_nonbool(s), -1) #endif extern const char *get_log_output_encoding(void); @@ -1164,6 +1170,21 @@ struct config_include_data { #define CONFIG_INCLUDE_INIT { 0 } extern int git_config_include(const char *name, const char *value, void *data); +/* + * Match and parse a config key of the form: + * + * section.(subsection.)?key + * + * (i.e., what gets handed to a config_fn_t). The caller provides the section; + * we return -1 if it does not match, 0 otherwise. The subsection and key + * out-parameters are filled by the function (and subsection is NULL if it is + * missing). + */ +extern int parse_config_key(const char *var, + const char *section, + const char **subsection, int *subsection_len, + const char **key); + extern int committer_ident_sufficiently_given(void); extern int author_ident_sufficiently_given(void); diff --git a/combine-diff.c b/combine-diff.c index bb1cc96c4e..7f6187f9cd 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -982,14 +982,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, free(sline); } -#define COLONS "::::::::::::::::::::::::::::::::" - static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev) { struct diff_options *opt = &rev->diffopt; - int i, offset; - const char *prefix; - int line_termination, inter_name_termination; + int line_termination, inter_name_termination, i; line_termination = opt->line_termination; inter_name_termination = '\t'; @@ -1000,17 +996,14 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re show_log(rev); if (opt->output_format & DIFF_FORMAT_RAW) { - offset = strlen(COLONS) - num_parent; - if (offset < 0) - offset = 0; - prefix = COLONS + offset; + /* As many colons as there are parents */ + for (i = 0; i < num_parent; i++) + putchar(':'); /* Show the modes */ - for (i = 0; i < num_parent; i++) { - printf("%s%06o", prefix, p->parent[i].mode); - prefix = " "; - } - printf("%s%06o", prefix, p->mode); + for (i = 0; i < num_parent; i++) + printf("%06o ", p->parent[i].mode); + printf("%06o", p->mode); /* Show sha1's */ for (i = 0; i < num_parent; i++) diff --git a/command-list.txt b/command-list.txt index 7e8cfec29d..bf83303c48 100644 --- a/command-list.txt +++ b/command-list.txt @@ -12,6 +12,7 @@ git-branch mainporcelain common git-bundle mainporcelain git-cat-file plumbinginterrogators git-check-attr purehelpers +git-check-ignore purehelpers git-checkout mainporcelain common git-checkout-index plumbingmanipulators git-check-ref-format purehelpers @@ -101,6 +101,7 @@ extern int has_non_ascii(const char *text); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ extern char *logmsg_reencode(const struct commit *commit, const char *output_encoding); +extern void logmsg_free(char *msg, const struct commit *commit); extern void get_commit_format(const char *arg, struct rev_info *); extern const char *format_subject(struct strbuf *sb, const char *msg, const char *line_separator); @@ -163,6 +164,9 @@ extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *r extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos, int cleanup); extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); +/* largest postive number a signed 32-bit integer can contain */ +#define INFINITE_DEPTH 0x7fffffff + extern int register_shallow(const unsigned char *sha1); extern int unregister_shallow(const unsigned char *sha1); extern int for_each_commit_graft(each_commit_graft_fn, void *); @@ -566,6 +566,12 @@ static int git_default_core_config(const char *var, const char *value) trust_ctime = git_config_bool(var, value); return 0; } + if (!strcmp(var, "core.statinfo")) { + if (!strcasecmp(value, "default")) + check_stat = 1; + else if (!strcasecmp(value, "minimal")) + check_stat = 0; + } if (!strcmp(var, "core.quotepath")) { quote_path_fully = git_config_bool(var, value); @@ -717,6 +723,14 @@ static int git_default_core_config(const char *var, const char *value) if (!strcmp(var, "core.editor")) return git_config_string(&editor_program, var, value); + if (!strcmp(var, "core.commentchar")) { + const char *comment; + int ret = git_config_string(&comment, var, value); + if (!ret) + comment_line_char = comment[0]; + return ret; + } + if (!strcmp(var, "core.askpass")) return git_config_string(&askpass_program, var, value); @@ -1667,3 +1681,36 @@ int config_error_nonbool(const char *var) { return error("Missing value for '%s'", var); } + +int parse_config_key(const char *var, + const char *section, + const char **subsection, int *subsection_len, + const char **key) +{ + int section_len = strlen(section); + const char *dot; + + /* Does it start with "section." ? */ + if (prefixcmp(var, section) || var[section_len] != '.') + return -1; + + /* + * Find the key; we don't know yet if we have a subsection, but we must + * parse backwards from the end, since the subsection may have dots in + * it, too. + */ + dot = strrchr(var, '.'); + *key = dot + 1; + + /* Did we have a subsection at all? */ + if (dot == var + section_len) { + *subsection = NULL; + *subsection_len = 0; + } + else { + *subsection = var + section_len + 1; + *subsection_len = dot - *subsection; + } + + return 0; +} diff --git a/config.mak.in b/config.mak.in index e8a9bb4682..d7c49cd8f3 100644 --- a/config.mak.in +++ b/config.mak.in @@ -19,6 +19,7 @@ template_dir = @datadir@/git-core/templates sysconfdir = @sysconfdir@ mandir = @mandir@ +htmldir = @htmldir@ srcdir = @srcdir@ VPATH = @srcdir@ diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 14dd5e7ca2..c8452fb163 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -13,6 +13,7 @@ # *) .git/remotes file names # *) git 'subcommands' # *) tree paths within 'ref:path/to/file' expressions +# *) file paths within current working directory and index # *) common --long-options # # To use these routines: @@ -233,6 +234,118 @@ __gitcomp_nl () COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}")) } +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + COMPREPLY=($(compgen -P "${2-}" -W "$1" -- "${3-$cur}")) + + # Tell Bash that compspec generates filenames. + compopt -o filenames 2>/dev/null +} + +__git_index_file_list_filter_compat () +{ + local path + + while read -r path; do + case "$path" in + ?*/*) echo "${path%%/*}/" ;; + *) echo "$path" ;; + esac + done +} + +__git_index_file_list_filter_bash () +{ + local path + + while read -r path; do + case "$path" in + ?*/*) + # XXX if we append a slash to directory names when using + # `compopt -o filenames`, Bash will append another slash. + # This is pretty stupid, and this the reason why we have to + # define a compatible version for this function. + echo "${path%%/*}" ;; + *) + echo "$path" ;; + esac + done +} + +# Process path list returned by "ls-files" and "diff-index --name-only" +# commands, in order to list only file names relative to a specified +# directory, and append a slash to directory names. +__git_index_file_list_filter () +{ + # Default to Bash >= 4.x + __git_index_file_list_filter_bash +} + +# Execute git ls-files, returning paths relative to the directory +# specified in the first argument, and using the options specified in +# the second argument. +__git_ls_files_helper () +{ + # NOTE: $2 is not quoted in order to support multiple options + cd "$1" && git ls-files --exclude-standard $2 +} 2>/dev/null + + +# Execute git diff-index, returning paths relative to the directory +# specified in the first argument, and using the tree object id +# specified in the second argument. +__git_diff_index_helper () +{ + cd "$1" && git diff-index --name-only --relative "$2" +} 2>/dev/null + +# __git_index_files accepts 1 or 2 arguments: +# 1: Options to pass to ls-files (required). +# Supported options are --cached, --modified, --deleted, --others, +# and --directory. +# 2: A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +__git_index_files () +{ + local dir="$(__gitdir)" root="${2-.}" + + if [ -d "$dir" ]; then + __git_ls_files_helper "$root" "$1" | __git_index_file_list_filter | + sort | uniq + fi +} + +# __git_diff_index_files accepts 1 or 2 arguments: +# 1) The id of a tree object. +# 2) A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +__git_diff_index_files () +{ + local dir="$(__gitdir)" root="${2-.}" + + if [ -d "$dir" ]; then + __git_diff_index_helper "$root" "$1" | __git_index_file_list_filter | + sort | uniq + fi +} + __git_heads () { local dir="$(__gitdir)" @@ -430,6 +543,46 @@ __git_complete_revlist_file () } +# __git_complete_index_file requires 1 argument: the options to pass to +# ls-file +__git_complete_index_file () +{ + local pfx cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + + __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" + ;; + *) + __gitcomp_file "$(__git_index_files "$1")" "" "$cur_" + ;; + esac +} + +# __git_complete_diff_index_file requires 1 argument: the id of a tree +# object +__git_complete_diff_index_file () +{ + local pfx cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + + __gitcomp_file "$(__git_diff_index_files "$1" "$pfx")" "$pfx" "$cur_" + ;; + *) + __gitcomp_file "$(__git_diff_index_files "$1")" "" "$cur_" + ;; + esac +} + __git_complete_file () { __git_complete_revlist_file @@ -531,10 +684,19 @@ __git_complete_strategy () return 1 } +__git_commands () { + if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" + then + printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" + else + git help -a|egrep '^ [a-zA-Z0-9]' + fi +} + __git_list_all_commands () { local i IFS=" "$'\n' - for i in $(git help -a|egrep '^ [a-zA-Z0-9]') + for i in $(__git_commands) do case $i in *--*) : helper pattern;; @@ -563,6 +725,7 @@ __git_list_porcelain_commands () archimport) : import;; cat-file) : plumbing;; check-attr) : plumbing;; + check-ignore) : plumbing;; check-ref-format) : plumbing;; checkout-index) : plumbing;; commit-tree) : plumbing;; @@ -722,6 +885,43 @@ __git_has_doubledash () return 1 } +# Try to count non option arguments passed on the command line for the +# specified git command. +# When options are used, it is necessary to use the special -- option to +# tell the implementation were non option arguments begin. +# XXX this can not be improved, since options can appear everywhere, as +# an example: +# git mv x -n y +# +# __git_count_arguments requires 1 argument: the git command executed. +__git_count_arguments () +{ + local word i c=0 + + # Skip "git" (first argument) + for ((i=1; i < ${#words[@]}; i++)); do + word="${words[i]}" + + case "$word" in + --) + # Good; we can assume that the following are only non + # option arguments. + ((c = 0)) + ;; + "$1") + # Skip the specified git command and discard git + # main options + ((c = 0)) + ;; + ?*) + ((c++)) + ;; + esac + done + + printf "%d" $c +} + __git_whitespacelist="nowarn warn error error-all fix" _git_am () @@ -770,8 +970,6 @@ _git_apply () _git_add () { - __git_has_doubledash && return - case "$cur" in --*) __gitcomp " @@ -780,7 +978,9 @@ _git_add () " return esac - COMPREPLY=() + + # XXX should we check for --update and --all options ? + __git_complete_index_file "--others --modified" } _git_archive () @@ -930,15 +1130,15 @@ _git_cherry_pick () _git_clean () { - __git_has_doubledash && return - case "$cur" in --*) __gitcomp "--dry-run --quiet" return ;; esac - COMPREPLY=() + + # XXX should we check for -x option ? + __git_complete_index_file "--others" } _git_clone () @@ -969,7 +1169,12 @@ _git_clone () _git_commit () { - __git_has_doubledash && return + case "$prev" in + -c|-C) + __gitcomp_nl "$(__git_refs)" "" "${cur}" + return + ;; + esac case "$prev" in -c|-C) @@ -1005,7 +1210,13 @@ _git_commit () " return esac - COMPREPLY=() + + if git rev-parse --verify --quiet HEAD >/dev/null; then + __git_complete_diff_index_file "HEAD" + else + # This is the first commit + __git_complete_index_file "--cached" + fi } _git_describe () @@ -1223,8 +1434,6 @@ _git_init () _git_ls_files () { - __git_has_doubledash && return - case "$cur" in --*) __gitcomp "--cached --deleted --modified --others --ignored @@ -1237,7 +1446,10 @@ _git_ls_files () return ;; esac - COMPREPLY=() + + # XXX ignore options like --modified and always suggest all cached + # files. + __git_complete_index_file "--cached" } _git_ls_remote () @@ -1369,7 +1581,14 @@ _git_mv () return ;; esac - COMPREPLY=() + + if [ $(__git_count_arguments "mv") -gt 0 ]; then + # We need to show both cached and untracked files (including + # empty directories) since this may not be the last argument. + __git_complete_index_file "--cached --others --directory" + else + __git_complete_index_file "--cached" + fi } _git_name_rev () @@ -2075,15 +2294,14 @@ _git_revert () _git_rm () { - __git_has_doubledash && return - case "$cur" in --*) __gitcomp "--cached --dry-run --ignore-unmatch --quiet" return ;; esac - COMPREPLY=() + + __git_complete_index_file "--cached" } _git_shortlog () @@ -2431,7 +2649,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then --*=*|*.) ;; *) c="$c " ;; esac - array+=("$c") + array[$#array+1]="$c" done compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 @@ -2448,6 +2666,15 @@ if [[ -n ${ZSH_VERSION-} ]]; then compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } + __gitcomp_file () + { + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 + } + __git_zsh_helper () { emulate -L ksh @@ -2469,6 +2696,14 @@ if [[ -n ${ZSH_VERSION-} ]]; then compdef _git git gitk return +elif [[ -n ${BASH_VERSION-} ]]; then + if ((${BASH_VERSINFO[0]} < 4)); then + # compopt is not supported + __git_index_file_list_filter () + { + __git_index_file_list_filter_compat + } + fi fi __git_func_wrap () diff --git a/contrib/completion/git-completion.tcsh b/contrib/completion/git-completion.tcsh index 3e3889f2b4..eaacaf0c3e 100644 --- a/contrib/completion/git-completion.tcsh +++ b/contrib/completion/git-completion.tcsh @@ -52,6 +52,18 @@ cat << EOF > ${__git_tcsh_completion_script} source ${__git_tcsh_completion_original_script} +# Remove the colon as a completion separator because tcsh cannot handle it +COMP_WORDBREAKS=\${COMP_WORDBREAKS//:} + +# For file completion, tcsh needs the '/' to be appended to directories. +# By default, the bash script does not do that. +# We can achieve this by using the below compatibility +# method of the git-completion.bash script. +__git_index_file_list_filter () +{ + __git_index_file_list_filter_compat +} + # Set COMP_WORDS in a way that can be handled by the bash script. COMP_WORDS=(\$2) diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index b2171a092e..0e5b72d7f1 100755 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -237,6 +237,7 @@ generate_email_header() X-Git-Reftype: $refname_type X-Git-Oldrev: $oldrev X-Git-Newrev: $newrev + Auto-Submitted: auto-generated This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing diff --git a/contrib/svn-fe/svnrdump_sim.py b/contrib/svn-fe/svnrdump_sim.py index 17cf6f961f..4e78a1c3cd 100755 --- a/contrib/svn-fe/svnrdump_sim.py +++ b/contrib/svn-fe/svnrdump_sim.py @@ -14,7 +14,7 @@ if sys.hexversion < 0x02040000: def getrevlimit(): var = 'SVNRMAX' - if os.environ.has_key(var): + if var in os.environ: return os.environ[var] return None @@ -44,7 +44,7 @@ def writedump(url, lower, upper): if __name__ == "__main__": if not (len(sys.argv) in (3, 4, 5)): - print "usage: %s dump URL -rLOWER:UPPER" + print("usage: %s dump URL -rLOWER:UPPER") sys.exit(1) if not sys.argv[1] == 'dump': raise NotImplementedError('only "dump" is suppported.') url = sys.argv[2] @@ -457,7 +457,7 @@ static struct convert_driver { static int read_convert_config(const char *var, const char *value, void *cb) { - const char *ep, *name; + const char *key, *name; int namelen; struct convert_driver *drv; @@ -465,10 +465,8 @@ static int read_convert_config(const char *var, const char *value, void *cb) * External conversion drivers are configured using * "filter.<name>.variable". */ - if (prefixcmp(var, "filter.") || (ep = strrchr(var, '.')) == var + 6) + if (parse_config_key(var, "filter", &name, &namelen, &key) < 0 || !name) return 0; - name = var + 7; - namelen = ep - name; for (drv = user_convert; drv; drv = drv->next) if (!strncmp(drv->name, name, namelen) && !drv->name[namelen]) break; @@ -479,8 +477,6 @@ static int read_convert_config(const char *var, const char *value, void *cb) user_convert_tail = &(drv->next); } - ep++; - /* * filter.<name>.smudge and filter.<name>.clean specifies * the command line: @@ -490,13 +486,13 @@ static int read_convert_config(const char *var, const char *value, void *cb) * The command-line will not be interpolated in any way. */ - if (!strcmp("smudge", ep)) + if (!strcmp("smudge", key)) return git_config_string(&drv->smudge, var, value); - if (!strcmp("clean", ep)) + if (!strcmp("clean", key)) return git_config_string(&drv->clean, var, value); - if (!strcmp("required", ep)) { + if (!strcmp("required", key)) { drv->required = git_config_bool(var, value); return 0; } @@ -194,12 +194,19 @@ static int match_one(const char *match, const char *name, int namelen) } /* - * Given a name and a list of pathspecs, see if the name matches - * any of the pathspecs. The caller is also interested in seeing - * all pathspec matches some names it calls this function with - * (otherwise the user could have mistyped the unmatched pathspec), - * and a mark is left in seen[] array for pathspec element that - * actually matched anything. + * Given a name and a list of pathspecs, returns the nature of the + * closest (i.e. most specific) match of the name to any of the + * pathspecs. + * + * The caller typically calls this multiple times with the same + * pathspec and seen[] array but with different name/namelen + * (e.g. entries from the index) and is interested in seeing if and + * how each pathspec matches all the names it calls this function + * with. A mark is left in the seen[] array for each pathspec element + * indicating the closest type of match that element achieved, so if + * seen[n] remains zero after multiple invocations, that means the nth + * pathspec did not match any names, which could indicate that the + * user mistyped the nth pathspec. */ int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen) @@ -269,12 +276,19 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix, } /* - * Given a name and a list of pathspecs, see if the name matches - * any of the pathspecs. The caller is also interested in seeing - * all pathspec matches some names it calls this function with - * (otherwise the user could have mistyped the unmatched pathspec), - * and a mark is left in seen[] array for pathspec element that - * actually matched anything. + * Given a name and a list of pathspecs, returns the nature of the + * closest (i.e. most specific) match of the name to any of the + * pathspecs. + * + * The caller typically calls this multiple times with the same + * pathspec and seen[] array but with different name/namelen + * (e.g. entries from the index) and is interested in seeing if and + * how each pathspec matches all the names it calls this function + * with. A mark is left in the seen[] array for each pathspec element + * indicating the closest type of match that element achieved, so if + * seen[n] remains zero after multiple invocations, that means the nth + * pathspec did not match any names, which could indicate that the + * user mistyped the nth pathspec. */ int match_pathspec_depth(const struct pathspec *ps, const char *name, int namelen, @@ -379,7 +393,7 @@ void parse_exclude_pattern(const char **pattern, } void add_exclude(const char *string, const char *base, - int baselen, struct exclude_list *el) + int baselen, struct exclude_list *el, int srcpos) { struct exclude *x; int patternlen; @@ -403,8 +417,10 @@ void add_exclude(const char *string, const char *base, x->base = base; x->baselen = baselen; x->flags = flags; + x->srcpos = srcpos; ALLOC_GROW(el->excludes, el->nr + 1, el->alloc); el->excludes[el->nr++] = x; + x->el = el; } static void *read_skip_worktree_file_from_index(const char *path, size_t *size) @@ -441,20 +457,21 @@ void clear_exclude_list(struct exclude_list *el) for (i = 0; i < el->nr; i++) free(el->excludes[i]); free(el->excludes); + free(el->filebuf); el->nr = 0; el->excludes = NULL; + el->filebuf = NULL; } int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen, - char **buf_p, struct exclude_list *el, int check_index) { struct stat st; - int fd, i; + int fd, i, lineno = 1; size_t size = 0; char *buf, *entry; @@ -492,25 +509,43 @@ int add_excludes_from_file_to_list(const char *fname, close(fd); } - if (buf_p) - *buf_p = buf; + el->filebuf = buf; entry = buf; for (i = 0; i < size; i++) { if (buf[i] == '\n') { if (entry != buf + i && entry[0] != '#') { buf[i - (i && buf[i-1] == '\r')] = 0; - add_exclude(entry, base, baselen, el); + add_exclude(entry, base, baselen, el, lineno); } + lineno++; entry = buf + i + 1; } } return 0; } +struct exclude_list *add_exclude_list(struct dir_struct *dir, + int group_type, const char *src) +{ + struct exclude_list *el; + struct exclude_list_group *group; + + group = &dir->exclude_list_group[group_type]; + ALLOC_GROW(group->el, group->nr + 1, group->alloc); + el = &group->el[group->nr++]; + memset(el, 0, sizeof(*el)); + el->src = src; + return el; +} + +/* + * Used to set up core.excludesfile and .git/info/exclude lists. + */ void add_excludes_from_file(struct dir_struct *dir, const char *fname) { - if (add_excludes_from_file_to_list(fname, "", 0, NULL, - &dir->exclude_list[EXC_FILE], 0) < 0) + struct exclude_list *el; + el = add_exclude_list(dir, EXC_FILE, fname); + if (add_excludes_from_file_to_list(fname, "", 0, el, 0) < 0) die("cannot use %s as an exclude file", fname); } @@ -520,6 +555,7 @@ void add_excludes_from_file(struct dir_struct *dir, const char *fname) */ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen) { + struct exclude_list_group *group; struct exclude_list *el; struct exclude_stack *stk = NULL; int current; @@ -528,17 +564,21 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen) (baselen + strlen(dir->exclude_per_dir) >= PATH_MAX)) return; /* too long a path -- ignore */ - /* Pop the directories that are not the prefix of the path being checked. */ - el = &dir->exclude_list[EXC_DIRS]; + group = &dir->exclude_list_group[EXC_DIRS]; + + /* Pop the exclude lists from the EXCL_DIRS exclude_list_group + * which originate from directories not in the prefix of the + * path being checked. */ while ((stk = dir->exclude_stack) != NULL) { if (stk->baselen <= baselen && !strncmp(dir->basebuf, base, stk->baselen)) break; + el = &group->el[dir->exclude_stack->exclude_ix]; dir->exclude_stack = stk->prev; - while (stk->exclude_ix < el->nr) - free(el->excludes[--el->nr]); - free(stk->filebuf); + free((char *)el->src); /* see strdup() below */ + clear_exclude_list(el); free(stk); + group->nr--; } /* Read from the parent directories and push them down. */ @@ -559,13 +599,22 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen) } stk->prev = dir->exclude_stack; stk->baselen = cp - base; - stk->exclude_ix = el->nr; memcpy(dir->basebuf + current, base + current, stk->baselen - current); strcpy(dir->basebuf + stk->baselen, dir->exclude_per_dir); + /* + * dir->basebuf gets reused by the traversal, but we + * need fname to remain unchanged to ensure the src + * member of each struct exclude correctly + * back-references its source file. Other invocations + * of add_exclude_list provide stable strings, so we + * strdup() and free() here in the caller. + */ + el = add_exclude_list(dir, EXC_DIRS, strdup(dir->basebuf)); + stk->exclude_ix = group->nr - 1; add_excludes_from_file_to_list(dir->basebuf, dir->basebuf, stk->baselen, - &stk->filebuf, el, 1); + el, 1); dir->exclude_stack = stk; current = stk->baselen; } @@ -636,7 +685,8 @@ int match_pathname(const char *pathname, int pathlen, } return wildmatch(pattern, name, - ignore_case ? FNM_CASEFOLD : 0) == 0; + WM_PATHNAME | (ignore_case ? WM_CASEFOLD : 0), + NULL) == 0; } /* @@ -712,18 +762,23 @@ static struct exclude *last_exclude_matching(struct dir_struct *dir, int *dtype_p) { int pathlen = strlen(pathname); - int st; + int i, j; + struct exclude_list_group *group; struct exclude *exclude; const char *basename = strrchr(pathname, '/'); basename = (basename) ? basename+1 : pathname; prep_exclude(dir, pathname, basename-pathname); - for (st = EXC_CMDL; st <= EXC_FILE; st++) { - exclude = last_exclude_matching_from_list( - pathname, pathlen, basename, dtype_p, - &dir->exclude_list[st]); - if (exclude) - return exclude; + + for (i = EXC_CMDL; i <= EXC_FILE; i++) { + group = &dir->exclude_list_group[i]; + for (j = group->nr - 1; j >= 0; j--) { + exclude = last_exclude_matching_from_list( + pathname, pathlen, basename, dtype_p, + &group->el[j]); + if (exclude) + return exclude; + } } return NULL; } @@ -1627,3 +1682,33 @@ int limit_pathspec_to_literal(void) flag = git_env_bool(GIT_LITERAL_PATHSPECS_ENVIRONMENT, 0); return flag; } + +/* + * Frees memory within dir which was allocated for exclude lists and + * the exclude_stack. Does not free dir itself. + */ +void clear_directory(struct dir_struct *dir) +{ + int i, j; + struct exclude_list_group *group; + struct exclude_list *el; + struct exclude_stack *stk; + + for (i = EXC_CMDL; i <= EXC_FILE; i++) { + group = &dir->exclude_list_group[i]; + for (j = 0; j < group->nr; j++) { + el = &group->el[j]; + if (i == EXC_DIRS) + free((char *)el->src); + clear_exclude_list(el); + } + free(group->el); + } + + stk = dir->exclude_stack; + while (stk) { + struct exclude_stack *prev = stk->prev; + free(stk); + stk = prev; + } +} @@ -16,21 +16,41 @@ struct dir_entry { #define EXC_FLAG_NEGATIVE 16 /* - * Each .gitignore file will be parsed into patterns which are then - * appended to the relevant exclude_list (either EXC_DIRS or - * EXC_FILE). exclude_lists are also used to represent the list of - * --exclude values passed via CLI args (EXC_CMDL). + * Each excludes file will be parsed into a fresh exclude_list which + * is appended to the relevant exclude_list_group (either EXC_DIRS or + * EXC_FILE). An exclude_list within the EXC_CMDL exclude_list_group + * can also be used to represent the list of --exclude values passed + * via CLI args. */ struct exclude_list { int nr; int alloc; + + /* remember pointer to exclude file contents so we can free() */ + char *filebuf; + + /* origin of list, e.g. path to filename, or descriptive string */ + const char *src; + struct exclude { + /* + * This allows callers of last_exclude_matching() etc. + * to determine the origin of the matching pattern. + */ + struct exclude_list *el; + const char *pattern; int patternlen; int nowildcardlen; const char *base; int baselen; int flags; + + /* + * Counting starts from 1 for line numbers in ignore files, + * and from -1 decrementing for patterns from CLI args. + */ + int srcpos; } **excludes; }; @@ -42,9 +62,13 @@ struct exclude_list { */ struct exclude_stack { struct exclude_stack *prev; /* the struct exclude_stack for the parent directory */ - char *filebuf; /* remember pointer to per-directory exclude file contents so we can free() */ int baselen; - int exclude_ix; + int exclude_ix; /* index of exclude_list within EXC_DIRS exclude_list_group */ +}; + +struct exclude_list_group { + int nr, alloc; + struct exclude_list *el; }; struct dir_struct { @@ -62,16 +86,23 @@ struct dir_struct { /* Exclude info */ const char *exclude_per_dir; - struct exclude_list exclude_list[3]; + /* - * We maintain three exclude pattern lists: + * We maintain three groups of exclude pattern lists: + * * EXC_CMDL lists patterns explicitly given on the command line. * EXC_DIRS lists patterns obtained from per-directory ignore files. - * EXC_FILE lists patterns from fallback ignore files. + * EXC_FILE lists patterns from fallback ignore files, e.g. + * - .git/info/exclude + * - core.excludesfile + * + * Each group contains multiple exclude lists, a single list + * per source. */ #define EXC_CMDL 0 #define EXC_DIRS 1 #define EXC_FILE 2 + struct exclude_list_group exclude_list_group[3]; /* * Temporary variables which are used during loading of the @@ -85,6 +116,12 @@ struct dir_struct { char basebuf[PATH_MAX]; }; +/* + * The ordering of these constants is significant, with + * higher-numbered match types signifying "closer" (i.e. more + * specific) matches which will override lower-numbered match types + * when populating the seen[] array. + */ #define MATCHED_RECURSIVELY 1 #define MATCHED_FNMATCH 2 #define MATCHED_EXACTLY 3 @@ -129,13 +166,16 @@ extern struct exclude *last_exclude_matching_path(struct path_exclude_check *, c extern int is_path_excluded(struct path_exclude_check *, const char *, int namelen, int *dtype); +extern struct exclude_list *add_exclude_list(struct dir_struct *dir, + int group_type, const char *src); extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen, - char **buf_p, struct exclude_list *el, int check_index); + struct exclude_list *el, int check_index); extern void add_excludes_from_file(struct dir_struct *, const char *fname); extern void parse_exclude_pattern(const char **string, int *patternlen, int *flags, int *nowildcardlen); extern void add_exclude(const char *string, const char *base, - int baselen, struct exclude_list *el); + int baselen, struct exclude_list *el, int srcpos); extern void clear_exclude_list(struct exclude_list *el); +extern void clear_directory(struct dir_struct *dir); extern int file_exists(const char *); extern int is_inside_dir(const char *dir); diff --git a/environment.c b/environment.c index 85edd7f95a..89d6c70c15 100644 --- a/environment.c +++ b/environment.c @@ -13,6 +13,7 @@ int trust_executable_bit = 1; int trust_ctime = 1; +int check_stat = 1; int has_symlinks = 1; int minimum_abbrev = 4, default_abbrev = 7; int ignore_case; @@ -62,6 +63,12 @@ int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */ struct startup_info *startup_info; unsigned long pack_size_limit_cfg; +/* + * The character that begins a commented line in user-editable file + * that is subject to stripspace. + */ +char comment_line_char = '#'; + /* Parallel index stat data preload? */ int core_preload_index = 0; diff --git a/fetch-pack.c b/fetch-pack.c index f0acdf7331..6d8926a550 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -594,6 +594,9 @@ static int everything_local(struct fetch_pack_args *args, for (ref = *refs; ref; ref = ref->next) { struct object *o; + if (!has_sha1_file(ref->old_sha1)) + continue; + o = parse_object(ref->old_sha1); if (!o) continue; @@ -334,7 +334,7 @@ split_patches () { # Since we cannot guarantee that the commit message is in # git-friendly format, we put no Subject: line and just consume # all of the message as the body - perl -M'POSIX qw(strftime)' -ne 'BEGIN { $subject = 0 } + LANG=C LC_ALL=C perl -M'POSIX qw(strftime)' -ne 'BEGIN { $subject = 0 } if ($subject) { print ; } elsif (/^\# User /) { s/\# User/From:/ ; print ; } elsif (/^\# Date /) { @@ -664,7 +664,7 @@ do sed -e '1,/^$/d' >"$dotest/msg-clean" echo "$commit" >"$dotest/original-commit" get_author_ident_from_commit "$commit" >"$dotest/author-script" - git diff-tree --root --binary "$commit" >"$dotest/patch" + git diff-tree --root --binary --full-index "$commit" >"$dotest/patch" else git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \ <"$dotest/$msgnum" >"$dotest/info" || diff --git a/git-compat-util.h b/git-compat-util.h index e5a4b7450b..cc2abeea0d 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -112,7 +112,9 @@ #include <sys/time.h> #include <time.h> #include <signal.h> +#ifndef USE_WILDMATCH #include <fnmatch.h> +#endif #include <assert.h> #include <regex.h> #include <utime.h> @@ -280,6 +282,17 @@ extern char *gitbasename(char *); #include "compat/bswap.h" +#ifdef USE_WILDMATCH +#include "wildmatch.h" +#define FNM_PATHNAME WM_PATHNAME +#define FNM_CASEFOLD WM_CASEFOLD +#define FNM_NOMATCH WM_NOMATCH +static inline int fnmatch(const char *pattern, const char *string, int flags) +{ + return wildmatch(pattern, string, flags, NULL); +} +#endif + /* General helper functions */ extern void vreportf(const char *prefix, const char *err, va_list params); extern void vwritef(int fd, const char *prefix, const char *err, va_list params); @@ -297,7 +310,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))) * behavior. But since we're only trying to help gcc, anyway, it's OK; other * compilers will fall back to using the function as usual. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && ! defined(__clang__) #define error(fmt, ...) (error((fmt), ##__VA_ARGS__), -1) #endif diff --git a/git-cvsserver.perl b/git-cvsserver.perl index c5ebfa0636..3679074983 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -60,6 +60,7 @@ my $methods = { 'Valid-responses' => \&req_Validresponses, 'valid-requests' => \&req_validrequests, 'Directory' => \&req_Directory, + 'Sticky' => \&req_Sticky, 'Entry' => \&req_Entry, 'Modified' => \&req_Modified, 'Unchanged' => \&req_Unchanged, @@ -470,11 +471,19 @@ sub req_Directory { $log->info("Setting prepend to '$state->{path}'"); $state->{prependdir} = $state->{path}; + my %entries; foreach my $entry ( keys %{$state->{entries}} ) { - $state->{entries}{$state->{prependdir} . $entry} = $state->{entries}{$entry}; - delete $state->{entries}{$entry}; + $entries{$state->{prependdir} . $entry} = $state->{entries}{$entry}; } + $state->{entries}=\%entries; + + my %dirMap; + foreach my $dir ( keys %{$state->{dirMap}} ) + { + $dirMap{$state->{prependdir} . $dir} = $state->{dirMap}{$dir}; + } + $state->{dirMap}=\%dirMap; } if ( defined ( $state->{prependdir} ) ) @@ -482,9 +491,60 @@ sub req_Directory $log->debug("Prepending '$state->{prependdir}' to state|directory"); $state->{directory} = $state->{prependdir} . $state->{directory} } + + if ( ! defined($state->{dirMap}{$state->{directory}}) ) + { + $state->{dirMap}{$state->{directory}} = + { + 'names' => {} + #'tagspec' => undef + }; + } + $log->debug("req_Directory : localdir=$data repository=$repository path=$state->{path} directory=$state->{directory} module=$state->{module}"); } +# Sticky tagspec \n +# Response expected: no. Tell the server that the directory most +# recently specified with Directory has a sticky tag or date +# tagspec. The first character of tagspec is T for a tag, D for +# a date, or some other character supplied by a Set-sticky +# response from a previous request to the server. The remainder +# of tagspec contains the actual tag or date, again as supplied +# by Set-sticky. +# The server should remember Static-directory and Sticky requests +# for a particular directory; the client need not resend them each +# time it sends a Directory request for a given directory. However, +# the server is not obliged to remember them beyond the context +# of a single command. +sub req_Sticky +{ + my ( $cmd, $tagspec ) = @_; + + my ( $stickyInfo ); + if($tagspec eq "") + { + # nothing + } + elsif($tagspec=~/^T([^ ]+)\s*$/) + { + $stickyInfo = { 'tag' => $1 }; + } + elsif($tagspec=~/^D([0-9.]+)\s*$/) + { + $stickyInfo= { 'date' => $1 }; + } + else + { + die "Unknown tag_or_date format\n"; + } + $state->{dirMap}{$state->{directory}}{stickyInfo}=$stickyInfo; + + $log->debug("req_Sticky : tagspec=$tagspec repository=$state->{repository}" + . " path=$state->{path} directory=$state->{directory}" + . " module=$state->{module}"); +} + # Entry entry-line \n # Response expected: no. Tell the server what version of a file is on the # local machine. The name in entry-line is a name relative to the directory @@ -511,6 +571,8 @@ sub req_Entry tag_or_date => $data[5], }; + $state->{dirMap}{$state->{directory}}{names}{$data[1]} = 'F'; + $log->info("Received entry line '$data' => '" . $state->{directory} . $data[1] . "'"); } @@ -549,7 +611,10 @@ sub req_add { $filename = filecleanup($filename); - my $meta = $updater->getmeta($filename); + # no -r, -A, or -D with add + my $stickyInfo = resolveStickyInfo($filename); + + my $meta = $updater->getmeta($filename,$stickyInfo); my $wrev = revparse($filename); if ($wrev && $meta && ($wrev=~/^-/)) @@ -572,8 +637,10 @@ sub req_add # this is an "entries" line my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash}); - $log->debug("/$filepart/$meta->{revision}//$kopts/"); - print "/$filepart/$meta->{revision}//$kopts/\n"; + my $entryLine = "/$filepart/$meta->{revision}//$kopts/"; + $entryLine .= getStickyTagOrDate($stickyInfo); + $log->debug($entryLine); + print "$entryLine\n"; # permissions $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}"); print "u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\n"; @@ -604,7 +671,8 @@ sub req_add print "$filename\n"; my $kopts = kopts_from_path($filename,"file", $state->{entries}{$filename}{modified_filename}); - print "/$filepart/0//$kopts/\n"; + print "/$filepart/0//$kopts/" . + getStickyTagOrDate($stickyInfo) . "\n"; my $requestedKopts = $state->{opt}{k}; if(defined($requestedKopts)) @@ -672,7 +740,10 @@ sub req_remove next; } - my $meta = $updater->getmeta($filename); + # only from entries + my $stickyInfo = resolveStickyInfo($filename); + + my $meta = $updater->getmeta($filename,$stickyInfo); my $wrev = revparse($filename); unless ( defined ( $wrev ) ) @@ -702,7 +773,7 @@ sub req_remove print "Checked-in $dirpart\n"; print "$filename\n"; my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash}); - print "/$filepart/-$wrev//$kopts/\n"; + print "/$filepart/-$wrev//$kopts/" . getStickyTagOrDate($stickyInfo) . "\n"; $rmcount++; } @@ -882,6 +953,9 @@ sub req_co return 1; } + my $stickyInfo = { 'tag' => $state->{opt}{r}, + 'date' => $state->{opt}{D} }; + my $module = $state->{args}[0]; $state->{module} = $module; my $checkout_path = $module; @@ -899,64 +973,32 @@ sub req_co my $updater = GITCVS::updater->new($state->{CVSROOT}, $module, $log); $updater->update(); - $checkout_path =~ s|/$||; # get rid of trailing slashes + my $headHash; + if( defined($stickyInfo) && defined($stickyInfo->{tag}) ) + { + $headHash = $updater->lookupCommitRef($stickyInfo->{tag}); + if( !defined($headHash) ) + { + print "error 1 no such tag `$stickyInfo->{tag}'\n"; + cleanupWorkTree(); + exit; + } + } - # Eclipse seems to need the Clear-sticky command - # to prepare the 'Entries' file for the new directory. - print "Clear-sticky $checkout_path/\n"; - print $state->{CVSROOT} . "/$module/\n"; - print "Clear-static-directory $checkout_path/\n"; - print $state->{CVSROOT} . "/$module/\n"; - print "Clear-sticky $checkout_path/\n"; # yes, twice - print $state->{CVSROOT} . "/$module/\n"; - print "Template $checkout_path/\n"; - print $state->{CVSROOT} . "/$module/\n"; - print "0\n"; - - # instruct the client that we're checking out to $checkout_path - print "E cvs checkout: Updating $checkout_path\n"; + $checkout_path =~ s|/$||; # get rid of trailing slashes my %seendirs = (); my $lastdir =''; - # recursive - sub prepdir { - my ($dir, $repodir, $remotedir, $seendirs) = @_; - my $parent = dirname($dir); - $dir =~ s|/+$||; - $repodir =~ s|/+$||; - $remotedir =~ s|/+$||; - $parent =~ s|/+$||; - $log->debug("announcedir $dir, $repodir, $remotedir" ); - - if ($parent eq '.' || $parent eq './') { - $parent = ''; - } - # recurse to announce unseen parents first - if (length($parent) && !exists($seendirs->{$parent})) { - prepdir($parent, $repodir, $remotedir, $seendirs); - } - # Announce that we are going to modify at the parent level - if ($parent) { - print "E cvs checkout: Updating $remotedir/$parent\n"; - } else { - print "E cvs checkout: Updating $remotedir\n"; - } - print "Clear-sticky $remotedir/$parent/\n"; - print "$repodir/$parent/\n"; - - print "Clear-static-directory $remotedir/$dir/\n"; - print "$repodir/$dir/\n"; - print "Clear-sticky $remotedir/$parent/\n"; # yes, twice - print "$repodir/$parent/\n"; - print "Template $remotedir/$dir/\n"; - print "$repodir/$dir/\n"; - print "0\n"; - - $seendirs->{$dir} = 1; - } - - foreach my $git ( @{$updater->gethead} ) + prepDirForOutput( + ".", + $state->{CVSROOT} . "/$module", + $checkout_path, + \%seendirs, + 'checkout', + $state->{dirArgs} ); + + foreach my $git ( @{$updater->getAnyHead($headHash)} ) { # Don't want to check out deleted files next if ( $git->{filehash} eq "deleted" ); @@ -964,16 +1006,13 @@ sub req_co my $fullName = $git->{name}; ( $git->{name}, $git->{dir} ) = filenamesplit($git->{name}); - if (length($git->{dir}) && $git->{dir} ne './' - && $git->{dir} ne $lastdir ) { - unless (exists($seendirs{$git->{dir}})) { - prepdir($git->{dir}, $state->{CVSROOT} . "/$module/", - $checkout_path, \%seendirs); - $lastdir = $git->{dir}; - $seendirs{$git->{dir}} = 1; - } - print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n"; - } + unless (exists($seendirs{$git->{dir}})) { + prepDirForOutput($git->{dir}, $state->{CVSROOT} . "/$module/", + $checkout_path, \%seendirs, 'checkout', + $state->{dirArgs} ); + $lastdir = $git->{dir}; + $seendirs{$git->{dir}} = 1; + } # modification time of this file print "Mod-time $git->{modified}\n"; @@ -993,7 +1032,8 @@ sub req_co # this is an "entries" line my $kopts = kopts_from_path($fullName,"sha1",$git->{filehash}); - print "/$git->{name}/$git->{revision}//$kopts/\n"; + print "/$git->{name}/$git->{revision}//$kopts/" . + getStickyTagOrDate($stickyInfo) . "\n"; # permissions print "u=$git->{mode},g=$git->{mode},o=$git->{mode}\n"; @@ -1006,6 +1046,119 @@ sub req_co statecleanup(); } +# used by req_co and req_update to set up directories for files +# recursively handles parents +sub prepDirForOutput +{ + my ($dir, $repodir, $remotedir, $seendirs, $request, $dirArgs) = @_; + + my $parent = dirname($dir); + $dir =~ s|/+$||; + $repodir =~ s|/+$||; + $remotedir =~ s|/+$||; + $parent =~ s|/+$||; + + if ($parent eq '.' || $parent eq './') + { + $parent = ''; + } + # recurse to announce unseen parents first + if( length($parent) && + !exists($seendirs->{$parent}) && + ( $request eq "checkout" || + exists($dirArgs->{$parent}) ) ) + { + prepDirForOutput($parent, $repodir, $remotedir, + $seendirs, $request, $dirArgs); + } + # Announce that we are going to modify at the parent level + if ($dir eq '.' || $dir eq './') + { + $dir = ''; + } + if(exists($seendirs->{$dir})) + { + return; + } + $log->debug("announcedir $dir, $repodir, $remotedir" ); + my($thisRemoteDir,$thisRepoDir); + if ($dir ne "") + { + $thisRepoDir="$repodir/$dir"; + if($remotedir eq ".") + { + $thisRemoteDir=$dir; + } + else + { + $thisRemoteDir="$remotedir/$dir"; + } + } + else + { + $thisRepoDir=$repodir; + $thisRemoteDir=$remotedir; + } + unless ( $state->{globaloptions}{-Q} || $state->{globaloptions}{-q} ) + { + print "E cvs $request: Updating $thisRemoteDir\n"; + } + + my ($opt_r)=$state->{opt}{r}; + my $stickyInfo; + if(exists($state->{opt}{A})) + { + # $stickyInfo=undef; + } + elsif( defined($opt_r) && $opt_r ne "" ) + # || ( defined($state->{opt}{D}) && $state->{opt}{D} ne "" ) # TODO + { + $stickyInfo={ 'tag' => (defined($opt_r)?$opt_r:undef) }; + + # TODO: Convert -D value into the form 2011.04.10.04.46.57, + # similar to an entry line's sticky date, without the D prefix. + # It sometimes (always?) arrives as something more like + # '10 Apr 2011 04:46:57 -0000'... + # $stickyInfo={ 'date' => (defined($stickyDate)?$stickyDate:undef) }; + } + else + { + $stickyInfo=getDirStickyInfo($state->{prependdir} . $dir); + } + + my $stickyResponse; + if(defined($stickyInfo)) + { + $stickyResponse = "Set-sticky $thisRemoteDir/\n" . + "$thisRepoDir/\n" . + getStickyTagOrDate($stickyInfo) . "\n"; + } + else + { + $stickyResponse = "Clear-sticky $thisRemoteDir/\n" . + "$thisRepoDir/\n"; + } + + unless ( $state->{globaloptions}{-n} ) + { + print $stickyResponse; + + print "Clear-static-directory $thisRemoteDir/\n"; + print "$thisRepoDir/\n"; + print $stickyResponse; # yes, twice + print "Template $thisRemoteDir/\n"; + print "$thisRepoDir/\n"; + print "0\n"; + } + + $seendirs->{$dir} = 1; + + # FUTURE: This would more accurately emulate CVS by sending + # another copy of sticky after processing the files in that + # directory. Or intermediate: perhaps send all sticky's for + # $seendirs after after processing all files. +} + # update \n # Response expected: yes. Actually do a cvs update command. This uses any # previous Argument, Directory, Entry, or Modified requests, if they have @@ -1049,29 +1202,19 @@ sub req_update #$log->debug("update state : " . Dumper($state)); - my $last_dirname = "///"; + my($repoDir); + $repoDir=$state->{CVSROOT} . "/$state->{module}/$state->{prependdir}"; + + my %seendirs = (); # foreach file specified on the command line ... - foreach my $filename ( @{$state->{args}} ) + foreach my $argsFilename ( @{$state->{args}} ) { - $filename = filecleanup($filename); + my $filename; + $filename = filecleanup($argsFilename); $log->debug("Processing file $filename"); - unless ( $state->{globaloptions}{-Q} || $state->{globaloptions}{-q} ) - { - my $cur_dirname = dirname($filename); - if ( $cur_dirname ne $last_dirname ) - { - $last_dirname = $cur_dirname; - if ( $cur_dirname eq "" ) - { - $cur_dirname = "."; - } - print "E cvs update: Updating $cur_dirname\n"; - } - } - # if we have a -C we should pretend we never saw modified stuff if ( exists ( $state->{opt}{C} ) ) { @@ -1080,13 +1223,11 @@ sub req_update $state->{entries}{$filename}{unchanged} = 1; } - my $meta; - if ( defined($state->{opt}{r}) and $state->{opt}{r} =~ /^(1\.\d+)$/ ) - { - $meta = $updater->getmeta($filename, $1); - } else { - $meta = $updater->getmeta($filename); - } + my $stickyInfo = resolveStickyInfo($filename, + $state->{opt}{r}, + $state->{opt}{D}, + exists($state->{opt}{A})); + my $meta = $updater->getmeta($filename, $stickyInfo); # If -p was given, "print" the contents of the requested revision. if ( exists ( $state->{opt}{p} ) ) { @@ -1099,6 +1240,17 @@ sub req_update next; } + # Directories: + prepDirForOutput( + dirname($argsFilename), + $repoDir, + ".", + \%seendirs, + "update", + $state->{dirArgs} ); + + my $wrev = revparse($filename); + if ( ! defined $meta ) { $meta = { @@ -1106,16 +1258,23 @@ sub req_update revision => '0', filehash => 'added' }; + if($wrev ne "0") + { + $meta->{filehash}='deleted'; + } } my $oldmeta = $meta; - my $wrev = revparse($filename); - # If the working copy is an old revision, lets get that version too for comparison. - if ( defined($wrev) and $wrev ne $meta->{revision} ) + my $oldWrev=$wrev; + if(defined($oldWrev)) { - $oldmeta = $updater->getmeta($filename, $wrev); + $oldWrev=~s/^-//; + if($oldWrev ne $meta->{revision}) + { + $oldmeta = $updater->getmeta($filename, $oldWrev); + } } #$log->debug("Target revision is $meta->{revision}, current working revision is $wrev"); @@ -1133,6 +1292,7 @@ sub req_update if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev eq $meta->{revision} + and $wrev ne "0" and defined($state->{entries}{$filename}{modified_hash}) and not exists ( $state->{opt}{C} ) ) { @@ -1143,7 +1303,7 @@ sub req_update next; } - if ( $meta->{filehash} eq "deleted" ) + if ( $meta->{filehash} eq "deleted" && $wrev ne "0" ) { # TODO: If it has been modified in the sandbox, error out # with the appropriate message, rather than deleting a modified @@ -1205,10 +1365,6 @@ sub req_update $log->debug("Updating existing file 'Update-existing $dirpart'"); } else { # instruct client we're sending a file to put in this path as a new file - print "Clear-static-directory $dirpart\n"; - print $state->{CVSROOT} . "/$state->{module}/$dirpart\n"; - print "Clear-sticky $dirpart\n"; - print $state->{CVSROOT} . "/$state->{module}/$dirpart\n"; $log->debug("Creating new file 'Created $dirpart'"); print "Created $dirpart\n"; @@ -1217,8 +1373,10 @@ sub req_update # this is an "entries" line my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash}); - $log->debug("/$filepart/$meta->{revision}//$kopts/"); - print "/$filepart/$meta->{revision}//$kopts/\n"; + my $entriesLine = "/$filepart/$meta->{revision}//$kopts/"; + $entriesLine .= getStickyTagOrDate($stickyInfo); + $log->debug($entriesLine); + print "$entriesLine\n"; # permissions $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}"); @@ -1266,7 +1424,9 @@ sub req_update my $kopts = kopts_from_path("$dirpart/$filepart", "file",$mergedFile); $log->debug("/$filepart/$meta->{revision}//$kopts/"); - print "/$filepart/$meta->{revision}//$kopts/\n"; + my $entriesLine="/$filepart/$meta->{revision}//$kopts/"; + $entriesLine .= getStickyTagOrDate($stickyInfo); + print "$entriesLine\n"; } } elsif ( $return == 1 ) @@ -1282,7 +1442,9 @@ sub req_update print $state->{CVSROOT} . "/$state->{module}/$filename\n"; my $kopts = kopts_from_path("$dirpart/$filepart", "file",$mergedFile); - print "/$filepart/$meta->{revision}/+/$kopts/\n"; + my $entriesLine = "/$filepart/$meta->{revision}/+/$kopts/"; + $entriesLine .= getStickyTagOrDate($stickyInfo); + print "$entriesLine\n"; } } else @@ -1310,6 +1472,43 @@ sub req_update } + # prepDirForOutput() any other existing directories unless they already + # have the right sticky tag: + unless ( $state->{globaloptions}{n} ) + { + my $dir; + foreach $dir (keys(%{$state->{dirMap}})) + { + if( ! $seendirs{$dir} && + exists($state->{dirArgs}{$dir}) ) + { + my($oldTag); + $oldTag=$state->{dirMap}{$dir}{tagspec}; + + unless( ( exists($state->{opt}{A}) && + defined($oldTag) ) || + ( defined($state->{opt}{r}) && + ( !defined($oldTag) || + $state->{opt}{r} ne $oldTag ) ) ) + # TODO?: OR sticky dir is different... + { + next; + } + + prepDirForOutput( + $dir, + $repoDir, + ".", + \%seendirs, + 'update', + $state->{dirArgs} ); + } + + # TODO?: Consider sending a final duplicate Sticky response + # to more closely mimic real CVS. + } + } + print "ok\n"; } @@ -1342,23 +1541,11 @@ sub req_ci my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log); $updater->update(); - # 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"; - cleanupWorkTree(); - exit; - } - - setupWorkTree($parenthash); - - $log->info("Lockless commit start, basing commit on '$work->{workDir}', index file is '$work->{index}'"); - - $log->info("Created index '$work->{index}' for head $state->{module} - exit status $?"); - my @committedfiles = (); my %oldmeta; + my $stickyInfo; + my $branchRef; + my $parenthash; # foreach file specified on the command line ... foreach my $filename ( @{$state->{args}} ) @@ -1368,7 +1555,67 @@ sub req_ci next unless ( exists $state->{entries}{$filename}{modified_filename} or not $state->{entries}{$filename}{unchanged} ); - my $meta = $updater->getmeta($filename); + ##### + # Figure out which branch and parenthash we are committing + # to, and setup worktree: + + # should always come from entries: + my $fileStickyInfo = resolveStickyInfo($filename); + if( !defined($branchRef) ) + { + $stickyInfo = $fileStickyInfo; + if( defined($stickyInfo) && + ( defined($stickyInfo->{date}) || + !defined($stickyInfo->{tag}) ) ) + { + print "error 1 cannot commit with sticky date for file `$filename'\n"; + cleanupWorkTree(); + exit; + } + + $branchRef = "refs/heads/$state->{module}"; + if ( defined($stickyInfo) && defined($stickyInfo->{tag}) ) + { + $branchRef = "refs/heads/$stickyInfo->{tag}"; + } + + $parenthash = `git show-ref -s $branchRef`; + chomp $parenthash; + if ($parenthash !~ /^[0-9a-f]{40}$/) + { + if ( defined($stickyInfo) && defined($stickyInfo->{tag}) ) + { + print "error 1 sticky tag `$stickyInfo->{tag}' for file `$filename' is not a branch\n"; + } + else + { + print "error 1 pserver cannot find the current HEAD of module"; + } + cleanupWorkTree(); + exit; + } + + setupWorkTree($parenthash); + + $log->info("Lockless commit start, basing commit on '$work->{workDir}', index file is '$work->{index}'"); + + $log->info("Created index '$work->{index}' for head $state->{module} - exit status $?"); + } + elsif( !refHashEqual($stickyInfo,$fileStickyInfo) ) + { + #TODO: We could split the cvs commit into multiple + # git commits by distinct stickyTag values, but that + # is lowish priority. + print "error 1 Committing different files to different" + . " branches is not currently supported\n"; + cleanupWorkTree(); + exit; + } + + ##### + # Process this file: + + my $meta = $updater->getmeta($filename,$stickyInfo); $oldmeta{$filename} = $meta; my $wrev = revparse($filename); @@ -1470,7 +1717,7 @@ sub req_ci } ### Emulate git-receive-pack by running hooks/update - my @hook = ( $ENV{GIT_DIR}.'hooks/update', "refs/heads/$state->{module}", + my @hook = ( $ENV{GIT_DIR}.'hooks/update', $branchRef, $parenthash, $commithash ); if( -x $hook[0] ) { unless( system( @hook ) == 0 ) @@ -1484,7 +1731,7 @@ sub req_ci ### Update the ref if (system(qw(git update-ref -m), "cvsserver ci", - "refs/heads/$state->{module}", $commithash, $parenthash)) { + $branchRef, $commithash, $parenthash)) { $log->warn("update-ref for $state->{module} failed."); print "error 1 Cannot commit -- update first\n"; cleanupWorkTree(); @@ -1498,7 +1745,7 @@ sub req_ci local $SIG{PIPE} = sub { die 'pipe broke' }; - print $pipe "$parenthash $commithash refs/heads/$state->{module}\n"; + print $pipe "$parenthash $commithash $branchRef\n"; close $pipe || die "bad pipe: $! $?"; } @@ -1508,7 +1755,7 @@ sub req_ci ### Then hooks/post-update $hook = $ENV{GIT_DIR}.'hooks/post-update'; if (-x $hook) { - system($hook, "refs/heads/$state->{module}"); + system($hook, $branchRef); } # foreach file specified on the command line ... @@ -1516,7 +1763,7 @@ sub req_ci { $filename = filecleanup($filename); - my $meta = $updater->getmeta($filename); + my $meta = $updater->getmeta($filename,$stickyInfo); unless (defined $meta->{revision}) { $meta->{revision} = "1.1"; } @@ -1540,7 +1787,8 @@ sub req_ci print "Checked-in $dirpart\n"; print "$filename\n"; my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash}); - print "/$filepart/$meta->{revision}//$kopts/\n"; + print "/$filepart/$meta->{revision}//$kopts/" . + getStickyTagOrDate($stickyInfo) . "\n"; } } @@ -1577,16 +1825,19 @@ sub req_status next; } - my $meta = $updater->getmeta($filename); - my $oldmeta = $meta; - my $wrev = revparse($filename); + my $stickyInfo = resolveStickyInfo($filename); + my $meta = $updater->getmeta($filename,$stickyInfo); + my $oldmeta = $meta; + # If the working copy is an old revision, lets get that # version too for comparison. if ( defined($wrev) and $wrev ne $meta->{revision} ) { - $oldmeta = $updater->getmeta($filename, $wrev); + my($rmRev)=$wrev; + $rmRev=~s/^-//; + $oldmeta = $updater->getmeta($filename, $rmRev); } # TODO : All possible statuses aren't yet implemented @@ -1629,6 +1880,7 @@ sub req_status # same revision but there are local changes if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev eq $meta->{revision} and + $wrev ne "0" and $state->{entries}{$filename}{modified_filename} ) { $status ||= "Locally Modified"; @@ -1644,7 +1896,8 @@ sub req_status } if ( defined ( $state->{entries}{$filename}{revision} ) and - not defined ( $meta->{revision} ) ) + ( !defined($meta->{revision}) || + $meta->{revision} eq "0" ) ) { $status ||= "Locally Added"; } @@ -1740,98 +1993,133 @@ sub req_diff # be providing status on ... argsfromdir($updater); + my($foundDiff); + # foreach file specified on the command line ... - foreach my $filename ( @{$state->{args}} ) + foreach my $argFilename ( @{$state->{args}} ) { - $filename = filecleanup($filename); + my($filename) = filecleanup($argFilename); my ( $fh, $file1, $file2, $meta1, $meta2, $filediff ); my $wrev = revparse($filename); - # We need _something_ to diff against - next unless ( defined ( $wrev ) ); + # Priority for revision1: + # 1. First -r (missing file: check -N) + # 2. wrev from client's Entry line + # - missing line/file: check -N + # - "0": added file not committed (empty contents for rev1) + # - Prefixed with dash (to be removed): check -N - # if we have a -r switch, use it if ( defined ( $revision1 ) ) { - ( undef, $file1 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); $meta1 = $updater->getmeta($filename, $revision1); - unless ( defined ( $meta1 ) and $meta1->{filehash} ne "deleted" ) + } + elsif( defined($wrev) && $wrev ne "0" ) + { + my($rmRev)=$wrev; + $rmRev=~s/^-//; + $meta1 = $updater->getmeta($filename, $rmRev); + } + if ( !defined($meta1) || + $meta1->{filehash} eq "deleted" ) + { + if( !exists($state->{opt}{N}) ) { - print "E File $filename at revision $revision1 doesn't exist\n"; + if(!defined($revision1)) + { + print "E File $filename at revision $revision1 doesn't exist\n"; + } next; } - transmitfile($meta1->{filehash}, { targetfile => $file1 }); - } - # otherwise we just use the working copy revision - else - { - ( undef, $file1 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); - $meta1 = $updater->getmeta($filename, $wrev); - transmitfile($meta1->{filehash}, { targetfile => $file1 }); + elsif( !defined($meta1) ) + { + $meta1 = { + name => $filename, + revision => '0', + filehash => 'deleted' + }; + } } + # Priority for revision2: + # 1. Second -r (missing file: check -N) + # 2. Modified file contents from client + # 3. wrev from client's Entry line + # - missing line/file: check -N + # - Prefixed with dash (to be removed): check -N + # if we have a second -r switch, use it too if ( defined ( $revision2 ) ) { - ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); $meta2 = $updater->getmeta($filename, $revision2); - - unless ( defined ( $meta2 ) and $meta2->{filehash} ne "deleted" ) - { - print "E File $filename at revision $revision2 doesn't exist\n"; - next; - } - - transmitfile($meta2->{filehash}, { targetfile => $file2 }); } - # otherwise we just use the working copy - else + elsif(defined($state->{entries}{$filename}{modified_filename})) { $file2 = $state->{entries}{$filename}{modified_filename}; + $meta2 = { + name => $filename, + revision => '0', + filehash => 'modified' + }; } - - # if we have been given -r, and we don't have a $file2 yet, lets - # get one - if ( defined ( $revision1 ) and not defined ( $file2 ) ) + elsif( defined($wrev) && ($wrev!~/^-/) ) { - ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); + if(!defined($revision1)) # no revision and no modifications: + { + next; + } $meta2 = $updater->getmeta($filename, $wrev); - transmitfile($meta2->{filehash}, { targetfile => $file2 }); + } + if(!defined($file2)) + { + if ( !defined($meta2) || + $meta2->{filehash} eq "deleted" ) + { + if( !exists($state->{opt}{N}) ) + { + if(!defined($revision2)) + { + print "E File $filename at revision $revision2 doesn't exist\n"; + } + next; + } + elsif( !defined($meta2) ) + { + $meta2 = { + name => $filename, + revision => '0', + filehash => 'deleted' + }; + } + } } - # We need to have retrieved something useful - next unless ( defined ( $meta1 ) ); - - # Files to date if the working copy and repo copy have the same - # revision, and the working copy is unmodified - if ( not defined ( $meta2 ) and $wrev eq $meta1->{revision} and - ( ( $state->{entries}{$filename}{unchanged} and - ( not defined ( $state->{entries}{$filename}{conflict} ) or - $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or - ( defined($state->{entries}{$filename}{modified_hash}) and - $state->{entries}{$filename}{modified_hash} eq - $meta1->{filehash} ) ) ) + if( $meta1->{filehash} eq $meta2->{filehash} ) { + $log->info("unchanged $filename"); next; } - # Apparently we only show diffs for locally modified files - unless ( defined($meta2) or - defined ( $state->{entries}{$filename}{modified_filename} ) ) + # Retrieve revision contents: + ( undef, $file1 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); + transmitfile($meta1->{filehash}, { targetfile => $file1 }); + + if(!defined($file2)) { - next; + ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); + transmitfile($meta2->{filehash}, { targetfile => $file2 }); } - print "M Index: $filename\n"; + # Generate the actual diff: + print "M Index: $argFilename\n"; print "M =======" . ( "=" x 60 ) . "\n"; print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n"; - if ( defined ( $meta1 ) ) + if ( defined ( $meta1 ) && $meta1->{revision} ne "0" ) { print "M retrieving revision $meta1->{revision}\n" } - if ( defined ( $meta2 ) ) + if ( defined ( $meta2 ) && $meta2->{revision} ne "0" ) { print "M retrieving revision $meta2->{revision}\n" } @@ -1852,33 +2140,73 @@ sub req_diff } } } - print "$filename\n"; + print "$argFilename\n"; $log->info("Diffing $filename -r $meta1->{revision} -r " . ( $meta2->{revision} or "workingcopy" )); - ( $fh, $filediff ) = tempfile ( DIR => $TEMP_DIR ); - - if ( exists $state->{opt}{u} ) + # TODO: Use --label instead of -L because -L is no longer + # documented and may go away someday. Not sure if there there are + # versions that only support -L, which would make this change risky? + # http://osdir.com/ml/bug-gnu-utils-gnu/2010-12/msg00060.html + # ("man diff" should actually document the best migration strategy, + # [current behavior, future changes, old compatibility issues + # or lack thereof, etc], not just stop mentioning the option...) + # TODO: Real CVS seems to include a date in the label, before + # the revision part, without the keyword "revision". The following + # has minimal changes compared to original versions of + # git-cvsserver.perl. (Mostly tab vs space after filename.) + + my (@diffCmd) = ( 'diff' ); + if ( exists($state->{opt}{N}) ) { - system("diff -u -L '$filename revision $meta1->{revision}'" . - " -L '$filename " . - ( defined($meta2->{revision}) ? - "revision $meta2->{revision}" : - "working copy" ) . - "' $file1 $file2 > $filediff" ); - } else { - system("diff $file1 $file2 > $filediff"); + push @diffCmd,"-N"; } + if ( exists $state->{opt}{u} ) + { + push @diffCmd,("-u","-L"); + if( $meta1->{filehash} eq "deleted" ) + { + push @diffCmd,"/dev/null"; + } else { + push @diffCmd,("$argFilename\trevision $meta1->{revision}"); + } - while ( <$fh> ) + if( defined($meta2->{filehash}) ) + { + if( $meta2->{filehash} eq "deleted" ) + { + push @diffCmd,("-L","/dev/null"); + } else { + push @diffCmd,("-L", + "$argFilename\trevision $meta2->{revision}"); + } + } else { + push @diffCmd,("-L","$argFilename\tworking copy"); + } + } + push @diffCmd,($file1,$file2); + if(!open(DIFF,"-|",@diffCmd)) { - print "M $_"; + $log->warn("Unable to run diff: $!"); } - close $fh; + my($diffLine); + while(defined($diffLine=<DIFF>)) + { + print "M $diffLine"; + $foundDiff=1; + } + close(DIFF); } - print "ok\n"; + if($foundDiff) + { + print "error \n"; + } + else + { + print "ok\n"; + } } sub req_log @@ -2098,7 +2426,7 @@ sub argsplit $opt = { A => 0, N => 0, P => 0, R => 0, c => 0, f => 0, l => 0, n => 0, p => 0, s => 0, r => 1, D => 1, d => 1, k => 1, j => 1, } if ( $type eq "co" ); $opt = { v => 0, l => 0, R => 0 } if ( $type eq "status" ); $opt = { A => 0, P => 0, C => 0, d => 0, f => 0, l => 0, R => 0, p => 0, k => 1, r => 1, D => 1, j => 1, I => 1, W => 1 } if ( $type eq "update" ); - $opt = { l => 0, R => 0, k => 1, D => 1, D => 1, r => 2 } if ( $type eq "diff" ); + $opt = { l => 0, R => 0, k => 1, D => 1, D => 1, r => 2, N => 0 } if ( $type eq "diff" ); $opt = { c => 0, R => 0, l => 0, f => 0, F => 1, m => 1, r => 1 } if ( $type eq "ci" ); $opt = { k => 1, m => 1 } if ( $type eq "add" ); $opt = { f => 0, l => 0, R => 0 } if ( $type eq "remove" ); @@ -2164,62 +2492,335 @@ sub argsplit } } -# This method uses $state->{directory} to populate $state->{args} with a list of filenames -sub argsfromdir +# Used by argsfromdir +sub expandArg { - my $updater = shift; + my ($updater,$outNameMap,$outDirMap,$path,$isDir) = @_; - $state->{args} = [] if ( scalar(@{$state->{args}}) == 1 and $state->{args}[0] eq "." ); + my $fullPath = filecleanup($path); - return if ( scalar ( @{$state->{args}} ) > 1 ); + # Is it a directory? + if( defined($state->{dirMap}{$fullPath}) || + defined($state->{dirMap}{"$fullPath/"}) ) + { + # It is a directory in the user's sandbox. + $isDir=1; - my @gethead = @{$updater->gethead}; + if(defined($state->{entries}{$fullPath})) + { + $log->fatal("Inconsistent file/dir type"); + die "Inconsistent file/dir type"; + } + } + elsif(defined($state->{entries}{$fullPath})) + { + # It is a file in the user's sandbox. + $isDir=0; + } + my($revDirMap,$otherRevDirMap); + if(!defined($isDir) || $isDir) + { + # Resolve version tree for sticky tag: + # (for now we only want list of files for the version, not + # particular versions of those files: assume it is a directory + # for the moment; ignore Entry's stick tag) + + # Order of precedence of sticky tags: + # -A [head] + # -r /tag/ + # [file entry sticky tag, but that is only relevant to files] + # [the tag specified in dir req_Sticky] + # [the tag specified in a parent dir req_Sticky] + # [head] + # Also, -r may appear twice (for diff). + # + # FUTURE: When/if -j (merges) are supported, we also + # need to add relevant files from one or two + # versions specified with -j. + + if(exists($state->{opt}{A})) + { + $revDirMap=$updater->getRevisionDirMap(); + } + elsif( defined($state->{opt}{r}) and + ref $state->{opt}{r} eq "ARRAY" ) + { + $revDirMap=$updater->getRevisionDirMap($state->{opt}{r}[0]); + $otherRevDirMap=$updater->getRevisionDirMap($state->{opt}{r}[1]); + } + elsif(defined($state->{opt}{r})) + { + $revDirMap=$updater->getRevisionDirMap($state->{opt}{r}); + } + else + { + my($sticky)=getDirStickyInfo($fullPath); + $revDirMap=$updater->getRevisionDirMap($sticky->{tag}); + } - # push added files - foreach my $file (keys %{$state->{entries}}) { - if ( exists $state->{entries}{$file}{revision} && - $state->{entries}{$file}{revision} eq '0' ) - { - push @gethead, { name => $file, filehash => 'added' }; - } + # Is it a directory? + if( defined($revDirMap->{$fullPath}) || + defined($otherRevDirMap->{$fullPath}) ) + { + $isDir=1; + } } - if ( scalar(@{$state->{args}}) == 1 ) + # What to do with it? + if(!$isDir) + { + $outNameMap->{$fullPath}=1; + } + else { - my $arg = $state->{args}[0]; - $arg .= $state->{prependdir} if ( defined ( $state->{prependdir} ) ); + $outDirMap->{$fullPath}=1; - $log->info("Only one arg specified, checking for directory expansion on '$arg'"); + if(defined($revDirMap->{$fullPath})) + { + addDirMapFiles($updater,$outNameMap,$outDirMap, + $revDirMap->{$fullPath}); + } + if( defined($otherRevDirMap) && + defined($otherRevDirMap->{$fullPath}) ) + { + addDirMapFiles($updater,$outNameMap,$outDirMap, + $otherRevDirMap->{$fullPath}); + } + } +} + +# Used by argsfromdir +# Add entries from dirMap to outNameMap. Also recurse into entries +# that are subdirectories. +sub addDirMapFiles +{ + my($updater,$outNameMap,$outDirMap,$dirMap)=@_; - foreach my $file ( @gethead ) + my($fullName); + foreach $fullName (keys(%$dirMap)) + { + my $cleanName=$fullName; + if(defined($state->{prependdir})) { - next if ( $file->{filehash} eq "deleted" and not defined ( $state->{entries}{$file->{name}} ) ); - next unless ( $file->{name} =~ /^$arg\// or $file->{name} eq $arg ); - push @{$state->{args}}, $file->{name}; + if(!($cleanName=~s/^\Q$state->{prependdir}\E//)) + { + $log->fatal("internal error stripping prependdir"); + die "internal error stripping prependdir"; + } } - shift @{$state->{args}} if ( scalar(@{$state->{args}}) > 1 ); - } else { - $log->info("Only one arg specified, populating file list automatically"); + if($dirMap->{$fullName} eq "F") + { + $outNameMap->{$cleanName}=1; + } + elsif($dirMap->{$fullName} eq "D") + { + if(!$state->{opt}{l}) + { + expandArg($updater,$outNameMap,$outDirMap,$cleanName,1); + } + } + else + { + $log->fatal("internal error in addDirMapFiles"); + die "internal error in addDirMapFiles"; + } + } +} + +# This method replaces $state->{args} with a directory-expanded +# list of all relevant filenames (recursively unless -d), based +# on $state->{entries}, and the "current" list of files in +# each directory. "Current" files as determined by +# either the requested (-r/-A) or "req_Sticky" version of +# that directory. +# Both the input args and the new output args are relative +# to the cvs-client's CWD, although some of the internal +# computations are relative to the top of the project. +sub argsfromdir +{ + my $updater = shift; + + # Notes about requirements for specific callers: + # update # "standard" case (entries; a single -r/-A/default; -l) + # # Special case: -d for create missing directories. + # diff # 0 or 1 -r's: "standard" case. + # # 2 -r's: We could ignore entries (just use the two -r's), + # # but it doesn't really matter. + # annotate # "standard" case + # log # Punting: log -r has a more complex non-"standard" + # # meaning, and we don't currently try to support log'ing + # # branches at all (need a lot of work to + # # support CVS-consistent branch relative version + # # numbering). +#HERE: But we still want to expand directories. Maybe we should +# essentially force "-A". + # status # "standard", except that -r/-A/default are not possible. + # # Mostly only used to expand entries only) + # + # Don't use argsfromdir at all: + # add # Explicit arguments required. Directory args imply add + # # the directory itself, not the files in it. + # co # Obtain list directly. + # remove # HERE: TEST: MAYBE client does the recursion for us, + # # since it only makes sense to remove stuff already in + # # the sandobx? + # ci # HERE: Similar to remove... + # # Don't try to implement the confusing/weird + # # ci -r bug er.."feature". + + if(scalar(@{$state->{args}})==0) + { + $state->{args} = [ "." ]; + } + my %allArgs; + my %allDirs; + for my $file (@{$state->{args}}) + { + expandArg($updater,\%allArgs,\%allDirs,$file); + } + + # Include any entries from sandbox. Generally client won't + # send entries that shouldn't be used. + foreach my $file (keys %{$state->{entries}}) + { + $allArgs{remove_prependdir($file)} = 1; + } - $state->{args} = []; + $state->{dirArgs} = \%allDirs; + $state->{args} = [ + sort { + # Sort priority: by directory depth, then actual file name: + my @piecesA=split('/',$a); + my @piecesB=split('/',$b); - foreach my $file ( @gethead ) + my $count=scalar(@piecesA); + my $tmp=scalar(@piecesB); + return $count<=>$tmp if($count!=$tmp); + + for($tmp=0;$tmp<$count;$tmp++) + { + if($piecesA[$tmp] ne $piecesB[$tmp]) + { + return $piecesA[$tmp] cmp $piecesB[$tmp] + } + } + return 0; + } keys(%allArgs) ]; +} + +## look up directory sticky tag, of either fullPath or a parent: +sub getDirStickyInfo +{ + my($fullPath)=@_; + + $fullPath=~s%/+$%%; + while($fullPath ne "" && !defined($state->{dirMap}{"$fullPath/"})) + { + $fullPath=~s%/?[^/]*$%%; + } + + if( !defined($state->{dirMap}{"$fullPath/"}) && + ( $fullPath eq "" || + $fullPath eq "." ) ) + { + return $state->{dirMap}{""}{stickyInfo}; + } + else + { + return $state->{dirMap}{"$fullPath/"}{stickyInfo}; + } +} + +# Resolve precedence of various ways of specifying which version of +# a file you want. Returns undef (for default head), or a ref to a hash +# that contains "tag" and/or "date" keys. +sub resolveStickyInfo +{ + my($filename,$stickyTag,$stickyDate,$reset) = @_; + + # Order of precedence of sticky tags: + # -A [head] + # -r /tag/ + # [file entry sticky tag] + # [the tag specified in dir req_Sticky] + # [the tag specified in a parent dir req_Sticky] + # [head] + + my $result; + if($reset) + { + # $result=undef; + } + elsif( defined($stickyTag) && $stickyTag ne "" ) + # || ( defined($stickyDate) && $stickyDate ne "" ) # TODO + { + $result={ 'tag' => (defined($stickyTag)?$stickyTag:undef) }; + + # TODO: Convert -D value into the form 2011.04.10.04.46.57, + # similar to an entry line's sticky date, without the D prefix. + # It sometimes (always?) arrives as something more like + # '10 Apr 2011 04:46:57 -0000'... + # $result={ 'date' => (defined($stickyDate)?$stickyDate:undef) }; + } + elsif( defined($state->{entries}{$filename}) && + defined($state->{entries}{$filename}{tag_or_date}) && + $state->{entries}{$filename}{tag_or_date} ne "" ) + { + my($tagOrDate)=$state->{entries}{$filename}{tag_or_date}; + if($tagOrDate=~/^T([^ ]+)\s*$/) { - next if ( $file->{filehash} eq "deleted" and not defined ( $state->{entries}{$file->{name}} ) ); - next unless ( $file->{name} =~ s/^$state->{prependdir}// ); - push @{$state->{args}}, $file->{name}; + $result = { 'tag' => $1 }; + } + elsif($tagOrDate=~/^D([0-9.]+)\s*$/) + { + $result= { 'date' => $1 }; + } + else + { + die "Unknown tag_or_date format\n"; } } + else + { + $result=getDirStickyInfo($filename); + } + + return $result; +} + +# Convert a stickyInfo (ref to a hash) as returned by resolveStickyInfo into +# a form appropriate for the sticky tag field of an Entries +# line (field index 5, 0-based). +sub getStickyTagOrDate +{ + my($stickyInfo)=@_; + + my $result; + if(defined($stickyInfo) && defined($stickyInfo->{tag})) + { + $result="T$stickyInfo->{tag}"; + } + # TODO: When/if we actually pick versions by {date} properly, + # also handle it here: + # "D$stickyInfo->{date}" (example: "D2011.04.13.20.37.07"). + else + { + $result=""; + } + + return $result; } # This method cleans up the $state variable after a command that uses arguments has run sub statecleanup { $state->{files} = []; + $state->{dirArgs} = {}; $state->{args} = []; $state->{arguments} = []; $state->{entries} = {}; + $state->{dirMap} = {}; } # Return working directory CVS revision "1.X" out @@ -2309,6 +2910,9 @@ sub filenamesplit return ( $filepart, $dirpart ); } +# Cleanup various junk in filename (try to canonicalize it), and +# add prependdir to accomodate running CVS client from a +# subdirectory (so the output is relative to top directory of the project). sub filecleanup { my $filename = shift; @@ -2320,11 +2924,36 @@ sub filecleanup return undef; } + if($filename eq ".") + { + $filename=""; + } $filename =~ s/^\.\///g; + $filename =~ s%/+%/%g; $filename = $state->{prependdir} . $filename; + $filename =~ s%/$%%; return $filename; } +# Remove prependdir from the path, so that is is relative to the directory +# the CVS client was started from, rather than the top of the project. +# Essentially the inverse of filecleanup(). +sub remove_prependdir +{ + my($path) = @_; + if(defined($state->{prependdir}) && $state->{prependdir} ne "") + { + my($pre)=$state->{prependdir}; + $pre=~s%/$%%; + if(!($path=~s%^\Q$pre\E/?%%)) + { + $log->fatal("internal error missing prependdir"); + die("internal error missing prependdir"); + } + } + return $path; +} + sub validateGitDir { if( !defined($state->{CVSROOT}) ) @@ -2738,6 +3367,45 @@ sub descramble return $ret; } +# Test if the (deep) values of two references to a hash are the same. +sub refHashEqual +{ + my($v1,$v2) = @_; + + my $out; + if(!defined($v1)) + { + if(!defined($v2)) + { + $out=1; + } + } + elsif( !defined($v2) || + scalar(keys(%{$v1})) != scalar(keys(%{$v2})) ) + { + # $out=undef; + } + else + { + $out=1; + + my $key; + foreach $key (keys(%{$v1})) + { + if( !exists($v2->{$key}) || + defined($v1->{$key}) ne defined($v2->{$key}) || + ( defined($v1->{$key}) && + $v1->{$key} ne $v2->{$key} ) ) + { + $out=undef; + last; + } + } + } + + return $out; +} + package GITCVS::log; @@ -2958,6 +3626,9 @@ sub new die "Git repo '$self->{git_path}' doesn't exist" unless ( -d $self->{git_path} ); + # Stores full sha1's for various branch/tag names, abbreviations, etc: + $self->{commitRefCache} = {}; + $self->{dbdriver} = $cfg->{gitcvs}{$state->{method}}{dbdriver} || $cfg->{gitcvs}{dbdriver} || "SQLite"; $self->{dbname} = $cfg->{gitcvs}{$state->{method}}{dbname} || @@ -3140,6 +3811,8 @@ sub update my $lastcommit = $self->_get_prop("last_commit"); if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date + # invalidate the gethead cache + $self->clearCommitRefCaches(); return 1; } @@ -3157,45 +3830,10 @@ sub update push @git_log_params, $self->{module}; } # git-rev-list is the backend / plumbing version of git-log - open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die "Cannot call git-rev-list: $!"; - - my @commits; - - my %commit = (); - - while ( <GITLOG> ) - { - chomp; - if (m/^commit\s+(.*)$/) { - # on ^commit lines put the just seen commit in the stack - # and prime things for the next one - if (keys %commit) { - my %copy = %commit; - unshift @commits, \%copy; - %commit = (); - } - my @parents = split(m/\s+/, $1); - $commit{hash} = shift @parents; - $commit{parents} = \@parents; - } elsif (m/^(\w+?):\s+(.*)$/ && !exists($commit{message})) { - # on rfc822-like lines seen before we see any message, - # lowercase the entry and put it in the hash as key-value - $commit{lc($1)} = $2; - } else { - # message lines - skip initial empty line - # and trim whitespace - if (!exists($commit{message}) && m/^\s*$/) { - # define it to mark the end of headers - $commit{message} = ''; - next; - } - s/^\s+//; s/\s+$//; # trim ws - $commit{message} .= $_ . "\n"; - } - } - close GITLOG; - - unshift @commits, \%commit if ( keys %commit ); + open(my $gitLogPipe, '-|', 'git', 'rev-list', @git_log_params) + or die "Cannot call git-rev-list: $!"; + my @commits=readCommits($gitLogPipe); + close $gitLogPipe; # Now all the commits are in the @commits bucket # ordered by time DESC. for each commit that needs processing, @@ -3294,7 +3932,7 @@ sub update } # convert the date to CVS-happy format - $commit->{date} = "$2 $1 $4 $3 $5" if ( $commit->{date} =~ /^\w+\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)\s+([+-]\d+)$/ ); + my $cvsDate = convertToCvsDate($commit->{date}); if ( defined ( $lastpicked ) ) { @@ -3303,7 +3941,7 @@ sub update while ( <FILELIST> ) { chomp; - unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)$/o ) + unless ( /^:\d{6}\s+([0-7]{6})\s+[a-f0-9]{40}\s+([a-f0-9]{40})\s+(\w)$/o ) { die("Couldn't process git-diff-tree line : $_"); } @@ -3313,11 +3951,7 @@ sub update # $log->debug("File mode=$mode, hash=$hash, change=$change, name=$name"); - my $git_perms = ""; - $git_perms .= "r" if ( $mode & 4 ); - $git_perms .= "w" if ( $mode & 2 ); - $git_perms .= "x" if ( $mode & 1 ); - $git_perms = "rw" if ( $git_perms eq "" ); + my $dbMode = convertToDbMode($mode); if ( $change eq "D" ) { @@ -3327,11 +3961,11 @@ sub update revision => $head->{$name}{revision} + 1, filehash => "deleted", commithash => $commit->{hash}, - modified => $commit->{date}, + modified => $cvsDate, author => $commit->{author}, - mode => $git_perms, + mode => $dbMode, }; - $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode); } elsif ( $change eq "M" || $change eq "T" ) { @@ -3341,11 +3975,11 @@ sub update revision => $head->{$name}{revision} + 1, filehash => $hash, commithash => $commit->{hash}, - modified => $commit->{date}, + modified => $cvsDate, author => $commit->{author}, - mode => $git_perms, + mode => $dbMode, }; - $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode); } elsif ( $change eq "A" ) { @@ -3355,11 +3989,11 @@ sub update revision => $head->{$name}{revision} ? $head->{$name}{revision}+1 : 1, filehash => $hash, commithash => $commit->{hash}, - modified => $commit->{date}, + modified => $cvsDate, author => $commit->{author}, - mode => $git_perms, + mode => $dbMode, }; - $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode); } else { @@ -3382,7 +4016,7 @@ sub update die("Couldn't process git-ls-tree line : $_"); } - my ( $git_perms, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 ); + my ( $mode, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 ); $seen_files->{$git_filename} = 1; @@ -3392,18 +4026,10 @@ sub update $head->{$git_filename}{mode} ); - if ( $git_perms =~ /^\d\d\d(\d)\d\d/o ) - { - $git_perms = ""; - $git_perms .= "r" if ( $1 & 4 ); - $git_perms .= "w" if ( $1 & 2 ); - $git_perms .= "x" if ( $1 & 1 ); - } else { - $git_perms = "rw"; - } + my $dbMode = convertToDbMode($mode); # unless the file exists with the same hash, we need to update it ... - unless ( defined($oldhash) and $oldhash eq $git_hash and defined($oldmode) and $oldmode eq $git_perms ) + unless ( defined($oldhash) and $oldhash eq $git_hash and defined($oldmode) and $oldmode eq $dbMode ) { my $newrevision = ( $oldrevision or 0 ) + 1; @@ -3412,13 +4038,13 @@ sub update revision => $newrevision, filehash => $git_hash, commithash => $commit->{hash}, - modified => $commit->{date}, + modified => $cvsDate, author => $commit->{author}, - mode => $git_perms, + mode => $dbMode, }; - $self->insert_rev($git_filename, $newrevision, $git_hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($git_filename, $newrevision, $git_hash, $commit->{hash}, $cvsDate, $commit->{author}, $dbMode); } } close FILELIST; @@ -3431,10 +4057,10 @@ sub update $head->{$file}{revision}++; $head->{$file}{filehash} = "deleted"; $head->{$file}{commithash} = $commit->{hash}; - $head->{$file}{modified} = $commit->{date}; + $head->{$file}{modified} = $cvsDate; $head->{$file}{author} = $commit->{author}; - $self->insert_rev($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $commit->{date}, $commit->{author}, $head->{$file}{mode}); + $self->insert_rev($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $cvsDate, $commit->{author}, $head->{$file}{mode}); } } # END : "Detect deleted files" @@ -3465,13 +4091,94 @@ sub update ); } # invalidate the gethead cache - $self->{gethead_cache} = undef; + $self->clearCommitRefCaches(); # Ending exclusive lock here $self->{dbh}->commit() or die "Failed to commit changes to SQLite"; } +sub readCommits +{ + my $pipeHandle = shift; + my @commits; + + my %commit = (); + + while ( <$pipeHandle> ) + { + chomp; + if (m/^commit\s+(.*)$/) { + # on ^commit lines put the just seen commit in the stack + # and prime things for the next one + if (keys %commit) { + my %copy = %commit; + unshift @commits, \%copy; + %commit = (); + } + my @parents = split(m/\s+/, $1); + $commit{hash} = shift @parents; + $commit{parents} = \@parents; + } elsif (m/^(\w+?):\s+(.*)$/ && !exists($commit{message})) { + # on rfc822-like lines seen before we see any message, + # lowercase the entry and put it in the hash as key-value + $commit{lc($1)} = $2; + } else { + # message lines - skip initial empty line + # and trim whitespace + if (!exists($commit{message}) && m/^\s*$/) { + # define it to mark the end of headers + $commit{message} = ''; + next; + } + s/^\s+//; s/\s+$//; # trim ws + $commit{message} .= $_ . "\n"; + } + } + + unshift @commits, \%commit if ( keys %commit ); + + return @commits; +} + +sub convertToCvsDate +{ + my $date = shift; + # Convert from: "git rev-list --pretty" formatted date + # Convert to: "the format specified by RFC822 as modified by RFC1123." + # Example: 26 May 1997 13:01:40 -0400 + if( $date =~ /^\w+\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)\s+([+-]\d+)$/ ) + { + $date = "$2 $1 $4 $3 $5"; + } + + return $date; +} + +sub convertToDbMode +{ + my $mode = shift; + + # NOTE: The CVS protocol uses a string similar "u=rw,g=rw,o=rw", + # but the database "mode" column historically (and currently) + # only stores the "rw" (for user) part of the string. + # FUTURE: It might make more sense to persist the raw + # octal mode (or perhaps the final full CVS form) instead of + # this half-converted form, but it isn't currently worth the + # backwards compatibility headaches. + + $mode=~/^\d\d(\d)\d{3}$/; + my $userBits=$1; + + my $dbMode = ""; + $dbMode .= "r" if ( $userBits & 4 ); + $dbMode .= "w" if ( $userBits & 2 ); + $dbMode .= "x" if ( $userBits & 1 ); + $dbMode = "rw" if ( $dbMode eq "" ); + + return $dbMode; +} + sub insert_rev { my $self = shift; @@ -3586,6 +4293,169 @@ sub gethead return $tree; } +=head2 getAnyHead + +Returns a reference to an array of getmeta structures, one +per file in the specified tree hash. + +=cut + +sub getAnyHead +{ + my ($self,$hash) = @_; + + if(!defined($hash)) + { + return $self->gethead(); + } + + my @files; + { + open(my $filePipe, '-|', 'git', 'ls-tree', '-z', '-r', $hash) + or die("Cannot call git-ls-tree : $!"); + local $/ = "\0"; + @files=<$filePipe>; + close $filePipe; + } + + my $tree=[]; + my($line); + foreach $line (@files) + { + $line=~s/\0$//; + unless ( $line=~/^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o ) + { + die("Couldn't process git-ls-tree line : $_"); + } + + my($mode, $git_type, $git_hash, $git_filename) = ($1, $2, $3, $4); + push @$tree, $self->getMetaFromCommithash($git_filename,$hash); + } + + return $tree; +} + +=head2 getRevisionDirMap + +A "revision dir map" contains all the plain-file filenames associated +with a particular revision (treeish), organized by directory: + + $type = $out->{$dir}{$fullName} + +The type of each is "F" (for ordinary file) or "D" (for directory, +for which the map $out->{$fullName} will also exist). + +=cut + +sub getRevisionDirMap +{ + my ($self,$ver)=@_; + + if(!defined($self->{revisionDirMapCache})) + { + $self->{revisionDirMapCache}={}; + } + + # Get file list (previously cached results are dependent on HEAD, + # but are early in each case): + my $cacheKey; + my (@fileList); + if( !defined($ver) || $ver eq "" ) + { + $cacheKey=""; + if( defined($self->{revisionDirMapCache}{$cacheKey}) ) + { + return $self->{revisionDirMapCache}{$cacheKey}; + } + + my @head = @{$self->gethead()}; + foreach my $file ( @head ) + { + next if ( $file->{filehash} eq "deleted" ); + + push @fileList,$file->{name}; + } + } + else + { + my ($hash)=$self->lookupCommitRef($ver); + if( !defined($hash) ) + { + return undef; + } + + $cacheKey=$hash; + if( defined($self->{revisionDirMapCache}{$cacheKey}) ) + { + return $self->{revisionDirMapCache}{$cacheKey}; + } + + open(my $filePipe, '-|', 'git', 'ls-tree', '-z', '-r', $hash) + or die("Cannot call git-ls-tree : $!"); + local $/ = "\0"; + while ( <$filePipe> ) + { + chomp; + unless ( /^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o ) + { + die("Couldn't process git-ls-tree line : $_"); + } + + my($mode, $git_type, $git_hash, $git_filename) = ($1, $2, $3, $4); + + push @fileList, $git_filename; + } + close $filePipe; + } + + # Convert to normalized form: + my %revMap; + my $file; + foreach $file (@fileList) + { + my($dir) = ($file=~m%^(?:(.*)/)?([^/]*)$%); + $dir='' if(!defined($dir)); + + # parent directories: + # ... create empty dir maps for parent dirs: + my($td)=$dir; + while(!defined($revMap{$td})) + { + $revMap{$td}={}; + + my($tp)=($td=~m%^(?:(.*)/)?([^/]*)$%); + $tp='' if(!defined($tp)); + $td=$tp; + } + # ... add children to parent maps (now that they exist): + $td=$dir; + while($td ne "") + { + my($tp)=($td=~m%^(?:(.*)/)?([^/]*)$%); + $tp='' if(!defined($tp)); + + if(defined($revMap{$tp}{$td})) + { + if($revMap{$tp}{$td} ne 'D') + { + die "Weird file/directory inconsistency in $cacheKey"; + } + last; # loop exit + } + $revMap{$tp}{$td}='D'; + + $td=$tp; + } + + # file + $revMap{$dir}{$file}='F'; + } + + # Save in cache: + $self->{revisionDirMapCache}{$cacheKey}=\%revMap; + return $self->{revisionDirMapCache}{$cacheKey}; +} + =head2 getlog See also gethistorydense(). @@ -3646,6 +4516,19 @@ sub getlog This function takes a filename (with path) argument and returns a hashref of metadata for that file. +There are several ways $revision can be specified: + + - A reference to hash that contains a "tag" that is the + actual revision (one of the below). TODO: Also allow it to + specify a "date" in the hash. + - undef, to refer to the latest version on the main branch. + - Full CVS client revision number (mapped to integer in DB, without the + "1." prefix), + - Complex CVS-compatible "special" revision number for + non-linear history (see comment below) + - git commit sha1 hash + - branch or tag name + =cut sub getmeta @@ -3656,23 +4539,144 @@ sub getmeta my $tablename_rev = $self->tablename("revision"); my $tablename_head = $self->tablename("head"); - my $db_query; - if ( defined($revision) and $revision =~ /^1\.(\d+)$/ ) + if ( ref($revision) eq "HASH" ) { - my ($intRev) = $1; - $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_rev WHERE name=? AND revision=?",{},1); - $db_query->execute($filename, $intRev); + $revision = $revision->{tag}; } - elsif ( defined($revision) and $revision =~ /^[a-zA-Z0-9]{40}$/ ) + + # Overview of CVS revision numbers: + # + # General CVS numbering scheme: + # - Basic mainline branch numbers: "1.1", "1.2", "1.3", etc. + # - Result of "cvs checkin -r" (possible, but not really + # recommended): "2.1", "2.2", etc + # - Branch tag: "1.2.0.n", where "1.2" is revision it was branched + # from, "0" is a magic placeholder that identifies it as a + # branch tag instead of a version tag, and n is 2 times the + # branch number off of "1.2", starting with "2". + # - Version on a branch: "1.2.n.x", where "1.2" is branch-from, "n" + # is branch number off of "1.2" (like n above), and "x" is + # the version number on the branch. + # - Branches can branch off of branches: "1.3.2.7.4.1" (even number + # of components). + # - Odd "n"s are used by "vendor branches" that result + # from "cvs import". Vendor branches have additional + # strangeness in the sense that the main rcs "head" of the main + # branch will (temporarily until first normal commit) point + # to the version on the vendor branch, rather than the actual + # main branch. (FUTURE: This may provide an opportunity + # to use "strange" revision numbers for fast-forward-merged + # branch tip when CVS client is asking for the main branch.) + # + # git-cvsserver CVS-compatible special numbering schemes: + # - Currently git-cvsserver only tries to be identical to CVS for + # simple "1.x" numbers on the "main" branch (as identified + # by the module name that was originally cvs checkout'ed). + # - The database only stores the "x" part, for historical reasons. + # But most of the rest of the cvsserver preserves + # and thinks using the full revision number. + # - To handle non-linear history, it uses a version of the form + # "2.1.1.2000.b.b.b."..., where the 2.1.1.2000 is to help uniquely + # identify this as a special revision number, and there are + # 20 b's that together encode the sha1 git commit from which + # this version of this file originated. Each b is + # the numerical value of the corresponding byte plus + # 100. + # - "plus 100" avoids "0"s, and also reduces the + # likelyhood of a collision in the case that someone someday + # writes an import tool that tries to preserve original + # CVS revision numbers, and the original CVS data had done + # lots of branches off of branches and other strangeness to + # end up with a real version number that just happens to look + # like this special revision number form. Also, if needed + # there are several ways to extend/identify alternative encodings + # within the "2.1.1.2000" part if necessary. + # - Unlike real CVS revisions, you can't really reconstruct what + # relation a revision of this form has to other revisions. + # - FUTURE: TODO: Rework database somehow to make up and remember + # fully-CVS-compatible branches and branch version numbers. + + my $meta; + if ( defined($revision) ) { - $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_rev WHERE name=? AND commithash=?",{},1); - $db_query->execute($filename, $revision); - } else { - $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_head WHERE name=?",{},1); + if ( $revision =~ /^1\.(\d+)$/ ) + { + my ($intRev) = $1; + my $db_query; + $db_query = $self->{dbh}->prepare_cached( + "SELECT * FROM $tablename_rev WHERE name=? AND revision=?", + {},1); + $db_query->execute($filename, $intRev); + $meta = $db_query->fetchrow_hashref; + } + elsif ( $revision =~ /^2\.1\.1\.2000(\.[1-3][0-9][0-9]){20}$/ ) + { + my ($commitHash)=($revision=~/^2\.1\.1\.2000(.*)$/); + $commitHash=~s/\.([0-9]+)/sprintf("%02x",$1-100)/eg; + if($commitHash=~/^[0-9a-f]{40}$/) + { + return $self->getMetaFromCommithash($filename,$commitHash); + } + + # error recovery: fall back on head version below + print "E Failed to find $filename version=$revision or commit=$commitHash\n"; + $log->warning("failed get $revision with commithash=$commitHash"); + undef $revision; + } + elsif ( $revision =~ /^[0-9a-f]{40}$/ ) + { + # Try DB first. This is mostly only useful for req_annotate(), + # which only calls this for stuff that should already be in + # the DB. It is fairly likely to be a waste of time + # in most other cases [unless the file happened to be + # modified in $revision specifically], but + # it is probably in the noise compared to how long + # getMetaFromCommithash() will take. + my $db_query; + $db_query = $self->{dbh}->prepare_cached( + "SELECT * FROM $tablename_rev WHERE name=? AND commithash=?", + {},1); + $db_query->execute($filename, $revision); + $meta = $db_query->fetchrow_hashref; + + if(! $meta) + { + my($revCommit)=$self->lookupCommitRef($revision); + if($revCommit=~/^[0-9a-f]{40}$/) + { + return $self->getMetaFromCommithash($filename,$revCommit); + } + + # error recovery: nothing found: + print "E Failed to find $filename version=$revision\n"; + $log->warning("failed get $revision"); + return $meta; + } + } + else + { + my($revCommit)=$self->lookupCommitRef($revision); + if($revCommit=~/^[0-9a-f]{40}$/) + { + return $self->getMetaFromCommithash($filename,$revCommit); + } + + # error recovery: fall back on head version below + print "E Failed to find $filename version=$revision\n"; + $log->warning("failed get $revision"); + undef $revision; # Allow fallback + } + } + + if(!defined($revision)) + { + my $db_query; + $db_query = $self->{dbh}->prepare_cached( + "SELECT * FROM $tablename_head WHERE name=?",{},1); $db_query->execute($filename); + $meta = $db_query->fetchrow_hashref; } - my $meta = $db_query->fetchrow_hashref; if($meta) { $meta->{revision} = "1.$meta->{revision}"; @@ -3680,6 +4684,204 @@ sub getmeta return $meta; } +sub getMetaFromCommithash +{ + my $self = shift; + my $filename = shift; + my $revCommit = shift; + + # NOTE: This function doesn't scale well (lots of forks), especially + # if you have many files that have not been modified for many commits + # (each git-rev-parse redoes a lot of work for each file + # that theoretically could be done in parallel by smarter + # graph traversal). + # + # TODO: Possible optimization strategies: + # - Solve the issue of assigning and remembering "real" CVS + # revision numbers for branches, and ensure the + # data structure can do this efficiently. Perhaps something + # similar to "git notes", and carefully structured to take + # advantage same-sha1-is-same-contents, to roll the same + # unmodified subdirectory data onto multiple commits? + # - Write and use a C tool that is like git-blame, but + # operates on multiple files with file granularity, instead + # of one file with line granularity. Cache + # most-recently-modified in $self->{commitRefCache}{$revCommit}. + # Try to be intelligent about how many files we do with + # one fork (perhaps one directory at a time, without recursion, + # and/or include directory as one line item, recurse from here + # instead of in C tool?). + # - Perhaps we could ask the DB for (filename,fileHash), + # and just guess that it is correct (that the file hadn't + # changed between $revCommit and the found commit, then + # changed back, confusing anything trying to interpret + # history). Probably need to add another index to revisions + # DB table for this. + # - NOTE: Trying to store all (commit,file) keys in DB [to + # find "lastModfiedCommit] (instead of + # just files that changed in each commit as we do now) is + # probably not practical from a disk space perspective. + + # Does the file exist in $revCommit? + # TODO: Include file hash in dirmap cache. + my($dirMap)=$self->getRevisionDirMap($revCommit); + my($dir,$file)=($filename=~m%^(?:(.*)/)?([^/]*$)%); + if(!defined($dir)) + { + $dir=""; + } + if( !defined($dirMap->{$dir}) || + !defined($dirMap->{$dir}{$filename}) ) + { + my($fileHash)="deleted"; + + my($retVal)={}; + $retVal->{name}=$filename; + $retVal->{filehash}=$fileHash; + + # not needed and difficult to compute: + $retVal->{revision}="0"; # $revision; + $retVal->{commithash}=$revCommit; + #$retVal->{author}=$commit->{author}; + #$retVal->{modified}=convertToCvsDate($commit->{date}); + #$retVal->{mode}=convertToDbMode($mode); + + return $retVal; + } + + my($fileHash)=safe_pipe_capture("git","rev-parse","$revCommit:$filename"); + chomp $fileHash; + if(!($fileHash=~/^[0-9a-f]{40}$/)) + { + die "Invalid fileHash '$fileHash' looking up" + ." '$revCommit:$filename'\n"; + } + + # information about most recent commit to modify $filename: + open(my $gitLogPipe, '-|', 'git', 'rev-list', + '--max-count=1', '--pretty', '--parents', + $revCommit, '--', $filename) + or die "Cannot call git-rev-list: $!"; + my @commits=readCommits($gitLogPipe); + close $gitLogPipe; + if(scalar(@commits)!=1) + { + die "Can't find most recent commit changing $filename\n"; + } + my($commit)=$commits[0]; + if( !defined($commit) || !defined($commit->{hash}) ) + { + return undef; + } + + # does this (commit,file) have a real assigned CVS revision number? + my $tablename_rev = $self->tablename("revision"); + my $db_query; + $db_query = $self->{dbh}->prepare_cached( + "SELECT * FROM $tablename_rev WHERE name=? AND commithash=?", + {},1); + $db_query->execute($filename, $commit->{hash}); + my($meta)=$db_query->fetchrow_hashref; + if($meta) + { + $meta->{revision} = "1.$meta->{revision}"; + return $meta; + } + + # fall back on special revision number + my($revision)=$commit->{hash}; + $revision=~s/(..)/'.' . (hex($1)+100)/eg; + $revision="2.1.1.2000$revision"; + + # meta data about $filename: + open(my $filePipe, '-|', 'git', 'ls-tree', '-z', + $commit->{hash}, '--', $filename) + or die("Cannot call git-ls-tree : $!"); + local $/ = "\0"; + my $line; + $line=<$filePipe>; + if(defined(<$filePipe>)) + { + die "Expected only a single file for git-ls-tree $filename\n"; + } + close $filePipe; + + chomp $line; + unless ( $line=~m/^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o ) + { + die("Couldn't process git-ls-tree line : $line\n"); + } + my ( $mode, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 ); + + # save result: + my($retVal)={}; + $retVal->{name}=$filename; + $retVal->{revision}=$revision; + $retVal->{filehash}=$fileHash; + $retVal->{commithash}=$revCommit; + $retVal->{author}=$commit->{author}; + $retVal->{modified}=convertToCvsDate($commit->{date}); + $retVal->{mode}=convertToDbMode($mode); + + return $retVal; +} + +=head2 lookupCommitRef + +Convert tag/branch/abbreviation/etc into a commit sha1 hash. Caches +the result so looking it up again is fast. + +=cut + +sub lookupCommitRef +{ + my $self = shift; + my $ref = shift; + + my $commitHash = $self->{commitRefCache}{$ref}; + if(defined($commitHash)) + { + return $commitHash; + } + + $commitHash=safe_pipe_capture("git","rev-parse","--verify","--quiet", + $self->unescapeRefName($ref)); + $commitHash=~s/\s*$//; + if(!($commitHash=~/^[0-9a-f]{40}$/)) + { + $commitHash=undef; + } + + if( defined($commitHash) ) + { + my $type=safe_pipe_capture("git","cat-file","-t",$commitHash); + if( ! ($type=~/^commit\s*$/ ) ) + { + $commitHash=undef; + } + } + if(defined($commitHash)) + { + $self->{commitRefCache}{$ref}=$commitHash; + } + return $commitHash; +} + +=head2 clearCommitRefCaches + +Clears cached commit cache (sha1's for various tags/abbeviations/etc), +and related caches. + +=cut + +sub clearCommitRefCaches +{ + my $self = shift; + $self->{commitRefCache} = {}; + $self->{revisionDirMapCache} = undef; + $self->{gethead_cache} = undef; +} + =head2 commitmessage this function takes a commithash and returns the commit message for that commit @@ -3745,6 +4947,97 @@ sub gethistorydense return $result; } +=head2 escapeRefName + +Apply an escape mechanism to compensate for characters that +git ref names can have that CVS tags can not. + +=cut +sub escapeRefName +{ + my($self,$refName)=@_; + + # CVS officially only allows [-_A-Za-z0-9] in tag names (or in + # many contexts it can also be a CVS revision number). + # + # Git tags commonly use '/' and '.' as well, but also handle + # anything else just in case: + # + # = "_-s-" For '/'. + # = "_-p-" For '.'. + # = "_-u-" For underscore, in case someone wants a literal "_-" in + # a tag name. + # = "_-xx-" Where "xx" is the hexadecimal representation of the + # desired ASCII character byte. (for anything else) + + if(! $refName=~/^[1-9][0-9]*(\.[1-9][0-9]*)*$/) + { + $refName=~s/_-/_-u--/g; + $refName=~s/\./_-p-/g; + $refName=~s%/%_-s-%g; + $refName=~s/[^-_a-zA-Z0-9]/sprintf("_-%02x-",$1)/eg; + } +} + +=head2 unescapeRefName + +Undo an escape mechanism to compensate for characters that +git ref names can have that CVS tags can not. + +=cut +sub unescapeRefName +{ + my($self,$refName)=@_; + + # see escapeRefName() for description of escape mechanism. + + $refName=~s/_-([spu]|[0-9a-f][0-9a-f])-/unescapeRefNameChar($1)/eg; + + # allowed tag names + # TODO: Perhaps use git check-ref-format, with an in-process cache of + # validated names? + if( !( $refName=~m%^[^-][-a-zA-Z0-9_/.]*$% ) || + ( $refName=~m%[/.]$% ) || + ( $refName=~/\.lock$/ ) || + ( $refName=~m%\.\.|/\.|[[\\:?*~]|\@\{% ) ) # matching } + { + # Error: + $log->warn("illegal refName: $refName"); + $refName=undef; + } + return $refName; +} + +sub unescapeRefNameChar +{ + my($char)=@_; + + if($char eq "s") + { + $char="/"; + } + elsif($char eq "p") + { + $char="."; + } + elsif($char eq "u") + { + $char="_"; + } + elsif($char=~/^[0-9a-f][0-9a-f]$/) + { + $char=chr(hex($char)); + } + else + { + # Error case: Maybe it has come straight from user, and + # wasn't supposed to be escaped? Restore it the way we got it: + $char="_-$char-"; + } + + return $char; +} + =head2 in_array() from Array::PAT - mimics the in_array() function diff --git a/git-difftool.perl b/git-difftool.perl index edd0493a08..0a90de4146 100755 --- a/git-difftool.perl +++ b/git-difftool.perl @@ -59,57 +59,16 @@ sub find_worktree return $worktree; } -sub filter_tool_scripts -{ - my ($tools) = @_; - if (-d $_) { - if ($_ ne ".") { - # Ignore files in subdirectories - $File::Find::prune = 1; - } - } else { - if ((-f $_) && ($_ ne "defaults")) { - push(@$tools, $_); - } - } -} - sub print_tool_help { - my ($cmd, @found, @notfound, @tools); - my $gitpath = Git::exec_path(); - - find(sub { filter_tool_scripts(\@tools) }, "$gitpath/mergetools"); - - foreach my $tool (@tools) { - $cmd = "TOOL_MODE=diff"; - $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"'; - $cmd .= " && get_merge_tool_path $tool >/dev/null 2>&1"; - $cmd .= " && can_diff >/dev/null 2>&1"; - if (system('sh', '-c', $cmd) == 0) { - push(@found, $tool); - } else { - push(@notfound, $tool); - } - } - - print << 'EOF'; -'git difftool --tool=<tool>' may be set to one of the following: -EOF - print "\t$_\n" for (sort(@found)); + my $cmd = 'TOOL_MODE=diff'; + $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"'; + $cmd .= ' && show_tool_help'; - print << 'EOF'; - -The following tools are valid, but not currently available: -EOF - print "\t$_\n" for (sort(@notfound)); - - print << 'EOF'; - -NOTE: Some of the tools listed above only work in a windowed -environment. If run in a terminal-only session, they will fail. -EOF - exit(0); + # See the comment at the bottom of file_diff() for the reason behind + # using system() followed by exit() instead of exec(). + my $rc = system('sh', '-c', $cmd); + exit($rc | ($rc >> 8)); } sub exit_cleanup diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index f013a03506..e338be5e57 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -1,5 +1,83 @@ #!/bin/sh # git-mergetool--lib is a library for common merge tool functions + +: ${MERGE_TOOLS_DIR=$(git --exec-path)/mergetools} + +mode_ok () { + if diff_mode + then + can_diff + elif merge_mode + then + can_merge + else + false + fi +} + +is_available () { + merge_tool_path=$(translate_merge_tool_path "$1") && + type "$merge_tool_path" >/dev/null 2>&1 +} + +list_config_tools () { + section=$1 + line_prefix=${2:-} + + git config --get-regexp $section'\..*\.cmd' | + while read -r key value + do + toolname=${key#$section.} + toolname=${toolname%.cmd} + + printf "%s%s\n" "$line_prefix" "$toolname" + done +} + +show_tool_names () { + condition=${1:-true} per_line_prefix=${2:-} preamble=${3:-} + not_found_msg=${4:-} + extra_content=${5:-} + + shown_any= + ( cd "$MERGE_TOOLS_DIR" && ls ) | { + while read toolname + do + if setup_tool "$toolname" 2>/dev/null && + (eval "$condition" "$toolname") + then + if test -n "$preamble" + then + printf "%s\n" "$preamble" + preamble= + fi + shown_any=yes + printf "%s%s\n" "$per_line_prefix" "$toolname" + fi + done + + if test -n "$extra_content" + then + if test -n "$preamble" + then + # Note: no '\n' here since we don't want a + # blank line if there is no initial content. + printf "%s" "$preamble" + preamble= + fi + shown_any=yes + printf "\n%s\n" "$extra_content" + fi + + if test -n "$preamble" && test -n "$not_found_msg" + then + printf "%s\n" "$not_found_msg" + fi + + test -n "$shown_any" + } +} + diff_mode() { test "$TOOL_MODE" = diff } @@ -30,61 +108,70 @@ check_unchanged () { fi } -valid_tool_config () { - if test -n "$(get_merge_tool_cmd "$1")" - then - return 0 - else - return 1 - fi -} - valid_tool () { - setup_tool "$1" || valid_tool_config "$1" + setup_tool "$1" && return 0 + cmd=$(get_merge_tool_cmd "$1") + test -n "$cmd" } setup_tool () { - case "$1" in - vim*|gvim*) - tool=vim - ;; - *) - tool="$1" - ;; - esac - mergetools="$(git --exec-path)/mergetools" + tool="$1" + + # Fallback definitions, to be overriden by tools. + can_merge () { + return 0 + } + + can_diff () { + return 0 + } + + diff_cmd () { + status=1 + return $status + } - # Load the default definitions - . "$mergetools/defaults" - if ! test -f "$mergetools/$tool" + merge_cmd () { + status=1 + return $status + } + + translate_merge_tool_path () { + echo "$1" + } + + if ! test -f "$MERGE_TOOLS_DIR/$tool" then - return 1 + # Use a special return code for this case since we want to + # source "defaults" even when an explicit tool path is + # configured since the user can use that to override the + # default path in the scriptlet. + return 2 fi # Load the redefined functions - . "$mergetools/$tool" + . "$MERGE_TOOLS_DIR/$tool" if merge_mode && ! can_merge then echo "error: '$tool' can not be used to resolve merges" >&2 - exit 1 + return 1 elif diff_mode && ! can_diff then echo "error: '$tool' can only be used to resolve merges" >&2 - exit 1 + return 1 fi return 0 } get_merge_tool_cmd () { - # Prints the custom command for a merge tool merge_tool="$1" if diff_mode then - echo "$(git config difftool.$merge_tool.cmd || - git config mergetool.$merge_tool.cmd)" + git config "difftool.$merge_tool.cmd" || + git config "mergetool.$merge_tool.cmd" else - echo "$(git config mergetool.$merge_tool.cmd)" + git config "mergetool.$merge_tool.cmd" fi } @@ -95,12 +182,25 @@ run_merge_tool () { GIT_PREFIX=${GIT_PREFIX:-.} export GIT_PREFIX - merge_tool_path="$(get_merge_tool_path "$1")" || exit + merge_tool_path=$(get_merge_tool_path "$1") || exit base_present="$2" status=0 # Bring tool-specific functions into scope setup_tool "$1" + exitcode=$? + case $exitcode in + 0) + : + ;; + 2) + # The configured tool is not a built-in tool. + test -n "$merge_tool_path" || return 1 + ;; + *) + return $exitcode + ;; + esac if merge_mode then @@ -113,7 +213,7 @@ run_merge_tool () { # Run a either a configured or built-in diff tool run_diff_cmd () { - merge_tool_cmd="$(get_merge_tool_cmd "$1")" + merge_tool_cmd=$(get_merge_tool_cmd "$1") if test -n "$merge_tool_cmd" then ( eval $merge_tool_cmd ) @@ -126,11 +226,11 @@ run_diff_cmd () { # Run a either a configured or built-in merge tool run_merge_cmd () { - merge_tool_cmd="$(get_merge_tool_cmd "$1")" + merge_tool_cmd=$(get_merge_tool_cmd "$1") if test -n "$merge_tool_cmd" then - trust_exit_code="$(git config --bool \ - mergetool."$1".trustExitCode || echo false)" + trust_exit_code=$(git config --bool \ + "mergetool.$1.trustExitCode" || echo false) if test "$trust_exit_code" = "false" then touch "$BACKUP" @@ -174,22 +274,61 @@ list_merge_tool_candidates () { esac } +show_tool_help () { + tool_opt="'git ${TOOL_MODE}tool --tool-<tool>'" + + tab=' ' + LF=' +' + any_shown=no + + cmd_name=${TOOL_MODE}tool + config_tools=$({ + diff_mode && list_config_tools difftool "$tab$tab" + list_config_tools mergetool "$tab$tab" + } | sort) + extra_content= + if test -n "$config_tools" + then + extra_content="${tab}user-defined:${LF}$config_tools" + fi + + show_tool_names 'mode_ok && is_available' "$tab$tab" \ + "$tool_opt may be set to one of the following:" \ + "No suitable tool for 'git $cmd_name --tool=<tool>' found." \ + "$extra_content" && + any_shown=yes + + show_tool_names 'mode_ok && ! is_available' "$tab$tab" \ + "${LF}The following tools are valid, but not currently available:" && + any_shown=yes + + if test "$any_shown" = yes + then + echo + echo "Some of the tools listed above only work in a windowed" + echo "environment. If run in a terminal-only session, they will fail." + fi + exit 0 +} + guess_merge_tool () { list_merge_tool_candidates - echo >&2 "merge tool candidates: $tools" + cat >&2 <<-EOF + + This message is displayed because '$TOOL_MODE.tool' is not configured. + See 'git ${TOOL_MODE}tool --tool-help' or 'git help config' for more details. + 'git ${TOOL_MODE}tool' will now attempt to use one of the following tools: + $tools + EOF # Loop over each candidate and stop when a valid merge tool is found. - for i in $tools + for tool in $tools do - merge_tool_path="$(translate_merge_tool_path "$i")" - if type "$merge_tool_path" >/dev/null 2>&1 - then - echo "$i" - return 0 - fi + is_available "$tool" && echo "$tool" && return 0 done - echo >&2 "No known merge resolution program available." + echo >&2 "No known ${TOOL_MODE} tool is available." return 1 } @@ -228,7 +367,7 @@ get_merge_tool_path () { fi if test -z "$merge_tool_path" then - merge_tool_path="$(translate_merge_tool_path "$merge_tool")" + merge_tool_path=$(translate_merge_tool_path "$merge_tool") fi if test -z "$(get_merge_tool_cmd "$merge_tool")" && ! type "$merge_tool_path" >/dev/null 2>&1 @@ -242,11 +381,11 @@ get_merge_tool_path () { get_merge_tool () { # Check if a merge tool has been configured - merge_tool="$(get_configured_merge_tool)" + merge_tool=$(get_configured_merge_tool) # Try to guess an appropriate merge tool if no tool has been set. if test -z "$merge_tool" then - merge_tool="$(guess_merge_tool)" || exit + merge_tool=$(guess_merge_tool) || exit fi echo "$merge_tool" } diff --git a/git-mergetool.sh b/git-mergetool.sh index c50e18a899..c0ee9aaf81 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -315,43 +315,6 @@ merge_file () { return 0 } -show_tool_help () { - TOOL_MODE=merge - list_merge_tool_candidates - unavailable= available= LF=' -' - for i in $tools - do - merge_tool_path=$(translate_merge_tool_path "$i") - if type "$merge_tool_path" >/dev/null 2>&1 - then - available="$available$i$LF" - else - unavailable="$unavailable$i$LF" - fi - done - if test -n "$available" - then - echo "'git mergetool --tool=<tool>' may be set to one of the following:" - echo "$available" | sort | sed -e 's/^/ /' - else - echo "No suitable tool for 'git mergetool --tool=<tool>' found." - fi - if test -n "$unavailable" - then - echo - echo 'The following tools are valid, but not currently available:' - echo "$unavailable" | sort | sed -e 's/^/ /' - fi - if test -n "$unavailable$available" - then - echo - echo "Some of the tools listed above only work in a windowed" - echo "environment. If run in a terminal-only session, they will fail." - fi - exit 0 -} - prompt=$(git config --bool mergetool.prompt || echo true) while test $# != 0 @@ -7,16 +7,36 @@ # 2007 Trolltech ASA # License: MIT <http://www.opensource.org/licenses/mit-license.php> # - import sys if sys.hexversion < 0x02040000: # The limiter is the subprocess module sys.stderr.write("git-p4: requires Python 2.4 or later.\n") sys.exit(1) - -import optparse, os, marshal, subprocess, shelve -import tempfile, getopt, os.path, time, platform -import re, shutil +import os +import optparse +import marshal +import subprocess +import tempfile +import time +import platform +import re +import shutil +import stat + +try: + from subprocess import CalledProcessError +except ImportError: + # from python2.7:subprocess.py + # Exception classes used by this module. + class CalledProcessError(Exception): + """This exception is raised when a process run by check_call() returns + a non-zero exit status. The exit status will be stored in the + returncode attribute.""" + def __init__(self, returncode, cmd): + self.returncode = returncode + self.cmd = cmd + def __str__(self): + return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) verbose = False @@ -158,13 +178,33 @@ def system(cmd): expand = isinstance(cmd,basestring) if verbose: sys.stderr.write("executing %s\n" % str(cmd)) - subprocess.check_call(cmd, shell=expand) + retcode = subprocess.call(cmd, shell=expand) + if retcode: + raise CalledProcessError(retcode, cmd) def p4_system(cmd): """Specifically invoke p4 as the system command. """ real_cmd = p4_build_cmd(cmd) expand = isinstance(real_cmd, basestring) - subprocess.check_call(real_cmd, shell=expand) + retcode = subprocess.call(real_cmd, shell=expand) + if retcode: + raise CalledProcessError(retcode, real_cmd) + +_p4_version_string = None +def p4_version_string(): + """Read the version string, showing just the last line, which + hopefully is the interesting version bit. + + $ p4 -V + Perforce - The Fast Software Configuration Management System. + Copyright 1995-2011 Perforce Software. All rights reserved. + Rev. P4/NTX86/2011.1/393975 (2011/12/16). + """ + global _p4_version_string + if not _p4_version_string: + a = p4_read_pipe_lines(["-V"]) + _p4_version_string = a[-1].rstrip() + return _p4_version_string def p4_integrate(src, dest): p4_system(["integrate", "-Dt", wildcard_encode(src), wildcard_encode(dest)]) @@ -539,18 +579,30 @@ def gitBranchExists(branch): return proc.wait() == 0; _gitConfig = {} -def gitConfig(key, args = None): # set args to "--bool", for instance + +def gitConfig(key): if not _gitConfig.has_key(key): - argsFilter = "" - if args != None: - argsFilter = "%s " % args - cmd = "git config %s%s" % (argsFilter, key) - _gitConfig[key] = read_pipe(cmd, ignore_error=True).strip() + cmd = [ "git", "config", key ] + s = read_pipe(cmd, ignore_error=True) + _gitConfig[key] = s.strip() + return _gitConfig[key] + +def gitConfigBool(key): + """Return a bool, using git config --bool. It is True only if the + variable is set to true, and False if set to false or not present + in the config.""" + + if not _gitConfig.has_key(key): + cmd = [ "git", "config", "--bool", key ] + s = read_pipe(cmd, ignore_error=True) + v = s.strip() + _gitConfig[key] = v == "true" return _gitConfig[key] def gitConfigList(key): if not _gitConfig.has_key(key): - _gitConfig[key] = read_pipe("git config --get-all %s" % key, ignore_error=True).strip().split(os.linesep) + s = read_pipe(["git", "config", "--get-all", key], ignore_error=True) + _gitConfig[key] = s.strip().split(os.linesep) return _gitConfig[key] def p4BranchesInGit(branchesAreInRemotes=True): @@ -697,8 +749,7 @@ def p4PathStartsWith(path, prefix): # # we may or may not have a problem. If you have core.ignorecase=true, # we treat DirA and dira as the same directory - ignorecase = gitConfig("core.ignorecase", "--bool") == "true" - if ignorecase: + if gitConfigBool("core.ignorecase"): return path.lower().startswith(prefix.lower()) return path.startswith(prefix) @@ -768,7 +819,8 @@ def wildcard_encode(path): return path def wildcard_present(path): - return path.translate(None, "*#@%") != path + m = re.search("[*#@%]", path) + return m is not None class Command: def __init__(self): @@ -934,7 +986,7 @@ class P4Submit(Command, P4UserMap): self.usage += " [name of git branch to submit into perforce depot]" self.origin = "" self.detectRenames = False - self.preserveUser = gitConfig("git-p4.preserveUser").lower() == "true" + self.preserveUser = gitConfigBool("git-p4.preserveUser") self.dry_run = False self.prepare_p4_only = False self.conflict_behavior = None @@ -1029,7 +1081,8 @@ class P4Submit(Command, P4UserMap): def p4UserForCommit(self,id): # Return the tuple (perforce user,git email) for a given git commit id self.getUserMapFromPerforceServer() - gitEmail = read_pipe("git log --max-count=1 --format='%%ae' %s" % id) + gitEmail = read_pipe(["git", "log", "--max-count=1", + "--format=%ae", id]) gitEmail = gitEmail.strip() if not self.emails.has_key(gitEmail): return (None,gitEmail) @@ -1042,7 +1095,7 @@ class P4Submit(Command, P4UserMap): (user,email) = self.p4UserForCommit(id) if not user: msg = "Cannot find p4 user for email %s in commit %s." % (email, id) - if gitConfig('git-p4.allowMissingP4Users').lower() == "true": + if gitConfigBool("git-p4.allowMissingP4Users"): print "%s" % msg else: die("Error: %s\nSet git-p4.allowMissingP4Users to true to allow this." % msg) @@ -1137,7 +1190,7 @@ class P4Submit(Command, P4UserMap): message. Return true if okay to continue with the submit.""" # if configured to skip the editing part, just submit - if gitConfig("git-p4.skipSubmitEdit") == "true": + if gitConfigBool("git-p4.skipSubmitEdit"): return True # look at the modification time, to check later if the user saved @@ -1153,7 +1206,7 @@ class P4Submit(Command, P4UserMap): # If the file was not saved, prompt to see if this patch should # be skipped. But skip this verification step if configured so. - if gitConfig("git-p4.skipSubmitEditCheck") == "true": + if gitConfigBool("git-p4.skipSubmitEditCheck"): return True # modification time updated means user saved the file @@ -1211,6 +1264,9 @@ class P4Submit(Command, P4UserMap): p4_edit(dest) pureRenameCopy.discard(dest) filesToChangeExecBit[dest] = diff['dst_mode'] + if self.isWindows: + # turn off read-only attribute + os.chmod(dest, stat.S_IWRITE) os.unlink(dest) editedFiles.add(dest) elif modifier == "R": @@ -1229,6 +1285,8 @@ class P4Submit(Command, P4UserMap): p4_edit(dest) # with move: already open, writable filesToChangeExecBit[dest] = diff['dst_mode'] if not self.p4HasMoveCommand: + if self.isWindows: + os.chmod(dest, stat.S_IWRITE) os.unlink(dest) filesToDelete.add(src) editedFiles.add(dest) @@ -1248,7 +1306,7 @@ class P4Submit(Command, P4UserMap): # Patch failed, maybe it's just RCS keyword woes. Look through # the patch to see if that's possible. - if gitConfig("git-p4.attemptRCSCleanup","--bool") == "true": + if gitConfigBool("git-p4.attemptRCSCleanup"): file = None pattern = None kwfiles = {} @@ -1269,6 +1327,10 @@ class P4Submit(Command, P4UserMap): for file in kwfiles: if verbose: print "zapping %s with %s" % (line,pattern) + # File is being deleted, so not open in p4. Must + # disable the read-only bit on windows. + if self.isWindows and file not in editedFiles: + os.chmod(file, stat.S_IWRITE) self.patchRCSKeywords(file, kwfiles[file]) fixed_rcs_keywords = True @@ -1539,7 +1601,7 @@ class P4Submit(Command, P4UserMap): sys.exit(128) self.useClientSpec = False - if gitConfig("git-p4.useclientspec", "--bool") == "true": + if gitConfigBool("git-p4.useclientspec"): self.useClientSpec = True if self.useClientSpec: self.clientSpecDirs = getClientSpec() @@ -1575,11 +1637,11 @@ class P4Submit(Command, P4UserMap): self.check() commits = [] - for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)): + for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (self.origin, self.master)]): commits.append(line.strip()) commits.reverse() - if self.preserveUser or (gitConfig("git-p4.skipUserNameCheck") == "true"): + if self.preserveUser or gitConfigBool("git-p4.skipUserNameCheck"): self.checkAuthorship = False else: self.checkAuthorship = True @@ -1615,7 +1677,7 @@ class P4Submit(Command, P4UserMap): else: self.diffOpts += " -C%s" % detectCopies - if gitConfig("git-p4.detectCopiesHarder", "--bool") == "true": + if gitConfigBool("git-p4.detectCopiesHarder"): self.diffOpts += " --find-copies-harder" # @@ -1699,7 +1761,7 @@ class P4Submit(Command, P4UserMap): "--format=format:%h %s", c]) print "You will have to do 'git p4 sync' and rebase." - if gitConfig("git-p4.exportLabels", "--bool") == "true": + if gitConfigBool("git-p4.exportLabels"): self.exportLabels = True if self.exportLabels: @@ -1969,7 +2031,6 @@ class P4Sync(Command, P4UserMap): self.syncWithOrigin = True self.importIntoRemotes = True self.maxChanges = "" - self.isWindows = (platform.system() == "Windows") self.keepRepoPath = False self.depotPaths = None self.p4BranchesInGit = [] @@ -2114,7 +2175,14 @@ class P4Sync(Command, P4UserMap): # operations. utf16 is converted to ascii or utf8, perhaps. # But ascii text saved as -t utf16 is completely mangled. # Invoke print -o to get the real contents. + # + # On windows, the newlines will always be mangled by print, so put + # them back too. This is not needed to the cygwin windows version, + # just the native "NT" type. + # text = p4_read_pipe(['print', '-q', '-o', '-', file['depotFile']]) + if p4_version_string().find("/NT") >= 0: + text = text.replace("\r\n", "\n") contents = [ text ] if type_base == "apple": @@ -2130,15 +2198,6 @@ class P4Sync(Command, P4UserMap): print "\nIgnoring apple filetype file %s" % file['depotFile'] return - # Perhaps windows wants unicode, utf16 newlines translated too; - # but this is not doing it. - if self.isWindows and type_base == "text": - mangled = [] - for data in contents: - data = data.replace("\r\n", "\n") - mangled.append(data) - contents = mangled - # Note that we do not try to de-mangle keywords on utf16 files, # even though in theory somebody may want that. pattern = p4_keywords_regexp_for_type(type_base, type_mods) @@ -2616,7 +2675,8 @@ class P4Sync(Command, P4UserMap): def searchParent(self, parent, branch, target): parentFound = False - for blob in read_pipe_lines(["git", "rev-list", "--reverse", "--no-merges", parent]): + for blob in read_pipe_lines(["git", "rev-list", "--reverse", + "--no-merges", parent]): blob = blob.strip() if len(read_pipe(["git", "diff-tree", blob, target])) == 0: parentFound = True @@ -2687,7 +2747,7 @@ class P4Sync(Command, P4UserMap): blob = None if len(parent) > 0: - tempBranch = os.path.join(self.tempBranchLocation, "%d" % (change)) + tempBranch = "%s/%d" % (self.tempBranchLocation, change) if self.verbose: print "Creating temporary branch: " + tempBranch self.commit(description, filesForCommit, tempBranch) @@ -2801,7 +2861,7 @@ class P4Sync(Command, P4UserMap): # will use this after clone to set the variable self.useClientSpec_from_options = True else: - if gitConfig("git-p4.useclientspec", "--bool") == "true": + if gitConfigBool("git-p4.useclientspec"): self.useClientSpec = True if self.useClientSpec: self.clientSpecDirs = getClientSpec() @@ -3041,7 +3101,7 @@ class P4Sync(Command, P4UserMap): sys.stdout.write("%s " % b) sys.stdout.write("\n") - if gitConfig("git-p4.importLabels", "--bool") == "true": + if gitConfigBool("git-p4.importLabels"): self.importLabels = True if self.importLabels: @@ -3159,6 +3219,7 @@ class P4Clone(P4Sync): self.cloneExclude = ["/"+p for p in self.cloneExclude] for p in depotPaths: if not p.startswith("//"): + sys.stderr.write('Depot paths must start with "//": %s\n' % p) return False if not self.cloneDestination: @@ -3173,7 +3234,9 @@ class P4Clone(P4Sync): init_cmd = [ "git", "init" ] if self.cloneBare: init_cmd.append("--bare") - subprocess.check_call(init_cmd) + retcode = subprocess.call(init_cmd) + if retcode: + raise CalledProcessError(retcode, init_cmd) if not P4Sync.run(self, depotPaths): return False diff --git a/git-remote-testpy.py b/git-remote-testpy.py index d94a66a870..ca6789996a 100644 --- a/git-remote-testpy.py +++ b/git-remote-testpy.py @@ -31,11 +31,27 @@ from git_remote_helpers.git.exporter import GitExporter from git_remote_helpers.git.importer import GitImporter from git_remote_helpers.git.non_local import NonLocalGit -if sys.hexversion < 0x01050200: - # os.makedirs() is the limiter - sys.stderr.write("git-remote-testgit: requires Python 1.5.2 or later.\n") +if sys.hexversion < 0x02000000: + # string.encode() is the limiter + sys.stderr.write("git-remote-testgit: requires Python 2.0 or later.\n") sys.exit(1) + +def encode_filepath(path): + """Encodes a Unicode file path to a byte string. + + On Python 2 this is a no-op; on Python 3 we encode the string as + suggested by [1] which allows an exact round-trip from the command line + to the filesystem. + + [1] http://docs.python.org/3/c-api/unicode.html#file-system-encoding + + """ + if sys.hexversion < 0x03000000: + return path + return path.encode(sys.getfilesystemencoding(), 'surrogateescape') + + def get_repo(alias, url): """Returns a git repository object initialized for usage. """ @@ -45,7 +61,7 @@ def get_repo(alias, url): repo.get_head() hasher = _digest() - hasher.update(repo.path) + hasher.update(encode_filepath(repo.path)) repo.hash = hasher.hexdigest() repo.get_base_path = lambda base: os.path.join( @@ -87,9 +103,9 @@ def do_capabilities(repo, args): """Prints the supported capabilities. """ - print "import" - print "export" - print "refspec refs/heads/*:%s*" % repo.prefix + print("import") + print("export") + print("refspec refs/heads/*:%s*" % repo.prefix) dirname = repo.get_base_path(repo.gitdir) @@ -98,11 +114,11 @@ def do_capabilities(repo, args): path = os.path.join(dirname, 'git.marks') - print "*export-marks %s" % path + print("*export-marks %s" % path) if os.path.exists(path): - print "*import-marks %s" % path + print("*import-marks %s" % path) - print # end capabilities + print('') # end capabilities def do_list(repo, args): @@ -115,16 +131,16 @@ def do_list(repo, args): for ref in repo.revs: debug("? refs/heads/%s", ref) - print "? refs/heads/%s" % ref + print("? refs/heads/%s" % ref) if repo.head: debug("@refs/heads/%s HEAD" % repo.head) - print "@refs/heads/%s HEAD" % repo.head + print("@refs/heads/%s HEAD" % repo.head) else: debug("@refs/heads/master HEAD") - print "@refs/heads/master HEAD" + print("@refs/heads/master HEAD") - print # end list + print('') # end list def update_local_repo(repo): @@ -154,7 +170,7 @@ def do_import(repo, args): refs = [ref] while True: - line = sys.stdin.readline() + line = sys.stdin.readline().decode() if line == '\n': break if not line.startswith('import '): @@ -164,7 +180,7 @@ def do_import(repo, args): ref = line[7:].strip() refs.append(ref) - print "feature done" + print("feature done") if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"): die('Told to fail') @@ -172,7 +188,7 @@ def do_import(repo, args): repo = update_local_repo(repo) repo.exporter.export_repo(repo.gitdir, refs) - print "done" + print("done") def do_export(repo, args): @@ -192,8 +208,8 @@ def do_export(repo, args): repo.non_local.push(repo.gitdir) for ref in changed: - print "ok %s" % ref - print + print("ok %s" % ref) + print('') COMMANDS = { @@ -225,7 +241,7 @@ def read_one_line(repo): line = sys.stdin.readline() - cmdline = line + cmdline = line.decode() if not cmdline: warn("Unexpected EOF") @@ -277,7 +293,11 @@ def main(args): more = True - sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0) + # Use binary mode since Python 3 does not permit unbuffered I/O in text + # mode. Unbuffered I/O is required to avoid data that should be going + # to git-fast-import after an "export" command getting caught in our + # stdin buffer instead. + sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0) while (more): more = read_one_line(repo) diff --git a/git-submodule.sh b/git-submodule.sh index 22ec5b63b4..004c034bc0 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -976,12 +976,12 @@ cmd_summary() { done | if test -n "$for_status"; then if [ -n "$files" ]; then - gettextln "# Submodules changed but not updated:" + gettextln "Submodules changed but not updated:" | git stripspace -c else - gettextln "# Submodule changes to be committed:" + gettextln "Submodule changes to be committed:" | git stripspace -c fi - echo "#" - sed -e 's|^|# |' -e 's|^# $|#|' + printf "\n" | git stripspace -c + git stripspace -c else cat fi diff --git a/git-svn.perl b/git-svn.perl index d0866946ce..b46795f593 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -61,8 +61,6 @@ my $cmd_dir_prefix = eval { command_oneline([qw/rev-parse --show-prefix/], STDERR => 0) } || ''; -my $git_dir_user_set = 1 if defined $ENV{GIT_DIR}; -$ENV{GIT_DIR} ||= '.git'; $Git::SVN::Ra::_log_window_size = 100; if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) { @@ -327,27 +325,20 @@ for (my $i = 0; $i < @ARGV; $i++) { }; # make sure we're always running at the top-level working directory -unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) { - unless (-d $ENV{GIT_DIR}) { - if ($git_dir_user_set) { - die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ", - "but it is not a directory\n"; - } - my $git_dir = delete $ENV{GIT_DIR}; - my $cdup = undef; - git_cmd_try { - $cdup = command_oneline(qw/rev-parse --show-cdup/); - $git_dir = '.' unless ($cdup); - chomp $cdup if ($cdup); - $cdup = "." unless ($cdup && length $cdup); - } "Already at toplevel, but $git_dir not found\n"; - chdir $cdup or die "Unable to chdir up to '$cdup'\n"; - unless (-d $git_dir) { - die "$git_dir still not found after going to ", - "'$cdup'\n"; - } - $ENV{GIT_DIR} = $git_dir; - } +if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) { + $ENV{GIT_DIR} ||= ".git"; +} else { + my ($git_dir, $cdup); + git_cmd_try { + $git_dir = command_oneline([qw/rev-parse --git-dir/]); + } "Unable to find .git directory\n"; + git_cmd_try { + $cdup = command_oneline(qw/rev-parse --show-cdup/); + chomp $cdup if ($cdup); + $cdup = "." unless ($cdup && length $cdup); + } "Already at toplevel, but $git_dir not found\n"; + $ENV{GIT_DIR} = $git_dir; + chdir $cdup or die "Unable to chdir up to '$cdup'\n"; $_repository = Git->repository(Repository => $ENV{GIT_DIR}); } @@ -313,6 +313,7 @@ static void handle_internal_command(int argc, const char **argv) { "bundle", cmd_bundle, RUN_SETUP_GENTLY }, { "cat-file", cmd_cat_file, RUN_SETUP }, { "check-attr", cmd_check_attr, RUN_SETUP }, + { "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE }, { "check-ref-format", cmd_check_ref_format }, { "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE }, { "checkout-index", cmd_checkout_index, diff --git a/git_remote_helpers/.gitignore b/git_remote_helpers/.gitignore index 2247d5f95a..cf040af3f5 100644 --- a/git_remote_helpers/.gitignore +++ b/git_remote_helpers/.gitignore @@ -1,2 +1,3 @@ +/GIT-PYTHON-VERSION /build /dist diff --git a/git_remote_helpers/Makefile b/git_remote_helpers/Makefile index 74b05dc91e..3d122328c8 100644 --- a/git_remote_helpers/Makefile +++ b/git_remote_helpers/Makefile @@ -23,10 +23,16 @@ endif PYLIBDIR=$(shell $(PYTHON_PATH) -c \ "import sys; \ - print 'lib/python%i.%i/site-packages' % sys.version_info[:2]") + print('lib/python%i.%i/site-packages' % sys.version_info[:2])") + +py_version=$(shell $(PYTHON_PATH) -c \ + 'import sys; print("%i.%i" % sys.version_info[:2])') all: $(pysetupfile) - $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build + $(QUIET)test "$$(cat GIT-PYTHON-VERSION 2>/dev/null)" = "$(py_version)" || \ + flags=--force; \ + $(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build $$flags + $(QUIET)echo "$(py_version)" >GIT-PYTHON-VERSION install: $(pysetupfile) $(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix) @@ -36,4 +42,4 @@ instlibdir: $(pysetupfile) clean: $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a - $(RM) *.pyo *.pyc + $(RM) *.pyo *.pyc GIT-PYTHON-VERSION diff --git a/git_remote_helpers/git/importer.py b/git_remote_helpers/git/importer.py index e28cc8f986..d3f90e1024 100644 --- a/git_remote_helpers/git/importer.py +++ b/git_remote_helpers/git/importer.py @@ -18,13 +18,16 @@ class GitImporter(object): def get_refs(self, gitdir): """Returns a dictionary with refs. + + Note that the keys in the returned dictionary are byte strings as + read from git. """ args = ["git", "--git-dir=" + gitdir, "for-each-ref", "refs/heads"] - lines = check_output(args).strip().split('\n') + lines = check_output(args).strip().split('\n'.encode('ascii')) refs = {} for line in lines: - value, name = line.split(' ') - name = name.strip('commit\t') + value, name = line.split(' '.encode('ascii')) + name = name.strip('commit\t'.encode('ascii')) refs[name] = value return refs diff --git a/git_remote_helpers/setup.py b/git_remote_helpers/setup.py index 4d434b65cb..6de41deb44 100644 --- a/git_remote_helpers/setup.py +++ b/git_remote_helpers/setup.py @@ -4,6 +4,15 @@ from distutils.core import setup +# If building under Python3 we need to run 2to3 on the code, do this by +# trying to import distutils' 2to3 builder, which is only available in +# Python3. +try: + from distutils.command.build_py import build_py_2to3 as build_py +except ImportError: + # 2.x + from distutils.command.build_py import build_py + setup( name = 'git_remote_helpers', version = '0.1.0', @@ -14,4 +23,5 @@ setup( url = 'http://www.git-scm.com/', package_dir = {'git_remote_helpers': ''}, packages = ['git_remote_helpers', 'git_remote_helpers.git'], + cmdclass = {'build_py': build_py}, ) diff --git a/gitk-git/.gitignore b/gitk-git/.gitignore new file mode 100644 index 0000000000..d7ebcaf366 --- /dev/null +++ b/gitk-git/.gitignore @@ -0,0 +1,2 @@ +/GIT-TCLTK-VARS +/gitk-wish diff --git a/gitk-git/Makefile b/gitk-git/Makefile index e1b6045605..5acdc900ab 100644 --- a/gitk-git/Makefile +++ b/gitk-git/Makefile @@ -17,6 +17,16 @@ DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) bindir_SQ = $(subst ','\'',$(bindir)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) +### Detect Tck/Tk interpreter path changes +TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)') + +GIT-TCLTK-VARS: FORCE + @VARS='$(TRACK_TCLTK)'; \ + if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \ + echo 1>&2 " * new Tcl/Tk interpreter location"; \ + echo "$$VARS" >$@; \ + fi + ## po-file creation rules XGETTEXT ?= xgettext ifdef NO_MSGFMT @@ -49,9 +59,9 @@ uninstall:: $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk clean:: - $(RM) gitk-wish po/*.msg + $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS -gitk-wish: gitk +gitk-wish: gitk GIT-TCLTK-VARS $(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \ chmod +x $@+ && \ @@ -65,3 +75,5 @@ $(ALL_MSGFILES): %.msg : %.po @echo Generating catalog $@ $(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@) +.PHONY: all install uninstall clean update-po +.PHONY: FORCE diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index c6bafe6ead..1309196d27 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2068,7 +2068,7 @@ sub picon_url { if (!$avatar_cache{$email}) { my ($user, $domain) = split('@', $email); $avatar_cache{$email} = - "http://www.cs.indiana.edu/cgi-pub/kinzler/piconsearch.cgi/" . + "//www.cs.indiana.edu/cgi-pub/kinzler/piconsearch.cgi/" . "$domain/$user/" . "users+domains+unknown/up/single"; } @@ -2083,7 +2083,7 @@ sub gravatar_url { my $email = lc shift; my $size = shift; $avatar_cache{$email} ||= - "http://www.gravatar.com/avatar/" . + "//www.gravatar.com/avatar/" . Digest::MD5::md5_hex($email) . "?s="; return $avatar_cache{$email} . $size; } diff --git a/gpg-interface.c b/gpg-interface.c index 0863c61800..45590330aa 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -109,10 +109,10 @@ int verify_signed_buffer(const char *payload, size_t payload_size, args_gpg[0] = gpg_program; fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX"); if (fd < 0) - return error("could not create temporary file '%s': %s", + return error(_("could not create temporary file '%s': %s"), path, strerror(errno)); if (write_in_full(fd, signature, signature_size) < 0) - return error("failed writing detached signature to '%s': %s", + return error(_("failed writing detached signature to '%s': %s"), path, strerror(errno)); close(fd); @@ -124,14 +124,16 @@ int verify_signed_buffer(const char *payload, size_t payload_size, args_gpg[2] = path; if (start_command(&gpg)) { unlink(path); - return error("could not run gpg."); + return error(_("could not run gpg.")); } write_in_full(gpg.in, payload, payload_size); close(gpg.in); - if (gpg_output) + if (gpg_output) { strbuf_read(gpg_output, gpg.err, 0); + close(gpg.err); + } ret = finish_command(&gpg); unlink_or_warn(path); @@ -223,6 +223,23 @@ void list_commands(unsigned int colopts, } } +void list_common_cmds_help(void) +{ + int i, longest = 0; + + for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { + if (longest < strlen(common_cmds[i].name)) + longest = strlen(common_cmds[i].name); + } + + puts(_("The most commonly used git commands are:")); + for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { + printf(" %s ", common_cmds[i].name); + mput_char(' ', longest - strlen(common_cmds[i].name)); + puts(_(common_cmds[i].help)); + } +} + int is_in_cmdlist(struct cmdnames *c, const char *s) { int i; @@ -46,6 +46,7 @@ static void copy_gecos(const struct passwd *w, struct strbuf *name) static int add_mailname_host(struct strbuf *buf) { FILE *mailname; + struct strbuf mailnamebuf = STRBUF_INIT; mailname = fopen("/etc/mailname", "r"); if (!mailname) { @@ -54,14 +55,17 @@ static int add_mailname_host(struct strbuf *buf) strerror(errno)); return -1; } - if (strbuf_getline(buf, mailname, '\n') == EOF) { + if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) { if (ferror(mailname)) warning("cannot read /etc/mailname: %s", strerror(errno)); + strbuf_release(&mailnamebuf); fclose(mailname); return -1; } /* success! */ + strbuf_addbuf(buf, &mailnamebuf); + strbuf_release(&mailnamebuf); fclose(mailname); return 0; } diff --git a/imap-send.c b/imap-send.c index e521e2fd22..21dc20b57d 100644 --- a/imap-send.c +++ b/imap-send.c @@ -33,46 +33,6 @@ typedef void *SSL; #include <openssl/hmac.h> #endif -struct store_conf { - char *name; - const char *path; /* should this be here? its interpretation is driver-specific */ - char *map_inbox; - char *trash; - unsigned max_size; /* off_t is overkill */ - unsigned trash_remote_new:1, trash_only_new:1; -}; - -/* For message->status */ -#define M_RECENT (1<<0) /* unsyncable flag; maildir_* depend on this being 1<<0 */ -#define M_DEAD (1<<1) /* expunged */ -#define M_FLAGS (1<<2) /* flags fetched */ - -struct message { - struct message *next; - size_t size; /* zero implies "not fetched" */ - int uid; - unsigned char flags, status; -}; - -struct store { - struct store_conf *conf; /* foreign */ - - /* currently open mailbox */ - const char *name; /* foreign! maybe preset? */ - char *path; /* own */ - struct message *msgs; /* own */ - int uidvalidity; - unsigned char opts; /* maybe preset? */ - /* note that the following do _not_ reflect stats from msgs, but mailbox totals */ - int count; /* # of messages */ - int recent; /* # of recent messages - don't trust this beyond the initial read */ -}; - -struct msg_data { - struct strbuf data; - unsigned char flags; -}; - static const char imap_send_usage[] = "git imap-send < <mbox>"; #undef DRV_OK @@ -90,8 +50,6 @@ static void imap_warn(const char *, ...); static char *next_arg(char **); -static void free_generic_messages(struct message *); - __attribute__((format (printf, 3, 4))) static int nfsnprintf(char *buf, int blen, const char *fmt, ...); @@ -135,20 +93,6 @@ static struct imap_server_conf server = { NULL, /* auth_method */ }; -struct imap_store_conf { - struct store_conf gen; - struct imap_server_conf *server; -}; - -#define NIL (void *)0x1 -#define LIST (void *)0x2 - -struct imap_list { - struct imap_list *next, *child; - char *val; - int len; -}; - struct imap_socket { int fd[2]; SSL *ssl; @@ -165,7 +109,6 @@ struct imap_cmd; struct imap { int uidnext; /* from SELECT responses */ - struct imap_list *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */ unsigned caps, rcaps; /* CAPABILITY results */ /* command queue */ int nexttag, num_in_progress, literal_pending; @@ -174,11 +117,11 @@ struct imap { }; struct imap_store { - struct store gen; + /* currently open mailbox */ + const char *name; /* foreign! maybe preset? */ int uidvalidity; struct imap *imap; const char *prefix; - unsigned /*currentnc:1,*/ trashnc:1; }; struct imap_cmd_cb { @@ -225,14 +168,6 @@ static const char *cap_list[] = { static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd); -static const char *Flags[] = { - "Draft", - "Flagged", - "Answered", - "Seen", - "Deleted", -}; - #ifndef NO_OPENSSL static void ssl_socket_perror(const char *func) { @@ -476,16 +411,6 @@ static char *next_arg(char **s) return ret; } -static void free_generic_messages(struct message *msgs) -{ - struct message *tmsg; - - for (; msgs; msgs = tmsg) { - tmsg = msgs->next; - free(msgs); - } -} - static int nfsnprintf(char *buf, int blen, const char *fmt, ...) { int ret; @@ -613,35 +538,9 @@ static int imap_exec_m(struct imap_store *ctx, struct imap_cmd_cb *cb, } } -static int is_atom(struct imap_list *list) -{ - return list && list->val && list->val != NIL && list->val != LIST; -} - -static int is_list(struct imap_list *list) -{ - return list && list->val == LIST; -} - -static void free_list(struct imap_list *list) -{ - struct imap_list *tmp; - - for (; list; list = tmp) { - tmp = list->next; - if (is_list(list)) - free_list(list->child); - else if (is_atom(list)) - free(list->val); - free(list); - } -} - -static int parse_imap_list_l(struct imap *imap, char **sp, struct imap_list **curp, int level) +static int skip_imap_list_l(char **sp, int level) { - struct imap_list *cur; - char *s = *sp, *p; - int n, bytes; + char *s = *sp; for (;;) { while (isspace((unsigned char)*s)) @@ -650,68 +549,23 @@ static int parse_imap_list_l(struct imap *imap, char **sp, struct imap_list **cu s++; break; } - *curp = cur = xmalloc(sizeof(*cur)); - curp = &cur->next; - cur->val = NULL; /* for clean bail */ if (*s == '(') { /* sublist */ s++; - cur->val = LIST; - if (parse_imap_list_l(imap, &s, &cur->child, level + 1)) - goto bail; - } else if (imap && *s == '{') { - /* literal */ - bytes = cur->len = strtol(s + 1, &s, 10); - if (*s != '}') - goto bail; - - s = cur->val = xmalloc(cur->len); - - /* dump whats left over in the input buffer */ - n = imap->buf.bytes - imap->buf.offset; - - if (n > bytes) - /* the entire message fit in the buffer */ - n = bytes; - - memcpy(s, imap->buf.buf + imap->buf.offset, n); - s += n; - bytes -= n; - - /* mark that we used part of the buffer */ - imap->buf.offset += n; - - /* now read the rest of the message */ - while (bytes > 0) { - if ((n = socket_read(&imap->buf.sock, s, bytes)) <= 0) - goto bail; - s += n; - bytes -= n; - } - - if (buffer_gets(&imap->buf, &s)) + if (skip_imap_list_l(&s, level + 1)) goto bail; } else if (*s == '"') { /* quoted string */ s++; - p = s; for (; *s != '"'; s++) if (!*s) goto bail; - cur->len = s - p; s++; - cur->val = xmemdupz(p, cur->len); } else { /* atom */ - p = s; for (; *s && !isspace((unsigned char)*s); s++) if (level && *s == ')') break; - cur->len = s - p; - if (cur->len == 3 && !memcmp("NIL", p, 3)) - cur->val = NIL; - else - cur->val = xmemdupz(p, cur->len); } if (!level) @@ -720,27 +574,15 @@ static int parse_imap_list_l(struct imap *imap, char **sp, struct imap_list **cu goto bail; } *sp = s; - *curp = NULL; return 0; bail: - *curp = NULL; return -1; } -static struct imap_list *parse_imap_list(struct imap *imap, char **sp) +static void skip_list(char **sp) { - struct imap_list *head; - - if (!parse_imap_list_l(imap, sp, &head, 0)) - return head; - free_list(head); - return NULL; -} - -static struct imap_list *parse_list(char **sp) -{ - return parse_imap_list(NULL, sp); + skip_imap_list_l(sp, 0); } static void parse_capability(struct imap *imap, char *cmd) @@ -772,7 +614,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb, *p++ = 0; arg = next_arg(&s); if (!strcmp("UIDVALIDITY", arg)) { - if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg))) { + if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg))) { fprintf(stderr, "IMAP error: malformed UIDVALIDITY status\n"); return RESP_BAD; } @@ -790,7 +632,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb, for (; isspace((unsigned char)*p); p++); fprintf(stderr, "*** IMAP ALERT *** %s\n", p); } else if (cb && cb->ctx && !strcmp("APPENDUID", arg)) { - if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg)) || + if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg)) || !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg))) { fprintf(stderr, "IMAP error: malformed APPENDUID status\n"); return RESP_BAD; @@ -819,20 +661,28 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd) } if (!strcmp("NAMESPACE", arg)) { - imap->ns_personal = parse_list(&cmd); - imap->ns_other = parse_list(&cmd); - imap->ns_shared = parse_list(&cmd); + /* rfc2342 NAMESPACE response. */ + skip_list(&cmd); /* Personal mailboxes */ + skip_list(&cmd); /* Others' mailboxes */ + skip_list(&cmd); /* Shared mailboxes */ } else if (!strcmp("OK", arg) || !strcmp("BAD", arg) || !strcmp("NO", arg) || !strcmp("BYE", arg)) { if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK) return resp; - } else if (!strcmp("CAPABILITY", arg)) + } else if (!strcmp("CAPABILITY", arg)) { parse_capability(imap, cmd); - else if ((arg1 = next_arg(&cmd))) { - if (!strcmp("EXISTS", arg1)) - ctx->gen.count = atoi(arg); - else if (!strcmp("RECENT", arg1)) - ctx->gen.recent = atoi(arg); + } else if ((arg1 = next_arg(&cmd))) { + ; /* + * Unhandled response-data with at least two words. + * Ignore it. + * + * NEEDSWORK: Previously this case handled '<num> EXISTS' + * and '<num> RECENT' but as a probably-unintended side + * effect it ignores other unrecognized two-word + * responses. imap-send doesn't ever try to read + * messages or mailboxes these days, so consider + * eliminating this case. + */ } else { fprintf(stderr, "IMAP error: unable to parse untagged response\n"); return RESP_BAD; @@ -934,16 +784,12 @@ static void imap_close_server(struct imap_store *ictx) imap_exec(ictx, NULL, "LOGOUT"); socket_shutdown(&imap->buf.sock); } - free_list(imap->ns_personal); - free_list(imap->ns_other); - free_list(imap->ns_shared); free(imap); } -static void imap_close_store(struct store *ctx) +static void imap_close_store(struct imap_store *ctx) { - imap_close_server((struct imap_store *)ctx); - free_generic_messages(ctx->msgs); + imap_close_server(ctx); free(ctx); } @@ -1028,7 +874,7 @@ static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const cha return 0; } -static struct store *imap_open_store(struct imap_server_conf *srvc) +static struct imap_store *imap_open_store(struct imap_server_conf *srvc) { struct imap_store *ctx; struct imap *imap; @@ -1238,103 +1084,69 @@ static struct store *imap_open_store(struct imap_server_conf *srvc) } /* !preauth */ ctx->prefix = ""; - ctx->trashnc = 1; - return (struct store *)ctx; + return ctx; bail: - imap_close_store(&ctx->gen); + imap_close_store(ctx); return NULL; } -static int imap_make_flags(int flags, char *buf) -{ - const char *s; - unsigned i, d; - - for (i = d = 0; i < ARRAY_SIZE(Flags); i++) - if (flags & (1 << i)) { - buf[d++] = ' '; - buf[d++] = '\\'; - for (s = Flags[i]; *s; s++) - buf[d++] = *s; - } - buf[0] = '('; - buf[d++] = ')'; - return d; -} - +/* + * Insert CR characters as necessary in *msg to ensure that every LF + * character in *msg is preceded by a CR. + */ static void lf_to_crlf(struct strbuf *msg) { - size_t new_len; char *new; - int i, j, lfnum = 0; - - if (msg->buf[0] == '\n') - lfnum++; - for (i = 1; i < msg->len; i++) { - if (msg->buf[i - 1] != '\r' && msg->buf[i] == '\n') - lfnum++; + size_t i, j; + char lastc; + + /* First pass: tally, in j, the size of the new string: */ + for (i = j = 0, lastc = '\0'; i < msg->len; i++) { + if (msg->buf[i] == '\n' && lastc != '\r') + j++; /* a CR will need to be added here */ + lastc = msg->buf[i]; + j++; } - new_len = msg->len + lfnum; - new = xmalloc(new_len + 1); - if (msg->buf[0] == '\n') { - new[0] = '\r'; - new[1] = '\n'; - i = 1; - j = 2; - } else { - new[0] = msg->buf[0]; - i = 1; - j = 1; - } - for ( ; i < msg->len; i++) { - if (msg->buf[i] != '\n') { - new[j++] = msg->buf[i]; - continue; - } - if (msg->buf[i - 1] != '\r') + new = xmalloc(j + 1); + + /* + * Second pass: write the new string. Note that this loop is + * otherwise identical to the first pass. + */ + for (i = j = 0, lastc = '\0'; i < msg->len; i++) { + if (msg->buf[i] == '\n' && lastc != '\r') new[j++] = '\r'; - /* otherwise it already had CR before */ - new[j++] = '\n'; + lastc = new[j++] = msg->buf[i]; } - strbuf_attach(msg, new, new_len, new_len + 1); + strbuf_attach(msg, new, j, j + 1); } /* * Store msg to IMAP. Also detach and free the data from msg->data, * leaving msg->data empty. */ -static int imap_store_msg(struct store *gctx, struct msg_data *msg) +static int imap_store_msg(struct imap_store *ctx, struct strbuf *msg) { - struct imap_store *ctx = (struct imap_store *)gctx; struct imap *imap = ctx->imap; struct imap_cmd_cb cb; const char *prefix, *box; - int ret, d; - char flagstr[128]; + int ret; - lf_to_crlf(&msg->data); + lf_to_crlf(msg); memset(&cb, 0, sizeof(cb)); - cb.dlen = msg->data.len; - cb.data = strbuf_detach(&msg->data, NULL); - - d = 0; - if (msg->flags) { - d = imap_make_flags(msg->flags, flagstr); - flagstr[d++] = ' '; - } - flagstr[d] = 0; + cb.dlen = msg->len; + cb.data = strbuf_detach(msg, NULL); - box = gctx->name; + box = ctx->name; prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix; cb.create = 0; - ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" %s", prefix, box, flagstr); + ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box); imap->caps = imap->rcaps; if (ret != DRV_OK) return ret; - gctx->count++; return DRV_OK; } @@ -1483,8 +1295,8 @@ static int git_imap_config(const char *key, const char *val, void *cb) int main(int argc, char **argv) { struct strbuf all_msgs = STRBUF_INIT; - struct msg_data msg = {STRBUF_INIT, 0}; - struct store *ctx = NULL; + struct strbuf msg = STRBUF_INIT; + struct imap_store *ctx = NULL; int ofs = 0; int r; int total, n = 0; @@ -1545,10 +1357,10 @@ int main(int argc, char **argv) unsigned percent = n * 100 / total; fprintf(stderr, "%4u%% (%d/%d) done\r", percent, n, total); - if (!split_msg(&all_msgs, &msg.data, &ofs)) + if (!split_msg(&all_msgs, &msg, &ofs)) break; if (server.use_html) - wrap_in_html(&msg.data); + wrap_in_html(&msg); r = imap_store_msg(ctx, &msg); if (r != DRV_OK) break; diff --git a/ll-merge.c b/ll-merge.c index acea33bf1b..fb61ea66a1 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -222,7 +222,7 @@ static const char *default_ll_merge; static int read_merge_config(const char *var, const char *value, void *cb) { struct ll_merge_driver *fn; - const char *ep, *name; + const char *key, *name; int namelen; if (!strcmp(var, "merge.default")) { @@ -236,15 +236,13 @@ static int read_merge_config(const char *var, const char *value, void *cb) * especially, we do not want to look at variables such as * "merge.summary", "merge.tool", and "merge.verbosity". */ - if (prefixcmp(var, "merge.") || (ep = strrchr(var, '.')) == var + 5) + if (parse_config_key(var, "merge", &name, &namelen, &key) < 0 || !name) return 0; /* * Find existing one as we might be processing merge.<name>.var2 * after seeing merge.<name>.var1. */ - name = var + 6; - namelen = ep - name; for (fn = ll_user_merge; fn; fn = fn->next) if (!strncmp(fn->name, name, namelen) && !fn->name[namelen]) break; @@ -256,16 +254,14 @@ static int read_merge_config(const char *var, const char *value, void *cb) ll_user_merge_tail = &(fn->next); } - ep++; - - if (!strcmp("name", ep)) { + if (!strcmp("name", key)) { if (!value) return error("%s: lacks value", var); fn->description = xstrdup(value); return 0; } - if (!strcmp("driver", ep)) { + if (!strcmp("driver", key)) { if (!value) return error("%s: lacks value", var); /* @@ -289,7 +285,7 @@ static int read_merge_config(const char *var, const char *value, void *cb) return 0; } - if (!strcmp("recursive", ep)) { + if (!strcmp("recursive", key)) { if (!value) return error("%s: lacks value", var); fn->recursive = xstrdup(value); diff --git a/mergetools/defaults b/mergetools/defaults deleted file mode 100644 index 21e63ecc3e..0000000000 --- a/mergetools/defaults +++ /dev/null @@ -1,22 +0,0 @@ -# Redefined by builtin tools -can_merge () { - return 0 -} - -can_diff () { - return 0 -} - -diff_cmd () { - status=1 - return $status -} - -merge_cmd () { - status=1 - return $status -} - -translate_merge_tool_path () { - echo "$1" -} diff --git a/mergetools/gvimdiff b/mergetools/gvimdiff new file mode 100644 index 0000000000..04a5bb0ea8 --- /dev/null +++ b/mergetools/gvimdiff @@ -0,0 +1 @@ +. "$MERGE_TOOLS_DIR/vimdiff" diff --git a/mergetools/gvimdiff2 b/mergetools/gvimdiff2 new file mode 100644 index 0000000000..04a5bb0ea8 --- /dev/null +++ b/mergetools/gvimdiff2 @@ -0,0 +1 @@ +. "$MERGE_TOOLS_DIR/vimdiff" diff --git a/mergetools/tortoisemerge b/mergetools/tortoisemerge index ed7db495ed..3b89f1c82d 100644 --- a/mergetools/tortoisemerge +++ b/mergetools/tortoisemerge @@ -6,12 +6,29 @@ merge_cmd () { if $base_present then touch "$BACKUP" - "$merge_tool_path" \ - -base:"$BASE" -mine:"$LOCAL" \ - -theirs:"$REMOTE" -merged:"$MERGED" + basename="$(basename "$merge_tool_path" .exe)" + if test "$basename" = "tortoisegitmerge" + then + "$merge_tool_path" \ + -base "$BASE" -mine "$LOCAL" \ + -theirs "$REMOTE" -merged "$MERGED" + else + "$merge_tool_path" \ + -base:"$BASE" -mine:"$LOCAL" \ + -theirs:"$REMOTE" -merged:"$MERGED" + fi check_unchanged else - echo "TortoiseMerge cannot be used without a base" 1>&2 + echo "$merge_tool_path cannot be used without a base" 1>&2 return 1 fi } + +translate_merge_tool_path() { + if type tortoisegitmerge >/dev/null 2>/dev/null + then + echo tortoisegitmerge + else + echo tortoisemerge + fi +} diff --git a/mergetools/vim b/mergetools/vimdiff index 619594ae4b..39d032771b 100644 --- a/mergetools/vim +++ b/mergetools/vimdiff @@ -1,14 +1,6 @@ diff_cmd () { - case "$1" in - gvimdiff|vimdiff) - "$merge_tool_path" -R -f -d \ - -c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE" - ;; - gvimdiff2|vimdiff2) - "$merge_tool_path" -R -f -d \ - -c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE" - ;; - esac + "$merge_tool_path" -R -f -d \ + -c 'wincmd l' -c 'cd $GIT_PREFIX' "$LOCAL" "$REMOTE" } merge_cmd () { diff --git a/mergetools/vimdiff2 b/mergetools/vimdiff2 new file mode 100644 index 0000000000..04a5bb0ea8 --- /dev/null +++ b/mergetools/vimdiff2 @@ -0,0 +1 @@ +. "$MERGE_TOOLS_DIR/vimdiff" diff --git a/parse-options.h b/parse-options.h index e703853749..1c8bd8d5a0 100644 --- a/parse-options.h +++ b/parse-options.h @@ -177,7 +177,7 @@ extern NORETURN void usage_msg_opt(const char *msg, extern int optbug(const struct option *opt, const char *reason); extern int opterror(const struct option *opt, const char *reason, int flags); -#ifdef __GNUC__ +#if defined(__GNUC__) && ! defined(clang) #define opterror(o,r,f) (opterror((o),(r),(f)), -1) #endif diff --git a/pathspec.c b/pathspec.c new file mode 100644 index 0000000000..284f3970a3 --- /dev/null +++ b/pathspec.c @@ -0,0 +1,101 @@ +#include "cache.h" +#include "dir.h" +#include "pathspec.h" + +/* + * Finds which of the given pathspecs match items in the index. + * + * For each pathspec, sets the corresponding entry in the seen[] array + * (which should be specs items long, i.e. the same size as pathspec) + * to the nature of the "closest" (i.e. most specific) match found for + * that pathspec in the index, if it was a closer type of match than + * the existing entry. As an optimization, matching is skipped + * altogether if seen[] already only contains non-zero entries. + * + * If seen[] has not already been written to, it may make sense + * to use find_pathspecs_matching_against_index() instead. + */ +void add_pathspec_matches_against_index(const char **pathspec, + char *seen, int specs) +{ + int num_unmatched = 0, i; + + /* + * Since we are walking the index as if we were walking the directory, + * we have to mark the matched pathspec as seen; otherwise we will + * mistakenly think that the user gave a pathspec that did not match + * anything. + */ + for (i = 0; i < specs; i++) + if (!seen[i]) + num_unmatched++; + if (!num_unmatched) + return; + for (i = 0; i < active_nr; i++) { + struct cache_entry *ce = active_cache[i]; + match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen); + } +} + +/* + * Finds which of the given pathspecs match items in the index. + * + * This is a one-shot wrapper around add_pathspec_matches_against_index() + * which allocates, populates, and returns a seen[] array indicating the + * nature of the "closest" (i.e. most specific) matches which each of the + * given pathspecs achieves against all items in the index. + */ +char *find_pathspecs_matching_against_index(const char **pathspec) +{ + char *seen; + int i; + + for (i = 0; pathspec[i]; i++) + ; /* just counting */ + seen = xcalloc(i, 1); + add_pathspec_matches_against_index(pathspec, seen, i); + return seen; +} + +/* + * Check the index to see whether path refers to a submodule, or + * something inside a submodule. If the former, returns the path with + * any trailing slash stripped. If the latter, dies with an error + * message. + */ +const char *check_path_for_gitlink(const char *path) +{ + int i, path_len = strlen(path); + for (i = 0; i < active_nr; i++) { + struct cache_entry *ce = active_cache[i]; + if (S_ISGITLINK(ce->ce_mode)) { + int ce_len = ce_namelen(ce); + if (path_len <= ce_len || path[ce_len] != '/' || + memcmp(ce->name, path, ce_len)) + /* path does not refer to this + * submodule or anything inside it */ + continue; + if (path_len == ce_len + 1) { + /* path refers to submodule; + * strip trailing slash */ + return xstrndup(ce->name, ce_len); + } else { + die (_("Path '%s' is in submodule '%.*s'"), + path, ce_len, ce->name); + } + } + } + return path; +} + +/* + * Dies if the given path refers to a file inside a symlinked + * directory in the index. + */ +void die_if_path_beyond_symlink(const char *path, const char *prefix) +{ + if (has_symlink_leading_path(path, strlen(path))) { + int len = prefix ? strlen(prefix) : 0; + die(_("'%s' is beyond a symbolic link"), path + len); + } +} diff --git a/pathspec.h b/pathspec.h new file mode 100644 index 0000000000..db0184a1ac --- /dev/null +++ b/pathspec.h @@ -0,0 +1,9 @@ +#ifndef PATHSPEC_H +#define PATHSPEC_H + +extern char *find_pathspecs_matching_against_index(const char **pathspec); +extern void add_pathspec_matches_against_index(const char **pathspec, char *seen, int specs); +extern const char *check_path_for_gitlink(const char *path); +extern void die_if_path_beyond_symlink(const char *path, const char *prefix); + +#endif /* PATHSPEC_H */ diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm index 59215fa86e..490e330380 100644 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@ -490,7 +490,7 @@ sub refname { # # Additionally, % must be escaped because it is used for escaping # and we want our escaped refname to be reversible - $refname =~ s{([ \%~\^:\?\*\[\t])}{uc sprintf('%%%02x',ord($1))}eg; + $refname =~ s{([ \%~\^:\?\*\[\t])}{sprintf('%%%02X',ord($1))}eg; # no slash-separated component can begin with a dot . # /.* becomes /%2E* @@ -2377,7 +2377,7 @@ sub map_path { sub uri_encode { my ($f) = @_; - $f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#uc sprintf("%%%02x",ord($1))#eg; + $f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#sprintf("%%%02X",ord($1))#eg; $f } diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm index 3db152155c..fa0d3c6cdd 100644 --- a/perl/Git/SVN/Editor.pm +++ b/perl/Git/SVN/Editor.pm @@ -146,7 +146,7 @@ sub url_path { my ($self, $path) = @_; if ($self->{url} =~ m#^https?://#) { # characters are taken from subversion/libsvn_subr/path.c - $path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#uc sprintf("%%%02x",ord($1))#eg; + $path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#sprintf("%%%02X",ord($1))#eg; } $self->{url} . '/' . $self->repo_path($path); } @@ -524,10 +524,11 @@ static void add_merge_info(const struct pretty_print_context *pp, strbuf_addch(sb, '\n'); } -static char *get_header(const struct commit *commit, const char *key) +static char *get_header(const struct commit *commit, const char *msg, + const char *key) { int key_len = strlen(key); - const char *line = commit->buffer; + const char *line = msg; while (line) { const char *eol = strchr(line, '\n'), *next; @@ -588,25 +589,77 @@ char *logmsg_reencode(const struct commit *commit, static const char *utf8 = "UTF-8"; const char *use_encoding; char *encoding; + char *msg = commit->buffer; char *out; + if (!msg) { + enum object_type type; + unsigned long size; + + msg = read_sha1_file(commit->object.sha1, &type, &size); + if (!msg) + die("Cannot read commit object %s", + sha1_to_hex(commit->object.sha1)); + if (type != OBJ_COMMIT) + die("Expected commit for '%s', got %s", + sha1_to_hex(commit->object.sha1), typename(type)); + } + if (!output_encoding || !*output_encoding) - return NULL; - encoding = get_header(commit, "encoding"); + return msg; + encoding = get_header(commit, msg, "encoding"); use_encoding = encoding ? encoding : utf8; - if (same_encoding(use_encoding, output_encoding)) - if (encoding) /* we'll strip encoding header later */ - out = xstrdup(commit->buffer); - else - return NULL; /* nothing to do */ - else - out = reencode_string(commit->buffer, - output_encoding, use_encoding); + if (same_encoding(use_encoding, output_encoding)) { + /* + * No encoding work to be done. If we have no encoding header + * at all, then there's nothing to do, and we can return the + * message verbatim (whether newly allocated or not). + */ + if (!encoding) + return msg; + + /* + * Otherwise, we still want to munge the encoding header in the + * result, which will be done by modifying the buffer. If we + * are using a fresh copy, we can reuse it. But if we are using + * the cached copy from commit->buffer, we need to duplicate it + * to avoid munging commit->buffer. + */ + out = msg; + if (out == commit->buffer) + out = xstrdup(out); + } + else { + /* + * There's actual encoding work to do. Do the reencoding, which + * still leaves the header to be replaced in the next step. At + * this point, we are done with msg. If we allocated a fresh + * copy, we can free it. + */ + out = reencode_string(msg, output_encoding, use_encoding); + if (out && msg != commit->buffer) + free(msg); + } + + /* + * This replacement actually consumes the buffer we hand it, so we do + * not have to worry about freeing the old "out" here. + */ if (out) out = replace_encoding_header(out, output_encoding); free(encoding); - return out; + /* + * If the re-encoding failed, out might be NULL here; in that + * case we just return the commit message verbatim. + */ + return out ? out : msg; +} + +void logmsg_free(char *msg, const struct commit *commit) +{ + if (msg != commit->buffer) + free(msg); } static int mailmap_name(const char **email, size_t *email_len, @@ -1278,14 +1331,11 @@ void format_commit_message(const struct commit *commit, context.pretty_ctx = pretty_ctx; context.wrap_start = sb->len; context.message = logmsg_reencode(commit, output_enc); - if (!context.message) - context.message = commit->buffer; strbuf_expand(sb, format, format_commit_item, &context); rewrap_message_tail(sb, &context, 0, 0, 0); - if (context.message != commit->buffer) - free(context.message); + logmsg_free(context.message, commit); free(context.signature.gpg_output); free(context.signature.signer); } @@ -1432,7 +1482,7 @@ void pretty_print_commit(const struct pretty_print_context *pp, { unsigned long beginning_of_body; int indent = 4; - const char *msg = commit->buffer; + const char *msg; char *reencoded; const char *encoding; int need_8bit_cte = pp->need_8bit_cte; @@ -1443,10 +1493,7 @@ void pretty_print_commit(const struct pretty_print_context *pp, } encoding = get_log_output_encoding(); - reencoded = logmsg_reencode(commit, encoding); - if (reencoded) { - msg = reencoded; - } + msg = reencoded = logmsg_reencode(commit, encoding); if (pp->fmt == CMIT_FMT_ONELINE || pp->fmt == CMIT_FMT_EMAIL) indent = 0; @@ -1503,7 +1550,7 @@ void pretty_print_commit(const struct pretty_print_context *pp, if (pp->fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body) strbuf_addch(sb, '\n'); - free(reencoded); + logmsg_free(reencoded, commit); } void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit, diff --git a/read-cache.c b/read-cache.c index fda78bc353..827ae55c50 100644 --- a/read-cache.c +++ b/read-cache.c @@ -197,21 +197,25 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) } if (ce->ce_mtime.sec != (unsigned int)st->st_mtime) changed |= MTIME_CHANGED; - if (trust_ctime && ce->ce_ctime.sec != (unsigned int)st->st_ctime) + if (trust_ctime && check_stat && + ce->ce_ctime.sec != (unsigned int)st->st_ctime) changed |= CTIME_CHANGED; #ifdef USE_NSEC - if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st)) + if (check_stat && ce->ce_mtime.nsec != ST_MTIME_NSEC(*st)) changed |= MTIME_CHANGED; - if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st)) + if (trust_ctime && check_stat && + ce->ce_ctime.nsec != ST_CTIME_NSEC(*st)) changed |= CTIME_CHANGED; #endif - if (ce->ce_uid != (unsigned int) st->st_uid || - ce->ce_gid != (unsigned int) st->st_gid) - changed |= OWNER_CHANGED; - if (ce->ce_ino != (unsigned int) st->st_ino) - changed |= INODE_CHANGED; + if (check_stat) { + if (ce->ce_uid != (unsigned int) st->st_uid || + ce->ce_gid != (unsigned int) st->st_gid) + changed |= OWNER_CHANGED; + if (ce->ce_ino != (unsigned int) st->st_ino) + changed |= INODE_CHANGED; + } #ifdef USE_STDEV /* @@ -219,8 +223,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) * clients will have different views of what "device" * the filesystem is on */ - if (ce->ce_dev != (unsigned int) st->st_dev) - changed |= INODE_CHANGED; + if (check_stat && ce->ce_dev != (unsigned int) st->st_dev) + changed |= INODE_CHANGED; #endif if (ce->ce_size != (unsigned int) st->st_size) @@ -333,14 +333,12 @@ struct string_slice { static int ref_entry_cmp_sslice(const void *key_, const void *ent_) { - struct string_slice *key = (struct string_slice *)key_; - struct ref_entry *ent = *(struct ref_entry **)ent_; - int entlen = strlen(ent->name); - int cmplen = key->len < entlen ? key->len : entlen; - int cmp = memcmp(key->str, ent->name, cmplen); + const struct string_slice *key = key_; + const struct ref_entry *ent = *(const struct ref_entry * const *)ent_; + int cmp = strncmp(key->str, ent->name, key->len); if (cmp) return cmp; - return key->len - entlen; + return '\0' - (unsigned char)ent->name[key->len]; } /* @@ -1279,26 +1279,6 @@ int match_push_refs(struct ref *src, struct ref **dst, return 0; } -static inline int is_forwardable(struct ref* ref) -{ - struct object *o; - - if (!prefixcmp(ref->name, "refs/tags/")) - return 0; - - /* old object must be a commit */ - o = parse_object(ref->old_sha1); - if (!o || o->type != OBJ_COMMIT) - return 0; - - /* new object must be commit-ish */ - o = deref_tag(parse_object(ref->new_sha1), NULL, 0); - if (!o || o->type != OBJ_COMMIT) - return 0; - - return 1; -} - void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, int force_update) { @@ -1320,54 +1300,40 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, } /* - * The below logic determines whether an individual - * refspec A:B can be pushed. The push will succeed - * if any of the following are true: + * Decide whether an individual refspec A:B can be + * pushed. The push will succeed if any of the + * following are true: * * (1) the remote reference B does not exist * * (2) the remote reference B is being removed (i.e., * pushing :B where no source is specified) * - * (3) the update meets all fast-forwarding criteria: - * - * (a) the destination is not under refs/tags/ - * (b) the old is a commit - * (c) the new is a descendant of the old - * - * NOTE: We must actually have the old object in - * order to overwrite it in the remote reference, - * and the new object must be commit-ish. These are - * implied by (b) and (c) respectively. + * (3) the destination is not under refs/tags/, and + * if the old and new value is a commit, the new + * is a descendant of the old. * * (4) it is forced using the +A:B notation, or by * passing the --force argument */ - ref->not_forwardable = !is_forwardable(ref); - - ref->update = - !ref->deletion && - !is_null_sha1(ref->old_sha1); - - if (ref->update) { - ref->nonfastforward = - !has_sha1_file(ref->old_sha1) - || !ref_newer(ref->new_sha1, ref->old_sha1); - - if (ref->not_forwardable) { - ref->requires_force = 1; - if (!force_ref_update) { - ref->status = REF_STATUS_REJECT_ALREADY_EXISTS; - continue; - } - } else if (ref->nonfastforward) { - ref->requires_force = 1; - if (!force_ref_update) { - ref->status = REF_STATUS_REJECT_NONFASTFORWARD; - continue; - } - } + if (!ref->deletion && !is_null_sha1(ref->old_sha1)) { + int why = 0; /* why would this push require --force? */ + + if (!prefixcmp(ref->name, "refs/tags/")) + why = REF_STATUS_REJECT_ALREADY_EXISTS; + else if (!has_sha1_file(ref->old_sha1)) + why = REF_STATUS_REJECT_FETCH_FIRST; + else if (!lookup_commit_reference_gently(ref->old_sha1, 1) || + !lookup_commit_reference_gently(ref->new_sha1, 1)) + why = REF_STATUS_REJECT_NEEDS_FORCE; + else if (!ref_newer(ref->new_sha1, ref->old_sha1)) + why = REF_STATUS_REJECT_NONFASTFORWARD; + + if (!force_ref_update) + ref->status = why; + else if (why) + ref->forced_update = 1; } } } @@ -1561,7 +1527,8 @@ int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1) struct commit_list *list, *used; int found = 0; - /* Both new and old must be commit-ish and new is descendant of + /* + * Both new and old must be commit-ish and new is descendant of * old. Otherwise we require --force. */ o = deref_tag(parse_object(old_sha1), NULL, 0); diff --git a/run-command.c b/run-command.c index 04712191e8..07e27ff4c8 100644 --- a/run-command.c +++ b/run-command.c @@ -274,6 +274,7 @@ int start_command(struct child_process *cmd) int need_in, need_out, need_err; int fdin[2], fdout[2], fderr[2]; int failed_errno = failed_errno; + char *str; /* * In case of errors we must keep the promise to close FDs @@ -286,6 +287,7 @@ int start_command(struct child_process *cmd) failed_errno = errno; if (cmd->out > 0) close(cmd->out); + str = "standard input"; goto fail_pipe; } cmd->in = fdin[1]; @@ -301,6 +303,7 @@ int start_command(struct child_process *cmd) close_pair(fdin); else if (cmd->in) close(cmd->in); + str = "standard output"; goto fail_pipe; } cmd->out = fdout[0]; @@ -318,9 +321,10 @@ int start_command(struct child_process *cmd) close_pair(fdout); else if (cmd->out) close(cmd->out); + str = "standard error"; fail_pipe: - error("cannot create pipe for %s: %s", - cmd->argv[0], strerror(failed_errno)); + error("cannot create %s pipe for %s: %s", + str, cmd->argv[0], strerror(failed_errno)); errno = failed_errno; return -1; } @@ -735,6 +739,15 @@ int finish_async(struct async *async) #endif } +char *find_hook(const char *name) +{ + char *path = git_path("hooks/%s", name); + if (access(path, X_OK) < 0) + path = NULL; + + return path; +} + int run_hook(const char *index_file, const char *name, ...) { struct child_process hook; @@ -744,11 +757,13 @@ int run_hook(const char *index_file, const char *name, ...) va_list args; int ret; - if (access(git_path("hooks/%s", name), X_OK) < 0) + p = find_hook(name); + if (!p) return 0; + argv_array_push(&argv, p); + va_start(args, name); - argv_array_push(&argv, git_path("hooks/%s", name)); while ((p = va_arg(args, const char *))) argv_array_push(&argv, p); va_end(args); diff --git a/run-command.h b/run-command.h index 850c638f19..221ce33140 100644 --- a/run-command.h +++ b/run-command.h @@ -45,6 +45,7 @@ int start_command(struct child_process *); int finish_command(struct child_process *); int run_command(struct child_process *); +extern char *find_hook(const char *name); extern int run_hook(const char *index_file, const char *name, ...); #define RUN_COMMAND_NO_STDIN 1 diff --git a/send-pack.c b/send-pack.c index 1c375f0a28..97ab336097 100644 --- a/send-pack.c +++ b/send-pack.c @@ -230,6 +230,8 @@ int send_pack(struct send_pack_args *args, switch (ref->status) { case REF_STATUS_REJECT_NONFASTFORWARD: case REF_STATUS_REJECT_ALREADY_EXISTS: + case REF_STATUS_REJECT_FETCH_FIRST: + case REF_STATUS_REJECT_NEEDS_FORCE: case REF_STATUS_UPTODATE: continue; default: @@ -66,7 +66,14 @@ int check_filename(const char *prefix, const char *arg) const char *name; struct stat st; - name = prefix ? prefix_filename(prefix, strlen(prefix), arg) : arg; + if (!prefixcmp(arg, ":/")) { + if (arg[2] == '\0') /* ":/" is root dir, always exists */ + return 1; + name = arg + 2; + } else if (prefix) + name = prefix_filename(prefix, strlen(prefix), arg); + else + name = arg; if (!lstat(name, &st)) return 1; /* file exists */ if (errno == ENOENT || errno == ENOTDIR) @@ -246,6 +253,25 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char return prefix_path(prefix, prefixlen, copyfrom); } +/* + * N.B. get_pathspec() is deprecated in favor of the "struct pathspec" + * based interface - see pathspec_magic above. + * + * Arguments: + * - prefix - a path relative to the root of the working tree + * - pathspec - a list of paths underneath the prefix path + * + * Iterates over pathspec, prepending each path with prefix, + * and return the resulting list. + * + * If pathspec is empty, return a singleton list containing prefix. + * + * If pathspec and prefix are both empty, return an empty list. + * + * This is typically used by built-in commands such as add.c, in order + * to normalize argv arguments provided to the built-in into a list of + * paths to process, all relative to the root of the working tree. + */ const char **get_pathspec(const char *prefix, const char **pathspec) { const char *entry = *pathspec; @@ -72,8 +72,14 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth, } if (parse_commit(commit)) die("invalid commit"); - commit->object.flags |= not_shallow_flag; cur_depth++; + if (cur_depth >= depth) { + commit_list_insert(commit, &result); + commit->object.flags |= shallow_flag; + commit = NULL; + continue; + } + commit->object.flags |= not_shallow_flag; for (p = commit->parents, commit = NULL; p; p = p->next) { if (!p->item->util) { int *pointer = xmalloc(sizeof(int)); @@ -204,6 +204,54 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...) va_end(ap); } +static void add_lines(struct strbuf *out, + const char *prefix1, + const char *prefix2, + const char *buf, size_t size) +{ + while (size) { + const char *prefix; + const char *next = memchr(buf, '\n', size); + next = next ? (next + 1) : (buf + size); + + prefix = (prefix2 && buf[0] == '\n') ? prefix2 : prefix1; + strbuf_addstr(out, prefix); + strbuf_add(out, buf, next - buf); + size -= next - buf; + buf = next; + } + strbuf_complete_line(out); +} + +void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size) +{ + static char prefix1[3]; + static char prefix2[2]; + + if (prefix1[0] != comment_line_char) { + sprintf(prefix1, "%c ", comment_line_char); + sprintf(prefix2, "%c", comment_line_char); + } + add_lines(out, prefix1, prefix2, buf, size); +} + +void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...) +{ + va_list params; + struct strbuf buf = STRBUF_INIT; + int incomplete_line = sb->len && sb->buf[sb->len - 1] != '\n'; + + va_start(params, fmt); + strbuf_vaddf(&buf, fmt, params); + va_end(params); + + strbuf_add_commented_lines(sb, buf.buf, buf.len); + if (incomplete_line) + sb->buf[--sb->len] = '\0'; + + strbuf_release(&buf); +} + void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap) { int len; @@ -414,15 +462,7 @@ int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) void strbuf_add_lines(struct strbuf *out, const char *prefix, const char *buf, size_t size) { - while (size) { - const char *next = memchr(buf, '\n', size); - next = next ? (next + 1) : (buf + size); - strbuf_addstr(out, prefix); - strbuf_add(out, buf, next - buf); - size -= next - buf; - buf = next; - } - strbuf_complete_line(out); + add_lines(out, prefix, NULL, buf, size); } void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s) @@ -110,6 +110,8 @@ extern void strbuf_remove(struct strbuf *, size_t pos, size_t len); extern void strbuf_splice(struct strbuf *, size_t pos, size_t len, const void *, size_t); +extern void strbuf_add_commented_lines(struct strbuf *out, const char *buf, size_t size); + extern void strbuf_add(struct strbuf *, const void *, size_t); static inline void strbuf_addstr(struct strbuf *sb, const char *s) { strbuf_add(sb, s, strlen(s)); @@ -131,6 +133,8 @@ extern void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf * __attribute__((format (printf,2,3))) extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...); +__attribute__((format (printf, 2, 3))) +extern void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...); __attribute__((format (printf,2,0))) extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap); diff --git a/submodule.c b/submodule.c index 2f55436234..9ba1496543 100644 --- a/submodule.c +++ b/submodule.c @@ -126,45 +126,44 @@ void gitmodules_config(void) int parse_submodule_config_option(const char *var, const char *value) { - int len; struct string_list_item *config; - struct strbuf submodname = STRBUF_INIT; + const char *name, *key; + int namelen; - var += 10; /* Skip "submodule." */ + if (parse_config_key(var, "submodule", &name, &namelen, &key) < 0 || !name) + return 0; - len = strlen(var); - if ((len > 5) && !strcmp(var + len - 5, ".path")) { - strbuf_add(&submodname, var, len - 5); + if (!strcmp(key, "path")) { config = unsorted_string_list_lookup(&config_name_for_path, value); if (config) free(config->util); else config = string_list_append(&config_name_for_path, xstrdup(value)); - config->util = strbuf_detach(&submodname, NULL); - strbuf_release(&submodname); - } else if ((len > 23) && !strcmp(var + len - 23, ".fetchrecursesubmodules")) { - strbuf_add(&submodname, var, len - 23); - config = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, submodname.buf); + config->util = xmemdupz(name, namelen); + } else if (!strcmp(key, "fetchrecursesubmodules")) { + char *name_cstr = xmemdupz(name, namelen); + config = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name_cstr); if (!config) - config = string_list_append(&config_fetch_recurse_submodules_for_name, - strbuf_detach(&submodname, NULL)); + config = string_list_append(&config_fetch_recurse_submodules_for_name, name_cstr); + else + free(name_cstr); config->util = (void *)(intptr_t)parse_fetch_recurse_submodules_arg(var, value); - strbuf_release(&submodname); - } else if ((len > 7) && !strcmp(var + len - 7, ".ignore")) { + } else if (!strcmp(key, "ignore")) { + char *name_cstr; + if (strcmp(value, "untracked") && strcmp(value, "dirty") && strcmp(value, "all") && strcmp(value, "none")) { warning("Invalid parameter \"%s\" for config option \"submodule.%s.ignore\"", value, var); return 0; } - strbuf_add(&submodname, var, len - 7); - config = unsorted_string_list_lookup(&config_ignore_for_name, submodname.buf); - if (config) + name_cstr = xmemdupz(name, namelen); + config = unsorted_string_list_lookup(&config_ignore_for_name, name_cstr); + if (config) { free(config->util); - else - config = string_list_append(&config_ignore_for_name, - strbuf_detach(&submodname, NULL)); - strbuf_release(&submodname); + free(name_cstr); + } else + config = string_list_append(&config_ignore_for_name, name_cstr); config->util = xstrdup(value); return 0; } diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh index 7061dce7e5..2098b9ba05 100644 --- a/t/lib-git-p4.sh +++ b/t/lib-git-p4.sh @@ -8,7 +8,8 @@ TEST_NO_CREATE_REPO=NoThanks . ./test-lib.sh -if ! test_have_prereq PYTHON; then +if ! test_have_prereq PYTHON +then skip_all='skipping git p4 tests; python not available' test_done fi @@ -17,6 +18,24 @@ fi test_done } +# On cygwin, the NT version of Perforce can be used. When giving +# it paths, either on the command-line or in client specifications, +# be sure to use the native windows form. +# +# Older versions of perforce were available compiled natively for +# cygwin. Those do not accept native windows paths, so make sure +# not to convert for them. +native_path() { + path="$1" && + if test_have_prereq CYGWIN && ! p4 -V | grep -q CYGWIN + then + path=$(cygpath --windows "$path") + else + path=$(test-path-utils real_path "$path") + fi && + echo "$path" +} + # Try to pick a unique port: guess a large number, then hope # no more than one of each test is running. # @@ -32,7 +51,7 @@ P4EDITOR=: export P4PORT P4CLIENT P4EDITOR db="$TRASH_DIRECTORY/db" -cli=$(test-path-utils real_path "$TRASH_DIRECTORY/cli") +cli="$TRASH_DIRECTORY/cli" git="$TRASH_DIRECTORY/git" pidfile="$TRASH_DIRECTORY/p4d.pid" @@ -40,8 +59,11 @@ start_p4d() { mkdir -p "$db" "$cli" "$git" && rm -f "$pidfile" && ( - p4d -q -r "$db" -p $P4DPORT & - echo $! >"$pidfile" + cd "$db" && + { + p4d -q -p $P4DPORT & + echo $! >"$pidfile" + } ) && # This gives p4d a long time to start up, as it can be @@ -74,15 +96,8 @@ start_p4d() { fi # build a client - ( - cd "$cli" && - p4 client -i <<-EOF - Client: client - Description: client - Root: $cli - View: //depot/... //client/... - EOF - ) + client_view "//depot/... //client/..." && + return 0 } @@ -123,13 +138,26 @@ marshal_dump() { client_view() { ( cat <<-EOF && - Client: client - Description: client + Client: $P4CLIENT + Description: $P4CLIENT Root: $cli + AltRoots: $(native_path "$cli") + LineEnd: unix View: EOF - for arg ; do - printf "\t$arg\n" - done + printf "\t%s\n" "$@" ) | p4 client -i } + +is_cli_file_writeable() { + # cygwin version of p4 does not set read-only attr, + # will be marked 444 but -w is true + file="$1" && + if test_have_prereq CYGWIN && p4 -V | grep -q CYGWIN + then + stat=$(stat --format=%a "$file") && + test $stat = 644 + else + test -w "$file" + fi +} diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh new file mode 100755 index 0000000000..d7df7198c4 --- /dev/null +++ b/t/t0008-ignores.sh @@ -0,0 +1,637 @@ +#!/bin/sh + +test_description=check-ignore + +. ./test-lib.sh + +init_vars () { + global_excludes="$(pwd)/global-excludes" +} + +enable_global_excludes () { + init_vars && + git config core.excludesfile "$global_excludes" +} + +expect_in () { + dest="$HOME/expected-$1" text="$2" + if test -z "$text" + then + >"$dest" # avoid newline + else + echo "$text" >"$dest" + fi +} + +expect () { + expect_in stdout "$1" +} + +expect_from_stdin () { + cat >"$HOME/expected-stdout" +} + +test_stderr () { + expected="$1" + expect_in stderr "$1" && + test_cmp "$HOME/expected-stderr" "$HOME/stderr" +} + +stderr_contains () { + regexp="$1" + if grep "$regexp" "$HOME/stderr" + then + return 0 + else + echo "didn't find /$regexp/ in $HOME/stderr" + cat "$HOME/stderr" + return 1 + fi +} + +stderr_empty_on_success () { + expect_code="$1" + if test $expect_code = 0 + then + test_stderr "" + else + # If we expect failure then stderr might or might not be empty + # due to --quiet - the caller can check its contents + return 0 + fi +} + +test_check_ignore () { + args="$1" expect_code="${2:-0}" global_args="$3" + + init_vars && + rm -f "$HOME/stdout" "$HOME/stderr" "$HOME/cmd" && + echo git $global_args check-ignore $quiet_opt $verbose_opt $args \ + >"$HOME/cmd" && + test_expect_code "$expect_code" \ + git $global_args check-ignore $quiet_opt $verbose_opt $args \ + >"$HOME/stdout" 2>"$HOME/stderr" && + test_cmp "$HOME/expected-stdout" "$HOME/stdout" && + stderr_empty_on_success "$expect_code" +} + +test_expect_success_multi () { + prereq= + if test $# -eq 4 + then + prereq=$1 + shift + fi + testname="$1" expect_verbose="$2" code="$3" + + expect=$( echo "$expect_verbose" | sed -e 's/.* //' ) + + test_expect_success $prereq "$testname" ' + expect "$expect" && + eval "$code" + ' + + for quiet_opt in '-q' '--quiet' + do + test_expect_success $prereq "$testname${quiet_opt:+ with $quiet_opt}" " + expect '' && + $code + " + done + quiet_opt= + + for verbose_opt in '-v' '--verbose' + do + test_expect_success $prereq "$testname${verbose_opt:+ with $verbose_opt}" " + expect '$expect_verbose' && + $code + " + done + verbose_opt= +} + +test_expect_success 'setup' ' + init_vars && + mkdir -p a/b/ignored-dir a/submodule b && + if test_have_prereq SYMLINKS + then + ln -s b a/symlink + fi && + ( + cd a/submodule && + git init && + echo a >a && + git add a && + git commit -m"commit in submodule" + ) && + git add a/submodule && + cat <<-\EOF >.gitignore && + one + ignored-* + EOF + for dir in . a + do + : >$dir/not-ignored && + : >$dir/ignored-and-untracked && + : >$dir/ignored-but-in-index + done && + git add -f ignored-but-in-index a/ignored-but-in-index && + cat <<-\EOF >a/.gitignore && + two* + *three + EOF + cat <<-\EOF >a/b/.gitignore && + four + five + # this comment should affect the line numbers + six + ignored-dir/ + # and so should this blank line: + + !on* + !two + EOF + echo "seven" >a/b/ignored-dir/.gitignore && + test -n "$HOME" && + cat <<-\EOF >"$global_excludes" && + globalone + !globaltwo + globalthree + EOF + cat <<-\EOF >>.git/info/exclude + per-repo + EOF +' + +############################################################################ +# +# test invalid inputs + +test_expect_success_multi 'empty command line' '' ' + test_check_ignore "" 128 && + stderr_contains "fatal: no path specified" +' + +test_expect_success_multi '--stdin with empty STDIN' '' ' + test_check_ignore "--stdin" 1 </dev/null && + if test -n "$quiet_opt"; then + test_stderr "" + else + test_stderr "no pathspec given." + fi +' + +test_expect_success '-q with multiple args' ' + expect "" && + test_check_ignore "-q one two" 128 && + stderr_contains "fatal: --quiet is only valid with a single pathname" +' + +test_expect_success '--quiet with multiple args' ' + expect "" && + test_check_ignore "--quiet one two" 128 && + stderr_contains "fatal: --quiet is only valid with a single pathname" +' + +for verbose_opt in '-v' '--verbose' +do + for quiet_opt in '-q' '--quiet' + do + test_expect_success "$quiet_opt $verbose_opt" " + expect '' && + test_check_ignore '$quiet_opt $verbose_opt foo' 128 && + stderr_contains 'fatal: cannot have both --quiet and --verbose' + " + done +done + +test_expect_success '--quiet with multiple args' ' + expect "" && + test_check_ignore "--quiet one two" 128 && + stderr_contains "fatal: --quiet is only valid with a single pathname" +' + +test_expect_success_multi 'erroneous use of --' '' ' + test_check_ignore "--" 128 && + stderr_contains "fatal: no path specified" +' + +test_expect_success_multi '--stdin with superfluous arg' '' ' + test_check_ignore "--stdin foo" 128 && + stderr_contains "fatal: cannot specify pathnames with --stdin" +' + +test_expect_success_multi '--stdin -z with superfluous arg' '' ' + test_check_ignore "--stdin -z foo" 128 && + stderr_contains "fatal: cannot specify pathnames with --stdin" +' + +test_expect_success_multi '-z without --stdin' '' ' + test_check_ignore "-z" 128 && + stderr_contains "fatal: -z only makes sense with --stdin" +' + +test_expect_success_multi '-z without --stdin and superfluous arg' '' ' + test_check_ignore "-z foo" 128 && + stderr_contains "fatal: -z only makes sense with --stdin" +' + +test_expect_success_multi 'needs work tree' '' ' + ( + cd .git && + test_check_ignore "foo" 128 + ) && + stderr_contains "fatal: This operation must be run in a work tree" +' + +############################################################################ +# +# test standard ignores + +# First make sure that the presence of a file in the working tree +# does not impact results, but that the presence of a file in the +# index does. + +for subdir in '' 'a/' +do + if test -z "$subdir" + then + where="at top-level" + else + where="in subdir $subdir" + fi + + test_expect_success_multi "non-existent file $where not ignored" '' " + test_check_ignore '${subdir}non-existent' 1 + " + + test_expect_success_multi "non-existent file $where ignored" \ + ".gitignore:1:one ${subdir}one" " + test_check_ignore '${subdir}one' + " + + test_expect_success_multi "existing untracked file $where not ignored" '' " + test_check_ignore '${subdir}not-ignored' 1 + " + + test_expect_success_multi "existing tracked file $where not ignored" '' " + test_check_ignore '${subdir}ignored-but-in-index' 1 + " + + test_expect_success_multi "existing untracked file $where ignored" \ + ".gitignore:2:ignored-* ${subdir}ignored-and-untracked" " + test_check_ignore '${subdir}ignored-and-untracked' + " +done + +# Having established the above, from now on we mostly test against +# files which do not exist in the working tree or index. + +test_expect_success 'sub-directory local ignore' ' + expect "a/3-three" && + test_check_ignore "a/3-three a/three-not-this-one" +' + +test_expect_success 'sub-directory local ignore with --verbose' ' + expect "a/.gitignore:2:*three a/3-three" && + test_check_ignore "--verbose a/3-three a/three-not-this-one" +' + +test_expect_success 'local ignore inside a sub-directory' ' + expect "3-three" && + ( + cd a && + test_check_ignore "3-three three-not-this-one" + ) +' +test_expect_success 'local ignore inside a sub-directory with --verbose' ' + expect "a/.gitignore:2:*three 3-three" && + ( + cd a && + test_check_ignore "--verbose 3-three three-not-this-one" + ) +' + +test_expect_success_multi 'nested include' \ + 'a/b/.gitignore:8:!on* a/b/one' ' + test_check_ignore "a/b/one" +' + +############################################################################ +# +# test ignored sub-directories + +test_expect_success_multi 'ignored sub-directory' \ + 'a/b/.gitignore:5:ignored-dir/ a/b/ignored-dir' ' + test_check_ignore "a/b/ignored-dir" +' + +test_expect_success 'multiple files inside ignored sub-directory' ' + expect_from_stdin <<-\EOF && + a/b/ignored-dir/foo + a/b/ignored-dir/twoooo + a/b/ignored-dir/seven + EOF + test_check_ignore "a/b/ignored-dir/foo a/b/ignored-dir/twoooo a/b/ignored-dir/seven" +' + +test_expect_success 'multiple files inside ignored sub-directory with -v' ' + expect_from_stdin <<-\EOF && + a/b/.gitignore:5:ignored-dir/ a/b/ignored-dir/foo + a/b/.gitignore:5:ignored-dir/ a/b/ignored-dir/twoooo + a/b/.gitignore:5:ignored-dir/ a/b/ignored-dir/seven + EOF + test_check_ignore "-v a/b/ignored-dir/foo a/b/ignored-dir/twoooo a/b/ignored-dir/seven" +' + +test_expect_success 'cd to ignored sub-directory' ' + expect_from_stdin <<-\EOF && + foo + twoooo + ../one + seven + ../../one + EOF + ( + cd a/b/ignored-dir && + test_check_ignore "foo twoooo ../one seven ../../one" + ) +' + +test_expect_success 'cd to ignored sub-directory with -v' ' + expect_from_stdin <<-\EOF && + a/b/.gitignore:5:ignored-dir/ foo + a/b/.gitignore:5:ignored-dir/ twoooo + a/b/.gitignore:8:!on* ../one + a/b/.gitignore:5:ignored-dir/ seven + .gitignore:1:one ../../one + EOF + ( + cd a/b/ignored-dir && + test_check_ignore "-v foo twoooo ../one seven ../../one" + ) +' + +############################################################################ +# +# test handling of symlinks + +test_expect_success_multi SYMLINKS 'symlink' '' ' + test_check_ignore "a/symlink" 1 +' + +test_expect_success_multi SYMLINKS 'beyond a symlink' '' ' + test_check_ignore "a/symlink/foo" 128 && + test_stderr "fatal: '\''a/symlink/foo'\'' is beyond a symbolic link" +' + +test_expect_success_multi SYMLINKS 'beyond a symlink from subdirectory' '' ' + ( + cd a && + test_check_ignore "symlink/foo" 128 + ) && + test_stderr "fatal: '\''symlink/foo'\'' is beyond a symbolic link" +' + +############################################################################ +# +# test handling of submodules + +test_expect_success_multi 'submodule' '' ' + test_check_ignore "a/submodule/one" 128 && + test_stderr "fatal: Path '\''a/submodule/one'\'' is in submodule '\''a/submodule'\''" +' + +test_expect_success_multi 'submodule from subdirectory' '' ' + ( + cd a && + test_check_ignore "submodule/one" 128 + ) && + test_stderr "fatal: Path '\''a/submodule/one'\'' is in submodule '\''a/submodule'\''" +' + +############################################################################ +# +# test handling of global ignore files + +test_expect_success 'global ignore not yet enabled' ' + expect_from_stdin <<-\EOF && + .git/info/exclude:7:per-repo per-repo + a/.gitignore:2:*three a/globalthree + .git/info/exclude:7:per-repo a/per-repo + EOF + test_check_ignore "-v globalone per-repo a/globalthree a/per-repo not-ignored a/globaltwo" +' + +test_expect_success 'global ignore' ' + enable_global_excludes && + expect_from_stdin <<-\EOF && + globalone + per-repo + globalthree + a/globalthree + a/per-repo + globaltwo + EOF + test_check_ignore "globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo" +' + +test_expect_success 'global ignore with -v' ' + enable_global_excludes && + expect_from_stdin <<-EOF && + $global_excludes:1:globalone globalone + .git/info/exclude:7:per-repo per-repo + $global_excludes:3:globalthree globalthree + a/.gitignore:2:*three a/globalthree + .git/info/exclude:7:per-repo a/per-repo + $global_excludes:2:!globaltwo globaltwo + EOF + test_check_ignore "-v globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo" +' + +############################################################################ +# +# test --stdin + +cat <<-\EOF >stdin + one + not-ignored + a/one + a/not-ignored + a/b/on + a/b/one + a/b/one one + "a/b/one two" + "a/b/one\"three" + a/b/not-ignored + a/b/two + a/b/twooo + globaltwo + a/globaltwo + a/b/globaltwo + b/globaltwo +EOF +cat <<-\EOF >expected-default + one + a/one + a/b/on + a/b/one + a/b/one one + a/b/one two + "a/b/one\"three" + a/b/two + a/b/twooo + globaltwo + a/globaltwo + a/b/globaltwo + b/globaltwo +EOF +cat <<-EOF >expected-verbose + .gitignore:1:one one + .gitignore:1:one a/one + a/b/.gitignore:8:!on* a/b/on + a/b/.gitignore:8:!on* a/b/one + a/b/.gitignore:8:!on* a/b/one one + a/b/.gitignore:8:!on* a/b/one two + a/b/.gitignore:8:!on* "a/b/one\"three" + a/b/.gitignore:9:!two a/b/two + a/.gitignore:1:two* a/b/twooo + $global_excludes:2:!globaltwo globaltwo + $global_excludes:2:!globaltwo a/globaltwo + $global_excludes:2:!globaltwo a/b/globaltwo + $global_excludes:2:!globaltwo b/globaltwo +EOF + +sed -e 's/^"//' -e 's/\\//' -e 's/"$//' stdin | \ + tr "\n" "\0" >stdin0 +sed -e 's/^"//' -e 's/\\//' -e 's/"$//' expected-default | \ + tr "\n" "\0" >expected-default0 +sed -e 's/ "/ /' -e 's/\\//' -e 's/"$//' expected-verbose | \ + tr ":\t\n" "\0" >expected-verbose0 + +test_expect_success '--stdin' ' + expect_from_stdin <expected-default && + test_check_ignore "--stdin" <stdin +' + +test_expect_success '--stdin -q' ' + expect "" && + test_check_ignore "-q --stdin" <stdin +' + +test_expect_success '--stdin -v' ' + expect_from_stdin <expected-verbose && + test_check_ignore "-v --stdin" <stdin +' + +for opts in '--stdin -z' '-z --stdin' +do + test_expect_success "$opts" " + expect_from_stdin <expected-default0 && + test_check_ignore '$opts' <stdin0 + " + + test_expect_success "$opts -q" " + expect "" && + test_check_ignore '-q $opts' <stdin0 + " + + test_expect_success "$opts -v" " + expect_from_stdin <expected-verbose0 && + test_check_ignore '-v $opts' <stdin0 + " +done + +cat <<-\EOF >stdin + ../one + ../not-ignored + one + not-ignored + b/on + b/one + b/one one + "b/one two" + "b/one\"three" + b/two + b/not-ignored + b/twooo + ../globaltwo + globaltwo + b/globaltwo + ../b/globaltwo +EOF +cat <<-\EOF >expected-default + ../one + one + b/on + b/one + b/one one + b/one two + "b/one\"three" + b/two + b/twooo + ../globaltwo + globaltwo + b/globaltwo + ../b/globaltwo +EOF +cat <<-EOF >expected-verbose + .gitignore:1:one ../one + .gitignore:1:one one + a/b/.gitignore:8:!on* b/on + a/b/.gitignore:8:!on* b/one + a/b/.gitignore:8:!on* b/one one + a/b/.gitignore:8:!on* b/one two + a/b/.gitignore:8:!on* "b/one\"three" + a/b/.gitignore:9:!two b/two + a/.gitignore:1:two* b/twooo + $global_excludes:2:!globaltwo ../globaltwo + $global_excludes:2:!globaltwo globaltwo + $global_excludes:2:!globaltwo b/globaltwo + $global_excludes:2:!globaltwo ../b/globaltwo +EOF + +sed -e 's/^"//' -e 's/\\//' -e 's/"$//' stdin | \ + tr "\n" "\0" >stdin0 +sed -e 's/^"//' -e 's/\\//' -e 's/"$//' expected-default | \ + tr "\n" "\0" >expected-default0 +sed -e 's/ "/ /' -e 's/\\//' -e 's/"$//' expected-verbose | \ + tr ":\t\n" "\0" >expected-verbose0 + +test_expect_success '--stdin from subdirectory' ' + expect_from_stdin <expected-default && + ( + cd a && + test_check_ignore "--stdin" <../stdin + ) +' + +test_expect_success '--stdin from subdirectory with -v' ' + expect_from_stdin <expected-verbose && + ( + cd a && + test_check_ignore "--stdin -v" <../stdin + ) +' + +for opts in '--stdin -z' '-z --stdin' +do + test_expect_success "$opts from subdirectory" ' + expect_from_stdin <expected-default0 && + ( + cd a && + test_check_ignore "'"$opts"'" <../stdin0 + ) + ' + + test_expect_success "$opts from subdirectory with -v" ' + expect_from_stdin <expected-verbose0 && + ( + cd a && + test_check_ignore "'"$opts"' -v" <../stdin0 + ) + ' +done + + +test_done diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index ccb0a3cb61..a8e84d8546 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -397,4 +397,39 @@ test_expect_success 'strip comments, too' ' test -z "$(echo "# comment" | git stripspace -s)" ' +test_expect_success 'strip comments with changed comment char' ' + test ! -z "$(echo "; comment" | git -c core.commentchar=";" stripspace)" && + test -z "$(echo "; comment" | git -c core.commentchar=";" stripspace -s)" +' + +test_expect_success '-c with single line' ' + printf "# foo\n" >expect && + printf "foo" | git stripspace -c >actual && + test_cmp expect actual +' + +test_expect_success '-c with single line followed by empty line' ' + printf "# foo\n#\n" >expect && + printf "foo\n\n" | git stripspace -c >actual && + test_cmp expect actual +' + +test_expect_success '-c with newline only' ' + printf "#\n" >expect && + printf "\n" | git stripspace -c >actual && + test_cmp expect actual +' + +test_expect_success '--comment-lines with single line' ' + printf "# foo\n" >expect && + printf "foo" | git stripspace -c >actual && + test_cmp expect actual +' + +test_expect_success '-c with changed comment char' ' + printf "; foo\n" >expect && + printf "foo" | git -c core.commentchar=";" stripspace -c >actual && + test_cmp expect actual +' + test_done diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 78816d9d93..05d78d22a6 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -29,12 +29,10 @@ test_have_prereq SYMLINKS || if test_have_prereq CASE_INSENSITIVE_FS then test_expect_success "detection of case insensitive filesystem during repo init" ' - test $(git config --bool core.ignorecase) = true ' else test_expect_success "detection of case insensitive filesystem during repo init" ' - test_must_fail git config --bool core.ignorecase >/dev/null || test $(git config --bool core.ignorecase) = false ' @@ -43,20 +41,17 @@ fi if test_have_prereq SYMLINKS then test_expect_success "detection of filesystem w/o symlink support during repo init" ' - test_must_fail git config --bool core.symlinks || test "$(git config --bool core.symlinks)" = true ' else test_expect_success "detection of filesystem w/o symlink support during repo init" ' - v=$(git config --bool core.symlinks) && test "$v" = false ' fi test_expect_success "setup case tests" ' - git config core.ignorecase true && touch camelcase && git add camelcase && @@ -67,29 +62,23 @@ test_expect_success "setup case tests" ' git mv tmp CamelCase && git commit -m "rename" && git checkout -f master - ' $test_case 'rename (case change)' ' - git mv camelcase CamelCase && git commit -m "rename" - ' -$test_case 'merge (case change)' ' - +test_expect_success 'merge (case change)' ' rm -f CamelCase && rm -f camelcase && git reset --hard initial && git merge topic - ' -test_expect_failure 'add (with different case)' ' - +test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' ' git reset --hard initial && rm camelcase && echo 1 >CamelCase && @@ -97,37 +86,30 @@ test_expect_failure 'add (with different case)' ' camel=$(git ls-files | grep -i camelcase) && test $(echo "$camel" | wc -l) = 1 && test "z$(git cat-file blob :$camel)" = z1 - ' test_expect_success "setup unicode normalization tests" ' - - test_create_repo unicode && - cd unicode && - touch "$aumlcdiar" && - git add "$aumlcdiar" && - git commit -m initial && - git tag initial && - git checkout -b topic && - git mv $aumlcdiar tmp && - git mv tmp "$auml" && - git commit -m rename && - git checkout -f master - + test_create_repo unicode && + cd unicode && + touch "$aumlcdiar" && + git add "$aumlcdiar" && + git commit -m initial && + git tag initial && + git checkout -b topic && + git mv $aumlcdiar tmp && + git mv tmp "$auml" && + git commit -m rename && + git checkout -f master ' $test_unicode 'rename (silent unicode normalization)' ' - - git mv "$aumlcdiar" "$auml" && - git commit -m rename - + git mv "$aumlcdiar" "$auml" && + git commit -m rename ' $test_unicode 'merge (silent unicode normalization)' ' - - git reset --hard initial && - git merge topic - + git reset --hard initial && + git merge topic ' test_done diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh index af54c83111..4c37057ddf 100755 --- a/t/t3070-wildmatch.sh +++ b/t/t3070-wildmatch.sh @@ -29,6 +29,18 @@ match() { fi } +pathmatch() { + if [ $1 = 1 ]; then + test_expect_success "pathmatch: match '$2' '$3'" " + test-wildmatch pathmatch '$2' '$3' + " + else + test_expect_success "pathmatch: no match '$2' '$3'" " + ! test-wildmatch pathmatch '$2' '$3' + " + fi +} + # Basic wildmat features match 1 1 foo foo match 0 0 foo bar @@ -191,5 +203,36 @@ match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/ match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*' match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t' match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t' +match 0 x foo '*/*/*' +match 0 x foo/bar '*/*/*' +match 1 x foo/bba/arr '*/*/*' +match 0 x foo/bb/aa/rr '*/*/*' +match 1 x foo/bb/aa/rr '**/**/**' +match 1 x abcXdefXghi '*X*i' +match 0 x ab/cXd/efXg/hi '*X*i' +match 1 x ab/cXd/efXg/hi '*/*X*/*/*i' +match 1 x ab/cXd/efXg/hi '**/*X*/**/*i' + +pathmatch 1 foo foo +pathmatch 0 foo fo +pathmatch 1 foo/bar foo/bar +pathmatch 1 foo/bar 'foo/*' +pathmatch 1 foo/bba/arr 'foo/*' +pathmatch 1 foo/bba/arr 'foo/**' +pathmatch 1 foo/bba/arr 'foo*' +pathmatch 1 foo/bba/arr 'foo**' +pathmatch 1 foo/bba/arr 'foo/*arr' +pathmatch 1 foo/bba/arr 'foo/**arr' +pathmatch 0 foo/bba/arr 'foo/*z' +pathmatch 0 foo/bba/arr 'foo/**z' +pathmatch 1 foo/bar 'foo?bar' +pathmatch 1 foo/bar 'foo[/]bar' +pathmatch 0 foo '*/*/*' +pathmatch 0 foo/bar '*/*/*' +pathmatch 1 foo/bba/arr '*/*/*' +pathmatch 1 foo/bb/aa/rr '*/*/*' +pathmatch 1 abcXdefXghi '*X*i' +pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i' +pathmatch 1 ab/cXd/efXg/hi '*Xg*i' test_done diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 80e6be39d7..f3e0e4a38c 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -73,8 +73,8 @@ test_expect_success \ test_expect_success \ 'git branch -m dumps usage' \ - 'test_expect_code 129 git branch -m 2>err && - test_i18ngrep "[Uu]sage: git branch" err' + 'test_expect_code 128 git branch -m 2>err && + test_i18ngrep "too many branches for a rename operation" err' test_expect_success \ 'git branch -m m m/m should work' \ diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh index f86f4bc5eb..141b0611ea 100755 --- a/t/t3201-branch-contains.sh +++ b/t/t3201-branch-contains.sh @@ -55,6 +55,16 @@ test_expect_success 'branch --contains=side' ' ' +test_expect_success 'branch --contains with pattern implies --list' ' + + git branch --contains=master master >actual && + { + echo " master" + } >expect && + test_cmp expect actual + +' + test_expect_success 'side: branch --merged' ' git branch --merged >actual && @@ -66,6 +76,16 @@ test_expect_success 'side: branch --merged' ' ' +test_expect_success 'branch --merged with pattern implies --list' ' + + git branch --merged=side master >actual && + { + echo " master" + } >expect && + test_cmp expect actual + +' + test_expect_success 'side: branch --no-merged' ' git branch --no-merged >actual && @@ -95,4 +115,19 @@ test_expect_success 'master: branch --no-merged' ' ' +test_expect_success 'branch --no-merged with pattern implies --list' ' + + git branch --no-merged=master master >actual && + >expect && + test_cmp expect actual + +' + +test_expect_success 'implicit --list conflicts with modification options' ' + + test_must_fail git branch --contains=master -d && + test_must_fail git branch --contains=master -m foo + +' + test_done diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 40277c77aa..614425adac 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -89,4 +89,28 @@ test_expect_success 'diagnose truncated file' ' grep "diff --cc file" out ' +test_expect_success 'setup for --cc --raw' ' + blob=$(echo file | git hash-object --stdin -w) && + base_tree=$(echo "100644 blob $blob file" | git mktree) && + trees= && + for i in `test_seq 1 40` + do + blob=$(echo file$i | git hash-object --stdin -w) && + trees="$trees$(echo "100644 blob $blob file" | git mktree)$LF" + done +' + +test_expect_success 'check --cc --raw with four trees' ' + four_trees=$(echo "$trees" | sed -e 4q) && + git diff --cc --raw $four_trees $base_tree >out && + # Check for four leading colons in the output: + grep "^::::[^:]" out +' + +test_expect_success 'check --cc --raw with forty trees' ' + git diff --cc --raw $trees $base_tree >out && + # Check for forty leading colons in the output: + grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out +' + test_done diff --git a/t/t4042-diff-textconv-caching.sh b/t/t4042-diff-textconv-caching.sh index 91f8198f05..04a44d5c61 100755 --- a/t/t4042-diff-textconv-caching.sh +++ b/t/t4042-diff-textconv-caching.sh @@ -106,4 +106,12 @@ test_expect_success 'switching diff driver produces correct results' ' test_cmp expect actual ' +# The point here is to test that we can log the notes cache and still use it to +# produce a diff later (older versions of git would segfault on this). It's +# much more likely to come up in the real world with "log --all -p", but using +# --no-walk lets us reliably reproduce the order of traversal. +test_expect_success 'log notes cache and still use cache for -p' ' + git log --no-walk -p refs/notes/textconv/magic HEAD +' + test_done diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh index 2c482b622b..72300b5f24 100755 --- a/t/t4208-log-magic-pathspec.sh +++ b/t/t4208-log-magic-pathspec.sh @@ -11,11 +11,24 @@ test_expect_success 'setup' ' mkdir sub ' -test_expect_success '"git log :/" should be ambiguous' ' - test_must_fail git log :/ 2>error && +test_expect_success '"git log :/" should not be ambiguous' ' + git log :/ +' + +test_expect_success '"git log :/a" should be ambiguous (applied both rev and worktree)' ' + : >a && + test_must_fail git log :/a 2>error && grep ambiguous error ' +test_expect_success '"git log :/a -- " should not be ambiguous' ' + git log :/a -- +' + +test_expect_success '"git log -- :/a" should not be ambiguous' ' + git log -- :/a +' + test_expect_success '"git log :" should be ambiguous' ' test_must_fail git log : 2>error && grep ambiguous error diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index e7c240fc1f..3fbd366ec3 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -212,7 +212,8 @@ test_expect_success 'git-archive --prefix=olde-' ' test_expect_success 'setup tar filters' ' git config tar.tar.foo.command "tr ab ba" && git config tar.bar.command "tr ab ba" && - git config tar.bar.remote true + git config tar.bar.remote true && + git config tar.invalid baz ' test_expect_success 'archive --list mentions user filter' ' diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 6322e8ade8..354d32c584 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -130,16 +130,25 @@ test_expect_success 'single given branch clone' ' test_must_fail git --git-dir=branch-a/.git rev-parse origin/B ' +test_expect_success 'clone shallow depth 1' ' + git clone --no-single-branch --depth 1 "file://$(pwd)/." shallow0 && + test "`git --git-dir=shallow0/.git rev-list --count HEAD`" = 1 +' + test_expect_success 'clone shallow' ' git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow ' +test_expect_success 'clone shallow depth count' ' + test "`git --git-dir=shallow/.git rev-list --count HEAD`" = 2 +' + test_expect_success 'clone shallow object count' ' ( cd shallow && git count-objects -v ) > count.shallow && - grep "^in-pack: 18" count.shallow + grep "^in-pack: 12" count.shallow ' test_expect_success 'clone shallow object count (part 2)' ' @@ -256,12 +265,36 @@ test_expect_success 'additional simple shallow deepenings' ' ) ' +test_expect_success 'clone shallow depth count' ' + test "`git --git-dir=shallow/.git rev-list --count HEAD`" = 11 +' + test_expect_success 'clone shallow object count' ' ( cd shallow && git count-objects -v ) > count.shallow && - grep "^count: 52" count.shallow + grep "^count: 55" count.shallow +' + +test_expect_success 'fetch --no-shallow on full repo' ' + test_must_fail git fetch --noshallow +' + +test_expect_success 'fetch --depth --no-shallow' ' + ( + cd shallow && + test_must_fail git fetch --depth=1 --noshallow + ) +' + +test_expect_success 'turn shallow to complete repository' ' + ( + cd shallow && + git fetch --unshallow && + ! test -f .git/shallow && + git fsck --full + ) ' test_expect_success 'clone shallow without --no-single-branch' ' @@ -273,7 +306,7 @@ test_expect_success 'clone shallow object count' ' cd shallow2 && git count-objects -v ) > count.shallow2 && - grep "^in-pack: 6" count.shallow2 + grep "^in-pack: 3" count.shallow2 ' test_expect_success 'clone shallow with --branch' ' @@ -281,7 +314,7 @@ test_expect_success 'clone shallow with --branch' ' ' test_expect_success 'clone shallow object count' ' - echo "in-pack: 6" > count3.expected && + echo "in-pack: 3" > count3.expected && GIT_DIR=shallow3/.git git count-objects -v | grep "^in-pack" > count3.actual && test_cmp count3.expected count3.actual @@ -310,7 +343,7 @@ EOF GIT_DIR=shallow6/.git git tag -l >taglist.actual && test_cmp taglist.expected taglist.actual && - echo "in-pack: 7" > count6.expected && + echo "in-pack: 4" > count6.expected && GIT_DIR=shallow6/.git git count-objects -v | grep "^in-pack" > count6.actual && test_cmp count6.expected count6.actual @@ -325,7 +358,7 @@ EOF GIT_DIR=shallow7/.git git tag -l >taglist.actual && test_cmp taglist.expected taglist.actual && - echo "in-pack: 7" > count7.expected && + echo "in-pack: 4" > count7.expected && GIT_DIR=shallow7/.git git count-objects -v | grep "^in-pack" > count7.actual && test_cmp count7.expected count7.actual diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 60093728fe..8f024a08f0 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -950,27 +950,6 @@ test_expect_success 'push requires --force to update lightweight tag' ' ) ' -test_expect_success 'push requires --force to update annotated tag' ' - mk_test heads/master && - mk_child child1 && - mk_child child2 && - ( - cd child1 && - git tag -a -m "message 1" Tag && - git push ../child2 Tag:refs/tmp/Tag && - git push ../child2 Tag:refs/tmp/Tag && - >file1 && - git add file1 && - git commit -m "file1" && - git tag -f -a -m "message 2" Tag && - test_must_fail git push ../child2 Tag:refs/tmp/Tag && - git push --force ../child2 Tag:refs/tmp/Tag && - git tag -f -a -m "message 3" Tag HEAD~ && - test_must_fail git push ../child2 Tag:refs/tmp/Tag && - git push --force ../child2 Tag:refs/tmp/Tag - ) -' - test_expect_success 'push --porcelain' ' mk_empty && echo >.git/foo "To testrepo" && diff --git a/t/t5571-pre-push-hook.sh b/t/t5571-pre-push-hook.sh new file mode 100755 index 0000000000..6f9916a390 --- /dev/null +++ b/t/t5571-pre-push-hook.sh @@ -0,0 +1,131 @@ +#!/bin/sh + +test_description='check pre-push hooks' +. ./test-lib.sh + +# Setup hook that always succeeds +HOOKDIR="$(git rev-parse --git-dir)/hooks" +HOOK="$HOOKDIR/pre-push" +mkdir -p "$HOOKDIR" +write_script "$HOOK" <<EOF +cat >/dev/null +exit 0 +EOF + +test_expect_success 'setup' ' + git config push.default upstream && + git init --bare repo1 && + git remote add parent1 repo1 && + test_commit one && + git push parent1 HEAD:foreign +' +write_script "$HOOK" <<EOF +cat >/dev/null +exit 1 +EOF + +COMMIT1="$(git rev-parse HEAD)" +export COMMIT1 + +test_expect_success 'push with failing hook' ' + test_commit two && + test_must_fail git push parent1 HEAD +' + +test_expect_success '--no-verify bypasses hook' ' + git push --no-verify parent1 HEAD +' + +COMMIT2="$(git rev-parse HEAD)" +export COMMIT2 + +write_script "$HOOK" <<'EOF' +echo "$1" >actual +echo "$2" >>actual +cat >>actual +EOF + +cat >expected <<EOF +parent1 +repo1 +refs/heads/master $COMMIT2 refs/heads/foreign $COMMIT1 +EOF + +test_expect_success 'push with hook' ' + git push parent1 master:foreign && + diff expected actual +' + +test_expect_success 'add a branch' ' + git checkout -b other parent1/foreign && + test_commit three +' + +COMMIT3="$(git rev-parse HEAD)" +export COMMIT3 + +cat >expected <<EOF +parent1 +repo1 +refs/heads/other $COMMIT3 refs/heads/foreign $COMMIT2 +EOF + +test_expect_success 'push to default' ' + git push && + diff expected actual +' + +cat >expected <<EOF +parent1 +repo1 +refs/tags/one $COMMIT1 refs/tags/tag1 $_z40 +HEAD~ $COMMIT2 refs/heads/prev $_z40 +EOF + +test_expect_success 'push non-branches' ' + git push parent1 one:tag1 HEAD~:refs/heads/prev && + diff expected actual +' + +cat >expected <<EOF +parent1 +repo1 +(delete) $_z40 refs/heads/prev $COMMIT2 +EOF + +test_expect_success 'push delete' ' + git push parent1 :prev && + diff expected actual +' + +cat >expected <<EOF +repo1 +repo1 +HEAD $COMMIT3 refs/heads/other $_z40 +EOF + +test_expect_success 'push to URL' ' + git push repo1 HEAD && + diff expected actual +' + +# Test that filling pipe buffers doesn't cause failure +# Too slow to leave enabled for general use +if false +then + printf 'parent1\nrepo1\n' >expected + nr=1000 + while test $nr -lt 2000 + do + nr=$(( $nr + 1 )) + git branch b/$nr $COMMIT3 + echo "refs/heads/b/$nr $COMMIT3 refs/heads/b/$nr $_z40" >>expected + done + + test_expect_success 'push many refs' ' + git push parent1 "refs/heads/b/*:refs/heads/b/*" && + diff expected actual + ' +fi + +test_done diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 1fa2a5fc23..df82ec9dda 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -28,7 +28,8 @@ test_expect_success 'creating initial files and commits' ' echo "1st line 2nd file" >secondfile && echo "2nd line 2nd file" >>secondfile && - git commit -a -m "modify 2nd file" + git commit -a -m "modify 2nd file" && + head5=$(git rev-parse --verify HEAD) ' # git log --pretty=oneline # to see those SHA1 involved @@ -56,7 +57,7 @@ test_expect_success 'giving a non existing revision should fail' ' test_must_fail git reset --mixed aaaaaa && test_must_fail git reset --soft aaaaaa && test_must_fail git reset --hard aaaaaa && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' test_expect_success 'reset --soft with unmerged index should fail' ' @@ -74,7 +75,7 @@ test_expect_success \ test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first && test_must_fail git reset --hard HEAD^ -- first && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' test_expect_success 'giving unrecognized options should fail' ' @@ -86,7 +87,7 @@ test_expect_success 'giving unrecognized options should fail' ' test_must_fail git reset --soft -o && test_must_fail git reset --hard --other && test_must_fail git reset --hard -o && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' test_expect_success \ @@ -110,7 +111,7 @@ test_expect_success \ git checkout master && git branch -D branch1 branch2 && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' test_expect_success \ @@ -133,27 +134,27 @@ test_expect_success \ git checkout master && git branch -D branch3 branch4 && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' test_expect_success \ 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset --hard HEAD && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset --soft && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset --soft HEAD && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset --mixed && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset --mixed HEAD && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git reset HEAD && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' >.diff_expect @@ -176,7 +177,7 @@ test_expect_success '--soft reset only should show changes in diff --cached' ' git reset --soft HEAD^ && check_changes d1a4bc3abce4829628ae2dcb0d60ef3d1a78b1c4 && test "$(git rev-parse ORIG_HEAD)" = \ - 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + $head5 ' >.diff_expect @@ -193,7 +194,7 @@ test_expect_success \ git commit -a -C ORIG_HEAD && check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d && test "$(git rev-parse ORIG_HEAD)" = \ - 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + $head5 ' >.diff_expect @@ -303,7 +304,7 @@ test_expect_success 'redoing the last two commits should succeed' ' echo "1st line 2nd file" >secondfile && echo "2nd line 2nd file" >>secondfile && git commit -a -m "modify 2nd file" && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' >.diff_expect @@ -341,15 +342,15 @@ EOF test_expect_success \ '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' git reset --hard HEAD^ && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git pull . branch1 && git reset --hard ORIG_HEAD && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc && + check_changes $head5 && git checkout master && git branch -D branch1 branch2 && - check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc + check_changes $head5 ' cat > expect << EOF diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh index f919c8d34d..8e32f19007 100755 --- a/t/t7402-submodule-rebase.sh +++ b/t/t7402-submodule-rebase.sh @@ -3,7 +3,7 @@ # Copyright (c) 2008 Johannes Schindelin # -test_description='Test rebasing and stashing with dirty submodules' +test_description='Test rebasing, stashing, etc. with submodules' . ./test-lib.sh @@ -20,7 +20,8 @@ test_expect_success setup ' echo second line >> file && (cd submodule && git pull) && test_tick && - git commit -m file-and-submodule -a + git commit -m file-and-submodule -a && + git branch added-submodule ' @@ -89,4 +90,29 @@ test_expect_success 'stash with a dirty submodule' ' ' +test_expect_success 'rebasing submodule that should conflict' ' + git reset --hard && + git checkout added-submodule && + git add submodule && + test_tick && + git commit -m third && + ( + cd submodule && + git commit --allow-empty -m extra + ) && + git add submodule && + test_tick && + git commit -m fourth && + + test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 && + git ls-files -s submodule >actual && + ( + cd submodule && + echo "160000 $(git rev-parse HEAD^) 1 submodule" && + echo "160000 $(git rev-parse HEAD^^) 2 submodule" && + echo "160000 $(git rev-parse HEAD) 3 submodule" + ) >expect && + test_cmp expect actual +' + test_done diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index b1c7648386..cbd7a45927 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -517,4 +517,11 @@ use_template="-t template" try_commit_status_combo +test_expect_success 'commit --status with custom comment character' ' + test_when_finished "git config --unset core.commentchar" && + git config core.commentchar ";" && + try_commit --status && + test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG +' + test_done diff --git a/t/t7508-status.sh b/t/t7508-status.sh index e313ef196e..a79c032ffd 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1254,6 +1254,56 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary ' cat > expect << EOF +; On branch master +; Changes to be committed: +; (use "git reset HEAD <file>..." to unstage) +; +; modified: sm +; +; Changes not staged for commit: +; (use "git add <file>..." to update what will be committed) +; (use "git checkout -- <file>..." to discard changes in working directory) +; +; modified: dir1/modified +; modified: sm (new commits) +; +; Submodule changes to be committed: +; +; * sm $head...$new_head (1): +; > Add bar +; +; Submodules changed but not updated: +; +; * sm $new_head...$head2 (1): +; > 2nd commit +; +; Untracked files: +; (use "git add <file>..." to include in what will be committed) +; +; .gitmodules +; dir1/untracked +; dir2/modified +; dir2/untracked +; expect +; output +; untracked +EOF + +test_expect_success "status (core.commentchar with submodule summary)" ' + test_when_finished "git config --unset core.commentchar" && + git config core.commentchar ";" && + git status >output && + test_i18ncmp expect output +' + +test_expect_success "status (core.commentchar with two chars with submodule summary)" ' + test_when_finished "git config --unset core.commentchar" && + git config core.commentchar ";;" && + git status >output && + test_i18ncmp expect output +' + +cat > expect << EOF # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 749b75e8d4..4fea8d901b 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -306,5 +306,13 @@ test_expect_success 'git-svn works in a bare repository' ' git svn fetch ) && rm -rf bare-repo ' +test_expect_success 'git-svn works in in a repository with a gitdir: link' ' + mkdir worktree gitdir && + ( cd worktree && + git svn init "$svnrepo" && + git init --separate-git-dir ../gitdir && + git svn fetch ) && + rm -rf worktree gitdir + ' test_done diff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh new file mode 100755 index 0000000000..735a018ecc --- /dev/null +++ b/t/t9402-git-cvsserver-refs.sh @@ -0,0 +1,551 @@ +#!/bin/sh + +test_description='git-cvsserver and git refspecs + +tests ability for git-cvsserver to switch between and compare +tags, branches and other git refspecs' + +. ./test-lib.sh + +######### + +check_start_tree() { + rm -f "$WORKDIR/list.expected" + echo "start $1" >>"${WORKDIR}/check.log" +} + +check_file() { + sandbox="$1" + file="$2" + ver="$3" + GIT_DIR=$SERVERDIR git show "${ver}:${file}" \ + >"$WORKDIR/check.got" 2>"$WORKDIR/check.stderr" + test_cmp "$WORKDIR/check.got" "$sandbox/$file" + stat=$? + echo "check_file $sandbox $file $ver : $stat" >>"$WORKDIR/check.log" + echo "$file" >>"$WORKDIR/list.expected" + return $stat +} + +check_end_tree() { + sandbox="$1" && + find "$sandbox" -name CVS -prune -o -type f -print >"$WORKDIR/list.actual" && + sort <"$WORKDIR/list.expected" >expected && + sort <"$WORKDIR/list.actual" | sed -e "s%cvswork/%%" >actual && + test_cmp expected actual && + rm expected actual +} + +check_end_full_tree() { + sandbox="$1" && + sort <"$WORKDIR/list.expected" >expected && + find "$sandbox" -name CVS -prune -o -type f -print | + sed -e "s%$sandbox/%%" | sort >act1 && + test_cmp expected act1 && + git ls-tree --name-only -r "$2" | sort >act2 && + test_cmp expected act2 && + rm expected act1 act2 +} + +######### + +check_diff() { + diffFile="$1" + vOld="$2" + vNew="$3" + rm -rf diffSandbox + git clone -q -n . diffSandbox && + ( + cd diffSandbox && + git checkout "$vOld" && + git apply -p0 --index <"../$diffFile" && + git diff --exit-code "$vNew" + ) >check_diff_apply.out 2>&1 +} + +######### + +cvs >/dev/null 2>&1 +if test $? -ne 1 +then + skip_all='skipping git-cvsserver tests, cvs not found' + test_done +fi +if ! test_have_prereq PERL +then + skip_all='skipping git-cvsserver tests, perl not available' + test_done +fi +"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { + skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' + test_done +} + +unset GIT_DIR GIT_CONFIG +WORKDIR=$(pwd) +SERVERDIR=$(pwd)/gitcvs.git +git_config="$SERVERDIR/config" +CVSROOT=":fork:$SERVERDIR" +CVSWORK="$(pwd)/cvswork" +CVS_SERVER=git-cvsserver +export CVSROOT CVS_SERVER + +rm -rf "$CVSWORK" "$SERVERDIR" +test_expect_success 'setup v1, b1' ' + echo "Simple text file" >textfile.c && + echo "t2" >t2 && + mkdir adir && + echo "adir/afile line1" >adir/afile && + echo "adir/afile line2" >>adir/afile && + echo "adir/afile line3" >>adir/afile && + echo "adir/afile line4" >>adir/afile && + echo "adir/a2file" >>adir/a2file && + mkdir adir/bdir && + echo "adir/bdir/bfile line 1" >adir/bdir/bfile && + echo "adir/bdir/bfile line 2" >>adir/bdir/bfile && + echo "adir/bdir/b2file" >adir/bdir/b2file && + git add textfile.c t2 adir && + git commit -q -m "First Commit (v1)" && + git tag v1 && + git branch b1 && + git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && + GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && + GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" +' + +rm -rf cvswork +test_expect_success 'cvs co v1' ' + cvs -f -Q co -r v1 -d cvswork master >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_tree cvswork +' + +rm -rf cvswork +test_expect_success 'cvs co b1' ' + cvs -f co -r b1 -d cvswork master >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_tree cvswork +' + +test_expect_success 'cvs co b1 [cvswork3]' ' + cvs -f co -r b1 -d cvswork3 master >cvs.log 2>&1 && + check_start_tree cvswork3 && + check_file cvswork3 textfile.c v1 && + check_file cvswork3 t2 v1 && + check_file cvswork3 adir/afile v1 && + check_file cvswork3 adir/a2file v1 && + check_file cvswork3 adir/bdir/bfile v1 && + check_file cvswork3 adir/bdir/b2file v1 && + check_end_full_tree cvswork3 v1 +' + +test_expect_success 'edit cvswork3 and save diff' ' + ( + cd cvswork3 && + sed -e "s/line1/line1 - data/" adir/afile >adir/afileNEW && + mv -f adir/afileNEW adir/afile && + echo "afile5" >adir/afile5 && + rm t2 && + cvs -f add adir/afile5 && + cvs -f rm t2 && + ! cvs -f diff -N -u >"$WORKDIR/cvswork3edit.diff" + ) +' + +test_expect_success 'setup v1.2 on b1' ' + git checkout b1 && + echo "new v1.2" >t3 && + rm t2 && + sed -e "s/line3/line3 - more data/" adir/afile >adir/afileNEW && + mv -f adir/afileNEW adir/afile && + rm adir/a2file && + echo "a3file" >>adir/a3file && + echo "bfile line 3" >>adir/bdir/bfile && + rm adir/bdir/b2file && + echo "b3file" >adir/bdir/b3file && + mkdir cdir && + echo "cdir/cfile" >cdir/cfile && + git add -A cdir adir t3 t2 && + git commit -q -m 'v1.2' && + git tag v1.2 && + git push --tags gitcvs.git b1:b1 +' + +test_expect_success 'cvs -f up (on b1 adir)' ' + ( cd cvswork/adir && cvs -f up -d ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1.2 && + check_file cvswork adir/a3file v1.2 && + check_file cvswork adir/bdir/bfile v1.2 && + check_file cvswork adir/bdir/b3file v1.2 && + check_end_tree cvswork +' + +test_expect_success 'cvs up (on b1 /)' ' + ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1.2 && + check_file cvswork t3 v1.2 && + check_file cvswork adir/afile v1.2 && + check_file cvswork adir/a3file v1.2 && + check_file cvswork adir/bdir/bfile v1.2 && + check_file cvswork adir/bdir/b3file v1.2 && + check_file cvswork cdir/cfile v1.2 && + check_end_tree cvswork +' + +# Make sure "CVS/Tag" files didn't get messed up: +test_expect_success 'cvs up (on b1 /) (again; check CVS/Tag files)' ' + ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1.2 && + check_file cvswork t3 v1.2 && + check_file cvswork adir/afile v1.2 && + check_file cvswork adir/a3file v1.2 && + check_file cvswork adir/bdir/bfile v1.2 && + check_file cvswork adir/bdir/b3file v1.2 && + check_file cvswork cdir/cfile v1.2 && + check_end_tree cvswork +' + +# update to another version: +test_expect_success 'cvs up -r v1' ' + ( cd cvswork && cvs -f up -r v1 ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_tree cvswork +' + +test_expect_success 'cvs up' ' + ( cd cvswork && cvs -f up ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_tree cvswork +' + +test_expect_success 'cvs up (again; check CVS/Tag files)' ' + ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_tree cvswork +' + +test_expect_success 'setup simple b2' ' + git branch b2 v1 && + git push --tags gitcvs.git b2:b2 +' + +test_expect_success 'cvs co b2 [into cvswork2]' ' + cvs -f co -r b2 -d cvswork2 master >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_tree cvswork +' + +test_expect_success 'root dir edit [cvswork2]' ' + ( + cd cvswork2 && echo "Line 2" >>textfile.c && + ! cvs -f diff -u >"$WORKDIR/cvsEdit1.diff" && + cvs -f commit -m "edit textfile.c" textfile.c + ) >cvsEdit1.log 2>&1 +' + +test_expect_success 'root dir rm file [cvswork2]' ' + ( + cd cvswork2 && + cvs -f rm -f t2 && + cvs -f diff -u >../cvsEdit2-empty.diff && + ! cvs -f diff -N -u >"$WORKDIR/cvsEdit2-N.diff" && + cvs -f commit -m "rm t2" + ) >cvsEdit2.log 2>&1 +' + +test_expect_success 'subdir edit/add/rm files [cvswork2]' ' + ( + cd cvswork2 && + sed -e "s/line 1/line 1 (v2)/" adir/bdir/bfile >adir/bdir/bfileNEW && + mv -f adir/bdir/bfileNEW adir/bdir/bfile && + rm adir/bdir/b2file && + cd adir && + cvs -f rm bdir/b2file && + echo "4th file" >bdir/b4file && + cvs -f add bdir/b4file && + ! cvs -f diff -N -u >"$WORKDIR/cvsEdit3.diff" && + git fetch gitcvs.git b2:b2 && + ( + cd .. && + ! cvs -f diff -u -N -r v1.2 >"$WORKDIR/cvsEdit3-v1.2.diff" && + ! cvs -f diff -u -N -r v1.2 -r v1 >"$WORKDIR/cvsEdit3-v1.2-v1.diff" + ) && + cvs -f commit -m "various add/rm/edit" + ) >cvs.log 2>&1 +' + +test_expect_success 'validate result of edits [cvswork2]' ' + git fetch gitcvs.git b2:b2 && + git tag v2 b2 && + git push --tags gitcvs.git b2:b2 && + check_start_tree cvswork2 && + check_file cvswork2 textfile.c v2 && + check_file cvswork2 adir/afile v2 && + check_file cvswork2 adir/a2file v2 && + check_file cvswork2 adir/bdir/bfile v2 && + check_file cvswork2 adir/bdir/b4file v2 && + check_end_full_tree cvswork2 v2 +' + +test_expect_success 'validate basic diffs saved during above cvswork2 edits' ' + test $(grep Index: cvsEdit1.diff | wc -l) = 1 && + test ! -s cvsEdit2-empty.diff && + test $(grep Index: cvsEdit2-N.diff | wc -l) = 1 && + test $(grep Index: cvsEdit3.diff | wc -l) = 3 && + rm -rf diffSandbox && + git clone -q -n . diffSandbox && + ( + cd diffSandbox && + git checkout v1 && + git apply -p0 --index <"$WORKDIR/cvsEdit1.diff" && + git apply -p0 --index <"$WORKDIR/cvsEdit2-N.diff" && + git apply -p0 --directory=adir --index <"$WORKDIR/cvsEdit3.diff" && + git diff --exit-code v2 + ) >"check_diff_apply.out" 2>&1 +' + +test_expect_success 'validate v1.2 diff saved during last cvswork2 edit' ' + test $(grep Index: cvsEdit3-v1.2.diff | wc -l) = 9 && + check_diff cvsEdit3-v1.2.diff v1.2 v2 +' + +test_expect_success 'validate v1.2 v1 diff saved during last cvswork2 edit' ' + test $(grep Index: cvsEdit3-v1.2-v1.diff | wc -l) = 9 && + check_diff cvsEdit3-v1.2-v1.diff v1.2 v1 +' + +test_expect_success 'cvs up [cvswork2]' ' + ( cd cvswork2 && cvs -f up ) >cvs.log 2>&1 && + check_start_tree cvswork2 && + check_file cvswork2 textfile.c v2 && + check_file cvswork2 adir/afile v2 && + check_file cvswork2 adir/a2file v2 && + check_file cvswork2 adir/bdir/bfile v2 && + check_file cvswork2 adir/bdir/b4file v2 && + check_end_full_tree cvswork2 v2 +' + +test_expect_success 'cvs up -r b2 [back to cvswork]' ' + ( cd cvswork && cvs -f up -r b2 ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v2 && + check_file cvswork adir/afile v2 && + check_file cvswork adir/a2file v2 && + check_file cvswork adir/bdir/bfile v2 && + check_file cvswork adir/bdir/b4file v2 && + check_end_full_tree cvswork v2 +' + +test_expect_success 'cvs up -r b1' ' + ( cd cvswork && cvs -f up -r b1 ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1.2 && + check_file cvswork t3 v1.2 && + check_file cvswork adir/afile v1.2 && + check_file cvswork adir/a3file v1.2 && + check_file cvswork adir/bdir/bfile v1.2 && + check_file cvswork adir/bdir/b3file v1.2 && + check_file cvswork cdir/cfile v1.2 && + check_end_full_tree cvswork v1.2 +' + +test_expect_success 'cvs up -A' ' + ( cd cvswork && cvs -f up -A ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_full_tree cvswork v1 +' + +test_expect_success 'cvs up (check CVS/Tag files)' ' + ( cd cvswork && cvs -f up ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_full_tree cvswork v1 +' + +# This is not really legal CVS, but it seems to work anyway: +test_expect_success 'cvs up -r heads/b1' ' + ( cd cvswork && cvs -f up -r heads/b1 ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1.2 && + check_file cvswork t3 v1.2 && + check_file cvswork adir/afile v1.2 && + check_file cvswork adir/a3file v1.2 && + check_file cvswork adir/bdir/bfile v1.2 && + check_file cvswork adir/bdir/b3file v1.2 && + check_file cvswork cdir/cfile v1.2 && + check_end_full_tree cvswork v1.2 +' + +# But this should work even if CVS client checks -r more carefully: +test_expect_success 'cvs up -r heads_-s-b2 (cvsserver escape mechanism)' ' + ( cd cvswork && cvs -f up -r heads_-s-b2 ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v2 && + check_file cvswork adir/afile v2 && + check_file cvswork adir/a2file v2 && + check_file cvswork adir/bdir/bfile v2 && + check_file cvswork adir/bdir/b4file v2 && + check_end_full_tree cvswork v2 +' + +v1hash=$(git rev-parse v1) +test_expect_success 'cvs up -r $(git rev-parse v1)' ' + test -n "$v1hash" && + ( cd cvswork && cvs -f up -r "$v1hash" ) >cvs.log 2>&1 && + check_start_tree cvswork && + check_file cvswork textfile.c v1 && + check_file cvswork t2 v1 && + check_file cvswork adir/afile v1 && + check_file cvswork adir/a2file v1 && + check_file cvswork adir/bdir/bfile v1 && + check_file cvswork adir/bdir/b2file v1 && + check_end_full_tree cvswork v1 +' + +test_expect_success 'cvs diff -r v1 -u' ' + ( cd cvswork && cvs -f diff -r v1 -u ) >cvsDiff.out 2>cvs.log && + test ! -s cvsDiff.out && + test ! -s cvs.log +' + +test_expect_success 'cvs diff -N -r v2 -u' ' + ( cd cvswork && ! cvs -f diff -N -r v2 -u ) >cvsDiff.out 2>cvs.log && + test ! -s cvs.log && + test -s cvsDiff.out && + check_diff cvsDiff.out v2 v1 >check_diff.out 2>&1 +' + +test_expect_success 'cvs diff -N -r v2 -r v1.2' ' + ( cd cvswork && ! cvs -f diff -N -r v2 -r v1.2 -u ) >cvsDiff.out 2>cvs.log && + test ! -s cvs.log && + test -s cvsDiff.out && + check_diff cvsDiff.out v2 v1.2 >check_diff.out 2>&1 +' + +test_expect_success 'apply early [cvswork3] diff to b3' ' + git clone -q . gitwork3 && + ( + cd gitwork3 && + git checkout -b b3 v1 && + git apply -p0 --index <"$WORKDIR/cvswork3edit.diff" && + git commit -m "cvswork3 edits applied" + ) && + git fetch gitwork3 b3:b3 && + git tag v3 b3 +' + +test_expect_success 'check [cvswork3] diff' ' + ( cd cvswork3 && ! cvs -f diff -N -u ) >"$WORKDIR/cvsDiff.out" 2>cvs.log && + test ! -s cvs.log && + test -s cvsDiff.out && + test $(grep Index: cvsDiff.out | wc -l) = 3 && + test_cmp cvsDiff.out cvswork3edit.diff && + check_diff cvsDiff.out v1 v3 >check_diff.out 2>&1 +' + +test_expect_success 'merge early [cvswork3] b3 with b1' ' + ( cd gitwork3 && git merge "message" HEAD b1 ) && + git fetch gitwork3 b3:b3 && + git tag v3merged b3 && + git push --tags gitcvs.git b3:b3 +' + +# This test would fail if cvsserver properly created a ".#afile"* file +# for the merge. +# TODO: Validate that the .# file was saved properly, and then +# delete/ignore it when checking the tree. +test_expect_success 'cvs up dirty [cvswork3]' ' + ( + cd cvswork3 && + cvs -f up && + ! cvs -f diff -N -u >"$WORKDIR/cvsDiff.out" + ) >cvs.log 2>&1 && + test -s cvsDiff.out && + test $(grep Index: cvsDiff.out | wc -l) = 2 && + check_start_tree cvswork3 && + check_file cvswork3 textfile.c v3merged && + check_file cvswork3 t3 v3merged && + check_file cvswork3 adir/afile v3merged && + check_file cvswork3 adir/a3file v3merged && + check_file cvswork3 adir/afile5 v3merged && + check_file cvswork3 adir/bdir/bfile v3merged && + check_file cvswork3 adir/bdir/b3file v3merged && + check_file cvswork3 cdir/cfile v3merged && + check_end_full_tree cvswork3 v3merged +' + +# TODO: test cvs status + +test_expect_success 'cvs commit [cvswork3]' ' + ( + cd cvswork3 && + cvs -f commit -m "dirty sandbox after auto-merge" + ) >cvs.log 2>&1 && + check_start_tree cvswork3 && + check_file cvswork3 textfile.c v3merged && + check_file cvswork3 t3 v3merged && + check_file cvswork3 adir/afile v3merged && + check_file cvswork3 adir/a3file v3merged && + check_file cvswork3 adir/afile5 v3merged && + check_file cvswork3 adir/bdir/bfile v3merged && + check_file cvswork3 adir/bdir/b3file v3merged && + check_file cvswork3 cdir/cfile v3merged && + check_end_full_tree cvswork3 v3merged && + git fetch gitcvs.git b3:b4 && + git tag v4.1 b4 && + git diff --exit-code v4.1 v3merged >check_diff_apply.out 2>&1 +' + +test_done diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh index 166e75209f..665607c9cb 100755 --- a/t/t9800-git-p4-basic.sh +++ b/t/t9800-git-p4-basic.sh @@ -30,6 +30,11 @@ test_expect_success 'basic git p4 clone' ' ) ' +test_expect_success 'depot typo error' ' + test_must_fail git p4 clone --dest="$git" /depot 2>errs && + grep "Depot paths must start with" errs +' + test_expect_success 'git p4 clone @all' ' git p4 clone --dest="$git" //depot@all && test_when_finished cleanup_git && diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh index 21924dfd7d..eeefa67904 100755 --- a/t/t9802-git-p4-filetype.sh +++ b/t/t9802-git-p4-filetype.sh @@ -8,6 +8,123 @@ test_expect_success 'start p4d' ' start_p4d ' +# +# This series of tests checks newline handling Both p4 and +# git store newlines as \n, and have options to choose how +# newlines appear in checked-out files. +# +test_expect_success 'p4 client newlines, unix' ' + ( + cd "$cli" && + p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i && + printf "unix\ncrlf\n" >f-unix && + printf "unix\r\ncrlf\r\n" >f-unix-as-crlf && + p4 add -t text f-unix && + p4 submit -d f-unix && + + # LineEnd: unix; should be no change after sync + cp f-unix f-unix-orig && + p4 sync -f && + test_cmp f-unix-orig f-unix && + + # make sure stored in repo as unix newlines + # use sed to eat python-appened newline + p4 -G print //depot/f-unix | marshal_dump data 2 |\ + sed \$d >f-unix-p4-print && + test_cmp f-unix-orig f-unix-p4-print && + + # switch to win, make sure lf -> crlf + p4 client -o | sed "/LineEnd/s/:.*/:win/" | p4 client -i && + p4 sync -f && + test_cmp f-unix-as-crlf f-unix + ) +' + +test_expect_success 'p4 client newlines, win' ' + ( + cd "$cli" && + p4 client -o | sed "/LineEnd/s/:.*/:win/" | p4 client -i && + printf "win\r\ncrlf\r\n" >f-win && + printf "win\ncrlf\n" >f-win-as-lf && + p4 add -t text f-win && + p4 submit -d f-win && + + # LineEnd: win; should be no change after sync + cp f-win f-win-orig && + p4 sync -f && + test_cmp f-win-orig f-win && + + # make sure stored in repo as unix newlines + # use sed to eat python-appened newline + p4 -G print //depot/f-win | marshal_dump data 2 |\ + sed \$d >f-win-p4-print && + test_cmp f-win-as-lf f-win-p4-print && + + # switch to unix, make sure lf -> crlf + p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i && + p4 sync -f && + test_cmp f-win-as-lf f-win + ) +' + +test_expect_success 'ensure blobs store only lf newlines' ' + test_when_finished cleanup_git && + ( + cd "$git" && + git init && + git p4 sync //depot@all && + + # verify the files in .git are stored only with newlines + o=$(git ls-tree p4/master -- f-unix | cut -f1 | cut -d\ -f3) && + git cat-file blob $o >f-unix-blob && + test_cmp "$cli"/f-unix-orig f-unix-blob && + + o=$(git ls-tree p4/master -- f-win | cut -f1 | cut -d\ -f3) && + git cat-file blob $o >f-win-blob && + test_cmp "$cli"/f-win-as-lf f-win-blob && + + rm f-unix-blob f-win-blob + ) +' + +test_expect_success 'gitattributes setting eol=lf produces lf newlines' ' + test_when_finished cleanup_git && + ( + # checkout the files and make sure core.eol works as planned + cd "$git" && + git init && + echo "* eol=lf" >.gitattributes && + git p4 sync //depot@all && + git checkout master && + test_cmp "$cli"/f-unix-orig f-unix && + test_cmp "$cli"/f-win-as-lf f-win + ) +' + +test_expect_success 'gitattributes setting eol=crlf produces crlf newlines' ' + test_when_finished cleanup_git && + ( + # checkout the files and make sure core.eol works as planned + cd "$git" && + git init && + echo "* eol=crlf" >.gitattributes && + git p4 sync //depot@all && + git checkout master && + test_cmp "$cli"/f-unix-as-crlf f-unix && + test_cmp "$cli"/f-win-orig f-win + ) +' + +test_expect_success 'crlf cleanup' ' + ( + cd "$cli" && + rm f-unix-orig f-unix-as-crlf && + rm f-win-orig f-win-as-lf && + p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i && + p4 sync -f + ) +' + test_expect_success 'utf-16 file create' ' ( cd "$cli" && @@ -105,12 +222,13 @@ build_gendouble() { cat >gendouble.py <<-\EOF import sys import struct - import array - s = array.array("c", '\0' * 26) - struct.pack_into(">L", s, 0, 0x00051607) # AppleDouble - struct.pack_into(">L", s, 4, 0x00020000) # version 2 - s.tofile(sys.stdout) + s = struct.pack(">LL18s", + 0x00051607, # AppleDouble + 0x00020000, # version 2 + "" # pad to 26 bytes + ) + sys.stdout.write(s) EOF } diff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh index 4f077eeca8..254d428b73 100755 --- a/t/t9806-git-p4-options.sh +++ b/t/t9806-git-p4-options.sh @@ -214,40 +214,33 @@ test_expect_success 'clone --use-client-spec' ' exec >/dev/null && test_must_fail git p4 clone --dest="$git" --use-client-spec ) && - cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") && + # build a different client + cli2="$TRASH_DIRECTORY/cli2" && mkdir -p "$cli2" && test_when_finished "rmdir \"$cli2\"" && - ( - cd "$cli2" && - p4 client -i <<-EOF - Client: client2 - Description: client2 - Root: $cli2 - View: //depot/sub/... //client2/bus/... - EOF - ) && test_when_finished cleanup_git && ( + # group P4CLIENT and cli changes in a sub-shell P4CLIENT=client2 && - git p4 clone --dest="$git" --use-client-spec //depot/... - ) && - ( - cd "$git" && - test_path_is_file bus/dir/f4 && - test_path_is_missing file1 - ) && - cleanup_git && - - # same thing again, this time with variable instead of option - ( - cd "$git" && - git init && - git config git-p4.useClientSpec true && - P4CLIENT=client2 && - git p4 sync //depot/... && - git checkout -b master p4/master && - test_path_is_file bus/dir/f4 && - test_path_is_missing file1 + cli="$cli2" && + client_view "//depot/sub/... //client2/bus/..." && + git p4 clone --dest="$git" --use-client-spec //depot/... && + ( + cd "$git" && + test_path_is_file bus/dir/f4 && + test_path_is_missing file1 + ) && + cleanup_git && + # same thing again, this time with variable instead of option + ( + cd "$git" && + git init && + git config git-p4.useClientSpec true && + git p4 sync //depot/... && + git checkout -b master p4/master && + test_path_is_file bus/dir/f4 && + test_path_is_missing file1 + ) ) ' diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh index 0ae048f29f..1fb7bc7cf9 100755 --- a/t/t9807-git-p4-submit.sh +++ b/t/t9807-git-p4-submit.sh @@ -17,6 +17,16 @@ test_expect_success 'init depot' ' ) ' +test_expect_failure 'is_cli_file_writeable function' ' + ( + cd "$cli" && + echo a >a && + is_cli_file_writeable a && + ! is_cli_file_writeable file1 && + rm a + ) +' + test_expect_success 'submit with no client dir' ' test_when_finished cleanup_git && git p4 clone --dest="$git" //depot && @@ -200,7 +210,7 @@ test_expect_success 'submit copy' ' ( cd "$cli" && test_path_is_file file5.ta && - test ! -w file5.ta + ! is_cli_file_writeable file5.ta ) ' @@ -219,7 +229,7 @@ test_expect_success 'submit rename' ' cd "$cli" && test_path_is_missing file6.t && test_path_is_file file6.ta && - test ! -w file6.ta + ! is_cli_file_writeable file6.ta ) ' diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh index 281be29174..77f63492d9 100755 --- a/t/t9809-git-p4-client-view.sh +++ b/t/t9809-git-p4-client-view.sh @@ -196,7 +196,7 @@ test_expect_success 'exclusion single file' ' test_expect_success 'overlay wildcard' ' client_view "//depot/dir1/... //client/cli/..." \ - "+//depot/dir2/... //client/cli/...\n" && + "+//depot/dir2/... //client/cli/..." && files="cli/file11 cli/file12 cli/file21 cli/file22" && client_verify $files && test_when_finished cleanup_git && @@ -333,7 +333,7 @@ test_expect_success 'subdir clone, submit copy' ' ( cd "$cli" && test_path_is_file dir1/file11a && - test ! -w dir1/file11a + ! is_cli_file_writeable dir1/file11a ) ' @@ -353,7 +353,7 @@ test_expect_success 'subdir clone, submit rename' ' cd "$cli" && test_path_is_missing dir1/file13 && test_path_is_file dir1/file13a && - test ! -w dir1/file13a + ! is_cli_file_writeable dir1/file13a ) ' @@ -365,7 +365,10 @@ test_expect_success 'wildcard files submit back to p4, client-spec case' ' ( cd "$git" && echo git-wild-hash >dir1/git-wild#hash && - echo git-wild-star >dir1/git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + echo git-wild-star >dir1/git-wild\*star + fi && echo git-wild-at >dir1/git-wild@at && echo git-wild-percent >dir1/git-wild%percent && git add dir1/git-wild* && @@ -376,7 +379,10 @@ test_expect_success 'wildcard files submit back to p4, client-spec case' ' ( cd "$cli" && test_path_is_file dir1/git-wild#hash && - test_path_is_file dir1/git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + test_path_is_file dir1/git-wild\*star + fi && test_path_is_file dir1/git-wild@at && test_path_is_file dir1/git-wild%percent ) && diff --git a/t/t9812-git-p4-wildcards.sh b/t/t9812-git-p4-wildcards.sh index 143d413057..67633257f3 100755 --- a/t/t9812-git-p4-wildcards.sh +++ b/t/t9812-git-p4-wildcards.sh @@ -14,7 +14,10 @@ test_expect_success 'add p4 files with wildcards in the names' ' printf "file2\nhas\nsome\nrandom\ntext\n" >file2 && p4 add file2 && echo file-wild-hash >file-wild#hash && - echo file-wild-star >file-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + echo file-wild-star >file-wild\*star + fi && echo file-wild-at >file-wild@at && echo file-wild-percent >file-wild%percent && p4 add -f file-wild* && @@ -28,7 +31,10 @@ test_expect_success 'wildcard files git p4 clone' ' ( cd "$git" && test -f file-wild#hash && - test -f file-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + test -f file-wild\*star + fi && test -f file-wild@at && test -f file-wild%percent ) @@ -40,7 +46,10 @@ test_expect_success 'wildcard files submit back to p4, add' ' ( cd "$git" && echo git-wild-hash >git-wild#hash && - echo git-wild-star >git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + echo git-wild-star >git-wild\*star + fi && echo git-wild-at >git-wild@at && echo git-wild-percent >git-wild%percent && git add git-wild* && @@ -51,7 +60,10 @@ test_expect_success 'wildcard files submit back to p4, add' ' ( cd "$cli" && test_path_is_file git-wild#hash && - test_path_is_file git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + test_path_is_file git-wild\*star + fi && test_path_is_file git-wild@at && test_path_is_file git-wild%percent ) @@ -63,7 +75,10 @@ test_expect_success 'wildcard files submit back to p4, modify' ' ( cd "$git" && echo new-line >>git-wild#hash && - echo new-line >>git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + echo new-line >>git-wild\*star + fi && echo new-line >>git-wild@at && echo new-line >>git-wild%percent && git add git-wild* && @@ -74,7 +89,10 @@ test_expect_success 'wildcard files submit back to p4, modify' ' ( cd "$cli" && test_line_count = 2 git-wild#hash && - test_line_count = 2 git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + test_line_count = 2 git-wild\*star + fi && test_line_count = 2 git-wild@at && test_line_count = 2 git-wild%percent ) @@ -87,7 +105,7 @@ test_expect_success 'wildcard files submit back to p4, copy' ' cd "$git" && cp file2 git-wild-cp#hash && git add git-wild-cp#hash && - cp git-wild\*star file-wild-3 && + cp git-wild#hash file-wild-3 && git add file-wild-3 && git commit -m "wildcard copies" && git config git-p4.detectCopies true && @@ -134,7 +152,10 @@ test_expect_success 'wildcard files submit back to p4, delete' ' ( cd "$cli" && test_path_is_missing git-wild#hash && - test_path_is_missing git-wild\*star && + if test_have_prereq NOT_MINGW NOT_CYGWIN + then + test_path_is_missing git-wild\*star + fi && test_path_is_missing git-wild@at && test_path_is_missing git-wild%percent ) diff --git a/t/t9815-git-p4-submit-fail.sh b/t/t9815-git-p4-submit-fail.sh index d2b7b3d98d..1243d96092 100755 --- a/t/t9815-git-p4-submit-fail.sh +++ b/t/t9815-git-p4-submit-fail.sh @@ -405,8 +405,8 @@ test_expect_success 'cleanup chmod after submit cancel' ' git p4 clone --dest="$git" //depot && ( cd "$git" && - chmod u+x text && - chmod u-x text+x && + test_chmod +x text && + test_chmod -x text+x && git add text text+x && git commit -m "chmod texts" && echo n | test_expect_code 1 git p4 submit @@ -415,10 +415,13 @@ test_expect_success 'cleanup chmod after submit cancel' ' cd "$cli" && test_path_is_file text && ! p4 fstat -T action text && - stat --format=%A text | egrep ^-r-- && test_path_is_file text+x && ! p4 fstat -T action text+x && - stat --format=%A text+x | egrep ^-r-x + if test_have_prereq NOT_CYGWIN + then + stat --format=%A text | egrep ^-r-- && + stat --format=%A text+x | egrep ^-r-x + fi ) ' diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 3cd53f87fb..adc1372b3c 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -13,6 +13,25 @@ complete () return 0 } +# Be careful when updating this list: +# +# (1) The build tree may have build artifact from different branch, or +# the user's $PATH may have a random executable that may begin +# with "git-check" that are not part of the subcommands this build +# will ship, e.g. "check-ignore". The tests for completion for +# subcommand names tests how "check" is expanded; we limit the +# possible candidates to "checkout" and "check-attr" to make sure +# "check-attr", which is known by the filter function as a +# subcommand to be thrown out, while excluding other random files +# that happen to begin with "check" to avoid letting them get in +# the way. +# +# (2) A test makes sure that common subcommands are included in the +# completion for "git <TAB>", and a plumbing is excluded. "add", +# "filter-branch" and "ls-files" are listed for this. + +GIT_TESTING_COMMAND_COMPLETION='add checkout check-attr filter-branch ls-files' + . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" # We don't need this function to actually join words or do anything special. @@ -196,7 +215,6 @@ test_expect_success 'general options plus command' ' test_completion "git --paginate check" "checkout " && test_completion "git --git-dir=foo check" "checkout " && test_completion "git --bare check" "checkout " && - test_completion "git --help des" "describe " && test_completion "git --exec-path=foo check" "checkout " && test_completion "git --html-path check" "checkout " && test_completion "git --no-pager check" "checkout " && @@ -207,6 +225,11 @@ test_expect_success 'general options plus command' ' test_completion "git --no-replace-objects check" "checkout " ' +test_expect_success 'git --help completion' ' + test_completion "git --help ad" "add " && + test_completion "git --help core" "core-tutorial " +' + test_expect_success 'setup for ref completion' ' echo content >file1 && echo more >file2 && diff --git a/t/test-lib.sh b/t/test-lib.sh index 1a6c4ab08c..9e7f6b424d 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -666,12 +666,14 @@ case $(uname -s) in # backslashes in pathspec are converted to '/' # exec does not inherit the PID test_set_prereq MINGW + test_set_prereq NOT_CYGWIN test_set_prereq SED_STRIPS_CR ;; *CYGWIN*) test_set_prereq POSIXPERM test_set_prereq EXECKEEPSPID test_set_prereq NOT_MINGW + test_set_prereq CYGWIN test_set_prereq SED_STRIPS_CR ;; *) @@ -679,6 +681,7 @@ case $(uname -s) in test_set_prereq BSLASHPSPEC test_set_prereq EXECKEEPSPID test_set_prereq NOT_MINGW + test_set_prereq NOT_CYGWIN ;; esac diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample new file mode 100644 index 0000000000..15ab6d8e7e --- /dev/null +++ b/templates/hooks--pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# <local ref> <local sha1> <remote ref> <remote sha1> +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +IFS=' ' +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/test-wildmatch.c b/test-wildmatch.c index e384c8edb1..a3e2643fbc 100644 --- a/test-wildmatch.c +++ b/test-wildmatch.c @@ -1,9 +1,85 @@ +#ifdef USE_WILDMATCH +#undef USE_WILDMATCH /* We need real fnmatch implementation here */ +#endif #include "cache.h" #include "wildmatch.h" +static int perf(int ac, char **av) +{ + struct timeval tv1, tv2; + struct stat st; + int fd, i, n, flags1 = 0, flags2 = 0; + char *buffer, *p; + uint32_t usec1, usec2; + const char *lang; + const char *file = av[0]; + const char *pattern = av[1]; + + lang = getenv("LANG"); + if (lang && strcmp(lang, "C")) + die("Please test it on C locale."); + + if ((fd = open(file, O_RDONLY)) == -1 || fstat(fd, &st)) + die_errno("file open"); + + buffer = xmalloc(st.st_size + 2); + if (read(fd, buffer, st.st_size) != st.st_size) + die_errno("read"); + + buffer[st.st_size] = '\0'; + buffer[st.st_size + 1] = '\0'; + for (i = 0; i < st.st_size; i++) + if (buffer[i] == '\n') + buffer[i] = '\0'; + + n = atoi(av[2]); + if (av[3] && !strcmp(av[3], "pathname")) { + flags1 = WM_PATHNAME; + flags2 = FNM_PATHNAME; + } + + gettimeofday(&tv1, NULL); + for (i = 0; i < n; i++) { + for (p = buffer; *p; p += strlen(p) + 1) + wildmatch(pattern, p, flags1, NULL); + } + gettimeofday(&tv2, NULL); + + usec1 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec; + usec1 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec; + printf("wildmatch %ds %dus\n", + (int)(usec1 / 1000000), + (int)(usec1 % 1000000)); + + gettimeofday(&tv1, NULL); + for (i = 0; i < n; i++) { + for (p = buffer; *p; p += strlen(p) + 1) + fnmatch(pattern, p, flags2); + } + gettimeofday(&tv2, NULL); + + usec2 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec; + usec2 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec; + if (usec2 > usec1) + printf("fnmatch %ds %dus or %.2f%% slower\n", + (int)((usec2 - usec1) / 1000000), + (int)((usec2 - usec1) % 1000000), + (float)(usec2 - usec1) / usec1 * 100); + else + printf("fnmatch %ds %dus or %.2f%% faster\n", + (int)((usec1 - usec2) / 1000000), + (int)((usec1 - usec2) % 1000000), + (float)(usec1 - usec2) / usec1 * 100); + return 0; +} + int main(int argc, char **argv) { int i; + + if (!strcmp(argv[1], "perf")) + return perf(argc - 2, argv + 2); + for (i = 2; i < argc; i++) { if (argv[i][0] == '/') die("Forward slash is not allowed at the beginning of the\n" @@ -12,9 +88,11 @@ int main(int argc, char **argv) argv[i] += 3; } if (!strcmp(argv[1], "wildmatch")) - return !!wildmatch(argv[3], argv[2], 0); + return !!wildmatch(argv[3], argv[2], WM_PATHNAME, NULL); else if (!strcmp(argv[1], "iwildmatch")) - return !!wildmatch(argv[3], argv[2], FNM_CASEFOLD); + return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL); + else if (!strcmp(argv[1], "pathmatch")) + return !!wildmatch(argv[3], argv[2], 0, NULL); else if (!strcmp(argv[1], "fnmatch")) return !!fnmatch(argv[3], argv[2], FNM_PATHNAME); else diff --git a/transport-helper.c b/transport-helper.c index 965b778cb3..cb3ef7d38e 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -666,6 +666,16 @@ static void push_update_ref_status(struct strbuf *buf, free(msg); msg = NULL; } + else if (!strcmp(msg, "fetch first")) { + status = REF_STATUS_REJECT_FETCH_FIRST; + free(msg); + msg = NULL; + } + else if (!strcmp(msg, "needs force")) { + status = REF_STATUS_REJECT_NEEDS_FORCE; + free(msg); + msg = NULL; + } } if (*ref) diff --git a/transport.c b/transport.c index 2673d273ff..886ffd8b1e 100644 --- a/transport.c +++ b/transport.c @@ -659,7 +659,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain) const char *msg; strcpy(quickref, status_abbrev(ref->old_sha1)); - if (ref->requires_force) { + if (ref->forced_update) { strcat(quickref, "..."); type = '+'; msg = "forced update"; @@ -699,6 +699,14 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count, i print_ref_status('!', "[rejected]", ref, ref->peer_ref, "already exists", porcelain); break; + case REF_STATUS_REJECT_FETCH_FIRST: + print_ref_status('!', "[rejected]", ref, ref->peer_ref, + "fetch first", porcelain); + break; + case REF_STATUS_REJECT_NEEDS_FORCE: + print_ref_status('!', "[rejected]", ref, ref->peer_ref, + "needs force", porcelain); + break; case REF_STATUS_REMOTE_REJECT: print_ref_status('!', "[remote rejected]", ref, ref->deletion ? NULL : ref->peer_ref, @@ -744,12 +752,16 @@ void transport_print_push_status(const char *dest, struct ref *refs, ref->status != REF_STATUS_OK) n += print_one_push_status(ref, dest, n, porcelain); if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD) { - if (!strcmp(head, ref->name)) + if (head != NULL && !strcmp(head, ref->name)) *reject_reasons |= REJECT_NON_FF_HEAD; else *reject_reasons |= REJECT_NON_FF_OTHER; } else if (ref->status == REF_STATUS_REJECT_ALREADY_EXISTS) { *reject_reasons |= REJECT_ALREADY_EXISTS; + } else if (ref->status == REF_STATUS_REJECT_FETCH_FIRST) { + *reject_reasons |= REJECT_FETCH_FIRST; + } else if (ref->status == REF_STATUS_REJECT_NEEDS_FORCE) { + *reject_reasons |= REJECT_NEEDS_FORCE; } } } @@ -1034,6 +1046,62 @@ static void die_with_unpushed_submodules(struct string_list *needs_pushing) die("Aborting."); } +static int run_pre_push_hook(struct transport *transport, + struct ref *remote_refs) +{ + int ret = 0, x; + struct ref *r; + struct child_process proc; + struct strbuf buf; + const char *argv[4]; + + if (!(argv[0] = find_hook("pre-push"))) + return 0; + + argv[1] = transport->remote->name; + argv[2] = transport->url; + argv[3] = NULL; + + memset(&proc, 0, sizeof(proc)); + proc.argv = argv; + proc.in = -1; + + if (start_command(&proc)) { + finish_command(&proc); + return -1; + } + + strbuf_init(&buf, 256); + + for (r = remote_refs; r; r = r->next) { + if (!r->peer_ref) continue; + if (r->status == REF_STATUS_REJECT_NONFASTFORWARD) continue; + if (r->status == REF_STATUS_UPTODATE) continue; + + strbuf_reset(&buf); + strbuf_addf( &buf, "%s %s %s %s\n", + r->peer_ref->name, sha1_to_hex(r->new_sha1), + r->name, sha1_to_hex(r->old_sha1)); + + if (write_in_full(proc.in, buf.buf, buf.len) != buf.len) { + ret = -1; + break; + } + } + + strbuf_release(&buf); + + x = close(proc.in); + if (!ret) + ret = x; + + x = finish_command(&proc); + if (!ret) + ret = x; + + return ret; +} + int transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags, unsigned int *reject_reasons) @@ -1074,6 +1142,10 @@ int transport_push(struct transport *transport, flags & TRANSPORT_PUSH_MIRROR, flags & TRANSPORT_PUSH_FORCE); + if (!(flags & TRANSPORT_PUSH_NO_HOOK)) + if (run_pre_push_hook(transport, remote_refs)) + return -1; + if ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) && !is_bare_repository()) { struct ref *ref = remote_refs; for (; ref; ref = ref->next) diff --git a/transport.h b/transport.h index bfd2df5823..a3450e97c0 100644 --- a/transport.h +++ b/transport.h @@ -104,6 +104,7 @@ struct transport { #define TRANSPORT_RECURSE_SUBMODULES_CHECK 64 #define TRANSPORT_PUSH_PRUNE 128 #define TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND 256 +#define TRANSPORT_PUSH_NO_HOOK 512 #define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3) #define TRANSPORT_SUMMARY(x) (int)(TRANSPORT_SUMMARY_WIDTH + strlen(x) - gettext_width(x)), (x) @@ -143,6 +144,8 @@ void transport_set_verbosity(struct transport *transport, int verbosity, #define REJECT_NON_FF_HEAD 0x01 #define REJECT_NON_FF_OTHER 0x02 #define REJECT_ALREADY_EXISTS 0x04 +#define REJECT_FETCH_FIRST 0x08 +#define REJECT_NEEDS_FORCE 0x10 int transport_push(struct transport *connection, int refspec_nr, const char **refspec, int flags, diff --git a/unpack-trees.c b/unpack-trees.c index 0e1a196ace..09e53df3b2 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1020,7 +1020,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options if (!core_apply_sparse_checkout || !o->update) o->skip_sparse_checkout = 1; if (!o->skip_sparse_checkout) { - if (add_excludes_from_file_to_list(git_path("info/sparse-checkout"), "", 0, NULL, &el, 0) < 0) + if (add_excludes_from_file_to_list(git_path("info/sparse-checkout"), "", 0, &el, 0) < 0) o->skip_sparse_checkout = 1; else o->el = ⪙ diff --git a/upload-pack.c b/upload-pack.c index 95d83135ae..7c05b15e68 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -672,10 +672,17 @@ static void receive_needs(void) if (depth == 0 && shallows.nr == 0) return; if (depth > 0) { - struct commit_list *result, *backup; + struct commit_list *result = NULL, *backup = NULL; int i; - backup = result = get_shallow_commits(&want_obj, depth, - SHALLOW, NOT_SHALLOW); + if (depth == INFINITE_DEPTH) + for (i = 0; i < shallows.nr; i++) { + struct object *object = shallows.objects[i].item; + object->flags |= NOT_SHALLOW; + } + else + backup = result = + get_shallow_commits(&want_obj, depth, + SHALLOW, NOT_SHALLOW); while (result) { struct object *object = &result->item->object; if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) { diff --git a/userdiff.c b/userdiff.c index ed958ef6b8..ea43a0306f 100644 --- a/userdiff.c +++ b/userdiff.c @@ -184,35 +184,6 @@ static struct userdiff_driver *userdiff_find_by_namelen(const char *k, int len) return NULL; } -static struct userdiff_driver *parse_driver(const char *var, - const char *value, const char *type) -{ - struct userdiff_driver *drv; - const char *dot; - const char *name; - int namelen; - - if (prefixcmp(var, "diff.")) - return NULL; - dot = strrchr(var, '.'); - if (dot == var + 4) - return NULL; - if (strcmp(type, dot+1)) - return NULL; - - name = var + 5; - namelen = dot - name; - drv = userdiff_find_by_namelen(name, namelen); - if (!drv) { - ALLOC_GROW(drivers, ndrivers+1, drivers_alloc); - drv = &drivers[ndrivers++]; - memset(drv, 0, sizeof(*drv)); - drv->name = xmemdupz(name, namelen); - drv->binary = -1; - } - return drv; -} - static int parse_funcname(struct userdiff_funcname *f, const char *k, const char *v, int cflags) { @@ -240,20 +211,34 @@ static int parse_bool(int *b, const char *k, const char *v) int userdiff_config(const char *k, const char *v) { struct userdiff_driver *drv; + const char *name, *type; + int namelen; + + if (parse_config_key(k, "diff", &name, &namelen, &type) || !name) + return 0; + + drv = userdiff_find_by_namelen(name, namelen); + if (!drv) { + ALLOC_GROW(drivers, ndrivers+1, drivers_alloc); + drv = &drivers[ndrivers++]; + memset(drv, 0, sizeof(*drv)); + drv->name = xmemdupz(name, namelen); + drv->binary = -1; + } - if ((drv = parse_driver(k, v, "funcname"))) + if (!strcmp(type, "funcname")) return parse_funcname(&drv->funcname, k, v, 0); - if ((drv = parse_driver(k, v, "xfuncname"))) + if (!strcmp(type, "xfuncname")) return parse_funcname(&drv->funcname, k, v, REG_EXTENDED); - if ((drv = parse_driver(k, v, "binary"))) + if (!strcmp(type, "binary")) return parse_tristate(&drv->binary, k, v); - if ((drv = parse_driver(k, v, "command"))) + if (!strcmp(type, "command")) return git_config_string(&drv->external, k, v); - if ((drv = parse_driver(k, v, "textconv"))) + if (!strcmp(type, "textconv")) return git_config_string(&drv->textconv, k, v); - if ((drv = parse_driver(k, v, "cachetextconv"))) + if (!strcmp(type, "cachetextconv")) return parse_bool(&drv->textconv_want_cache, k, v); - if ((drv = parse_driver(k, v, "wordregex"))) + if (!strcmp(type, "wordregex")) return git_config_string(&drv->word_regex, k, v); return 0; diff --git a/wildmatch.c b/wildmatch.c index 2d3ed84364..7192bdc1b8 100644 --- a/wildmatch.c +++ b/wildmatch.c @@ -18,9 +18,6 @@ typedef unsigned char uchar; #define NEGATE_CLASS '!' #define NEGATE_CLASS2 '^' -#define FALSE 0 -#define TRUE 1 - #define CC_EQ(class, len, litmatch) ((len) == sizeof (litmatch)-1 \ && *(class) == *(litmatch) \ && strncmp((char*)class, litmatch, len) == 0) @@ -55,7 +52,7 @@ typedef unsigned char uchar; #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c)) /* Match pattern "p" against "text" */ -static int dowild(const uchar *p, const uchar *text, int force_lower_case) +static int dowild(const uchar *p, const uchar *text, unsigned int flags) { uchar p_ch; const uchar *pattern = p; @@ -64,10 +61,10 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case) int matched, match_slash, negated; uchar t_ch, prev_ch; if ((t_ch = *text) == '\0' && p_ch != '*') - return ABORT_ALL; - if (force_lower_case && ISUPPER(t_ch)) + return WM_ABORT_ALL; + if ((flags & WM_CASEFOLD) && ISUPPER(t_ch)) t_ch = tolower(t_ch); - if (force_lower_case && ISUPPER(p_ch)) + if ((flags & WM_CASEFOLD) && ISUPPER(p_ch)) p_ch = tolower(p_ch); switch (p_ch) { case '\\': @@ -77,18 +74,21 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case) /* FALLTHROUGH */ default: if (t_ch != p_ch) - return NOMATCH; + return WM_NOMATCH; continue; case '?': /* Match anything but '/'. */ - if (t_ch == '/') - return NOMATCH; + if ((flags & WM_PATHNAME) && t_ch == '/') + return WM_NOMATCH; continue; case '*': if (*++p == '*') { const uchar *prev_p = p - 2; while (*++p == '*') {} - if ((prev_p < pattern || *prev_p == '/') && + if (!(flags & WM_PATHNAME)) + /* without WM_PATHNAME, '*' == '**' */ + match_slash = 1; + else if ((prev_p < pattern || *prev_p == '/') && (*p == '\0' || *p == '/' || (p[0] == '\\' && p[1] == '/'))) { /* @@ -101,135 +101,172 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case) * both foo/bar and foo/a/bar. */ if (p[0] == '/' && - dowild(p + 1, text, force_lower_case) == MATCH) - return MATCH; - match_slash = TRUE; + dowild(p + 1, text, flags) == WM_MATCH) + return WM_MATCH; + match_slash = 1; } else - return ABORT_MALFORMED; + return WM_ABORT_MALFORMED; } else - match_slash = FALSE; + /* without WM_PATHNAME, '*' == '**' */ + match_slash = flags & WM_PATHNAME ? 0 : 1; if (*p == '\0') { /* Trailing "**" matches everything. Trailing "*" matches * only if there are no more slash characters. */ if (!match_slash) { if (strchr((char*)text, '/') != NULL) - return NOMATCH; + return WM_NOMATCH; } - return MATCH; + return WM_MATCH; + } else if (!match_slash && *p == '/') { + /* + * _one_ asterisk followed by a slash + * with WM_PATHNAME matches the next + * directory + */ + const char *slash = strchr((char*)text, '/'); + if (!slash) + return WM_NOMATCH; + text = (const uchar*)slash; + /* the slash is consumed by the top-level for loop */ + break; } while (1) { if (t_ch == '\0') break; - if ((matched = dowild(p, text, force_lower_case)) != NOMATCH) { - if (!match_slash || matched != ABORT_TO_STARSTAR) + /* + * Try to advance faster when an asterisk is + * followed by a literal. We know in this case + * that the the string before the literal + * must belong to "*". + * If match_slash is false, do not look past + * the first slash as it cannot belong to '*'. + */ + if (!is_glob_special(*p)) { + p_ch = *p; + if ((flags & WM_CASEFOLD) && ISUPPER(p_ch)) + p_ch = tolower(p_ch); + while ((t_ch = *text) != '\0' && + (match_slash || t_ch != '/')) { + if ((flags & WM_CASEFOLD) && ISUPPER(t_ch)) + t_ch = tolower(t_ch); + if (t_ch == p_ch) + break; + text++; + } + if (t_ch != p_ch) + return WM_NOMATCH; + } + if ((matched = dowild(p, text, flags)) != WM_NOMATCH) { + if (!match_slash || matched != WM_ABORT_TO_STARSTAR) return matched; } else if (!match_slash && t_ch == '/') - return ABORT_TO_STARSTAR; + return WM_ABORT_TO_STARSTAR; t_ch = *++text; } - return ABORT_ALL; + return WM_ABORT_ALL; case '[': p_ch = *++p; #ifdef NEGATE_CLASS2 if (p_ch == NEGATE_CLASS2) p_ch = NEGATE_CLASS; #endif - /* Assign literal TRUE/FALSE because of "matched" comparison. */ - negated = p_ch == NEGATE_CLASS? TRUE : FALSE; + /* Assign literal 1/0 because of "matched" comparison. */ + negated = p_ch == NEGATE_CLASS ? 1 : 0; if (negated) { /* Inverted character class. */ p_ch = *++p; } prev_ch = 0; - matched = FALSE; + matched = 0; do { if (!p_ch) - return ABORT_ALL; + return WM_ABORT_ALL; if (p_ch == '\\') { p_ch = *++p; if (!p_ch) - return ABORT_ALL; + return WM_ABORT_ALL; if (t_ch == p_ch) - matched = TRUE; + matched = 1; } else if (p_ch == '-' && prev_ch && p[1] && p[1] != ']') { p_ch = *++p; if (p_ch == '\\') { p_ch = *++p; if (!p_ch) - return ABORT_ALL; + return WM_ABORT_ALL; } if (t_ch <= p_ch && t_ch >= prev_ch) - matched = TRUE; + matched = 1; p_ch = 0; /* This makes "prev_ch" get set to 0. */ } else if (p_ch == '[' && p[1] == ':') { const uchar *s; int i; for (s = p += 2; (p_ch = *p) && p_ch != ']'; p++) {} /*SHARED ITERATOR*/ if (!p_ch) - return ABORT_ALL; + return WM_ABORT_ALL; i = p - s - 1; if (i < 0 || p[-1] != ':') { /* Didn't find ":]", so treat like a normal set. */ p = s - 2; p_ch = '['; if (t_ch == p_ch) - matched = TRUE; + matched = 1; continue; } if (CC_EQ(s,i, "alnum")) { if (ISALNUM(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "alpha")) { if (ISALPHA(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "blank")) { if (ISBLANK(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "cntrl")) { if (ISCNTRL(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "digit")) { if (ISDIGIT(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "graph")) { if (ISGRAPH(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "lower")) { if (ISLOWER(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "print")) { if (ISPRINT(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "punct")) { if (ISPUNCT(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "space")) { if (ISSPACE(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "upper")) { if (ISUPPER(t_ch)) - matched = TRUE; + matched = 1; } else if (CC_EQ(s,i, "xdigit")) { if (ISXDIGIT(t_ch)) - matched = TRUE; + matched = 1; } else /* malformed [:class:] string */ - return ABORT_ALL; + return WM_ABORT_ALL; p_ch = 0; /* This makes "prev_ch" get set to 0. */ } else if (t_ch == p_ch) - matched = TRUE; + matched = 1; } while (prev_ch = p_ch, (p_ch = *++p) != ']'); - if (matched == negated || t_ch == '/') - return NOMATCH; + if (matched == negated || + ((flags & WM_PATHNAME) && t_ch == '/')) + return WM_NOMATCH; continue; } } - return *text ? NOMATCH : MATCH; + return *text ? WM_NOMATCH : WM_MATCH; } /* Match the "pattern" against the "text" string. */ -int wildmatch(const char *pattern, const char *text, int flags) +int wildmatch(const char *pattern, const char *text, + unsigned int flags, struct wildopts *wo) { - return dowild((const uchar*)pattern, (const uchar*)text, - flags & FNM_CASEFOLD ? 1 :0); + return dowild((const uchar*)pattern, (const uchar*)text, flags); } diff --git a/wildmatch.h b/wildmatch.h index 984a38cdc2..4090c8f4bb 100644 --- a/wildmatch.h +++ b/wildmatch.h @@ -1,9 +1,18 @@ -/* wildmatch.h */ +#ifndef WILDMATCH_H +#define WILDMATCH_H -#define ABORT_MALFORMED 2 -#define NOMATCH 1 -#define MATCH 0 -#define ABORT_ALL -1 -#define ABORT_TO_STARSTAR -2 +#define WM_CASEFOLD 1 +#define WM_PATHNAME 2 -int wildmatch(const char *pattern, const char *text, int flags); +#define WM_ABORT_MALFORMED 2 +#define WM_NOMATCH 1 +#define WM_MATCH 0 +#define WM_ABORT_ALL -1 +#define WM_ABORT_TO_STARSTAR -2 + +struct wildopts; + +int wildmatch(const char *pattern, const char *text, + unsigned int flags, + struct wildopts *wo); +#endif diff --git a/wt-status.c b/wt-status.c index d7cfe8f31c..aa2734fcbe 100644 --- a/wt-status.c +++ b/wt-status.c @@ -45,7 +45,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color, strbuf_vaddf(&sb, fmt, ap); if (!sb.len) { - strbuf_addch(&sb, '#'); + strbuf_addch(&sb, comment_line_char); if (!trail) strbuf_addch(&sb, ' '); color_print_strbuf(s->fp, color, &sb); @@ -59,7 +59,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color, strbuf_reset(&linebuf); if (at_bol) { - strbuf_addch(&linebuf, '#'); + strbuf_addch(&linebuf, comment_line_char); if (*line != '\n' && *line != '\t') strbuf_addch(&linebuf, ' '); } @@ -762,8 +762,10 @@ static void wt_status_print_tracking(struct wt_status *s) for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1) color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), - "# %.*s", (int)(ep - cp), cp); - color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#"); + "%c %.*s", comment_line_char, + (int)(ep - cp), cp); + color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c", + comment_line_char); } static int has_unmerged(struct wt_status *s) |